From df09ea9bc56060ef50f2366ff43f6ec570c71b8f Mon Sep 17 00:00:00 2001 From: Ger Hobbelt Date: Sun, 15 Nov 2020 13:47:17 +0100 Subject: [PATCH] regenerated library files and updated test references --- dist/cli-cjs-es5.js | 4486 ++++---- dist/cli-cjs.js | 9193 ++++++++-------- dist/cli-es6.js | 9192 ++++++++-------- dist/cli-umd-es5.js | 4488 ++++---- dist/cli-umd.js | 9198 ++++++++--------- dist/jison-cjs-es5.js | 4466 ++++---- dist/jison-cjs.js | 9119 ++++++++-------- dist/jison-es6.js | 9118 ++++++++-------- dist/jison-umd-es5.js | 4468 ++++---- dist/jison-umd.js | 9124 ++++++++-------- .../ebnf-parser/dist/ebnf-parser-cjs-es5.js | 1980 ++-- packages/ebnf-parser/dist/ebnf-parser-cjs.js | 4071 ++++---- packages/ebnf-parser/dist/ebnf-parser-es6.js | 4070 ++++---- .../ebnf-parser/dist/ebnf-parser-umd-es5.js | 1980 ++-- packages/ebnf-parser/dist/ebnf-parser-umd.js | 4078 ++++---- packages/ebnf-parser/parser.js | 1504 ++- .../specs/output/1013-test.jison-ref.json5 | 12 +- .../specs/output/1014-test.jison-ref.json5 | 8 +- .../specs/output/1015-test.jison-ref.json5 | 12 +- .../specs/output/1016-test.jison-ref.json5 | 12 +- .../specs/output/1017-test.jison-ref.json5 | 12 +- .../specs/output/1018-test.jison-ref.json5 | 12 +- .../specs/output/1019-test.jison-ref.json5 | 12 +- .../1013-test.jison-ref.json5 | 12 +- .../1014-test.jison-ref.json5 | 8 +- .../1015-test.jison-ref.json5 | 12 +- .../1016-test.jison-ref.json5 | 12 +- .../1017-test.jison-ref.json5 | 12 +- .../1018-test.jison-ref.json5 | 12 +- .../1019-test.jison-ref.json5 | 12 +- packages/ebnf-parser/transform-parser.js | 893 +- .../helpers-lib/dist/helpers-lib-cjs-es5.js | 611 +- packages/helpers-lib/dist/helpers-lib-cjs.js | 774 +- packages/helpers-lib/dist/helpers-lib-es6.js | 773 +- .../helpers-lib/dist/helpers-lib-umd-es5.js | 613 +- packages/helpers-lib/dist/helpers-lib-umd.js | 781 +- packages/jison-lex/dist/cli-cjs-es5.js | 1838 ++-- packages/jison-lex/dist/cli-cjs.js | 3209 +++--- packages/jison-lex/dist/cli-es6.js | 3208 +++--- packages/jison-lex/dist/cli-umd-es5.js | 1838 ++-- packages/jison-lex/dist/cli-umd.js | 3216 +++--- .../jison-lex/dist/regexp-lexer-cjs-es5.js | 1820 ++-- packages/jison-lex/dist/regexp-lexer-cjs.js | 3175 +++--- packages/jison-lex/dist/regexp-lexer-es6.js | 3174 +++--- .../jison-lex/dist/regexp-lexer-umd-es5.js | 1820 ++-- packages/jison-lex/dist/regexp-lexer-umd.js | 3182 +++--- .../examples/output/basic2_lex.jison-lexer.js | 471 +- .../examples/output/basic_lex.jison-lexer.js | 471 +- .../jison-lex/examples/output/c99.l-lexer.js | 471 +- .../jison-lex/examples/output/c99.l-ref.json5 | 10 +- .../examples/output/ccalc-lex.l-lexer.js | 471 +- .../examples/output/ccalc-lex.l-ref.json5 | 10 +- .../examples/output/classy.jisonlex-lexer.js | 471 +- ...codegen-feature-tester-base.jison-lexer.js | 471 +- .../examples/output/comments.jison-lexer.js | 471 +- .../examples/output/comments.jison-ref.json5 | 10 +- .../output/compiled_calc_parse.jison-lexer.js | 471 +- ...ng-multiple-start-rules-alt.jison-lexer.js | 471 +- .../examples/output/floop.l-lexer.js | 471 +- .../output/handlebars.jison.l-lexer.js | 471 +- .../issue-19-jison_lex-fixed.jison-lexer.js | 471 +- .../issue-19-jison_lex-fixed.jison-ref.json5 | 8 +- .../output/issue-19-jison_lex.jison-lexer.js | 471 +- .../issue-357-url-lexing.jison-lexer.js | 471 +- .../jison-lex/examples/output/lex.l-lexer.js | 471 +- .../jison-lex/examples/output/lex.l-ref.json5 | 10 +- .../output/lex_grammar.jisonlex-lexer.js | 471 +- ...-communication-test-w-debug.jison-lexer.js | 471 +- .../examples/output/pascal.l-lexer.js | 471 +- .../examples/output/pascal.l-ref.json5 | 10 +- .../examples/output/regex.jison-lexer.js | 471 +- .../output/semwhitespace_lex.jison-lexer.js | 471 +- .../output/tikiwikiparser.jison-lexer.js | 471 +- .../examples/output/unicode.jison-lexer.js | 471 +- .../examples/output/unicode.jison-ref.json5 | 10 +- .../examples/output/unicode2.jison-lexer.js | 471 +- .../examples/output/unicode2.jison-ref.json5 | 10 +- .../output/with-includes.jison-lexer.js | 471 +- .../output/with-includes.test.lex-lexer.js | 471 +- .../output/with_custom_lexer.jison-lexer.js | 10 +- .../examples/output/xregexp.jison-lexer.js | 471 +- .../basic2_lex.jison-lexer.js | 471 +- .../reference-output/basic_lex.jison-lexer.js | 471 +- .../examples/reference-output/c99.l-lexer.js | 471 +- .../examples/reference-output/c99.l-ref.json5 | 10 +- .../reference-output/ccalc-lex.l-lexer.js | 471 +- .../reference-output/ccalc-lex.l-ref.json5 | 10 +- .../reference-output/classy.jisonlex-lexer.js | 471 +- ...codegen-feature-tester-base.jison-lexer.js | 471 +- .../reference-output/comments.jison-lexer.js | 471 +- .../reference-output/comments.jison-ref.json5 | 10 +- .../compiled_calc_parse.jison-lexer.js | 471 +- ...ng-multiple-start-rules-alt.jison-lexer.js | 471 +- .../reference-output/floop.l-lexer.js | 471 +- .../handlebars.jison.l-lexer.js | 471 +- .../issue-19-jison_lex-fixed.jison-lexer.js | 471 +- .../issue-19-jison_lex-fixed.jison-ref.json5 | 8 +- .../issue-19-jison_lex.jison-lexer.js | 471 +- .../issue-357-url-lexing.jison-lexer.js | 471 +- .../examples/reference-output/lex.l-lexer.js | 471 +- .../examples/reference-output/lex.l-ref.json5 | 10 +- .../lex_grammar.jisonlex-lexer.js | 471 +- ...-communication-test-w-debug.jison-lexer.js | 471 +- .../reference-output/pascal.l-lexer.js | 471 +- .../reference-output/pascal.l-ref.json5 | 10 +- .../reference-output/regex.jison-lexer.js | 471 +- .../semwhitespace_lex.jison-lexer.js | 471 +- .../tikiwikiparser.jison-lexer.js | 471 +- .../reference-output/unicode.jison-lexer.js | 471 +- .../reference-output/unicode.jison-ref.json5 | 10 +- .../reference-output/unicode2.jison-lexer.js | 471 +- .../reference-output/unicode2.jison-ref.json5 | 10 +- .../with-includes.jison-lexer.js | 471 +- .../with-includes.test.lex-lexer.js | 471 +- .../with_custom_lexer.jison-lexer.js | 10 +- .../reference-output/xregexp.jison-lexer.js | 471 +- .../001-custom-lexer-baseline.jison-lexer.js | 10 +- ...tom-lexer-extra-code-chunks.jison-lexer.js | 10 +- .../output/003-issue-23-alt-good.js-lexer.js | 471 +- .../output/003-issue-23-good.js-lexer.js | 471 +- .../output/003-issue-23-trouble.js-lexer.js | 471 +- ...unspecified-condition-state.jison-lexer.js | 10 +- ...nspecified-condition-state.jison-ref.json5 | 14 +- .../output/005-combined-rules.jison-lexer.js | 471 +- .../006-multiple-action-chunks.jison-lexer.js | 471 +- ...006-multiple-action-chunks.jison-ref.json5 | 10 +- ...action-chunks-with-includes.jison-lexer.js | 471 +- ...ction-chunks-with-includes.jison-ref.json5 | 10 +- ...8-template-string-in-action.jison-lexer.js | 471 +- ...-template-string-in-action.jison-ref.json5 | 10 +- ...9-template-string-in-action.jison-lexer.js | 471 +- ...-template-string-in-action.jison-ref.json5 | 10 +- ...on-code-marker-alternatives.jison-lexer.js | 471 +- ...n-code-marker-alternatives.jison-ref.json5 | 10 +- ...on-code-marker-alternatives.jison-lexer.js | 471 +- ...n-code-marker-alternatives.jison-ref.json5 | 10 +- .../001-custom-lexer-baseline.jison-lexer.js | 10 +- ...tom-lexer-extra-code-chunks.jison-lexer.js | 10 +- .../003-issue-23-alt-good.js-lexer.js | 471 +- .../003-issue-23-good.js-lexer.js | 471 +- .../003-issue-23-trouble.js-lexer.js | 471 +- ...unspecified-condition-state.jison-lexer.js | 10 +- ...nspecified-condition-state.jison-ref.json5 | 14 +- .../005-combined-rules.jison-lexer.js | 471 +- .../006-multiple-action-chunks.jison-lexer.js | 471 +- ...006-multiple-action-chunks.jison-ref.json5 | 10 +- ...action-chunks-with-includes.jison-lexer.js | 471 +- ...ction-chunks-with-includes.jison-ref.json5 | 10 +- ...8-template-string-in-action.jison-lexer.js | 471 +- ...-template-string-in-action.jison-ref.json5 | 10 +- ...9-template-string-in-action.jison-lexer.js | 471 +- ...-template-string-in-action.jison-ref.json5 | 10 +- ...on-code-marker-alternatives.jison-lexer.js | 471 +- ...n-code-marker-alternatives.jison-ref.json5 | 10 +- ...on-code-marker-alternatives.jison-lexer.js | 471 +- ...n-code-marker-alternatives.jison-ref.json5 | 10 +- .../lex-parser/dist/lex-parser-cjs-es5.js | 1815 ++-- packages/lex-parser/dist/lex-parser-cjs.js | 2086 ++-- packages/lex-parser/dist/lex-parser-es6.js | 2085 ++-- .../lex-parser/dist/lex-parser-umd-es5.js | 1817 ++-- packages/lex-parser/dist/lex-parser-umd.js | 2093 ++-- packages/lex-parser/lex-parser.js | 1574 ++- .../specs/output/0014-test.jisonlex-lex.json5 | 14 +- .../specs/output/0014-test.jisonlex-ref.json5 | 22 +- .../specs/output/0015-test.jisonlex-lex.json5 | 14 +- .../specs/output/0015-test.jisonlex-ref.json5 | 22 +- .../specs/output/0016-test.jisonlex-lex.json5 | 14 +- .../specs/output/0016-test.jisonlex-ref.json5 | 22 +- .../specs/output/0017-test.jisonlex-lex.json5 | 14 +- .../specs/output/0017-test.jisonlex-ref.json5 | 22 +- .../specs/output/0018-test.jisonlex-ref.json5 | 12 +- .../specs/output/0023-test.jisonlex-lex.json5 | 14 +- .../specs/output/0023-test.jisonlex-ref.json5 | 22 +- .../specs/output/0029-test.jisonlex-lex.json5 | 14 +- .../specs/output/0029-test.jisonlex-ref.json5 | 22 +- .../specs/output/0031-test.jisonlex-ref.json5 | 12 +- .../0014-test.jisonlex-lex.json5 | 14 +- .../0014-test.jisonlex-ref.json5 | 22 +- .../0015-test.jisonlex-lex.json5 | 14 +- .../0015-test.jisonlex-ref.json5 | 22 +- .../0016-test.jisonlex-lex.json5 | 14 +- .../0016-test.jisonlex-ref.json5 | 22 +- .../0017-test.jisonlex-lex.json5 | 14 +- .../0017-test.jisonlex-ref.json5 | 22 +- .../0018-test.jisonlex-ref.json5 | 12 +- .../0023-test.jisonlex-lex.json5 | 14 +- .../0023-test.jisonlex-ref.json5 | 22 +- .../0029-test.jisonlex-lex.json5 | 14 +- .../0029-test.jisonlex-ref.json5 | 22 +- .../0031-test.jisonlex-ref.json5 | 12 +- 190 files changed, 82634 insertions(+), 85232 deletions(-) diff --git a/dist/cli-cjs-es5.js b/dist/cli-cjs-es5.js index 63aa7bc60..daad5cbd1 100644 --- a/dist/cli-cjs-es5.js +++ b/dist/cli-cjs-es5.js @@ -3,8 +3,18 @@ 'use strict'; +function _templateObject163() { + 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 "]); + + _templateObject163 = function _templateObject163() { + return data; + }; + + return data; +} + function _templateObject162() { - 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 dentical 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 dentical 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 "]); + 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 "]); _templateObject162 = function _templateObject162() { return data; @@ -14,7 +24,7 @@ function _templateObject162() { } function _templateObject161() { - var data = _taggedTemplateLiteral(["\n ", "\n\n var 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 var 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 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 "]); _templateObject161 = function _templateObject161() { return data; @@ -24,7 +34,7 @@ function _templateObject161() { } function _templateObject160() { - 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\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 "]); _templateObject160 = function _templateObject160() { return data; @@ -34,7 +44,7 @@ function _templateObject160() { } function _templateObject159() { - 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 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 "]); _templateObject159 = function _templateObject159() { return data; @@ -44,7 +54,7 @@ function _templateObject159() { } function _templateObject158() { - 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 // 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 "]); _templateObject158 = function _templateObject158() { return data; @@ -54,7 +64,7 @@ function _templateObject158() { } function _templateObject157() { - 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 ", "\n\n let yymain = ", ";\n\n function yyExecMain() {\n yymain(process.argv.slice(1));\n }\n "]); _templateObject157 = function _templateObject157() { return data; @@ -64,7 +74,7 @@ function _templateObject157() { } function _templateObject156() { - var data = _taggedTemplateLiteral(["\n\n ", "\n\n var yymain = ", ";\n\n function yyExecMain() {\n yymain(process.argv.slice(1));\n }\n "]); + var data = _taggedTemplateLiteral(["\n\n // START code section \"", "\"\n ", "\n // END code section \"", "\"\n\n "]); _templateObject156 = function _templateObject156() { return data; @@ -74,7 +84,7 @@ function _templateObject156() { } function _templateObject155() { - var data = _taggedTemplateLiteral(["\n\n // START code section \"", "\"\n ", "\n // END code section \"", "\"\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 "]); _templateObject155 = function _templateObject155() { return data; @@ -84,7 +94,7 @@ function _templateObject155() { } function _templateObject154() { - 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 %%\n\n "]); _templateObject154 = function _templateObject154() { return data; @@ -94,7 +104,7 @@ function _templateObject154() { } function _templateObject153() { - var data = _taggedTemplateLiteral(["\n\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 "]); _templateObject153 = function _templateObject153() { return data; @@ -104,7 +114,7 @@ function _templateObject153() { } function _templateObject152() { - 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 %%\n\n "]); _templateObject152 = function _templateObject152() { return data; @@ -114,7 +124,7 @@ function _templateObject152() { } function _templateObject151() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n /*\n * Parser stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); _templateObject151 = function _templateObject151() { return data; @@ -124,7 +134,7 @@ function _templateObject151() { } function _templateObject150() { - var data = _taggedTemplateLiteral(["\n /*\n * Parser stuff that's unknown to the JISON prettyPrint service:\n *\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 "]); _templateObject150 = function _templateObject150() { return data; @@ -134,7 +144,7 @@ function _templateObject150() { } function _templateObject149() { - 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 // END of unknown declarations.\n "]); _templateObject149 = function _templateObject149() { return data; @@ -144,7 +154,7 @@ function _templateObject149() { } function _templateObject148() { - var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); + var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); _templateObject148 = function _templateObject148() { return data; @@ -154,7 +164,7 @@ function _templateObject148() { } function _templateObject147() { - var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject147 = function _templateObject147() { return data; @@ -174,7 +184,7 @@ function _templateObject146() { } function _templateObject145() { - 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 "]); _templateObject145 = function _templateObject145() { return data; @@ -184,7 +194,7 @@ function _templateObject145() { } function _templateObject144() { - var data = _taggedTemplateLiteral(["\n /*\n * Lexer stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); + var data = _taggedTemplateLiteral(["\n // options:\n "]); _templateObject144 = function _templateObject144() { return data; @@ -194,7 +204,7 @@ function _templateObject144() { } function _templateObject143() { - var data = _taggedTemplateLiteral(["\n // options:\n "]); + var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); _templateObject143 = function _templateObject143() { return data; @@ -204,7 +214,7 @@ function _templateObject143() { } function _templateObject142() { - var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); + var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); _templateObject142 = function _templateObject142() { return data; @@ -214,7 +224,7 @@ function _templateObject142() { } function _templateObject141() { - var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); + var data = _taggedTemplateLiteral(["\n // END of the lexer macros.\n "]); _templateObject141 = function _templateObject141() { return data; @@ -224,7 +234,7 @@ function _templateObject141() { } function _templateObject140() { - var data = _taggedTemplateLiteral(["\n // END of the lexer macros.\n "]); + var data = _taggedTemplateLiteral(["\n // macros:\n "]); _templateObject140 = function _templateObject140() { return data; @@ -234,7 +244,7 @@ function _templateObject140() { } function _templateObject139() { - var data = _taggedTemplateLiteral(["\n // macros:\n "]); + var data = _taggedTemplateLiteral(["\n unsupported parser input: ", "\n while lexing in ", " state.\n \n Erroneous area:\n "]); _templateObject139 = function _templateObject139() { return data; @@ -244,7 +254,7 @@ function _templateObject139() { } function _templateObject138() { - 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 "]); _templateObject138 = function _templateObject138() { return data; @@ -274,7 +284,7 @@ function _templateObject136() { } function _templateObject135() { - 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 "]); _templateObject135 = function _templateObject135() { return data; @@ -304,7 +314,7 @@ function _templateObject133() { } function _templateObject132() { - 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 "]); _templateObject132 = function _templateObject132() { return data; @@ -334,7 +344,7 @@ function _templateObject130() { } function _templateObject129() { - 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 "]); _templateObject129 = function _templateObject129() { return data; @@ -344,7 +354,7 @@ function _templateObject129() { } function _templateObject128() { - var data = _taggedTemplateLiteral(["\n EBNF: ignoring unsupported parser option ", "\n while lexing in ", " state.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n module code declaration error?\n \n Erroneous area:\n "]); _templateObject128 = function _templateObject128() { return data; @@ -354,7 +364,7 @@ function _templateObject128() { } function _templateObject127() { - var data = _taggedTemplateLiteral(["\n module code declaration error?\n \n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n "]); _templateObject127 = function _templateObject127() { return data; @@ -364,7 +374,7 @@ function _templateObject127() { } function _templateObject126() { - var data = _taggedTemplateLiteral(["\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n "]); + var data = _taggedTemplateLiteral(["\n included action code file \"", "\" does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject126 = function _templateObject126() { return data; @@ -374,7 +384,7 @@ function _templateObject126() { } function _templateObject125() { - 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 match curly braces '{ ... }' in a parser rule action block.\n \n Erroneous area:\n ", "\n "]); _templateObject125 = function _templateObject125() { return data; @@ -384,7 +394,7 @@ function _templateObject125() { } function _templateObject124() { - 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 Seems you did not correctly bracket a parser rule action block in curly braces: '{ ... }'.\n \n Erroneous area:\n ", "\n "]); _templateObject124 = function _templateObject124() { return data; @@ -394,7 +404,7 @@ function _templateObject124() { } function _templateObject123() { - 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 %prec precedence override declaration error?\n \n Erroneous precedence declaration:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject123 = function _templateObject123() { return data; @@ -404,7 +414,7 @@ function _templateObject123() { } function _templateObject122() { - 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 Seems you did not correctly bracket a grammar rule sublist in '( ... )' brackets.\n \n Erroneous area:\n ", "\n "]); _templateObject122 = function _templateObject122() { return data; @@ -414,7 +424,7 @@ function _templateObject122() { } function _templateObject121() { - 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 rule action declaration error?\n \n Erroneous area:\n ", "\n "]); _templateObject121 = function _templateObject121() { return data; @@ -424,7 +434,7 @@ function _templateObject121() { } function _templateObject120() { - 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 "]); _templateObject120 = function _templateObject120() { return data; @@ -434,7 +444,7 @@ function _templateObject120() { } function _templateObject119() { - 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 "]); _templateObject119 = function _templateObject119() { return data; @@ -444,7 +454,7 @@ function _templateObject119() { } function _templateObject118() { - 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 action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject118 = function _templateObject118() { return data; @@ -454,7 +464,7 @@ function _templateObject118() { } function _templateObject117() { - var data = _taggedTemplateLiteral(["\n production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n multiple alternative rule productions should be separated by a '|' pipe character, not a ':' colon!\n \n Erroneous area:\n ", "\n "]); _templateObject117 = function _templateObject117() { return data; @@ -464,7 +474,7 @@ function _templateObject117() { } function _templateObject116() { - var data = _taggedTemplateLiteral(["\n multiple alternative rule productions should be separated by a '|' pipe character, not a ':' colon!\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n rule alternative production declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject116 = function _templateObject116() { return data; @@ -474,7 +484,7 @@ function _templateObject116() { } function _templateObject115() { - var data = _taggedTemplateLiteral(["\n rule alternative production declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Production for rule '", "' is missing: arrows introduce action code in Jison.\n \n Jison does not support rule production definition using arrows (->, =>, \u2192) but expects\n colons (:) instead, so maybe you intended this:\n \n ", " : ", "\n \n while the user-defined action code block MAY be an arrow function, e.g.\n \n rule: math_production -> Math.min($math_production, 42);\n \n Erroneous area:\n ", "\n "]); _templateObject115 = function _templateObject115() { return data; @@ -484,7 +494,7 @@ function _templateObject115() { } function _templateObject114() { - var data = _taggedTemplateLiteral(["\n Production for rule '", "' is missing: arrows introduce action code in Jison.\n \n Jison does not support rule production definition using arrows (->, =>, \u2192) but expects\n colons (:) instead, so maybe you intended this:\n \n ", " : ", "\n \n while the user-defined action code block MAY be an arrow function, e.g.\n \n rule: math_production -> Math.min($math_production, 42);\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n rule id should be followed by a colon, but that one seems missing?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject114 = function _templateObject114() { return data; @@ -494,7 +504,7 @@ function _templateObject114() { } function _templateObject113() { - var data = _taggedTemplateLiteral(["\n rule id should be followed by a colon, but that one seems missing?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n rule production declaration error: did you terminate the rule production set with a semicolon?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject113 = function _templateObject113() { return data; @@ -504,7 +514,7 @@ function _templateObject113() { } function _templateObject112() { - var data = _taggedTemplateLiteral(["\n rule production declaration error: did you terminate the rule production set with a semicolon?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n rule production declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject112 = function _templateObject112() { return data; @@ -514,7 +524,7 @@ function _templateObject112() { } function _templateObject111() { - var data = _taggedTemplateLiteral(["\n rule production declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n operator token list error in an associativity statement?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject111 = function _templateObject111() { return data; @@ -524,7 +534,7 @@ function _templateObject111() { } function _templateObject110() { - var data = _taggedTemplateLiteral(["\n operator token list error in an associativity statement?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %parser-type declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject110 = function _templateObject110() { return data; @@ -534,7 +544,7 @@ function _templateObject110() { } function _templateObject109() { - var data = _taggedTemplateLiteral(["\n %parser-type declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %parse-params declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject109 = function _templateObject109() { return data; @@ -544,7 +554,7 @@ function _templateObject109() { } function _templateObject108() { - var data = _taggedTemplateLiteral(["\n %parse-params declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n named %option value assignment error?\n \n Erroneous area:\n ", "\n "]); _templateObject108 = function _templateObject108() { return data; @@ -554,7 +564,7 @@ function _templateObject108() { } function _templateObject107() { - var data = _taggedTemplateLiteral(["\n named %option value assignment error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n named %option value error for ", "?\n \n Erroneous area:\n ", "\n "]); _templateObject107 = function _templateObject107() { return data; @@ -564,7 +574,7 @@ function _templateObject107() { } function _templateObject106() { - var data = _taggedTemplateLiteral(["\n named %option value error for ", "?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %options don't seem terminated?\n \n Erroneous area:\n ", "\n "]); _templateObject106 = function _templateObject106() { return data; @@ -574,7 +584,7 @@ function _templateObject106() { } function _templateObject105() { - var data = _taggedTemplateLiteral(["\n %options don't seem terminated?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %options ill defined / error?\n \n Erroneous area:\n ", "\n "]); _templateObject105 = function _templateObject105() { return data; @@ -584,7 +594,7 @@ function _templateObject105() { } function _templateObject104() { - var data = _taggedTemplateLiteral(["\n %options ill defined / error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %import name or source filename missing maybe?\n \n Erroneous area:\n ", "\n "]); _templateObject104 = function _templateObject104() { return data; @@ -594,7 +604,7 @@ function _templateObject104() { } function _templateObject103() { - var data = _taggedTemplateLiteral(["\n %import name or source filename missing maybe?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %token definition list error?\n \n Erroneous area:\n ", "\n "]); _templateObject103 = function _templateObject103() { return data; @@ -604,7 +614,7 @@ function _templateObject103() { } function _templateObject102() { - var data = _taggedTemplateLiteral(["\n %token definition list error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %start token error?\n \n Erroneous area:\n ", "\n "]); _templateObject102 = function _templateObject102() { return data; @@ -614,7 +624,7 @@ function _templateObject102() { } function _templateObject101() { - var data = _taggedTemplateLiteral(["\n %start token error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Each '%code' initialization code section must be qualified by a name, e.g. 'required' before the action code itself:\n \n %code qualifier_name {action code}\n \n Erroneous area:\n ", "\n "]); _templateObject101 = function _templateObject101() { return data; @@ -624,7 +634,7 @@ function _templateObject101() { } function _templateObject100() { - var data = _taggedTemplateLiteral(["\n Each '%code' initialization code section must be qualified by a name, e.g. 'required' before the action code itself:\n \n %code qualifier_name {action code}\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %code \"", "\" initialization section action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject100 = function _templateObject100() { return data; @@ -634,7 +644,7 @@ function _templateObject100() { } function _templateObject99() { - var data = _taggedTemplateLiteral(["\n %code \"", "\" initialization section action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Each '%import'-ed initialization code section must be qualified by a name, e.g. 'required' before the import path itself:\n \n %import qualifier_name file_path\n \n Erroneous area:\n ", "\n "]); _templateObject99 = function _templateObject99() { return data; @@ -644,7 +654,7 @@ function _templateObject99() { } function _templateObject98() { - var data = _taggedTemplateLiteral(["\n Each '%import'-ed initialization code section must be qualified by a name, e.g. 'required' before the import path itself:\n \n %import qualifier_name file_path\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n You did not specify a legal file path for the '%import' initialization code statement, which must have the format:\n \n %import qualifier_name file_path\n \n Erroneous area:\n ", "\n "]); _templateObject98 = function _templateObject98() { return data; @@ -654,7 +664,7 @@ function _templateObject98() { } function _templateObject97() { - var data = _taggedTemplateLiteral(["\n You did not specify a legal file path for the '%import' initialization code statement, which must have the format:\n \n %import qualifier_name file_path\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n action header code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject97 = function _templateObject97() { return data; @@ -664,7 +674,7 @@ function _templateObject97() { } function _templateObject96() { - var data = _taggedTemplateLiteral(["\n action header code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject96 = function _templateObject96() { return data; @@ -674,7 +684,7 @@ function _templateObject96() { } function _templateObject95() { - var data = _taggedTemplateLiteral(["\n action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n declaration list error?\n \n Erroneous area:\n ", "\n "]); _templateObject95 = function _templateObject95() { return data; @@ -684,7 +694,7 @@ function _templateObject95() { } function _templateObject94() { - var data = _taggedTemplateLiteral(["\n declaration list error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n action header code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject94 = function _templateObject94() { return data; @@ -694,7 +704,7 @@ function _templateObject94() { } function _templateObject93() { - var data = _taggedTemplateLiteral(["\n action header code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n The extra parser module code section (a.k.a. 'epilogue') does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject93 = function _templateObject93() { return data; @@ -704,7 +714,7 @@ function _templateObject93() { } function _templateObject92() { - var data = _taggedTemplateLiteral(["\n The extra parser module code section (a.k.a. 'epilogue') does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Maybe you did not correctly separate the parse 'header section' (token definitions, options, lexer spec, etc.) from the grammar rule set with a '%%' on an otherwise empty line?\n \n Erroneous area:\n ", "\n "]); _templateObject92 = function _templateObject92() { return data; @@ -714,7 +724,7 @@ function _templateObject92() { } function _templateObject91() { - var data = _taggedTemplateLiteral(["\n Maybe you did not correctly separate the parse 'header section' (token definitions, options, lexer spec, etc.) from the grammar rule set with a '%%' on an otherwise empty line?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n illegal input in the parser grammar productions definition section.\n \n Maybe you did not correctly separate trailing code from the grammar rule set with a '%%' marker on an otherwise empty line?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject91 = function _templateObject91() { return data; @@ -724,7 +734,7 @@ function _templateObject91() { } function _templateObject90() { - var data = _taggedTemplateLiteral(["\n illegal input in the parser grammar productions definition section.\n \n Maybe you did not correctly separate trailing code from the grammar rule set with a '%%' marker on an otherwise empty line?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n ", "\n\n var ", " = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n\n if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\n exports.lexer = ", ";\n exports.lex = function () {\n return ", ".lex.apply(lexer, arguments);\n };\n }\n "]); _templateObject90 = function _templateObject90() { return data; @@ -734,7 +744,7 @@ function _templateObject90() { } function _templateObject89() { - var data = _taggedTemplateLiteral(["\n ", "\n\n var ", " = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n\n if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\n exports.lexer = ", ";\n exports.lex = function () {\n return ", ".lex.apply(lexer, arguments);\n };\n }\n "]); + var data = _taggedTemplateLiteral(["\n ", "\n\n const lexer = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n\n function yylex() {\n return lexer.lex.apply(lexer, arguments);\n }\n\n export {\n lexer,\n yylex as lex\n };\n "]); _templateObject89 = function _templateObject89() { return data; @@ -744,7 +754,7 @@ function _templateObject89() { } function _templateObject88() { - var data = _taggedTemplateLiteral(["\n ", "\n\n var lexer = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n\n function yylex() {\n return lexer.lex.apply(lexer, arguments);\n }\n\n export {\n lexer,\n yylex as lex\n };\n "]); + var data = _taggedTemplateLiteral(["\n ", "\n\n define([], function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n });\n "]); _templateObject88 = function _templateObject88() { return data; @@ -754,7 +764,7 @@ function _templateObject88() { } function _templateObject87() { - var data = _taggedTemplateLiteral(["\n ", "\n\n define([], function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n });\n "]); + var data = _taggedTemplateLiteral(["\n ", "\n\n var ", " = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n "]); _templateObject87 = function _templateObject87() { return data; @@ -764,7 +774,7 @@ function _templateObject87() { } function _templateObject86() { - var data = _taggedTemplateLiteral(["\n ", "\n\n var ", " = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n "]); + var data = _taggedTemplateLiteral(["\n /* lexer generated by jison-lex ", " */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" `yy` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This \"shared context\" object was passed to the lexer by way of\n * the `lexer.setInput(str, yy)` API before you may use it.\n *\n * This \"shared context\" object is passed to the lexer action code in `performAction()`\n * so userland code in the lexer actions may communicate with the outside world\n * and/or other lexer rules' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall \"shared context\" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `lexer` instance.\n * `yy_` is an alias for `this` lexer instance reference used internally.\n *\n * - `yy` : a reference to the `yy` \"shared state\" object which was passed to the lexer\n * by way of the `lexer.setInput(str, yy)` API before.\n *\n * Note:\n * The extra arguments you specified in the `%parse-param` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - `yyrulenumber` : index of the matched lexer rule (regex), used internally.\n *\n * - `YY_START`: the current lexer \"start condition\" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.\n * See it's use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo('fail!', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the `lexer.setInput()` API.\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of the **lexer** grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Lexer's additional `args...` parameters (via lexer's `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the **parser** or the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.\n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (`yylloc`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a 'hash' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal \"shared state\" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while `this` will reference the current lexer instance.\n *\n * When `parseError` is invoked by the lexer, the default implementation will\n * attempt to invoke `yy.parser.parseError()`; when this callback is not provided\n * it will try to invoke `yy.parseError()` instead. When that callback is also not\n * provided, a `JisonLexerError` exception will be thrown containing the error\n * message and `hash`, as constructed by the `constructLexErrorInfo()` API.\n *\n * Note that the lexer's `JisonLexerError` error class is passed via the\n * `ExceptionClass` argument, which is invoked to construct the exception\n * instance to be thrown, so technically `parseError` will throw the object\n * produced by the `new ExceptionClass(str, hash)` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the `.options` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n *\n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are \"extended regex format\" requiring the\n * `XRegExp` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n "], ["\n /* lexer generated by jison-lex ", " */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" \\`yy\\` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This \"shared context\" object was passed to the lexer by way of\n * the \\`lexer.setInput(str, yy)\\` API before you may use it.\n *\n * This \"shared context\" object is passed to the lexer action code in \\`performAction()\\`\n * so userland code in the lexer actions may communicate with the outside world\n * and/or other lexer rules' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall \"shared context\" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and \\`this\\` have the following value/meaning:\n * - \\`this\\` : reference to the \\`lexer\\` instance.\n * \\`yy_\\` is an alias for \\`this\\` lexer instance reference used internally.\n *\n * - \\`yy\\` : a reference to the \\`yy\\` \"shared state\" object which was passed to the lexer\n * by way of the \\`lexer.setInput(str, yy)\\` API before.\n *\n * Note:\n * The extra arguments you specified in the \\`%parse-param\\` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - \\`yyrulenumber\\` : index of the matched lexer rule (regex), used internally.\n *\n * - \\`YY_START\\`: the current lexer \"start condition\" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo \\'hash object\\' which can be passed into \\`parseError()\\`.\n * See it\\'s use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo(\\'fail!\\', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the \\`lexer.setInput()\\` API.\n * You MAY use the additional \\`args...\\` parameters as per \\`%parse-param\\` spec of the **lexer** grammar:\n * these extra \\`args...\\` are added verbatim to the \\`yy\\` object reference as member variables.\n *\n * WARNING:\n * Lexer's additional \\`args...\\` parameters (via lexer's \\`%parse-param\\`) MAY conflict with\n * any attributes already added to \\`yy\\` by the **parser** or the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.\n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (\\`yylloc\\`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The \\`parseError\\` function receives a \\'hash\\' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal \"shared state\" \\`yy\\`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while \\`this\\` will reference the current lexer instance.\n *\n * When \\`parseError\\` is invoked by the lexer, the default implementation will\n * attempt to invoke \\`yy.parser.parseError()\\`; when this callback is not provided\n * it will try to invoke \\`yy.parseError()\\` instead. When that callback is also not\n * provided, a \\`JisonLexerError\\` exception will be thrown containing the error\n * message and \\`hash\\`, as constructed by the \\`constructLexErrorInfo()\\` API.\n *\n * Note that the lexer\\'s \\`JisonLexerError\\` error class is passed via the\n * \\`ExceptionClass\\` argument, which is invoked to construct the exception\n * instance to be thrown, so technically \\`parseError\\` will throw the object\n * produced by the \\`new ExceptionClass(str, hash)\\` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the \\`.options\\` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n *\n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default \\`parseError\\` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * \\`this\\` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token \\`token\\`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original \\`token\\`.\n * \\`this\\` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: \\`true\\` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: \\`true\\` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: \\`true\\` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: \\`true\\` ==> lexer rule regexes are \"extended regex format\" requiring the\n * \\`XRegExp\\` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n "]); _templateObject86 = function _templateObject86() { return data; @@ -774,7 +784,7 @@ function _templateObject86() { } function _templateObject85() { - var data = _taggedTemplateLiteral(["\n /* lexer generated by jison-lex ", " */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" `yy` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This \"shared context\" object was passed to the lexer by way of\n * the `lexer.setInput(str, yy)` API before you may use it.\n *\n * This \"shared context\" object is passed to the lexer action code in `performAction()`\n * so userland code in the lexer actions may communicate with the outside world\n * and/or other lexer rules' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall \"shared context\" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `lexer` instance.\n * `yy_` is an alias for `this` lexer instance reference used internally.\n *\n * - `yy` : a reference to the `yy` \"shared state\" object which was passed to the lexer\n * by way of the `lexer.setInput(str, yy)` API before.\n *\n * Note:\n * The extra arguments you specified in the `%parse-param` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - `yyrulenumber` : index of the matched lexer rule (regex), used internally.\n *\n * - `YY_START`: the current lexer \"start condition\" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.\n * See it's use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo('fail!', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the `lexer.setInput()` API.\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of the **lexer** grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Lexer's additional `args...` parameters (via lexer's `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the **parser** or the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.\n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (`yylloc`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a 'hash' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal \"shared state\" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while `this` will reference the current lexer instance.\n *\n * When `parseError` is invoked by the lexer, the default implementation will\n * attempt to invoke `yy.parser.parseError()`; when this callback is not provided\n * it will try to invoke `yy.parseError()` instead. When that callback is also not\n * provided, a `JisonLexerError` exception will be thrown containing the error\n * message and `hash`, as constructed by the `constructLexErrorInfo()` API.\n *\n * Note that the lexer's `JisonLexerError` error class is passed via the\n * `ExceptionClass` argument, which is invoked to construct the exception\n * instance to be thrown, so technically `parseError` will throw the object\n * produced by the `new ExceptionClass(str, hash)` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the `.options` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n *\n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are \"extended regex format\" requiring the\n * `XRegExp` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n "], ["\n /* lexer generated by jison-lex ", " */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" \\`yy\\` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This \"shared context\" object was passed to the lexer by way of\n * the \\`lexer.setInput(str, yy)\\` API before you may use it.\n *\n * This \"shared context\" object is passed to the lexer action code in \\`performAction()\\`\n * so userland code in the lexer actions may communicate with the outside world\n * and/or other lexer rules' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall \"shared context\" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and \\`this\\` have the following value/meaning:\n * - \\`this\\` : reference to the \\`lexer\\` instance.\n * \\`yy_\\` is an alias for \\`this\\` lexer instance reference used internally.\n *\n * - \\`yy\\` : a reference to the \\`yy\\` \"shared state\" object which was passed to the lexer\n * by way of the \\`lexer.setInput(str, yy)\\` API before.\n *\n * Note:\n * The extra arguments you specified in the \\`%parse-param\\` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - \\`yyrulenumber\\` : index of the matched lexer rule (regex), used internally.\n *\n * - \\`YY_START\\`: the current lexer \"start condition\" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo \\'hash object\\' which can be passed into \\`parseError()\\`.\n * See it\\'s use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo(\\'fail!\\', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the \\`lexer.setInput()\\` API.\n * You MAY use the additional \\`args...\\` parameters as per \\`%parse-param\\` spec of the **lexer** grammar:\n * these extra \\`args...\\` are added verbatim to the \\`yy\\` object reference as member variables.\n *\n * WARNING:\n * Lexer's additional \\`args...\\` parameters (via lexer's \\`%parse-param\\`) MAY conflict with\n * any attributes already added to \\`yy\\` by the **parser** or the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.\n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (\\`yylloc\\`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The \\`parseError\\` function receives a \\'hash\\' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal \"shared state\" \\`yy\\`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while \\`this\\` will reference the current lexer instance.\n *\n * When \\`parseError\\` is invoked by the lexer, the default implementation will\n * attempt to invoke \\`yy.parser.parseError()\\`; when this callback is not provided\n * it will try to invoke \\`yy.parseError()\\` instead. When that callback is also not\n * provided, a \\`JisonLexerError\\` exception will be thrown containing the error\n * message and \\`hash\\`, as constructed by the \\`constructLexErrorInfo()\\` API.\n *\n * Note that the lexer\\'s \\`JisonLexerError\\` error class is passed via the\n * \\`ExceptionClass\\` argument, which is invoked to construct the exception\n * instance to be thrown, so technically \\`parseError\\` will throw the object\n * produced by the \\`new ExceptionClass(str, hash)\\` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the \\`.options\\` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n *\n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default \\`parseError\\` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * \\`this\\` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token \\`token\\`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original \\`token\\`.\n * \\`this\\` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: \\`true\\` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: \\`true\\` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: \\`true\\` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: \\`true\\` ==> lexer rule regexes are \"extended regex format\" requiring the\n * \\`XRegExp\\` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n "]); + var data = _taggedTemplateLiteral([",\n JisonLexerError: JisonLexerError,\n performAction: ", ",\n simpleCaseActionClusters: ", ",\n rules: [\n ", "\n ],\n conditions: ", "\n };\n "]); _templateObject85 = function _templateObject85() { return data; @@ -784,7 +794,7 @@ function _templateObject85() { } function _templateObject84() { - var data = _taggedTemplateLiteral([",\n JisonLexerError: JisonLexerError,\n performAction: ", ",\n simpleCaseActionClusters: ", ",\n rules: [\n ", "\n ],\n conditions: ", "\n };\n "]); + var data = _taggedTemplateLiteral(["\n const lexer = {\n "]); _templateObject84 = function _templateObject84() { return data; @@ -794,7 +804,7 @@ function _templateObject84() { } function _templateObject83() { - var data = _taggedTemplateLiteral(["\n var lexer = {\n "]); + var data = _taggedTemplateLiteral(["\n // Code Generator Information Report\n // ---------------------------------\n //\n // Options:\n //\n // backtracking: .................... ", "\n // location.ranges: ................. ", "\n // location line+column tracking: ... ", "\n //\n //\n // Forwarded Parser Analysis flags:\n //\n // uses yyleng: ..................... ", "\n // uses yylineno: ................... ", "\n // uses yytext: ..................... ", "\n // uses yylloc: ..................... ", "\n // uses lexer values: ............... ", " / ", "\n // location tracking: ............... ", "\n // location assignment: ............. ", "\n //\n //\n // Lexer Analysis flags:\n //\n // uses yyleng: ..................... ", "\n // uses yylineno: ................... ", "\n // uses yytext: ..................... ", "\n // uses yylloc: ..................... ", "\n // uses ParseError API: ............. ", "\n // uses yyerror: .................... ", "\n // uses location tracking & editing: ", "\n // uses more() API: ................. ", "\n // uses unput() API: ................ ", "\n // uses reject() API: ............... ", "\n // uses less() API: ................. ", "\n // uses display APIs pastInput(), upcomingInput(), showPosition():\n // ............................. ", "\n // uses describeYYLLOC() API: ....... ", "\n //\n // --------- END OF REPORT -----------\n\n "]); _templateObject83 = function _templateObject83() { return data; @@ -804,7 +814,7 @@ function _templateObject83() { } function _templateObject82() { - var data = _taggedTemplateLiteral(["\n // Code Generator Information Report\n // ---------------------------------\n //\n // Options:\n //\n // backtracking: .................... ", "\n // location.ranges: ................. ", "\n // location line+column tracking: ... ", "\n //\n //\n // Forwarded Parser Analysis flags:\n //\n // uses yyleng: ..................... ", "\n // uses yylineno: ................... ", "\n // uses yytext: ..................... ", "\n // uses yylloc: ..................... ", "\n // uses lexer values: ............... ", " / ", "\n // location tracking: ............... ", "\n // location assignment: ............. ", "\n //\n //\n // Lexer Analysis flags:\n //\n // uses yyleng: ..................... ", "\n // uses yylineno: ................... ", "\n // uses yytext: ..................... ", "\n // uses yylloc: ..................... ", "\n // uses ParseError API: ............. ", "\n // uses yyerror: .................... ", "\n // uses location tracking & editing: ", "\n // uses more() API: ................. ", "\n // uses unput() API: ................ ", "\n // uses reject() API: ............... ", "\n // uses less() API: ................. ", "\n // uses display APIs pastInput(), upcomingInput(), showPosition():\n // ............................. ", "\n // uses describeYYLLOC() API: ....... ", "\n //\n // --------- END OF REPORT -----------\n\n "]); + var data = _taggedTemplateLiteral(["\n stripUnusedLexerCode WARNING: \n\n JISON failed to reformat the generated lexer.\n Using the generated code as-is instead and pray it works in your final output!\n\n Internal error report:\n\n ", "\n\n The offending action code chunk as reported above:\n\n ", "\n "]); _templateObject82 = function _templateObject82() { return data; @@ -814,7 +824,7 @@ function _templateObject82() { } function _templateObject81() { - var data = _taggedTemplateLiteral(["\n stripUnusedLexerCode WARNING: \n\n JISON failed to reformat the generated lexer.\n Using the generated code as-is instead and pray it works in your final output!\n\n Internal error report:\n\n ", "\n\n The offending action code chunk as reported above:\n\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n \"use strict\";\n\n return ", ";\n"]); _templateObject81 = function _templateObject81() { return data; @@ -824,7 +834,7 @@ function _templateObject81() { } function _templateObject80() { - var data = _taggedTemplateLiteral(["\n \"use strict\";\n\n return ", ";\n"]); + var data = _taggedTemplateLiteral(["\n // JISON INJECTED VALIDATION CODE\n // which attempts to ascertain you have defined a minimal viable lexer at least:\n if (typeof lexer === \"undefined\") {\n throw new SyntaxError(\"user-defined lexer does not define the required 'lexer' instance.\");\n }\n if (!lexer) {\n throw new SyntaxError(\"user-defined lexer does not define a non-NULL 'lexer' instance.\");\n }\n if (typeof lexer.setInput !== 'function') {\n throw new SyntaxError(\"user-defined lexer does not provide the mandatory 'lexer.setInput()' API function.\");\n }\n if (typeof lexer.lex !== 'function') {\n throw new SyntaxError(\"user-defined lexer does not provide the mandatory 'lexer.lex()' API function.\");\n }\n // END OF JISON INJECTED VALIDATION CODE\n "]); _templateObject80 = function _templateObject80() { return data; @@ -1627,6 +1637,12 @@ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice( function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } var fs = require('fs'); @@ -1635,6 +1651,8 @@ var path$1 = require('path'); var JSON5 = require('@gerhobbelt/json5'); +var mkdirp = require('mkdirp'); + var XRegExp = require('@gerhobbelt/xregexp'); var recast = require('recast'); @@ -1661,6 +1679,8 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); +var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); + var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); @@ -1671,7 +1691,7 @@ var astUtils__default = /*#__PURE__*/_interopDefaultLegacy(astUtils); var process__default = /*#__PURE__*/_interopDefaultLegacy(process$1); -var nomnom__default = /*#__PURE__*/_interopDefaultLegacy(nomnom); // Return TRUE if `src` starts with `searchString`. +var nomnom__default = /*#__PURE__*/_interopDefaultLegacy(nomnom); // Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { @@ -1694,7 +1714,7 @@ function rmCommonWS(strings) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look @@ -1723,37 +1743,42 @@ function rmCommonWS(strings) { // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); // Done removing common indentation. - // + { + var a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; // only correct indentation at start of line, i.e. only check for + var _a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { - if (startsWith(a[j], indent_str)) { - a[j] = a[j].substr(indent_str.length); + for (var j = 1, linecnt = _a.length; j < linecnt; j++) { + if (startsWith(_a[j], indent_str)) { + _a[j] = _a[j].substr(indent_str.length); } } } } // now merge everything to construct the template result: - var rv = []; + { + var rv = []; + var _i = 0; - for (var i = 0, len = arguments.length <= 1 ? 0 : arguments.length - 1; i < len; i++) { - rv.push(src[i].join('\n')); - rv.push(i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1]); - } // the last value is always followed by a last template string partial: + for (var _len = arguments.length <= 1 ? 0 : arguments.length - 1; _i < _len; _i++) { + rv.push(src[_i].join('\n')); + rv.push(_i + 1 < 1 || arguments.length <= _i + 1 ? undefined : arguments[_i + 1]); + } // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + rv.push(src[_i].join('\n')); + var sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` /** @public */ @@ -1773,14 +1798,36 @@ function camelCase(s) { return rv; }); -} // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers +} // https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words + + +var reservedWords = function (list) { + var rv = new Set(); + + var _iterator = _createForOfIteratorHelper(list), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var w = _step.value; + //console.error('reserved word:', w); + rv.add(w); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + return rv; +}(['await', 'break', 'case', 'catch', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'enum', 'export', 'extends', 'finally', 'for', 'function', 'if', 'implements', 'import', 'in', 'instanceof', 'interface', 'new', 'package', 'private', 'protected', 'public', 'return', 'super', 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'yield']); // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + var rv = s // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { var c = match.charAt(1); @@ -1796,6 +1843,12 @@ function mkIdentifier(s) { .replace(/^[^\w_]/, '_') // do not accept numerics at the leading position, despite those matching regex `\w`: .replace(/^\d/, '_').replace(/[^\w\d_]/g, '_') // and only accept multiple (double, not triple) underscores at start or end of identifier name: .replace(/^__+/, '#').replace(/__+$/, '#').replace(/_+/g, '_').replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + + return rv; } // Check if the start of the given input matches a regex expression. // Return the length of the regex expression or -1 if none was found. @@ -1831,13 +1884,11 @@ function scanRegExp(s) { if (ch === ']') { classMarker = false; } - } else { - if (ch === '/') { - terminated = true; - break; - } else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } @@ -1861,7 +1912,7 @@ function isLineTerminator(cp) { function isLegalIdentifierInput(s) { - s = '' + s; // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + s = '' + s; // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` var ref = s.replace(/-\w/g, function (match) { @@ -1911,6 +1962,55 @@ function pad(n, p) { p = p || 2; var rv = '0000' + n; return rv.slice(-p); +} + +function convertExceptionToObject(ex) { + if (!ex) return ex; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + + var rv = Object.assign({}, ex); // - Set up the default fields which should ALWAYS be present: + + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + + if (Array.isArray(ex.errors)) { + rv.errors = []; + + var _iterator2 = _createForOfIteratorHelper(ex.errors), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var se = _step2.value; + rv.errors.push(convertExceptionToObject(se)); + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + } + + return rv; +} + +function find_suitable_app_dump_path() { + return process.cwd().replace(/\\/g, '/').replace(/\/node_modules\/.*$/, function (m) { + return '/___nm___/'; + }).replace(/(\/jison\/)(.*)$/, function (m, p1, p2) { + return p1 + '___' + p2.split('/').map(function (d) { + return d.charAt(0).toUpperCase(); + }).join('_'); + }); } // attempt to dump in one of several locations: first winner is *it*! @@ -1919,15 +2019,27 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { options = options || {}; try { - var dumpPaths = [options.outfile ? path__default['default'].dirname(options.outfile) : null, options.inputPath, process.cwd()]; + var dumpPaths = [options.outfile ? path__default['default'].dirname(options.outfile) : null, options.inputPath, find_suitable_app_dump_path()]; var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname).replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; + } // generate a stacktrace for the dump no matter what: + + + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } } err_id = err_id || 'XXX'; + err_id = err_id.replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); var ts = new Date(); var tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + '' + pad(ts.getUTCMinutes()) + '' + pad(ts.getUTCSeconds()) + '.' + pad(ts.getUTCMilliseconds(), 3) + 'Z'; dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; @@ -1938,21 +2050,34 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); var dump = { errname: errname, err_id: err_id, options: options, - ex: ex + ex: convertExceptionToObject(ex) }; - var d = JSON5__default['default'].stringify(dump, null, 2); // make sure each line is a comment line: + var d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + + return value; + }, + space: 2, + circularRefHandler: function circularRefHandler(value, circusPos, stack, keyStack, key, err) { + return '[!circular ref!]'; + } + }); // make sure each line is a comment line: d = d.split('\n').map(function (l) { return '// ' + l; }); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -1962,7 +2087,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -1993,25 +2118,36 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + var errname = '' + (title || 'exec_test'); + var err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + + var debug = options.debug || 0; + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + + if (debug > 1) { + console.warn("\n ######################## source code ##########################\n ".concat(sourcecode, "\n ######################## source code ##########################\n ")); } - var debug = 0; var p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + if (debug > 1) console.log('exec-and-diagnose options:', options); + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } @@ -2024,9 +2160,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t return p; } -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject: convertExceptionToObject }; // assert__default['default'](recast__default['default']); //var types = recast.types; @@ -2040,18 +2177,18 @@ assert__default['default'](recast__default['default']); //var types = recast.typ // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! -var ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +var ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: -var IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; // Determine which Unicode NonAsciiIdentifierStart characters +var IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; // Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -2063,37 +2200,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -2101,30 +2238,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -2135,58 +2272,58 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -2231,27 +2368,27 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - var escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: + var escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: - var typeIdCharSets = ["ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", + var typeIdCharSets = ['ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ"]; //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ']; //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - var reStr = escCharSet + typeIdCharSets.join(""); + var reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); var re = new RegExp("[".concat(reStr, "]"), 'g'); var hash = new Array(0xD800); @@ -2262,18 +2399,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { hash[i] = (hash[i] || 0) + 1; } // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -2284,64 +2421,64 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // var escChar = pickChar(escCharSet); var typeIdChar = []; - for (var _i = 0, l = typeIdCharSets.length; _i < l; _i++) { - typeIdChar[_i] = pickChar(typeIdCharSets[_i]); - } // produce a function set for encoding and decoding content, + for (var _i2 = 0, l = typeIdCharSets.length; _i2 < l; _i2++) { + typeIdChar[_i2] = pickChar(typeIdCharSets[_i2]); + } // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: @@ -2349,47 +2486,47 @@ function generateMapper4JisonGrammarIdentifiers(input) { return _ref = { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default']("#(".concat(ID_REGEX_BASE, ")#"), 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default']("$(".concat(ID_REGEX_BASE, ")|$([0-9]+)"), 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default']("@(".concat(ID_REGEX_BASE, ")|@([0-9]+)"), 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default']("#(".concat(ID_REGEX_BASE, ")|#([0-9]+)"), 'g'), // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default']("##(".concat(ID_REGEX_BASE, ")|##([0-9]+)"), 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4] - }, _defineProperty(_ref, "tokenValueReferenceRe", new XRegExp__default['default']("$-([0-9]+)", 'g')), _defineProperty(_ref, "tokenNegativeLocationStart", escChar + typeIdChar[5]), _defineProperty(_ref, "tokenNegativeLocationRe", new XRegExp__default['default']("@-([0-9]+)", 'g')), _defineProperty(_ref, "tokenNegativeStackIndexStart", escChar + typeIdChar[6]), _defineProperty(_ref, "tokenNegativeStackIndexRe", new XRegExp__default['default']("#-([0-9]+)", 'g')), _defineProperty(_ref, "tokenDetect4EncodeRe", new XRegExp__default['default']("([^$@#".concat(IN_ID_CHARSET, "])([$@#]|##)(").concat(ID_REGEX_BASE, "|[$]|-?[0-9]+)(#?)(?![$@#").concat(IN_ID_CHARSET, "])"), 'g')), _defineProperty(_ref, "tokenDetect4DecodeRe", new XRegExp__default['default']("([^$".concat(IN_ID_CHARSET, "])(").concat(escChar, "[").concat(typeIdChar.slice(0, 7).join(''), "])(").concat(ID_REGEX_BASE, "|[$]|[0-9]+)(?![$@#").concat(IN_ID_CHARSET, "])"), 'g')), _defineProperty(_ref, "encode", function encodeJisonTokens(src, locationOffsetSpec) { + }, _defineProperty(_ref, "tokenValueReferenceRe", new XRegExp__default['default']('$-([0-9]+)', 'g')), _defineProperty(_ref, "tokenNegativeLocationStart", escChar + typeIdChar[5]), _defineProperty(_ref, "tokenNegativeLocationRe", new XRegExp__default['default']('@-([0-9]+)', 'g')), _defineProperty(_ref, "tokenNegativeStackIndexStart", escChar + typeIdChar[6]), _defineProperty(_ref, "tokenNegativeStackIndexRe", new XRegExp__default['default']('#-([0-9]+)', 'g')), _defineProperty(_ref, "tokenDetect4EncodeRe", new XRegExp__default['default']("([^$@#".concat(IN_ID_CHARSET, "])([$@#]|##)(").concat(ID_REGEX_BASE, "|[$]|-?[0-9]+)(#?)(?![$@#").concat(IN_ID_CHARSET, "])"), 'g')), _defineProperty(_ref, "tokenDetect4DecodeRe", new XRegExp__default['default']("([^$".concat(IN_ID_CHARSET, "])(").concat(escChar, "[").concat(typeIdChar.slice(0, 7).join(''), "])(").concat(ID_REGEX_BASE, "|[$]|[0-9]+)(?![$@#").concat(IN_ID_CHARSET, "])"), 'g')), _defineProperty(_ref, "encode", function encodeJisonTokens(src, locationOffsetSpec) { var _this = this; var re = this.tokenDetect4EncodeRe; // reset regex @@ -2397,10 +2534,10 @@ function generateMapper4JisonGrammarIdentifiers(input) { re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -2484,10 +2621,10 @@ function generateMapper4JisonGrammarIdentifiers(input) { re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -2496,19 +2633,19 @@ function generateMapper4JisonGrammarIdentifiers(input) { // p1 is only serving as lookbehind emulation switch (p2) { case _this2.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case _this2.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case _this2.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case _this2.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case _this2.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case _this2.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -2564,13 +2701,13 @@ function compileCodeToES5(src, options) { sourceRoot: '.', sourceType: 'module', babelrc: false, - ignore: ["node_modules/**/*.js"], + ignore: ['node_modules/**/*.js'], compact: false, retainLines: false, - presets: [["@babel/preset-env", { + presets: [['@babel/preset-env', { targets: { - browsers: ["last 2 versions"], - node: "8.0" + browsers: ['last 2 versions'], + node: '8.0' } }]] }, options); @@ -2578,7 +2715,7 @@ function compileCodeToES5(src, options) { } function prettyPrintAST(ast, options) { - var options = options || {}; + options = options || {}; var defaultOptions = { tabWidth: 2, quote: 'single', @@ -2601,8 +2738,8 @@ function prettyPrintAST(ast, options) { .replace(/\uFFDA/g, '@').replace(/\uFFDB/g, '#'); return new_src; } // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { @@ -2622,16 +2759,16 @@ function checkActionBlock(src, yylloc, options) { var rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } // The rough-and-ready preprocessor for any action code block: // this one trims off any surplus whitespace and removes any // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -2639,7 +2776,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -2648,12 +2785,12 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { @@ -2730,16 +2867,16 @@ function printFunctionSourceCode(f) { var funcRe = /^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/; var arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/; /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ @@ -2768,8 +2905,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -2795,12 +2932,12 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { printFunctionSourceCode: printFunctionSourceCode, printFunctionSourceCodeContainer: printFunctionSourceCodeContainer -}; // -// -// +}; // +// +// function detectIstanbulGlobal() { - var gcv = "__coverage__"; + var gcv = '__coverage__'; var globalvar = new Function('return this')(); var coverage = globalvar[gcv]; return coverage || false; @@ -2987,12 +3124,44 @@ function shallow_copy_and_strip_depth(src, parentKey) { } return src; -} +} // strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. + function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: - msg = msg.replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)').replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + msg = msg.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; +} // strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. + + +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + var msg = obj.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + + var keys = Object.keys(obj); + + for (var i in keys) { + var key = keys[i]; + var el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + + return obj; } function trim_array_tail(arr) { @@ -3040,33 +3209,33 @@ function treat_error_infos_array(arr) { trim_array_tail(inf); for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + var _err = inf[key]; - if (err) { + if (_err) { path.push('[' + key + ']'); - err = treat_object(err); + _err = treat_object(_err); - if (_typeof(err) === 'object') { - if (err.lexer) { - err.lexer = '[lexer]'; + if (_typeof(_err) === 'object') { + if (_err.lexer) { + _err.lexer = '[lexer]'; } - if (err.parser) { - err.parser = '[parser]'; + if (_err.parser) { + _err.parser = '[parser]'; } - trim_array_tail(err.symbol_stack); - trim_array_tail(err.state_stack); - trim_array_tail(err.location_stack); + trim_array_tail(_err.symbol_stack); + trim_array_tail(_err.state_stack); + trim_array_tail(_err.location_stack); - if (err.value_stack) { + if (_err.value_stack) { path.push('value_stack'); - err.value_stack = treat_value_stack(err.value_stack); + _err.value_stack = treat_value_stack(_err.value_stack); path.pop(); } } - inf[key] = err; + inf[key] = _err; path.pop(); } } @@ -3213,7 +3382,7 @@ function treat_object(e) { return e; } // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. @@ -3245,10 +3414,12 @@ var helpers = { dquote: dquote$1, trimErrorForTestReporting: trimErrorForTestReporting, stripErrorStackPaths: stripErrorStackPaths, + cleanStackTrace4Comparison: cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, compileCodeToES5: parse2AST.compileCodeToES5, @@ -3336,7 +3507,7 @@ function typal_mix() { return this; } // Same as typal_mix but also camelCases every object member and 'standardizes' the key set of every input // argument through a caLLback function. -// +// // This is useful for processing options with dashes in their key, e.g. `token-stack` --> tokenStack. @@ -3370,7 +3541,7 @@ function typal_camel_mix(cb) { var nk = mkIdentifier$1(k); var match = k.match(position); var key = k.replace(position, ''); // This anticipates before/after members to be camelcased already, e.g. - // 'afterParse()' for layering 'parse()': + // 'afterParse()' for layering 'parse()': var alt_key = lcase0(key); @@ -3501,7 +3672,7 @@ var setMixin = { return this._items.length === 0; }, copy: function copy() { - return new Set(this._items); + return new Set$1(this._items); }, toString: function toString() { return this._items.toString(); @@ -3515,11 +3686,11 @@ var setMixin = { }); 'filter slice map'.split(' ').forEach(function (e, i) { setMixin[e] = function () { - return new Set(Array.prototype[e].apply(this._items, arguments), true); + return new Set$1(Array.prototype[e].apply(this._items, arguments), true); }; //setMixin[e].name = e; }); -var Set = typal.construct(setMixin); // See also: +var Set$1 = typal.construct(setMixin); // 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. @@ -4022,16 +4193,16 @@ var parser = { switch (yystate) { case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; - this._$ = yylstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4060,8 +4231,8 @@ var parser = { case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { @@ -4078,17 +4249,17 @@ var parser = { case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp - 1].errStr)); break; case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { rules: yyvstack[yysp] @@ -4097,17 +4268,17 @@ var parser = { case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject2(), yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr)); break; case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { rules: [] @@ -4116,9 +4287,9 @@ var parser = { case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; if (!yy.options) yy.options = {}; @@ -4157,8 +4328,8 @@ var parser = { case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4208,8 +4379,8 @@ var parser = { case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { macros: {}, @@ -4227,8 +4398,8 @@ var parser = { case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` // macros here: @@ -4251,17 +4422,17 @@ var parser = { case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject6(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4278,17 +4449,17 @@ var parser = { case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject7(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4305,17 +4476,17 @@ var parser = { case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject8(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4337,8 +4508,8 @@ var parser = { case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. @@ -4347,8 +4518,8 @@ var parser = { case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -4358,8 +4529,8 @@ var parser = { case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -4369,8 +4540,8 @@ var parser = { case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4383,17 +4554,17 @@ var parser = { case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject12(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { type: 'unknown', @@ -4403,8 +4574,8 @@ var parser = { case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4431,17 +4602,17 @@ var parser = { case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject15(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 5, yysp); // END of default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4475,9 +4646,9 @@ var parser = { case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + 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 : ''; @@ -4487,36 +4658,36 @@ var parser = { case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1(_templateObject20(), yylexer.prettyPrintRange(yylstack[yysp - 3], yylstack[yysp - 4]), yyvstack[yysp - 3].errStr)); break; case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject21(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1(_templateObject22(), yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = yyvstack[yysp]; @@ -4527,9 +4698,9 @@ var parser = { case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; yy.__options_category_description__ = yyvstack[yysp]; @@ -4537,9 +4708,9 @@ var parser = { case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; yy.__options_category_description__ = yyvstack[yysp]; @@ -4547,9 +4718,9 @@ var parser = { case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = 'the inclusive lexer start conditions set (%s)'; @@ -4557,9 +4728,9 @@ var parser = { case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = 'the exclusive lexer start conditions set (%x)'; @@ -4567,9 +4738,9 @@ var parser = { case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; yy.__options_category_description__ = 'the <...> delimited set of lexer start conditions'; @@ -4577,9 +4748,9 @@ var parser = { case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; yy.__options_category_description__ = 'the lexer rules definition section'; @@ -4587,9 +4758,9 @@ var parser = { case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; yy.__options_category_description__ = 'the lexer epilogue section'; @@ -4597,24 +4768,24 @@ var parser = { case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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].concat(yyvstack[yysp]); break; case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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].concat([yyvstack[yysp]]); break; case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4633,8 +4804,8 @@ var parser = { case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. @@ -4643,8 +4814,8 @@ var parser = { case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -4654,8 +4825,8 @@ var parser = { case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4690,8 +4861,8 @@ var parser = { case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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(_templateObject27(), yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp]))); this.$ = yyvstack[yysp - 1]; @@ -4702,16 +4873,16 @@ var parser = { case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (yyvstack[yysp - 1]) { yyvstack[yysp].unshift(yyvstack[yysp - 1]); @@ -4722,8 +4893,8 @@ var parser = { case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (yyvstack[yysp - 3]) { yyvstack[yysp - 1].forEach(function (d) { @@ -4736,35 +4907,35 @@ var parser = { case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + 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$1(_templateObject28(), yyvstack[yysp - 3].join(','), yylexer.prettyPrintRange(yyparser.mergeLocationInfo(yysp - 3, yysp), yylstack[yysp - 3]), yyvstack[yysp - 1].errStr)); break; case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject29(), yyvstack[yysp - 2].join(','), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject30(), yyvstack[yysp - 2].join(','), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push(yyvstack[yysp]); @@ -4775,8 +4946,8 @@ var parser = { case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -4790,8 +4961,8 @@ var parser = { case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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. @@ -4822,8 +4993,8 @@ var parser = { case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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(_templateObject33(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); @@ -4831,8 +5002,8 @@ var parser = { case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO: REWRITE this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -4841,8 +5012,8 @@ var parser = { case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO: REWRITE this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -4851,8 +5022,8 @@ var parser = { case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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], yyvstack[yysp]]; yyparser.yyError(rmCommonWS$1(_templateObject36(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); @@ -4872,52 +5043,52 @@ var parser = { case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + yyvstack[yysp]; break; case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '\n\n' + yyvstack[yysp] + '\n\n'; break; case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject37(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]))); break; case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject38(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]))); break; case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject39(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]))); break; case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject40(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]))); break; @@ -4927,16 +5098,16 @@ var parser = { case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -4955,9 +5126,9 @@ var parser = { case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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) { @@ -4968,8 +5139,8 @@ var parser = { case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -5049,56 +5220,56 @@ var parser = { case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; break; case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '|'; break; case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; break; case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '|'; break; case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + ')'; break; case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + ')'; break; @@ -5108,49 +5279,49 @@ var parser = { case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject43(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '+'; break; case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '*'; break; case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '?'; break; case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + ')'; break; case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + ')'; break; @@ -5172,65 +5343,65 @@ var parser = { case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '.'; break; case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '^'; break; case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '$'; break; case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); break; case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + yyvstack[yysp]; break; case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject44(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) && yyvstack[yysp].toUpperCase() !== yyvstack[yysp]) { // treat this as part of an XRegExp `\p{...}` Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories @@ -5244,8 +5415,8 @@ var parser = { case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -5255,8 +5426,8 @@ var parser = { case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -5264,8 +5435,8 @@ var parser = { case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -5286,8 +5457,8 @@ var parser = { case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -5300,24 +5471,24 @@ var parser = { case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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], true]; break; case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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_VALUE) { @@ -5329,9 +5500,9 @@ var parser = { case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... yyparser.yyError(rmCommonWS$1(_templateObject49(), $option, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 4]), yyvstack[yysp].errStr)); @@ -5339,9 +5510,9 @@ var parser = { case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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)'; @@ -5354,8 +5525,8 @@ var parser = { case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -5381,8 +5552,8 @@ var parser = { case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -5401,32 +5572,32 @@ var parser = { case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = parseValue(yyvstack[yysp]); break; case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = ''; break; case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -5443,17 +5614,17 @@ var parser = { case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject54(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$1(_templateObject55(), yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr)); @@ -5462,8 +5633,8 @@ var parser = { case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -5483,8 +5654,8 @@ var parser = { case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -5494,8 +5665,8 @@ var parser = { case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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. @@ -5504,8 +5675,8 @@ var parser = { case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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]; @@ -5540,9 +5711,9 @@ var parser = { case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject61(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; @@ -5621,20 +5792,14 @@ var parser = { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + var ASSERT = typeof assert !== 'function' ? function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : assert; this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -5667,13 +5832,14 @@ var parser = { shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + var _dst = {}; + shallow_copy_noclobber(_dst, src); + return _dst; + } } return src; @@ -5690,10 +5856,8 @@ var parser = { if (chk.call(src, k)) { dst[k] = src[k]; } - } else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -5862,11 +6026,11 @@ var parser = { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (var _i3 = this.__error_recovery_infos.length - 1; _i3 >= 0; _i3--) { + var _el = this.__error_recovery_infos[_i3]; - if (el && typeof el.destroy === 'function') { - el.destroy(); + if (_el && typeof _el.destroy === 'function') { + _el.destroy(); } } @@ -5894,10 +6058,10 @@ var parser = { this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; + var i1 = first_index | 0; + var i2 = last_index | 0; + var l1 = first_yylloc; + var l2 = last_yylloc; var rv; // rules: // - first/last yylloc entries override first/last indexes @@ -5915,8 +6079,8 @@ var parser = { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { - l2 = lstack[i]; + for (var _i4 = i2; _i4 >= i1; _i4--) { + l2 = lstack[_i4]; if (l2) { break; @@ -5929,8 +6093,8 @@ var parser = { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { - l1 = lstack[i]; + for (var _i5 = (i1 || sp) - 1; _i5 >= 0; _i5--) { + l1 = lstack[_i5]; if (l1) { break; @@ -5943,30 +6107,30 @@ var parser = { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; - } + return null; + } // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + + rv = this.copy_yylloc(l2); return rv; + } // shallow-copy L1, then adjust first col/row 1 column past the end. + + + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; } + + return rv; } if (!l1) { @@ -5975,7 +6139,7 @@ var parser = { } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... @@ -6025,6 +6189,12 @@ var parser = { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -6107,11 +6277,15 @@ var parser = { // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty - } + { + var i; + + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty + } - rv.base_pointer = i; - rv.info_stack_pointer = i; + rv.base_pointer = i; + rv.info_stack_pointer = i; + } rv.root_failure_pointer = rv.stack_pointer; // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_recovery_infos.push(rv); @@ -6197,9 +6371,9 @@ var parser = { while (stack_probe >= 0) { // check for error recovery rule in this state - var t = table[state] && table[state][TERROR] || NO_ACTION; + var _t = table[state] && table[state][TERROR] || NO_ACTION; - if (t[0]) { + if (_t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must // prevent the core from running forever, @@ -6362,7 +6536,7 @@ var parser = { if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: @@ -6418,7 +6592,7 @@ var parser = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errSymbolDescr: errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -6437,7 +6611,8 @@ var parser = { yyval.$ = recoveringErrorInfo; yyval._$ = undefined; yyrulelen = error_rule_depth; - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + var combineState = NO_ACTION[1]; + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -6494,9 +6669,9 @@ var parser = { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); var errorSymbolFromParser = true; for (;;) { @@ -6529,7 +6704,7 @@ var parser = { // and take it from there! if (!action) { - ASSERT(recoveringErrorInfo, "line 1087"); // Prep state variables so that upon breaking out of + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` // statement in the outer "fast parse loop" we redo // the exact same state table lookup as the one above @@ -6564,12 +6739,12 @@ var parser = { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -6611,7 +6786,7 @@ var parser = { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; // read action for current state and first input @@ -6641,7 +6816,7 @@ var parser = { // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; @@ -6701,15 +6876,17 @@ var parser = { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -6763,7 +6940,7 @@ var parser = { // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; @@ -6805,25 +6982,25 @@ var parser = { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + var _tokenName = this.getSymbolName(symbol || EOF); - if (!tokenName) { - tokenName = symbol; + if (!_tokenName) { + _tokenName = symbol; } Jison.parserDebugger.push({ action: 'shift', text: lexer.yytext, - terminal: tokenName, + terminal: _tokenName, terminal_id: symbol }); } ++sp; symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc = this.copy_yylloc(lexer.yylloc); @@ -6831,9 +7008,9 @@ var parser = { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... @@ -6841,25 +7018,28 @@ var parser = { r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; + var _prereduceValue = vstack.slice(sp - yyrulelen, sp); - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); - debuggableProductions.push(debuggableProduction); + var _debuggableProductions = []; + + for (var _debugIdx = yyrulelen - 1; _debugIdx >= 0; _debugIdx--) { + var _debuggableProduction = getNonTerminalFromCode(stack[sp - _debugIdx]); + + _debuggableProductions.push(_debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + var _currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + + var _currentNonterminal = getNonTerminalFromCode(_currentNonterminalCode); - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', - nonterminal: currentNonterminal, - nonterminal_id: currentNonterminalCode, - prereduce: prereduceValue, + nonterminal: _currentNonterminal, + nonterminal_id: _currentNonterminalCode, + prereduce: _prereduceValue, result: r, - productions: debuggableProductions, + productions: _debuggableProductions, text: yyval.$ }); } @@ -6881,15 +7061,17 @@ var parser = { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var _ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = _ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][_ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -7398,6 +7580,10 @@ var lexer = function () { * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -7779,9 +7965,9 @@ var lexer = function () { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -7791,8 +7977,8 @@ var lexer = function () { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -7868,12 +8054,22 @@ var lexer = function () { */ pastInput: function lexer_pastInput(maxSize, maxLines) { var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) maxSize = Infinity;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substr` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = Infinity; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: @@ -7890,8 +8086,8 @@ var lexer = function () { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -7917,20 +8113,30 @@ var lexer = function () { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { var next = this.match; var source = this._input || ''; - if (maxSize < 0) maxSize = next.length + source.length;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substring` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = next.length + source.length; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + if (next.length < maxSize * 2 + 2) { next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8 } // now that we have a significantly reduced string to process, transform the newlines @@ -8255,7 +8461,7 @@ var lexer = function () { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + var backup; if (this.options.backtrack_lexer) { // save context @@ -8283,9 +8489,9 @@ var lexer = function () { }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + var match_str = match[0]; + var match_str_len = match_str.length; + var lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -8311,7 +8517,7 @@ var lexer = function () { // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] + var token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */ ); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -8357,8 +8563,6 @@ var lexer = function () { this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -8390,65 +8594,73 @@ var lexer = function () { } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; // 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! + { + var rule_ids = spec.rules; + var regexes = spec.__rule_regexes; + var len = spec.__rule_count; + var match; + var index; // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + for (var i = 1; i <= len; i++) { + var tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + var token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + var _token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + if (_token !== false) { + return _token; + } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + var _lineno_msg = 'Lexical error'; if (this.yylloc) { - lineno_msg += ' on line ' + (this.yylineno + 1); + _lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var _p = this.constructLexErrorInfo(_lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var pendingInput = this._input; var activeCondition = this.topState(); var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; - if (token === this.ERROR) { + var _token2 = this.parseError(_p.errStr, _p, this.JisonLexerError) || this.ERROR; + + if (_token2 === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: @@ -8460,7 +8672,7 @@ var lexer = function () { } } - return token; + return _token2; } }, @@ -8517,24 +8729,24 @@ var lexer = function () { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -8561,24 +8773,24 @@ var lexer = function () { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -8642,9 +8854,9 @@ var lexer = function () { if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -8660,9 +8872,9 @@ var lexer = function () { if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -8682,7 +8894,7 @@ var lexer = function () { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -10309,9 +10521,9 @@ function i2c(i) { if (x.length >= 1 && i <= 0xFFFF) { c = '0000' + x; return "\\u" + c.substr(c.length - 4); - } else { - return "\\u{" + x + '}'; } + + return "\\u{" + x + '}'; } return String.fromCharCode(i); @@ -10321,7 +10533,7 @@ function i2c(i) { var Pcodes_bitarray_cache = {}; -var Pcodes_bitarray_cache_test_order = []; // Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by +var Pcodes_bitarray_cache_test_order = []; // Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. var EscCode_bitarray_output_refs; // now initialize the EscCodes_... table above: @@ -10423,13 +10635,13 @@ function updatePcodesBitarrayCacheTestOrder(opts) { l[k] = cnt; } // now dig out the unique ones: only need one per pcode. - // + // // We ASSUME every \\p{NAME} 'pcode' has at least ONE character - // in it that is ONLY matched by that particular pcode. + // in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode - // won't be tested during optimization. - // + // won't be tested during optimization. + // // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to @@ -10484,11 +10696,11 @@ function updatePcodesBitarrayCacheTestOrder(opts) { } } // order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. - // + // // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more - // optimal minification of the regex set expression. - // + // optimal minification of the regex set expression. + // // This is a guestimate/heuristic only! @@ -10725,7 +10937,7 @@ function set2bitarray(bitarr, s, opts) { mark(v1); } // When we have marked all slots, '^' NEGATES the set, hence we flip all slots. - // + // // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. @@ -10802,9 +11014,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { break; } } - } // We're only interested in matches which actually cover some + } // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: @@ -10905,9 +11117,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { break; } } - } // We're only interested in matches which actually cover some + } // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: @@ -11003,10 +11215,9 @@ function reduceRegexToSetBitArray(s, name, opts) { if (!c1) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"'); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -11023,10 +11234,9 @@ function reduceRegexToSetBitArray(s, name, opts) { if (!inner) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"'); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -11042,10 +11252,10 @@ function reduceRegexToSetBitArray(s, name, opts) { if (!c2) { // cope with illegal escape sequences too! return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; + if (c2 !== ']') { return new Error('regex set expression is broken in regex: ' + orig); } @@ -11133,10 +11343,9 @@ function reduceRegexToSetBitArray(s, name, opts) { // inside a regex set: try { - var re; assert__default['default'](s); assert__default['default'](!(s instanceof Error)); - re = new XRegExp__default['default']('[' + s + ']'); + var re = new XRegExp__default['default']('[' + s + ']'); re.test(s[0]); // One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` // so we check for lingering UNESCAPED brackets in here as those cannot be: @@ -11156,7 +11365,7 @@ function reduceRegexToSetBitArray(s, name, opts) { } return l; -} // Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` +} // Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! @@ -11168,13 +11377,12 @@ function produceOptimizedRegex4Set(bitarr) { if (s1.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s1; - } else { - s1 = '[' + s1 + ']'; - } // Now try to produce a minimum regex from the *inverted* bitarray via negation: + } + + s1 = '[' + s1 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s2 = bitarray2set(bitarr, true, true); if (s2[0] === '^') { @@ -11190,7 +11398,7 @@ function produceOptimizedRegex4Set(bitarr) { s2 = '[' + s2 + ']'; // Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: - // + // // First try to produce a minimum regex from the bitarray directly: var s3 = bitarray2set(bitarr, false, false); // and when the regex set turns out to match a single pcode/escape, then @@ -11199,13 +11407,12 @@ function produceOptimizedRegex4Set(bitarr) { if (s3.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s3; - } else { - s3 = '[' + s3 + ']'; - } // Now try to produce a minimum regex from the *inverted* bitarray via negation: + } + + s3 = '[' + s3 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s4 = bitarray2set(bitarr, true, false); if (s4[0] === '^') { @@ -11254,7 +11461,7 @@ var setmgmt = { var rmCommonWS$2 = helpers.rmCommonWS; var mkIdentifier$3 = helpers.mkIdentifier; -var code_exec$1 = helpers.exec; +var code_exec = helpers.exec; var version = '0.6.2-220'; // require('./package.json').version; function chkBugger$2(src) { @@ -11335,7 +11542,7 @@ function mkStdOptions() var opts = {}; var args = [].concat.apply([], arguments); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(defaultJisonLexOptions); } else { args.shift(); @@ -11631,9 +11838,9 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse function errinfo() { if (name) { return 'macro [[' + name + ']]'; - } else { - return 'regex [[' + orig + ']]'; } + + return 'regex [[' + orig + ']]'; } // propagate deferred exceptions = error reports. @@ -11652,10 +11859,9 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse if (!c1) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -11673,10 +11879,9 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse if (!inner) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -11692,10 +11897,10 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse if (!c2) { // cope with illegal escape sequences too! return new Error(errinfo() + ': regex set expression is broken: "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; + if (c2 !== ']') { return new Error(errinfo() + ': regex set expression is broken: apparently unterminated'); } @@ -12210,7 +12415,7 @@ function buildActions(dict, tokens, opts) { function generateErrorClass() { // --- START lexer error class --- - var prelude = "/**\n * See also:\n * http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n * but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n * with userland code which might access the derived class in a 'classic' way.\n *\n * @public\n * @constructor\n * @nocollapse\n */\nfunction JisonLexerError(msg, hash) {\n \"use strict\";\n\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'JisonLexerError'\n });\n\n if (msg == null) msg = '???';\n\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n var stacktrace;\n if (hash && hash.exception instanceof Error) {\n var ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty('captureStackTrace')) { // V8\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(JisonLexerError.prototype, Error.prototype);\n} else {\n JisonLexerError.prototype = Object.create(Error.prototype);\n}\nJisonLexerError.prototype.constructor = JisonLexerError;\nJisonLexerError.prototype.name = 'JisonLexerError';"; // --- END lexer error class --- + var prelude = "/**\n * See also:\n * http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n * but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n * with userland code which might access the derived class in a 'classic' way.\n *\n * @public\n * @constructor\n * @nocollapse\n */\nfunction JisonLexerError(msg, hash) {\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'JisonLexerError'\n });\n\n if (msg == null) msg = '???';\n\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n let stacktrace;\n if (hash && hash.exception instanceof Error) {\n const ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty('captureStackTrace')) { // V8\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(JisonLexerError.prototype, Error.prototype);\n} else {\n JisonLexerError.prototype = Object.create(Error.prototype);\n}\nJisonLexerError.prototype.constructor = JisonLexerError;\nJisonLexerError.prototype.name = 'JisonLexerError';"; // --- END lexer error class --- return prelude; } @@ -12246,36 +12451,39 @@ function RegExpLexer(dict, input, tokens, build_options) { // The compiled code will look something like this: // // ``` - // var lexer; + // let lexer; // bla bla... // ``` // // or // // ``` - // var lexer = { bla... }; + // const lexer = { bla... }; // ``` - var testcode = ['// provide a local version for test purposes:', jisonLexerErrorDefinition, '', generateFakeXRegExpClassSrcCode(), '', source, '', 'return lexer;'].join('\n'); - var lexer = code_exec$1(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { + var testcode = ['// provide a local version for test purposes:', jisonLexerErrorDefinition, '', generateFakeXRegExpClassSrcCode(), '', source, '', rmCommonWS$2(_templateObject80()), 'return lexer;'].join('\n'); + + var _lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { //console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$2(sourcecode); var lexer_f = new Function('', sourcecode); return lexer_f(); - }, opts.options, "lexer"); + }, Object.assign({}, opts.options, { + throwErrorOnCompileFailure: true + }), 'lexer'); - if (!lexer) { + if (!_lexer) { throw new Error('no lexer defined *at all*?!'); } - if (_typeof(lexer.options) !== 'object' || lexer.options == null) { + if (_typeof(_lexer.options) !== 'object' || _lexer.options == null) { throw new Error('your lexer class MUST have an .options member object or it won\'t fly!'); } - if (typeof lexer.setInput !== 'function') { + if (typeof _lexer.setInput !== 'function') { throw new Error('your lexer class MUST have a .setInput function member or it won\'t fly!'); } - if (lexer.EOF !== 1 && lexer.ERROR !== 2) { + if (_lexer.EOF !== 1 && _lexer.ERROR !== 2) { throw new Error('your lexer class MUST have these constants defined: lexer.EOF = 1 and lexer.ERROR = 2 or it won\'t fly!'); } // When we do NOT crash, we found/killed the problem area just before this call! @@ -12296,23 +12504,23 @@ function RegExpLexer(dict, input, tokens, build_options) { var post = opts.options.post_lex; // since JSON cannot encode functions, we'll have to do it manually now: if (typeof pre === 'function') { - lexer.options.pre_lex = pre; + _lexer.options.pre_lex = pre; } if (typeof post === 'function') { - lexer.options.post_lex = post; + _lexer.options.post_lex = post; } } if (opts.options.showSource) { if (typeof opts.options.showSource === 'function') { - opts.options.showSource(lexer, source, opts, RegExpLexer); + opts.options.showSource(_lexer, source, opts, RegExpLexer); } else { - console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n"); + console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n', source, '\n----------------------------------------\n'); } } - return lexer; + return _lexer; } catch (ex) { // if (src_exception) { // src_exception.message += '\n (' + description + ': ' + ex.message + ')'; @@ -12351,62 +12559,66 @@ function RegExpLexer(dict, input, tokens, build_options) { assert__default['default'](Array.isArray(opts.rules)); return opts.rules.length > 0 ? 'One or more of your lexer state names are possibly botched?' : 'Your custom lexer is somehow botched.'; }, ex, null)) { - var rulesSpecSize; - - if (!test_me(function () { - // store the parsed rule set size so we can use that info in case - // this attempt also fails: - assert__default['default'](Array.isArray(opts.rules)); - rulesSpecSize = opts.rules.length; // opts.conditions = []; - - opts.rules = []; - opts.showSource = false; - opts.__in_rules_failure_analysis_mode__ = true; - }, 'One or more of your lexer rules are possibly botched?', ex, null)) { - // kill each rule action block, one at a time and test again after each 'edit': - var rv = false; - - for (var i = 0, len = rulesSpecSize; i < len; i++) { - var lastEditedRuleSpec; - rv = test_me(function () { - assert__default['default'](Array.isArray(opts.rules)); - assert__default['default'](opts.rules.length === rulesSpecSize); // opts.conditions = []; - // opts.rules = []; - // opts.__in_rules_failure_analysis_mode__ = true; - // nuke all rules' actions up to and including rule numero `i`: - - for (var j = 0; j <= i; j++) { - // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; - // now we want to edit the *action* part: - var rule = opts.rules[j]; - assert__default['default'](Array.isArray(rule)); - assert__default['default'](rule.length === 2 || rule.length === 3); - rule.pop(); - rule.push('{ /* nada */ }'); - lastEditedRuleSpec = rule; - } - }, function () { - return 'Your lexer rule "' + lastEditedRuleSpec[0] + '" action code block is botched?'; - }, ex, null); + var i, len; + var lastEditedRuleSpec; + + (function () { + var rulesSpecSize; + + if (!test_me(function () { + // store the parsed rule set size so we can use that info in case + // this attempt also fails: + assert__default['default'](Array.isArray(opts.rules)); + rulesSpecSize = opts.rules.length; // opts.conditions = []; + + opts.rules = []; + opts.showSource = false; + opts.__in_rules_failure_analysis_mode__ = true; + }, 'One or more of your lexer rules are possibly botched?', ex, null)) { + // kill each rule action block, one at a time and test again after each 'edit': + var rv = false; + + for (i = 0, len = rulesSpecSize; i < len; i++) { + rv = test_me(function () { + assert__default['default'](Array.isArray(opts.rules)); + assert__default['default'](opts.rules.length === rulesSpecSize); // opts.conditions = []; + // opts.rules = []; + // opts.__in_rules_failure_analysis_mode__ = true; + // nuke all rules' actions up to and including rule numero `i`: + + for (var j = 0; j <= i; j++) { + // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; + // now we want to edit the *action* part: + var rule = opts.rules[j]; + assert__default['default'](Array.isArray(rule)); + assert__default['default'](rule.length === 2 || rule.length === 3); + rule.pop(); + rule.push('{ /* nada */ }'); + lastEditedRuleSpec = rule; + } + }, function () { + return 'Your lexer rule "' + lastEditedRuleSpec[0] + '" action code block is botched?'; + }, ex, null); - if (rv) { - break; + if (rv) { + break; + } } - } - if (!rv) { - test_me(function () { - opts.conditions = []; - opts.rules = []; - opts.performAction = 'null'; // opts.options = {}; - // opts.caseHelperInclude = '{}'; - - opts.showSource = false; - opts.__in_rules_failure_analysis_mode__ = true; - dump = false; - }, 'One or more of your lexer rule action code block(s) are possibly botched?', ex, null); + if (!rv) { + test_me(function () { + opts.conditions = []; + opts.rules = []; + opts.performAction = 'null'; // opts.options = {}; + // opts.caseHelperInclude = '{}'; + + opts.showSource = false; + opts.__in_rules_failure_analysis_mode__ = true; + dump = false; + }, 'One or more of your lexer rule action code block(s) are possibly botched?', ex, null); + } } - } + })(); } } @@ -12479,11 +12691,11 @@ function RegExpLexer(dict, input, tokens, build_options) { function getRegExpLexerPrototype() { // --- START lexer kernel --- - return "{\n EOF: 1,\n ERROR: 2,\n\n // JisonLexerError: JisonLexerError, /// <-- injected by the code generator\n\n // options: {}, /// <-- injected by the code generator\n\n // yy: ..., /// <-- injected by setInput()\n\n __currentRuleSet__: null, /// INTERNAL USE ONLY: internal rule set cache for the current lexer state\n\n __error_infos: [], /// INTERNAL USE ONLY: the set of lexErrorInfo objects created since the last cleanup\n\n __decompressed: false, /// INTERNAL USE ONLY: mark whether the lexer instance has been 'unfolded' completely and is now ready for use\n\n done: false, /// INTERNAL USE ONLY\n _backtrack: false, /// INTERNAL USE ONLY\n _input: '', /// INTERNAL USE ONLY\n _more: false, /// INTERNAL USE ONLY\n _signaled_error_token: false, /// INTERNAL USE ONLY\n _clear_state: 0, /// INTERNAL USE ONLY; 0: clear to do, 1: clear done for lex()/next(); -1: clear done for inut()/unput()/...\n\n conditionStack: [], /// INTERNAL USE ONLY; managed via `pushState()`, `popState()`, `topState()` and `stateStackSize()`\n\n match: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction. `match` is identical to `yytext` except that this one still contains the matched input string after `lexer.performAction()` has been invoked, where userland code MAY have changed/replaced the `yytext` value entirely!\n matched: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks entire input which has been matched so far\n matches: false, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks RE match result for last (successful) match attempt\n yytext: '', /// ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction; this value is transferred to the parser as the 'token value' when the parser consumes the lexer token produced through a call to the `lex()` API.\n offset: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks the 'cursor position' in the input string, i.e. the number of characters matched so far. (**WARNING:** this value MAY be negative if you `unput()` more text than you have already lexed. This type of behaviour is generally observed for one kind of 'lexer/parser hack' where custom token-illiciting characters are pushed in front of the input stream to help simulate multiple-START-points in the parser. When this happens, `base_position` will be adjusted to help track the original input's starting point in the `_input` buffer.)\n base_position: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: index to the original starting point of the input; always ZERO(0) unless `unput()` has pushed content before the input: see the `offset` **WARNING** just above.\n yyleng: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: length of matched input for the token under construction (`yytext`)\n yylineno: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: 'line number' at which the token under construction is located\n yylloc: null, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks location info (lines + columns) for the token under construction\n CRLF_Re: /\\r\\n?|\\n/, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: regex used to split lines while tracking the lexer cursor position.\n\n /**\n * INTERNAL USE: construct a suitable error info hash object instance for `parseError`.\n *\n * @public\n * @this {RegExpLexer}\n */\n constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) {\n \"use strict\";\n \n msg = '' + msg;\n\n // heuristic to determine if the error message already contains a (partial) source code dump\n // as produced by either `showPosition()` or `prettyPrintRange()`:\n if (show_input_position == undefined) {\n show_input_position = !(msg.indexOf('\\n') > 0 && msg.indexOf('^') > 0);\n }\n if (this.yylloc && show_input_position) {\n if (typeof this.prettyPrintRange === 'function') {\n var pretty_src = this.prettyPrintRange(this.yylloc);\n\n if (!/\\n\\s*$/.test(msg)) {\n msg += '\\n';\n }\n msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc);\n } else if (typeof this.showPosition === 'function') {\n var pos_str = this.showPosition();\n if (pos_str) {\n if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') {\n msg += '\\n' + pos_str;\n } else {\n msg += pos_str;\n }\n }\n }\n }\n /** @constructor */\n var pei = {\n errStr: msg,\n recoverable: !!recoverable,\n text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'...\n token: null,\n line: this.yylineno,\n loc: this.yylloc,\n yy: this.yy, \n lexer: this,\n\n /**\n * and make sure the error info doesn't stay due to potential\n * ref cycle via userland code manipulations.\n * These would otherwise all be memory leak opportunities!\n *\n * Note that only array and object references are nuked as those\n * constitute the set of elements which can produce a cyclic ref.\n * The rest of the members is kept intact as they are harmless.\n *\n * @public\n * @this {LexErrorInfo}\n */\n destroy: function destructLexErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // ...\n \"use strict\";\n var rec = !!this.recoverable;\n for (var key in this) {\n if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n },\n\n /**\n * handler which is invoked when a lexer error occurs.\n *\n * @public\n * @this {RegExpLexer}\n */\n parseError: function lexer_parseError(str, hash, ExceptionClass) {\n \"use strict\";\n\n if (!ExceptionClass) {\n ExceptionClass = this.JisonLexerError;\n }\n if (this.yy) {\n if (this.yy.parser && typeof this.yy.parser.parseError === 'function') {\n return this.yy.parser.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n } else if (typeof this.yy.parseError === 'function') {\n return this.yy.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n }\n }\n throw new ExceptionClass(str, hash);\n },\n\n /**\n * method which implements `yyerror(str, ...args)` functionality for use inside lexer actions.\n *\n * @public\n * @this {RegExpLexer}\n */\n yyerror: function yyError(str /*, ...args */) {\n \"use strict\";\n\n var lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable);\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n var args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n p.extra_error_attributes = args;\n }\n\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n },\n\n /**\n * final cleanup function for when we have completed lexing the input;\n * make it an API so that external code can use this one once userland\n * code has decided it's time to destroy any lingering lexer error\n * hash object instances and the like: this function helps to clean\n * up these constructs, which *may* carry cyclic references which would\n * otherwise prevent the instances from being properly and timely\n * garbage-collected, i.e. this function helps prevent memory leaks!\n *\n * @public\n * @this {RegExpLexer}\n */\n cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) {\n \"use strict\";\n\n // prevent lingering circular references from causing memory leaks:\n this.setInput('', {});\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (var i = this.__error_infos.length - 1; i >= 0; i--) {\n var el = this.__error_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n }\n\n return this;\n },\n\n /**\n * clear the lexer token context; intended for internal use only\n *\n * @public\n * @this {RegExpLexer}\n */\n clear: function lexer_clear() {\n \"use strict\";\n\n this.yytext = '';\n this.yyleng = 0;\n this.match = '';\n // - DO NOT reset `this.matched`\n this.matches = false;\n\n this._more = false;\n this._backtrack = false;\n\n var col = this.yylloc.last_column;\n this.yylloc = {\n first_line: this.yylineno + 1,\n first_column: col,\n last_line: this.yylineno + 1,\n last_column: col,\n\n range: [this.offset, this.offset]\n };\n },\n\n /**\n * resets the lexer, sets new input\n *\n * @public\n * @this {RegExpLexer}\n */\n setInput: function lexer_setInput(input, yy) {\n \"use strict\";\n\n this.yy = yy || this.yy || {};\n\n // also check if we've fully initialized the lexer instance,\n // including expansion work to be done to go from a loaded\n // lexer to a usable lexer:\n if (!this.__decompressed) {\n // step 1: decompress the regex list:\n var rules = this.rules;\n for (var i = 0, len = rules.length; i < len; i++) {\n var rule_re = rules[i];\n\n // compression: is the RE an xref to another RE slot in the rules[] table?\n if (typeof rule_re === 'number') {\n rules[i] = rules[rule_re];\n }\n }\n\n // step 2: unfold the conditions[] set to make these ready for use:\n var conditions = this.conditions;\n for (var k in conditions) {\n var spec = conditions[k];\n\n var rule_ids = spec.rules;\n\n var len = rule_ids.length;\n var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple!\n var rule_new_ids = new Array(len + 1);\n\n for (var i = 0; i < len; i++) {\n var idx = rule_ids[i];\n var rule_re = rules[idx];\n rule_regexes[i + 1] = rule_re;\n rule_new_ids[i + 1] = idx;\n }\n\n spec.rules = rule_new_ids;\n spec.__rule_regexes = rule_regexes;\n spec.__rule_count = len;\n }\n\n this.__decompressed = true;\n }\n\n if (input && typeof input !== 'string') {\n input = '' + input;\n }\n this._input = input || '';\n this._clear_state = -1;\n this._signaled_error_token = false;\n this.done = false;\n this.yylineno = 0;\n this.matched = '';\n this.conditionStack = ['INITIAL'];\n this.__currentRuleSet__ = null;\n this.yylloc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [0, 0]\n };\n this.offset = 0;\n this.base_position = 0;\n // apply these bits of `this.clear()` as well:\n this.yytext = '';\n this.yyleng = 0;\n this.match = '';\n this.matches = false;\n\n this._more = false;\n this._backtrack = false;\n\n return this;\n },\n\n /**\n * edit the remaining input via user-specified callback.\n * This can be used to forward-adjust the input-to-parse,\n * e.g. inserting macro expansions and alike in the\n * input which has yet to be lexed.\n * The behaviour of this API contrasts the `unput()` et al\n * APIs as those act on the *consumed* input, while this\n * one allows one to manipulate the future, without impacting\n * the current `yyloc` cursor location or any history.\n *\n * Use this API to help implement C-preprocessor-like\n * `#include` statements, etc.\n *\n * The provided callback must be synchronous and is\n * expected to return the edited input (string).\n *\n * The `cpsArg` argument value is passed to the callback\n * as-is.\n *\n * `callback` interface:\n * `function callback(input, cpsArg)`\n *\n * - `input` will carry the remaining-input-to-lex string\n * from the lexer.\n * - `cpsArg` is `cpsArg` passed into this API.\n *\n * The `this` reference for the callback will be set to\n * reference this lexer instance so that userland code\n * in the callback can easily and quickly access any lexer\n * API.\n *\n * When the callback returns a non-string-type falsey value,\n * we assume the callback did not edit the input and we\n * will using the input as-is.\n *\n * When the callback returns a non-string-type value, it\n * is converted to a string for lexing via the `\"\" + retval`\n * operation. (See also why: http://2ality.com/2012/03/converting-to-string.html\n * -- that way any returned object's `toValue()` and `toString()`\n * methods will be invoked in a proper/desirable order.)\n *\n * @public\n * @this {RegExpLexer}\n */\n editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) {\n \"use strict\";\n\n var rv = callback.call(this, this._input, cpsArg);\n if (typeof rv !== 'string') {\n if (rv) {\n this._input = '' + rv;\n }\n // else: keep `this._input` as is.\n } else {\n this._input = rv;\n }\n return this;\n },\n\n /**\n * consumes and returns one char from the input\n *\n * @public\n * @this {RegExpLexer}\n */\n input: function lexer_input() {\n \"use strict\";\n\n if (!this._input) {\n //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*)\n return null;\n }\n if (!this._clear_state && !this._more) {\n this._clear_state = -1;\n this.clear();\n }\n var ch = this._input[0];\n this.yytext += ch;\n this.yyleng++;\n this.offset++;\n this.match += ch;\n this.matched += ch;\n // Count the linenumber up when we hit the LF (or a stand-alone CR).\n // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo\n // and we advance immediately past the LF as well, returning both together as if\n // it was all a single 'character' only.\n var slice_len = 1;\n var lines = false;\n if (ch === '\\n') {\n lines = true;\n } else if (ch === '\\r') {\n lines = true;\n var ch2 = this._input[1];\n if (ch2 === '\\n') {\n slice_len++;\n ch += ch2;\n this.yytext += ch2;\n this.yyleng++;\n this.offset++;\n this.match += ch2;\n this.matched += ch2;\n this.yylloc.range[1]++;\n }\n }\n if (lines) {\n this.yylineno++;\n this.yylloc.last_line++;\n this.yylloc.last_column = 0;\n } else {\n this.yylloc.last_column++;\n }\n this.yylloc.range[1]++;\n\n this._input = this._input.slice(slice_len);\n return ch;\n },\n\n /**\n * unshifts one char (or an entire string) into the input\n *\n * @public\n * @this {RegExpLexer}\n */\n unput: function lexer_unput(ch) {\n \"use strict\";\n\n var len = ch.length;\n var lines = ch.split(this.CRLF_Re);\n\n if (!this._clear_state && !this._more) {\n this._clear_state = -1;\n this.clear();\n }\n\n this._input = ch + this._input;\n this.yytext = this.yytext.substr(0, this.yytext.length - len);\n this.yyleng = this.yytext.length;\n this.offset -= len;\n // **WARNING:**\n // The `offset` value MAY be negative if you `unput()` more text than you have already lexed.\n // This type of behaviour is generally observed for one kind of 'lexer/parser hack'\n // where custom token-illiciting characters are pushed in front of the input stream to help\n // simulate multiple-START-points in the parser.\n // When this happens, `base_position` will be adjusted to help track the original input's\n // starting point in the `_input` buffer.\n if (-this.offset > this.base_position) {\n this.base_position = -this.offset;\n }\n this.match = this.match.substr(0, this.match.length - len);\n this.matched = this.matched.substr(0, this.matched.length - len);\n\n if (lines.length > 1) {\n this.yylineno -= lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n\n // Get last entirely matched line into the `pre_lines[]` array's\n // last index slot; we don't mind when other previously\n // matched lines end up in the array too.\n var pre = this.match;\n var pre_lines = pre.split(this.CRLF_Re);\n if (pre_lines.length === 1) {\n pre = this.matched;\n pre_lines = pre.split(this.CRLF_Re);\n }\n this.yylloc.last_column = pre_lines[pre_lines.length - 1].length;\n } else {\n this.yylloc.last_column -= len;\n }\n\n this.yylloc.range[1] = this.yylloc.range[0] + this.yyleng;\n\n this.done = false;\n return this;\n },\n\n /**\n * return the upcoming input *which has not been lexed yet*.\n * This can, for example, be used for custom look-ahead inspection code \n * in your lexer.\n * \n * The entire pending input string is returned.\n *\n * > ### NOTE ###\n * >\n * > When augmenting error reports and alike, you might want to\n * > look at the `upcomingInput()` API instead, which offers more\n * > features for limited input extraction and which includes the\n * > part of the input which has been lexed by the last token a.k.a.\n * > the *currently lexed* input.\n * > \n * \n * @public\n * @this {RegExpLexer}\n */\n lookAhead: function lexer_lookAhead() {\n \"use strict\";\n\n return this._input || '';\n },\n\n /**\n * cache matched text and append it on next action\n *\n * @public\n * @this {RegExpLexer}\n */\n more: function lexer_more() {\n \"use strict\";\n\n this._more = true;\n return this;\n },\n\n /**\n * signal the lexer that this rule fails to match the input, so the\n * next matching rule (regex) should be tested instead.\n *\n * @public\n * @this {RegExpLexer}\n */\n reject: function lexer_reject() {\n \"use strict\";\n\n if (this.options.backtrack_lexer) {\n this._backtrack = true;\n } else {\n // when the `parseError()` call returns, we MUST ensure that the error is registered.\n // We accomplish this by signaling an 'error' token to be produced for the current\n // `.lex()` run.\n var lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false);\n this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n return this;\n },\n\n /**\n * retain first n characters of the match\n *\n * @public\n * @this {RegExpLexer}\n */\n less: function lexer_less(n) {\n \"use strict\";\n\n return this.unput(this.match.slice(n));\n },\n\n /**\n * return (part of the) already matched input, i.e. for error\n * messages.\n *\n * Limit the returned string length to `maxSize` (default: 20).\n *\n * Limit the returned string to the `maxLines` number of lines of\n * input (default: 1).\n *\n * A negative `maxSize` limit value equals *unlimited*, i.e.\n * produce the entire input that has already been lexed.\n *\n * A negative `maxLines` limit value equals *unlimited*, i.e. limit the result\n * to the `maxSize` specified number of characters *only*.\n *\n * @public\n * @this {RegExpLexer}\n */\n pastInput: function lexer_pastInput(maxSize, maxLines) {\n \"use strict\";\n\n var past = this.matched.substring(0, this.matched.length - this.match.length);\n if (maxSize < 0)\n maxSize = Infinity;\n else if (!maxSize)\n maxSize = 20;\n if (maxLines < 0)\n maxLines = Infinity; // can't ever have more input lines than this!\n else if (!maxLines)\n maxLines = 1;\n // `substr` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we've transformed and limited the newLines in here:\n past = past.substr(-maxSize * 2 - 2);\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n var a = past.split(this.CRLF_Re);\n a = a.slice(-maxLines);\n past = a.join('\\n');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis prefix...\n if (past.length > maxSize) {\n past = '...' + past.substr(-maxSize);\n }\n return past;\n },\n\n /**\n * return (part of the) upcoming input *including* the input \n * matched by the last token (see also the NOTE below). \n * This can be used to augment error messages, for example.\n *\n * Limit the returned string length to `maxSize` (default: 20).\n *\n * Limit the returned string to the `maxLines` number of lines of input (default: 1).\n *\n * A negative `maxSize` limit value equals *unlimited*, i.e.\n * produce the entire input that is yet to be lexed.\n *\n * A negative `maxLines` limit value equals *unlimited*, i.e. limit the result\n * to the `maxSize` specified number of characters *only*.\n *\n * > ### NOTE ###\n * >\n * > *\"upcoming input\"* is defined as the whole of the both\n * > the *currently lexed* input, together with any remaining input\n * > following that. *\"currently lexed\"* input is the input\n * > already recognized by the lexer but not yet returned with\n * > the lexer token. This happens when you are invoking this API\n * > from inside any lexer rule action code block.\n * >\n * > When you want access to the 'upcoming input' in that you want access\n * > to the input *which has not been lexed yet* for look-ahead\n * > inspection or likewise purposes, please consider using the\n * > `lookAhead()` API instead.\n * > \n * \n * @public\n * @this {RegExpLexer}\n */\n upcomingInput: function lexer_upcomingInput(maxSize, maxLines) {\n \"use strict\";\n\n var next = this.match;\n var source = this._input || '';\n if (maxSize < 0)\n maxSize = next.length + source.length;\n else if (!maxSize)\n maxSize = 20;\n if (maxLines < 0)\n maxLines = maxSize; // can't ever have more input lines than this!\n else if (!maxLines)\n maxLines = 1;\n // `substring` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we've transformed and limited the newLines in here:\n if (next.length < maxSize * 2 + 2) {\n next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8\n }\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines.\n a = a.slice(0, maxLines);\n next = a.join('\\n');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis postfix...\n if (next.length > maxSize) {\n next = next.substring(0, maxSize) + '...';\n }\n return next;\n },\n\n /**\n * return a string which displays the character position where the\n * lexing error occurred, i.e. for error messages\n *\n * @public\n * @this {RegExpLexer}\n */\n showPosition: function lexer_showPosition(maxPrefix, maxPostfix) {\n \"use strict\";\n\n var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' ');\n var c = new Array(pre.length + 1).join('-');\n return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^';\n },\n\n /**\n * return an YYLLOC info object derived off the given context (actual, preceding, following, current).\n * Use this method when the given `actual` location is not guaranteed to exist (i.e. when\n * it MAY be NULL) and you MUST have a valid location info object anyway:\n * then we take the given context of the `preceding` and `following` locations, IFF those are available,\n * and reconstruct the `actual` location info from those.\n * If this fails, the heuristic is to take the `current` location, IFF available.\n * If this fails as well, we assume the sought location is at/around the current lexer position\n * and then produce that one as a response. DO NOTE that these heuristic/derived location info\n * values MAY be inaccurate!\n *\n * NOTE: `deriveLocationInfo()` ALWAYS produces a location info object *copy* of `actual`, not just\n * a *reference* hence all input location objects can be assumed to be 'constant' (function has no side-effects).\n *\n * @public\n * @this {RegExpLexer}\n */\n deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) {\n \"use strict\";\n\n var loc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [0, 0]\n };\n if (actual) {\n loc.first_line = actual.first_line | 0;\n loc.last_line = actual.last_line | 0;\n loc.first_column = actual.first_column | 0;\n loc.last_column = actual.last_column | 0;\n\n if (actual.range) {\n loc.range[0] = actual.range[0] | 0;\n loc.range[1] = actual.range[1] | 0;\n }\n }\n if (loc.first_line <= 0 || loc.last_line < loc.first_line) {\n // plan B: heuristic using preceding and following:\n if (loc.first_line <= 0 && preceding) {\n loc.first_line = preceding.last_line | 0;\n loc.first_column = preceding.last_column | 0;\n\n if (preceding.range) {\n loc.range[0] = actual.range[1] | 0;\n }\n }\n\n if ((loc.last_line <= 0 || loc.last_line < loc.first_line) && following) {\n loc.last_line = following.first_line | 0;\n loc.last_column = following.first_column | 0;\n\n if (following.range) {\n loc.range[1] = actual.range[0] | 0;\n }\n }\n\n // plan C?: see if the 'current' location is useful/sane too:\n if (loc.first_line <= 0 && current && (loc.last_line <= 0 || current.last_line <= loc.last_line)) {\n loc.first_line = current.first_line | 0;\n loc.first_column = current.first_column | 0;\n\n if (current.range) {\n loc.range[0] = current.range[0] | 0;\n }\n }\n\n if (loc.last_line <= 0 && current && (loc.first_line <= 0 || current.first_line >= loc.first_line)) {\n loc.last_line = current.last_line | 0;\n loc.last_column = current.last_column | 0;\n\n if (current.range) {\n loc.range[1] = current.range[1] | 0;\n }\n }\n }\n // sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter\n // or plan D heuristics to produce a 'sensible' last_line value:\n if (loc.last_line <= 0) {\n if (loc.first_line <= 0) {\n loc.first_line = this.yylloc.first_line;\n loc.last_line = this.yylloc.last_line;\n loc.first_column = this.yylloc.first_column;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[0] = this.yylloc.range[0];\n loc.range[1] = this.yylloc.range[1];\n } else {\n loc.last_line = this.yylloc.last_line;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[1] = this.yylloc.range[1];\n }\n }\n if (loc.first_line <= 0) {\n loc.first_line = loc.last_line;\n loc.first_column = 0; // loc.last_column;\n\n loc.range[1] = loc.range[0];\n }\n if (loc.first_column < 0) {\n loc.first_column = 0;\n }\n if (loc.last_column < 0) {\n loc.last_column = (loc.first_column > 0 ? loc.first_column : 80);\n }\n return loc;\n },\n\n /**\n * return a string which displays the lines & columns of input which are referenced\n * by the given location info range, plus a few lines of context.\n *\n * This function pretty-prints the indicated section of the input, with line numbers\n * and everything!\n *\n * This function is very useful to provide highly readable error reports, while\n * the location range may be specified in various flexible ways:\n *\n * - `loc` is the location info object which references the area which should be\n * displayed and 'marked up': these lines & columns of text are marked up by `^`\n * characters below each character in the entire input range.\n *\n * - `context_loc` is the *optional* location info object which instructs this\n * pretty-printer how much *leading* context should be displayed alongside\n * the area referenced by `loc`. This can help provide context for the displayed\n * error, etc.\n *\n * When this location info is not provided, a default context of 3 lines is\n * used.\n *\n * - `context_loc2` is another *optional* location info object, which serves\n * a similar purpose to `context_loc`: it specifies the amount of *trailing*\n * context lines to display in the pretty-print output.\n *\n * When this location info is not provided, a default context of 1 line only is\n * used.\n *\n * Special Notes:\n *\n * - when the `loc`-indicated range is very large (about 5 lines or more), then\n * only the first and last few lines of this block are printed while a\n * `...continued...` message will be printed between them.\n *\n * This serves the purpose of not printing a huge amount of text when the `loc`\n * range happens to be huge: this way a manageable & readable output results\n * for arbitrary large ranges.\n *\n * - this function can display lines of input which whave not yet been lexed.\n * `prettyPrintRange()` can access the entire input!\n *\n * @public\n * @this {RegExpLexer}\n */\n prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) {\n \"use strict\";\n\n loc = this.deriveLocationInfo(loc, context_loc, context_loc2);\n\n const CONTEXT = 3;\n const CONTEXT_TAIL = 1;\n const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2;\n var input = this.matched + (this._input || '');\n var lines = input.split('\\n');\n var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT));\n var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL));\n var lineno_display_width = (1 + Math.log10(l1 | 1) | 0);\n var ws_prefix = new Array(lineno_display_width).join(' ');\n var nonempty_line_indexes = [[], [], []];\n var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) {\n \"use strict\";\n\n var lno = index + l0;\n var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width);\n var rv = lno_pfx + ': ' + line;\n var errpfx = (new Array(lineno_display_width + 1)).join('^');\n var offset = 2 + 1;\n var len = 0;\n\n if (lno === loc.first_line) {\n offset += loc.first_column;\n\n len = Math.max(\n 2,\n ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1\n );\n } else if (lno === loc.last_line) {\n len = Math.max(2, loc.last_column + 1);\n } else if (lno > loc.first_line && lno < loc.last_line) {\n len = Math.max(2, line.length + 1);\n }\n\n var nli;\n if (len) {\n var lead = new Array(offset).join('.');\n var mark = new Array(len).join('^');\n rv += '\\n' + errpfx + lead + mark;\n\n nli = 1;\n } else if (lno < loc.first_line) {\n nli = 0;\n } else if (lno > loc.last_line) {\n nli = 2;\n }\n\n if (line.trim().length > 0) {\n nonempty_line_indexes[nli].push(index);\n }\n\n rv = rv.replace(/\\t/g, ' ');\n return rv;\n });\n\n // now make sure we don't print an overly large amount of lead/error/tail area: limit it\n // to the top and bottom line count:\n for (var i = 0; i <= 2; i++) {\n var line_arr = nonempty_line_indexes[i];\n if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) {\n var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1;\n var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1;\n\n var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)';\n if (i === 1) {\n intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)';\n }\n rv.splice(clip_start, clip_end - clip_start + 1, intermediate_line);\n }\n }\n\n return rv.join('\\n');\n },\n\n /**\n * helper function, used to produce a human readable description as a string, given\n * the input `yylloc` location object.\n *\n * Set `display_range_too` to TRUE to include the string character index position(s)\n * in the description if the `yylloc.range` is available.\n *\n * @public\n * @this {RegExpLexer}\n */\n describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) {\n \"use strict\";\n\n var l1 = yylloc.first_line;\n var l2 = yylloc.last_line;\n var c1 = yylloc.first_column;\n var c2 = yylloc.last_column;\n var dl = l2 - l1;\n var dc = c2 - c1;\n var rv;\n if (dl === 0) {\n rv = 'line ' + l1 + ', ';\n if (dc <= 1) {\n rv += 'column ' + c1;\n } else {\n rv += 'columns ' + c1 + ' .. ' + c2;\n }\n } else {\n rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')';\n }\n if (yylloc.range && display_range_too) {\n var r1 = yylloc.range[0];\n var r2 = yylloc.range[1] - 1;\n if (r2 <= r1) {\n rv += ' {String Offset: ' + r1 + '}';\n } else {\n rv += ' {String Offset range: ' + r1 + ' .. ' + r2 + '}';\n }\n }\n return rv;\n },\n\n /**\n * test the lexed token: return FALSE when not a match, otherwise return token.\n *\n * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]`\n * contains the actually matched text string.\n *\n * Also move the input cursor forward and update the match collectors:\n *\n * - `yytext`\n * - `yyleng`\n * - `match`\n * - `matches`\n * - `yylloc`\n * - `offset`\n *\n * @public\n * @this {RegExpLexer}\n */\n test_match: function lexer_test_match(match, indexed_rule) {\n \"use strict\";\n\n var token,\n lines,\n backup,\n match_str,\n match_str_len;\n\n if (this.options.backtrack_lexer) {\n // save context\n backup = {\n yylineno: this.yylineno,\n yylloc: {\n first_line: this.yylloc.first_line,\n last_line: this.yylloc.last_line,\n first_column: this.yylloc.first_column,\n last_column: this.yylloc.last_column,\n\n range: this.yylloc.range.slice()\n },\n yytext: this.yytext,\n match: this.match,\n matches: this.matches,\n matched: this.matched,\n yyleng: this.yyleng,\n offset: this.offset,\n _more: this._more,\n _input: this._input,\n //_signaled_error_token: this._signaled_error_token,\n yy: this.yy,\n conditionStack: this.conditionStack.slice(),\n done: this.done\n };\n }\n\n match_str = match[0];\n match_str_len = match_str.length;\n\n lines = match_str.split(this.CRLF_Re);\n if (lines.length > 1) {\n this.yylineno += lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n this.yylloc.last_column = lines[lines.length - 1].length;\n } else {\n this.yylloc.last_column += match_str_len;\n }\n\n this.yytext += match_str;\n this.match += match_str;\n this.matched += match_str;\n this.matches = match;\n this.yyleng = this.yytext.length;\n this.yylloc.range[1] += match_str_len;\n\n // previous lex rules MAY have invoked the `more()` API rather than producing a token:\n // those rules will already have moved this `offset` forward matching their match lengths,\n // hence we must only add our own match length now:\n this.offset += match_str_len;\n this._more = false;\n this._backtrack = false;\n this._input = this._input.slice(match_str_len);\n\n // calling this method:\n //\n // function lexer__performAction(yy, yyrulenumber, YY_START) {...}\n token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */);\n // otherwise, when the action codes are all simple return token statements:\n //token = this.simpleCaseActionClusters[indexed_rule];\n\n if (this.done && this._input) {\n this.done = false;\n }\n if (token) {\n return token;\n } else if (this._backtrack) {\n // recover context\n for (var k in backup) {\n this[k] = backup[k];\n }\n this.__currentRuleSet__ = null;\n return false; // rule action called reject() implying the next rule should be tested instead.\n } else if (this._signaled_error_token) {\n // produce one 'error' token as `.parseError()` in `reject()`\n // did not guarantee a failure signal by throwing an exception!\n token = this._signaled_error_token;\n this._signaled_error_token = false;\n return token;\n }\n return false;\n },\n\n /**\n * return next match in input\n *\n * @public\n * @this {RegExpLexer}\n */\n next: function lexer_next() {\n \"use strict\";\n\n if (this.done) {\n this.clear();\n return this.EOF;\n }\n if (!this._input) {\n this.done = true;\n }\n\n var token,\n match,\n tempMatch,\n index;\n if (!this._more) {\n if (!this._clear_state) {\n this._clear_state = 1;\n }\n this.clear();\n }\n var spec = this.__currentRuleSet__;\n if (!spec) {\n // Update the ruleset cache as we apparently encountered a state change or just started lexing.\n // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will\n // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps\n // speed up those activities a tiny bit.\n spec = this.__currentRuleSet__ = this._currentRules();\n // Check whether a *sane* condition has been pushed before: this makes the lexer robust against\n // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19\n if (!spec || !spec.rules) {\n var lineno_msg = '';\n if (this.yylloc) {\n lineno_msg = ' on line ' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name \"' + this.topState() + '\"; this is a fatal error and should be reported to the application programmer team!', false);\n // produce one 'error' token until this situation has been resolved, most probably by parse termination!\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n }\n\n var rule_ids = spec.rules;\n var regexes = spec.__rule_regexes;\n var len = spec.__rule_count;\n\n // Note: the arrays are 1-based, while `len` itself is a valid index,\n // hence the non-standard less-or-equal check in the next loop condition!\n for (var i = 1; i <= len; i++) {\n tempMatch = this._input.match(regexes[i]);\n if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n match = tempMatch;\n index = i;\n if (this.options.backtrack_lexer) {\n token = this.test_match(tempMatch, rule_ids[i]);\n if (token !== false) {\n return token;\n } else if (this._backtrack) {\n match = undefined;\n continue; // rule action called reject() implying a rule MISmatch.\n } else {\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n } else if (!this.options.flex) {\n break;\n }\n }\n }\n if (match) {\n token = this.test_match(match, rule_ids[index]);\n if (token !== false) {\n return token;\n }\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n if (!this._input) {\n this.done = true;\n this.clear();\n return this.EOF;\n } else {\n var lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable);\n\n var pendingInput = this._input;\n var activeCondition = this.topState();\n var conditionStackDepth = this.conditionStack.length;\n\n token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n if (token === this.ERROR) {\n // we can try to recover from a lexer error that `parseError()` did not 'recover' for us\n // by moving forward at least one character at a time IFF the (user-specified?) `parseError()`\n // has not consumed/modified any pending input or changed state in the error handler:\n if (!this.matches &&\n // and make sure the input has been modified/consumed ...\n pendingInput === this._input &&\n // ...or the lexer state has been modified significantly enough\n // to merit a non-consuming error handling action right now.\n activeCondition === this.topState() &&\n conditionStackDepth === this.conditionStack.length\n ) {\n this.input();\n }\n }\n return token;\n }\n },\n\n /**\n * return next match that has a token\n *\n * @public\n * @this {RegExpLexer}\n */\n lex: function lexer_lex() {\n \"use strict\";\n\n var r;\n\n //this._clear_state = 0;\n\n if (!this._more) {\n if (!this._clear_state) {\n this._clear_state = 1;\n }\n this.clear();\n }\n\n // allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer:\n if (typeof this.pre_lex === 'function') {\n r = this.pre_lex.call(this, 0);\n }\n if (typeof this.options.pre_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.pre_lex.call(this, r) || r;\n }\n if (this.yy && typeof this.yy.pre_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.pre_lex.call(this, r) || r;\n }\n\n while (!r) {\n r = this.next();\n }\n\n if (this.yy && typeof this.yy.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.post_lex.call(this, r) || r;\n }\n if (typeof this.options.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.post_lex.call(this, r) || r;\n }\n if (typeof this.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.post_lex.call(this, r) || r;\n }\n\n if (!this._more) {\n //\n // 1) make sure any outside interference is detected ASAP: \n // these attributes are to be treated as 'const' values\n // once the lexer has produced them with the token (return value `r`).\n // 2) make sure any subsequent `lex()` API invocation CANNOT\n // edit the `yytext`, etc. token attributes for the *current*\n // token, i.e. provide a degree of 'closure safety' so that\n // code like this:\n // \n // t1 = lexer.lex();\n // v = lexer.yytext;\n // l = lexer.yylloc;\n // t2 = lexer.lex();\n // assert(lexer.yytext !== v);\n // assert(lexer.yylloc !== l);\n // \n // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee*\n // these conditions.\n // \n this.yytext = Object.freeze(this.yytext);\n this.matches = Object.freeze(this.matches);\n this.yylloc.range = Object.freeze(this.yylloc.range);\n this.yylloc = Object.freeze(this.yylloc);\n\n this._clear_state = 0;\n }\n\n return r;\n },\n\n /**\n * return next match that has a token. Identical to the `lex()` API but does not invoke any of the\n * `pre_lex()` nor any of the `post_lex()` callbacks.\n *\n * @public\n * @this {RegExpLexer}\n */\n fastLex: function lexer_fastLex() {\n \"use strict\";\n\n var r;\n\n //this._clear_state = 0;\n\n while (!r) {\n r = this.next();\n }\n\n if (!this._more) {\n //\n // 1) make sure any outside interference is detected ASAP: \n // these attributes are to be treated as 'const' values\n // once the lexer has produced them with the token (return value `r`).\n // 2) make sure any subsequent `lex()` API invocation CANNOT\n // edit the `yytext`, etc. token attributes for the *current*\n // token, i.e. provide a degree of 'closure safety' so that\n // code like this:\n // \n // t1 = lexer.lex();\n // v = lexer.yytext;\n // l = lexer.yylloc;\n // t2 = lexer.lex();\n // assert(lexer.yytext !== v);\n // assert(lexer.yylloc !== l);\n // \n // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee*\n // these conditions.\n // \n this.yytext = Object.freeze(this.yytext);\n this.matches = Object.freeze(this.matches);\n this.yylloc.range = Object.freeze(this.yylloc.range);\n this.yylloc = Object.freeze(this.yylloc);\n\n this._clear_state = 0;\n }\n \n return r;\n },\n\n /**\n * return info about the lexer state that can help a parser or other lexer API user to use the\n * most efficient means available. This API is provided to aid run-time performance for larger\n * systems which employ this lexer.\n *\n * @public\n * @this {RegExpLexer}\n */\n canIUse: function lexer_canIUse() {\n \"use strict\";\n\n var rv = {\n fastLex: !(\n typeof this.pre_lex === 'function' ||\n typeof this.options.pre_lex === 'function' ||\n (this.yy && typeof this.yy.pre_lex === 'function') ||\n (this.yy && typeof this.yy.post_lex === 'function') ||\n typeof this.options.post_lex === 'function' ||\n typeof this.post_lex === 'function'\n ) && typeof this.fastLex === 'function',\n };\n return rv;\n },\n\n\n /**\n * backwards compatible alias for `pushState()`;\n * the latter is symmetrical with `popState()` and we advise to use\n * those APIs in any modern lexer code, rather than `begin()`.\n *\n * @public\n * @this {RegExpLexer}\n */\n begin: function lexer_begin(condition) {\n \"use strict\";\n\n return this.pushState(condition);\n },\n\n /**\n * activates a new lexer condition state (pushes the new lexer\n * condition state onto the condition stack)\n *\n * @public\n * @this {RegExpLexer}\n */\n pushState: function lexer_pushState(condition) {\n \"use strict\";\n\n this.conditionStack.push(condition);\n this.__currentRuleSet__ = null;\n return this;\n },\n\n /**\n * pop the previously active lexer condition state off the condition\n * stack\n *\n * @public\n * @this {RegExpLexer}\n */\n popState: function lexer_popState() {\n \"use strict\";\n\n var n = this.conditionStack.length - 1;\n if (n > 0) {\n this.__currentRuleSet__ = null;\n return this.conditionStack.pop();\n } else {\n return this.conditionStack[0];\n }\n },\n\n /**\n * return the currently active lexer condition state; when an index\n * argument is provided it produces the N-th previous condition state,\n * if available\n *\n * @public\n * @this {RegExpLexer}\n */\n topState: function lexer_topState(n) {\n \"use strict\";\n\n n = this.conditionStack.length - 1 - Math.abs(n || 0);\n if (n >= 0) {\n return this.conditionStack[n];\n } else {\n return 'INITIAL';\n }\n },\n\n /**\n * (internal) determine the lexer rule set which is active for the\n * currently active lexer condition state\n *\n * @public\n * @this {RegExpLexer}\n */\n _currentRules: function lexer__currentRules() {\n \"use strict\";\n\n var n = this.conditionStack.length - 1;\n var state;\n if (n >= 0) {\n state = this.conditionStack[n];\n } else {\n state = 'INITIAL';\n }\n return this.conditions[state] || this.conditions['INITIAL'];\n },\n\n /**\n * return the number of states currently on the stack\n *\n * @public\n * @this {RegExpLexer}\n */\n stateStackSize: function lexer_stateStackSize() {\n \"use strict\";\n\n return this.conditionStack.length;\n }\n}"; // --- END lexer kernel --- + return "{\n EOF: 1,\n ERROR: 2,\n\n // JisonLexerError: JisonLexerError, /// <-- injected by the code generator\n\n // options: {}, /// <-- injected by the code generator\n\n // yy: ..., /// <-- injected by setInput()\n\n __currentRuleSet__: null, /// INTERNAL USE ONLY: internal rule set cache for the current lexer state\n\n __error_infos: [], /// INTERNAL USE ONLY: the set of lexErrorInfo objects created since the last cleanup\n\n __decompressed: false, /// INTERNAL USE ONLY: mark whether the lexer instance has been 'unfolded' completely and is now ready for use\n\n done: false, /// INTERNAL USE ONLY\n _backtrack: false, /// INTERNAL USE ONLY\n _input: '', /// INTERNAL USE ONLY\n _more: false, /// INTERNAL USE ONLY\n _signaled_error_token: false, /// INTERNAL USE ONLY\n _clear_state: 0, /// INTERNAL USE ONLY; 0: clear to do, 1: clear done for lex()/next(); -1: clear done for inut()/unput()/...\n\n conditionStack: [], /// INTERNAL USE ONLY; managed via `pushState()`, `popState()`, `topState()` and `stateStackSize()`\n\n match: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction. `match` is identical to `yytext` except that this one still contains the matched input string after `lexer.performAction()` has been invoked, where userland code MAY have changed/replaced the `yytext` value entirely!\n matched: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks entire input which has been matched so far\n matches: false, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks RE match result for last (successful) match attempt\n yytext: '', /// ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction; this value is transferred to the parser as the 'token value' when the parser consumes the lexer token produced through a call to the `lex()` API.\n offset: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks the 'cursor position' in the input string, i.e. the number of characters matched so far. (**WARNING:** this value MAY be negative if you `unput()` more text than you have already lexed. This type of behaviour is generally observed for one kind of 'lexer/parser hack' where custom token-illiciting characters are pushed in front of the input stream to help simulate multiple-START-points in the parser. When this happens, `base_position` will be adjusted to help track the original input's starting point in the `_input` buffer.)\n base_position: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: index to the original starting point of the input; always ZERO(0) unless `unput()` has pushed content before the input: see the `offset` **WARNING** just above.\n yyleng: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: length of matched input for the token under construction (`yytext`)\n yylineno: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: 'line number' at which the token under construction is located\n yylloc: null, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks location info (lines + columns) for the token under construction\n CRLF_Re: /\\r\\n?|\\n/, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: regex used to split lines while tracking the lexer cursor position.\n\n /**\n * INTERNAL USE: construct a suitable error info hash object instance for `parseError`.\n *\n * @public\n * @this {RegExpLexer}\n */\n constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) {\n msg = '' + msg;\n\n // heuristic to determine if the error message already contains a (partial) source code dump\n // as produced by either `showPosition()` or `prettyPrintRange()`:\n if (show_input_position == undefined) {\n show_input_position = !(msg.indexOf('\\n') > 0 && msg.indexOf('^') > 0);\n }\n if (this.yylloc && show_input_position) {\n if (typeof this.prettyPrintRange === 'function') {\n const pretty_src = this.prettyPrintRange(this.yylloc);\n\n if (!/\\n\\s*$/.test(msg)) {\n msg += '\\n';\n }\n msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc);\n } else if (typeof this.showPosition === 'function') {\n const pos_str = this.showPosition();\n if (pos_str) {\n if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') {\n msg += '\\n' + pos_str;\n } else {\n msg += pos_str;\n }\n }\n }\n }\n /** @constructor */\n const pei = {\n errStr: msg,\n recoverable: !!recoverable,\n text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'...\n token: null,\n line: this.yylineno,\n loc: this.yylloc,\n yy: this.yy,\n lexer: this,\n\n /**\n * and make sure the error info doesn't stay due to potential\n * ref cycle via userland code manipulations.\n * These would otherwise all be memory leak opportunities!\n *\n * Note that only array and object references are nuked as those\n * constitute the set of elements which can produce a cyclic ref.\n * The rest of the members is kept intact as they are harmless.\n *\n * @public\n * @this {LexErrorInfo}\n */\n destroy: function destructLexErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // ...\n const rec = !!this.recoverable;\n for (let key in this) {\n if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n },\n\n /**\n * handler which is invoked when a lexer error occurs.\n *\n * @public\n * @this {RegExpLexer}\n */\n parseError: function lexer_parseError(str, hash, ExceptionClass) {\n if (!ExceptionClass) {\n ExceptionClass = this.JisonLexerError;\n }\n if (this.yy) {\n if (this.yy.parser && typeof this.yy.parser.parseError === 'function') {\n return this.yy.parser.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n } else if (typeof this.yy.parseError === 'function') {\n return this.yy.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n }\n }\n throw new ExceptionClass(str, hash);\n },\n\n /**\n * method which implements `yyerror(str, ...args)` functionality for use inside lexer actions.\n *\n * @public\n * @this {RegExpLexer}\n */\n yyerror: function yyError(str /*, ...args */) {\n let lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable);\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n let args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n p.extra_error_attributes = args;\n }\n\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n },\n\n /**\n * final cleanup function for when we have completed lexing the input;\n * make it an API so that external code can use this one once userland\n * code has decided it's time to destroy any lingering lexer error\n * hash object instances and the like: this function helps to clean\n * up these constructs, which *may* carry cyclic references which would\n * otherwise prevent the instances from being properly and timely\n * garbage-collected, i.e. this function helps prevent memory leaks!\n *\n * @public\n * @this {RegExpLexer}\n */\n cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) {\n // prevent lingering circular references from causing memory leaks:\n this.setInput('', {});\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (let i = this.__error_infos.length - 1; i >= 0; i--) {\n let el = this.__error_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n }\n\n return this;\n },\n\n /**\n * clear the lexer token context; intended for internal use only\n *\n * @public\n * @this {RegExpLexer}\n */\n clear: function lexer_clear() {\n this.yytext = '';\n this.yyleng = 0;\n this.match = '';\n // - DO NOT reset `this.matched`\n this.matches = false;\n\n this._more = false;\n this._backtrack = false;\n\n const col = this.yylloc.last_column;\n this.yylloc = {\n first_line: this.yylineno + 1,\n first_column: col,\n last_line: this.yylineno + 1,\n last_column: col,\n\n range: [ this.offset, this.offset ]\n };\n },\n\n /**\n * resets the lexer, sets new input\n *\n * @public\n * @this {RegExpLexer}\n */\n setInput: function lexer_setInput(input, yy) {\n this.yy = yy || this.yy || {};\n\n // also check if we've fully initialized the lexer instance,\n // including expansion work to be done to go from a loaded\n // lexer to a usable lexer:\n if (!this.__decompressed) {\n // step 1: decompress the regex list:\n let rules = this.rules;\n for (var i = 0, len = rules.length; i < len; i++) {\n var rule_re = rules[i];\n\n // compression: is the RE an xref to another RE slot in the rules[] table?\n if (typeof rule_re === 'number') {\n rules[i] = rules[rule_re];\n }\n }\n\n // step 2: unfold the conditions[] set to make these ready for use:\n let conditions = this.conditions;\n for (let k in conditions) {\n let spec = conditions[k];\n\n let rule_ids = spec.rules;\n\n var len = rule_ids.length;\n let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple!\n let rule_new_ids = new Array(len + 1);\n\n for (var i = 0; i < len; i++) {\n let idx = rule_ids[i];\n var rule_re = rules[idx];\n rule_regexes[i + 1] = rule_re;\n rule_new_ids[i + 1] = idx;\n }\n\n spec.rules = rule_new_ids;\n spec.__rule_regexes = rule_regexes;\n spec.__rule_count = len;\n }\n\n this.__decompressed = true;\n }\n\n if (input && typeof input !== 'string') {\n input = '' + input;\n }\n this._input = input || '';\n this._clear_state = -1;\n this._signaled_error_token = false;\n this.done = false;\n this.yylineno = 0;\n this.matched = '';\n this.conditionStack = [ 'INITIAL' ];\n this.__currentRuleSet__ = null;\n this.yylloc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [ 0, 0 ]\n };\n this.offset = 0;\n this.base_position = 0;\n // apply these bits of `this.clear()` as well:\n this.yytext = '';\n this.yyleng = 0;\n this.match = '';\n this.matches = false;\n\n this._more = false;\n this._backtrack = false;\n\n return this;\n },\n\n /**\n * edit the remaining input via user-specified callback.\n * This can be used to forward-adjust the input-to-parse,\n * e.g. inserting macro expansions and alike in the\n * input which has yet to be lexed.\n * The behaviour of this API contrasts the `unput()` et al\n * APIs as those act on the *consumed* input, while this\n * one allows one to manipulate the future, without impacting\n * the current `yyloc` cursor location or any history.\n *\n * Use this API to help implement C-preprocessor-like\n * `#include` statements, etc.\n *\n * The provided callback must be synchronous and is\n * expected to return the edited input (string).\n *\n * The `cpsArg` argument value is passed to the callback\n * as-is.\n *\n * `callback` interface:\n * `function callback(input, cpsArg)`\n *\n * - `input` will carry the remaining-input-to-lex string\n * from the lexer.\n * - `cpsArg` is `cpsArg` passed into this API.\n *\n * The `this` reference for the callback will be set to\n * reference this lexer instance so that userland code\n * in the callback can easily and quickly access any lexer\n * API.\n *\n * When the callback returns a non-string-type falsey value,\n * we assume the callback did not edit the input and we\n * will using the input as-is.\n *\n * When the callback returns a non-string-type value, it\n * is converted to a string for lexing via the `\"\" + retval`\n * operation. (See also why: http://2ality.com/2012/03/converting-to-string.html\n * -- that way any returned object's `toValue()` and `toString()`\n * methods will be invoked in a proper/desirable order.)\n *\n * @public\n * @this {RegExpLexer}\n */\n editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) {\n const rv = callback.call(this, this._input, cpsArg);\n if (typeof rv !== 'string') {\n if (rv) {\n this._input = '' + rv;\n }\n // else: keep `this._input` as is.\n } else {\n this._input = rv;\n }\n return this;\n },\n\n /**\n * consumes and returns one char from the input\n *\n * @public\n * @this {RegExpLexer}\n */\n input: function lexer_input() {\n if (!this._input) {\n //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*)\n return null;\n }\n if (!this._clear_state && !this._more) {\n this._clear_state = -1;\n this.clear();\n }\n let ch = this._input[0];\n this.yytext += ch;\n this.yyleng++;\n this.offset++;\n this.match += ch;\n this.matched += ch;\n // Count the linenumber up when we hit the LF (or a stand-alone CR).\n // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo\n // and we advance immediately past the LF as well, returning both together as if\n // it was all a single 'character' only.\n let slice_len = 1;\n let lines = false;\n if (ch === '\\n') {\n lines = true;\n } else if (ch === '\\r') {\n lines = true;\n const ch2 = this._input[1];\n if (ch2 === '\\n') {\n slice_len++;\n ch += ch2;\n this.yytext += ch2;\n this.yyleng++;\n this.offset++;\n this.match += ch2;\n this.matched += ch2;\n this.yylloc.range[1]++;\n }\n }\n if (lines) {\n this.yylineno++;\n this.yylloc.last_line++;\n this.yylloc.last_column = 0;\n } else {\n this.yylloc.last_column++;\n }\n this.yylloc.range[1]++;\n\n this._input = this._input.slice(slice_len);\n return ch;\n },\n\n /**\n * unshifts one char (or an entire string) into the input\n *\n * @public\n * @this {RegExpLexer}\n */\n unput: function lexer_unput(ch) {\n let len = ch.length;\n let lines = ch.split(this.CRLF_Re);\n\n if (!this._clear_state && !this._more) {\n this._clear_state = -1;\n this.clear();\n }\n\n this._input = ch + this._input;\n this.yytext = this.yytext.substr(0, this.yytext.length - len);\n this.yyleng = this.yytext.length;\n this.offset -= len;\n // **WARNING:**\n // The `offset` value MAY be negative if you `unput()` more text than you have already lexed.\n // This type of behaviour is generally observed for one kind of 'lexer/parser hack'\n // where custom token-illiciting characters are pushed in front of the input stream to help\n // simulate multiple-START-points in the parser.\n // When this happens, `base_position` will be adjusted to help track the original input's\n // starting point in the `_input` buffer.\n if (-this.offset > this.base_position) {\n this.base_position = -this.offset;\n }\n this.match = this.match.substr(0, this.match.length - len);\n this.matched = this.matched.substr(0, this.matched.length - len);\n\n if (lines.length > 1) {\n this.yylineno -= lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n\n // Get last entirely matched line into the `pre_lines[]` array's\n // last index slot; we don't mind when other previously\n // matched lines end up in the array too.\n let pre = this.match;\n let pre_lines = pre.split(this.CRLF_Re);\n if (pre_lines.length === 1) {\n pre = this.matched;\n pre_lines = pre.split(this.CRLF_Re);\n }\n this.yylloc.last_column = pre_lines[pre_lines.length - 1].length;\n } else {\n this.yylloc.last_column -= len;\n }\n\n this.yylloc.range[1] = this.yylloc.range[0] + this.yyleng;\n\n this.done = false;\n return this;\n },\n\n /**\n * return the upcoming input *which has not been lexed yet*.\n * This can, for example, be used for custom look-ahead inspection code\n * in your lexer.\n *\n * The entire pending input string is returned.\n *\n * > ### NOTE ###\n * >\n * > When augmenting error reports and alike, you might want to\n * > look at the `upcomingInput()` API instead, which offers more\n * > features for limited input extraction and which includes the\n * > part of the input which has been lexed by the last token a.k.a.\n * > the *currently lexed* input.\n * >\n *\n * @public\n * @this {RegExpLexer}\n */\n lookAhead: function lexer_lookAhead() {\n return this._input || '';\n },\n\n /**\n * cache matched text and append it on next action\n *\n * @public\n * @this {RegExpLexer}\n */\n more: function lexer_more() {\n this._more = true;\n return this;\n },\n\n /**\n * signal the lexer that this rule fails to match the input, so the\n * next matching rule (regex) should be tested instead.\n *\n * @public\n * @this {RegExpLexer}\n */\n reject: function lexer_reject() {\n if (this.options.backtrack_lexer) {\n this._backtrack = true;\n } else {\n // when the `parseError()` call returns, we MUST ensure that the error is registered.\n // We accomplish this by signaling an 'error' token to be produced for the current\n // `.lex()` run.\n let lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false);\n this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n return this;\n },\n\n /**\n * retain first n characters of the match\n *\n * @public\n * @this {RegExpLexer}\n */\n less: function lexer_less(n) {\n return this.unput(this.match.slice(n));\n },\n\n /**\n * return (part of the) already matched input, i.e. for error\n * messages.\n *\n * Limit the returned string length to `maxSize` (default: 20).\n *\n * Limit the returned string to the `maxLines` number of lines of\n * input (default: 1).\n *\n * A negative `maxSize` limit value equals *unlimited*, i.e.\n * produce the entire input that has already been lexed.\n *\n * A negative `maxLines` limit value equals *unlimited*, i.e. limit the result\n * to the `maxSize` specified number of characters *only*.\n *\n * @public\n * @this {RegExpLexer}\n */\n pastInput: function lexer_pastInput(maxSize, maxLines) {\n let past = this.matched.substring(0, this.matched.length - this.match.length);\n if (maxSize < 0) {\n maxSize = Infinity;\n } else if (!maxSize) {\n maxSize = 20;\n }\n if (maxLines < 0) {\n maxLines = Infinity; // can't ever have more input lines than this!\n } else if (!maxLines) {\n maxLines = 1;\n }\n // `substr` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we've transformed and limited the newLines in here:\n past = past.substr(-maxSize * 2 - 2);\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n let a = past.split(this.CRLF_Re);\n a = a.slice(-maxLines);\n past = a.join('\\n');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis prefix...\n if (past.length > maxSize) {\n past = '...' + past.substr(-maxSize);\n }\n return past;\n },\n\n /**\n * return (part of the) upcoming input *including* the input\n * matched by the last token (see also the NOTE below).\n * This can be used to augment error messages, for example.\n *\n * Limit the returned string length to `maxSize` (default: 20).\n *\n * Limit the returned string to the `maxLines` number of lines of input (default: 1).\n *\n * A negative `maxSize` limit value equals *unlimited*, i.e.\n * produce the entire input that is yet to be lexed.\n *\n * A negative `maxLines` limit value equals *unlimited*, i.e. limit the result\n * to the `maxSize` specified number of characters *only*.\n *\n * > ### NOTE ###\n * >\n * > *\"upcoming input\"* is defined as the whole of the both\n * > the *currently lexed* input, together with any remaining input\n * > following that. *\"currently lexed\"* input is the input\n * > already recognized by the lexer but not yet returned with\n * > the lexer token. This happens when you are invoking this API\n * > from inside any lexer rule action code block.\n * >\n * > When you want access to the 'upcoming input' in that you want access\n * > to the input *which has not been lexed yet* for look-ahead\n * > inspection or likewise purposes, please consider using the\n * > `lookAhead()` API instead.\n * >\n *\n * @public\n * @this {RegExpLexer}\n */\n upcomingInput: function lexer_upcomingInput(maxSize, maxLines) {\n let next = this.match;\n let source = this._input || '';\n if (maxSize < 0) {\n maxSize = next.length + source.length;\n } else if (!maxSize) {\n maxSize = 20;\n }\n\n if (maxLines < 0) {\n maxLines = maxSize; // can't ever have more input lines than this!\n } else if (!maxLines) {\n maxLines = 1;\n }\n // `substring` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we've transformed and limited the newLines in here:\n if (next.length < maxSize * 2 + 2) {\n next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8\n }\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines.\n a = a.slice(0, maxLines);\n next = a.join('\\n');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis postfix...\n if (next.length > maxSize) {\n next = next.substring(0, maxSize) + '...';\n }\n return next;\n },\n\n /**\n * return a string which displays the character position where the\n * lexing error occurred, i.e. for error messages\n *\n * @public\n * @this {RegExpLexer}\n */\n showPosition: function lexer_showPosition(maxPrefix, maxPostfix) {\n const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' ');\n let c = new Array(pre.length + 1).join('-');\n return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^';\n },\n\n /**\n * return an YYLLOC info object derived off the given context (actual, preceding, following, current).\n * Use this method when the given `actual` location is not guaranteed to exist (i.e. when\n * it MAY be NULL) and you MUST have a valid location info object anyway:\n * then we take the given context of the `preceding` and `following` locations, IFF those are available,\n * and reconstruct the `actual` location info from those.\n * If this fails, the heuristic is to take the `current` location, IFF available.\n * If this fails as well, we assume the sought location is at/around the current lexer position\n * and then produce that one as a response. DO NOTE that these heuristic/derived location info\n * values MAY be inaccurate!\n *\n * NOTE: `deriveLocationInfo()` ALWAYS produces a location info object *copy* of `actual`, not just\n * a *reference* hence all input location objects can be assumed to be 'constant' (function has no side-effects).\n *\n * @public\n * @this {RegExpLexer}\n */\n deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) {\n let loc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [ 0, 0 ]\n };\n if (actual) {\n loc.first_line = actual.first_line | 0;\n loc.last_line = actual.last_line | 0;\n loc.first_column = actual.first_column | 0;\n loc.last_column = actual.last_column | 0;\n\n if (actual.range) {\n loc.range[0] = actual.range[0] | 0;\n loc.range[1] = actual.range[1] | 0;\n }\n }\n if (loc.first_line <= 0 || loc.last_line < loc.first_line) {\n // plan B: heuristic using preceding and following:\n if (loc.first_line <= 0 && preceding) {\n loc.first_line = preceding.last_line | 0;\n loc.first_column = preceding.last_column | 0;\n\n if (preceding.range) {\n loc.range[0] = actual.range[1] | 0;\n }\n }\n\n if ((loc.last_line <= 0 || loc.last_line < loc.first_line) && following) {\n loc.last_line = following.first_line | 0;\n loc.last_column = following.first_column | 0;\n\n if (following.range) {\n loc.range[1] = actual.range[0] | 0;\n }\n }\n\n // plan C?: see if the 'current' location is useful/sane too:\n if (loc.first_line <= 0 && current && (loc.last_line <= 0 || current.last_line <= loc.last_line)) {\n loc.first_line = current.first_line | 0;\n loc.first_column = current.first_column | 0;\n\n if (current.range) {\n loc.range[0] = current.range[0] | 0;\n }\n }\n\n if (loc.last_line <= 0 && current && (loc.first_line <= 0 || current.first_line >= loc.first_line)) {\n loc.last_line = current.last_line | 0;\n loc.last_column = current.last_column | 0;\n\n if (current.range) {\n loc.range[1] = current.range[1] | 0;\n }\n }\n }\n // sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter\n // or plan D heuristics to produce a 'sensible' last_line value:\n if (loc.last_line <= 0) {\n if (loc.first_line <= 0) {\n loc.first_line = this.yylloc.first_line;\n loc.last_line = this.yylloc.last_line;\n loc.first_column = this.yylloc.first_column;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[0] = this.yylloc.range[0];\n loc.range[1] = this.yylloc.range[1];\n } else {\n loc.last_line = this.yylloc.last_line;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[1] = this.yylloc.range[1];\n }\n }\n if (loc.first_line <= 0) {\n loc.first_line = loc.last_line;\n loc.first_column = 0; // loc.last_column;\n\n loc.range[1] = loc.range[0];\n }\n if (loc.first_column < 0) {\n loc.first_column = 0;\n }\n if (loc.last_column < 0) {\n loc.last_column = (loc.first_column > 0 ? loc.first_column : 80);\n }\n return loc;\n },\n\n /**\n * return a string which displays the lines & columns of input which are referenced\n * by the given location info range, plus a few lines of context.\n *\n * This function pretty-prints the indicated section of the input, with line numbers\n * and everything!\n *\n * This function is very useful to provide highly readable error reports, while\n * the location range may be specified in various flexible ways:\n *\n * - `loc` is the location info object which references the area which should be\n * displayed and 'marked up': these lines & columns of text are marked up by `^`\n * characters below each character in the entire input range.\n *\n * - `context_loc` is the *optional* location info object which instructs this\n * pretty-printer how much *leading* context should be displayed alongside\n * the area referenced by `loc`. This can help provide context for the displayed\n * error, etc.\n *\n * When this location info is not provided, a default context of 3 lines is\n * used.\n *\n * - `context_loc2` is another *optional* location info object, which serves\n * a similar purpose to `context_loc`: it specifies the amount of *trailing*\n * context lines to display in the pretty-print output.\n *\n * When this location info is not provided, a default context of 1 line only is\n * used.\n *\n * Special Notes:\n *\n * - when the `loc`-indicated range is very large (about 5 lines or more), then\n * only the first and last few lines of this block are printed while a\n * `...continued...` message will be printed between them.\n *\n * This serves the purpose of not printing a huge amount of text when the `loc`\n * range happens to be huge: this way a manageable & readable output results\n * for arbitrary large ranges.\n *\n * - this function can display lines of input which whave not yet been lexed.\n * `prettyPrintRange()` can access the entire input!\n *\n * @public\n * @this {RegExpLexer}\n */\n prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) {\n loc = this.deriveLocationInfo(loc, context_loc, context_loc2);\n\n const CONTEXT = 3;\n const CONTEXT_TAIL = 1;\n const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2;\n let input = this.matched + (this._input || '');\n let lines = input.split('\\n');\n let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT));\n let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL));\n let lineno_display_width = (1 + Math.log10(l1 | 1) | 0);\n let ws_prefix = new Array(lineno_display_width).join(' ');\n let nonempty_line_indexes = [ [], [], [] ];\n let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) {\n let lno = index + l0;\n let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width);\n let rv = lno_pfx + ': ' + line;\n let errpfx = (new Array(lineno_display_width + 1)).join('^');\n let offset = 2 + 1;\n let len = 0;\n\n if (lno === loc.first_line) {\n offset += loc.first_column;\n\n len = Math.max(\n 2,\n ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1\n );\n } else if (lno === loc.last_line) {\n len = Math.max(2, loc.last_column + 1);\n } else if (lno > loc.first_line && lno < loc.last_line) {\n len = Math.max(2, line.length + 1);\n }\n\n let nli;\n if (len) {\n let lead = new Array(offset).join('.');\n let mark = new Array(len).join('^');\n rv += '\\n' + errpfx + lead + mark;\n\n nli = 1;\n } else if (lno < loc.first_line) {\n nli = 0;\n } else if (lno > loc.last_line) {\n nli = 2;\n }\n\n if (line.trim().length > 0) {\n nonempty_line_indexes[nli].push(index);\n }\n\n rv = rv.replace(/\\t/g, ' ');\n return rv;\n });\n\n // now make sure we don't print an overly large amount of lead/error/tail area: limit it\n // to the top and bottom line count:\n for (let i = 0; i <= 2; i++) {\n let line_arr = nonempty_line_indexes[i];\n if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) {\n let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1;\n let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1;\n\n let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)';\n if (i === 1) {\n intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)';\n }\n rv.splice(clip_start, clip_end - clip_start + 1, intermediate_line);\n }\n }\n\n return rv.join('\\n');\n },\n\n /**\n * helper function, used to produce a human readable description as a string, given\n * the input `yylloc` location object.\n *\n * Set `display_range_too` to TRUE to include the string character index position(s)\n * in the description if the `yylloc.range` is available.\n *\n * @public\n * @this {RegExpLexer}\n */\n describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) {\n let l1 = yylloc.first_line;\n let l2 = yylloc.last_line;\n let c1 = yylloc.first_column;\n let c2 = yylloc.last_column;\n let dl = l2 - l1;\n let dc = c2 - c1;\n let rv;\n if (dl === 0) {\n rv = 'line ' + l1 + ', ';\n if (dc <= 1) {\n rv += 'column ' + c1;\n } else {\n rv += 'columns ' + c1 + ' .. ' + c2;\n }\n } else {\n rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')';\n }\n if (yylloc.range && display_range_too) {\n let r1 = yylloc.range[0];\n let r2 = yylloc.range[1] - 1;\n if (r2 <= r1) {\n rv += ' {String Offset: ' + r1 + '}';\n } else {\n rv += ' {String Offset range: ' + r1 + ' .. ' + r2 + '}';\n }\n }\n return rv;\n },\n\n /**\n * test the lexed token: return FALSE when not a match, otherwise return token.\n *\n * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]`\n * contains the actually matched text string.\n *\n * Also move the input cursor forward and update the match collectors:\n *\n * - `yytext`\n * - `yyleng`\n * - `match`\n * - `matches`\n * - `yylloc`\n * - `offset`\n *\n * @public\n * @this {RegExpLexer}\n */\n test_match: function lexer_test_match(match, indexed_rule) {\n let backup;\n\n if (this.options.backtrack_lexer) {\n // save context\n backup = {\n yylineno: this.yylineno,\n yylloc: {\n first_line: this.yylloc.first_line,\n last_line: this.yylloc.last_line,\n first_column: this.yylloc.first_column,\n last_column: this.yylloc.last_column,\n\n range: this.yylloc.range.slice()\n },\n yytext: this.yytext,\n match: this.match,\n matches: this.matches,\n matched: this.matched,\n yyleng: this.yyleng,\n offset: this.offset,\n _more: this._more,\n _input: this._input,\n //_signaled_error_token: this._signaled_error_token,\n yy: this.yy,\n conditionStack: this.conditionStack.slice(),\n done: this.done\n };\n }\n\n let match_str = match[0];\n let match_str_len = match_str.length;\n\n let lines = match_str.split(this.CRLF_Re);\n if (lines.length > 1) {\n this.yylineno += lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n this.yylloc.last_column = lines[lines.length - 1].length;\n } else {\n this.yylloc.last_column += match_str_len;\n }\n\n this.yytext += match_str;\n this.match += match_str;\n this.matched += match_str;\n this.matches = match;\n this.yyleng = this.yytext.length;\n this.yylloc.range[1] += match_str_len;\n\n // previous lex rules MAY have invoked the `more()` API rather than producing a token:\n // those rules will already have moved this `offset` forward matching their match lengths,\n // hence we must only add our own match length now:\n this.offset += match_str_len;\n this._more = false;\n this._backtrack = false;\n this._input = this._input.slice(match_str_len);\n\n // calling this method:\n //\n // function lexer__performAction(yy, yyrulenumber, YY_START) {...}\n let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */);\n // otherwise, when the action codes are all simple return token statements:\n //token = this.simpleCaseActionClusters[indexed_rule];\n\n if (this.done && this._input) {\n this.done = false;\n }\n if (token) {\n return token;\n } else if (this._backtrack) {\n // recover context\n for (let k in backup) {\n this[k] = backup[k];\n }\n this.__currentRuleSet__ = null;\n return false; // rule action called reject() implying the next rule should be tested instead.\n } else if (this._signaled_error_token) {\n // produce one 'error' token as `.parseError()` in `reject()`\n // did not guarantee a failure signal by throwing an exception!\n token = this._signaled_error_token;\n this._signaled_error_token = false;\n return token;\n }\n return false;\n },\n\n /**\n * return next match in input\n *\n * @public\n * @this {RegExpLexer}\n */\n next: function lexer_next() {\n if (this.done) {\n this.clear();\n return this.EOF;\n }\n if (!this._input) {\n this.done = true;\n }\n\n if (!this._more) {\n if (!this._clear_state) {\n this._clear_state = 1;\n }\n this.clear();\n }\n let spec = this.__currentRuleSet__;\n if (!spec) {\n // Update the ruleset cache as we apparently encountered a state change or just started lexing.\n // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will\n // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps\n // speed up those activities a tiny bit.\n spec = this.__currentRuleSet__ = this._currentRules();\n // Check whether a *sane* condition has been pushed before: this makes the lexer robust against\n // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19\n if (!spec || !spec.rules) {\n let lineno_msg = '';\n if (this.yylloc) {\n lineno_msg = ' on line ' + (this.yylineno + 1);\n }\n const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name \"' + this.topState() + '\"; this is a fatal error and should be reported to the application programmer team!', false);\n // produce one 'error' token until this situation has been resolved, most probably by parse termination!\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n }\n\n {\n let rule_ids = spec.rules;\n let regexes = spec.__rule_regexes;\n let len = spec.__rule_count;\n let match;\n let index;\n\n // Note: the arrays are 1-based, while `len` itself is a valid index,\n // hence the non-standard less-or-equal check in the next loop condition!\n for (let i = 1; i <= len; i++) {\n let tempMatch = this._input.match(regexes[i]);\n if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n match = tempMatch;\n index = i;\n if (this.options.backtrack_lexer) {\n let token = this.test_match(tempMatch, rule_ids[i]);\n if (token !== false) {\n return token;\n } else if (this._backtrack) {\n match = undefined;\n continue; // rule action called reject() implying a rule MISmatch.\n } else {\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n } else if (!this.options.flex) {\n break;\n }\n }\n }\n\n if (match) {\n let token = this.test_match(match, rule_ids[index]);\n if (token !== false) {\n return token;\n }\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n }\n\n if (!this._input) {\n this.done = true;\n this.clear();\n return this.EOF;\n }\n\n {\n let lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable);\n\n let pendingInput = this._input;\n let activeCondition = this.topState();\n let conditionStackDepth = this.conditionStack.length;\n\n let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n if (token === this.ERROR) {\n // we can try to recover from a lexer error that `parseError()` did not 'recover' for us\n // by moving forward at least one character at a time IFF the (user-specified?) `parseError()`\n // has not consumed/modified any pending input or changed state in the error handler:\n if (!this.matches &&\n // and make sure the input has been modified/consumed ...\n pendingInput === this._input &&\n // ...or the lexer state has been modified significantly enough\n // to merit a non-consuming error handling action right now.\n activeCondition === this.topState() &&\n conditionStackDepth === this.conditionStack.length\n ) {\n this.input();\n }\n }\n return token;\n }\n },\n\n /**\n * return next match that has a token\n *\n * @public\n * @this {RegExpLexer}\n */\n lex: function lexer_lex() {\n let r;\n\n //this._clear_state = 0;\n\n if (!this._more) {\n if (!this._clear_state) {\n this._clear_state = 1;\n }\n this.clear();\n }\n\n // allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer:\n if (typeof this.pre_lex === 'function') {\n r = this.pre_lex.call(this, 0);\n }\n if (typeof this.options.pre_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.pre_lex.call(this, r) || r;\n }\n if (this.yy && typeof this.yy.pre_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.pre_lex.call(this, r) || r;\n }\n\n while (!r) {\n r = this.next();\n }\n\n if (this.yy && typeof this.yy.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.post_lex.call(this, r) || r;\n }\n if (typeof this.options.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.post_lex.call(this, r) || r;\n }\n if (typeof this.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.post_lex.call(this, r) || r;\n }\n\n if (!this._more) {\n //\n // 1) make sure any outside interference is detected ASAP:\n // these attributes are to be treated as 'const' values\n // once the lexer has produced them with the token (return value `r`).\n // 2) make sure any subsequent `lex()` API invocation CANNOT\n // edit the `yytext`, etc. token attributes for the *current*\n // token, i.e. provide a degree of 'closure safety' so that\n // code like this:\n //\n // t1 = lexer.lex();\n // v = lexer.yytext;\n // l = lexer.yylloc;\n // t2 = lexer.lex();\n // assert(lexer.yytext !== v);\n // assert(lexer.yylloc !== l);\n //\n // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee*\n // these conditions.\n //\n this.yytext = Object.freeze(this.yytext);\n this.matches = Object.freeze(this.matches);\n this.yylloc.range = Object.freeze(this.yylloc.range);\n this.yylloc = Object.freeze(this.yylloc);\n\n this._clear_state = 0;\n }\n\n return r;\n },\n\n /**\n * return next match that has a token. Identical to the `lex()` API but does not invoke any of the\n * `pre_lex()` nor any of the `post_lex()` callbacks.\n *\n * @public\n * @this {RegExpLexer}\n */\n fastLex: function lexer_fastLex() {\n let r;\n\n //this._clear_state = 0;\n\n while (!r) {\n r = this.next();\n }\n\n if (!this._more) {\n //\n // 1) make sure any outside interference is detected ASAP:\n // these attributes are to be treated as 'const' values\n // once the lexer has produced them with the token (return value `r`).\n // 2) make sure any subsequent `lex()` API invocation CANNOT\n // edit the `yytext`, etc. token attributes for the *current*\n // token, i.e. provide a degree of 'closure safety' so that\n // code like this:\n //\n // t1 = lexer.lex();\n // v = lexer.yytext;\n // l = lexer.yylloc;\n // t2 = lexer.lex();\n // assert(lexer.yytext !== v);\n // assert(lexer.yylloc !== l);\n //\n // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee*\n // these conditions.\n //\n this.yytext = Object.freeze(this.yytext);\n this.matches = Object.freeze(this.matches);\n this.yylloc.range = Object.freeze(this.yylloc.range);\n this.yylloc = Object.freeze(this.yylloc);\n\n this._clear_state = 0;\n }\n\n return r;\n },\n\n /**\n * return info about the lexer state that can help a parser or other lexer API user to use the\n * most efficient means available. This API is provided to aid run-time performance for larger\n * systems which employ this lexer.\n *\n * @public\n * @this {RegExpLexer}\n */\n canIUse: function lexer_canIUse() {\n const rv = {\n fastLex: !(\n typeof this.pre_lex === 'function' ||\n typeof this.options.pre_lex === 'function' ||\n (this.yy && typeof this.yy.pre_lex === 'function') ||\n (this.yy && typeof this.yy.post_lex === 'function') ||\n typeof this.options.post_lex === 'function' ||\n typeof this.post_lex === 'function'\n ) && typeof this.fastLex === 'function'\n };\n return rv;\n },\n\n\n /**\n * backwards compatible alias for `pushState()`;\n * the latter is symmetrical with `popState()` and we advise to use\n * those APIs in any modern lexer code, rather than `begin()`.\n *\n * @public\n * @this {RegExpLexer}\n */\n begin: function lexer_begin(condition) {\n return this.pushState(condition);\n },\n\n /**\n * activates a new lexer condition state (pushes the new lexer\n * condition state onto the condition stack)\n *\n * @public\n * @this {RegExpLexer}\n */\n pushState: function lexer_pushState(condition) {\n this.conditionStack.push(condition);\n this.__currentRuleSet__ = null;\n return this;\n },\n\n /**\n * pop the previously active lexer condition state off the condition\n * stack\n *\n * @public\n * @this {RegExpLexer}\n */\n popState: function lexer_popState() {\n const n = this.conditionStack.length - 1;\n if (n > 0) {\n this.__currentRuleSet__ = null;\n return this.conditionStack.pop();\n }\n return this.conditionStack[0];\n },\n\n /**\n * return the currently active lexer condition state; when an index\n * argument is provided it produces the N-th previous condition state,\n * if available\n *\n * @public\n * @this {RegExpLexer}\n */\n topState: function lexer_topState(n) {\n n = this.conditionStack.length - 1 - Math.abs(n || 0);\n if (n >= 0) {\n return this.conditionStack[n];\n }\n return 'INITIAL';\n },\n\n /**\n * (internal) determine the lexer rule set which is active for the\n * currently active lexer condition state\n *\n * @public\n * @this {RegExpLexer}\n */\n _currentRules: function lexer__currentRules() {\n const n = this.conditionStack.length - 1;\n let state;\n if (n >= 0) {\n state = this.conditionStack[n];\n } else {\n state = 'INITIAL';\n }\n return this.conditions[state] || this.conditions.INITIAL;\n },\n\n /**\n * return the number of states currently on the stack\n *\n * @public\n * @this {RegExpLexer}\n */\n stateStackSize: function lexer_stateStackSize() {\n return this.conditionStack.length;\n }\n}"; // --- END lexer kernel --- } chkBugger$2(getRegExpLexerPrototype()); -RegExpLexer.prototype = new Function(rmCommonWS$2(_templateObject80(), getRegExpLexerPrototype()))(); // The lexer code stripper, driven by optimization analysis settings and +RegExpLexer.prototype = new Function(rmCommonWS$2(_templateObject81(), getRegExpLexerPrototype()))(); // The lexer code stripper, driven by optimization analysis settings and // lexer options, which cannot be changed at run-time. function stripUnusedLexerCode(src, opt) { @@ -12512,15 +12724,15 @@ 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 _c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); var offendingChunk = ' ' + b.join('\n '); - console.error(rmCommonWS$2(_templateObject81(), ex, offendingChunk)); + console.error(rmCommonWS$2(_templateObject82(), ex, offendingChunk)); new_src = src; } // inject analysis report now: - new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2(_templateObject82(), opt.options.backtrack_lexer, opt.options.ranges, opt.options.trackPosition, opt.parseActionsUseYYLENG, opt.parseActionsUseYYLINENO, opt.parseActionsUseYYTEXT, opt.parseActionsUseYYLOC, opt.parseActionsUseValueTracking, opt.parseActionsUseValueAssignment, opt.parseActionsUseLocationTracking, opt.parseActionsUseLocationAssignment, opt.lexerActionsUseYYLENG, opt.lexerActionsUseYYLINENO, opt.lexerActionsUseYYTEXT, opt.lexerActionsUseYYLOC, opt.lexerActionsUseParseError, opt.lexerActionsUseYYERROR, opt.lexerActionsUseLocationTracking, opt.lexerActionsUseMore, opt.lexerActionsUseUnput, opt.lexerActionsUseReject, opt.lexerActionsUseLess, opt.lexerActionsUseDisplayAPIs, opt.lexerActionsUseDescribeYYLOC)); + new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2(_templateObject83(), opt.options.backtrack_lexer, opt.options.ranges, opt.options.trackPosition, opt.parseActionsUseYYLENG, opt.parseActionsUseYYLINENO, opt.parseActionsUseYYTEXT, opt.parseActionsUseYYLOC, opt.parseActionsUseValueTracking, opt.parseActionsUseValueAssignment, opt.parseActionsUseLocationTracking, opt.parseActionsUseLocationAssignment, opt.lexerActionsUseYYLENG, opt.lexerActionsUseYYLINENO, opt.lexerActionsUseYYTEXT, opt.lexerActionsUseYYLOC, opt.lexerActionsUseParseError, opt.lexerActionsUseYYERROR, opt.lexerActionsUseLocationTracking, opt.lexerActionsUseMore, opt.lexerActionsUseUnput, opt.lexerActionsUseReject, opt.lexerActionsUseLess, opt.lexerActionsUseDisplayAPIs, opt.lexerActionsUseDescribeYYLOC)); return new_src; } // generate lexer source from a grammar @@ -12657,9 +12869,9 @@ function generateRegexesInitTableCode(opt) { var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); return "/* ".concat(idx_str, ": */ new XRegExp(\"").concat(re_src, "\", \"").concat(re.xregexp.flags, "\")"); - } else { - return "/* ".concat(idx_str, ": */ ").concat(re); } + + return "/* ".concat(idx_str, ": */ ").concat(re); }); return b.join(',\n'); } @@ -12667,8 +12879,8 @@ function generateRegexesInitTableCode(opt) { function generateModuleBody(opt) { // make the JSON output look more like JavaScript: function cleanupJSON(str) { - str = str.replace(/ "rules": \[/g, ' rules: ['); - str = str.replace(/ "inclusive": /g, ' inclusive: '); + str = str.replace(/ {2}"rules": \[/g, ' rules: ['); + str = str.replace(/ {2}"inclusive": /g, ' inclusive: '); return str; } @@ -12779,7 +12991,7 @@ function generateModuleBody(opt) { if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) { // we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. - var code = [rmCommonWS$2(_templateObject83()), '/*JISON-LEX-ANALYTICS-REPORT*/' + var code = [rmCommonWS$2(_templateObject84()), '/* JISON-LEX-ANALYTICS-REPORT */\n' /* slot #1: placeholder for analysis report further below */ ]; // get the RegExpLexer.prototype in source code form: @@ -12808,7 +13020,7 @@ function generateModuleBody(opt) { var simpleCaseActionClustersCode = String(opt.caseHelperInclude); var rulesCode = generateRegexesInitTableCode(opt); var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); - code.push(rmCommonWS$2(_templateObject84(), performActionCode, simpleCaseActionClustersCode, rulesCode, conditionsCode)); + code.push(rmCommonWS$2(_templateObject85(), performActionCode, simpleCaseActionClustersCode, rulesCode, conditionsCode)); opt.is_custom_lexer = false; out = code.join(''); } else { @@ -12816,9 +13028,9 @@ function generateModuleBody(opt) { // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // - // Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter + // Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. - out = 'var lexer;\n'; + out = '\n'; assert__default['default'](opt.regular_rule_count === 0); assert__default['default'](opt.simple_rule_count === 0); opt.is_custom_lexer = true; @@ -12829,8 +13041,6 @@ function generateModuleBody(opt) { } // The output of this function is guaranteed to read something like this: // // ``` - // var lexer; - // // bla bla bla bla ... lotsa bla bla; // ``` // @@ -12841,7 +13051,7 @@ function generateModuleBody(opt) { } function generateGenericHeaderComment() { - var out = rmCommonWS$2(_templateObject85(), version); + var out = rmCommonWS$2(_templateObject86(), version); return out; } @@ -12870,7 +13080,7 @@ function prepareOptions(opt) { function generateModule(opt) { opt = prepareOptions(opt); var modIncSrc = opt.moduleInclude ? opt.moduleInclude + ';' : ''; - var src = rmCommonWS$2(_templateObject86(), generateGenericHeaderComment(), opt.moduleName, jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); + var src = rmCommonWS$2(_templateObject87(), generateGenericHeaderComment(), opt.moduleName, jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); src = stripUnusedLexerCode(src, opt); opt.exportSourceCode.all = src; return src; @@ -12879,7 +13089,7 @@ function generateModule(opt) { function generateAMDModule(opt) { opt = prepareOptions(opt); var modIncSrc = opt.moduleInclude ? opt.moduleInclude + ';' : ''; - var src = rmCommonWS$2(_templateObject87(), generateGenericHeaderComment(), jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); + var src = rmCommonWS$2(_templateObject88(), generateGenericHeaderComment(), jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); src = stripUnusedLexerCode(src, opt); opt.exportSourceCode.all = src; return src; @@ -12888,7 +13098,7 @@ function generateAMDModule(opt) { function generateESModule(opt) { opt = prepareOptions(opt); var modIncSrc = opt.moduleInclude ? opt.moduleInclude + ';' : ''; - var src = rmCommonWS$2(_templateObject88(), generateGenericHeaderComment(), jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); + var src = rmCommonWS$2(_templateObject89(), generateGenericHeaderComment(), jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); src = stripUnusedLexerCode(src, opt); opt.exportSourceCode.all = src; return src; @@ -12897,7 +13107,7 @@ function generateESModule(opt) { function generateCommonJSModule(opt) { opt = prepareOptions(opt); var modIncSrc = opt.moduleInclude ? opt.moduleInclude + ';' : ''; - var src = rmCommonWS$2(_templateObject89(), generateGenericHeaderComment(), opt.moduleName, jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc, opt.moduleName, opt.moduleName); + var src = rmCommonWS$2(_templateObject90(), generateGenericHeaderComment(), opt.moduleName, jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc, opt.moduleName, opt.moduleName); src = stripUnusedLexerCode(src, opt); opt.exportSourceCode.all = src; return src; @@ -13269,15 +13479,15 @@ var parser$1 = { switch (yystate) { case 0: /*! Production:: $accept : production $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-): - this.$ = yyvstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-) + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-): + this.$ = yyvstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-) break; case 1: /*! Production:: production : handle EOF */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-): - this.$ = yyvstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-) + // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-): + this.$ = yyvstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-) return yyvstack[yysp - 1]; @@ -13425,20 +13635,14 @@ var parser$1 = { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + var ASSERT = typeof assert !== 'function' ? function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : assert; this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -13467,13 +13671,14 @@ var parser$1 = { shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + var _dst2 = {}; + shallow_copy_noclobber(_dst2, src); + return _dst2; + } } return src; @@ -13490,10 +13695,8 @@ var parser$1 = { if (chk.call(src, k)) { dst[k] = src[k]; } - } else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } // copy state @@ -13639,6 +13842,12 @@ var parser$1 = { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -13780,7 +13989,7 @@ var parser$1 = { action = t[0]; // handle parse error if (!action) { - var errStr; + var errStr = void 0; var errSymbolDescr = this.describeSymbol(symbol) || symbol; var expected = this.collect_expected_token_set(state); // Report error @@ -13914,14 +14123,16 @@ var parser$1 = { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -14429,6 +14640,10 @@ var lexer$1 = function () { * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -14810,9 +15025,9 @@ var lexer$1 = function () { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -14822,8 +15037,8 @@ var lexer$1 = function () { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -14899,12 +15114,22 @@ var lexer$1 = function () { */ pastInput: function lexer_pastInput(maxSize, maxLines) { var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) maxSize = Infinity;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substr` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = Infinity; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: @@ -14921,8 +15146,8 @@ var lexer$1 = function () { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -14948,20 +15173,30 @@ var lexer$1 = function () { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { var next = this.match; var source = this._input || ''; - if (maxSize < 0) maxSize = next.length + source.length;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substring` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = next.length + source.length; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + if (next.length < maxSize * 2 + 2) { next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8 } // now that we have a significantly reduced string to process, transform the newlines @@ -15286,7 +15521,7 @@ var lexer$1 = function () { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + var backup; if (this.options.backtrack_lexer) { // save context @@ -15314,9 +15549,9 @@ var lexer$1 = function () { }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + var match_str = match[0]; + var match_str_len = match_str.length; + var lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -15342,7 +15577,7 @@ var lexer$1 = function () { // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] + var token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */ ); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -15388,8 +15623,6 @@ var lexer$1 = function () { this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -15421,65 +15654,73 @@ var lexer$1 = function () { } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; // 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! + { + var rule_ids = spec.rules; + var regexes = spec.__rule_regexes; + var len = spec.__rule_count; + var match; + var index; // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + for (var i = 1; i <= len; i++) { + var tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + var token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + var _token3 = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + if (_token3 !== false) { + return _token3; + } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + var _lineno_msg2 = 'Lexical error'; if (this.yylloc) { - lineno_msg += ' on line ' + (this.yylineno + 1); + _lineno_msg2 += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var _p2 = this.constructLexErrorInfo(_lineno_msg2 + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var pendingInput = this._input; var activeCondition = this.topState(); var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; - if (token === this.ERROR) { + var _token4 = this.parseError(_p2.errStr, _p2, this.JisonLexerError) || this.ERROR; + + if (_token4 === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: @@ -15491,7 +15732,7 @@ var lexer$1 = function () { } } - return token; + return _token4; } }, @@ -15548,24 +15789,24 @@ var lexer$1 = function () { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15592,24 +15833,24 @@ var lexer$1 = function () { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15673,9 +15914,9 @@ var lexer$1 = function () { if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -15691,9 +15932,9 @@ var lexer$1 = function () { if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -15713,7 +15954,7 @@ var lexer$1 = function () { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -15916,10 +16157,10 @@ function generatePushAction(handle, offset) { } function transformExpression(e, opts, emit) { - var type = e[0], - value = e[1], - name = false, - has_transformed = 0; + var type = e[0]; + var value = e[1]; + var name = false; + var has_transformed = 0; var list, n; if (type === 'xalias') { @@ -16040,8 +16281,8 @@ function optsForProduction(id, grammar) { function transformProduction(id, production, grammar) { var transform_opts = optsForProduction(id, grammar); return production.map(function (handle) { - var action = null, - opts = null; + var action = null; + var opts = null; var i, len, n; if (typeof handle !== 'string') { @@ -16135,7 +16376,7 @@ function transformProduction(id, production, grammar) { } // now scan the action for all named and numeric semantic values ($nonterminal / $1 / @1, ##1, ...) // // Note that `#name` are straight **static** symbol translations, which are okay as they don't - // require access to the parse stack: `#n` references can be resolved completely + // require access to the parse stack: `#n` references can be resolved completely // at grammar compile time. // @@ -16182,9 +16423,9 @@ function transformProduction(id, production, grammar) { if (ret.length === 1) { return ret[0]; - } else { - return ret; } + + return ret; }); } @@ -16728,16 +16969,16 @@ var parser$3 = { switch (yystate) { case 0: /*! Production:: $accept : spec $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; - this._$ = yylstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break; case 1: /*! Production:: spec : declaration_list "%%" grammar optional_end_block EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4]; @@ -16751,20 +16992,20 @@ var parser$3 = { case 2: /*! Production:: spec : declaration_list "%%" grammar error EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject90(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject91(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 3: /*! Production:: spec : declaration_list error EOF */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject91(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject92(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); break; case 4: @@ -16781,21 +17022,21 @@ var parser$3 = { case 133: /*! Production:: optional_module_code_chunk : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject92(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject93(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); } this.$ = yyvstack[yysp]; @@ -16806,8 +17047,8 @@ var parser$3 = { case 10: /*! Production:: declaration_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -16817,14 +17058,14 @@ var parser$3 = { case 8: /*! Production:: optional_action_header_block : optional_action_header_block include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject93(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject94(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); } yy.addDeclaration(this.$, { @@ -16834,8 +17075,8 @@ var parser$3 = { case 9: /*! Production:: declaration_list : declaration_list declaration */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -16843,18 +17084,18 @@ var parser$3 = { case 11: /*! Production:: declaration_list : declaration_list error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject94(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject95(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 12: /*! Production:: declaration : START id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { start: yyvstack[yysp] @@ -16863,8 +17104,8 @@ var parser$3 = { case 13: /*! Production:: declaration : LEX_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { lex: { @@ -16876,8 +17117,8 @@ var parser$3 = { case 14: /*! Production:: declaration : operator */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { operator: yyvstack[yysp] @@ -16886,8 +17127,8 @@ var parser$3 = { case 15: /*! Production:: declaration : TOKEN full_token_definitions */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { token_list: yyvstack[yysp] @@ -16896,13 +17137,13 @@ var parser$3 = { case 16: /*! Production:: declaration : ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject95(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject96(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); } this.$ = { @@ -16912,13 +17153,13 @@ var parser$3 = { case 17: /*! Production:: declaration : include_macro_code */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject96(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject97(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); } this.$ = { @@ -16928,8 +17169,8 @@ var parser$3 = { case 18: /*! Production:: declaration : parse_params */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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] @@ -16938,8 +17179,8 @@ var parser$3 = { case 19: /*! Production:: declaration : parser_type */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { parserType: yyvstack[yysp] @@ -16948,8 +17189,8 @@ var parser$3 = { case 20: /*! Production:: declaration : options */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { options: yyvstack[yysp] @@ -16958,8 +17199,8 @@ var parser$3 = { case 21: /*! Production:: declaration : DEBUG */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { options: [['debug', true]] @@ -16968,8 +17209,8 @@ var parser$3 = { case 22: /*! Production:: declaration : EBNF */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) ebnf = true; this.$ = { @@ -16979,8 +17220,8 @@ var parser$3 = { case 23: /*! Production:: declaration : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { unknownDecl: yyvstack[yysp] @@ -16989,8 +17230,8 @@ var parser$3 = { case 24: /*! Production:: declaration : IMPORT import_name import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { imports: { @@ -17002,31 +17243,31 @@ var parser$3 = { case 25: /*! Production:: declaration : IMPORT import_name error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject97(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject98(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 26: /*! Production:: declaration : IMPORT error import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject98(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject99(), 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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(_templateObject99(), $init_code_name, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject100(), $init_code_name, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); } this.$ = { @@ -17039,41 +17280,41 @@ var parser$3 = { case 28: /*! Production:: declaration : INIT_CODE error action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject100(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject101(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]))); break; case 29: /*! Production:: declaration : START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject101(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject102(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 30: /*! Production:: declaration : TOKEN error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject102(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject103(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 31: /*! Production:: declaration : IMPORT error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject103(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject104(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 32: @@ -17153,8 +17394,8 @@ var parser$3 = { case 132: /*! Production:: optional_module_code_chunk : module_code_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -17164,30 +17405,30 @@ var parser$3 = { case 111: /*! Production:: action_ne : "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1]; break; case 40: /*! Production:: options : OPTIONS error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject104(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject105(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]))); break; case 41: /*! Production:: options : OPTIONS error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject105(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject106(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 42: @@ -17198,8 +17439,8 @@ var parser$3 = { case 70: /*! Production:: id_list : id_list id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push(yyvstack[yysp]); @@ -17216,24 +17457,24 @@ var parser$3 = { case 84: /*! Production:: handle_list : handle_action */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 44: /*! Production:: option : NAME */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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], true]; break; case 45: /*! Production:: option : NAME "=" OPTION_STRING_VALUE */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]]; break; @@ -17243,30 +17484,30 @@ var parser$3 = { case 47: /*! Production:: option : NAME "=" NAME */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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], parseValue$1(yyvstack[yysp])]; break; case 48: /*! Production:: option : NAME "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject106(), yyvstack[yysp - 2], yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject107(), yyvstack[yysp - 2], yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 49: /*! Production:: option : NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject107(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject108(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 50: @@ -17274,36 +17515,36 @@ var parser$3 = { case 52: /*! Production:: parser_type : PARSER_TYPE symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; break; case 51: /*! Production:: parse_params : PARSE_PARAM error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject108(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject109(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 53: /*! Production:: parser_type : PARSER_TYPE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject109(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject110(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 54: /*! Production:: operator : associativity token_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push.apply(this.$, yyvstack[yysp]); @@ -17311,42 +17552,42 @@ var parser$3 = { case 55: /*! Production:: operator : associativity error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject110(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject111(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 56: /*! Production:: associativity : LEFT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = 'left'; break; case 57: /*! Production:: associativity : RIGHT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = 'right'; break; case 58: /*! Production:: associativity : NONASSOC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = 'nonassoc'; break; case 61: /*! Production:: full_token_definitions : optional_token_type id_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -17369,8 +17610,8 @@ var parser$3 = { case 62: /*! Production:: full_token_definitions : optional_token_type one_full_token */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -17383,8 +17624,8 @@ var parser$3 = { case 63: /*! Production:: one_full_token : id token_value token_description */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { id: yyvstack[yysp - 2], @@ -17395,8 +17636,8 @@ var parser$3 = { case 64: /*! Production:: one_full_token : id token_description */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { id: yyvstack[yysp - 1], @@ -17406,8 +17647,8 @@ var parser$3 = { case 65: /*! Production:: one_full_token : id token_value */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { id: yyvstack[yysp - 1], @@ -17417,16 +17658,16 @@ var parser$3 = { case 66: /*! Production:: optional_token_type : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = false; break; case 72: /*! Production:: grammar : optional_action_header_block production_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.grammar = yyvstack[yysp]; @@ -17434,8 +17675,8 @@ var parser$3 = { case 73: /*! Production:: production_list : production_list production */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -17449,8 +17690,8 @@ var parser$3 = { case 74: /*! Production:: production_list : production */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = {}; this.$[yyvstack[yysp][0]] = yyvstack[yysp][1]; @@ -17458,36 +17699,36 @@ var parser$3 = { case 75: /*! Production:: production : production_id handle_list ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1]]; break; case 76: /*! Production:: production : production_id error ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject111(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject112(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 77: /*! Production:: production : production_id error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject112(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject113(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 78: /*! Production:: production_id : id optional_production_description ":" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; // TODO: carry rule description support into the parser generator... @@ -17495,36 +17736,36 @@ var parser$3 = { case 79: /*! Production:: production_id : id optional_production_description error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject113(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject114(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 80: /*! Production:: production_id : id optional_production_description ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject114(), $id, yyvstack[yysp - 2], yyvstack[yysp], yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject115(), $id, yyvstack[yysp - 2], yyvstack[yysp], yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 82: /*! Production:: optional_production_description : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) break; case 83: /*! Production:: handle_list : handle_list "|" handle_action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; this.$.push(yyvstack[yysp]); @@ -17532,28 +17773,28 @@ var parser$3 = { case 85: /*! Production:: handle_list : handle_list "|" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject115(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject116(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 86: /*! Production:: handle_list : handle_list ":" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject116(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject117(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 87: /*! Production:: handle_action : handle prec action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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(' ') : '']; @@ -17561,7 +17802,7 @@ var parser$3 = { var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject117(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject118(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); } this.$.push(yyvstack[yysp]); @@ -17569,7 +17810,7 @@ var parser$3 = { if (yyvstack[yysp - 1]) { if (yyvstack[yysp - 2].length === 0) { - yyparser.yyError(rmCommonWS$3(_templateObject118(), yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp] + 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! */ ))); } @@ -17585,8 +17826,8 @@ var parser$3 = { case 88: /*! Production:: handle_action : EPSILON action */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = ['']; @@ -17594,7 +17835,7 @@ var parser$3 = { var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject119(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject120(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); } this.$.push(yyvstack[yysp]); @@ -17608,18 +17849,18 @@ var parser$3 = { case 89: /*! Production:: handle_action : EPSILON error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject120(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject121(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 90: /*! Production:: handle : handle suffixed_expression */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push(yyvstack[yysp]); @@ -17627,16 +17868,16 @@ var parser$3 = { case 91: /*! Production:: handle : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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 92: /*! Production:: handle_sublist : handle_sublist "|" handle */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; this.$.push(yyvstack[yysp].join(' ')); @@ -17644,16 +17885,16 @@ var parser$3 = { case 93: /*! Production:: handle_sublist : handle */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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].join(' ')]; break; case 94: /*! Production:: suffixed_expression : expression suffix ALIAS */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + "[" + yyvstack[yysp] + "]"; break; @@ -17666,24 +17907,24 @@ var parser$3 = { case 130: /*! Production:: module_code_chunk : module_code_chunk CODE */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + yyvstack[yysp]; break; case 97: /*! Production:: expression : EOF_ID */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '$end'; break; case 98: /*! Production:: expression : STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // Re-encode the string *anyway* as it will // be made part of the rule rhs a.k.a. production (type: *string*) again and we want // to be able to handle all tokens, including *significant space* @@ -17694,25 +17935,25 @@ var parser$3 = { case 99: /*! Production:: expression : "(" handle_sublist ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1].join(' | ') + ')'; break; case 100: /*! Production:: expression : "(" handle_sublist error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject121(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject122(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 105: /*! Production:: prec : PREC symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { prec: yyvstack[yysp] @@ -17721,76 +17962,76 @@ var parser$3 = { case 106: /*! Production:: prec : PREC error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject122(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject123(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 107: /*! Production:: prec : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = null; break; case 112: /*! Production:: action_ne : "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject123(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject124(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 116: /*! Production:: action : ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 120: /*! Production:: action_body : action_body "{" action_body "}" action_comments_body */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4] + yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; break; case 121: /*! Production:: action_body : action_body "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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 - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; break; case 122: /*! Production:: action_body : action_body "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject124(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject125(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 126: /*! Production:: extra_parser_module_code : optional_module_code_chunk include_macro_code extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + yyvstack[yysp]; break; case 127: /*! Production:: include_macro_code : INCLUDE PATH */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -17798,7 +18039,7 @@ var parser$3 = { var rv = checkActionBlock$2(fileContent); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject125(), $PATH, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject126(), $PATH, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); } // And no, we don't support nested '%include': @@ -17807,21 +18048,21 @@ var parser$3 = { case 128: /*! Production:: include_macro_code : INCLUDE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject126()) + yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])); + yyparser.yyError(rmCommonWS$3(_templateObject127()) + yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])); break; case 131: /*! Production:: module_code_chunk : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject127()) + yylexer.prettyPrintRange(yylstack[yysp])); + yyparser.yyError(rmCommonWS$3(_templateObject128()) + yylexer.prettyPrintRange(yylstack[yysp])); break; } }, @@ -17898,20 +18139,14 @@ var parser$3 = { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + var ASSERT = typeof assert !== 'function' ? function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : assert; this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -17944,13 +18179,14 @@ var parser$3 = { shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + var _dst3 = {}; + shallow_copy_noclobber(_dst3, src); + return _dst3; + } } return src; @@ -17967,10 +18203,8 @@ var parser$3 = { if (chk.call(src, k)) { dst[k] = src[k]; } - } else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -18139,11 +18373,11 @@ var parser$3 = { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (var _i6 = this.__error_recovery_infos.length - 1; _i6 >= 0; _i6--) { + var _el2 = this.__error_recovery_infos[_i6]; - if (el && typeof el.destroy === 'function') { - el.destroy(); + if (_el2 && typeof _el2.destroy === 'function') { + _el2.destroy(); } } @@ -18171,10 +18405,10 @@ var parser$3 = { this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; + var i1 = first_index | 0; + var i2 = last_index | 0; + var l1 = first_yylloc; + var l2 = last_yylloc; var rv; // rules: // - first/last yylloc entries override first/last indexes @@ -18192,8 +18426,8 @@ var parser$3 = { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { - l2 = lstack[i]; + for (var _i7 = i2; _i7 >= i1; _i7--) { + l2 = lstack[_i7]; if (l2) { break; @@ -18206,8 +18440,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 i = (i1 || sp) - 1; i >= 0; i--) { - l1 = lstack[i]; + for (var _i8 = (i1 || sp) - 1; _i8 >= 0; _i8--) { + l1 = lstack[_i8]; if (l1) { break; @@ -18220,30 +18454,30 @@ var parser$3 = { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; - } + return null; + } // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + + rv = this.copy_yylloc(l2); return rv; + } // shallow-copy L1, then adjust first col/row 1 column past the end. + + + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; } + + return rv; } if (!l1) { @@ -18252,7 +18486,7 @@ var parser$3 = { } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... @@ -18302,6 +18536,12 @@ var parser$3 = { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -18384,11 +18624,15 @@ var parser$3 = { // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty - } + { + var i; + + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty + } - rv.base_pointer = i; - rv.info_stack_pointer = i; + rv.base_pointer = i; + rv.info_stack_pointer = i; + } rv.root_failure_pointer = rv.stack_pointer; // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_recovery_infos.push(rv); @@ -18474,9 +18718,9 @@ var parser$3 = { while (stack_probe >= 0) { // check for error recovery rule in this state - var t = table[state] && table[state][TERROR] || NO_ACTION; + var _t2 = table[state] && table[state][TERROR] || NO_ACTION; - if (t[0]) { + if (_t2[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must // prevent the core from running forever, @@ -18639,7 +18883,7 @@ var parser$3 = { if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: @@ -18695,7 +18939,7 @@ var parser$3 = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errSymbolDescr: errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -18714,7 +18958,8 @@ var parser$3 = { yyval.$ = recoveringErrorInfo; yyval._$ = undefined; yyrulelen = error_rule_depth; - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + var combineState = NO_ACTION[1]; + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -18771,9 +19016,9 @@ var parser$3 = { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); var errorSymbolFromParser = true; for (;;) { @@ -18806,7 +19051,7 @@ var parser$3 = { // and take it from there! if (!action) { - ASSERT(recoveringErrorInfo, "line 1087"); // Prep state variables so that upon breaking out of + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` // statement in the outer "fast parse loop" we redo // the exact same state table lookup as the one above @@ -18841,12 +19086,12 @@ var parser$3 = { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -18888,7 +19133,7 @@ var parser$3 = { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; // read action for current state and first input @@ -18918,7 +19163,7 @@ var parser$3 = { // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; @@ -18978,15 +19223,17 @@ var parser$3 = { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -19040,7 +19287,7 @@ var parser$3 = { // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; @@ -19082,25 +19329,25 @@ var parser$3 = { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + var _tokenName2 = this.getSymbolName(symbol || EOF); - if (!tokenName) { - tokenName = symbol; + if (!_tokenName2) { + _tokenName2 = symbol; } Jison.parserDebugger.push({ action: 'shift', text: lexer.yytext, - terminal: tokenName, + terminal: _tokenName2, terminal_id: symbol }); } ++sp; symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc = this.copy_yylloc(lexer.yylloc); @@ -19108,9 +19355,9 @@ var parser$3 = { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... @@ -19118,25 +19365,28 @@ var parser$3 = { r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; + var _prereduceValue2 = vstack.slice(sp - yyrulelen, sp); - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); - debuggableProductions.push(debuggableProduction); + var _debuggableProductions2 = []; + + for (var _debugIdx2 = yyrulelen - 1; _debugIdx2 >= 0; _debugIdx2--) { + var _debuggableProduction2 = getNonTerminalFromCode(stack[sp - _debugIdx2]); + + _debuggableProductions2.push(_debuggableProduction2); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + var _currentNonterminalCode2 = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + + var _currentNonterminal2 = getNonTerminalFromCode(_currentNonterminalCode2); - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', - nonterminal: currentNonterminal, - nonterminal_id: currentNonterminalCode, - prereduce: prereduceValue, + nonterminal: _currentNonterminal2, + nonterminal_id: _currentNonterminalCode2, + prereduce: _prereduceValue2, result: r, - productions: debuggableProductions, + productions: _debuggableProductions2, text: yyval.$ }); } @@ -19158,15 +19408,17 @@ var parser$3 = { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var _ntsymbol2 = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = _ntsymbol2; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][_ntsymbol2]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -19675,6 +19927,10 @@ var lexer$2 = function () { * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -20056,9 +20312,9 @@ var lexer$2 = function () { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -20068,8 +20324,8 @@ var lexer$2 = function () { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -20145,12 +20401,22 @@ var lexer$2 = function () { */ pastInput: function lexer_pastInput(maxSize, maxLines) { var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) maxSize = Infinity;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substr` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = Infinity; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: @@ -20167,8 +20433,8 @@ var lexer$2 = function () { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -20194,20 +20460,30 @@ var lexer$2 = function () { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { var next = this.match; var source = this._input || ''; - if (maxSize < 0) maxSize = next.length + source.length;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substring` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = next.length + source.length; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + if (next.length < maxSize * 2 + 2) { next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8 } // now that we have a significantly reduced string to process, transform the newlines @@ -20532,7 +20808,7 @@ var lexer$2 = function () { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + var backup; if (this.options.backtrack_lexer) { // save context @@ -20560,9 +20836,9 @@ var lexer$2 = function () { }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + var match_str = match[0]; + var match_str_len = match_str.length; + var lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -20588,7 +20864,7 @@ var lexer$2 = function () { // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] + var token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */ ); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -20634,8 +20910,6 @@ var lexer$2 = function () { this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -20667,65 +20941,73 @@ var lexer$2 = function () { } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; // 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! + { + var rule_ids = spec.rules; + var regexes = spec.__rule_regexes; + var len = spec.__rule_count; + var match; + var index; // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + for (var i = 1; i <= len; i++) { + var tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + var token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + var _token5 = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + if (_token5 !== false) { + return _token5; + } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + var _lineno_msg3 = 'Lexical error'; if (this.yylloc) { - lineno_msg += ' on line ' + (this.yylineno + 1); + _lineno_msg3 += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var _p3 = this.constructLexErrorInfo(_lineno_msg3 + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var pendingInput = this._input; var activeCondition = this.topState(); var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; - if (token === this.ERROR) { + var _token6 = this.parseError(_p3.errStr, _p3, this.JisonLexerError) || this.ERROR; + + if (_token6 === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: @@ -20737,7 +21019,7 @@ var lexer$2 = function () { } } - return token; + return _token6; } }, @@ -20794,24 +21076,24 @@ var lexer$2 = function () { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -20838,24 +21120,24 @@ var lexer$2 = function () { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -20919,9 +21201,9 @@ var lexer$2 = function () { if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -20937,9 +21219,9 @@ var lexer$2 = function () { if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -20959,7 +21241,7 @@ var lexer$2 = function () { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -21202,7 +21484,7 @@ var lexer$2 = function () { /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */ - this.warn(rmCommonWS(_templateObject128(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); + this.warn(rmCommonWS(_templateObject129(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); yy_.yytext = [// {NAME} this.matches[1], // optional value/parameters this.matches[2].trim()]; @@ -21323,42 +21605,42 @@ var lexer$2 = function () { /*! Conditions:: action */ /*! Rule:: " */ - yy_.yyerror(rmCommonWS(_templateObject129()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject130()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 82: /*! Conditions:: action */ /*! Rule:: ' */ - yy_.yyerror(rmCommonWS(_templateObject130()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject131()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 83: /*! Conditions:: action */ /*! Rule:: ` */ - yy_.yyerror(rmCommonWS(_templateObject131()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject132()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 84: /*! Conditions:: option_values */ /*! Rule:: " */ - yy_.yyerror(rmCommonWS(_templateObject132()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject133()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 85: /*! Conditions:: option_values */ /*! Rule:: ' */ - yy_.yyerror(rmCommonWS(_templateObject133()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject134()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 86: /*! Conditions:: option_values */ /*! Rule:: ` */ - yy_.yyerror(rmCommonWS(_templateObject134()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject135()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 87: @@ -21366,7 +21648,7 @@ var lexer$2 = function () { /*! Rule:: " */ var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject135(), rules) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject136(), rules) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 88: @@ -21374,7 +21656,7 @@ var lexer$2 = function () { /*! Rule:: ' */ var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject136(), rules) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject137(), rules) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 89: @@ -21382,7 +21664,7 @@ var lexer$2 = function () { /*! Rule:: ` */ var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject137(), rules) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject138(), rules) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 90: @@ -21391,7 +21673,7 @@ var lexer$2 = function () { /*! Rule:: . */ /* b0rk on bad characters */ - yy_.yyerror(rmCommonWS(_templateObject138(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject139(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); return 2; default: @@ -22128,8 +22410,8 @@ function grammarPrinter(raw, options) { // which MAY get corrupted that way as their actual content would change then! // construct fake nesting levels to arrive at the intended start indent value: `num` var nesting_levels = num / 2; - var pre = '// **PRE**', - post = '// **POST**'; + var pre = '// **PRE**'; + var post = '// **POST**'; for (; nesting_levels > 0; nesting_levels--) { pre = 'function x() {\n' + pre; @@ -22167,8 +22449,8 @@ function grammarPrinter(raw, options) { // Begin - var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - meta = { + var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; + var meta = { // table of character substitutions '\b': '\\b', '\t': '\\t', @@ -22236,134 +22518,140 @@ function grammarPrinter(raw, options) { var lex_pre = []; var lex_rules = []; var lex_post = []; - var key, src; - src = raw.lex.macros; - delete raw.lex.macros; + { + var src = raw.lex.macros; + delete raw.lex.macros; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject139())); - var keylen = 0; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4(_templateObject140())); + var keylen = 0; - for (key in src) { - keylen = Math.max(keylen, key.length); - } + for (var key in src) { + keylen = Math.max(keylen, key.length); + } - console.log('macros keylen:', keylen); - keylen = (keylen / 4 | 0) * 4 + 4; - console.log('macros keylen B:', keylen); + console.log('macros keylen:', keylen); + keylen = (keylen / 4 | 0) * 4 + 4; + console.log('macros keylen B:', keylen); - for (key in src) { - lex_pre.push(padRight(key, keylen) + src[key]); - } + for (var _key in src) { + lex_pre.push(padRight(_key, keylen) + src[_key]); + } - lex_pre.push(rmCommonWS$4(_templateObject140())); + lex_pre.push(rmCommonWS$4(_templateObject141())); + } } + { + var _src = raw.lex.unknownDecls; + delete raw.lex.unknownDecls; - src = raw.lex.unknownDecls; - delete raw.lex.unknownDecls; + if (_src && !isEmptyObj(_src)) { + lex_pre.push(rmCommonWS$4(_templateObject142())); - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject141())); + for (var i = 0, len = _src.length; i < len; i++) { + var entry = _src[i]; + var _key2 = entry.name; + var value = entry.value; + lex_pre.push('%' + _key2 + ' ' + value); + } - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; - lex_pre.push('%' + key + ' ' + value); + lex_pre.push(rmCommonWS$4(_templateObject143())); } - - lex_pre.push(rmCommonWS$4(_templateObject142())); } + { + var _src2 = raw.lex.options; + delete raw.lex.options; - src = raw.lex.options; - delete raw.lex.options; - - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject143())); + if (_src2 && !isEmptyObj(_src2)) { + lex_pre.push(rmCommonWS$4(_templateObject144())); - for (key in src) { - var value = src[key]; + for (var _key3 in _src2) { + var _value = _src2[_key3]; - if (value) { - lex_pre.push('%options ' + key + '=' + value); - } else { - lex_pre.push('%options ' + key); + if (_value) { + lex_pre.push('%options ' + _key3 + '=' + _value); + } else { + lex_pre.push('%options ' + _key3); + } } } } + { + var _src3 = raw.lex.startConditions; + delete raw.lex.startConditions; - src = raw.lex.startConditions; - delete raw.lex.startConditions; - - if (src && !isEmptyObj(src)) { - for (key in src) { - var value = src[key]; - lex_pre.push((value ? '%x ' : '%s ') + key); + if (_src3 && !isEmptyObj(_src3)) { + for (var _key4 in _src3) { + var _value2 = _src3[_key4]; + lex_pre.push((_value2 ? '%x ' : '%s ') + _key4); + } } } + { + var _src4 = raw.lex.actionInclude; + delete raw.lex.actionInclude; - src = raw.lex.actionInclude; - delete raw.lex.actionInclude; - - if (src && src.trim()) { - lex_pre.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + if (_src4 && _src4.trim()) { + lex_pre.push('%{\n' + indentAction(_src4.trim(), 4) + '\n%}'); + } } + { + var _src5 = raw.lex.rules; + delete raw.lex.rules; - src = raw.lex.rules; - delete raw.lex.rules; - - if (src) { - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - key = entry[0]; - var action = indentAction(entry[1], 4); - var actionHasLF = /[\r\n]/.test(action); - console.log('indented action:', { - entry: entry[1], - action: action, - actionHasLF: actionHasLF - }); + if (_src5) { + for (var _i9 = 0, _len2 = _src5.length; _i9 < _len2; _i9++) { + var _entry = _src5[_i9]; + var _key5 = _entry[0]; + var action = indentAction(_entry[1], 4); + var actionHasLF = /[\r\n]/.test(action); + console.log('indented action:', { + entry: _entry[1], + action: action, + actionHasLF: actionHasLF + }); - if (key.length <= 12) { - if (!actionHasLF) { - lex_rules.push(padRight(key, 16) + indentAction(action, 16)); - } else { - lex_rules.push(padRight(key, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); - } - } else { - if (!actionHasLF) { - lex_rules.push(key, makeIndent(16) + indentAction(action, 16)); + if (_key5.length <= 12) { + if (!actionHasLF) { + lex_rules.push(padRight(_key5, 16) + indentAction(action, 16)); + } else { + lex_rules.push(padRight(_key5, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + } + } else if (!actionHasLF) { + lex_rules.push(_key5, makeIndent(16) + indentAction(action, 16)); } else { - lex_rules.push(key, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + lex_rules.push(_key5, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } } } + { + var _src6 = raw.lex.moduleInclude; + delete raw.lex.moduleInclude; - src = raw.lex.moduleInclude; - delete raw.lex.moduleInclude; - - if (src && src.trim()) { - lex_post.push(indentAction(src.trim(), 0)); + if (_src6 && _src6.trim()) { + lex_post.push(indentAction(_src6.trim(), 0)); + } } + { + var out = ''; - var out = ''; + 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, '*\\/')); + } - if (!isEmptyObj(raw.lex)) { - // dump the remainder as a comment: - var rem = JSON5__default['default'].stringify(raw.lex, null, 2); - out += rmCommonWS$4(_templateObject144(), rem.replace(/\*\//g, '*\\/')); - } + delete raw.lex; + out += lex_pre.join('\n') + '\n\n'; + out += rmCommonWS$4(_templateObject146()) + lex_rules.join('\n') + '\n\n'; - delete raw.lex; - out += lex_pre.join('\n') + '\n\n'; - out += rmCommonWS$4(_templateObject145()) + lex_rules.join('\n') + '\n\n'; + if (lex_post.length > 0) { + out += rmCommonWS$4(_templateObject147()) + lex_post.join('\n') + '\n\n'; + } - if (lex_post.length > 0) { - out += rmCommonWS$4(_templateObject146()) + lex_post.join('\n') + '\n\n'; + lex_out_str = out; } - - lex_out_str = out; } var grammar_pre = []; @@ -22371,7 +22659,6 @@ function grammarPrinter(raw, options) { var ebnf_rules = []; var bnf_rules = []; var grammar_post = []; - var key, src; var fmtprod = function fmtprod(rule, prodset) { var backup = deepClone(prodset); @@ -22409,12 +22696,12 @@ function grammarPrinter(raw, options) { } if (typeof prodset[1] === 'string') { - var action = prodset[1]; + var _action = prodset[1]; if (lead.length < 12 - 1) { - rule += makeIndent(12 - lead.length) + indentAction('{ ' + action + ' }', 12); + rule += makeIndent(12 - lead.length) + indentAction('{ ' + _action + ' }', 12); } else { - rule += '\n' + makeIndent(12) + indentAction('{ ' + action + ' }', 12); + rule += '\n' + makeIndent(12) + indentAction('{ ' + _action + ' }', 12); } delete prodset[1]; @@ -22430,72 +22717,71 @@ function grammarPrinter(raw, options) { }; var grammarfmt = function grammarfmt(src) { - var key; var dst = []; - for (key in src) { - var prodset = src[key]; - var rule; + for (var _key6 in src) { + var prodset = src[_key6]; + var rule = void 0; console.log('format one rule:', { - key: key, + key: _key6, prodset: prodset }); if (typeof prodset === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; - delete src[key]; + rule = fmtprod(_key6 + ' : ', [prodset]) + ';'; + delete src[_key6]; } else if (prodset instanceof Array) { if (prodset.length === 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; - delete src[key]; + rule = fmtprod(_key6 + ' : ', [prodset]) + ';'; + delete src[_key6]; } else if (prodset[0] instanceof Array) { - rule = fmtprod(key + ' : ', prodset[0]); + rule = fmtprod(_key6 + ' : ', prodset[0]); rule += '\n ;'; if (prodset[0].length === 0) { - delete src[key]; + delete src[_key6]; } } else { - rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; + rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } } else if (prodset.length > 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + '\n : ', [prodset[0]]); + rule = fmtprod(_key6 + '\n : ', [prodset[0]]); delete prodset[0]; } else if (prodset[0] instanceof Array) { - rule = fmtprod(key + '\n : ', prodset[0]); + rule = fmtprod(_key6 + '\n : ', prodset[0]); if (prodset[0].length === 0) { delete prodset[0]; } } else { - rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; + rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - for (var i = 1, len = prodset.length; i < len; i++) { - if (typeof prodset[i] === 'string') { - rule += fmtprod('\n | ', [prodset[i]]); - delete prodset[i]; - } else if (prodset[i] instanceof Array) { - rule += fmtprod('\n | ', prodset[i]); + 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]); - if (prodset[i].length === 0) { - delete prodset[i]; + if (prodset[_i10].length === 0) { + delete prodset[_i10]; } } else { - rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[i]; + rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[_i10]; } } rule += '\n ;'; if (isEmptyArr(prodset)) { - delete src[key]; + delete src[_key6]; } } } else { - rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; + rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; } dst.push(rule); @@ -22504,313 +22790,333 @@ function grammarPrinter(raw, options) { return dst; }; - src = raw.ebnf; + { + var _src7 = raw.ebnf; - if (src) { - ebnf_rules = grammarfmt(src); + if (_src7) { + ebnf_rules = grammarfmt(_src7); - if (isEmptyObj(src)) { - delete raw.ebnf; + if (isEmptyObj(_src7)) { + delete raw.ebnf; + } } } + { + var _src8 = raw.bnf; //delete raw.bnf; - src = raw.bnf; //delete raw.bnf; - - if (src) { - bnf_rules = grammarfmt(src); + if (_src8) { + bnf_rules = grammarfmt(_src8); - if (isEmptyObj(src)) { - delete raw.bnf; + if (isEmptyObj(_src8)) { + delete raw.bnf; + } } } + { + var _src9 = raw.unknownDecls; + delete raw.unknownDecls; - src = raw.unknownDecls; - delete raw.unknownDecls; + if (_src9 && !isEmptyObj(_src9)) { + lex_pre.push(rmCommonWS$4(_templateObject148())); - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject147())); + for (var _i11 = 0, _len4 = _src9.length; _i11 < _len4; _i11++) { + var _entry2 = _src9[_i11]; + var _key7 = _entry2.name; + var _value3 = _entry2.value; + lex_pre.push('%' + _key7 + ' ' + _value3); + } - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; - lex_pre.push('%' + key + ' ' + value); + lex_pre.push(rmCommonWS$4(_templateObject149())); } - - lex_pre.push(rmCommonWS$4(_templateObject148())); - } //src = raw.lex; + } //let src = raw.lex; //delete raw.lex; //if (src) { - if (lex_out_str.trim() && options.showLexer) { - grammar_pre.push(rmCommonWS$4(_templateObject149(), lex_out_str)); + grammar_pre.push(rmCommonWS$4(_templateObject150(), lex_out_str)); } - src = raw.options; - delete raw.options; + { + var _src10 = raw.options; + delete raw.options; - if (src && !isEmptyObj(src)) { - var a = []; + if (_src10 && !isEmptyObj(_src10)) { + var a = []; - for (key in src) { - var value = src[key]; + for (var _key8 in _src10) { + var _value4 = _src10[_key8]; - switch (key) { - default: - if (value !== true) { - a.push('options', '%options ' + key + '=' + value); - } else { - a.push('options', '%options ' + key); - } + switch (_key8) { + default: + if (_value4 !== true) { + a.push('options', '%options ' + _key8 + '=' + _value4); + } else { + a.push('options', '%options ' + _key8); + } - break; + break; - case 'ebnf': - if (value) { - a.push(key, '%ebnf'); - } + case 'ebnf': + if (_value4) { + a.push(_key8, '%ebnf'); + } - break; + break; - case 'type': - if (value) { - a.push(key, '%parser-type ' + value); - } + case 'type': + if (_value4) { + a.push(_key8, '%parser-type ' + _value4); + } - break; + break; - case 'debug': - if (typeof value !== 'boolean') { - a.push(key, '%debug ' + value); - } else if (value) { - a.push(key, '%debug'); - } + case 'debug': + if (typeof _value4 !== 'boolean') { + a.push(_key8, '%debug ' + _value4); + } else if (_value4) { + a.push(_key8, '%debug'); + } - break; + break; + } } - } - var type = null; + var type = null; - for (var i = 0, len = a.length; i < len; i += 2) { - var t = a[i]; - var line = a[i + 1]; + for (var _i12 = 0, _len5 = a.length; _i12 < _len5; _i12 += 2) { + var t = a[_i12]; + var line = a[_i12 + 1]; + + if (t !== type) { + type = t; + grammar_pre.push(''); + } - if (t !== type) { - type = t; - grammar_pre.push(''); + grammar_pre.push(line); } - grammar_pre.push(line); + grammar_pre.push(''); } - - grammar_pre.push(''); } + { + var _src11 = raw.imports; - src = raw.imports; - - if (src) { - var clean = true; + if (_src11) { + var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - grammar_pre.push('%import ' + entry.name + ' ' + entry.path); - delete entry.name; - delete entry.path; + for (var _i13 = 0, _len6 = _src11.length; _i13 < _len6; _i13++) { + var _entry3 = _src11[_i13]; + grammar_pre.push('%import ' + _entry3.name + ' ' + _entry3.path); + delete _entry3.name; + delete _entry3.path; - if (isEmptyObj(entry)) { - delete src[i]; - } else { - clean = false; + if (isEmptyObj(_entry3)) { + delete _src11[_i13]; + } else { + clean = false; + } } - } - if (clean) { - delete raw.imports; + if (clean) { + delete raw.imports; + } } } + { + var _src12 = raw.moduleInit; - src = raw.moduleInit; - - if (src) { - var clean = true; + if (_src12) { + var _clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - grammar_pre.push('%code ' + entry.qualifier + ' ' + entry.include); - delete entry.qualifier; - delete entry.include; + for (var _i14 = 0, _len7 = _src12.length; _i14 < _len7; _i14++) { + var _entry4 = _src12[_i14]; + grammar_pre.push('%code ' + _entry4.qualifier + ' ' + _entry4.include); + delete _entry4.qualifier; + delete _entry4.include; - if (isEmptyObj(entry)) { - delete src[i]; - } else { - clean = false; + if (isEmptyObj(_entry4)) { + delete _src12[_i14]; + } else { + _clean = false; + } } - } - if (clean) { - delete raw.moduleInit; + if (_clean) { + delete raw.moduleInit; + } } } + { + var _src13 = raw.operators; - src = raw.operators; + if (_src13) { + var _clean2 = true; - if (src) { - var clean = true; + for (var _i15 = 0, _len8 = _src13.length; _i15 < _len8; _i15++) { + var _entry5 = _src13[_i15]; + var tokens = _entry5[1]; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var tokens = entry[1]; - var line = '%' + entry[0] + ' '; + var _line = '%' + _entry5[0] + ' '; - for (var t = 0, tlen = tokens.length; t < tlen; t++) { - line += ' ' + tokens[t]; - } + for (var _t3 = 0, tlen = tokens.length; _t3 < tlen; _t3++) { + _line += ' ' + tokens[_t3]; + } - grammar_pre.push(line); + grammar_pre.push(_line); - if (entry.length === 2) { - delete src[i]; - } else { - clean = false; + if (_entry5.length === 2) { + delete _src13[_i15]; + } else { + _clean2 = false; + } } - } - if (clean) { - delete raw.operators; + if (_clean2) { + delete raw.operators; + } } } + { + var _src14 = raw.extra_tokens; - src = raw.extra_tokens; + if (_src14) { + var _clean3 = true; - if (src) { - var clean = true; + for (var _i16 = 0, _len9 = _src14.length; _i16 < _len9; _i16++) { + var _entry6 = _src14[_i16]; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var line = '%token ' + entry.id; + var _line2 = '%token ' + _entry6.id; - if (entry.type) { - line += ' <' + entry.type + '>'; - delete entry.type; - } + if (_entry6.type) { + _line2 += ' <' + _entry6.type + '>'; + delete _entry6.type; + } - if (entry.value) { - line += ' ' + entry.value; - delete entry.value; - } + if (_entry6.value) { + _line2 += ' ' + _entry6.value; + delete _entry6.value; + } - if (entry.description) { - line += ' ' + escapeString(entry.description); - delete entry.description; - } + if (_entry6.description) { + _line2 += ' ' + escapeString(_entry6.description); + delete _entry6.description; + } - grammar_pre.push(line); - delete entry.id; + grammar_pre.push(_line2); + delete _entry6.id; - if (isEmptyObj(entry)) { - delete src[i]; - } else { - clean = false; + if (isEmptyObj(_entry6)) { + delete _src14[_i16]; + } else { + _clean3 = false; + } } - } - if (clean) { - delete raw.extra_tokens; + if (_clean3) { + delete raw.extra_tokens; + } } } + { + var _src15 = raw.parseParams; + delete raw.parseParams; - src = raw.parseParams; - delete raw.parseParams; - - if (src) { - grammar_pre.push('%parse-param ' + src.join(' ')); + if (_src15) { + grammar_pre.push('%parse-param ' + _src15.join(' ')); + } } + { + var _src16 = raw.start; + delete raw.start; - src = raw.start; - delete raw.start; - - if (src) { - grammar_pre.push('%start ' + src); + if (_src16) { + grammar_pre.push('%start ' + _src16); + } } + { + var _src17 = raw.moduleInclude; + delete raw.moduleInclude; - src = raw.moduleInclude; - delete raw.moduleInclude; + if (_src17 && _src17.trim()) { + grammar_post.push(indentAction(_src17.trim(), 0)); + } + } + { + var _src18 = raw.actionInclude; + delete raw.actionInclude; - if (src && src.trim()) { - grammar_post.push(indentAction(src.trim(), 0)); + if (_src18 && _src18.trim()) { + grammar_mid.push('%{\n' + indentAction(_src18.trim(), 4) + '\n%}'); + } } + { + var _out = ''; - src = raw.actionInclude; - delete raw.actionInclude; + if (!isEmptyObj(raw)) { + // dump the remainder as a comment: + var _rem = JSON5__default['default'].stringify(raw, null, 2); - if (src && src.trim()) { - grammar_mid.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); - } + _out += rmCommonWS$4(_templateObject151(), _rem.replace(/\*\//g, '*\\/')); // delete raw; + } - var out = ''; + if (!options.showParser) { + _out += lex_out_str; + } else { + _out += grammar_pre.join('\n') + '\n\n'; + _out += rmCommonWS$4(_templateObject152()); - if (!isEmptyObj(raw)) { - // dump the remainder as a comment: - var rem = JSON5__default['default'].stringify(raw, null, 2); - out += rmCommonWS$4(_templateObject150(), rem.replace(/\*\//g, '*\\/')); // delete raw; - } + if (grammar_mid.length > 0) { + _out += grammar_mid.join('\n') + '\n\n'; + } - if (!options.showParser) { - out += lex_out_str; - } else { - out += grammar_pre.join('\n') + '\n\n'; - out += rmCommonWS$4(_templateObject151()); + if (ebnf_rules.length > 0) { + if (bnf_rules.length > 0) { + // dump the original EBNF grammar as source and dump the BNF derivative as COMMENT: + var bnf_deriv = bnf_rules.join('\n\n'); - if (grammar_mid.length > 0) { - out += grammar_mid.join('\n') + '\n\n'; - } + var _a2 = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - if (ebnf_rules.length > 0) { - if (bnf_rules.length > 0) { - // dump the original EBNF grammar as source and dump the BNF derivative as COMMENT: - var bnf_deriv = bnf_rules.join('\n\n'); - var a = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); - out += rmCommonWS$4(_templateObject152(), a.join('\n')); + _out += rmCommonWS$4(_templateObject153(), _a2.join('\n')); + } + + _out += ebnf_rules.join('\n\n') + '\n\n'; + } else if (bnf_rules.length > 0) { + _out += bnf_rules.join('\n\n') + '\n\n'; } - out += ebnf_rules.join('\n\n') + '\n\n'; - } else if (bnf_rules.length > 0) { - out += bnf_rules.join('\n\n') + '\n\n'; + if (grammar_post.length > 0) { + _out += rmCommonWS$4(_templateObject154()) + grammar_post.join('\n') + '\n\n'; + } } - if (grammar_post.length > 0) { - out += rmCommonWS$4(_templateObject153()) + grammar_post.join('\n') + '\n\n'; - } - } + if (options.format === 'json5') { + var _a3 = _out.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - if (options.format === 'json5') { - var a = out.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); - out = rmCommonWS$4(_templateObject154(), options.showParser ? 'grammar' : 'lexer', a.join('\n')); // process the original input once again: this time via JSON5 + _out = rmCommonWS$4(_templateObject155(), options.showParser ? 'grammar' : 'lexer', _a3.join('\n')); // process the original input once again: this time via JSON5 - raw = deepClone(originalInput); + raw = deepClone(originalInput); - if (!options.showLexer) { - delete raw.lex; - out += JSON5__default['default'].stringify(raw, null, 2); - } else if (!options.showParser) { - out += JSON5__default['default'].stringify(raw.lex, null, 2); + if (!options.showLexer) { + delete raw.lex; + _out += JSON5__default['default'].stringify(raw, null, 2); + } else if (!options.showParser) { + _out += JSON5__default['default'].stringify(raw.lex, null, 2); + } } - } - return out; + return _out; + } } // Jison, an LR(0), SLR(1), LARL(1), LR(1) Parser Generator var rmCommonWS$5 = helpers.rmCommonWS; var mkIdentifier$4 = helpers.mkIdentifier; -var code_exec$2 = helpers.exec; -var version$2 = '0.6.2-220'; +var code_exec$1 = helpers.exec; +var version$2 = '0.7.0-220'; var devDebug = 0; function chkBugger$3(src) { @@ -22842,9 +23148,9 @@ var defaultJisonOptions = { // 0, 1, 2 outputDebugTables: false, noDefaultResolve: false, - defaultActionMode: ["classic", "merge"], + defaultActionMode: ['classic', 'merge'], // {classic, ast, none, skip}, {classic, ast, merge, none, skip} - testCompileActionCode: "parser:*,lexer:*", + testCompileActionCode: 'parser:*,lexer:*', noTryCatch: false, hasPartialLrUpgradeOnConflict: true, errorRecoveryTokenDiscardCount: 3, @@ -22924,14 +23230,14 @@ Jison$1.defaultJisonOptions = defaultJisonOptions; // Merge sets of options. function mkStdOptions$1() { var h = Object.prototype.hasOwnProperty; - var opts = {}; //var args = Array.prototype.concat.apply([], args); + var opts = {}; //let args = Array.prototype.concat.apply([], args); // clone defaults, so we do not modify those constants? - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len10 = arguments.length, args = new Array(_len10), _key9 = 0; _key9 < _len10; _key9++) { + args[_key9] = arguments[_key9]; } - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(Jison$1.defaultJisonOptions); } else { args.shift(); @@ -23047,10 +23353,10 @@ function mkStdOptions$1() { } // now see if we have an overriding option here: - for (var p in o2) { - if (h.call(o2, p)) { - if (typeof o2[p] !== 'undefined') { - opts[p] = o2[p]; + for (var _p4 in o2) { + if (h.call(o2, _p4)) { + if (typeof o2[_p4] !== 'undefined') { + opts[_p4] = o2[_p4]; } } } @@ -23121,7 +23427,7 @@ function autodetectAndConvertToJSONformat$1(grammar, optionalLexerSection, optio // When both JSON5 and JISON input modes barf a hairball, assume the most important // error is the JISON one (show that one first!), while it MAY be a JSON5 format // error that triggered it (show that one last!). - // + // // Also check for common JISON errors which are obviously never triggered by any // odd JSON5 input format error: when we encounter such an error here, we don't // confuse matters and forget about the JSON5 fail as it's irrelevant: @@ -23238,7 +23544,7 @@ if (typeof console !== 'undefined' && console.log) { Jison$1.Lexer = RegExpLexer; Jison$1.ebnfParser = ebnfParser; Jison$1.lexParser = lexParser; -Jison$1.codeExec = code_exec$2; +Jison$1.codeExec = code_exec$1; Jison$1.XRegExp = XRegExp__default['default']; Jison$1.recast = recast__default['default']; Jison$1.astUtils = astUtils__default['default']; //Jison.prettier = prettier; @@ -23314,7 +23620,7 @@ function union(a, b) { var Nonterminal = typal.construct({ constructor: function Nonterminal(symbol) { this.symbol = symbol; - this.productions = new Set(); + this.productions = new Set$1(); this.first = []; this.follows = []; this.nullable = false; @@ -23608,10 +23914,10 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, }; generator.processGrammar = function processGrammarDef(grammar) { - var bnf = grammar.bnf, - tokens = grammar.tokens, - nonterminals = this.nonterminals = {}, - productions = this.productions; + var bnf = grammar.bnf; + var tokens = grammar.tokens; + var nonterminals = this.nonterminals = {}; + var productions = this.productions; if (!grammar.bnf && grammar.ebnf) { bnf = grammar.bnf = ebnfParser.transform(grammar.ebnf); @@ -23667,11 +23973,11 @@ generator.processGrammar = function processGrammarDef(grammar) { } // Make sure all predefined symbols are unique and *numeric* and do not include predefined tokens JISON already defines to a fixed ID on its own: - delete predefined_symbols['$accept']; - delete predefined_symbols['$end']; - delete predefined_symbols['error']; - delete predefined_symbols['$eof']; - delete predefined_symbols['EOF']; + delete predefined_symbols.$accept; + delete predefined_symbols.$end; + delete predefined_symbols.error; + delete predefined_symbols.$eof; + delete predefined_symbols.EOF; var symdef_uniq_check = {}; // Only these symbols are allowed to have the values 1 or 2: symdef_uniq_check[1] = 'EOF'; @@ -23683,21 +23989,21 @@ generator.processGrammar = function processGrammarDef(grammar) { if (typeof v !== 'number') { if (typeof v !== 'string' || v.length !== 1) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a non-numeric symbol ID value must be a single-character string.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a non-numeric symbol ID value must be a single-character string."); } v = v.charCodeAt(0); } - v = v | 0; + v |= 0; if (!v || v < 0) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a symbol ID value must be an integer value, 3 or greater.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a symbol ID value must be an integer value, 3 or greater."); } if (symdef_uniq_check[v]) { if (symdef_uniq_check[v] !== sym) { - throw new Error('Error: `%import symbols `: symbol table contains duplicate ID values for keys \'' + sym + '\' and \'' + symdef_uniq_check[v] + '\''); + throw new Error("Error: `%import symbols `: symbol table contains duplicate ID values for keys '" + sym + "' and '" + symdef_uniq_check[v] + "'"); } } @@ -23798,13 +24104,14 @@ generator.augmentGrammar = function augmentGrammar(grammar) { generator.signalUnusedProductions = function () { + var _this3 = this; + var mark = {}; var productions = this.productions; var nonterminals = this.nonterminals; - var i, len, nt, sym; - for (i = 0, len = nonterminals.length; i < len; i++) { - nt = nonterminals[i]; + for (var i = 0, len = nonterminals.length; i < len; i++) { + var nt = nonterminals[i]; assert__default['default'](nt.symbol); mark[nt.symbol] = false; } // scan & mark all visited productions @@ -23821,7 +24128,7 @@ generator.signalUnusedProductions = function () { assert__default['default'](p.handle); var rhs = p.handle; - for (var j = 0, len = rhs.length; j < len; j++) { + for (var j = 0, _len11 = rhs.length; j < _len11; j++) { var sym = rhs[j]; assert__default['default'](!sym ? !nonterminals[sym] : true); @@ -23836,8 +24143,8 @@ generator.signalUnusedProductions = function () { /* this.startSymbol */ ]); // now any production which is not yet marked is *unused*: - for (sym in mark) { - nt = nonterminals[sym]; + var _loop = function _loop(sym) { + var nt = nonterminals[sym]; assert__default['default'](nt); var prods = nt.productions; assert__default['default'](prods); @@ -23854,8 +24161,12 @@ generator.signalUnusedProductions = function () { if (!in_use) { // and kill the unused nonterminals: - delete this.nonterminals[sym]; + delete _this3.nonterminals[sym]; } + }; + + for (var sym in mark) { + _loop(sym); } this.unused_productions = productions.filter(function (p) { @@ -23922,7 +24233,7 @@ function reindentCodeBlock(action, indent_level) { generator.buildProductions = function buildProductions(bnf, productions, nonterminals, symbols, operators, predefined_symbols, descriptions) { var self = this; - var prods, symbol, symId; + var prods, symId; var productions_ = []; var symbols_ = {}; var descriptions_ = {}; @@ -23938,9 +24249,9 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm this.EOF = '$end'; symbols_.$accept = 0; symbols_[this.EOF] = 1; - symbols_['$eof'] = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.$eof = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! - symbols_['EOF'] = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.EOF = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! symbols[0] = '$accept'; symbols[1] = this.EOF; @@ -23950,7 +24261,7 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm symbols[2] = 'error'; if (predefined_symbols) { - for (symbol in predefined_symbols) { + for (var symbol in predefined_symbols) { symId = predefined_symbols[symbol]; if (symId === true) { @@ -23974,9 +24285,9 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm usedSymbolIdsLowIndex = (this.options.compressTables | 0) < 2 ? 32 : 3; - for (symbol in predefined_symbols) { - symId = predefined_symbols[symbol]; - addSymbol(symbol); + for (var _symbol in predefined_symbols) { + symId = predefined_symbols[_symbol]; + addSymbol(_symbol); } // reset ID low water mark: nonterminals etc. can be assigned any number, preferably a small/low one! @@ -24035,20 +24346,19 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm function collectLiteralTokensInProduction(handle) { - var rhs, i, sym; + var rhs; try { if (devDebug) ; var maxlen = this.maxTokenLength || Infinity; if (handle.constructor === Array) { - var rhs_i; rhs = typeof handle[0] === 'string' ? splitStringIntoSymbols(handle[0]) : handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; // check for aliased names, e.g., id[alias] and strip them + for (var i = 0; i < rhs.length; i++) { + var sym = rhs[i]; // check for aliased names, e.g., id[alias] and strip them - rhs_i = sym.match(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]$"))); + var rhs_i = sym.match(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]$"))); if (rhs_i) { sym = sym.substr(0, sym.length - rhs_i[0].length); @@ -24063,18 +24373,16 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm handle = handle.replace(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]"), 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; + for (var _i17 = 0; _i17 < rhs.length; _i17++) { + var _sym = rhs[_i17]; - if (!bnf[sym] && sym.length <= maxlen) { - addSymbol(sym); + if (!bnf[_sym] && _sym.length <= maxlen) { + addSymbol(_sym); } } } } catch (ex) { - console.error(ex, '\ncollectLiteralTokensInProduction: ', symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { - i: i, - sym: sym, + console.error(ex, '\ncollectLiteralTokensInProduction: ', this.symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { rhs: rhs }); throw ex; @@ -24087,33 +24395,35 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm var prodsLUT = {}; - for (symbol in bnf) { - if (!bnf.hasOwnProperty(symbol)) continue; + for (var _symbol2 in bnf) { + if (!bnf.hasOwnProperty(_symbol2)) continue; - if (typeof bnf[symbol] === 'string') { - prods = bnf[symbol].split(/\s*\|\s*/g); + if (typeof bnf[_symbol2] === 'string') { + prods = bnf[_symbol2].split(/\s*\|\s*/g); } else { - prods = bnf[symbol].slice(0); + prods = bnf[_symbol2].slice(0); } - prodsLUT[symbol] = prods; + prodsLUT[_symbol2] = prods; } // First we collect all single-character literal tokens: - for (symbol in prodsLUT) { - if (!prodsLUT.hasOwnProperty(symbol)) continue; - prods = prodsLUT[symbol]; + for (var _symbol3 in prodsLUT) { + if (!prodsLUT.hasOwnProperty(_symbol3)) continue; + prods = prodsLUT[_symbol3]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: 1 + maxTokenLength: 1, + symbol: _symbol3 }); } // Next we collect all other literal tokens: - for (symbol in prodsLUT) { - if (!prodsLUT.hasOwnProperty(symbol)) continue; - prods = prodsLUT[symbol]; + for (var _symbol4 in prodsLUT) { + if (!prodsLUT.hasOwnProperty(_symbol4)) continue; + prods = prodsLUT[_symbol4]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: Infinity + maxTokenLength: Infinity, + symbol: _symbol4 }); } // and now go and process the entire grammar: // first collect all nonterminals in a symbol table, then build the productions @@ -24122,22 +24432,24 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm // referenced: - for (symbol in bnf) { - if (!bnf.hasOwnProperty(symbol)) continue; - addSymbol(symbol); - nonterminals[symbol] = new Nonterminal(symbol); + for (var _symbol5 in bnf) { + if (!bnf.hasOwnProperty(_symbol5)) continue; + addSymbol(_symbol5); + nonterminals[_symbol5] = new Nonterminal(_symbol5); } // now that we have collected all nonterminals in our symbol table, it's finally // time to process the productions: - for (symbol in prodsLUT) { - if (!prodsLUT.hasOwnProperty(symbol)) continue; - prods = prodsLUT[symbol]; - prods.forEach(buildProduction); + for (var _symbol6 in prodsLUT) { + if (!prodsLUT.hasOwnProperty(_symbol6)) continue; + prods = prodsLUT[_symbol6]; + prods.forEach(buildProduction, { + symbol: _symbol6 + }); } - var terms = [], - terms_ = {}; + var terms = []; + var terms_ = {}; each(symbols_, function (id, sym) { // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number @@ -24162,9 +24474,9 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm chk_er_opt('parserErrorsAreRecoverable', 'parser-errors-are-recoverable feature/option'); // Hmmmm... why would lexer errors need to be NON-recoverable when there's no ERROR rules in the GRAMMAR?! chk_er_opt('lexerErrorsAreRecoverable', 'lexer-errors-are-recoverable feature/option'); - chk_er_opt('parseActionsUseYYRECOVERING', 'YYRECOVERING macro/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYERROK', 'yyerrok() function/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYCLEARIN', 'yyclearin() function/API in grammar rules\' action code'); + chk_er_opt('parseActionsUseYYRECOVERING', "YYRECOVERING macro/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYERROK', "yyerrok() function/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYCLEARIN', "yyclearin() function/API in grammar rules' action code"); } this.terminals = terms; @@ -24256,23 +24568,21 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm } return tokens; - } + } // options object { symbol } is `this` for this functon/callback: + function buildProduction(handle) { - var r, - rhs, - i, - precedence_override, - aliased = [], - action = null; + var rhs; + var precedence_override = null; + var aliased = []; + var action = null; if (handle.constructor === Array) { - var rhs_i; rhs = typeof handle[0] === 'string' ? splitStringIntoSymbols(handle[0]) : handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { + for (var i = 0; i < rhs.length; i++) { // check for aliased names, e.g., id[alias] and strip them - rhs_i = rhs[i].match(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]$"))); + var rhs_i = rhs[i].match(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]$"))); if (rhs_i) { rhs[i] = rhs[i].substr(0, rhs[i].length - rhs_i[0].length); @@ -24316,17 +24626,17 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm handle = handle.replace(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]"), 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (i = 0; i < rhs.length; i++) { - if (rhs[i] === 'error') { + for (var _i18 = 0; _i18 < rhs.length; _i18++) { + if (rhs[_i18] === 'error') { hasErrorRecovery = true; } - assert__default['default'](bnf[rhs[i]] ? symbols_[rhs[i]] : true, 'all nonterminals must already exist in the symbol table'); - assert__default['default'](rhs[i] ? symbols_[rhs[i]] : true, 'all symbols (terminals and nonterminals) must already exist in the symbol table'); //addSymbol(rhs[i]); + 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]); } } - r = new Production(symbol, rhs, productions.length + 1, aliased, action); // set precedence + var r = new Production(this.symbol, rhs, productions.length + 1, aliased, action); // set precedence assert__default['default'](r.precedence === 0); @@ -24336,23 +24646,23 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm var prec_symbols = []; var winning_symbol; - for (i = r.handle.length - 1; i >= 0; i--) { - if (!(r.handle[i] in nonterminals) && r.handle[i] in operators) { + for (var _i19 = r.handle.length - 1; _i19 >= 0; _i19--) { + if (!(r.handle[_i19] in nonterminals) && r.handle[_i19] in operators) { var old_prec = r.precedence; - var new_prec = operators[r.handle[i]].precedence; + var new_prec = operators[r.handle[_i19]].precedence; if (old_prec !== 0 && old_prec !== new_prec) { - prec_symbols.push(r.handle[i]); // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], symbol, handle[0]); + prec_symbols.push(r.handle[_i19]); // 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[i]; + winning_symbol = r.handle[_i19]; } else { // keep previously set precedence: new_prec = old_prec; } } else if (old_prec === 0) { - prec_symbols.push(r.handle[i]); - winning_symbol = r.handle[i]; // Jison.print('precedence set first time: ', old_prec, r.handle[i], symbol, handle[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]); } r.precedence = new_prec; @@ -24361,14 +24671,14 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm if (prec_symbols.length > 1) { if (self.DEBUG || 1) { - self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); + self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + this.symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); } } } productions.push(r); productions_.push([symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length]); - nonterminals[symbol].productions.push(r); + nonterminals[this.symbol].productions.push(r); } }; // Preprocess the action code block before we perform any `$n`, `@n` ,`##n` or `#n` expansions: // Any comment blocks in there should be kept intact (and not cause trouble either as those comments MAY @@ -24440,13 +24750,10 @@ function preprocessActionCode(s) { // with our pants down in constructs like // `'"' + $$ + '"'` vs. `"'" + $$ + "'"` - var dqpos, - sqpos, - ccmtpos, - cppcmtpos, - first = -1; + var dqpos, sqpos, ccmtpos, cppcmtpos; + var first = -1; - for (var c = 0;; c++) { + for (var _c2 = 0;; _c2++) { first++; dqpos = s.indexOf('"', first); sqpos = s.indexOf("'", first); // also look for remaining comments which contain quotes of any kind, @@ -24480,7 +24787,7 @@ function postprocessActionCode(s) { s = s // multiline comment start markers: .replace(/\x01\x84/g, '/*').replace(/\x01\x85/g, '/*').replace(/\x01\x86/g, '//') // revert markers: .replace(/\x01\x81/g, '#').replace(/\x01\x82/g, '$').replace(/\x01\x83/g, '@') // and revert the string and regex markers: - .replace(/\x01\x87/g, '\'').replace(/\x01\x88/g, '\"').replace(/\x01\x89/g, '##').replace(/\x01\x90/g, '\\\\').replace(/\x01\x91/g, '\\\'').replace(/\x01\x92/g, '\\\"').replace(/\x01\x93/g, '\\\/').replace(/\x01\x94/g, 'YYABORT').replace(/\x01\x95/g, 'YYACCEPT').replace(/\x01\x96/g, 'yyvstack').replace(/\x01\x97/g, 'yylstack').replace(/\x01\x98/g, 'yyerror').replace(/\x01\x99/g, 'YYRECOVERING').replace(/\x01\x9A/g, 'yyerrok').replace(/\x01\x9B/g, 'yyclearin').replace(/\x01\x9C/g, 'yysp').replace(/\x01\x9D__/g, 'yy'); // And a final, minimal, fixup for the semicolon-lovers -- like me! ;-) + .replace(/\x01\x87/g, "'").replace(/\x01\x88/g, '\"').replace(/\x01\x89/g, '##').replace(/\x01\x90/g, '\\\\').replace(/\x01\x91/g, "\\'").replace(/\x01\x92/g, '\\\"').replace(/\x01\x93/g, '\\\/').replace(/\x01\x94/g, 'YYABORT').replace(/\x01\x95/g, 'YYACCEPT').replace(/\x01\x96/g, 'yyvstack').replace(/\x01\x97/g, 'yylstack').replace(/\x01\x98/g, 'yyerror').replace(/\x01\x99/g, 'YYRECOVERING').replace(/\x01\x9A/g, 'yyerrok').replace(/\x01\x9B/g, 'yyclearin').replace(/\x01\x9C/g, 'yysp').replace(/\x01\x9D__/g, 'yy'); // And a final, minimal, fixup for the semicolon-lovers -- like me! ;-) // // Make sure the last statement is properly semicolon-terminated 99.9% of the time: @@ -24519,11 +24826,11 @@ generator.buildProductionActions = function buildProductionActions() { this.productions_ = productions_; assert(this.productions === productions); */ - var productions = this.productions, - nonterminals = this.nonterminals, - symbols = this.symbols, - operators = this.operators, - self = this; // As a SIDE EFFECT of this call, we also fixup + var productions = this.productions; + var nonterminals = this.nonterminals; + var symbols = this.symbols; + var operators = this.operators; + var self = this; // As a SIDE EFFECT of this call, we also fixup // the other code chunks specified in the grammar file: // // Replace direct symbol references, e.g. #NUMBER# when there's a `%token NUMBER` for your grammar. @@ -24554,16 +24861,19 @@ generator.buildProductionActions = function buildProductionActions() { while (gen_hash !== prev_gen_hash) { var preludeCode = preprocessActionCode(this.actionInclude || ''); - var actions = ["\n /* this == yyval */\n\n // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code!\n var yy = this.yy;\n var yyparser = yy.parser;\n var yylexer = yy.lexer;\n\n ".concat(preludeCode, "\n\n switch (yystate) {")]; + var actions = ["\n /* this == yyval */\n\n // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code!\n let yy = this.yy;\n let yyparser = yy.parser;\n let yylexer = yy.lexer;\n\n ".concat(preludeCode, "\n\n switch (yystate) {")]; var actionGroups = {}; // used to combine identical actions into single instances: no use duplicating action code needlessly var actionGroupValue = {}; // stores the unaltered, expanded, user-defined action code for each action group. var stateHasAction = []; // marks which state IDs have an action, either user-specified or default. + // and now go and process the entire grammar: - var symbol; // and now go and process the entire grammar: - - productions.forEach(buildProductionAction); + productions.forEach(buildProductionAction, { + actionGroups: actionGroups, + actionGroupValue: actionGroupValue, + stateHasAction: stateHasAction + }); for (var hash in actionGroups) { actions.push([].concat.apply([], actionGroups[hash]).join('\n') + '\n\n' + actionGroupValue[hash] + '\n break;\n'); @@ -24588,10 +24898,10 @@ generator.buildProductionActions = function buildProductionActions() { if (missingActions.length) { if (this.DEBUG) { - this.warn("WARNING: missing actions for states: ", missingActions); + this.warn('WARNING: missing actions for states: ', missingActions); } - actions.push("default:\n // default action for all unlisted resolve states: ".concat(missingActions.join(', '), "\n\n // When we hit this entry, it's always a non-recoverable issue as this is a severe internal parser state failure:\n function __b0rk_on_internal_failure(str) {\n var hash = yyparser.constructParseErrorInfo(str, null, null, false);\n\n return yyparser.parseError(str, hash, yyparser.JisonParserError);\n }\n\n return __b0rk_on_internal_failure(\"internal parser failure: resolving unlisted state: \" + yystate);")); + actions.push("default:\n // default action for all unlisted resolve states: ".concat(missingActions.join(', '), "\n\n // When we hit this entry, it's always a non-recoverable issue as this is a severe internal parser state failure:\n function __b0rk_on_internal_failure(str) {\n let hash = yyparser.constructParseErrorInfo(str, null, null, false);\n\n return yyparser.parseError(str, hash, yyparser.JisonParserError);\n }\n\n return __b0rk_on_internal_failure(\"internal parser failure: resolving unlisted state: \" + yystate);")); } actions.push('}'); @@ -24761,9 +25071,9 @@ generator.buildProductionActions = function buildProductionActions() { this.actionsUseValueAssignment = true; break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": + case 'skip': // <-- this one injects *nothing* break; } @@ -24774,9 +25084,9 @@ generator.buildProductionActions = function buildProductionActions() { default: break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": + case 'skip': // <-- this one injects *nothing* break; } @@ -24848,7 +25158,7 @@ generator.buildProductionActions = function buildProductionActions() { moduleInit.getInitCodeSection = function getInitCodeSection(section) { var rv = []; - for (var i = 0, len = this.length; i < len; i++) { + for (var i = 0, _len12 = this.length; i < _len12; i++) { var m = this[i]; if (m.qualifier === section) { @@ -24866,11 +25176,11 @@ generator.buildProductionActions = function buildProductionActions() { moduleInit.getRemainingInitCodeSections = function getRemainingInitCodeSections() { var rv = []; - for (var i = 0, len = this.length; i < len; i++) { + for (var i = 0, _len13 = this.length; i < _len13; i++) { var m = this[i]; if (!this.__consumedInitCodeSlots__[i]) { - rv.push(rmCommonWS$5(_templateObject155(), m.qualifier, m.include, m.qualifier)); + rv.push(rmCommonWS$5(_templateObject156(), m.qualifier, m.include, m.qualifier)); this.__consumedInitCodeSlots__[i] = true; } } @@ -24947,12 +25257,11 @@ generator.buildProductionActions = function buildProductionActions() { return ''; - } + } // options object { actionGroups, actionGroupValue, stateHasAction } is `this` for this function/callback: + function buildProductionAction(handle) { - var i; - var aliased = handle.aliases, - rhs_i; + var aliased = handle.aliases; var rhs = handle.handle; var named_token_re = new XRegExp__default['default']("^".concat(ID_REGEX_BASE$3, "$")); // semantic action specified @@ -24970,7 +25279,7 @@ generator.buildProductionActions = function buildProductionActions() { var rule4msg = handle.symbol + ': ' + rhs.join(' '); assert__default['default'](typeof handle.id === 'number'); assert__default['default'](handle.id >= 0); - stateHasAction[handle.id] = true; // before anything else, replace direct symbol references, e.g. #NUMBER# when there's a %token NUMBER for your grammar. + this.stateHasAction[handle.id] = true; // before anything else, replace direct symbol references, e.g. #NUMBER# when there's a %token NUMBER for your grammar. // This is done to prevent incorrect expansions where tokens are used in rules as RHS elements: we allow these to // be referenced as both #TOKEN# and #TOKEN where the first is a literal token/symbol reference (unrelated to its use // in the rule) and the latter is a reference to the token/symbol being used in the rule. @@ -24982,9 +25291,9 @@ generator.buildProductionActions = function buildProductionActions() { }); // replace named semantic values ($nonterminal) if (action.match(new XRegExp__default['default']("(?:[$@#]|##)".concat(ID_REGEX_BASE$3)))) { - var count = {}, - names = {}, - donotalias = {}; // When the rule is fitted with aliases it doesn't mean that the action code MUST use those: + var count = {}; + var names = {}; + var donotalias = {}; // When the rule is fitted with aliases it doesn't mean that the action code MUST use those: // we therefor allow access to both the original (non)terminal and the alias. // // Also note that each (non)terminal can also be uniquely addressed by [$@] @@ -25014,7 +25323,7 @@ generator.buildProductionActions = function buildProductionActions() { // while `e2` would be ambiguous from the human perspective as he *might* then // expect `e2` and `e3`. - var addName = function addName(s) { + var addName = function addName(s, i) { var base = s.replace(/[0-9]+$/, ''); var dna = donotalias[base]; @@ -25046,9 +25355,9 @@ generator.buildProductionActions = function buildProductionActions() { } }; - for (i = 0; i < rhs.length; i++) { + for (var i = 0; i < rhs.length; i++) { // mark both regular and aliased names, e.g., `id[alias1]` and `id1` - rhs_i = aliased[i]; + var rhs_i = aliased[i]; markBasename(rhs_i); if (rhs_i !== rhs[i]) { @@ -25056,13 +25365,13 @@ generator.buildProductionActions = function buildProductionActions() { } } - for (i = 0; i < rhs.length; i++) { + for (var _i20 = 0; _i20 < rhs.length; _i20++) { // check for aliased names, e.g., id[alias] - rhs_i = aliased[i]; - addName(rhs_i); + var _rhs_i = aliased[_i20]; + addName(_rhs_i, _i20); - if (rhs_i !== rhs[i]) { - addName(rhs[i]); + if (_rhs_i !== rhs[_i20]) { + addName(rhs[_i20], _i20); } } @@ -25077,7 +25386,7 @@ generator.buildProductionActions = function buildProductionActions() { action = action // replace references to `$$` with `this.$`, `@$` with `this._$` and `#$` with the token ID of the current rule .replace(/\$\$/g, 'this.$').replace(/@\$/g, 'this._$').replace(/#\$/g, function (_) { - return provideSymbolAsSourcecode(symbol); + return provideSymbolAsSourcecode(handle.symbol); }) // replace semantic value references ($n) with stack value (stack[n]) .replace(/\$(-?\d+)\b/g, function (_, n) { return 'yyvstack[yysp' + indexToJsExpr(n, rhs.length, rule4msg) + ']'; @@ -25201,24 +25510,26 @@ generator.buildProductionActions = function buildProductionActions() { // $@ = undefined; // - var vmode = !inject_default_value_action ? "skip" : self.options.defaultActionMode[0]; - var lmode = !inject_default_loc_action ? "skip" : self.options.defaultActionMode[1]; // check if there's no user action specified. Insert default action if it isn't. + var vmode = !inject_default_value_action ? 'skip' : self.options.defaultActionMode[0]; + var lmode = !inject_default_loc_action ? 'skip' : self.options.defaultActionMode[1]; // check if there's no user action specified. Insert default action if it isn't. // first determine the actual number of terms in the production: - var rhs = handle.handle.slice(0); + var rhs_reduced_length = rhs.length; var real_rhs_length = rhs.length; // strip away EOF terms at the end of the rule, ditto for epsilon terms: - if (rhs.length) { - switch (rhs[rhs.length - 1]) { + while (rhs_reduced_length) { + switch (rhs[rhs_reduced_length - 1]) { case '$end': - rhs.length--; - break; + rhs_reduced_length--; + continue; case '': // %epsilon - rhs.length--; - break; + rhs_reduced_length--; + continue; } + + break; } // then we can choose what to do, depending on the number of terms in the production. // // There are a few reasons *why* one would choose to inject the default action: @@ -25235,18 +25546,18 @@ generator.buildProductionActions = function buildProductionActions() { // - switch (rhs.length) { + switch (rhs_reduced_length) { case 0: switch (vmode) { - case "classic": // $$ = $1; <-- but that would cause nondeterministic behaviour, so + case 'classic': // $$ = $1; <-- but that would cause nondeterministic behaviour, so // we fall back to the default here! - case "ast": - case "none": - default_action.push("this.$ = undefined;"); + case 'ast': + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25255,22 +25566,22 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // an empty production has no location as there are no terms parsed. // ergo: we produce a zero-width location which points at the tail // end of the previous content: // @$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);"); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25282,19 +25593,19 @@ generator.buildProductionActions = function buildProductionActions() { case 1: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; // // WARNING: be careful with the ACCEPT rule as that one's production has - // rhs.length === 1 **BUT** has real_rhs_length === 2 as we have discarded + // rhs_reduced_length === 1 **BUT** has real_rhs_length === 2 as we have discarded // the `$end` term at the end! // Here we need to account for that magick though! - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // As we're looking at a production which has one(1) useful term, we can simply // reference-copy that one intom a fresh array, instead of `slice()`-ing it out // of the vstack. @@ -25303,14 +25614,14 @@ generator.buildProductionActions = function buildProductionActions() { // WARNING/NOTE: as above, and ditto BTW for rule productions which end with // `EOF` as a last term: as we now construct an entire AST, we DO NOT include // those 'values' here! - default_action.push("this.$ = [yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "]];"); + default_action.push('this.$ = [yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ']];'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25319,23 +25630,23 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: // as we have a production length of 1 only, we can simply ref-copy @1: // @$ = @1; // // WARNING: same as above for the value copying: we may have discarded an `EOF` or `$end` term! - default_action.push("this._$ = yylstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this._$ = yylstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25347,31 +25658,31 @@ generator.buildProductionActions = function buildProductionActions() { default: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // - // WARNING: as with the situation further above where rhs.length === 1 after we + // WARNING: as with the situation further above where rhs_reduced_length === 1 after we // have got rid of a possible `EOF` or `$end` at the end of the production, // we again have to account for our trickery earlier and compensate the // action above: again we DO NOT include the value of the EOF/$end token in the // resulting array 'AST', hence our `slice()` end index may vary by one(1): - var end_offset = 1 - real_rhs_length + rhs.length; - default_action.push("this.$ = yyvstack.slice(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp" + ( - /* CANNOT USE indexToJsExpr(rhs.length + 1, real_rhs_length, rule4msg) HERE! */ - end_offset === 0 ? "" : " + " + end_offset) + ");"); + var end_offset = 1 - real_rhs_length + rhs_reduced_length; + default_action.push('this.$ = yyvstack.slice(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp' + ( + /* CANNOT USE indexToJsExpr(rhs_reduced_length + 1, real_rhs_length, rule4msg) HERE! */ + end_offset === 0 ? '' : ' + ' + end_offset) + ');'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25380,20 +25691,20 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: - // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs.length - 1}, yysp); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp);"); + // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs_reduced_length - 1}, yysp); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25407,7 +25718,7 @@ generator.buildProductionActions = function buildProductionActions() { if (default_action.length > 0) { - var flags = [rhs.length, self.actionsUseValueTracking ? "VT" : "-", self.actionsUseValueAssignment ? "VA" : "-", uses_$$ ? "VU" : "-", uses_$$_before_assignment ? "VUbA" : "-", self.actionsUseLocationTracking ? "LT" : "-", self.actionsUseLocationAssignment ? "LA" : "-", uses_$loc ? "LU" : "-", uses_$loc_before_assignment ? "LUbA" : "-"].join(','); + var flags = [rhs_reduced_length + '/' + real_rhs_length, self.actionsUseValueTracking ? 'VT' : '-', self.actionsUseValueAssignment ? 'VA' : '-', uses_$$ ? 'VU' : '-', uses_$$_before_assignment ? 'VUbA' : '-', self.actionsUseLocationTracking ? 'LT' : '-', self.actionsUseLocationAssignment ? 'LA' : '-', uses_$loc ? 'LU' : '-', uses_$loc_before_assignment ? 'LUbA' : '-'].join(','); default_action.unshift("// default action (generated by JISON mode ".concat(self.options.defaultActionMode[0], "/").concat(self.options.defaultActionMode[1], " :: ").concat(flags, "):")); default_action.push("// END of default action (generated by JISON mode ".concat(self.options.defaultActionMode[0], "/").concat(self.options.defaultActionMode[1], " :: ").concat(flags, ")")); @@ -25422,11 +25733,11 @@ generator.buildProductionActions = function buildProductionActions() { var actionHash = mkHashIndex(action); // Delay running the postprocess (restore) process until we've done ALL macro expansions: //action = postprocessActionCode(action); - if (actionHash in actionGroups) { - actionGroups[actionHash].push(label); + if (actionHash in this.actionGroups) { + this.actionGroups[actionHash].push(label); } else { - actionGroups[actionHash] = [label]; - actionGroupValue[actionHash] = action; + this.actionGroups[actionHash] = [label]; + this.actionGroupValue[actionHash] = action; } } }; @@ -25532,7 +25843,7 @@ generator.reportGrammarInformation = function reportGrammarInformation() { }; // --- START of debugTraceSrc chunk --- -var debugTraceSrc = "\nfunction debug_trace() {\n \"use strict\";\n\n if (typeof Jison !== 'undefined' && Jison.print) {\n Jison.print.apply(null, arguments);\n } else if (typeof print !== 'undefined') {\n print.apply(null, arguments);\n } else if (typeof console !== 'undefined' && console.log) {\n var args = Array.prototype.slice.call(arguments, 0);\n args.unshift(''); // prevent `%.` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args\n console.log.apply(null, args);\n }\n}\n"; // --- END of debugTraceSrc chunk --- +var debugTraceSrc = "\nfunction debug_trace() {\n if (typeof Jison !== 'undefined' && Jison.print) {\n Jison.print.apply(null, arguments);\n } else if (typeof print !== 'undefined') {\n print.apply(null, arguments);\n } else if (typeof console !== 'undefined' && console.log) {\n let args = Array.prototype.slice.call(arguments, 0);\n args.unshift(''); // prevent `%.` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args\n console.log.apply(null, args);\n }\n}\n"; // --- END of debugTraceSrc chunk --- // Generator debug mixin var generatorDebug = { @@ -25599,10 +25910,10 @@ lookaheadMixin.displayFollowSets = function displayFollowSets() { lookaheadMixin.followSets = function followSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true; // loop until no further changes have been made + var productions = this.productions; + var nonterminals = this.nonterminals; + var self = this; + var cont = true; // loop until no further changes have been made while (cont) { cont = false; @@ -25619,7 +25930,7 @@ lookaheadMixin.followSets = function followSets() { } var bool = !ctx || q === self.nterms_[t]; - var set; + var set = void 0; if (i === production.handle.length - 1 && bool) { set = nonterminals[production.symbol].follows; @@ -25668,25 +25979,25 @@ lookaheadMixin.first = function first(symbol) { firsts = union(firsts, this.nonterminals[t].first); } - if (!this.nullable(t)) break; + if (!this.nullable(t)) { + break; + } } return firsts; // terminal } else if (!this.nonterminals[symbol]) { return [symbol]; // nonterminal - } else { - return this.nonterminals[symbol].first; } + + return this.nonterminals[symbol].first; }; // fixed-point calculation of FIRST sets lookaheadMixin.firstSets = function firstSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true, - symbol, - firsts; // loop until no further changes have been made + var productions = this.productions; + var nonterminals = this.nonterminals; + var self = this; + var cont = true; // loop until no further changes have been made while (cont) { cont = false; @@ -25699,8 +26010,8 @@ lookaheadMixin.firstSets = function firstSets() { } }); - for (symbol in nonterminals) { - firsts = []; + var _loop2 = function _loop2(symbol) { + var firsts = []; nonterminals[symbol].productions.forEach(function FirstSets_forEachNonTerm(production) { firsts = union(firsts, production.first); }); @@ -25709,22 +26020,29 @@ lookaheadMixin.firstSets = function firstSets() { nonterminals[symbol].first = firsts; cont = true; } + }; + + for (var symbol in nonterminals) { + _loop2(symbol); } } }; // fixed-point calculation of NULLABLE lookaheadMixin.nullableSets = function nullableSets() { - var nonterminals = this.nonterminals, - self = this, - cont = true; // loop until no further changes have been made + var nonterminals = this.nonterminals; + var self = this; + var cont = true; // loop until no further changes have been made while (cont) { cont = false; // check if each production is nullable this.productions.forEach(function isEachProductionNullable(production, k) { if (!production.nullable) { - for (var i = 0, n = 0, t; t = production.handle[i]; ++i) { + var i = 0; + var n = 0; + + for (var t; t = production.handle[i]; ++i) { if (self.nullable(t)) n++; } @@ -25762,9 +26080,9 @@ lookaheadMixin.nullable = function nullable(symbol) { return true; // terminal } else if (!this.nonterminals[symbol]) { return false; // nonterminal - } else { - return this.nonterminals[symbol].nullable; } + + return this.nonterminals[symbol].nullable; }; // lookahead debug mixin @@ -25866,7 +26184,7 @@ lrGeneratorMixin.Item = typal.construct({ return s; } }); -lrGeneratorMixin.ItemSet = Set.prototype.construct({ +lrGeneratorMixin.ItemSet = Set$1.prototype.construct({ afterconstructor: function afterconstructor() { this.reductions = []; this.goes = {}; @@ -25913,12 +26231,12 @@ lrGeneratorMixin.ItemSet = Set.prototype.construct({ lrGeneratorMixin.closureOperation = function closureOperation(itemSet) { var closureSet = new this.ItemSet(); var self = this; - var set = itemSet, - itemQueue, - syms = {}; + var set = itemSet; + var itemQueue; + var syms = {}; do { - itemQueue = new Set(); + itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function CO_set_forEach(item) { var symbol = item.markedSymbol; // if token is a non-terminal, recursively add closures @@ -25951,8 +26269,8 @@ lrGeneratorMixin.closureOperation = function closureOperation(itemSet) { }; lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) { - var gotoSet = new this.ItemSet(), - self = this; + var gotoSet = new this.ItemSet(); + var self = this; itemSet.forEach(function goto_forEach(item, n) { if (item.markedSymbol === symbol) { gotoSet.push(new self.Item(item.production, item.dotPosition + 1, item.follows, n)); @@ -25967,13 +26285,13 @@ lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) { lrGeneratorMixin.canonicalCollection = function canonicalCollection() { var item1 = new this.Item(this.productions[0], 0, [this.EOF]); - var firstStateNoClosure = new this.ItemSet(item1), - firstState = this.closureOperation(firstStateNoClosure), - states = new Set(firstState), - marked = 0, - self = this, - itemSet, - markedSymbols; + var firstStateNoClosure = new this.ItemSet(item1); + var firstState = this.closureOperation(firstStateNoClosure); + var states = new Set$1(firstState); + var marked = 0; + var self = this; + var itemSet; + var markedSymbols; states.has = {}; states.has[firstStateNoClosure.valueOf()] = 0; @@ -25994,8 +26312,8 @@ lrGeneratorMixin.canonicalCollection = function canonicalCollection() { lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert(symbol, itemSet, states, stateNum) { - var g = this.gotoOperation(itemSet, symbol), - state = states.has[g.valueOf()]; + var g = this.gotoOperation(itemSet, symbol); + var state = states.has[g.valueOf()]; if (typeof state !== 'undefined') { itemSet.edges[symbol] = state; // store goto transition for table @@ -26020,12 +26338,12 @@ lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert( }; lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { - var states = [], - nonterminals = this.nonterminals, - operators = this.operators, - conflictedStates = {}, - // set of [state, token] tuples - self = this; // for each item set + var states = []; + var nonterminals = this.nonterminals; + var operators = this.operators; + var conflictedStates = {}; // set of [state, token] tuples + + var self = this; // for each item set itemSets.forEach(function parseTableItem(itemSet, k) { k = +k; @@ -26170,11 +26488,11 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { function findDefaults(states, hasErrorRecovery) { var defaults = {}; states.forEach(function (state, k) { - var act, sym, st; + var act; var i = 0; var gotos = {}; - for (sym in state) { + for (var sym in state) { assert__default['default']({}.hasOwnProperty.call(state, sym)); // it this isn't true, the last part of this function won't work! // keep state rows where there's an error recovery state: @@ -26184,7 +26502,7 @@ function findDefaults(states, hasErrorRecovery) { return; } - st = state[sym]; + var st = state[sym]; if (typeof st !== 'number') { if (st[0] !== REDUCE) { @@ -26220,11 +26538,11 @@ function findDefaults(states, hasErrorRecovery) { // when there's no error recovery code included in the generated parser: if (!hasErrorRecovery) { - for (sym in state) { - st = state[sym]; + for (var _sym2 in state) { + var _st = state[_sym2]; - if (typeof st !== 'number') { - delete state[sym]; + if (typeof _st !== 'number') { + delete state[_sym2]; } } } @@ -26236,9 +26554,7 @@ function findDefaults(states, hasErrorRecovery) { function cleanupTable(table) { table.forEach(function (state, k) { - var symbol; - - for (symbol in state) { + for (var symbol in state) { if (state[symbol] === NONASSOC) { delete state[symbol]; } @@ -26324,7 +26640,7 @@ generatorMixin.__prepareOptions = function parser___prepare_Options(opt) { }; generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComment() { - var out = "\n/* parser generated by jison ".concat(version$2, " */\n\n/*\n * Returns a Parser object of the following structure:\n *\n * Parser: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" `yy` passed around to\n * the rule actions, etc. is a derivative/copy of this one,\n * not a direct reference!\n * }\n *\n * Parser.prototype: {\n * yy: {},\n * EOF: 1,\n * TERROR: 2,\n *\n * trace: function(errorMessage, ...),\n *\n * JisonParserError: function(msg, hash),\n *\n * quoteName: function(name),\n * Helper function which can be overridden by user code later on: put suitable\n * quotes around literal IDs in a description string.\n *\n * originalQuoteName: function(name),\n * The basic quoteName handler provided by JISON.\n * `cleanupAfterParse()` will clean up and reset `quoteName()` to reference this function\n * at the end of the `parse()`.\n *\n * describeSymbol: function(symbol),\n * Return a more-or-less human-readable description of the given symbol, when\n * available, or the symbol itself, serving as its own 'description' for lack\n * of something better to serve up.\n *\n * Return NULL when the symbol is unknown to the parser.\n *\n * symbols_: {associative list: name ==> number},\n * terminals_: {associative list: number ==> name},\n * nonterminals: {associative list: rule-name ==> {associative list: number ==> rule-alt}},\n * terminal_descriptions_: (if there are any) {associative list: number ==> description},\n * productions_: [...],\n *\n * performAction: function parser__performAction(yytext, yyleng, yylineno, yyloc, yystate, yysp, yyvstack, yylstack, yystack, yysstack),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `yyval` internal object, which has members (`$` and `_$`)\n * to store/reference the rule value `$$` and location info `@$`.\n *\n * One important thing to note about `this` a.k.a. `yyval`: every *reduce* action gets\n * to see the same object via the `this` reference, i.e. if you wish to carry custom\n * data from one reduce action through to the next within a single parse run, then you\n * may get nasty and use `yyval` a.k.a. `this` for storing you own semi-permanent data.\n *\n * `this.yy` is a direct reference to the `yy` shared state object.\n *\n * `%parse-param`-specified additional `parse()` arguments have been added to this `yy`\n * object at `parse()` start and are therefore available to the action code via the\n * same named `yy.xxxx` attributes (where `xxxx` represents a identifier name from\n * the %parse-param` list.\n *\n * - `yytext` : reference to the lexer value which belongs to the last lexer token used\n * to match this rule. This is *not* the look-ahead token, but the last token\n * that's actually part of this rule.\n *\n * Formulated another way, `yytext` is the value of the token immediately preceeding\n * the current look-ahead token.\n * Caveats apply for rules which don't require look-ahead, such as epsilon rules.\n *\n * - `yyleng` : ditto as `yytext`, only now for the lexer.yyleng value.\n *\n * - `yylineno`: ditto as `yytext`, only now for the lexer.yylineno value.\n *\n * - `yyloc` : ditto as `yytext`, only now for the lexer.yylloc lexer token location info.\n *\n * WARNING: since jison 0.4.18-186 this entry may be NULL/UNDEFINED instead\n * of an empty object when no suitable location info can be provided.\n *\n * - `yystate` : the current parser state number, used internally for dispatching and\n * executing the action code chunk matching the rule currently being reduced.\n *\n * - `yysp` : the current state stack position (a.k.a. 'stack pointer')\n *\n * This one comes in handy when you are going to do advanced things to the parser\n * stacks, all of which are accessible from your action code (see the next entries below).\n *\n * Also note that you can access this and other stack index values using the new double-hash\n * syntax, i.e. `##$ === ##0 === yysp`, while `##1` is the stack index for all things\n * related to the first rule term, just like you have `$1`, `@1` and `#1`.\n * This is made available to write very advanced grammar action rules, e.g. when you want\n * to investigate the parse state stack in your action code, which would, for example,\n * be relevant when you wish to implement error diagnostics and reporting schemes similar\n * to the work described here:\n *\n * + Pottier, F., 2016. Reachability and error diagnosis in LR(1) automata.\n * In Journ\xE9es Francophones des Languages Applicatifs.\n *\n * + Jeffery, C.L., 2003. Generating LR syntax error messages from examples.\n * ACM Transactions on Programming Languages and Systems (TOPLAS), 25(5), pp.631\u2013640.\n *\n * - `yyrulelength`: the current rule's term count, i.e. the number of entries occupied on the stack.\n *\n * This one comes in handy when you are going to do advanced things to the parser\n * stacks, all of which are accessible from your action code (see the next entries below).\n *\n * - `yyvstack`: reference to the parser value stack. Also accessed via the `$1` etc.\n * constructs.\n *\n * - `yylstack`: reference to the parser token location stack. Also accessed via\n * the `@1` etc. constructs.\n *\n * WARNING: since jison 0.4.18-186 this array MAY contain slots which are\n * UNDEFINED rather than an empty (location) object, when the lexer/parser\n * action code did not provide a suitable location info object when such a\n * slot was filled!\n *\n * - `yystack` : reference to the parser token id stack. Also accessed via the\n * `#1` etc. constructs.\n *\n * Note: this is a bit of a **white lie** as we can statically decode any `#n` reference to\n * its numeric token id value, hence that code wouldn't need the `yystack` but *you* might\n * want access this array for your own purposes, such as error analysis as mentioned above!\n *\n * Note that this stack stores the current stack of *tokens*, that is the sequence of\n * already parsed=reduced *nonterminals* (tokens representing rules) and *terminals*\n * (lexer tokens *shifted* onto the stack until the rule they belong to is found and\n * *reduced*.\n *\n * - `yysstack`: reference to the parser state stack. This one carries the internal parser\n * *states* such as the one in `yystate`, which are used to represent\n * the parser state machine in the *parse table*. *Very* *internal* stuff,\n * what can I say? If you access this one, you're clearly doing wicked things\n *\n * - `...` : the extra arguments you specified in the `%parse-param` statement in your\n * grammar definition file.\n *\n * table: [...],\n * State transition table\n * ----------------------\n *\n * index levels are:\n * - `state` --> hash table\n * - `symbol` --> action (number or array)\n *\n * If the `action` is an array, these are the elements' meaning:\n * - index [0]: 1 = shift, 2 = reduce, 3 = accept\n * - index [1]: GOTO `state`\n *\n * If the `action` is a number, it is the GOTO `state`\n *\n * defaultActions: {...},\n *\n * parseError: function(str, hash, ExceptionClass),\n * yyError: function(str, ...),\n * yyRecovering: function(),\n * yyErrOk: function(),\n * yyClearIn: function(),\n *\n * constructParseErrorInfo: function(error_message, exception_object, expected_token_set, is_recoverable),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.\n * See it's use in this parser kernel in many places; example usage:\n *\n * var infoObj = parser.constructParseErrorInfo('fail!', null,\n * parser.collect_expected_token_set(state), true);\n * var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError);\n *\n * originalParseError: function(str, hash, ExceptionClass),\n * The basic `parseError` handler provided by JISON.\n * `cleanupAfterParse()` will clean up and reset `parseError()` to reference this function\n * at the end of the `parse()`.\n *\n * options: { ... parser %options ... },\n *\n * parse: function(input[, args...]),\n * Parse the given `input` and return the parsed value (or `true` when none was provided by\n * the root action, in which case the parser is acting as a *matcher*).\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of this grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Parser's additional `args...` parameters (via `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * The lexer MAY add its own set of additional parameters (via the `%parse-param` line in\n * the lexer section of the grammar spec): these will be inserted in the `yy` shared state\n * object and any collision with those will be reported by the lexer via a thrown exception.\n *\n * cleanupAfterParse: function(resultValue, invoke_post_methods, do_not_nuke_errorinfos),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * This helper API is invoked at the end of the `parse()` call, unless an exception was thrown\n * and `%options no-try-catch` has been defined for this grammar: in that case this helper MAY\n * be invoked by calling user code to ensure the `post_parse` callbacks are invoked and\n * the internal parser gets properly garbage collected under these particular circumstances.\n *\n * yyMergeLocationInfo: function(first_index, last_index, first_yylloc, last_yylloc, dont_look_back),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * This helper API can be invoked to calculate a spanning `yylloc` location info object.\n *\n * Note: %epsilon rules MAY specify no `first_index` and `first_yylloc`, in which case\n * this function will attempt to obtain a suitable location marker by inspecting the location stack\n * backwards.\n *\n * For more info see the documentation comment further below, immediately above this function's\n * implementation.\n *\n * lexer: {\n * yy: {...}, A reference to the so-called \"shared state\" `yy` once\n * received via a call to the `.setInput(input, yy)` lexer API.\n * EOF: 1,\n * ERROR: 2,\n * JisonLexerError: function(msg, hash),\n * parseError: function(str, hash, ExceptionClass),\n * setInput: function(input, [yy]),\n * input: function(),\n * unput: function(str),\n * more: function(),\n * reject: function(),\n * less: function(n),\n * pastInput: function(n),\n * upcomingInput: function(n),\n * showPosition: function(),\n * test_match: function(regex_match_array, rule_index, ...),\n * next: function(...),\n * lex: function(...),\n * begin: function(condition),\n * pushState: function(condition),\n * popState: function(),\n * topState: function(),\n * _currentRules: function(),\n * stateStackSize: function(),\n * cleanupAfterLex: function()\n *\n * options: { ... lexer %options ... },\n *\n * performAction: function(yy, yy_, $avoiding_name_collisions, YY_START, ...),\n * rules: [...],\n * conditions: {associative list: name ==> set},\n * }\n * }\n *\n *\n * token location info (@$, _$, etc.): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a 'hash' object with these members for lexer and\n * parser errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * }\n *\n * parser (grammar) errors will also provide these additional members:\n *\n * {\n * expected: (array describing the set of expected tokens;\n * may be UNDEFINED when we cannot easily produce such a set)\n * state: (integer (or array when the table includes grammar collisions);\n * represents the current internal state of the parser kernel.\n * can, for example, be used to pass to the `collect_expected_token_set()`\n * API to obtain the expected token set)\n * action: (integer; represents the current internal action which will be executed)\n * new_state: (integer; represents the next/planned internal state, once the current\n * action has executed)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * state_stack: (array: the current parser LALR/LR internal state stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * value_stack: (array: the current parser LALR/LR internal `$$` value stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * location_stack: (array: the current parser LALR/LR internal location stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * yy: (object: the current parser internal \"shared state\" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * parser: (reference to the current parser instance)\n * }\n *\n * while `this` will reference the current parser instance.\n *\n * When `parseError` is invoked by the lexer, `this` will still reference the related *parser*\n * instance, while these additional `hash` fields will also be provided:\n *\n * {\n * lexer: (reference to the current lexer instance which reported the error)\n * }\n *\n * When `parseError` is invoked by the parser due to a **JavaScript exception** being fired\n * from either the parser or lexer, `this` will still reference the related *parser*\n * instance, while these additional `hash` fields will also be provided:\n *\n * {\n * exception: (reference to the exception thrown)\n * }\n *\n * Please do note that in the latter situation, the `expected` field will be omitted as\n * this type of failure is assumed not to be due to *parse errors* but rather due to user\n * action code in either parser or lexer failing unexpectedly.\n *\n * ---\n *\n * You can specify parser options by setting / modifying the `.yy` object of your Parser instance.\n * These options are available:\n *\n * ### options which are global for all parser instances\n *\n * Parser.pre_parse: function(yy)\n * optional: you can specify a pre_parse() function in the chunk following\n * the grammar, i.e. after the last `%%`.\n * Parser.post_parse: function(yy, retval, parseInfo) { return retval; }\n * optional: you can specify a post_parse() function in the chunk following\n * the grammar, i.e. after the last `%%`. When it does not return any value,\n * the parser will return the original `retval`.\n *\n * ### options which can be set up per parser instance\n *\n * yy: {\n * pre_parse: function(yy)\n * optional: is invoked before the parse cycle starts (and before the first\n * invocation of `lex()`) but immediately after the invocation of\n * `parser.pre_parse()`).\n * post_parse: function(yy, retval, parseInfo) { return retval; }\n * optional: is invoked when the parse terminates due to success ('accept')\n * or failure (even when exceptions are thrown).\n * `retval` contains the return value to be produced by `Parser.parse()`;\n * this function can override the return value by returning another.\n * When it does not return any value, the parser will return the original\n * `retval`.\n * This function is invoked immediately before `parser.post_parse()`.\n *\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * quoteName: function(name),\n * optional: overrides the default `quoteName` function.\n * }\n *\n * parser.lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean (\u214F \uC13C \u214A \u2056 \u2058 \u2059 \u205A \u205B \u205C \u205D \u205E \u2020 \u2021 \n a\u2BC8b\n \u2200 \u2201 \u2202 \u2203 \u2204 \u2205 \u2206 \u2207 \u2208 \u2209 \u220A \u220B \u220C \u220D \u220E \u220F\nU+221x \u2210 \u2211 \u2212 \u2213 \u2214 \u2215 \u2216 \u2217 \u2218 \u2219 \u221A \u221B \u221C \u221D \u221E \u221F\nU+222x \u2220 \u2221 \u2222 \u2223 \u2224 \u2225 \u2226 \u2227 \u2228 \u2229 \u222A \u222B \u222C \u222D \u222E \u222F\nU+223x \u2230 \u2231 \u2232 \u2233 \u2234 \u2235 \u2236 \u2237 \u2238 \u2239 \u223A \u223B \u223C \u223D \u223E \u223F\nU+224x \u2240 \u2241 \u2242 \u2243 \u2244 \u2245 \u2246 \u2247 \u2248 \u2249 \u224A \u224B \u224C \u224D \u224E \u224F\nU+225x \u2250 \u2251 \u2252 \u2253 \u2254 \u2255 \u2256 \u2257 \u2258 \u2259 \u225A \u225B \u225C \u225D \u225E \u225F\nU+226x \u2260 \u2261 \u2262 \u2263 \u2264 \u2265 \u2266 \u2267 \u2268 \u2269 \u226A \u226B \u226C \u226D \u226E \u226F\nU+227x \u2270 \u2271 \u2272 \u2273 \u2274 \u2275 \u2276 \u2277 \u2278 \u2279 \u227A \u227B \u227C \u227D \u227E \u227F\nU+228x \u2280 \u2281 \u2282 \u2283 \u2284 \u2285 \u2286 \u2287 \u2288 \u2289 \u228A \u228B \u228C \u228D \u228E \u228F\nU+229x \u2290 \u2291 \u2292 \u2293 \u2294 \u2295 \u2296 \u2297 \u2298 \u2299 \u229A \u229B \u229C \u229D \u229E \u229F\nU+22Ax \u22A0 \u22A1 \u22A2 \u22A3 \u22A4 \u22A5 \u22A6 \u22A7 \u22A8 \u22A9 \u22AA \u22AB \u22AC \u22AD \u22AE \u22AF\nU+22Bx \u22B0 \u22B1 \u22B2 \u22B3 \u22B4 \u22B5 \u22B6 \u22B7 \u22B8 \u22B9 \u22BA \u22BB \u22BC \u22BD \u22BE \u22BF\nU+22Cx \u22C0 \u22C1 \u22C2 \u22C3 \u22C4 \u22C5 \u22C6 \u22C7 \u22C8 \u22C9 \u22CA \u22CB \u22CC \u22CD \u22CE \u22CF\nU+22Dx \u22D0 \u22D1 \u22D2 \u22D3 \u22D4 \u22D5 \u22D6 \u22D7 \u22D8 \u22D9 \u22DA \u22DB \u22DC \u22DD \u22DE \u22DF\nU+22Ex \u22E0 \u22E1 \u22E2 \u22E3 \u22E4 \u22E5 \u22E6 \u22E7 \u22E8 \u22E9 \u22EA \u22EB \u22EC \u22ED \u22EE \u22EF\nU+22Fx \u22F0 \u22F1 \u22F2 \u22F3 \u22F4 \u22F5 \u22F6 \u22F7 \u22F8 \u22F9 \u22FA \u22FB \u22FC \u22FD \u22FE \u22FF)\nU+230x \u2300 \u2301 \u2302 \u2303 \u2304 \u2305 \u2306 \u2307 \u2308 \u2309 \u230A \u230B \u230C \u230D \u230E \u230F\nU+231x \u2310 \u2311 \u2312 \u2313 \u2314 \u2315 \u2316 \u2317 \u2318 \u2319 \u231A \u231B \u231C \u231D \u231E \u231F\nU+232x \u2320 \u2321 \u2322 \u2323 \u2324 \u2325 \u2326 \u2327 \u2328 \u2329 \u232A \u232B \u232C \u232D \u232E \u232F\nU+233x \u2330 \u2331 \u2332 \u2333 \u2334 \u2335 \u2336 \u2337 \u2338 \u2339 \u233A \u233B \u233C \u233D \u233E \u233F\nU+234x \u2340 \u2341 \u2342 \u2343 \u2344 \u2345 \u2346 \u2347 \u2348 \u2349 \u234A \u234B \u234C \u234D \u234E \u234F\nU+235x \u2350 \u2351 \u2352 \u2353 \u2354 \u2355 \u2356 \u2357 \u2358 \u2359 \u235A \u235B \u235C \u235D \u235E \u235F\nU+236x \u2360 \u2361 \u2362 \u2363 \u2364 \u2365 \u2366 \u2367 \u2368 \u2369 \u236A \u236B \u236C \u236D \u236E \u236F\nU+237x \u2370 \u2371 \u2372 \u2373 \u2374 \u2375 \u2376 \u2377 \u2378 \u2379 \u237A \u237B \u237C \u237D \u237E \u237F\nU+238x \u2380 \u2381 \u2382 \u2383 \u2384 \u2385 \u2386 \u2387 \u2388 \u2389 \u238A \u238B \u238C \u238D \u238E \u238F\nU+239x \u2390 \u2391 \u2392 \u2393 \u2394 \u2395 \u2396 \u2397 \u2398 \u2399 \u239A \u239B \u239C \u239D \u239E \u239F\nU+23Ax \u23A0 \u23A1 \u23A2 \u23A3 \u23A4 \u23A5 \u23A6 \u23A7 \u23A8 \u23A9 \u23AA \u23AB \u23AC \u23AD \u23AE \u23AF\nU+23Bx \u23B0 \u23B1 \u23B2 \u23B3 \u23B4 \u23B5 \u23B6 \u23B7 \u23B8 \u23B9 \u23BA \u23BB \u23BC \u23BD \u23BE \u23BF\nU+23Cx \u23C0 \u23C1 \u23C2 \u23C3 \u23C4 \u23C5 \u23C6 \u23C7 \u23C8 \u23C9 \u23CA \u23CB \u23CC \u23CD \u23CE \u23CF\nU+23Dx \u23D0 \u23D1 \u23D2 \u23D3 \u23D4 \u23D5 \u23D6 \u23D7 \u23D8 \u23D9 \u23DA \u23DB \u23DC \u23DD \u23DE \u23DF\nU+23Ex \u23E0 \u23E1 \u23E2 \u23E3 \u23E4 \u23E5 \u23E6 \u23E7 \u23E8 \u23E9 \u23EA \u23EB \u23EC \u23ED \u23EE \u23EF\nU+23Fx \u23F0 \u23F1 \u23F2 \u23F3 \u23F4 \u23F5 \u23F6 \u23F7 \u23F8 \u23F9 \u23FA \u23FB \u23FC \u23FD \u23FE \u23FF\n\nU+260x \u2600 \u2601 \u2602 \u2603 \u2604 \u2605 \u2606 \u2607 \u2608 \u2609 \u260A \u260B \u260C \u260D \u260E \u260F\nU+261x \u2610 \u2611 \u2612 \u2613 \u2614 \u2615 \u2616 \u2617 \u2618 \u2619 \u261A \u261B \u261C \u261D \u261E \u261F\nU+262x \u2620 \u2621 \u2622 \u2623 \u2624 \u2625 \u2626 \u2627 \u2628 \u2629 \u262A \u262B \u262C \u262D \u262E \u262F\nU+263x \u2630 \u2631 \u2632 \u2633 \u2634 \u2635 \u2636 \u2637 \u2638 \u2639 \u263A \u263B \u263C \u263D \u263E \u263F\nU+264x \u2640 \u2641 \u2642 \u2643 \u2644 \u2645 \u2646 \u2647 \u2648 \u2649 \u264A \u264B \u264C \u264D \u264E \u264F\nU+265x \u2650 \u2651 \u2652 \u2653 \u2654 \u2655 \u2656 \u2657 \u2658 \u2659 \u265A \u265B \u265C \u265D \u265E \u265F\nU+266x \u2660 \u2661 \u2662 \u2663 \u2664 \u2665 \u2666 \u2667 \u2668 \u2669 \u266A \u266B \u266C \u266D \u266E \u266F\nU+267x \u2670 \u2671 \u2672 \u2673 \u2674 \u2675 \u2676 \u2677 \u2678 \u2679 \u267A \u267B \u267C \u267D \u267E \u267F\nU+268x \u2680 \u2681 \u2682 \u2683 \u2684 \u2685 \u2686 \u2687 \u2688 \u2689 \u268A \u268B \u268C \u268D \u268E \u268F\nU+269x \u2690 \u2691 \u2692 \u2693 \u2694 \u2695 \u2696 \u2697 \u2698 \u2699 \u269A \u269B \u269C \u269D \u269E \u269F\nU+26Ax \u26A0 \u26A1 \u26A2 \u26A3 \u26A4 \u26A5 \u26A6 \u26A7 \u26A8 \u26A9 \u26AA \u26AB \u26AC \u26AD \u26AE \u26AF\nU+26Bx \u26B0 \u26B1 \u26B2 \u26B3 \u26B4 \u26B5 \u26B6 \u26B7 \u26B8 \u26B9 \u26BA \u26BB \u26BC \u26BD \u26BE \u26BF\nU+26Cx \u26C0 \u26C1 \u26C2 \u26C3 \u26C4 \u26C5 \u26C6 \u26C7 \u26C8 \u26C9 \u26CA \u26CB \u26CC \u26CD \u26CE \u26CF\nU+26Dx \u26D0 \u26D1 \u26D2 \u26D3 \u26D4 \u26D5 \u26D6 \u26D7 \u26D8 \u26D9 \u26DA \u26DB \u26DC \u26DD \u26DE \u26DF\nU+26Ex \u26E0 \u26E1 \u26E2 \u26E3 \u26E4 \u26E5 \u26E6 \u26E7 \u26E8 \u26E9 \u26EA \u26EB \u26EC \u26ED \u26EE \u26EF\nU+26Fx \u26F0 \u26F1 \u26F2 \u26F3 \u26F4 \u26F5 \u26F6 \u26F7 \u26F8 \u26F9 \u26FA \u26FB \u26FC \u26FD \u26FE \u26FF\n\n \u2701 \u2702 \u2703 \u2704 \u2705 \u2706 \u2707 \u2708 \u2709 \u261B \u261E \u270C \u270D \u270E \u270F\n\u2710 \u2711 \u2712 \u2713 \u2714 \u2715 \u2716 \u2717 \u2718 \u2719 \u271A \u271B \u271C \u271D \u271E \u271F\n\u2720 \u2721 \u2722 \u2723 \u2724 \u2725 \u2726 \u2727 \u2605 \u2729 \u272A \u272B \u272C \u272D \u272E \u272F\n\u2730 \u2731 \u2732 \u2733 \u2734 \u2735 \u2736 \u2737 \u2738 \u2739 \u273A \u273B \u273C \u273D \u273E \u273F\n\u2740 \u2741 \u2742 \u2743 \u2744 \u2745 \u2746 \u2747 \u2748 \u2749 \u274A \u274B \u25CF \u274D \u25A0 \u274F\n\u263A \u263B \u2665 \u2666 \u2663 \u2660 \u2022 \u25D8 \u25CB \u2750 \u2751 \u2752 \u25B2 \u25BC \u25C6 \u2756\n\u25D7 \u2758 \u2759 \u275A \u275B \u275C \u275D \u275E \n\nU+270x \u2700 \u2701 \u2702 \u2703 \u2704 \u2705 \u2706 \u2707 \u2708 \u2709 \u270A \u270B \u270C \u270D \u270E \u270F\nU+271x \u2710 \u2711 \u2712 \u2713 \u2714 \u2715 \u2716 \u2717 \u2718 \u2719 \u271A \u271B \u271C \u271D \u271E \u271F\nU+272x \u2720 \u2721 \u2722 \u2723 a\u2724b a\u2725b a\u2726b a\u2727b \u2728 \u2729 \u272A \u272B \u272C \u272D \u272E \u272F\nU+273x \u2730 \u2731 \u2732 \u2733 \u2734 \u2735 \u2736 \u2737 \u2738 \u2739 \u273A \u273B \u273C \u273D \u273E \u273F\nU+274x \u2740 \u2741 \u2742 \u2743 \u2744 \u2745 \u2746 \u2747 \u2748 \u2749 \u274A \u274B \u274C \u274D \u274E \u274F\nU+275x \u2750 \u2751 \u2752 \u2753 \u2754 \u2755 \u2756 \u2757 \u2758 \u2759 \u275A \u275B \u275C \u275D \u275E \u275F\nU+276x \u2760 \u2761 \u2762 \u2763 \u2764 \u2765 \u2766 \u2767 \u2768 \u2769 \u276A \u276B \u276C \u276D \u276E a\u276Fb\nU+277x \u2770 \u2771 \u2772 \u2773 \u2774 \u2775 \u2776 \u2777 \u2778 \u2779 \u277A \u277B \u277C \u277D \u277E \u277F\nU+278x \u2780 \u2781 \u2782 \u2783 \u2784 \u2785 \u2786 \u2787 \u2788 \u2789 \u278A \u278B \u278C \u278D \u278E \u278F\nU+279x \u2790 \u2791 \u2792 \u2793 \u2794 \u2795 \u2796 \u2797 \u2798 \u2799 \u279A \u279B \u279C \u279D \u279E \u279F\nU+27Ax \u27A0 \u27A1 \u27A2 \u27A3 \u27A4 \u27A5 \u27A6 \u27A7 a\u27A8b \u27A9 \u27AA \u27AB \u27AC \u27AD \u27AE \u27AF\nU+27Bx \u27B0 a\u27B1b \u27B2 \u27B3 \u27B4 \u27B5 \u27B6 \u27B7 \u27B8 \u27B9 \u27BA \u27BB \u27BC \u27BD \u27BE \u27BF\n\nU+2580 \u2580 Upper half block\nU+2581 \u2581 Lower one eighth block\nU+2582 \u2582 Lower one quarter block\nU+2583 \u2583 Lower three eighths block\nU+2584 \u2584 Lower half block\nU+2585 \u2585 Lower five eighths block\nU+2586 \u2586 Lower three quarters block\nU+2587 \u2587 Lower seven eighths block\nU+2588 \u2588 Full block\nU+2589 \u2589 Left seven eighths block\nU+258A \u258A Left three quarters block\nU+258B \u258B Left five eighths block\nU+258C \u258C Left half block\nU+258D \u258D Left three eighths block\nU+258E \u258E Left one quarter block\nU+258F \u258F Left one eighth block\nU+2590 \u2590 Right half block\nU+2591 \u2591 Light shade\nU+2592 \u2592 Medium shade\nU+2593 \u2593 Dark shade\nU+2594 \u2594 Upper one eighth block\nU+2595 \u2595 Right one eighth block\nU+2596 \u2596 Quadrant lower left\nU+2597 \u2597 Quadrant lower right\nU+2598 \u2598 Quadrant upper left\nU+2599 \u2599 Quadrant upper left and lower left and lower right\nU+259A \u259A Quadrant upper left and lower right\nU+259B \u259B Quadrant upper left and upper right and lower left\nU+259C \u259C Quadrant upper left and upper right and lower right\nU+259D \u259D Quadrant upper right\nU+259E \u259E Quadrant upper right and lower left\nU+259F \u259F Quadrant upper right and lower left and lower right\nGeometric Shapes\nMain articles: Geometric Shapes (Unicode block) and Geometric Shapes Extended (Unicode block)\n[hide]Code Glyph Description\nU+25A0 \u25A0 Black square\nU+25A1 \u25A1 White square\nU+25A2 \u25A2 White square with rounded corners\nU+25A3 \u25A3 White square containing small black square\nU+25A4 \u25A4 Square with horizontal fill\nU+25A5 \u25A5 Square with vertical fill\nU+25A6 \u25A6 Square with orthogonal crosshatch fill\nU+25A7 \u25A7 Square with upper left to lower right fill\nU+25A8 \u25A8 Square with upper right to lower left fill\nU+25A9 \u25A9 Square with diagonal crosshatch fill\nU+25AA \u25AA Black small square\nU+25AB \u25AB White small square\nU+25AC \u25AC Black rectangle\nU+25AD \u25AD White rectangle\nU+25AE \u25AE Black vertical rectangle\nU+25AF \u25AF White vertical rectangle\nU+25B0 \u25B0 Black parallelogram\nU+25B1 \u25B1 White parallelogram\nU+25B2 \u25B2 Black up-pointing triangle\nU+25B3 \u25B3 White up-pointing triangle\nU+25B4 \u25B4 Black up-pointing small triangle\nU+25B5 \u25B5 White up-pointing small triangle\nU+25B6 \u25B6 Black right-pointing triangle\nU+25B7 \u25B7 White right-pointing triangle\nU+25B8 \u25B8 Black right-pointing small triangle\nU+25B9 \u25B9 White right-pointing small triangle\nU+25BA \u25BA Black right-pointing pointer\nU+25BB \u25BB White right-pointing pointer\nU+25BC \u25BC Black down-pointing triangle\nU+25BD \u25BD White down-pointing triangle\nU+25BE \u25BE Black down-pointing small triangle\nU+25BF \u25BF White down-pointing small triangle\nU+25C0 \u25C0 Black left-pointing triangle\nU+25C1 \u25C1 White left-pointing triangle\nU+25C2 \u25C2 Black left-pointing small triangle\nU+25C3 \u25C3 White left-pointing small triangle\nU+25C4 \u25C4 Black left-pointing pointer\nU+25C5 \u25C5 White left-pointing pointer\nU+25C6 \u25C6 Black diamond\nU+25C7 \u25C7 White diamond\nU+25C8 \u25C8 White diamond containing small black diamond\nU+25C9 \u25C9 Fisheye\nU+25CA \u25CA Lozenge\nU+25CB \u25CB White circle\nU+25CC \u25CC Dotted circle\nU+25CD \u25CD Circle with vertical fill\nU+25CE \u25CE Bullseye\nU+25CF \u25CF Black circle\nU+25D0 \u25D0 Circle with left half black\nU+25D1 \u25D1 Circle with right half black\nU+25D2 \u25D2 Circle with lower half black\nU+25D3 \u25D3 Circle with upper half black\nU+25D4 \u25D4 Circle with upper right quadrant black\nU+25D5 \u25D5 Circle with all but upper left quadrant black\nU+25D6 \u25D6 Left half circle black\nU+25D7 \u25D7 Right half black circle\nU+25D8 \u25D8 Inverse bullet\nU+25D9 \u25D9 Inverse white circle\nU+25DA \u25DA Upper half inverse white circle\nU+25DB \u25DB Lower half inverse white circle\nU+25DC \u25DC Upper left quadrant circular arc\nU+25DD \u25DD Upper right quadrant circular arc\nU+25DE \u25DE Lower right quadrant circular arc\nU+25DF \u25DF Lower left quadrant circular arc\nU+25E0 \u25E0 Upper half circle\nU+25E1 \u25E1 Lower half circle\nU+25E2 \u25E2 Black lower right triangle\nU+25E3 \u25E3 Black lower left triangle\nU+25E4 \u25E4 Black upper left triangle\nU+25E5 \u25E5 Black upper right triangle\nU+25E6 \u25E6 White bullet\nU+25E7 \u25E7 Square with left half black\nU+25E8 \u25E8 Square with right half black\nU+25E9 \u25E9 Square with upper left diagonal half black\nU+25EA \u25EA Square with lower right diagonal half black\nU+25EB \u25EB White square with vertical bisecting line\nU+25EC \u25EC White up-pointing triangle with dot\nU+25ED \u25ED Up-pointing triangle with left half black\nU+25EE \u25EE Up-pointing triangle with right half black\nU+25EF \u25EF Large circle\nU+25F0 \u25F0 White square with upper left quadrant\nU+25F1 \u25F1 White square with lower left quadrant\nU+25F2 \u25F2 White square with lower right quadrant\nU+25F3 \u25F3 White square with upper right quadrant\nU+25F4 \u25F4 White circle with upper left quadrant\nU+25F5 \u25F5 White circle with lower left quadrant\nU+25F6 \u25F6 White circle with lower right quadrant\nU+25F7 \u25F7 White circle with upper right quadrant\nU+25F8 \u25F8 Upper left triangle\nU+25F9 \u25F9 Upper right triangle\nU+25FA \u25FA Lower-left triangle\nU+25FB \u25FB White medium square\nU+25FC \u25FC Black medium square\nU+25FD \u25FD White medium small square\nU+25FE \u25FE Black medium small square\nU+25FF \u25FF Lower right triangle\n\n\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are \"extended regex format\" requiring the\n * `XRegExp` library. When this `%option` has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n"); + var out = "\n/* parser generated by jison ".concat(version$2, " */\n\n/*\n * Returns a Parser object of the following structure:\n *\n * Parser: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" `yy` passed around to\n * the rule actions, etc. is a derivative/copy of this one,\n * not a direct reference!\n * }\n *\n * Parser.prototype: {\n * yy: {},\n * EOF: 1,\n * TERROR: 2,\n *\n * trace: function(errorMessage, ...),\n *\n * JisonParserError: function(msg, hash),\n *\n * quoteName: function(name),\n * Helper function which can be overridden by user code later on: put suitable\n * quotes around literal IDs in a description string.\n *\n * originalQuoteName: function(name),\n * The basic quoteName handler provided by JISON.\n * `cleanupAfterParse()` will clean up and reset `quoteName()` to reference this function\n * at the end of the `parse()`.\n *\n * describeSymbol: function(symbol),\n * Return a more-or-less human-readable description of the given symbol, when\n * available, or the symbol itself, serving as its own 'description' for lack\n * of something better to serve up.\n *\n * Return NULL when the symbol is unknown to the parser.\n *\n * symbols_: {associative list: name ==> number},\n * terminals_: {associative list: number ==> name},\n * nonterminals: {associative list: rule-name ==> {associative list: number ==> rule-alt}},\n * terminal_descriptions_: (if there are any) {associative list: number ==> description},\n * productions_: [...],\n *\n * performAction: function parser__performAction(yytext, yyleng, yylineno, yyloc, yystate, yysp, yyvstack, yylstack, yystack, yysstack),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `yyval` internal object, which has members (`$` and `_$`)\n * to store/reference the rule value `$$` and location info `@$`.\n *\n * One important thing to note about `this` a.k.a. `yyval`: every *reduce* action gets\n * to see the same object via the `this` reference, i.e. if you wish to carry custom\n * data from one reduce action through to the next within a single parse run, then you\n * may get nasty and use `yyval` a.k.a. `this` for storing you own semi-permanent data.\n *\n * `this.yy` is a direct reference to the `yy` shared state object.\n *\n * `%parse-param`-specified additional `parse()` arguments have been added to this `yy`\n * object at `parse()` start and are therefore available to the action code via the\n * same named `yy.xxxx` attributes (where `xxxx` represents a identifier name from\n * the %parse-param` list.\n *\n * - `yytext` : reference to the lexer value which belongs to the last lexer token used\n * to match this rule. This is *not* the look-ahead token, but the last token\n * that's actually part of this rule.\n *\n * Formulated another way, `yytext` is the value of the token immediately preceeding\n * the current look-ahead token.\n * Caveats apply for rules which don't require look-ahead, such as epsilon rules.\n *\n * - `yyleng` : ditto as `yytext`, only now for the lexer.yyleng value.\n *\n * - `yylineno`: ditto as `yytext`, only now for the lexer.yylineno value.\n *\n * - `yyloc` : ditto as `yytext`, only now for the lexer.yylloc lexer token location info.\n *\n * WARNING: since jison 0.4.18-186 this entry may be NULL/UNDEFINED instead\n * of an empty object when no suitable location info can be provided.\n *\n * - `yystate` : the current parser state number, used internally for dispatching and\n * executing the action code chunk matching the rule currently being reduced.\n *\n * - `yysp` : the current state stack position (a.k.a. 'stack pointer')\n *\n * This one comes in handy when you are going to do advanced things to the parser\n * stacks, all of which are accessible from your action code (see the next entries below).\n *\n * Also note that you can access this and other stack index values using the new double-hash\n * syntax, i.e. `##$ === ##0 === yysp`, while `##1` is the stack index for all things\n * related to the first rule term, just like you have `$1`, `@1` and `#1`.\n * This is made available to write very advanced grammar action rules, e.g. when you want\n * to investigate the parse state stack in your action code, which would, for example,\n * be relevant when you wish to implement error diagnostics and reporting schemes similar\n * to the work described here:\n *\n * + Pottier, F., 2016. Reachability and error diagnosis in LR(1) automata.\n * In Journ\xE9es Francophones des Languages Applicatifs.\n *\n * + Jeffery, C.L., 2003. Generating LR syntax error messages from examples.\n * ACM Transactions on Programming Languages and Systems (TOPLAS), 25(5), pp.631\u2013640.\n *\n * - `yyrulelength`: the current rule's term count, i.e. the number of entries occupied on the stack.\n *\n * This one comes in handy when you are going to do advanced things to the parser\n * stacks, all of which are accessible from your action code (see the next entries below).\n *\n * - `yyvstack`: reference to the parser value stack. Also accessed via the `$1` etc.\n * constructs.\n *\n * - `yylstack`: reference to the parser token location stack. Also accessed via\n * the `@1` etc. constructs.\n *\n * WARNING: since jison 0.4.18-186 this array MAY contain slots which are\n * UNDEFINED rather than an empty (location) object, when the lexer/parser\n * action code did not provide a suitable location info object when such a\n * slot was filled!\n *\n * - `yystack` : reference to the parser token id stack. Also accessed via the\n * `#1` etc. constructs.\n *\n * Note: this is a bit of a **white lie** as we can statically decode any `#n` reference to\n * its numeric token id value, hence that code wouldn't need the `yystack` but *you* might\n * want access this array for your own purposes, such as error analysis as mentioned above!\n *\n * Note that this stack stores the current stack of *tokens*, that is the sequence of\n * already parsed=reduced *nonterminals* (tokens representing rules) and *terminals*\n * (lexer tokens *shifted* onto the stack until the rule they belong to is found and\n * *reduced*.\n *\n * - `yysstack`: reference to the parser state stack. This one carries the internal parser\n * *states* such as the one in `yystate`, which are used to represent\n * the parser state machine in the *parse table*. *Very* *internal* stuff,\n * what can I say? If you access this one, you're clearly doing wicked things\n *\n * - `...` : the extra arguments you specified in the `%parse-param` statement in your\n * grammar definition file.\n *\n * table: [...],\n * State transition table\n * ----------------------\n *\n * index levels are:\n * - `state` --> hash table\n * - `symbol` --> action (number or array)\n *\n * If the `action` is an array, these are the elements' meaning:\n * - index [0]: 1 = shift, 2 = reduce, 3 = accept\n * - index [1]: GOTO `state`\n *\n * If the `action` is a number, it is the GOTO `state`\n *\n * defaultActions: {...},\n *\n * parseError: function(str, hash, ExceptionClass),\n * yyError: function(str, ...),\n * yyRecovering: function(),\n * yyErrOk: function(),\n * yyClearIn: function(),\n *\n * constructParseErrorInfo: function(error_message, exception_object, expected_token_set, is_recoverable),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.\n * See it's use in this parser kernel in many places; example usage:\n *\n * let infoObj = parser.constructParseErrorInfo('fail!', null,\n * parser.collect_expected_token_set(state), true);\n * let retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError);\n *\n * originalParseError: function(str, hash, ExceptionClass),\n * The basic `parseError` handler provided by JISON.\n * `cleanupAfterParse()` will clean up and reset `parseError()` to reference this function\n * at the end of the `parse()`.\n *\n * options: { ... parser %options ... },\n *\n * parse: function(input[, args...]),\n * Parse the given `input` and return the parsed value (or `true` when none was provided by\n * the root action, in which case the parser is acting as a *matcher*).\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of this grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Parser's additional `args...` parameters (via `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * The lexer MAY add its own set of additional parameters (via the `%parse-param` line in\n * the lexer section of the grammar spec): these will be inserted in the `yy` shared state\n * object and any collision with those will be reported by the lexer via a thrown exception.\n *\n * cleanupAfterParse: function(resultValue, invoke_post_methods, do_not_nuke_errorinfos),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * This helper API is invoked at the end of the `parse()` call, unless an exception was thrown\n * and `%options no-try-catch` has been defined for this grammar: in that case this helper MAY\n * be invoked by calling user code to ensure the `post_parse` callbacks are invoked and\n * the internal parser gets properly garbage collected under these particular circumstances.\n *\n * yyMergeLocationInfo: function(first_index, last_index, first_yylloc, last_yylloc, dont_look_back),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * This helper API can be invoked to calculate a spanning `yylloc` location info object.\n *\n * Note: %epsilon rules MAY specify no `first_index` and `first_yylloc`, in which case\n * this function will attempt to obtain a suitable location marker by inspecting the location stack\n * backwards.\n *\n * For more info see the documentation comment further below, immediately above this function's\n * implementation.\n *\n * lexer: {\n * yy: {...}, A reference to the so-called \"shared state\" `yy` once\n * received via a call to the `.setInput(input, yy)` lexer API.\n * EOF: 1,\n * ERROR: 2,\n * JisonLexerError: function(msg, hash),\n * parseError: function(str, hash, ExceptionClass),\n * setInput: function(input, [yy]),\n * input: function(),\n * unput: function(str),\n * more: function(),\n * reject: function(),\n * less: function(n),\n * pastInput: function(n),\n * upcomingInput: function(n),\n * showPosition: function(),\n * test_match: function(regex_match_array, rule_index, ...),\n * next: function(...),\n * lex: function(...),\n * begin: function(condition),\n * pushState: function(condition),\n * popState: function(),\n * topState: function(),\n * _currentRules: function(),\n * stateStackSize: function(),\n * cleanupAfterLex: function()\n *\n * options: { ... lexer %options ... },\n *\n * performAction: function(yy, yy_, $avoiding_name_collisions, YY_START, ...),\n * rules: [...],\n * conditions: {associative list: name ==> set},\n * }\n * }\n *\n *\n * token location info (@$, _$, etc.): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a 'hash' object with these members for lexer and\n * parser errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * }\n *\n * parser (grammar) errors will also provide these additional members:\n *\n * {\n * expected: (array describing the set of expected tokens;\n * may be UNDEFINED when we cannot easily produce such a set)\n * state: (integer (or array when the table includes grammar collisions);\n * represents the current internal state of the parser kernel.\n * can, for example, be used to pass to the `collect_expected_token_set()`\n * API to obtain the expected token set)\n * action: (integer; represents the current internal action which will be executed)\n * new_state: (integer; represents the next/planned internal state, once the current\n * action has executed)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * state_stack: (array: the current parser LALR/LR internal state stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * value_stack: (array: the current parser LALR/LR internal `$$` value stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * location_stack: (array: the current parser LALR/LR internal location stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * yy: (object: the current parser internal \"shared state\" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * parser: (reference to the current parser instance)\n * }\n *\n * while `this` will reference the current parser instance.\n *\n * When `parseError` is invoked by the lexer, `this` will still reference the related *parser*\n * instance, while these additional `hash` fields will also be provided:\n *\n * {\n * lexer: (reference to the current lexer instance which reported the error)\n * }\n *\n * When `parseError` is invoked by the parser due to a **JavaScript exception** being fired\n * from either the parser or lexer, `this` will still reference the related *parser*\n * instance, while these additional `hash` fields will also be provided:\n *\n * {\n * exception: (reference to the exception thrown)\n * }\n *\n * Please do note that in the latter situation, the `expected` field will be omitted as\n * this type of failure is assumed not to be due to *parse errors* but rather due to user\n * action code in either parser or lexer failing unexpectedly.\n *\n * ---\n *\n * You can specify parser options by setting / modifying the `.yy` object of your Parser instance.\n * These options are available:\n *\n * ### options which are global for all parser instances\n *\n * Parser.pre_parse: function(yy)\n * optional: you can specify a pre_parse() function in the chunk following\n * the grammar, i.e. after the last `%%`.\n * Parser.post_parse: function(yy, retval, parseInfo) { return retval; }\n * optional: you can specify a post_parse() function in the chunk following\n * the grammar, i.e. after the last `%%`. When it does not return any value,\n * the parser will return the original `retval`.\n *\n * ### options which can be set up per parser instance\n *\n * yy: {\n * pre_parse: function(yy)\n * optional: is invoked before the parse cycle starts (and before the first\n * invocation of `lex()`) but immediately after the invocation of\n * `parser.pre_parse()`).\n * post_parse: function(yy, retval, parseInfo) { return retval; }\n * optional: is invoked when the parse terminates due to success ('accept')\n * or failure (even when exceptions are thrown).\n * `retval` contains the return value to be produced by `Parser.parse()`;\n * this function can override the return value by returning another.\n * When it does not return any value, the parser will return the original\n * `retval`.\n * This function is invoked immediately before `parser.post_parse()`.\n *\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * quoteName: function(name),\n * optional: overrides the default `quoteName` function.\n * }\n *\n * parser.lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are \"extended regex format\" requiring the\n * `XRegExp` library. When this `%option` has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n"); return out; }; @@ -26359,7 +26675,7 @@ generatorMixin.generate = function parser_generate(opt) { generatorMixin.generateAMDModule = function generateAMDModule(opt) { opt = this.__prepareOptions(opt); var module = this.generateModule_(); - var out = [this.generateGenericHeaderComment(), '', 'define(function (require) {', module.initCode, module.commonCode, '', 'var parser = ' + module.moduleCode, module.modulePostlude]; + var out = [this.generateGenericHeaderComment(), '', 'define(function (require) {', module.initCode, module.commonCode, '', 'let parser = ' + module.moduleCode, module.modulePostlude]; if (this.lexer && this.lexer.generateModule) { var lexSrc = this.lexer.generateModule(); @@ -26378,7 +26694,7 @@ generatorMixin.generateAMDModule = function generateAMDModule(opt) { lrGeneratorMixin.generateESModule = function generateESModule(opt) { opt = this.__prepareOptions(opt); var module = this.generateModule_(); - var out = [this.generateGenericHeaderComment(), '', module.initCode, module.commonCode, '', 'var parser = ' + module.moduleCode, module.modulePostlude]; + var out = [this.generateGenericHeaderComment(), '', module.initCode, module.commonCode, '', 'let parser = ' + module.moduleCode, module.modulePostlude]; if (this.lexer && this.lexer.generateModule) { var lexSrc = this.lexer.generateModule(); @@ -26394,12 +26710,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(_templateObject156(), moduleImportsAsCode, moduleNameAsCode.trim())); + out.push(rmCommonWS$5(_templateObject157(), moduleImportsAsCode, moduleNameAsCode.trim())); exportMain = 'main: yyExecMain,'; - invokeMain = rmCommonWS$5(_templateObject157()); + invokeMain = rmCommonWS$5(_templateObject158()); } - out.push(rmCommonWS$5(_templateObject158(), invokeMain, exportMain)); + out.push(rmCommonWS$5(_templateObject159(), invokeMain, exportMain)); var src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; @@ -26413,10 +26729,10 @@ generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { if (!opt.noMain) { var moduleNameAsCode = String(opt.moduleMain || commonJsMain); var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); - main = rmCommonWS$5(_templateObject159(), moduleImportsAsCode, moduleNameAsCode.trim()); + main = rmCommonWS$5(_templateObject160(), moduleImportsAsCode, moduleNameAsCode.trim()); } - var out = this.generateModule(opt) + rmCommonWS$5(_templateObject160(), moduleName, moduleName, moduleName, moduleName, main); + var out = this.generateModule(opt) + rmCommonWS$5(_templateObject161(), moduleName, moduleName, moduleName, moduleName, main); opt.exportSourceCode.all = out; return out; }; @@ -26431,13 +26747,13 @@ generatorMixin.generateModule = function generateModule(opt) { var subModuleName = namespaces.shift(); if (subModuleName != null) { - var moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; + var _moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; if (namespaces.length > 0) { - return 'var ' + subModuleName + ';\n' + '(function (' + subModuleName + ') {\n' + _generateNamespace(namespaces, subModuleName, callback) + '\n})(' + subModuleName + (previousNamespace == null ? '' : ' = ' + moduleName) + ' || (' + moduleName + ' = {}));\n'; + return '(function (' + subModuleName + ') {\n' + _generateNamespace(namespaces, subModuleName, callback) + '\n})(' + subModuleName + (previousNamespace == null ? '' : ' = ' + _moduleName) + ' || (' + _moduleName + ' = {}));\n'; } - return callback(moduleName); + return callback(_moduleName); } return ''; @@ -26446,7 +26762,7 @@ generatorMixin.generateModule = function generateModule(opt) { var sourceCodeDef = self.generateModuleExpr(); out += "\n ".concat(sourceCodeDef.init, "\n "); out += _generateNamespace(moduleName.split('.'), null, function _generateNamespace_cb(moduleName) { - var name = moduleName.match(/\./) ? moduleName : 'var ' + moduleName; + var name = moduleName.match(/\./) ? moduleName : 'let ' + moduleName; return "\n ".concat(name, " = ").concat(sourceCodeDef.src, "\n "); }); opt.exportSourceCode.all = out; @@ -26454,12 +26770,10 @@ generatorMixin.generateModule = function generateModule(opt) { }; generatorMixin.generateModuleExpr = function generateModuleExpr() { - var out; - var opt = this.__prepareOptions(); var module = this.generateModule_(); - out = ['(function () {', module.commonCode, '', 'var parser = ' + module.moduleCode, module.modulePostlude]; + var out = ['(function () {', module.commonCode, '', 'let parser = ' + module.moduleCode, module.modulePostlude]; if (this.lexer && this.lexer.generateModule) { var lexSrc = this.lexer.generateModule(); @@ -26508,7 +26822,7 @@ function removeUnusedKernelFeatures(parseFn, info) { // if (typeof lexer.yyleng === 'undefined') { // lexer.yyleng = 0; // } - // var yyleng; + // let yyleng; // ... parseFn = parseFn.replace(/, yyleng\b/g, '').replace(/^.*?\bvar yyleng\b.*?$/gm, '').replace(/\s+if\b.*?\.yyleng\b.*?\{[^}]+\}/g, '\n').replace(/^.*?\byyleng = .+$/gm, '').replace(/^.*?\byyleng\b.*?=.*?\byyleng\b.*?$/gm, ''); @@ -26519,7 +26833,7 @@ function removeUnusedKernelFeatures(parseFn, info) { // so we can kill the local var and its usage at least: actionFn = actionFn.replace(/, yylineno\b/g, ''); // remove: // - // var yylineno; + // let yylineno; // ... parseFn = parseFn.replace(/\bvar yylineno\b.*?$/gm, '').replace(/, yylineno\b/g, '').replace(/^.*?\byylineno\b.*?=.*?\byylineno\b.*?$/gm, ''); @@ -26554,7 +26868,7 @@ function removeUnusedKernelFeatures(parseFn, info) { if (!info.actionsUseLocationTracking) { actionFn = actionFn.replace(/\byyloc, (.*?), yylstack\b/g, '$1'); // remove: // - // var yyloc = lexer.yylloc; + // let yyloc = lexer.yylloc; // lstack[sp] = yyloc; // ... // lstack[sp] = copy_yylloc(lexer.yylloc); @@ -26579,11 +26893,11 @@ function removeUnusedKernelFeatures(parseFn, info) { // } // // and - // + // // if (sp >= 0 && typeof vstack[sp] !== 'undefined') { // retval = vstack[sp]; // } - // + // // but keep the yyval declaration as either location tracking MAY // still be employed by the grammar OR the grammar uses advanced // code which uses `yyval` as a run-time store which carries data @@ -26622,12 +26936,12 @@ function removeUnusedKernelFeatures(parseFn, info) { if (info.actionsAreAllDefault) { // remove // - // var yyval = { + // let yyval = { // $: true, // _$: undefined, // yy: sharedState_yy // }; - parseFn = parseFn.replace(/\s+var yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); + parseFn = parseFn.replace(/\s+let yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); } } @@ -26641,10 +26955,14 @@ function removeUnusedKernelFeatures(parseFn, info) { // option set or by invoking JISON with the debug flag `-t`. // remove: // - // var yydebug = false; + // let yydebug = false; // ... and delete yydebug function definition ... // ... // if (yydebug) yydebug(...); + // ... + // if (yydebug) { + // yydebug(...); + // } // // and // @@ -26652,9 +26970,9 @@ function removeUnusedKernelFeatures(parseFn, info) { // if (sharedState_yy.yydebug === false) { // yydebug = undefined; // } - parseFn = parseFn.replace(/\s+var yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') // strip multi-line `if (debug) yydebug(..., {...});` statements + parseFn = parseFn.replace(/\s+let yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') // strip multi-line `if (debug) { yydebug(..., {...}); }` statements // also strip simple yet possibly multi-line `if (debug) yydebug('...');` statements - .replace(/\n\s+if\s+\(yydebug\)\s+yydebug\([^]+?['}]\);[^\r\n]*?/g, '\n\n\n\n\n\n\n\n\n') // strip single-line `yydebug(...);` statements + .replace(/\n\s+if\s+\(yydebug\)\s+\{[\r\n]+\s+yydebug\([^]+?}\);[\s\r\n]+}\s*/g, '\n\n\n\n\n\n\n\n\n').replace(/\n\s+if\s+\(yydebug\)\s+yydebug\([^]+?['}]\);[^\r\n]*?/g, '\n\n\n\n\n\n\n\n\n') // strip single-line `yydebug(...);` statements .replace(/^.*?\byydebug\b[^;]+?\);[^\r\n]*?$/gm, '') // strip `if (sharedState_yy.yydebug) {...}` chunk .replace(/\n\s+\/\/\s*disable\s*debugging.*?[\r\n]+\s+if\s+\(sharedState_yy\.yydebug[^]+?\}/g, '\n\n\n\n'); } @@ -26730,8 +27048,8 @@ function removeUnusedKernelFeatures(parseFn, info) { * ... __reentrant_call_depth ... */ parseFn = parseFn.replace(/\s+try \{([\s\r\n]+this\.__reentrant_call_depth[\s\S]+?)\} catch \(ex\) \{[\s\S]+?\} finally \{([^]+?)\}\s+\/\/\s+\/finally/, function replace_noTryCatch(m, p1, p2) { - p1 = p1.replace(/^ /mg, ' '); - p2 = p2.replace(/^ /mg, ' '); + p1 = p1.replace(/^ {8}/mg, ' '); + p2 = p2.replace(/^ {8}/mg, ' '); return '\n' + p1 + '\n // ... AND FINALLY ...\n' + p2; }).replace(/^[^\n]+\b__reentrant_call_depth\b[^\n]+$/gm, '\n'); } @@ -26788,11 +27106,11 @@ function expandParseArguments(parseFn, self) { if (!arglist || arglist.length === 0) { parseFn = parseFn.replace(/, parseParams\b/g, ''); parseFn = parseFn.replace(/\bparseParams\b/g, ''); - parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers:\s+parseParamsAsMembers\b/g, ''); + parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers\b/g, ''); } else { parseFn = parseFn.replace(/, parseParams\b/g, ', ' + arglist.join(', ')); parseFn = parseFn.replace(/\bparseParams\b/g, arglist.join(', ')); - parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers:\s+parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { + parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { var s = ','; // determine longest name of the bunch (for formatting the generated code) var max_k_len = 0; @@ -26804,9 +27122,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 i = 0, len = arglist.length; i < len; i++) { - var k = arglist[i]; - s += '\n' + ws + k + ': ' + k + (i < len - 1 ? ',' + wsi2.substr(0, max_k_len - k.length - 1) : wsi2.substr(0, max_k_len - k.length)) + ' // parseParams::' + k; + 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; } return s; @@ -26843,11 +27161,11 @@ function addOrRemoveTokenStack(fn, wantTokenStack) { // // if (wantTokenStack) { // try { - // var ast = esprima.parse(parseFn); - // var stackAst = esprima.parse(String(tokenStackLex)).body[0]; + // let ast = esprima.parse(parseFn); + // let stackAst = esprima.parse(String(tokenStackLex)).body[0]; // stackAst.id.name = 'lex'; // - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); // // labeled[0].body = stackAst; // @@ -26857,7 +27175,7 @@ function addOrRemoveTokenStack(fn, wantTokenStack) { // } // } else { // // remove the line: - // // var tstack = []; // token stack + // // let tstack = []; // token stack // parseFn = parseFn.replace(/tstack = .*$/m, ''); // return parseFn; // } @@ -26867,11 +27185,11 @@ function addOrRemoveTokenStack(fn, wantTokenStack) { if (wantTokenStack) { // And rename the `tokenStackLex` function to become the new `lex`: return parseFn.replace(/\btokenStackLex\b/g, 'lex'); - } else { - // Also nuke the support declaration statement: - // var tstack = []; - return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); - } + } // Also nuke the support declaration statement: + // let tstack = []; + + + return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); } // returns parse function with/without error recovery code @@ -26879,8 +27197,8 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { var parseFn = fn; // We don't use the Esprima+Escodegen toolchain as those loose the code comments easily; // instead we just chop the code using labels as sentinels for our chopping-it-up regexes: // try { - // var ast = esprima.parse(parseFn); - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("' + + // let ast = esprima.parse(parseFn); + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("' + // (!hasErrorRecovery ? '_handle_error_with_recovery' : '_handle_error_no_recovery') + // '"))', ast); // Jison.print('labeled: ', labeled); @@ -26896,7 +27214,7 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { if (!hasErrorRecovery) { // Also nuke the support declaration statement: - // var recovering = 0; + // let recovering = 0; // and the recovery support statements: // if (recovering > 0) { // recovering--; @@ -26904,15 +27222,15 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // and these yydebug particles: // , recovering: recovering // ASSERT(recovering === 0); - parseFn = parseFn.replace(/^\s*var recovering.*$/gm, '').replace(/, recovering: recovering/g, '').replace(/^.*?recovering =.*$/gm, '').replace(/^\s+recovering[,]?\s*$/gm, '').replace(/[ \t]*if \(recovering[^\)]+\) \{[^\0]+?\}\n/g, '\n\n\n\n\n') // And nuke the preErrorSymbol code as it is unused when there's no error recovery + parseFn = parseFn.replace(/^\s*let recovering.*$/gm, '').replace(/, recovering: recovering/g, '').replace(/^.*?recovering =.*$/gm, '').replace(/^\s+recovering[,]?\s*$/gm, '').replace(/[ \t]*if \(recovering[^\)]+\) \{[^\0]+?\}\n/g, '\n\n\n\n\n') // And nuke the preErrorSymbol code as it is unused when there's no error recovery // if (!preErrorSymbol) { // ... keep this chunk ... // } else { // ... KILL this chunk ... // } - .replace(/\s+if[^a-z]+preErrorSymbol.*?\{\s*\/\/[^\n]+([\s\S]+?)\} else \{[\s\S]+?\}\n\s+\}\n/g, '\n$1\n\n\n\n').replace(/^\s+(?:var )?preErrorSymbol = .*$/gm, '').replace(/^.*?\bpreErrorSymbol =.*$/gm, '') // And nuke the support declaration statement: - // var lastEofErrorStateDepth = 0; - .replace(/^\s*var lastEofErrorStateDepth.*$/gm, ''); + .replace(/\s+if[^a-z]+preErrorSymbol.*?\{\s*\/\/[^\n]+([\s\S]+?)\} else \{[\s\S]+?\}\n\s+\}\n/g, '\n$1\n\n\n\n').replace(/^\s+(?:let )?preErrorSymbol = .*$/gm, '').replace(/^.*?\bpreErrorSymbol =.*$/gm, '') // And nuke the support declaration statement: + // let lastEofErrorStateDepth = 0; + .replace(/^\s*let lastEofErrorStateDepth.*$/gm, ''); } return parseFn; @@ -26934,8 +27252,6 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { exportDest.parseTable = this.table; exportDest.defaultParseActions = this.defaultActions; exportDest.parseProductions = this.productions_; - var exportSourceCode = this.options.exportSourceCode; - assert__default['default'](exportSourceCode); var tableCode; switch (this.options.compressTables | 0) { @@ -26970,10 +27286,9 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { var a = Object.keys(tbl); a.sort(); var nt = {}; - var k; for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); + var k = a[i]; // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number // and we do not want `$eof`/`EOF` to show up in the symbol tables of generated parsers // as we use `$end` for that one! @@ -26990,11 +27305,10 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { function produceTerminalTable(tbl) { var a = Object.keys(tbl); var nt = {}; - var k, v; for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; - v = tbl[k]; + var k = a[i]; + var v = tbl[k]; nt[v] = +k; // convert numeric key back to number type; all terminals have numeric keys } @@ -27137,11 +27451,10 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { reachable: production.reachable }; // Determine state for given production, if it's not a production that's listed as part of a state: - var chk, idx; var lst = prods.rules[nonterm]; - chk = rv.symbol + ' : ' + rv.handle; + var chk = rv.symbol + ' : ' + rv.handle; - for (idx in lst) { + for (var idx in lst) { idx = +idx; var p = lst[idx]; @@ -27160,8 +27473,8 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { if (base && base.rules) { var pr = base.rules[rv.base_symbol]; - for (idx in pr) { - var bprod = pr[idx]; + for (var _idx in pr) { + var bprod = pr[_idx]; if (bprod.symbol + ' : ' + bprod.handle === chk) { assert__default['default'](rv.base_state === -1); @@ -27243,9 +27556,8 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { } var nt = tbl; - var sbn; - for (sbn in nt) { + for (var sbn in nt) { var orig_symbol = get_orig_symbol(sbn); var item = nt[sbn]; var firsts = item.first; @@ -27268,12 +27580,12 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { } } - for (sbn in prods.first) { - prods.first[sbn] = get_orig_symbol_set(prods.first[sbn]); + for (var _sbn in prods.first) { + prods.first[_sbn] = get_orig_symbol_set(prods.first[_sbn]); } - for (sbn in prods.follows) { - prods.follows[sbn] = get_orig_symbol_set(prods.follows[sbn]); + for (var _sbn2 in prods.follows) { + prods.follows[_sbn2] = get_orig_symbol_set(prods.follows[_sbn2]); } if (this.newg) { @@ -27429,7 +27741,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { lrGeneratorMixin.generateErrorClass = function () { // --- START parser error class --- - var prelude = "\n// See also:\n// http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n// but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n// with userland code which might access the derived class in a 'classic' way.\nfunction JisonParserError(msg, hash) {\n \"use strict\";\n\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'JisonParserError'\n });\n\n if (msg == null) msg = '???';\n\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n var stacktrace;\n if (hash && hash.exception instanceof Error) {\n var ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty('captureStackTrace')) { // V8/Chrome engine\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(JisonParserError.prototype, Error.prototype);\n} else {\n JisonParserError.prototype = Object.create(Error.prototype);\n}\nJisonParserError.prototype.constructor = JisonParserError;\nJisonParserError.prototype.name = 'JisonParserError';\n"; // --- END parser error class --- + var prelude = "\n// See also:\n// http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n// but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n// with userland code which might access the derived class in a 'classic' way.\nfunction JisonParserError(msg, hash) {\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'JisonParserError'\n });\n\n if (msg == null) msg = '???';\n\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n let stacktrace;\n if (hash && hash.exception instanceof Error) {\n let ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty('captureStackTrace')) { // V8/Chrome engine\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(JisonParserError.prototype, Error.prototype);\n} else {\n JisonParserError.prototype = Object.create(Error.prototype);\n}\nJisonParserError.prototype.constructor = JisonParserError;\nJisonParserError.prototype.name = 'JisonParserError';\n"; // --- END parser error class --- return { commonCode: '', @@ -27456,7 +27768,7 @@ lrGeneratorMixin.generateTableCode0 = function (table, defaultActions, productio // e.g., x([1, 3, 4], [6, 7], { x: 1, y: 2 }) = { 1: [6, 7]; 3: [6, 7], 4: [6, 7], x: 1, y: 2 } -var compressor1ObjectCode = "\nfunction x(k, v, o) {\n o = o || {};\n for (var l = k.length; l--; ) {\n o[k[l]] = v;\n }\n return o;\n}\n"; // Generate code that represents the specified parser table +var compressor1ObjectCode = "\nfunction x(k, v, o) {\n o = o || {};\n for (let l = k.length; l--; ) {\n o[k[l]] = v;\n }\n return o;\n}\n"; // Generate code that represents the specified parser table lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productions) { var tableCode = JSON.stringify(table, null, 2); @@ -27469,21 +27781,18 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio tableCode = tableCode.replace(/\{[\s\r\n]*\d+:[^\}]+,[\s\r\n]*\d+:[^\}]+\}/g, function (object) { // Find the value that occurs with the highest number of keys - var value, - frequentValue, - key, - keys = {}, - keyCount, - maxKeyCount = 0, - keyValue, - keyValues = [], - keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; + var frequentValue; + var keys = {}; + var maxKeyCount = 0; + var keyValue; + var keyValues = []; + var keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; while (keyValue = keyValueMatcher.exec(object)) { // For each value, store the keys where that value occurs - key = keyValue[1]; - value = keyValue[2].trim(); - keyCount = 1; + var key = keyValue[1]; + var value = keyValue[2].trim(); + var keyCount = 1; if (!(value in keys)) { keys[value] = [key]; @@ -27501,10 +27810,10 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio if (maxKeyCount > 1) { // Collect all non-frequent values into a remainder object - for (value in keys) { - if (value !== frequentValue) { - for (var k = keys[value], i = 0, l = k.length; i < l; i++) { - keyValues.push(k[i] + ':' + value); + for (var _value5 in keys) { + if (_value5 !== frequentValue) { + for (var k = keys[_value5], i = 0, l = k.length; i < l; i++) { + keyValues.push(k[i] + ':' + _value5); } } } @@ -27553,7 +27862,7 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio } if (frequentLists.length > 0) { - prelude.push('var u = [\n ' + frequentLists.join(',\n ') + '\n];'); + prelude.push('let u = [\n ' + frequentLists.join(',\n ') + '\n];'); prelude.push(''); } // Return the variable initialization code and the table code @@ -27600,11 +27909,10 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); function reportColumnsForCompression(def_arr) { - var i, key, len; var report = []; - len = 0; + var len = 0; - for (key in def_arr) { + for (var key in def_arr) { len = Math.max(len, def_arr[key].length); } @@ -27618,48 +27926,52 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } var track_prev4delta = {}; - var c, delta, val, delta_val; var line = []; line.push('║'); - for (c in def_arr) { - key = clip(c, col_width); - delta = clip('∆', col_delta_width); - line.push(key); + for (var _c3 in def_arr) { + var _key10 = clip(_c3, col_width); + + var delta = clip('∆', col_delta_width); + line.push(_key10); line.push('┊'); line.push(delta); line.push('║'); - track_prev4delta[c] = 10000000; + track_prev4delta[_c3] = 10000000; } report.push(line.join('')); - for (i = 0; i < len; i++) { + for (var i = 0; i < len; i++) { line = []; line.push('║'); - for (c in def_arr) { - var tbl = def_arr[c]; + for (var _c4 in def_arr) { + var val = void 0, + delta_val = void 0; + var tbl = def_arr[_c4]; if (tbl.length > i) { val = tbl[i] || 0; - delta_val = val - track_prev4delta[c]; // negative deltas are jumps: don't treat those as delta but as absolute value, sign-flipped: + delta_val = val - track_prev4delta[_c4]; // 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[c] = val; + track_prev4delta[_c4] = val; } else { val = '.'; delta_val = '.'; } - key = clip(val, col_width); - delta = clip(delta_val, col_delta_width); - line.push(key); + var _key11 = clip(val, col_width); + + var _delta = clip(delta_val, col_delta_width); + + line.push(_key11); line.push('┊'); - line.push(delta); + line.push(_delta); line.push('║'); } @@ -27692,9 +28004,9 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } var def_arr = { - 'len': len_col, - 'pop': pop_col, - 'rule': rule_col + len: len_col, + pop: pop_col, + rule: rule_col }; return def_arr; } // table is hash of 1/2-len arrays: @@ -27717,8 +28029,8 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } var def_arr = { - 'idx': idx_col, - 'goto': goto_col + idx: idx_col, + goto: goto_col }; return def_arr; } @@ -27736,16 +28048,15 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio var mode_col = []; // column: symbol hash entry goto state value if array slot type: var goto_col = []; // // column: merged: state_col + goto_col: - // var next_col = []; + // let next_col = []; var row_count = table.length; for (var state = 0; state < row_count; state++) { var hashtable = table[state]; var count = 0; - var symbol; - for (symbol in hashtable) { + for (var symbol in hashtable) { symbol = +symbol; symbol_col.push(symbol); var slot = hashtable[symbol]; @@ -27779,12 +28090,12 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } var def_arr = { - 'len': len_col, - 'symbol': symbol_col, - 'type': type_col, - 'state': state_col, - 'mode': mode_col, - 'goto': goto_col //'next': next_col, + len: len_col, + symbol: symbol_col, + type: type_col, + state: state_col, + mode: mode_col, + goto: goto_col //'next': next_col, }; return def_arr; @@ -27794,11 +28105,11 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function generateColumn(name, col) { var rv = []; - var i, j, len, l; - for (i = 0, len = col.length; i < len; i++) { + for (var i = 0, len = col.length; i < len; i++) { // try basic run-length encoding first: var v = col[i]; + var j = void 0; for (j = i + 1; j < len; j++) { if (col[j] !== v) { @@ -27828,6 +28139,8 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio var upper_bound = i - 2; for (j = 0; j < upper_bound; j++) { + var l = void 0; + for (l = 0; col[j + l] === col[i + l]; l++) {// No need to check for: // if (j + l === i) break; // because we know how the c() helper function will regenerate @@ -27896,10 +28209,10 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio var tableDef = analyzeGotoTableForCompression(table); var defaultActionsDef = analyzeSetForCompression(defaultActions); var productionsDef = analyzeTableForCompression(productions); - var bp_code_container = "\n // helper: reconstruct the productions[] table\n function bp(s) {\n var rv = [];\n var p = s.pop;\n var r = s.rule;\n for (var i = 0, l = p.length; i < l; i++) {\n rv.push([\n p[i],\n r[i]\n ]);\n }\n return rv;\n }\n "; - var bda_code_container = "\n // helper: reconstruct the defaultActions[] table\n function bda(s) {\n var rv = {};\n var d = s.idx;\n var g = s.goto;\n for (var i = 0, l = d.length; i < l; i++) {\n var j = d[i];\n rv[j] = g[i];\n }\n return rv;\n }\n "; - var bt_code_container = "\n // helper: reconstruct the 'goto' table\n function bt(s) {\n var rv = [];\n var d = s.len;\n var y = s.symbol;\n var t = s.type;\n var a = s.state;\n var m = s.mode;\n var g = s.goto;\n for (var i = 0, l = d.length; i < l; i++) {\n var n = d[i];\n var q = {};\n for (var j = 0; j < n; j++) {\n var z = y.shift();\n switch (t.shift()) {\n case 2:\n q[z] = [\n m.shift(),\n g.shift()\n ];\n break;\n\n case 0:\n q[z] = a.shift();\n break;\n\n default:\n // type === 1: accept\n q[z] = [\n 3\n ];\n }\n }\n rv.push(q);\n }\n return rv;\n }\n "; - var c_s_u_code_container = "\n // helper: runlength encoding with increment step: code, length: step (default step = 0)\n // `this` references an array\n function s(c, l, a) {\n a = a || 0;\n for (var i = 0; i < l; i++) {\n this.push(c);\n c += a;\n }\n }\n\n // helper: duplicate sequence from *relative* offset and length.\n // `this` references an array\n function c(i, l) {\n i = this.length - i;\n for (l += i; i < l; i++) {\n this.push(this[i]);\n }\n }\n\n // helper: unpack an array using helpers and data, all passed in an array argument 'a'.\n function u(a) {\n var rv = [];\n for (var i = 0, l = a.length; i < l; i++) {\n var e = a[i];\n // Is this entry a helper function?\n if (typeof e === 'function') {\n i++;\n e.apply(rv, a[i]);\n } else {\n rv.push(e);\n }\n }\n return rv;\n }\n "; + var bp_code_container = "\n // helper: reconstruct the productions[] table\n function bp(s) {\n let rv = [];\n let p = s.pop;\n let r = s.rule;\n for (let i = 0, l = p.length; i < l; i++) {\n rv.push([\n p[i],\n r[i]\n ]);\n }\n return rv;\n }\n "; + var bda_code_container = "\n // helper: reconstruct the defaultActions[] table\n function bda(s) {\n let rv = {};\n let d = s.idx;\n let g = s.goto;\n for (let i = 0, l = d.length; i < l; i++) {\n let j = d[i];\n rv[j] = g[i];\n }\n return rv;\n }\n "; + var bt_code_container = "\n // helper: reconstruct the 'goto' table\n function bt(s) {\n let rv = [];\n let d = s.len;\n let y = s.symbol;\n let t = s.type;\n let a = s.state;\n let m = s.mode;\n let g = s.goto;\n for (let i = 0, l = d.length; i < l; i++) {\n let n = d[i];\n let q = {};\n for (let j = 0; j < n; j++) {\n let z = y.shift();\n switch (t.shift()) {\n case 2:\n q[z] = [\n m.shift(),\n g.shift()\n ];\n break;\n\n case 0:\n q[z] = a.shift();\n break;\n\n default:\n // type === 1: accept\n q[z] = [\n 3\n ];\n }\n }\n rv.push(q);\n }\n return rv;\n }\n "; + var c_s_u_code_container = "\n // helper: runlength encoding with increment step: code, length: step (default step = 0)\n // `this` references an array\n function s(c, l, a) {\n a = a || 0;\n for (let i = 0; i < l; i++) {\n this.push(c);\n c += a;\n }\n }\n\n // helper: duplicate sequence from *relative* offset and length.\n // `this` references an array\n function c(i, l) {\n i = this.length - i;\n for (l += i; i < l; i++) {\n this.push(this[i]);\n }\n }\n\n // helper: unpack an array using helpers and data, all passed in an array argument 'a'.\n function u(a) {\n let rv = [];\n for (let i = 0, l = a.length; i < l; i++) {\n let e = a[i];\n // Is this entry a helper function?\n if (typeof e === 'function') {\n i++;\n e.apply(rv, a[i]);\n } else {\n rv.push(e);\n }\n }\n return rv;\n }\n "; has_compressed_a_table = false; var tc = generateCompressedGotoTable(tableDef); var compressGotoTable = has_compressed_a_table; @@ -27927,13 +28240,13 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio productionsCode: productionsCode }; }; // --- START of commonJsMain chunk --- -// +// // default main method for generated commonjs modules -var commonJsMain = "\nfunction (args) {\n \"use strict\";\n\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 var source = fs.readFileSync(path.normalize(args[1]), 'utf8');\n var 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 var 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 = "\nvar fs = require('fs');\nvar path = require('path');\n"; // debug mixin for LR parser generators +var commonJsMainImports = "\nconst fs = require('fs');\nconst path = require('path');\n"; // debug mixin for LR parser generators function printAction(a, gen) { var s = a[0] === SHIFT ? 'shift token (then go to state ' + a[1] + ')' : a[0] === REDUCE ? 'reduce by rule: ' + gen.productions[a[1]] : a[0] === ACCEPT ? 'accept' : 'UNDEFINED ACTION: ' + a[0]; @@ -27979,8 +28292,8 @@ 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(_templateObject161(), sourceCodeDef.init, sourceCodeDef.src); - var p = code_exec$2(sourcecode, function generated_code_exec_wrapper_jison(sourcecode) { + var sourcecode = rmCommonWS$5(_templateObject162(), 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); var rv = eval(sourcecode); @@ -27988,7 +28301,7 @@ generatorMixin.createParser = function createParser() { }, mkStdOptions$1(this.options, { dumpSourceCodeOnFailure: this.DEBUG, throwErrorOnCompileFailure: true - }), "parser"); + }), 'parser'); assert__default['default'](_typeof(p) === 'object'); assert__default['default'](typeof p.parse === 'function'); assert__default['default'](typeof p.parser === 'undefined'); @@ -28055,7 +28368,7 @@ parser$4.trace = generator.trace; parser$4.warn = generator.warn; parser$4.error = generator.error; // --- START parser Error class chunk --- -var parseErrorSourceCode = "\nfunction parseError(str, hash, ExceptionClass) {\n \"use strict\";\n\n if (hash.recoverable) {\n if (typeof this.trace === 'function') {\n this.trace(str);\n }\n hash.destroy(); // destroy... well, *almost*!\n } else {\n if (typeof this.trace === 'function') {\n this.trace(str);\n }\n if (!ExceptionClass) {\n ExceptionClass = this.JisonParserError;\n }\n throw new ExceptionClass(str, hash);\n }\n}\n"; // --- END of parseErrorSourceCode chunk --- +var parseErrorSourceCode = "\nfunction parseError(str, hash, ExceptionClass) {\n if (hash.recoverable) {\n if (typeof this.trace === 'function') {\n this.trace(str);\n }\n hash.destroy(); // destroy... well, *almost*!\n } else {\n if (typeof this.trace === 'function') {\n this.trace(str);\n }\n if (!ExceptionClass) {\n ExceptionClass = this.JisonParserError;\n }\n throw new ExceptionClass(str, hash);\n }\n}\n"; // --- END of parseErrorSourceCode chunk --- chkBugger$3(parseErrorSourceCode); parser$4.parseError = lrGeneratorMixin.parseError = eval(parseErrorSourceCode + '\n\nparseError;'); @@ -28071,7 +28384,7 @@ generatorMixin.createLexer = function createLexer(lexerSpec, input, tokens, opti // in the generated code: -var define_parser_APIs_1 = "\n TERROR: 2,\n EOF: 1,\n\n // internals: defined here so the object *structure* doesn't get modified by parse() et al,\n // thus helping JIT compilers like Chrome V8.\n originalQuoteName: null,\n originalParseError: null,\n cleanupAfterParse: null,\n constructParseErrorInfo: null,\n yyMergeLocationInfo: null,\n copy_yytext: null,\n copy_yylloc: null,\n\n __reentrant_call_depth: 0, // INTERNAL USE ONLY\n __error_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup\n __error_recovery_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup\n\n // APIs which will be set up depending on user action code analysis:\n //yyRecovering: 0,\n //yyErrOk: 0,\n //yyClearIn: 0,\n\n // Helper APIs\n // -----------\n\n // Helper function which can be overridden by user code later on: put suitable quotes around\n // literal IDs in a description string.\n quoteName: function parser_quoteName(id_str) {\n \"use strict\";\n\n return '\"' + id_str + '\"';\n },\n\n // Return the name of the given symbol (terminal or non-terminal) as a string, when available.\n //\n // Return NULL when the symbol is unknown to the parser.\n getSymbolName: function parser_getSymbolName(symbol) {\n \"use strict\";\n\n if (this.terminals_[symbol]) {\n return this.terminals_[symbol];\n }\n\n // Otherwise... this might refer to a RULE token i.e. a non-terminal: see if we can dig that one up.\n //\n // An example of this may be where a rule's action code contains a call like this:\n //\n // parser.getSymbolName(#$)\n //\n // to obtain a human-readable name of the current grammar rule.\n var s = this.symbols_;\n for (var key in s) {\n if (s[key] === symbol) {\n return key;\n }\n }\n return null;\n },\n\n // Return a more-or-less human-readable description of the given symbol, when available,\n // or the symbol itself, serving as its own 'description' for lack of something better to serve up.\n //\n // Return NULL when the symbol is unknown to the parser.\n describeSymbol: function parser_describeSymbol(symbol) {\n \"use strict\";\n\n if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) {\n return this.terminal_descriptions_[symbol];\n }\n else if (symbol === this.EOF) {\n return 'end of input';\n }\n var id = this.getSymbolName(symbol);\n if (id) {\n return this.quoteName(id);\n }\n return null;\n },\n\n // Produce a (more or less) human-readable list of expected tokens at the point of failure.\n //\n // The produced list may contain token or token set descriptions instead of the tokens\n // themselves to help turning this output into something that easier to read by humans\n // unless `do_not_describe` parameter is set, in which case a list of the raw, *numeric*,\n // expected terminals and nonterminals is produced.\n //\n // The returned list (array) will not contain any duplicate entries.\n collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) {\n \"use strict\";\n\n var TERROR = this.TERROR;\n var tokenset = [];\n var check = {};\n // Has this (error?) state been outfitted with a custom expectations description text for human consumption?\n // If so, use that one instead of the less palatable token set.\n if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) {\n return [\n this.state_descriptions_[state]\n ];\n }\n for (var p in this.table[state]) {\n p = +p;\n if (p !== TERROR) {\n var d = do_not_describe ? p : this.describeSymbol(p);\n if (d && !check[d]) {\n tokenset.push(d);\n check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries.\n }\n }\n }\n return tokenset;\n }\n"; // --- END of define_parser_APIs_1 chunk --- +var define_parser_APIs_1 = "\n TERROR: 2,\n EOF: 1,\n\n // internals: defined here so the object *structure* doesn't get modified by parse() et al,\n // thus helping JIT compilers like Chrome V8.\n originalQuoteName: null,\n originalParseError: null,\n cleanupAfterParse: null,\n constructParseErrorInfo: null,\n yyMergeLocationInfo: null,\n copy_yytext: null,\n copy_yylloc: null,\n\n __reentrant_call_depth: 0, // INTERNAL USE ONLY\n __error_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup\n __error_recovery_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup\n\n // APIs which will be set up depending on user action code analysis:\n //yyRecovering: 0,\n //yyErrOk: 0,\n //yyClearIn: 0,\n\n // Helper APIs\n // -----------\n\n // Helper function which can be overridden by user code later on: put suitable quotes around\n // literal IDs in a description string.\n quoteName: function parser_quoteName(id_str) {\n return '\"' + id_str + '\"';\n },\n\n // Return the name of the given symbol (terminal or non-terminal) as a string, when available.\n //\n // Return NULL when the symbol is unknown to the parser.\n getSymbolName: function parser_getSymbolName(symbol) {\n if (this.terminals_[symbol]) {\n return this.terminals_[symbol];\n }\n\n // Otherwise... this might refer to a RULE token i.e. a non-terminal: see if we can dig that one up.\n //\n // An example of this may be where a rule's action code contains a call like this:\n //\n // parser.getSymbolName(#$)\n //\n // to obtain a human-readable name of the current grammar rule.\n const s = this.symbols_;\n for (let key in s) {\n if (s[key] === symbol) {\n return key;\n }\n }\n return null;\n },\n\n // Return a more-or-less human-readable description of the given symbol, when available,\n // or the symbol itself, serving as its own 'description' for lack of something better to serve up.\n //\n // Return NULL when the symbol is unknown to the parser.\n describeSymbol: function parser_describeSymbol(symbol) {\n if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) {\n return this.terminal_descriptions_[symbol];\n } else if (symbol === this.EOF) {\n return 'end of input';\n }\n\n let id = this.getSymbolName(symbol);\n if (id) {\n return this.quoteName(id);\n }\n return null;\n },\n\n // Produce a (more or less) human-readable list of expected tokens at the point of failure.\n //\n // The produced list may contain token or token set descriptions instead of the tokens\n // themselves to help turning this output into something that easier to read by humans\n // unless `do_not_describe` parameter is set, in which case a list of the raw, *numeric*,\n // expected terminals and nonterminals is produced.\n //\n // The returned list (array) will not contain any duplicate entries.\n collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) {\n const TERROR = this.TERROR;\n let tokenset = [];\n let check = {};\n\n // Has this (error?) state been outfitted with a custom expectations description text for human consumption?\n // If so, use that one instead of the less palatable token set.\n if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) {\n return [\n this.state_descriptions_[state]\n ];\n }\n for (let p in this.table[state]) {\n p = +p;\n if (p !== TERROR) {\n let d = do_not_describe ? p : this.describeSymbol(p);\n if (d && !check[d]) {\n tokenset.push(d);\n check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries.\n }\n }\n }\n return tokenset;\n }\n"; // --- END of define_parser_APIs_1 chunk --- var api_set = new Function('', 'return { ' + define_parser_APIs_1 + ' };')(); @@ -28080,7 +28393,7 @@ for (var api in api_set) { } // --- START parser kernel --- -parser$4.parse = "\nfunction parse(input, parseParams) {\n \"use strict\";\n\n var self = this;\n var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage)\n var sstack = new Array(128); // state stack: stores states (column storage)\n var tstack = []; // token stack (only used when `%options token_stack` support has been enabled)\n var vstack = new Array(128); // semantic value stack\n var lstack = new Array(128); // location stack\n var table = this.table;\n var sp = 0; // 'stack pointer': index into the stacks\n var yyloc;\n var yytext;\n var yylineno;\n var yyleng;\n\n var symbol = 0;\n var preErrorSymbol = 0;\n var lastEofErrorStateDepth = Infinity;\n var recoveringErrorInfo = null;\n var recovering = 0; // (only used when the grammar contains error recovery rules)\n var TERROR = this.TERROR;\n var EOF = this.EOF;\n var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3;\n var NO_ACTION = [0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */];\n\n var lexer;\n if (this.__lexer__) {\n lexer = this.__lexer__;\n } else {\n lexer = this.__lexer__ = Object.create(this.lexer);\n }\n\n var sharedState_yy = {\n parseError: undefined,\n quoteName: undefined,\n lexer: undefined,\n parser: undefined,\n pre_parse: undefined,\n post_parse: undefined,\n pre_lex: undefined,\n post_lex: undefined,\n parseParamsAsMembers: parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes!\n };\n\n var ASSERT;\n if (typeof assert !== 'function') {\n ASSERT = function JisonAssert(cond, msg) {\n \"use strict\";\n\n if (!cond) {\n throw new Error('assertion failed: ' + (msg || '***'));\n }\n };\n } else {\n ASSERT = assert;\n }\n\n this.yyGetSharedState = function yyGetSharedState() {\n return sharedState_yy;\n };\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n this.yyGetErrorInfoTrack = function yyGetErrorInfoTrack() {\n return recoveringErrorInfo;\n };\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // shallow clone objects & arrays, straight copy of simple `src` values\n // e.g. `lexer.yytext` MAY be a complex value object,\n // rather than a simple string/value.\n //\n // https://jsperf.com/new-array-vs-splice-vs-slice/72\n // https://jsperf.com/instanceof-vs-typeof/20\n // benchmark:: http://127.0.0.1:8080/example/jsperf/#testfile=test0020-typeof-instanceof-isArray.json5\n // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5\n //\n function shallow_copy(src) {\n \"use strict\";\n\n if (src && typeof src === 'object') {\n // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned\n // using their constructor:\n if (src.constructor !== Object) {\n if (Array.isArray(src)) {\n return src.slice();\n }\n var dst = new src.constructor(src);\n\n // and make sure all custom attributes are added to the clone:\n shallow_copy_noclobber(dst, src);\n return dst;\n }\n // native objects must be cloned a different way:\n //\n //return Object.assign({}, src);\n var dst = {};\n shallow_copy_noclobber(dst, src);\n return dst;\n }\n return src;\n }\n // add elements from `src` to `dst` when:\n // - either the element does not yet exist in `src`\n // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst`\n function shallow_copy_noclobber(dst, src) {\n \"use strict\";\n\n const chk = Object.prototype.hasOwnProperty;\n for (var k in src) {\n if (!(k in dst)) {\n if (chk.call(src, k)) {\n dst[k] = src[k];\n }\n }\n else {\n if (src[k] != null && dst[k] == null && chk.call(src, k)) {\n dst[k] = src[k];\n }\n }\n }\n }\n function copy_yylloc_native(loc) {\n \"use strict\";\n\n var rv = shallow_copy(loc);\n // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries:\n if (rv) {\n rv.range = rv.range.slice();\n }\n return rv;\n }\n\n // copy state\n shallow_copy_noclobber(sharedState_yy, this.yy);\n\n sharedState_yy.lexer = lexer;\n sharedState_yy.parser = this;\n\n // allow userland code to override the yytext and yylloc copy/clone functions:\n this.copy_yytext = this.options.copy_yytext || sharedState_yy.copy_yytext || shallow_copy;\n this.copy_yylloc = this.options.copy_yylloc || sharedState_yy.copy_yylloc || copy_yylloc_native;\n\n var yydebug = false;\n if (this.options.debug) {\n yydebug = function yydebug_impl(msg, obj) {\n \"use strict\";\n\n var ref_list;\n var ref_names;\n\n function deepClone(from, sub) {\n \"use strict\";\n\n if (sub == null) {\n ref_list = [];\n ref_names = [];\n sub = 'root';\n }\n if (typeof from === 'function') return '[Function]';\n if (from == null || typeof from !== 'object') return from;\n if (from.constructor !== Object && from.constructor !== Array) {\n return from;\n }\n\n var i = ref_list.indexOf(from);\n if (i >= 0) {\n return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference\n }\n ref_list.push(from);\n ref_names.push(sub);\n\n var to = new from.constructor();\n for (var name in from) {\n if (name === 'parser') continue;\n if (name === 'lexer') continue;\n to[name] = deepClone(from[name], name);\n }\n return to;\n }\n\n obj = obj || {};\n if (obj.symbol) {\n obj.local_yytext = yytext;\n obj.lexer_yytext = lexer.yytext;\n obj.lexer_yylloc = lexer.yylloc;\n obj.lexer_yyllineno = lexer.yyllineno;\n }\n\n // warning: here we fetch from closure (stack et al)\n obj.symbol_stack = stack;\n obj.state_stack = sstack;\n obj.value_stack = vstack;\n obj.location_stack = lstack;\n obj.stack_pointer = sp;\n\n // ready the object for printing:\n obj = deepClone(obj);\n\n // wrap try/catch in a function to help the V8 JIT compiler...\n function yydebug_cvt(obj) {\n \"use strict\";\n\n var js;\n try {\n var re1;\n if (typeof XRegExp === 'undefined') {\n re1 = / \\\"([a-z_][a-z_0-9. ]*)\\\": /ig;\n } else {\n re1 = new XRegExp(' \\\"([\\\\p{Alphabetic}_][\\\\p{Alphabetic}\\\\p{Number}_. ]*)\\\": ', 'g');\n }\n js = JSON.stringify(obj, null, 2)\n .replace(re1, ' $1: ')\n .replace(/[\\n\\s]+/g, ' ')\n // shorten yylloc object dumps too:\n .replace(/\\{ first_line: (\\d+), first_column: (\\d+), last_line: (\\d+), last_column: (\\d+)/g, '{L/C: ($1,$2)..($3,$4)');\n } catch (ex) {\n js = String(obj);\n }\n return js;\n }\n\n self.trace(msg, yydebug_cvt(obj), '\\n');\n };\n }\n\n // disable debugging at run-time ANYWAY when you've *explicitly* set \"yy.yydebug = false\":\n if (sharedState_yy.yydebug === false) {\n yydebug = undefined;\n }\n\n // *Always* setup `yyError`, `YYRECOVERING`, `yyErrOk` and `yyClearIn` functions as it is paramount\n // to have *their* closure match ours -- if we only set them up once,\n // any subsequent `parse()` runs will fail in very obscure ways when\n // these functions are invoked in the user action code block(s) as\n // their closure will still refer to the `parse()` instance which set\n // them up. Hence we MUST set them up at the start of every `parse()` run!\n if (this.yyError) {\n this.yyError = function yyError(str /*, ...args */) {\n \"use strict\";\n\n if (yydebug) yydebug('yyerror: ', { message: str, args: arguments, symbol: symbol, state: state, newState: newState, recovering: recovering, action: action });\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1);\n var expected = this.collect_expected_token_set(state);\n var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0));\n // append to the old one?\n if (recoveringErrorInfo) {\n var esp = recoveringErrorInfo.info_stack_pointer;\n\n recoveringErrorInfo.symbol_stack[esp] = symbol;\n var v = this.shallowCopyErrorInfo(hash);\n v.yyError = true;\n v.errorRuleDepth = error_rule_depth;\n v.recovering = recovering;\n // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH;\n\n recoveringErrorInfo.value_stack[esp] = v;\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc);\n recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n } else {\n recoveringErrorInfo = this.shallowCopyErrorInfo(hash);\n recoveringErrorInfo.yyError = true;\n recoveringErrorInfo.errorRuleDepth = error_rule_depth;\n recoveringErrorInfo.recovering = recovering;\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n\n var expected = this.collect_expected_token_set(state);\n var hash = this.constructParseErrorInfo(str, null, expected, false);\n\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n var args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n hash.extra_error_attributes = args;\n }\n\n return this.parseError(str, hash, this.JisonParserError);\n };\n }\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n if (this.yyRecovering) {\n this.yyRecovering = function yyRecovering() {\n \"use strict\";\n\n if (yydebug) yydebug('yyrecovering: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action });\n return recovering;\n };\n }\n\n if (this.yyErrOk) {\n this.yyErrOk = function yyErrOk() {\n \"use strict\";\n\n if (yydebug) yydebug('yyerrok: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action });\n recovering = 0;\n\n // DO NOT reset/cleanup `recoveringErrorInfo` yet: userland code\n // MAY invoke this API before the error is actually fully\n // recovered, in which case the parser recovery code won't be able\n // to append the skipped tokens to this info object.\n //\n // The rest of the kernel code is safe enough that it won't inadvertedly\n // re-use an old `recoveringErrorInfo` chunk so we'ld better wait\n // with destruction/cleanup until the end of the parse or until another\n // fresh parse error rears its ugly head...\n //\n // if (recoveringErrorInfo && typeof recoveringErrorInfo.destroy === 'function') {\n // recoveringErrorInfo.destroy();\n // recoveringErrorInfo = undefined;\n // }\n };\n }\n\n if (this.yyClearIn) {\n this.yyClearIn = function yyClearIn() {\n \"use strict\";\n\n if (yydebug) yydebug('yyclearin: ', { symbol: symbol, newState: newState, recovering: recovering, action: action, preErrorSymbol: preErrorSymbol });\n if (symbol === TERROR) {\n symbol = 0;\n yytext = null;\n yyleng = 0;\n yyloc = undefined;\n }\n preErrorSymbol = 0;\n };\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // Does the shared state override the default `parseError` that already comes with this instance?\n if (typeof sharedState_yy.parseError === 'function') {\n this.parseError = function parseErrorAlt(str, hash, ExceptionClass) {\n \"use strict\";\n\n if (!ExceptionClass) {\n ExceptionClass = this.JisonParserError;\n }\n return sharedState_yy.parseError.call(this, str, hash, ExceptionClass);\n };\n } else {\n this.parseError = this.originalParseError;\n }\n\n // Does the shared state override the default `quoteName` that already comes with this instance?\n if (typeof sharedState_yy.quoteName === 'function') {\n this.quoteName = function quoteNameAlt(id_str) {\n \"use strict\";\n\n return sharedState_yy.quoteName.call(this, id_str);\n };\n } else {\n this.quoteName = this.originalQuoteName;\n }\n\n // set up the cleanup function; make it an API so that external code can re-use this one in case of\n // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which\n // case this parse() API method doesn't come with a `finally { ... }` block any more!\n //\n // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,\n // or else your `sharedState`, etc. references will be *wrong*!\n this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) {\n \"use strict\";\n\n var rv;\n\n if (invoke_post_methods) {\n var hash;\n\n if (sharedState_yy.post_parse || this.post_parse) {\n // create an error hash info instance: we re-use this API in a **non-error situation**\n // as this one delivers all parser internals ready for access by userland code.\n hash = this.constructParseErrorInfo(null /* no error! */, null /* no exception! */, null, false);\n }\n\n if (sharedState_yy.post_parse) {\n rv = sharedState_yy.post_parse.call(this, sharedState_yy, resultValue, hash);\n if (typeof rv !== 'undefined') resultValue = rv;\n }\n if (this.post_parse) {\n rv = this.post_parse.call(this, sharedState_yy, resultValue, hash);\n if (typeof rv !== 'undefined') resultValue = rv;\n }\n\n // cleanup:\n if (hash && hash.destroy) {\n hash.destroy();\n }\n }\n\n if (this.__reentrant_call_depth > 1) return resultValue; // do not (yet) kill the sharedState when this is a reentrant run.\n\n // clean up the lingering lexer structures as well:\n if (lexer.cleanupAfterLex) {\n lexer.cleanupAfterLex(do_not_nuke_errorinfos);\n }\n\n // prevent lingering circular references from causing memory leaks:\n if (sharedState_yy) {\n sharedState_yy.lexer = undefined;\n sharedState_yy.parser = undefined;\n if (lexer.yy === sharedState_yy) {\n lexer.yy = undefined;\n }\n }\n sharedState_yy = undefined;\n this.parseError = this.originalParseError;\n this.quoteName = this.originalQuoteName;\n\n // nuke the vstack[] array at least as that one will still reference obsoleted user values.\n // To be safe, we nuke the other internal stack columns as well...\n stack.length = 0; // fastest way to nuke an array without overly bothering the GC\n sstack.length = 0;\n lstack.length = 0;\n vstack.length = 0;\n sp = 0;\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (var i = this.__error_infos.length - 1; i >= 0; i--) {\n var el = this.__error_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) {\n var el = this.__error_recovery_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_recovery_infos.length = 0;\n\n // `recoveringErrorInfo` is also part of the `__error_recovery_infos` array,\n // hence has been destroyed already: no need to do that *twice*.\n if (recoveringErrorInfo) {\n recoveringErrorInfo = undefined;\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n }\n\n return resultValue;\n };\n\n // merge yylloc info into a new yylloc instance.\n //\n // `first_index` and `last_index` MAY be UNDEFINED/NULL or these are indexes into the `lstack[]` location stack array.\n //\n // `first_yylloc` and `last_yylloc` MAY be UNDEFINED/NULL or explicit (custom or regular) `yylloc` instances, in which\n // case these override the corresponding first/last indexes.\n //\n // `dont_look_back` is an optional flag (default: FALSE), which instructs this merge operation NOT to search\n // through the parse location stack for a location, which would otherwise be used to construct the new (epsilon!)\n // yylloc info.\n //\n // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL.\n this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) {\n \"use strict\";\n\n var i1 = first_index | 0,\n i2 = last_index | 0;\n var l1 = first_yylloc,\n l2 = last_yylloc;\n var rv;\n\n // rules:\n // - first/last yylloc entries override first/last indexes\n\n if (!l1) {\n if (first_index != null) {\n for (var i = i1; i <= i2; i++) {\n l1 = lstack[i];\n if (l1) {\n break;\n }\n }\n }\n }\n\n if (!l2) {\n if (last_index != null) {\n for (var i = i2; i >= i1; i--) {\n l2 = lstack[i];\n if (l2) {\n break;\n }\n }\n }\n }\n\n // - detect if an epsilon rule is being processed and act accordingly:\n if (!l1 && first_index == null) {\n // epsilon rule span merger. With optional look-ahead in l2.\n if (!dont_look_back) {\n for (var i = (i1 || sp) - 1; i >= 0; i--) {\n l1 = lstack[i];\n if (l1) {\n break;\n }\n }\n }\n if (!l1) {\n if (!l2) {\n // when we still don't have any valid yylloc info, we're looking at an epsilon rule\n // without look-ahead and no preceding terms and/or `dont_look_back` set:\n // in that case we ca do nothing but return NULL/UNDEFINED:\n return undefined;\n } else {\n // shallow-copy L2: after all, we MAY be looking\n // at unconventional yylloc info objects...\n rv = this.copy_yylloc(l2);\n return rv;\n }\n } else {\n // shallow-copy L1, then adjust first col/row 1 column past the end.\n rv = this.copy_yylloc(l1);\n rv.first_line = rv.last_line;\n rv.first_column = rv.last_column;\n rv.range[0] = rv.range[1];\n\n if (l2) {\n // shallow-mixin L2, then adjust last col/row accordingly.\n shallow_copy_noclobber(rv, l2);\n rv.last_line = l2.last_line;\n rv.last_column = l2.last_column;\n rv.range[1] = l2.range[1];\n }\n return rv;\n }\n }\n\n if (!l1) {\n l1 = l2;\n l2 = null;\n }\n if (!l1) {\n return undefined;\n }\n\n // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking\n // at unconventional yylloc info objects...\n rv = this.copy_yylloc(l1);\n\n if (l2) {\n shallow_copy_noclobber(rv, l2);\n rv.last_line = l2.last_line;\n rv.last_column = l2.last_column;\n rv.range[1] = l2.range[1];\n }\n\n return rv;\n };\n\n // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,\n // or else your `lexer`, `sharedState`, etc. references will be *wrong*!\n this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) {\n \"use strict\";\n\n var pei = {\n errStr: msg,\n exception: ex,\n text: lexer.match,\n value: this.copy_yytext(lexer.yytext),\n token: this.describeSymbol(symbol) || symbol,\n token_id: symbol,\n line: lexer.yylineno,\n loc: this.copy_yylloc(lexer.yylloc),\n expected: expected,\n recoverable: recoverable,\n state: state,\n action: action,\n new_state: newState,\n symbol_stack: stack,\n state_stack: sstack,\n value_stack: vstack,\n location_stack: lstack,\n stack_pointer: sp,\n yy: sharedState_yy,\n lexer: lexer,\n parser: this,\n\n // and make sure the error info doesn't stay due to potential\n // ref cycle via userland code manipulations.\n // These would otherwise all be memory leak opportunities!\n //\n // Note that only array and object references are nuked as those\n // constitute the set of elements which can produce a cyclic ref.\n // The rest of the members is kept intact as they are harmless.\n destroy: function destructParseErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // info.value = null;\n // info.value_stack = null;\n // ...\n \"use strict\";\n\n var rec = !!this.recoverable;\n for (var key in this) {\n if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n };\n\n // clone some parts of the (possibly enhanced!) errorInfo object\n // to give them some persistence.\n this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) {\n \"use strict\";\n\n var rv = shallow_copy(p);\n\n // remove the large parts which can only cause cyclic references\n // and are otherwise available from the parser kernel anyway.\n delete rv.sharedState_yy;\n delete rv.parser;\n delete rv.lexer;\n\n // lexer.yytext MAY be a complex value object, rather than a simple string/value:\n rv.value = this.copy_yytext(rv.value);\n\n // yylloc info:\n rv.loc = this.copy_yylloc(rv.loc);\n\n // the 'expected' set won't be modified, so no need to clone it:\n //rv.expected = rv.expected.slice();\n\n // symbol stack is a simple array:\n rv.symbol_stack = rv.symbol_stack.slice();\n // ditto for state stack:\n rv.state_stack = rv.state_stack.slice();\n // clone the yylloc's in the location stack?:\n rv.location_stack = rv.location_stack.map(this.copy_yylloc);\n // and the value stack may carry both simple and complex values:\n // shallow-copy the latter.\n rv.value_stack = rv.value_stack.map(this.copy_yytext);\n\n // and we don't bother with the sharedState_yy reference:\n //delete rv.yy;\n\n // now we prepare for tracking the COMBINE actions\n // in the error recovery code path:\n //\n // as we want to keep the maximum error info context, we\n // *scan* the state stack to find the first *empty* slot.\n // This position will surely be AT OR ABOVE the current\n // stack pointer, but we want to keep the 'used but discarded'\n // part of the parse stacks *intact* as those slots carry\n // error context that may be useful when you want to produce\n // very detailed error diagnostic reports.\n //\n // ### Purpose of each stack pointer:\n //\n // - stack_pointer: points at the top of the parse stack\n // **as it existed at the time of the error\n // occurrence, i.e. at the time the stack\n // snapshot was taken and copied into the\n // errorInfo object.**\n // - base_pointer: the bottom of the **empty part** of the\n // stack, i.e. **the start of the rest of\n // the stack space /above/ the existing\n // parse stack. This section will be filled\n // by the error recovery process as it\n // travels the parse state machine to\n // arrive at the resolving error recovery rule.**\n // - info_stack_pointer:\n // this stack pointer points to the **top of\n // the error recovery tracking stack space**, i.e.\n // this stack pointer takes up the role of\n // the `stack_pointer` for the error recovery\n // process. Any mutations in the **parse stack**\n // are **copy-appended** to this part of the\n // stack space, keeping the bottom part of the\n // stack (the 'snapshot' part where the parse\n // state at the time of error occurrence was kept)\n // intact.\n // - root_failure_pointer:\n // copy of the `stack_pointer`...\n //\n for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) {\n // empty\n }\n rv.base_pointer = i;\n rv.info_stack_pointer = i;\n\n rv.root_failure_pointer = rv.stack_pointer;\n\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_recovery_infos.push(rv);\n\n return rv;\n };\n\n function getNonTerminalFromCode(symbol) {\n \"use strict\";\n\n var tokenName = self.getSymbolName(symbol);\n if (!tokenName) {\n tokenName = symbol;\n }\n return tokenName;\n }\n\n//_lexer_without_token_stack:\n\n function stdLex() {\n \"use strict\";\n\n var token = lexer.lex();\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n var tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName: tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n function fastLex() {\n \"use strict\";\n\n var token = lexer.fastLex();\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n var tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName: tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n var lex = stdLex;\n\n//_lexer_with_token_stack:\n\n // lex function that supports token stacks\n function tokenStackLex() {\n \"use strict\";\n\n var token;\n token = tstack.pop() || lexer.lex() || EOF;\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n if (token instanceof Array) {\n // tokenstack CANNOT be nested, i.e. an 'array'-type token\n // now means the `tstack` is empty as this array of tokens\n // could only have originated from the `lexer.lex()`\n // call:\n tstack = token;\n token = tstack.pop();\n }\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n var tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName: tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n//_lexer_with_token_stack_end:\n\n var state, action, r, t;\n var yyval = {\n $: true,\n _$: undefined,\n yy: sharedState_yy\n };\n var p;\n var yyrulelen;\n var this_production;\n var newState;\n var retval = false;\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n // Return the rule stack depth where the nearest error rule can be found.\n // Return -1 when no error recovery rule was found.\n function locateNearestErrorRecoveryRule(state) {\n \"use strict\";\n\n var stack_probe = sp - 1;\n var depth = 0;\n\n // try to recover from error\n while (stack_probe >= 0) {\n // check for error recovery rule in this state\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #test#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n var t = (table[state] && table[state][TERROR]) || NO_ACTION;\n if (t[0]) {\n // We need to make sure we're not cycling forever:\n // once we hit EOF, even when we `yyerrok()` an error, we must\n // prevent the core from running forever,\n // e.g. when parent rules are still expecting certain input to\n // follow after this, for example when you handle an error inside a set\n // of braces which are matched by a parent rule in your grammar.\n //\n // Hence we require that every error handling/recovery attempt\n // *after we've hit EOF* has a diminishing state stack: this means\n // we will ultimately have unwound the state stack entirely and thus\n // terminate the parse in a controlled fashion even when we have\n // very complex error/recovery code interplay in the core + user\n // action code blocks:\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #found#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n if (symbol === EOF) {\n if (lastEofErrorStateDepth > sp - 1 - depth) {\n lastEofErrorStateDepth = sp - 1 - depth;\n } else {\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #skip#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n --stack_probe; // popStack(1): [symbol, action]\n state = sstack[stack_probe];\n ++depth;\n continue;\n }\n }\n return depth;\n }\n if (state === 0 /* $accept rule */ || stack_probe < 1) {\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n return -1; // No suitable error recovery rule available.\n }\n --stack_probe; // popStack(1): [symbol, action]\n state = sstack[stack_probe];\n ++depth;\n }\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n return -1; // No suitable error recovery rule available.\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n try {\n this.__reentrant_call_depth++;\n\n lexer.setInput(input, sharedState_yy);\n\n // NOTE: we *assume* no lexer pre/post handlers are set up *after*\n // this initial `setInput()` call: hence we can now check and decide\n // whether we'll go with the standard, slower, lex() API or the\n // `fast_lex()` one:\n if (typeof lexer.canIUse === 'function') {\n var lexerInfo = lexer.canIUse();\n if (lexerInfo.fastLex && typeof fastLex === 'function') {\n lex = fastLex;\n }\n }\n\n yyloc = this.copy_yylloc(lexer.yylloc);\n lstack[sp] = yyloc;\n vstack[sp] = null;\n sstack[sp] = 0;\n stack[sp] = 0;\n ++sp;\n\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyleng = lexer.yyleng;\n\n if (this.pre_parse) {\n this.pre_parse.call(this, sharedState_yy);\n }\n if (sharedState_yy.pre_parse) {\n sharedState_yy.pre_parse.call(this, sharedState_yy);\n }\n\n newState = sstack[sp - 1];\n for (;;) {\n // retrieve state number from top of stack\n state = newState; // sstack[sp - 1];\n\n // use default actions if available\n if (this.defaultActions[state]) {\n action = 2;\n newState = this.defaultActions[state];\n } else {\n // The single `==` condition below covers both these `===` comparisons in a single\n // operation:\n //\n // if (symbol === null || typeof symbol === 'undefined') ...\n if (!symbol) {\n symbol = lex();\n }\n // read action for current state and first input\n t = (table[state] && table[state][symbol]) || NO_ACTION;\n newState = t[1];\n action = t[0];\n\n if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action });\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n // handle parse error\n if (!action) {\n // first see if there's any chance at hitting an error recovery rule:\n var error_rule_depth = locateNearestErrorRecoveryRule(state);\n var errStr = null;\n var errSymbolDescr = (this.describeSymbol(symbol) || symbol);\n var expected = this.collect_expected_token_set(state);\n\n if (!recovering) {\n // Report error\n errStr = 'Parse error';\n if (typeof lexer.yylineno === 'number') {\n errStr += ' on line ' + (lexer.yylineno + 1);\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += ':\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n } else {\n errStr += ': ';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n\n p = this.constructParseErrorInfo(errStr, null, expected, (error_rule_depth >= 0));\n\n // DO NOT cleanup the old one before we start the new error info track:\n // the old one will *linger* on the error stack and stay alive until we\n // invoke the parser's cleanup API!\n recoveringErrorInfo = this.shallowCopyErrorInfo(p);\n\n if (yydebug) yydebug('error recovery rule detected: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p });\n\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n break;\n }\n\n // Protect against overly blunt userland `parseError` code which *sets*\n // the `recoverable` flag without properly checking first:\n // we always terminate the parse when there's no recovery rule available anyhow!\n if (!p.recoverable || error_rule_depth < 0) {\n break;\n } else {\n // TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process...\n }\n }\n\n if (yydebug) yydebug('after ERROR DETECT: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p });\n\n var esp = recoveringErrorInfo.info_stack_pointer;\n\n // just recovered from another error\n if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) {\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = this.copy_yytext(lexer.yytext);\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n\n // SHIFT current lookahead and grab another\n recoveringErrorInfo.symbol_stack[esp] = symbol;\n recoveringErrorInfo.value_stack[esp] = yytext;\n recoveringErrorInfo.location_stack[esp] = yyloc;\n recoveringErrorInfo.state_stack[esp] = newState; // push state\n ++esp;\n\n preErrorSymbol = 0;\n symbol = lex();\n\n if (yydebug) yydebug('after ERROR RECOVERY-3: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol] });\n }\n\n // try to recover from error\n if (error_rule_depth < 0) {\n ASSERT(recovering > 0, \"line 897\");\n recoveringErrorInfo.info_stack_pointer = esp;\n\n // barf a fatal hairball when we're out of look-ahead symbols and none hit a match\n // while we are still busy recovering from another error:\n var po = this.__error_infos[this.__error_infos.length - 1];\n\n // Report error\n if (typeof lexer.yylineno === 'number') {\n errStr = 'Parsing halted on line ' + (lexer.yylineno + 1) + ' while starting to recover from another error';\n } else {\n errStr = 'Parsing halted while starting to recover from another error';\n }\n\n if (po) {\n errStr += ' -- previous error which resulted in this fatal result: ' + po.errStr;\n } else {\n errStr += ': ';\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += '\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n\n p = this.constructParseErrorInfo(errStr, null, expected, false);\n if (po) {\n p.extra_error_attributes = po;\n }\n\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n\n preErrorSymbol = (symbol === TERROR ? 0 : symbol); // save the lookahead token\n symbol = TERROR; // insert generic error symbol as new lookahead\n\n const EXTRA_STACK_SAMPLE_DEPTH = 3;\n\n // REDUCE/COMBINE the pushed terms/tokens to a new ERROR token:\n recoveringErrorInfo.symbol_stack[esp] = preErrorSymbol;\n if (errStr) {\n recoveringErrorInfo.value_stack[esp] = {\n yytext: this.copy_yytext(lexer.yytext),\n errorRuleDepth: error_rule_depth,\n errStr: errStr,\n errorSymbolDescr: errSymbolDescr,\n expectedStr: expected,\n stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH\n };\n if (yydebug) yydebug('Error recovery process: pushed error info item on the info stack: ', {\n item: vstack[sp],\n sp,\n esp,\n vstack,\n stack,\n sstack,\n combineState: NO_ACTION[1]\n });\n } else {\n recoveringErrorInfo.value_stack[esp] = {\n yytext: this.copy_yytext(lexer.yytext),\n errorRuleDepth: error_rule_depth,\n stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH\n };\n }\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc);\n recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n\n yyval.$ = recoveringErrorInfo;\n yyval._$ = undefined;\n\n yyrulelen = error_rule_depth;\n\n if (yydebug) yydebug('Error recovery process: performAction: COMBINE: ', {\n yyval, yytext, sp, pop_size: yyrulelen, vstack, stack, sstack,\n combineState: NO_ACTION[1]\n });\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, NO_ACTION[1], sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof r !== 'undefined') {\n retval = r;\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // and move the top entries + discarded part of the parse stacks onto the error info stack:\n for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) {\n recoveringErrorInfo.symbol_stack[esp] = stack[idx];\n recoveringErrorInfo.value_stack[esp] = vstack[idx];\n recoveringErrorInfo.location_stack[esp] = lstack[idx];\n recoveringErrorInfo.state_stack[esp] = sstack[idx];\n }\n\n recoveringErrorInfo.symbol_stack[esp] = TERROR;\n recoveringErrorInfo.value_stack[esp] = this.copy_yytext(yyval.$);\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(yyval._$);\n\n // goto new state = table[STATE][NONTERMINAL]\n newState = sstack[sp - 1];\n\n if (this.defaultActions[newState]) {\n recoveringErrorInfo.state_stack[esp] = this.defaultActions[newState];\n } else {\n t = (table[newState] && table[newState][symbol]) || NO_ACTION;\n recoveringErrorInfo.state_stack[esp] = t[1];\n }\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n\n // allow N (default: 3) real symbols to be shifted before reporting a new error\n recovering = ERROR_RECOVERY_TOKEN_DISCARD_COUNT;\n\n if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth: error_rule_depth, symbol: symbol, preErrorSymbol: preErrorSymbol });\n\n // Now duplicate the standard parse machine here, at least its initial\n // couple of rounds until the TERROR symbol is **pushed onto the parse stack**,\n // as we wish to push something special then!\n //\n // Run the state machine in this copy of the parser state machine\n // until we *either* consume the error symbol (and its related information)\n // *or* we run into another error while recovering from this one\n // *or* we execute a `reduce` action which outputs a final parse\n // result (yes, that MAY happen!).\n //\n // We stay in this secondary parse loop until we have completed\n // the *error recovery phase* as the main parse loop (further below)\n // is optimized for regular parse operation and DOES NOT cope with\n // error recovery *at all*.\n //\n // We call the secondary parse loop just below the \"slow parse loop\",\n // while the main parse loop, which is an almost-duplicate of this one,\n // yet optimized for regular parse operation, is called the \"fast\n // parse loop\".\n //\n // Compare this to `bison` & (vanilla) `jison`, both of which have\n // only a single parse loop, which handles everything. Our goal is\n // to eke out every drop of performance in the main parse loop...\n\n ASSERT(recoveringErrorInfo, \"line 1049\");\n ASSERT(symbol === TERROR, \"line 1050\");\n ASSERT(!action, \"line 1051\");\n var errorSymbolFromParser = true;\n for (;;) {\n // retrieve state number from top of stack\n state = newState; // sstack[sp - 1];\n\n // use default actions if available\n if (this.defaultActions[state]) {\n action = 2;\n newState = this.defaultActions[state];\n } else {\n // The single `==` condition below covers both these `===` comparisons in a single\n // operation:\n //\n // if (symbol === null || typeof symbol === 'undefined') ...\n if (!symbol) {\n symbol = lex();\n // **Warning: Edge Case**: the *lexer* may produce\n // TERROR tokens of its own volition: *those* TERROR\n // tokens should be treated like *regular tokens*\n // i.e. tokens which have a lexer-provided `yyvalue`\n // and `yylloc`:\n errorSymbolFromParser = false;\n }\n // read action for current state and first input\n t = (table[state] && table[state][symbol]) || NO_ACTION;\n newState = t[1];\n action = t[0];\n\n if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action });\n\n // encountered another parse error? If so, break out to main loop\n // and take it from there!\n if (!action) {\n if (yydebug) yydebug('**NESTED ERROR DETECTED** while still recovering from previous error');\n\n ASSERT(recoveringErrorInfo, \"line 1087\");\n\n // Prep state variables so that upon breaking out of\n // this \"slow parse loop\" and hitting the `continue;`\n // statement in the outer \"fast parse loop\" we redo\n // the exact same state table lookup as the one above\n // so that the outer=main loop will also correctly\n // detect the 'parse error' state (`!action`) we have\n // just encountered above.\n newState = state;\n break;\n }\n }\n\n if (yydebug) yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) {\n \"use strict\";\n\n if (!nt || !nt.states || !nt.rules)\n return '';\n var rulename = nt.states[state];\n var rulespec = nt.rules[rulename][state];\n return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')';\n })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol });\n\n switch (action) {\n // catch misc. parse failures:\n default:\n // this shouldn't happen, unless resolve defaults are off\n //\n // SILENTLY SIGNAL that the outer \"fast parse loop\" should\n // take care of this internal error condition:\n // prevent useless code duplication now/here.\n break;\n\n // shift:\n case 1:\n stack[sp] = symbol;\n // ### Note/Warning ###\n //\n // The *lexer* may also produce TERROR tokens on its own,\n // so we specifically test for the TERROR we did set up\n // in the error recovery logic further above!\n if (symbol === TERROR && errorSymbolFromParser) {\n // Push a special value onto the stack when we're\n // shifting the `error` symbol that is related to the\n // error we're recovering from.\n ASSERT(recoveringErrorInfo, \"line 1131\");\n vstack[sp] = recoveringErrorInfo;\n lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true);\n } else {\n ASSERT(symbol !== 0, \"line 1135\");\n ASSERT(preErrorSymbol === 0, \"line 1136\");\n vstack[sp] = lexer.yytext;\n lstack[sp] = this.copy_yylloc(lexer.yylloc);\n }\n sstack[sp] = newState; // push state\n\n ++sp;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n var tokenName = this.getSymbolName(symbol || EOF);\n if (!tokenName) {\n tokenName = symbol;\n }\n\n Jison.parserDebugger.push({\n action: 'shift',\n text: lexer.yytext,\n terminal: tokenName,\n terminal_id: symbol\n });\n }\n\n symbol = 0;\n // **Warning: Edge Case**: the *lexer* may have produced\n // TERROR tokens of its own volition: *those* TERROR\n // tokens should be treated like *regular tokens*\n // i.e. tokens which have a lexer-provided `yyvalue`\n // and `yylloc`:\n errorSymbolFromParser = false;\n if (!preErrorSymbol) { // normal execution / no error\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n\n if (recovering > 0) {\n recovering--;\n if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering: recovering, symbol: symbol });\n }\n } else {\n // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode:\n ASSERT(recovering > 0, \"line 1163\");\n symbol = preErrorSymbol;\n preErrorSymbol = 0;\n if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering: recovering, symbol: symbol });\n // read action for current state and first input\n t = (table[newState] && table[newState][symbol]) || NO_ACTION;\n if (!t[0] || symbol === TERROR) {\n // forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where\n // (simple) stuff might have been missing before the token which caused the error we're\n // recovering from now...\n //\n // Also check if the LookAhead symbol isn't the ERROR token we set as part of the error\n // recovery, for then this we would we idling (cycling) on the error forever.\n // Yes, this does not take into account the possibility that the *lexer* may have\n // produced a *new* TERROR token all by itself, but that would be a very peculiar grammar!\n if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering: recovering, symbol: symbol });\n symbol = 0;\n }\n }\n\n // once we have pushed the special ERROR token value,\n // we REMAIN in this inner, \"slow parse loop\" until\n // the entire error recovery phase has completed.\n //\n // ### Note About Edge Case ###\n //\n // Userland action code MAY already have 'reset' the\n // error recovery phase marker `recovering` to ZERO(0)\n // while the error symbol hasn't been shifted onto\n // the stack yet. Hence we only exit this \"slow parse loop\"\n // when *both* conditions are met!\n ASSERT(preErrorSymbol === 0, \"line 1194\");\n if (recovering === 0) {\n break;\n }\n continue;\n\n // reduce:\n case 2:\n this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...\n yyrulelen = this_production[1];\n\n if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol });\n\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n var prereduceValue = vstack.slice(sp - yyrulelen, sp);\n var debuggableProductions = [];\n for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) {\n var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]);\n debuggableProductions.push(debuggableProduction);\n }\n\n // find the current nonterminal name (- nolan)\n var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0];\n var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode);\n\n Jison.parserDebugger.push({\n action: 'reduce',\n nonterminal: currentNonterminal,\n nonterminal_id: currentNonterminalCode,\n prereduce: prereduceValue,\n result: r,\n productions: debuggableProductions,\n text: yyval.$\n });\n }\n\n if (typeof r !== 'undefined') {\n // signal end of error recovery loop AND end of outer parse loop\n action = 3;\n retval = r;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n sp = -2; // magic number: signal outer \"fast parse loop\" ACCEPT state that we already have a properly set up `retval` parser return value.\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // don't overwrite the `symbol` variable: use a local var to speed things up:\n var ntsymbol = this_production[0]; // push nonterminal (reduce)\n stack[sp] = ntsymbol;\n vstack[sp] = yyval.$;\n lstack[sp] = yyval._$;\n // goto new state = table[STATE][NONTERMINAL]\n newState = table[sstack[sp - 1]][ntsymbol];\n sstack[sp] = newState;\n ++sp;\n if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol });\n continue;\n\n // accept:\n case 3:\n retval = true;\n // Return the `$accept` rule's `$$` result, if available.\n //\n // Also note that JISON always adds this top-most `$accept` rule (with implicit,\n // default, action):\n //\n // $accept: $end\n // %{ $$ = $1; @$ = @1; %}\n //\n // which, combined with the parse kernel's `$accept` state behaviour coded below,\n // will produce the `$$` value output of the rule as the parse result,\n // IFF that result is *not* `undefined`. (See also the parser kernel code.)\n //\n // In code:\n //\n // %{\n // @$ = @1; // if location tracking support is included\n // if (typeof $1 !== 'undefined')\n // return $1;\n // else\n // return true; // the default parse result if the rule actions don't produce anything\n // %}\n sp--;\n if (sp >= 0 && typeof vstack[sp] !== 'undefined') {\n retval = vstack[sp];\n }\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n sp = -2; // magic number: signal outer \"fast parse loop\" ACCEPT state that we already have a properly set up `retval` parser return value.\n break;\n }\n\n // break out of loop: we accept or fail with error\n break;\n }\n\n // should we also break out of the regular/outer parse loop,\n // i.e. did the parser already produce a parse result in here?!\n // *or* did we hit an unsupported parse state, to be handled\n // in the `switch/default` code further below?\n ASSERT(action !== 2, \"line 1272\");\n if (!action || action === 1) {\n continue;\n }\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n\n // handle parse error\n if (!action) {\n var errStr;\n var errSymbolDescr = (this.describeSymbol(symbol) || symbol);\n var expected = this.collect_expected_token_set(state);\n\n // Report error\n errStr = 'Parse error';\n if (typeof lexer.yylineno === 'number') {\n errStr += ' on line ' + (lexer.yylineno + 1);\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += ':\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n } else {\n errStr += ': ';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n // we cannot recover from the error!\n p = this.constructParseErrorInfo(errStr, null, expected, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n }\n\n if (yydebug) yydebug('::: MAIN CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) {\n \"use strict\";\n\n if (!nt || !nt.states || !nt.rules)\n return '';\n var rulename = nt.states[state];\n var rulespec = nt.rules[rulename][state];\n return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')';\n })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol });\n\n switch (action) {\n // catch misc. parse failures:\n default:\n // this shouldn't happen, unless resolve defaults are off\n if (action instanceof Array) {\n p = this.constructParseErrorInfo('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol, null, null, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n // Another case of better safe than sorry: in case state transitions come out of another error recovery process\n // or a buggy LUT (LookUp Table):\n p = this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.', null, null, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n\n // shift:\n case 1:\n stack[sp] = symbol;\n vstack[sp] = lexer.yytext;\n lstack[sp] = this.copy_yylloc(lexer.yylloc);\n sstack[sp] = newState; // push state\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n var tokenName = this.getSymbolName(symbol || EOF);\n if (!tokenName) {\n tokenName = symbol;\n }\n\n Jison.parserDebugger.push({\n action: 'shift',\n text: lexer.yytext,\n terminal: tokenName,\n terminal_id: symbol\n });\n }\n\n ++sp;\n\n symbol = 0;\n\n ASSERT(preErrorSymbol === 0, \"line 1352\"); // normal execution / no error\n ASSERT(recovering === 0, \"line 1353\"); // normal execution / no error\n\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n continue;\n\n // reduce:\n case 2:\n ASSERT(preErrorSymbol === 0, \"line 1364\"); // normal execution / no error\n ASSERT(recovering === 0, \"line 1365\"); // normal execution / no error\n\n this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...\n yyrulelen = this_production[1];\n\n if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol });\n\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n var prereduceValue = vstack.slice(sp - yyrulelen, sp);\n var debuggableProductions = [];\n for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) {\n var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]);\n debuggableProductions.push(debuggableProduction);\n }\n\n // find the current nonterminal name (- nolan)\n var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0];\n var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode);\n\n Jison.parserDebugger.push({\n action: 'reduce',\n nonterminal: currentNonterminal,\n nonterminal_id: currentNonterminalCode,\n prereduce: prereduceValue,\n result: r,\n productions: debuggableProductions,\n text: yyval.$\n });\n }\n\n if (typeof r !== 'undefined') {\n retval = r;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // don't overwrite the `symbol` variable: use a local var to speed things up:\n var ntsymbol = this_production[0]; // push nonterminal (reduce)\n stack[sp] = ntsymbol;\n vstack[sp] = yyval.$;\n lstack[sp] = yyval._$;\n // goto new state = table[STATE][NONTERMINAL]\n newState = table[sstack[sp - 1]][ntsymbol];\n sstack[sp] = newState;\n ++sp;\n if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol });\n continue;\n\n // accept:\n case 3:\n if (sp !== -2) {\n retval = true;\n // Return the `$accept` rule's `$$` result, if available.\n //\n // Also note that JISON always adds this top-most `$accept` rule (with implicit,\n // default, action):\n //\n // $accept: $end\n // %{ $$ = $1; @$ = @1; %}\n //\n // which, combined with the parse kernel's `$accept` state behaviour coded below,\n // will produce the `$$` value output of the rule as the parse result,\n // IFF that result is *not* `undefined`. (See also the parser kernel code.)\n //\n // In code:\n //\n // %{\n // @$ = @1; // if location tracking support is included\n // if (typeof $1 !== 'undefined')\n // return $1;\n // else\n // return true; // the default parse result if the rule actions don't produce anything\n // %}\n sp--;\n if (typeof vstack[sp] !== 'undefined') {\n retval = vstack[sp];\n }\n }\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n break;\n }\n\n // break out of loop: we accept or fail with error\n break;\n }\n } catch (ex) {\n // report exceptions through the parseError callback too, but keep the exception intact\n // if it is a known parser or lexer error which has been thrown by parseError() already:\n if (ex instanceof this.JisonParserError) {\n throw ex;\n }\n else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) {\n throw ex;\n }\n\n p = this.constructParseErrorInfo('Parsing aborted due to exception.', ex, null, false);\n retval = false;\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n } finally {\n retval = this.cleanupAfterParse(retval, true, true);\n this.__reentrant_call_depth--;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'return',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n } // /finally\n\n return retval;\n}\n"; // --- END parser kernel --- +parser$4.parse = "\nfunction parse(input, parseParams) {\n let self = this;\n let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage)\n let sstack = new Array(128); // state stack: stores states (column storage)\n let tstack = []; // token stack (only used when `%options token_stack` support has been enabled)\n let vstack = new Array(128); // semantic value stack\n let lstack = new Array(128); // location stack\n let table = this.table;\n let sp = 0; // 'stack pointer': index into the stacks\n let yyloc;\n let yytext;\n let yylineno;\n let yyleng;\n\n let symbol = 0;\n let preErrorSymbol = 0;\n let lastEofErrorStateDepth = Infinity;\n let recoveringErrorInfo = null;\n let recovering = 0; // (only used when the grammar contains error recovery rules)\n const TERROR = this.TERROR;\n const EOF = this.EOF;\n const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3;\n const NO_ACTION = [ 0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */];\n\n let lexer;\n if (this.__lexer__) {\n lexer = this.__lexer__;\n } else {\n lexer = this.__lexer__ = Object.create(this.lexer);\n }\n\n let sharedState_yy = {\n parseError: undefined,\n quoteName: undefined,\n lexer: undefined,\n parser: undefined,\n pre_parse: undefined,\n post_parse: undefined,\n pre_lex: undefined,\n post_lex: undefined,\n parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly!\n };\n\n const ASSERT = (\n typeof assert !== 'function' ?\n function JisonAssert(cond, msg) {\n if (!cond) {\n throw new Error('assertion failed: ' + (msg || '***'));\n }\n } :\n assert\n );\n\n this.yyGetSharedState = function yyGetSharedState() {\n return sharedState_yy;\n };\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n this.yyGetErrorInfoTrack = function yyGetErrorInfoTrack() {\n return recoveringErrorInfo;\n };\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // shallow clone objects & arrays, straight copy of simple `src` values\n // e.g. `lexer.yytext` MAY be a complex value object,\n // rather than a simple string/value.\n //\n // https://jsperf.com/new-array-vs-splice-vs-slice/72\n // https://jsperf.com/instanceof-vs-typeof/20\n // benchmark:: http://127.0.0.1:8080/example/jsperf/#testfile=test0020-typeof-instanceof-isArray.json5\n // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5\n //\n function shallow_copy(src) {\n if (src && typeof src === 'object') {\n // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned\n // using their constructor:\n if (src.constructor !== Object) {\n if (Array.isArray(src)) {\n return src.slice();\n }\n let dst = new src.constructor(src);\n\n // and make sure all custom attributes are added to the clone:\n shallow_copy_noclobber(dst, src);\n return dst;\n }\n // native objects must be cloned a different way:\n {\n //return Object.assign({}, src);\n let dst = {};\n shallow_copy_noclobber(dst, src);\n return dst;\n }\n }\n return src;\n }\n // add elements from `src` to `dst` when:\n // - either the element does not yet exist in `src`\n // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst`\n function shallow_copy_noclobber(dst, src) {\n const chk = Object.prototype.hasOwnProperty;\n for (let k in src) {\n if (!(k in dst)) {\n if (chk.call(src, k)) {\n dst[k] = src[k];\n }\n } else if (src[k] != null && dst[k] == null && chk.call(src, k)) {\n dst[k] = src[k];\n }\n }\n }\n function copy_yylloc_native(loc) {\n let rv = shallow_copy(loc);\n // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries:\n if (rv) {\n rv.range = rv.range.slice();\n }\n return rv;\n }\n\n // copy state\n shallow_copy_noclobber(sharedState_yy, this.yy);\n\n sharedState_yy.lexer = lexer;\n sharedState_yy.parser = this;\n\n // allow userland code to override the yytext and yylloc copy/clone functions:\n this.copy_yytext = this.options.copy_yytext || sharedState_yy.copy_yytext || shallow_copy;\n this.copy_yylloc = this.options.copy_yylloc || sharedState_yy.copy_yylloc || copy_yylloc_native;\n\n let yydebug = false;\n if (this.options.debug) {\n yydebug = function yydebug_impl(msg, obj) {\n let ref_list;\n let ref_names;\n\n function deepClone(from, sub) {\n if (sub == null) {\n ref_list = [];\n ref_names = [];\n sub = 'root';\n }\n if (typeof from === 'function') return '[Function]';\n if (from == null || typeof from !== 'object') return from;\n if (from.constructor !== Object && from.constructor !== Array) {\n return from;\n }\n\n let i = ref_list.indexOf(from);\n if (i >= 0) {\n return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference\n }\n ref_list.push(from);\n ref_names.push(sub);\n\n let to = new from.constructor();\n for (let name in from) {\n if (name === 'parser') continue;\n if (name === 'lexer') continue;\n to[name] = deepClone(from[name], name);\n }\n return to;\n }\n\n obj = obj || {};\n if (obj.symbol) {\n obj.local_yytext = yytext;\n obj.lexer_yytext = lexer.yytext;\n obj.lexer_yylloc = lexer.yylloc;\n obj.lexer_yyllineno = lexer.yyllineno;\n }\n\n // warning: here we fetch from closure (stack et al)\n obj.symbol_stack = stack;\n obj.state_stack = sstack;\n obj.value_stack = vstack;\n obj.location_stack = lstack;\n obj.stack_pointer = sp;\n\n // ready the object for printing:\n obj = deepClone(obj);\n\n // wrap try/catch in a function to help the V8 JIT compiler...\n function yydebug_cvt(obj) {\n let js;\n try {\n let re1;\n if (typeof XRegExp === 'undefined') {\n re1 = / {2}\\\"([a-z_][a-z_0-9. ]*)\\\": /ig;\n } else {\n re1 = new XRegExp(' \\\"([\\\\p{Alphabetic}_][\\\\p{Alphabetic}\\\\p{Number}_. ]*)\\\": ', 'g');\n }\n js = JSON.stringify(obj, null, 2)\n .replace(re1, ' $1: ')\n .replace(/[\\n\\s]+/g, ' ')\n // shorten yylloc object dumps too:\n .replace(/\\{ first_line: (\\d+), first_column: (\\d+), last_line: (\\d+), last_column: (\\d+)/g, '{L/C: ($1,$2)..($3,$4)');\n } catch (ex) {\n js = String(obj);\n }\n return js;\n }\n\n self.trace(msg, yydebug_cvt(obj), '\\n');\n };\n }\n\n // disable debugging at run-time ANYWAY when you've *explicitly* set \"yy.yydebug = false\":\n if (sharedState_yy.yydebug === false) {\n yydebug = undefined;\n }\n\n // *Always* setup `yyError`, `YYRECOVERING`, `yyErrOk` and `yyClearIn` functions as it is paramount\n // to have *their* closure match ours -- if we only set them up once,\n // any subsequent `parse()` runs will fail in very obscure ways when\n // these functions are invoked in the user action code block(s) as\n // their closure will still refer to the `parse()` instance which set\n // them up. Hence we MUST set them up at the start of every `parse()` run!\n if (this.yyError) {\n this.yyError = function yyError(str /*, ...args */) {\n if (yydebug) {\n yydebug('yyerror: ', {\n message: str,\n args: arguments,\n symbol, state, newState, recovering, action\n });\n }\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1);\n let expected = this.collect_expected_token_set(state);\n let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0));\n // append to the old one?\n if (recoveringErrorInfo) {\n let esp = recoveringErrorInfo.info_stack_pointer;\n\n recoveringErrorInfo.symbol_stack[esp] = symbol;\n let v = this.shallowCopyErrorInfo(hash);\n v.yyError = true;\n v.errorRuleDepth = error_rule_depth;\n v.recovering = recovering;\n // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH;\n\n recoveringErrorInfo.value_stack[esp] = v;\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc);\n recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n } else {\n recoveringErrorInfo = this.shallowCopyErrorInfo(hash);\n recoveringErrorInfo.yyError = true;\n recoveringErrorInfo.errorRuleDepth = error_rule_depth;\n recoveringErrorInfo.recovering = recovering;\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n\n let expected = this.collect_expected_token_set(state);\n let hash = this.constructParseErrorInfo(str, null, expected, false);\n\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n let args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n hash.extra_error_attributes = args;\n }\n\n return this.parseError(str, hash, this.JisonParserError);\n };\n }\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n if (this.yyRecovering) {\n this.yyRecovering = function yyRecovering() {\n if (yydebug) yydebug('yyrecovering: ', { symbol, state, newState, recovering, action });\n return recovering;\n };\n }\n\n if (this.yyErrOk) {\n this.yyErrOk = function yyErrOk() {\n if (yydebug) yydebug('yyerrok: ', { symbol, state, newState, recovering, action });\n recovering = 0;\n\n // DO NOT reset/cleanup `recoveringErrorInfo` yet: userland code\n // MAY invoke this API before the error is actually fully\n // recovered, in which case the parser recovery code won't be able\n // to append the skipped tokens to this info object.\n //\n // The rest of the kernel code is safe enough that it won't inadvertedly\n // re-use an old `recoveringErrorInfo` chunk so we'ld better wait\n // with destruction/cleanup until the end of the parse or until another\n // fresh parse error rears its ugly head...\n //\n // if (recoveringErrorInfo && typeof recoveringErrorInfo.destroy === 'function') {\n // recoveringErrorInfo.destroy();\n // recoveringErrorInfo = undefined;\n // }\n };\n }\n\n if (this.yyClearIn) {\n this.yyClearIn = function yyClearIn() {\n if (yydebug) yydebug('yyclearin: ', { symbol, newState, recovering, action, preErrorSymbol });\n if (symbol === TERROR) {\n symbol = 0;\n yytext = null;\n yyleng = 0;\n yyloc = undefined;\n }\n preErrorSymbol = 0;\n };\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // Does the shared state override the default `parseError` that already comes with this instance?\n if (typeof sharedState_yy.parseError === 'function') {\n this.parseError = function parseErrorAlt(str, hash, ExceptionClass) {\n if (!ExceptionClass) {\n ExceptionClass = this.JisonParserError;\n }\n return sharedState_yy.parseError.call(this, str, hash, ExceptionClass);\n };\n } else {\n this.parseError = this.originalParseError;\n }\n\n // Does the shared state override the default `quoteName` that already comes with this instance?\n if (typeof sharedState_yy.quoteName === 'function') {\n this.quoteName = function quoteNameAlt(id_str) {\n return sharedState_yy.quoteName.call(this, id_str);\n };\n } else {\n this.quoteName = this.originalQuoteName;\n }\n\n // set up the cleanup function; make it an API so that external code can re-use this one in case of\n // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which\n // case this parse() API method doesn't come with a `finally { ... }` block any more!\n //\n // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,\n // or else your `sharedState`, etc. references will be *wrong*!\n this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) {\n let rv;\n\n if (invoke_post_methods) {\n let hash;\n\n if (sharedState_yy.post_parse || this.post_parse) {\n // create an error hash info instance: we re-use this API in a **non-error situation**\n // as this one delivers all parser internals ready for access by userland code.\n hash = this.constructParseErrorInfo(null /* no error! */, null /* no exception! */, null, false);\n }\n\n if (sharedState_yy.post_parse) {\n rv = sharedState_yy.post_parse.call(this, sharedState_yy, resultValue, hash);\n if (typeof rv !== 'undefined') resultValue = rv;\n }\n if (this.post_parse) {\n rv = this.post_parse.call(this, sharedState_yy, resultValue, hash);\n if (typeof rv !== 'undefined') resultValue = rv;\n }\n\n // cleanup:\n if (hash && hash.destroy) {\n hash.destroy();\n }\n }\n\n if (this.__reentrant_call_depth > 1) return resultValue; // do not (yet) kill the sharedState when this is a reentrant run.\n\n // clean up the lingering lexer structures as well:\n if (lexer.cleanupAfterLex) {\n lexer.cleanupAfterLex(do_not_nuke_errorinfos);\n }\n\n // prevent lingering circular references from causing memory leaks:\n if (sharedState_yy) {\n sharedState_yy.lexer = undefined;\n sharedState_yy.parser = undefined;\n if (lexer.yy === sharedState_yy) {\n lexer.yy = undefined;\n }\n }\n sharedState_yy = undefined;\n this.parseError = this.originalParseError;\n this.quoteName = this.originalQuoteName;\n\n // nuke the vstack[] array at least as that one will still reference obsoleted user values.\n // To be safe, we nuke the other internal stack columns as well...\n stack.length = 0; // fastest way to nuke an array without overly bothering the GC\n sstack.length = 0;\n lstack.length = 0;\n vstack.length = 0;\n sp = 0;\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (let i = this.__error_infos.length - 1; i >= 0; i--) {\n let el = this.__error_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) {\n let el = this.__error_recovery_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_recovery_infos.length = 0;\n\n // `recoveringErrorInfo` is also part of the `__error_recovery_infos` array,\n // hence has been destroyed already: no need to do that *twice*.\n if (recoveringErrorInfo) {\n recoveringErrorInfo = undefined;\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n }\n\n return resultValue;\n };\n\n // merge yylloc info into a new yylloc instance.\n //\n // `first_index` and `last_index` MAY be UNDEFINED/NULL or these are indexes into the `lstack[]` location stack array.\n //\n // `first_yylloc` and `last_yylloc` MAY be UNDEFINED/NULL or explicit (custom or regular) `yylloc` instances, in which\n // case these override the corresponding first/last indexes.\n //\n // `dont_look_back` is an optional flag (default: FALSE), which instructs this merge operation NOT to search\n // through the parse location stack for a location, which would otherwise be used to construct the new (epsilon!)\n // yylloc info.\n //\n // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL.\n this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) {\n let i1 = first_index | 0;\n let i2 = last_index | 0;\n let l1 = first_yylloc;\n let l2 = last_yylloc;\n let rv;\n\n // rules:\n // - first/last yylloc entries override first/last indexes\n\n if (!l1) {\n if (first_index != null) {\n for (let i = i1; i <= i2; i++) {\n l1 = lstack[i];\n if (l1) {\n break;\n }\n }\n }\n }\n\n if (!l2) {\n if (last_index != null) {\n for (let i = i2; i >= i1; i--) {\n l2 = lstack[i];\n if (l2) {\n break;\n }\n }\n }\n }\n\n // - detect if an epsilon rule is being processed and act accordingly:\n if (!l1 && first_index == null) {\n // epsilon rule span merger. With optional look-ahead in l2.\n if (!dont_look_back) {\n for (let i = (i1 || sp) - 1; i >= 0; i--) {\n l1 = lstack[i];\n if (l1) {\n break;\n }\n }\n }\n if (!l1) {\n if (!l2) {\n // when we still don't have any valid yylloc info, we're looking at an epsilon rule\n // without look-ahead and no preceding terms and/or `dont_look_back` set:\n // in that case we ca do nothing but return NULL/UNDEFINED:\n return null;\n }\n // shallow-copy L2: after all, we MAY be looking\n // at unconventional yylloc info objects...\n rv = this.copy_yylloc(l2);\n return rv;\n }\n // shallow-copy L1, then adjust first col/row 1 column past the end.\n rv = this.copy_yylloc(l1);\n rv.first_line = rv.last_line;\n rv.first_column = rv.last_column;\n rv.range[0] = rv.range[1];\n\n if (l2) {\n // shallow-mixin L2, then adjust last col/row accordingly.\n shallow_copy_noclobber(rv, l2);\n rv.last_line = l2.last_line;\n rv.last_column = l2.last_column;\n rv.range[1] = l2.range[1];\n }\n return rv;\n }\n\n if (!l1) {\n l1 = l2;\n l2 = null;\n }\n if (!l1) {\n return null;\n }\n\n // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking\n // at unconventional yylloc info objects...\n rv = this.copy_yylloc(l1);\n\n if (l2) {\n shallow_copy_noclobber(rv, l2);\n rv.last_line = l2.last_line;\n rv.last_column = l2.last_column;\n rv.range[1] = l2.range[1];\n }\n\n return rv;\n };\n\n // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,\n // or else your `lexer`, `sharedState`, etc. references will be *wrong*!\n this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) {\n const pei = {\n errStr: msg,\n exception: ex,\n text: lexer.match,\n value: this.copy_yytext(lexer.yytext),\n token: this.describeSymbol(symbol) || symbol,\n token_id: symbol,\n line: lexer.yylineno,\n loc: this.copy_yylloc(lexer.yylloc),\n expected,\n recoverable,\n state,\n action,\n new_state: newState,\n symbol_stack: stack,\n state_stack: sstack,\n value_stack: vstack,\n location_stack: lstack,\n stack_pointer: sp,\n yy: sharedState_yy,\n lexer,\n parser: this,\n\n // and make sure the error info doesn't stay due to potential\n // ref cycle via userland code manipulations.\n // These would otherwise all be memory leak opportunities!\n //\n // Note that only array and object references are nuked as those\n // constitute the set of elements which can produce a cyclic ref.\n // The rest of the members is kept intact as they are harmless.\n destroy: function destructParseErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // info.value = null;\n // info.value_stack = null;\n // ...\n const rec = !!this.recoverable;\n for (let key in this) {\n if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n };\n\n // clone some parts of the (possibly enhanced!) errorInfo object\n // to give them some persistence.\n this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) {\n let rv = shallow_copy(p);\n\n // remove the large parts which can only cause cyclic references\n // and are otherwise available from the parser kernel anyway.\n delete rv.sharedState_yy;\n delete rv.parser;\n delete rv.lexer;\n\n // lexer.yytext MAY be a complex value object, rather than a simple string/value:\n rv.value = this.copy_yytext(rv.value);\n\n // yylloc info:\n rv.loc = this.copy_yylloc(rv.loc);\n\n // the 'expected' set won't be modified, so no need to clone it:\n //rv.expected = rv.expected.slice();\n\n // symbol stack is a simple array:\n rv.symbol_stack = rv.symbol_stack.slice();\n // ditto for state stack:\n rv.state_stack = rv.state_stack.slice();\n // clone the yylloc's in the location stack?:\n rv.location_stack = rv.location_stack.map(this.copy_yylloc);\n // and the value stack may carry both simple and complex values:\n // shallow-copy the latter.\n rv.value_stack = rv.value_stack.map(this.copy_yytext);\n\n // and we don't bother with the sharedState_yy reference:\n //delete rv.yy;\n\n // now we prepare for tracking the COMBINE actions\n // in the error recovery code path:\n //\n // as we want to keep the maximum error info context, we\n // *scan* the state stack to find the first *empty* slot.\n // This position will surely be AT OR ABOVE the current\n // stack pointer, but we want to keep the 'used but discarded'\n // part of the parse stacks *intact* as those slots carry\n // error context that may be useful when you want to produce\n // very detailed error diagnostic reports.\n //\n // ### Purpose of each stack pointer:\n //\n // - stack_pointer: points at the top of the parse stack\n // **as it existed at the time of the error\n // occurrence, i.e. at the time the stack\n // snapshot was taken and copied into the\n // errorInfo object.**\n // - base_pointer: the bottom of the **empty part** of the\n // stack, i.e. **the start of the rest of\n // the stack space /above/ the existing\n // parse stack. This section will be filled\n // by the error recovery process as it\n // travels the parse state machine to\n // arrive at the resolving error recovery rule.**\n // - info_stack_pointer:\n // this stack pointer points to the **top of\n // the error recovery tracking stack space**, i.e.\n // this stack pointer takes up the role of\n // the `stack_pointer` for the error recovery\n // process. Any mutations in the **parse stack**\n // are **copy-appended** to this part of the\n // stack space, keeping the bottom part of the\n // stack (the 'snapshot' part where the parse\n // state at the time of error occurrence was kept)\n // intact.\n // - root_failure_pointer:\n // copy of the `stack_pointer`...\n //\n {\n let i;\n for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) {\n // empty\n }\n rv.base_pointer = i;\n rv.info_stack_pointer = i;\n }\n\n rv.root_failure_pointer = rv.stack_pointer;\n\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_recovery_infos.push(rv);\n\n return rv;\n };\n\n function getNonTerminalFromCode(symbol) {\n let tokenName = self.getSymbolName(symbol);\n if (!tokenName) {\n tokenName = symbol;\n }\n return tokenName;\n }\n\n//_lexer_without_token_stack:\n\n function stdLex() {\n let token = lexer.lex();\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n let tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n function fastLex() {\n let token = lexer.fastLex();\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n let tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n let lex = stdLex;\n\n//_lexer_with_token_stack:\n\n // lex function that supports token stacks\n function tokenStackLex() {\n let token;\n token = tstack.pop() || lexer.lex() || EOF;\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n if (token instanceof Array) {\n // tokenstack CANNOT be nested, i.e. an 'array'-type token\n // now means the `tstack` is empty as this array of tokens\n // could only have originated from the `lexer.lex()`\n // call:\n tstack = token;\n token = tstack.pop();\n }\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n let tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n//_lexer_with_token_stack_end:\n\n let state, action, r, t;\n let yyval = {\n $: true,\n _$: undefined,\n yy: sharedState_yy\n };\n let p;\n let yyrulelen;\n let this_production;\n let newState;\n let retval = false;\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n // Return the rule stack depth where the nearest error rule can be found.\n // Return -1 when no error recovery rule was found.\n function locateNearestErrorRecoveryRule(state) {\n let stack_probe = sp - 1;\n let depth = 0;\n\n // try to recover from error\n while (stack_probe >= 0) {\n // check for error recovery rule in this state\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #test#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n const t = (table[state] && table[state][TERROR]) || NO_ACTION;\n if (t[0]) {\n // We need to make sure we're not cycling forever:\n // once we hit EOF, even when we `yyerrok()` an error, we must\n // prevent the core from running forever,\n // e.g. when parent rules are still expecting certain input to\n // follow after this, for example when you handle an error inside a set\n // of braces which are matched by a parent rule in your grammar.\n //\n // Hence we require that every error handling/recovery attempt\n // *after we've hit EOF* has a diminishing state stack: this means\n // we will ultimately have unwound the state stack entirely and thus\n // terminate the parse in a controlled fashion even when we have\n // very complex error/recovery code interplay in the core + user\n // action code blocks:\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #found#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n if (symbol === EOF) {\n if (lastEofErrorStateDepth > sp - 1 - depth) {\n lastEofErrorStateDepth = sp - 1 - depth;\n } else {\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #skip#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n --stack_probe; // popStack(1): [symbol, action]\n state = sstack[stack_probe];\n ++depth;\n continue;\n }\n }\n return depth;\n }\n if (state === 0 /* $accept rule */ || stack_probe < 1) {\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n return -1; // No suitable error recovery rule available.\n }\n --stack_probe; // popStack(1): [symbol, action]\n state = sstack[stack_probe];\n ++depth;\n }\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n return -1; // No suitable error recovery rule available.\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n try {\n this.__reentrant_call_depth++;\n\n lexer.setInput(input, sharedState_yy);\n\n // NOTE: we *assume* no lexer pre/post handlers are set up *after*\n // this initial `setInput()` call: hence we can now check and decide\n // whether we'll go with the standard, slower, lex() API or the\n // `fast_lex()` one:\n if (typeof lexer.canIUse === 'function') {\n let lexerInfo = lexer.canIUse();\n if (lexerInfo.fastLex && typeof fastLex === 'function') {\n lex = fastLex;\n }\n }\n\n yyloc = this.copy_yylloc(lexer.yylloc);\n lstack[sp] = yyloc;\n vstack[sp] = null;\n sstack[sp] = 0;\n stack[sp] = 0;\n ++sp;\n\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyleng = lexer.yyleng;\n\n if (this.pre_parse) {\n this.pre_parse.call(this, sharedState_yy);\n }\n if (sharedState_yy.pre_parse) {\n sharedState_yy.pre_parse.call(this, sharedState_yy);\n }\n\n newState = sstack[sp - 1];\n for (;;) {\n // retrieve state number from top of stack\n state = newState; // sstack[sp - 1];\n\n // use default actions if available\n if (this.defaultActions[state]) {\n action = 2;\n newState = this.defaultActions[state];\n } else {\n // The single `==` condition below covers both these `===` comparisons in a single\n // operation:\n //\n // if (symbol === null || typeof symbol === 'undefined') ...\n if (!symbol) {\n symbol = lex();\n }\n // read action for current state and first input\n t = (table[state] && table[state][symbol]) || NO_ACTION;\n newState = t[1];\n action = t[0];\n\n if (yydebug) {\n yydebug('after FETCH/LEX: ', {\n symbol,\n symbolID: this.terminals_ && this.terminals_[symbol],\n state, newState, recovering, action\n });\n }\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n // handle parse error\n if (!action) {\n // first see if there's any chance at hitting an error recovery rule:\n let error_rule_depth = locateNearestErrorRecoveryRule(state);\n let errStr = null;\n let errSymbolDescr = (this.describeSymbol(symbol) || symbol);\n let expected = this.collect_expected_token_set(state);\n\n if (!recovering) {\n // Report error\n errStr = 'Parse error';\n if (typeof lexer.yylineno === 'number') {\n errStr += ' on line ' + (lexer.yylineno + 1);\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += ':\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n } else {\n errStr += ': ';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n\n p = this.constructParseErrorInfo(errStr, null, expected, (error_rule_depth >= 0));\n\n // DO NOT cleanup the old one before we start the new error info track:\n // the old one will *linger* on the error stack and stay alive until we\n // invoke the parser's cleanup API!\n recoveringErrorInfo = this.shallowCopyErrorInfo(p);\n\n if (yydebug) {\n yydebug('error recovery rule detected: ', {\n error_rule_depth,\n error: p.errStr,\n error_hash: p\n });\n }\n\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n break;\n }\n\n // Protect against overly blunt userland `parseError` code which *sets*\n // the `recoverable` flag without properly checking first:\n // we always terminate the parse when there's no recovery rule available anyhow!\n if (!p.recoverable || error_rule_depth < 0) {\n break;\n } else {\n // TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process...\n }\n }\n\n if (yydebug) {\n yydebug('after ERROR DETECT: ', {\n error_rule_depth,\n error: p.errStr,\n error_hash: p\n });\n }\n\n let esp = recoveringErrorInfo.info_stack_pointer;\n\n // just recovered from another error\n if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) {\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = this.copy_yytext(lexer.yytext);\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n\n // SHIFT current lookahead and grab another\n recoveringErrorInfo.symbol_stack[esp] = symbol;\n recoveringErrorInfo.value_stack[esp] = yytext;\n recoveringErrorInfo.location_stack[esp] = yyloc;\n recoveringErrorInfo.state_stack[esp] = newState; // push state\n ++esp;\n\n preErrorSymbol = 0;\n symbol = lex();\n\n if (yydebug) {\n yydebug('after ERROR RECOVERY-3: ', {\n symbol,\n symbolID: this.terminals_ && this.terminals_[symbol]\n });\n }\n }\n\n // try to recover from error\n if (error_rule_depth < 0) {\n ASSERT(recovering > 0, 'Line 1048');\n recoveringErrorInfo.info_stack_pointer = esp;\n\n // barf a fatal hairball when we're out of look-ahead symbols and none hit a match\n // while we are still busy recovering from another error:\n let po = this.__error_infos[this.__error_infos.length - 1];\n\n // Report error\n if (typeof lexer.yylineno === 'number') {\n errStr = 'Parsing halted on line ' + (lexer.yylineno + 1) + ' while starting to recover from another error';\n } else {\n errStr = 'Parsing halted while starting to recover from another error';\n }\n\n if (po) {\n errStr += ' -- previous error which resulted in this fatal result: ' + po.errStr;\n } else {\n errStr += ': ';\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += '\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n\n p = this.constructParseErrorInfo(errStr, null, expected, false);\n if (po) {\n p.extra_error_attributes = po;\n }\n\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n\n preErrorSymbol = (symbol === TERROR ? 0 : symbol); // save the lookahead token\n symbol = TERROR; // insert generic error symbol as new lookahead\n\n const EXTRA_STACK_SAMPLE_DEPTH = 3;\n\n // REDUCE/COMBINE the pushed terms/tokens to a new ERROR token:\n recoveringErrorInfo.symbol_stack[esp] = preErrorSymbol;\n if (errStr) {\n recoveringErrorInfo.value_stack[esp] = {\n yytext: this.copy_yytext(lexer.yytext),\n errorRuleDepth: error_rule_depth,\n errStr,\n errSymbolDescr,\n expectedStr: expected,\n stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH\n };\n if (yydebug) {\n yydebug('Error recovery process: pushed error info item on the info stack: ', {\n item: vstack[sp],\n sp, esp, vstack, stack, sstack,\n combineState: NO_ACTION[1]\n });\n }\n } else {\n recoveringErrorInfo.value_stack[esp] = {\n yytext: this.copy_yytext(lexer.yytext),\n errorRuleDepth: error_rule_depth,\n stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH\n };\n }\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc);\n recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n\n yyval.$ = recoveringErrorInfo;\n yyval._$ = undefined;\n\n yyrulelen = error_rule_depth;\n\n let combineState = NO_ACTION[1];\n\n if (yydebug) {\n yydebug('Error recovery process: performAction: COMBINE: ', {\n yyval, yytext, sp,\n pop_size: yyrulelen,\n vstack, stack, sstack,\n combineState\n });\n }\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, combineState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof r !== 'undefined') {\n retval = r;\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // and move the top entries + discarded part of the parse stacks onto the error info stack:\n for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) {\n recoveringErrorInfo.symbol_stack[esp] = stack[idx];\n recoveringErrorInfo.value_stack[esp] = vstack[idx];\n recoveringErrorInfo.location_stack[esp] = lstack[idx];\n recoveringErrorInfo.state_stack[esp] = sstack[idx];\n }\n\n recoveringErrorInfo.symbol_stack[esp] = TERROR;\n recoveringErrorInfo.value_stack[esp] = this.copy_yytext(yyval.$);\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(yyval._$);\n\n // goto new state = table[STATE][NONTERMINAL]\n newState = sstack[sp - 1];\n\n if (this.defaultActions[newState]) {\n recoveringErrorInfo.state_stack[esp] = this.defaultActions[newState];\n } else {\n t = (table[newState] && table[newState][symbol]) || NO_ACTION;\n recoveringErrorInfo.state_stack[esp] = t[1];\n }\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n\n // allow N (default: 3) real symbols to be shifted before reporting a new error\n recovering = ERROR_RECOVERY_TOKEN_DISCARD_COUNT;\n\n if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth, symbol, preErrorSymbol });\n\n // Now duplicate the standard parse machine here, at least its initial\n // couple of rounds until the TERROR symbol is **pushed onto the parse stack**,\n // as we wish to push something special then!\n //\n // Run the state machine in this copy of the parser state machine\n // until we *either* consume the error symbol (and its related information)\n // *or* we run into another error while recovering from this one\n // *or* we execute a `reduce` action which outputs a final parse\n // result (yes, that MAY happen!).\n //\n // We stay in this secondary parse loop until we have completed\n // the *error recovery phase* as the main parse loop (further below)\n // is optimized for regular parse operation and DOES NOT cope with\n // error recovery *at all*.\n //\n // We call the secondary parse loop just below the \"slow parse loop\",\n // while the main parse loop, which is an almost-duplicate of this one,\n // yet optimized for regular parse operation, is called the \"fast\n // parse loop\".\n //\n // Compare this to `bison` & (vanilla) `jison`, both of which have\n // only a single parse loop, which handles everything. Our goal is\n // to eke out every drop of performance in the main parse loop...\n\n ASSERT(recoveringErrorInfo, 'Line 1204');\n ASSERT(symbol === TERROR, 'Line 1205');\n ASSERT(!action, 'Line 1206');\n let errorSymbolFromParser = true;\n for (;;) {\n // retrieve state number from top of stack\n state = newState; // sstack[sp - 1];\n\n // use default actions if available\n if (this.defaultActions[state]) {\n action = 2;\n newState = this.defaultActions[state];\n } else {\n // The single `==` condition below covers both these `===` comparisons in a single\n // operation:\n //\n // if (symbol === null || typeof symbol === 'undefined') ...\n if (!symbol) {\n symbol = lex();\n // **Warning: Edge Case**: the *lexer* may produce\n // TERROR tokens of its own volition: *those* TERROR\n // tokens should be treated like *regular tokens*\n // i.e. tokens which have a lexer-provided `yyvalue`\n // and `yylloc`:\n errorSymbolFromParser = false;\n }\n // read action for current state and first input\n t = (table[state] && table[state][symbol]) || NO_ACTION;\n newState = t[1];\n action = t[0];\n\n if (yydebug) {\n yydebug('after FETCH/LEX: ', {\n symbol,\n symbolID: this.terminals_ && this.terminals_[symbol],\n state, newState, recovering, action\n });\n }\n\n // encountered another parse error? If so, break out to main loop\n // and take it from there!\n if (!action) {\n if (yydebug) yydebug('**NESTED ERROR DETECTED** while still recovering from previous error');\n\n ASSERT(recoveringErrorInfo, 'Line 1248');\n\n // Prep state variables so that upon breaking out of\n // this \"slow parse loop\" and hitting the `continue;`\n // statement in the outer \"fast parse loop\" we redo\n // the exact same state table lookup as the one above\n // so that the outer=main loop will also correctly\n // detect the 'parse error' state (`!action`) we have\n // just encountered above.\n newState = state;\n break;\n }\n }\n\n if (yydebug) {\n yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' +\n (action === 1 ?\n 'shift token ' + symbol + ' (then go to state ' + newState + ')' :\n action === 2 ?\n 'reduce by rule: ' + newState + (function __print_rule(nt, state) {\n if (!nt || !nt.states || !nt.rules) {\n return '';\n }\n let rulename = nt.states[state];\n let rulespec = nt.rules[rulename][state];\n return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')';\n })(this.nonterminals_, newState) :\n action === 3 ?\n 'accept' :\n '???unexpected???'\n ), {\n action, newState, recovering, symbol\n });\n }\n\n switch (action) {\n // catch misc. parse failures:\n default:\n // this shouldn't happen, unless resolve defaults are off\n //\n // SILENTLY SIGNAL that the outer \"fast parse loop\" should\n // take care of this internal error condition:\n // prevent useless code duplication now/here.\n break;\n\n // shift:\n case 1:\n stack[sp] = symbol;\n // ### Note/Warning ###\n //\n // The *lexer* may also produce TERROR tokens on its own,\n // so we specifically test for the TERROR we did set up\n // in the error recovery logic further above!\n if (symbol === TERROR && errorSymbolFromParser) {\n // Push a special value onto the stack when we're\n // shifting the `error` symbol that is related to the\n // error we're recovering from.\n ASSERT(recoveringErrorInfo, 'Line 1305');\n vstack[sp] = recoveringErrorInfo;\n lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true);\n } else {\n ASSERT(symbol !== 0, 'Line 1309');\n ASSERT(preErrorSymbol === 0, 'Line 1310');\n vstack[sp] = lexer.yytext;\n lstack[sp] = this.copy_yylloc(lexer.yylloc);\n }\n sstack[sp] = newState; // push state\n\n ++sp;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n let tokenName = this.getSymbolName(symbol || EOF);\n if (!tokenName) {\n tokenName = symbol;\n }\n\n Jison.parserDebugger.push({\n action: 'shift',\n text: lexer.yytext,\n terminal: tokenName,\n terminal_id: symbol\n });\n }\n\n symbol = 0;\n // **Warning: Edge Case**: the *lexer* may have produced\n // TERROR tokens of its own volition: *those* TERROR\n // tokens should be treated like *regular tokens*\n // i.e. tokens which have a lexer-provided `yyvalue`\n // and `yylloc`:\n errorSymbolFromParser = false;\n if (!preErrorSymbol) { // normal execution / no error\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n\n if (recovering > 0) {\n recovering--;\n if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering, symbol });\n }\n } else {\n // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode:\n ASSERT(recovering > 0, 'Line 1352');\n symbol = preErrorSymbol;\n preErrorSymbol = 0;\n if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering, symbol });\n // read action for current state and first input\n t = (table[newState] && table[newState][symbol]) || NO_ACTION;\n if (!t[0] || symbol === TERROR) {\n // forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where\n // (simple) stuff might have been missing before the token which caused the error we're\n // recovering from now...\n //\n // Also check if the LookAhead symbol isn't the ERROR token we set as part of the error\n // recovery, for then this we would we idling (cycling) on the error forever.\n // Yes, this does not take into account the possibility that the *lexer* may have\n // produced a *new* TERROR token all by itself, but that would be a very peculiar grammar!\n if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering, symbol });\n symbol = 0;\n }\n }\n\n // once we have pushed the special ERROR token value,\n // we REMAIN in this inner, \"slow parse loop\" until\n // the entire error recovery phase has completed.\n //\n // ### Note About Edge Case ###\n //\n // Userland action code MAY already have 'reset' the\n // error recovery phase marker `recovering` to ZERO(0)\n // while the error symbol hasn't been shifted onto\n // the stack yet. Hence we only exit this \"slow parse loop\"\n // when *both* conditions are met!\n ASSERT(preErrorSymbol === 0, 'Line 1383');\n if (recovering === 0) {\n break;\n }\n continue;\n\n // reduce:\n case 2:\n this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...\n yyrulelen = this_production[1];\n\n if (yydebug) {\n yydebug('~~~ REDUCE: ', {\n pop_size: yyrulelen,\n newState, recovering, symbol\n });\n }\n\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n let prereduceValue = vstack.slice(sp - yyrulelen, sp);\n let debuggableProductions = [];\n for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) {\n let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]);\n debuggableProductions.push(debuggableProduction);\n }\n\n // find the current nonterminal name (- nolan)\n let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0];\n let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode);\n\n Jison.parserDebugger.push({\n action: 'reduce',\n nonterminal: currentNonterminal,\n nonterminal_id: currentNonterminalCode,\n prereduce: prereduceValue,\n result: r,\n productions: debuggableProductions,\n text: yyval.$\n });\n }\n\n if (typeof r !== 'undefined') {\n // signal end of error recovery loop AND end of outer parse loop\n action = 3;\n retval = r;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n sp = -2; // magic number: signal outer \"fast parse loop\" ACCEPT state that we already have a properly set up `retval` parser return value.\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // don't overwrite the `symbol` variable: use a local var to speed things up:\n {\n let ntsymbol = this_production[0]; // push nonterminal (reduce)\n stack[sp] = ntsymbol;\n vstack[sp] = yyval.$;\n lstack[sp] = yyval._$;\n // goto new state = table[STATE][NONTERMINAL]\n newState = table[sstack[sp - 1]][ntsymbol];\n sstack[sp] = newState;\n ++sp;\n if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol });\n }\n continue;\n\n // accept:\n case 3:\n retval = true;\n // Return the `$accept` rule's `$$` result, if available.\n //\n // Also note that JISON always adds this top-most `$accept` rule (with implicit,\n // default, action):\n //\n // $accept: $end\n // %{ $$ = $1; @$ = @1; %}\n //\n // which, combined with the parse kernel's `$accept` state behaviour coded below,\n // will produce the `$$` value output of the rule as the parse result,\n // IFF that result is *not* `undefined`. (See also the parser kernel code.)\n //\n // In code:\n //\n // %{\n // @$ = @1; // if location tracking support is included\n // if (typeof $1 !== 'undefined')\n // return $1;\n // else\n // return true; // the default parse result if the rule actions don't produce anything\n // %}\n sp--;\n if (sp >= 0 && typeof vstack[sp] !== 'undefined') {\n retval = vstack[sp];\n }\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n sp = -2; // magic number: signal outer \"fast parse loop\" ACCEPT state that we already have a properly set up `retval` parser return value.\n break;\n }\n\n // break out of loop: we accept or fail with error\n break;\n }\n\n // should we also break out of the regular/outer parse loop,\n // i.e. did the parser already produce a parse result in here?!\n // *or* did we hit an unsupported parse state, to be handled\n // in the `switch/default` code further below?\n ASSERT(action !== 2, 'Line 1509');\n if (!action || action === 1) {\n continue;\n }\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n\n // handle parse error\n if (!action) {\n let errStr;\n let errSymbolDescr = (this.describeSymbol(symbol) || symbol);\n let expected = this.collect_expected_token_set(state);\n\n // Report error\n errStr = 'Parse error';\n if (typeof lexer.yylineno === 'number') {\n errStr += ' on line ' + (lexer.yylineno + 1);\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += ':\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n } else {\n errStr += ': ';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n // we cannot recover from the error!\n p = this.constructParseErrorInfo(errStr, null, expected, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n }\n\n if (yydebug) {\n yydebug('::: MAIN CYCLE action: ' +\n (action === 1 ?\n 'shift token ' + symbol + ' (then go to state ' + newState + ')' :\n action === 2 ?\n 'reduce by rule: ' + newState + (function __print_rule(nt, state) {\n if (!nt || !nt.states || !nt.rules) {\n return '';\n }\n let rulename = nt.states[state];\n let rulespec = nt.rules[rulename][state];\n return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')';\n })(this.nonterminals_, newState) :\n action === 3 ?\n 'accept' :\n '???unexpected???'\n ), {\n action, newState, recovering, symbol\n });\n }\n\n switch (action) {\n // catch misc. parse failures:\n default:\n // this shouldn't happen, unless resolve defaults are off\n if (action instanceof Array) {\n p = this.constructParseErrorInfo('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol, null, null, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n // Another case of better safe than sorry: in case state transitions come out of another error recovery process\n // or a buggy LUT (LookUp Table):\n p = this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.', null, null, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n\n // shift:\n case 1:\n stack[sp] = symbol;\n vstack[sp] = lexer.yytext;\n lstack[sp] = this.copy_yylloc(lexer.yylloc);\n sstack[sp] = newState; // push state\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n let tokenName = this.getSymbolName(symbol || EOF);\n if (!tokenName) {\n tokenName = symbol;\n }\n\n Jison.parserDebugger.push({\n action: 'shift',\n text: lexer.yytext,\n terminal: tokenName,\n terminal_id: symbol\n });\n }\n\n ++sp;\n\n symbol = 0;\n\n ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error\n ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error\n\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n continue;\n\n // reduce:\n case 2:\n ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error\n ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error\n\n this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...\n yyrulelen = this_production[1];\n\n if (yydebug) {\n yydebug('~~~ REDUCE: ', {\n pop_size: yyrulelen,\n newState, recovering, symbol\n });\n }\n\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n let prereduceValue = vstack.slice(sp - yyrulelen, sp);\n let debuggableProductions = [];\n for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) {\n let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]);\n debuggableProductions.push(debuggableProduction);\n }\n\n // find the current nonterminal name (- nolan)\n let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0];\n let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode);\n\n Jison.parserDebugger.push({\n action: 'reduce',\n nonterminal: currentNonterminal,\n nonterminal_id: currentNonterminalCode,\n prereduce: prereduceValue,\n result: r,\n productions: debuggableProductions,\n text: yyval.$\n });\n }\n\n if (typeof r !== 'undefined') {\n retval = r;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // don't overwrite the `symbol` variable: use a local var to speed things up:\n {\n let ntsymbol = this_production[0]; // push nonterminal (reduce)\n stack[sp] = ntsymbol;\n vstack[sp] = yyval.$;\n lstack[sp] = yyval._$;\n // goto new state = table[STATE][NONTERMINAL]\n newState = table[sstack[sp - 1]][ntsymbol];\n sstack[sp] = newState;\n ++sp;\n if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol });\n }\n continue;\n\n // accept:\n case 3:\n if (sp !== -2) {\n retval = true;\n // Return the `$accept` rule's `$$` result, if available.\n //\n // Also note that JISON always adds this top-most `$accept` rule (with implicit,\n // default, action):\n //\n // $accept: $end\n // %{ $$ = $1; @$ = @1; %}\n //\n // which, combined with the parse kernel's `$accept` state behaviour coded below,\n // will produce the `$$` value output of the rule as the parse result,\n // IFF that result is *not* `undefined`. (See also the parser kernel code.)\n //\n // In code:\n //\n // %{\n // @$ = @1; // if location tracking support is included\n // if (typeof $1 !== 'undefined')\n // return $1;\n // else\n // return true; // the default parse result if the rule actions don't produce anything\n // %}\n sp--;\n if (typeof vstack[sp] !== 'undefined') {\n retval = vstack[sp];\n }\n }\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n break;\n }\n\n // break out of loop: we accept or fail with error\n break;\n }\n } catch (ex) {\n // report exceptions through the parseError callback too, but keep the exception intact\n // if it is a known parser or lexer error which has been thrown by parseError() already:\n if (ex instanceof this.JisonParserError) {\n throw ex;\n } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) {\n throw ex;\n }\n\n p = this.constructParseErrorInfo('Parsing aborted due to exception.', ex, null, false);\n retval = false;\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n } finally {\n retval = this.cleanupAfterParse(retval, true, true);\n this.__reentrant_call_depth--;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'return',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n } // /finally\n\n return retval;\n}\n"; // --- END parser kernel --- /* * LR(0) Parser @@ -28305,7 +28618,7 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { }, unionLookaheads: function LALR_unionLookaheads() { var self = this, - newg = this.newg; // var states = !!this.onDemandLookahead ? this.inadequateStates : this.states; + newg = this.newg; // let states = !!this.onDemandLookahead ? this.inadequateStates : this.states; var these_states = this.states; these_states.forEach(function union_states_forEach(state, i) { @@ -28421,19 +28734,17 @@ var lr1 = lrLookaheadGenerator.beget({ closureOperation: function LR_ClosureOperation(itemSet) { var closureSet = new this.ItemSet(); var self = this; - var set = itemSet, - itemQueue; + var set = itemSet; - do { - itemQueue = new Set(); + var _loop3 = function _loop3() { + var itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function LR_AddItemToClosureSets(item) { - var symbol = item.markedSymbol; - var b, r; // if token is a nonterminal, recursively add closures + var symbol = item.markedSymbol; // if token is a nonterminal, recursively add closures if (symbol && self.nonterminals[symbol]) { - r = item.remainingHandle(); - b = self.first(r); + var r = item.remainingHandle(); + var b = self.first(r); if (b.length === 0 || item.production.nullable || self.nullable(r)) { b = b.concat(item.follows); @@ -28452,7 +28763,11 @@ var lr1 = lrLookaheadGenerator.beget({ } }); set = itemQueue; - } while (!itemQueue.isEmpty()); + }; + + do { + _loop3(); + } while (!set.isEmpty()); return closureSet; } @@ -28483,9 +28798,9 @@ var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { //cleanupTable(this.table); }, parseTable: function ll_ParseTable(productions) { - var table = {}, - symbols_ = this.symbols_, - self = this; + var table = {}; + var symbols_ = this.symbols_; + var self = this; productions.forEach(function (production, i) { var row = table[production.symbol] || {}; var tokens = production.first; @@ -28538,7 +28853,7 @@ Jison$1.Generator = function Jison_Generator(grammar, optionalLexerSection, opti // Anyway, API/CLI options **override** options coming in from the grammar spec. // - options = mkStdOptions$1("NODEFAULT", grammar.options, options); + options = mkStdOptions$1('NODEFAULT', grammar.options, options); switch (options.type || Jison$1.defaultJisonOptions.type) { case 'lr0': @@ -28578,7 +28893,22 @@ function Parser$3(g, l, options) { return gen.createParser(); } -Jison$1.Parser = Parser$3; +Jison$1.Parser = Parser$3; // exports for unit/system testing purposes: + +Jison$1.TestExports = { + lookaheadMixin: lookaheadMixin, + generatorMixin: generatorMixin, + lrGeneratorMixin: lrGeneratorMixin, + lalr: lalr, + lr0: lr0, + lr1: lr1, + ll: ll, + parser: parser$4, + pickErrorHandlingChunk: pickErrorHandlingChunk, + addOrRemoveTokenStack: addOrRemoveTokenStack, + removeUnusedKernelFeatures: removeUnusedKernelFeatures, + expandParseArguments: expandParseArguments +}; var rmCommonWS$6 = helpers.rmCommonWS; var mkIdentifier$5 = helpers.mkIdentifier; assert__default['default'](Jison$1); @@ -28586,7 +28916,7 @@ assert__default['default'](typeof Jison$1.prettyPrint === 'function'); assert__default['default'](Jison$1.defaultJisonOptions); assert__default['default'](typeof Jison$1.mkStdOptions === 'function'); assert__default['default'](typeof Jison$1.Generator === 'function'); -var version$3 = '0.6.2-220'; // require('./package.json').version; +var version$3 = '0.7.0-220'; // require('./package.json').version; function getCommandlineOptions() { var defaults = Jison$1.defaultJisonOptions; @@ -28696,7 +29026,7 @@ function getCommandlineOptions() { // FAIL when found: return this.help; }, - help: 'OBSOLETED. Use \'--default-action=[for-value,for-location]\' instead. (See below in \'--help\' output.)' + help: "OBSOLETED. Use '--default-action=[for-value,for-location]' instead. (See below in '--help' output.)" }, defaultActionMode: { full: 'default-action', @@ -28720,7 +29050,7 @@ function getCommandlineOptions() { switch (mode) { case 'false': case '0': - return "none"; + return 'none'; case 'true': case '1': @@ -28738,7 +29068,7 @@ function getCommandlineOptions() { return v; }, - help: rmCommonWS$6(_templateObject162(), defaults.defaultActionMode.join(",")) + help: rmCommonWS$6(_templateObject163(), defaults.defaultActionMode.join(',')) }, hasTryCatch: { full: 'try-catch', @@ -28753,13 +29083,13 @@ function getCommandlineOptions() { default: defaults.errorRecoveryTokenDiscardCount, callback: function callback(count) { if (count != parseInt(count)) { - return "count must be an integer"; + return 'count must be an integer'; } count = parseInt(count); if (count < 2) { - return "count must be >= 2"; + return 'count must be >= 2'; } }, transform: function transform(val) { @@ -28772,7 +29102,7 @@ function getCommandlineOptions() { abbr: 'E', flag: true, default: defaults.exportAllTables, - help: 'Next to producing a grammar source file, also export the symbols, terminals, grammar and parse tables to separate JSON files for further use by other tools. The files\' names will be derived from the outputFile name by appending a suffix.' + help: "Next to producing a grammar source file, also export the symbols, terminals, grammar and parse tables to separate JSON files for further use by other tools. The files' names will be derived from the outputFile name by appending a suffix." }, exportAST: { full: 'export-ast', @@ -28800,7 +29130,7 @@ function getCommandlineOptions() { flag: true, metavar: 'false|true|CFGFILE', default: defaults.prettyCfg, - help: 'Output the generated code pretty-formatted; turning this option OFF will output the generated code as-is a.k.a. \'raw\'.' + help: "Output the generated code pretty-formatted; turning this option OFF will output the generated code as-is a.k.a. 'raw'." }, main: { full: 'main', @@ -28827,7 +29157,7 @@ function getCommandlineOptions() { }).parse(); if (opts.debug) { - console.log("JISON CLI options:\n", opts); + console.log('JISON CLI options:\n', opts); } return opts; diff --git a/dist/cli-cjs.js b/dist/cli-cjs.js index 472ffa2c6..151712809 100644 --- a/dist/cli-cjs.js +++ b/dist/cli-cjs.js @@ -6,6 +6,7 @@ var fs = require('fs'); var path$1 = require('path'); var JSON5 = require('@gerhobbelt/json5'); +var mkdirp = require('mkdirp'); var XRegExp = require('@gerhobbelt/xregexp'); var recast = require('recast'); var babel = require('@babel/core'); @@ -19,6 +20,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); +var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); @@ -26,7 +28,7 @@ var astUtils__default = /*#__PURE__*/_interopDefaultLegacy(astUtils); var process__default = /*#__PURE__*/_interopDefaultLegacy(process$1); var nomnom__default = /*#__PURE__*/_interopDefaultLegacy(nomnom); -// Return TRUE if `src` starts with `searchString`. +// Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -49,19 +51,19 @@ function rmCommonWS(strings, ...values) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -80,19 +82,21 @@ function rmCommonWS(strings, ...values) { // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -101,16 +105,19 @@ function rmCommonWS(strings, ...values) { } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -121,27 +128,79 @@ function camelCase(s) { return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } +// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; +})([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' +]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -159,6 +218,11 @@ function mkIdentifier(s) { .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -167,13 +231,13 @@ function mkIdentifier(s) { function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -184,23 +248,17 @@ function scanRegExp(s) { break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -223,34 +281,33 @@ function isLineTerminator(cp) { /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote$1(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -273,28 +330,76 @@ function chkBugger(src) { // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } +function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; +} + + +function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); +} + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -305,27 +410,37 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -335,7 +450,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -343,7 +458,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -369,27 +484,43 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; } - const debug = 0; + const debug = options.debug || 0; - var p; + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); + } + + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -402,9 +533,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -426,22 +558,22 @@ assert__default['default'](recast__default['default']); // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; -// Determine which Unicode NonAsciiIdentifierStart characters +// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -449,40 +581,40 @@ const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -490,30 +622,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -524,59 +656,59 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -618,38 +750,38 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -661,18 +793,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -683,56 +815,56 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -740,97 +872,97 @@ function generateMapper4JisonGrammarIdentifiers(input) { typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -838,7 +970,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -851,7 +983,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -864,7 +996,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -877,7 +1009,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -896,37 +1028,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -958,7 +1090,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -975,37 +1107,37 @@ function parseCodeChunkToAST(src, options) { .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return babel.transformSync(src, options); // => { code, map, ast } @@ -1013,8 +1145,8 @@ function compileCodeToES5(src, options) { function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1023,7 +1155,7 @@ function prettyPrintAST(ast, options) { // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1046,25 +1178,25 @@ function prettyPrintAST(ast, options) { // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1075,9 +1207,9 @@ function checkActionBlock(src, yylloc, options) { // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1085,7 +1217,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1094,14 +1226,14 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1155,7 +1287,7 @@ var parse2AST = { trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1169,7 +1301,7 @@ function chkBugger$1(src) { /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1181,24 +1313,24 @@ const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?: /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1215,8 +1347,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1227,14 +1359,14 @@ function printFunctionSourceCodeContainer(f) { action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1245,17 +1377,17 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; -// -// -// +// +// +// function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1281,7 +1413,7 @@ function detectIstanbulGlobal() { // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1329,7 +1461,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1392,13 +1524,13 @@ var reHelpers = { getRegExpInfo: getRegExpInfo }; -var cycleref = []; -var cyclerefpath = []; +let cycleref = []; +let cyclerefpath = []; -var linkref = []; -var linkrefpath = []; +let linkref = []; +let linkrefpath = []; -var path = []; +let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1406,14 +1538,14 @@ function shallow_copy(src) { return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1426,11 +1558,11 @@ function shallow_copy(src) { function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1443,9 +1575,9 @@ function shallow_copy_and_strip_depth(src, parentKey) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1460,16 +1592,52 @@ function shallow_copy_and_strip_depth(src, parentKey) { } +// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } +// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; +} + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1484,7 +1652,7 @@ function trim_array_tail(arr) { function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1510,10 +1678,10 @@ function treat_value_stack(v) { } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1611,7 +1779,7 @@ function treat_hash(h) { function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1628,7 +1796,7 @@ function treat_error_report_info(e) { path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1656,7 +1824,7 @@ function treat_error_report_info(e) { function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1672,7 +1840,7 @@ function treat_object(e) { linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1684,14 +1852,14 @@ function treat_object(e) { // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1701,7 +1869,7 @@ function trimErrorForTestReporting(e) { cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1715,12 +1883,14 @@ var helpers = { dquote: dquote$1, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1735,7 +1905,7 @@ var helpers = { printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; /* @@ -1745,23 +1915,23 @@ var helpers = { * By Zachary Carter * MIT Licensed */ -var mkIdentifier$1 = helpers.mkIdentifier; +let mkIdentifier$1 = helpers.mkIdentifier; -var create = Object.create || function (o) { - function F(){} - F.prototype = o; - return new F(); +let create = Object.create || function (o) { + function F() {} + F.prototype = o; + return new F(); }; -var position = /^(before|after)/; +let position = /^(before|after)/; // basic method layering // always returns original method's return value function layerMethod(pos, key, prop, fun) { if (pos === 'after') { return function () { - var ret = prop.apply(this, arguments); - var args = [].slice.call(arguments); + let ret = prop.apply(this, arguments); + let args = [].slice.call(arguments); args.splice(0, 0, ret); fun.apply(this, args); return ret; @@ -1769,7 +1939,7 @@ function layerMethod(pos, key, prop, fun) { } else if (pos === 'before') { return function () { fun.apply(this, arguments); - var ret = prop.apply(this, arguments); + let ret = prop.apply(this, arguments); return ret; }; } @@ -1780,7 +1950,7 @@ function layerMethod(pos, key, prop, fun) { // overwriting them or layering them. i.e. an object method 'meth' is // layered by mixin methods 'beforemeth' or 'aftermeth' function typal_mix() { - var i, o, k; + let i, o, k; for (i = 0; i < arguments.length; i++) { o = arguments[i]; if (!o) continue; @@ -1792,8 +1962,8 @@ function typal_mix() { } for (k in o) { if (Object.prototype.hasOwnProperty.call(o, k)) { - var match = k.match(position); - var key = k.replace(position, ''); + let match = k.match(position); + let key = k.replace(position, ''); if (match && typeof this[key] === 'function') { this[key] = layerMethod(match[0], key, this[key], o[k]); } else { @@ -1807,15 +1977,15 @@ function typal_mix() { // Same as typal_mix but also camelCases every object member and 'standardizes' the key set of every input // argument through a caLLback function. -// +// // This is useful for processing options with dashes in their key, e.g. `token-stack` --> tokenStack. function typal_camel_mix(cb) { - var i, o, k; + let i, o, k; // Convert first character to lowercase function lcase0(s) { - return s.replace(/^\w/, function (match) { - return match.toLowerCase(); + return s.replace(/^\w/, function (match) { + return match.toLowerCase(); }); } @@ -1833,16 +2003,15 @@ function typal_camel_mix(cb) { } for (k in o) { if (Object.prototype.hasOwnProperty.call(o, k)) { - var nk = mkIdentifier$1(k); - var match = k.match(position); - var key = k.replace(position, ''); + let nk = mkIdentifier$1(k); + let match = k.match(position); + let key = k.replace(position, ''); // This anticipates before/after members to be camelcased already, e.g. - // 'afterParse()' for layering 'parse()': - var alt_key = lcase0(key); + // 'afterParse()' for layering 'parse()': + let alt_key = lcase0(key); if (match && typeof this[key] === 'function') { this[key] = layerMethod(match[0], key, this[key], o[k]); - } - else if (match && typeof this[alt_key] === 'function') { + } else if (match && typeof this[alt_key] === 'function') { this[alt_key] = layerMethod(match[0], alt_key, this[alt_key], o[k]); } else { this[nk] = o[k]; @@ -1853,7 +2022,7 @@ function typal_camel_mix(cb) { return this; } -var typal = { +let typal = { // extend object with own properties of each argument mix: typal_mix, @@ -1868,9 +2037,9 @@ var typal = { // Creates a new Class function based on an object with a constructor method construct: function typal_construct() { - var o = typal_mix.apply(create(this), arguments); - var constructor = o.constructor; - var Klass = o.constructor = function () { return constructor.apply(this, arguments); }; + let o = typal_mix.apply(create(this), arguments); + let constructor = o.constructor; + let Klass = o.constructor = function () { return constructor.apply(this, arguments); }; Klass.prototype = o; Klass.mix = typal_mix; // allow for easy singleton property extension return Klass; @@ -1882,13 +2051,12 @@ var typal = { // Set class to wrap arrays -var setMixin = { +let setMixin = { constructor: function Set_constructor(set, raw) { this._items = []; if (set && set.constructor === Array) { - this._items = raw ? set: set.slice(0); - } - else if (arguments.length) { + this._items = raw ? set : set.slice(0); + } else if (arguments.length) { this._items = [].slice.call(arguments, 0); } }, @@ -1901,7 +2069,7 @@ var setMixin = { }, indexOf: function indexOf(item) { if (item && item.eq) { - for (var k = 0; k < this._items.length; k++) { + for (let k = 0; k < this._items.length; k++) { if (item.eq(this._items[k])) { return k; } @@ -1916,14 +2084,14 @@ var setMixin = { }); }, complement: function complement(set) { - var that = this; + let that = this; return set.filter(function sub_complement(elm) { return !that.contains(elm); }); }, subset: function subset(set) { - var cont = true; - for (var i = 0; i < this._items.length && cont; i++) { + let cont = true; + for (let i = 0; i < this._items.length && cont; i++) { cont = cont && set.contains(this._items[i]); } return cont; @@ -1934,60 +2102,59 @@ var setMixin = { joinSet: function joinSet(set) { return this.concat(this.complement(set)); }, - contains: function contains(item) { - return this.indexOf(item) !== -1; + contains: function contains(item) { + return this.indexOf(item) !== -1; }, - item: function item(v) { - return this._items[v]; + item: function item(v) { + return this._items[v]; }, - i: function i(v) { - return this._items[v]; + i: function i(v) { + return this._items[v]; }, - assign: function assign(index, value) { + assign: function assign(index, value) { this._items[index] = value; - return this; + return this; }, - first: function first() { - return this._items[0]; + first: function first() { + return this._items[0]; }, - last: function last() { - return this._items[this._items.length - 1]; + last: function last() { + return this._items[this._items.length - 1]; }, - size: function size() { - return this._items.length; + size: function size() { + return this._items.length; }, - isEmpty: function isEmpty() { - return this._items.length === 0; + isEmpty: function isEmpty() { + return this._items.length === 0; }, - copy: function copy() { - return new Set(this._items); + copy: function copy() { + return new Set$1(this._items); }, - toString: function toString() { - return this._items.toString(); + toString: function toString() { + return this._items.toString(); } }; 'push shift unshift forEach some every join sort'.split(' ').forEach(function (e, i) { - setMixin[e] = function () { - return Array.prototype[e].apply(this._items, arguments); + setMixin[e] = function () { + return Array.prototype[e].apply(this._items, arguments); }; //setMixin[e].name = e; }); 'filter slice map'.split(' ').forEach(function (e, i) { - setMixin[e] = function () { - return new Set(Array.prototype[e].apply(this._items, arguments), true); + setMixin[e] = function () { + return new Set$1(Array.prototype[e].apply(this._items, arguments), true); }; //setMixin[e].name = e; }); -var Set = typal.construct(setMixin); +var Set$1 = typal.construct(setMixin); // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -2004,9 +2171,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -2039,10 +2206,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -2055,11 +2222,11 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -2069,18 +2236,18 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -2111,7 +2278,7 @@ JisonParserError.prototype.name = 'JisonParserError'; // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -2128,9 +2295,9 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -2143,7 +2310,7 @@ JisonParserError.prototype.name = 'JisonParserError'; } -var parser = { +let parser = { // Code Generator Information Report // --------------------------------- // @@ -2393,7 +2560,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2401,7 +2567,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2413,8 +2578,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2427,14 +2592,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2450,10 +2614,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2461,10 +2625,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2619,9 +2783,9 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -2633,18 +2797,18 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2674,9 +2838,9 @@ case 1: case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -2689,10 +2853,10 @@ case 2: case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2719,9 +2883,9 @@ case 3: case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -2730,10 +2894,10 @@ case 4: case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2761,9 +2925,9 @@ case 5: case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -2772,10 +2936,10 @@ case 6: case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -2814,9 +2978,9 @@ case 7: case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2881,9 +3045,9 @@ case 8: case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2898,9 +3062,9 @@ case 9: case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -2935,10 +3099,10 @@ case 10: case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2955,9 +3119,9 @@ case 11: case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2974,10 +3138,10 @@ case 12: case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2994,9 +3158,9 @@ case 13: case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -3013,10 +3177,10 @@ case 14: case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3033,9 +3197,9 @@ case 15: case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3059,9 +3223,9 @@ case 17: case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3072,9 +3236,9 @@ case 132: case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3094,9 +3258,9 @@ case 18: case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3120,9 +3284,9 @@ case 19: case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -3135,10 +3299,10 @@ case 20: case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3155,9 +3319,9 @@ case 21: case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -3169,9 +3333,9 @@ case 22: case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -3211,10 +3375,10 @@ case 23: case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3234,9 +3398,9 @@ case 24: case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3286,10 +3450,10 @@ case 25: case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -3313,10 +3477,10 @@ case 26: case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3336,10 +3500,10 @@ case 27: case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3363,10 +3527,10 @@ case 28: case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3387,10 +3551,10 @@ case 29: case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3402,10 +3566,10 @@ case 31: case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3415,10 +3579,10 @@ case 33: case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3428,10 +3592,10 @@ case 32: case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3441,10 +3605,10 @@ case 34: case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3454,10 +3618,10 @@ case 35: case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -3467,10 +3631,10 @@ case 36: case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3480,10 +3644,10 @@ case 37: case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3493,9 +3657,9 @@ case 38: case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -3504,9 +3668,9 @@ case 39: case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -3515,9 +3679,9 @@ case 40: case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3539,9 +3703,9 @@ case 41: case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3552,9 +3716,9 @@ case 42: case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3574,9 +3738,9 @@ case 43: case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3630,9 +3794,9 @@ case 49: case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3652,9 +3816,9 @@ case 51: case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -3663,9 +3827,9 @@ case 58: case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -3677,9 +3841,9 @@ case 52: case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -3693,10 +3857,10 @@ case 53: case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3716,10 +3880,10 @@ case 54: case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3739,10 +3903,10 @@ case 55: case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3762,9 +3926,9 @@ case 56: case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3775,9 +3939,9 @@ case 59: case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3796,9 +3960,9 @@ case 60: case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -3839,9 +4003,9 @@ case 61: case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3865,9 +4029,9 @@ case 62: case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3893,9 +4057,9 @@ case 63: case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3940,9 +4104,9 @@ case 64: case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -3968,9 +4132,9 @@ case 106: case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -3979,9 +4143,9 @@ case 127: case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -3990,10 +4154,10 @@ case 67: case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4007,10 +4171,10 @@ case 68: case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4024,10 +4188,10 @@ case 69: case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4041,10 +4205,10 @@ case 70: case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4063,9 +4227,9 @@ case 72: case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4074,9 +4238,9 @@ case 77: case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -4114,10 +4278,10 @@ case 73: case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -4141,9 +4305,9 @@ case 74: case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -4222,9 +4386,9 @@ case 110: case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -4233,9 +4397,9 @@ case 129: case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -4244,9 +4408,9 @@ case 78: case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -4255,9 +4419,9 @@ case 79: case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -4266,9 +4430,9 @@ case 80: case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -4277,9 +4441,9 @@ case 81: case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -4288,9 +4452,9 @@ case 85: case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -4301,10 +4465,10 @@ case 87: case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4321,9 +4485,9 @@ case 88: case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -4332,9 +4496,9 @@ case 89: case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -4343,9 +4507,9 @@ case 90: case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -4354,9 +4518,9 @@ case 91: case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -4365,9 +4529,9 @@ case 92: case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -4386,18 +4550,18 @@ case 107: case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -4406,9 +4570,9 @@ case 97: case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -4417,9 +4581,9 @@ case 98: case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -4428,9 +4592,9 @@ case 99: case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -4439,9 +4603,9 @@ case 102: case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -4450,10 +4614,10 @@ case 104: case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4470,9 +4634,9 @@ case 105: case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -4489,9 +4653,9 @@ case 109: case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -4503,9 +4667,9 @@ case 111: case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -4515,9 +4679,9 @@ case 112: case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4552,9 +4716,9 @@ case 113: case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4573,9 +4737,9 @@ case 114: case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -4584,9 +4748,9 @@ case 115: case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -4595,9 +4759,9 @@ case 116: case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4615,10 +4779,10 @@ case 117: case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -4636,10 +4800,10 @@ case 118: case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -4660,9 +4824,9 @@ case 119: case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4695,9 +4859,9 @@ case 120: case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4723,9 +4887,9 @@ case 121: case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5__default['default'].parse(yyvstack[yysp]); @@ -4734,9 +4898,9 @@ case 122: case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue(yyvstack[yysp]); @@ -4745,9 +4909,9 @@ case 123: case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4756,9 +4920,9 @@ case 124: case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -4779,10 +4943,10 @@ case 125: case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4799,9 +4963,9 @@ case 126: case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -4820,9 +4984,9 @@ case 128: case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4846,9 +5010,9 @@ case 130: case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -4868,9 +5032,9 @@ case 131: case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4881,9 +5045,9 @@ case 133: case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -4939,10 +5103,10 @@ case 134: case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6545,7 +6709,6 @@ defaultActions: bda({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -6562,38 +6725,34 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -6601,20 +6760,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -6636,7 +6793,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -6644,18 +6800,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -6663,24 +6820,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -6718,18 +6870,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -6750,7 +6899,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -6768,7 +6917,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -6781,7 +6929,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -6795,11 +6942,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -6853,8 +6999,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6862,8 +7008,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6895,19 +7041,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -6918,7 +7063,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -6931,7 +7076,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -6943,29 +7088,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -6973,7 +7116,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -6993,8 +7136,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -7003,10 +7145,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -7014,7 +7156,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -7025,9 +7167,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -7043,8 +7190,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -7113,11 +7259,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -7128,8 +7277,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -7138,21 +7286,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -7162,21 +7309,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -7185,28 +7331,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -7219,8 +7364,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -7243,8 +7387,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -7256,8 +7399,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -7274,8 +7416,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -7289,8 +7430,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -7304,7 +7444,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -7357,16 +7497,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -7400,9 +7537,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -7425,9 +7560,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -7454,17 +7587,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -7511,8 +7643,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -7524,8 +7656,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -7543,6 +7674,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -7551,7 +7683,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -7562,7 +7694,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -7622,10 +7754,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -7660,9 +7792,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -7675,7 +7805,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -7696,9 +7826,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7720,12 +7848,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -7734,7 +7862,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7775,7 +7903,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -7822,7 +7950,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -7840,21 +7968,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7888,14 +8014,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7905,6 +8032,7 @@ parse: function parse(input) { + } continue; // accept: @@ -7956,7 +8084,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -7972,9 +8100,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -8003,7 +8129,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -8020,8 +8146,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -8032,8 +8158,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -8045,21 +8171,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -8090,14 +8214,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -8107,6 +8232,7 @@ parse: function parse(input) { + } continue; // accept: @@ -8159,8 +8285,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -8421,7 +8546,6 @@ var lexer = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -8438,10 +8562,10 @@ var lexer = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -8473,7 +8597,7 @@ var lexer = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -8515,7 +8639,9 @@ var lexer = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -8601,7 +8727,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -8609,7 +8735,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -8622,7 +8748,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -8648,10 +8774,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -8674,7 +8803,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -8697,16 +8825,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -8728,7 +8856,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -8736,8 +8863,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -8766,7 +8893,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -8791,7 +8918,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -8803,17 +8930,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -8907,7 +9034,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -8928,7 +9055,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -8939,7 +9065,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -8950,15 +9076,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -8992,8 +9118,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -9026,9 +9152,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -9047,9 +9173,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -9059,8 +9185,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -9087,20 +9213,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -9140,17 +9265,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -9159,7 +9286,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -9174,8 +9301,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -9201,24 +9328,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -9229,7 +9358,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -9251,8 +9380,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -9274,8 +9403,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -9419,21 +9547,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -9448,11 +9576,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -9471,13 +9599,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -9501,13 +9629,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -9522,8 +9650,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -9554,7 +9682,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -9586,9 +9714,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -9617,7 +9745,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -9635,7 +9763,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -9660,7 +9788,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -9670,8 +9797,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -9680,7 +9805,7 @@ EOF: 1, this.clear(); } - 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. @@ -9692,13 +9817,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -9708,68 +9833,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -9794,7 +9925,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -9842,24 +9973,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9879,7 +10010,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -9889,24 +10020,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9927,8 +10058,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -9968,14 +10098,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -9991,9 +10121,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -10004,8 +10134,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -10013,7 +10143,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -11703,7 +11833,7 @@ const UNICODE_BASE_PLANE_MAX_CP = 65535; // The expanded regex sets which are equivalent to the given `\\{c}` escapes: // // `/\s/`: -const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; +const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; // `/\d/`: const DIGIT_SETSTR = '0-9'; // `/\w/`: @@ -11715,7 +11845,7 @@ const WORDCHAR_SETSTR = 'A-Za-z0-9_'; // Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex function i2c(i) { - var c, x; + let c, x; switch (i) { case 10: @@ -11755,7 +11885,7 @@ function i2c(i) { || i > 0xFFF0 /* Unicode Specials, also in UTF16 */ || (i >= 0xD800 && i <= 0xDFFF) /* Unicode Supplementary Planes; we're TOAST in JavaScript as we're NOT UTF-16 but UCS-2! */ || String.fromCharCode(i).match(/[\u2028\u2029]/) /* Code compilation via `new Function()` does not like to see these, or rather: treats them as just another form of CRLF, which breaks your generated regex code! */ - ) { + ) { // Detail about a detail: // U+2028 and U+2029 are part of the `\s` regex escape code (`\s` and `[\s]` match either of these) and when placed in a JavaScript // source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report @@ -11763,11 +11893,10 @@ function i2c(i) { // Hence we MUST escape these buggers everywhere we go... x = i.toString(16); if (x.length >= 1 && i <= 0xFFFF) { - c = '0000' + x; - return '\\u' + c.substr(c.length - 4); - } else { - return '\\u{' + x + '}'; + c = '0000' + x; + return '\\u' + c.substr(c.length - 4); } + return '\\u{' + x + '}'; } return String.fromCharCode(i); } @@ -11776,18 +11905,18 @@ function i2c(i) { // Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating // this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a // `\\p{NAME}` shorthand to represent [part of] the bitarray: -var Pcodes_bitarray_cache = {}; -var Pcodes_bitarray_cache_test_order = []; +let Pcodes_bitarray_cache = {}; +let Pcodes_bitarray_cache_test_order = []; -// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by +// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. -var EscCode_bitarray_output_refs; +let EscCode_bitarray_output_refs; // now initialize the EscCodes_... table above: init_EscCode_lookup_table(); function init_EscCode_lookup_table() { - var s, bitarr, set2esc = {}, esc2bitarr = {}; + let s, bitarr, set2esc = {}, esc2bitarr = {}; // patch global lookup tables for the time being, while we calculate their *real* content in this function: EscCode_bitarray_output_refs = { @@ -11856,13 +11985,13 @@ function init_EscCode_lookup_table() { }; updatePcodesBitarrayCacheTestOrder(); -} +} function updatePcodesBitarrayCacheTestOrder(opts) { - var t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var l = {}; - var user_has_xregexp = opts && opts.options && opts.options.xregexp; - var i, j, k, ba; + let t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let l = {}; + let user_has_xregexp = opts && opts.options && opts.options.xregexp; + let i, j, k, ba; // mark every character with which regex pcodes they are part of: for (k in Pcodes_bitarray_cache) { @@ -11872,12 +12001,12 @@ function updatePcodesBitarrayCacheTestOrder(opts) { continue; } - var cnt = 0; + let cnt = 0; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { cnt++; if (!t[i]) { - t[i] = [k]; + t[i] = [ k ]; } else { t[i].push(k); } @@ -11887,27 +12016,27 @@ function updatePcodesBitarrayCacheTestOrder(opts) { } // now dig out the unique ones: only need one per pcode. - // + // // We ASSUME every \\p{NAME} 'pcode' has at least ONE character - // in it that is ONLY matched by that particular pcode. + // in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode - // won't be tested during optimization. - // + // won't be tested during optimization. + // // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to // look for markers which match multiple escapes/pcodes for those // ones where a unique item isn't available... - var lut = []; - var done = {}; - var keys = Object.keys(Pcodes_bitarray_cache); + let lut = []; + let done = {}; + let keys = Object.keys(Pcodes_bitarray_cache); for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { k = t[i][0]; if (t[i].length === 1 && !done[k]) { assert__default['default'](l[k] > 0); - lut.push([i, k]); + lut.push([ i, k ]); done[k] = true; } } @@ -11918,19 +12047,19 @@ function updatePcodesBitarrayCacheTestOrder(opts) { if (!user_has_xregexp && k.indexOf('\\p{') >= 0) { continue; } - + if (!done[k]) { assert__default['default'](l[k] > 0); // find a minimum span character to mark this one: - var w = Infinity; + let w = Infinity; var rv; ba = Pcodes_bitarray_cache[k]; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { - var tl = t[i].length; + let tl = t[i].length; if (tl > 1 && tl < w) { assert__default['default'](l[k] > 0); - rv = [i, k]; + rv = [ i, k ]; w = tl; } } @@ -11944,16 +12073,16 @@ function updatePcodesBitarrayCacheTestOrder(opts) { // order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. - // + // // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more - // optimal minification of the regex set expression. - // + // optimal minification of the regex set expression. + // // This is a guestimate/heuristic only! lut.sort(function (a, b) { - var k1 = a[1]; - var k2 = b[1]; - var ld = l[k2] - l[k1]; + let k1 = a[1]; + let k2 = b[1]; + let ld = l[k2] - l[k1]; if (ld) { return ld; } @@ -11971,19 +12100,19 @@ function updatePcodesBitarrayCacheTestOrder(opts) { // 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set. function set2bitarray(bitarr, s, opts) { - var orig = s; - var set_is_inverted = false; - var bitarr_orig; + let orig = s; + let set_is_inverted = false; + let bitarr_orig; function mark(d1, d2) { if (d2 == null) d2 = d1; - for (var i = d1; i <= d2; i++) { + for (let i = d1; i <= d2; i++) { bitarr[i] = true; } } function add2bitarray(dst, src) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (src[i]) { dst[i] = true; } @@ -11991,10 +12120,10 @@ function set2bitarray(bitarr, s, opts) { } function eval_escaped_code(s) { - var c; + let c; // decode escaped code? If none, just take the character as-is if (s.indexOf('\\') === 0) { - var l = s.substr(0, 2); + let l = s.substr(0, 2); switch (l) { case '\\c': c = s.charCodeAt(2) - 'A'.charCodeAt(0) + 1; @@ -12012,7 +12141,7 @@ function set2bitarray(bitarr, s, opts) { } c = parseInt(s, 16); if (c >= 0x10000) { - return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); + return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); } return String.fromCharCode(c); @@ -12056,7 +12185,7 @@ function set2bitarray(bitarr, s, opts) { } if (s && s.length) { - var c1, c2; + let c1, c2; // inverted set? if (s[0] === '^') { @@ -12087,13 +12216,13 @@ function set2bitarray(bitarr, s, opts) { c2 = c2[0]; s = s.substr(c2.length); // do we have this one cached already? - var pex = c1 + c2; - var ba4p = Pcodes_bitarray_cache[pex]; + let pex = c1 + c2; + let ba4p = Pcodes_bitarray_cache[pex]; if (!ba4p) { // expand escape: - var xr = new XRegExp__default['default']('[' + pex + ']'); // TODO: case-insensitive grammar??? + let xr = new XRegExp__default['default']('[' + pex + ']'); // TODO: case-insensitive grammar??? // rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`: - var xs = '' + xr; + let xs = '' + xr; // remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: xs = xs.substr(1, xs.length - 2); @@ -12128,7 +12257,7 @@ function set2bitarray(bitarr, s, opts) { break; } } - var v1 = eval_escaped_code(c1); + let v1 = eval_escaped_code(c1); // propagate deferred exceptions = error reports. if (v1 instanceof Error) { return v1; @@ -12146,7 +12275,7 @@ function set2bitarray(bitarr, s, opts) { } else { c2 = c2[0]; } - var v2 = eval_escaped_code(c2); + let v2 = eval_escaped_code(c2); // propagate deferred exceptions = error reports. if (v2 instanceof Error) { return v1; @@ -12169,12 +12298,12 @@ function set2bitarray(bitarr, s, opts) { } // When we have marked all slots, '^' NEGATES the set, hence we flip all slots. - // + // // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. if (set_is_inverted) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (!bitarr[i]) { bitarr_orig[i] = true; } @@ -12193,10 +12322,10 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // below can be simple and fast: l[UNICODE_BASE_PLANE_MAX_CP + 1] = 1; // now reconstruct the regex set: - var rv = []; - var i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; - var bitarr_is_cloned = false; - var l_orig = l; + let rv = []; + let i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; + let bitarr_is_cloned = false; + let l_orig = l; if (output_inverted_variant) { // generate the inverted set, hence all unmarked slots are part of the output range: @@ -12210,8 +12339,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. // BUT... since we output the INVERTED set, we output the match-all set instead: return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` // BUT... since we output the INVERTED set, we output the match-nothing set instead: @@ -12243,9 +12371,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12272,7 +12400,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } } - + i = 0; while (i <= UNICODE_BASE_PLANE_MAX_CP) { // find first character not in original set: @@ -12303,8 +12431,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. return '^\\S\\s'; } @@ -12334,9 +12461,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12388,11 +12515,11 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } assert__default['default'](rv.length); - var s = rv.join(''); + let s = rv.join(''); assert__default['default'](s); // Check if the set is better represented by one of the regex escapes: - var esc4s = EscCode_bitarray_output_refs.set2esc[s]; + let esc4s = EscCode_bitarray_output_refs.set2esc[s]; if (esc4s) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return '\\' + esc4s; @@ -12407,25 +12534,24 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there; // ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`. function reduceRegexToSetBitArray(s, name, opts) { - var orig = s; + let orig = s; // propagate deferred exceptions = error reports. if (s instanceof Error) { return s; } - var l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var internal_state = 0; - var derr; + let l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let internal_state = 0; + let derr; while (s.length) { - var c1 = s.match(CHR_RE); + let c1 = s.match(CHR_RE); if (!c1) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"'); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12433,15 +12559,14 @@ function reduceRegexToSetBitArray(s, name, opts) { // this is starting a set within the regex: scan until end of set! var set_content = []; while (s.length) { - var inner = s.match(SET_PART_RE); + let inner = s.match(SET_PART_RE); if (!inner) { inner = s.match(CHR_RE); if (!inner) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"'); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12455,9 +12580,8 @@ function reduceRegexToSetBitArray(s, name, opts) { if (!c2) { // cope with illegal escape sequences too! return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error('regex set expression is broken in regex: ' + orig); } @@ -12541,10 +12665,9 @@ function reduceRegexToSetBitArray(s, name, opts) { // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; assert__default['default'](s); assert__default['default'](!(s instanceof Error)); - re = new XRegExp__default['default']('[' + s + ']'); + let re = new XRegExp__default['default']('[' + s + ']'); re.test(s[0]); // One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` @@ -12569,25 +12692,24 @@ function reduceRegexToSetBitArray(s, name, opts) { -// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` +// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! function produceOptimizedRegex4Set(bitarr) { // First try to produce a minimum regex from the bitarray directly: - var s1 = bitarray2set(bitarr, false, true); + let s1 = bitarray2set(bitarr, false, true); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s1.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s1; - } else { - s1 = '[' + s1 + ']'; } + s1 = '[' + s1 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s2 = bitarray2set(bitarr, true, true); + let s2 = bitarray2set(bitarr, true, true); if (s2[0] === '^') { s2 = s2.substr(1); @@ -12602,23 +12724,22 @@ function produceOptimizedRegex4Set(bitarr) { // Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: - // + // // First try to produce a minimum regex from the bitarray directly: - var s3 = bitarray2set(bitarr, false, false); + let s3 = bitarray2set(bitarr, false, false); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s3.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s3; - } else { - s3 = '[' + s3 + ']'; } + s3 = '[' + s3 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s4 = bitarray2set(bitarr, true, false); + let s4 = bitarray2set(bitarr, true, false); if (s4[0] === '^') { s4 = s4.substr(1); @@ -12650,30 +12771,30 @@ function produceOptimizedRegex4Set(bitarr) { var setmgmt = { - XREGEXP_UNICODE_ESCAPE_RE, - CHR_RE, - SET_PART_RE, - NOTHING_SPECIAL_RE, - SET_IS_SINGLE_PCODE_RE, - - UNICODE_BASE_PLANE_MAX_CP, - - WHITESPACE_SETSTR, - DIGIT_SETSTR, - WORDCHAR_SETSTR, - - set2bitarray, - bitarray2set, - produceOptimizedRegex4Set, - reduceRegexToSetBitArray, + XREGEXP_UNICODE_ESCAPE_RE, + CHR_RE, + SET_PART_RE, + NOTHING_SPECIAL_RE, + SET_IS_SINGLE_PCODE_RE, + + UNICODE_BASE_PLANE_MAX_CP, + + WHITESPACE_SETSTR, + DIGIT_SETSTR, + WORDCHAR_SETSTR, + + set2bitarray, + bitarray2set, + produceOptimizedRegex4Set, + reduceRegexToSetBitArray }; // Basic Lexer implemented using JavaScript regular expressions -var rmCommonWS$2 = helpers.rmCommonWS; -var mkIdentifier$3 = helpers.mkIdentifier; -var code_exec$1 = helpers.exec; +const rmCommonWS$2 = helpers.rmCommonWS; +const mkIdentifier$3 = helpers.mkIdentifier; +const code_exec = helpers.exec; -var version = '0.6.2-220'; // require('./package.json').version; +const version = '0.6.2-220'; // require('./package.json').version; @@ -12734,7 +12855,7 @@ const defaultJisonLexOptions = { exportAST: false, prettyCfg: true, pre_lex: undefined, - post_lex: undefined, + post_lex: undefined }; @@ -12752,23 +12873,23 @@ const defaultJisonLexOptions = { // Return a fresh set of options. /** @public */ function mkStdOptions(/*...args*/) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - var args = [].concat.apply([], arguments); + let opts = {}; + let args = [].concat.apply([], arguments); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(defaultJisonLexOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; for (var p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { @@ -12806,7 +12927,7 @@ function mkStdOptions(/*...args*/) { function prepExportStructures(options) { // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -12827,8 +12948,8 @@ function prepExportStructures(options) { // Otherwise return the *parsed* lexer spec as it has // been processed through LexParser. function autodetectAndConvertToJSONformat(lexerSpec, options) { - var chk_l = null; - var ex1, err; + let chk_l = null; + let ex1, err; if (typeof lexerSpec === 'string') { if (options.json) { @@ -12880,9 +13001,9 @@ function autodetectAndConvertToJSONformat(lexerSpec, options) { /should be separated/, /an error in one or more of your lexer regex rules/, /an error in your lexer epilogue/, - /unsupported definition type/, + /unsupported definition type/ ]; - var cmnerr = commonErrors.filter(function check(re) { + let cmnerr = commonErrors.filter(function check(re) { return e.message.match(re); }); if (cmnerr.length > 0) { @@ -12911,14 +13032,14 @@ function autodetectAndConvertToJSONformat(lexerSpec, options) { // expand macros and convert matchers to RegExp's function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) { - var m, i, k, rule, action, conditions; - var active_conditions; + let m, i, k, rule, action, conditions; + let active_conditions; assert__default['default'](Array.isArray(dict.rules)); - var rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! - var newRules = []; - var macros = {}; - var regular_rule_count = 0; - var simple_rule_count = 0; + let rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! + let newRules = []; + let macros = {}; + let regular_rule_count = 0; + let simple_rule_count = 0; // Assure all options are camelCased: assert__default['default'](typeof opts.options['case-insensitive'] === 'undefined'); @@ -12928,7 +13049,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) } if (opts.options.flex && rules.length > 0) { - rules.push(['.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']); + rules.push([ '.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */' ]); } // Depending on the location within the regex we need different expansions of the macros: @@ -12952,7 +13073,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) return str; } - var routingCode = ['switch(yyrulenumber) {']; + let routingCode = [ 'switch(yyrulenumber) {' ]; for (i = 0; i < rules.length; i++) { rule = rules[i].slice(0); // shallow copy: do not modify input rules @@ -13006,7 +13127,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) action = action.replace(/return\s*\(?'((?:\\'|[^']+)+)'\)?/g, tokenNumberReplacement); action = action.replace(/return\s*\(?"((?:\\"|[^"]+)+)"\)?/g, tokenNumberReplacement); - var code = ['\n/*! Conditions::']; + let code = [ '\n/*! Conditions::' ]; code.push(postprocessComment(active_conditions)); code.push('*/', '\n/*! Rule:: '); code.push(postprocessComment(rule[0])); @@ -13027,7 +13148,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) // 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'. - var match_nr = /^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim()); + 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 ')); @@ -13054,7 +13175,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) macros: macros, regular_rule_count: regular_rule_count, - simple_rule_count: simple_rule_count, + simple_rule_count: simple_rule_count }; } @@ -13067,14 +13188,13 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) // 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. function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElsewhere_cb) { - var orig = s; + let orig = s; function errinfo() { if (name) { return 'macro [[' + name + ']]'; - } else { - return 'regex [[' + orig + ']]'; } + return 'regex [[' + orig + ']]'; } // propagate deferred exceptions = error reports. @@ -13082,19 +13202,18 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse return s; } - var c1, c2; - var rv = []; - var derr; - var se; + let c1, c2; + let rv = []; + let derr; + let se; while (s.length) { c1 = s.match(CHR_RE$1); if (!c1) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -13104,15 +13223,14 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse var l = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1); while (s.length) { - var inner = s.match(SET_PART_RE$1); + let inner = s.match(SET_PART_RE$1); if (!inner) { inner = s.match(CHR_RE$1); if (!inner) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -13126,9 +13244,8 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse if (!c2) { // cope with illegal escape sequences too! return new Error(errinfo() + ': regex set expression is broken: "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error(errinfo() + ': regex set expression is broken: apparently unterminated'); } @@ -13189,7 +13306,7 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse c2 = c2[0]; s = s.substr(c2.length); - var c3 = s[0]; + let c3 = s[0]; s = s.substr(c3.length); if (c3 === '}') { // possibly a macro name in there... Expand if possible: @@ -13242,7 +13359,7 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; + let re; re = new XRegExp__default['default'](s); re.test(s[0]); } catch (ex) { @@ -13258,11 +13375,11 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse // expand macros within macros and cache the result function prepareMacros(dict_macros, opts) { - var macros = {}; + let macros = {}; // expand a `{NAME}` macro which exists inside a `[...]` set: function expandMacroInSet(i) { - var k, a, m; + let k, a, m; if (!macros[i]) { m = dict_macros[i]; @@ -13296,7 +13413,7 @@ function prepareMacros(dict_macros, opts) { a = m.split('{' + k + '}'); if (a.length > 1) { - var x = expandMacroInSet(k); + let x = expandMacroInSet(k); assert__default['default'](x); if (x instanceof Error) { m = x; @@ -13308,9 +13425,9 @@ function prepareMacros(dict_macros, opts) { } } - var mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); + let mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); - var s1; + let s1; // propagate deferred exceptions = error reports. if (mba instanceof Error) { @@ -13344,7 +13461,7 @@ function prepareMacros(dict_macros, opts) { } function expandMacroElsewhere(i) { - var m; + let m; if (macros[i].elsewhere == null) { m = dict_macros[i]; @@ -13379,13 +13496,13 @@ function prepareMacros(dict_macros, opts) { } function expandAllMacrosInSet(s) { - var i, x; + let i, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { for (i in macros) { if (macros.hasOwnProperty(i)) { - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroInSet(i); assert__default['default'](x); @@ -13407,7 +13524,7 @@ function prepareMacros(dict_macros, opts) { } function expandAllMacrosElsewhere(s) { - var i, x; + let i, x; // When we process the remaining macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13422,7 +13539,7 @@ function prepareMacros(dict_macros, opts) { for (i in macros) { if (macros.hasOwnProperty(i)) { // These are all submacro expansions, hence non-capturing grouping is applied: - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroElsewhere(i); assert__default['default'](x); @@ -13444,7 +13561,7 @@ function prepareMacros(dict_macros, opts) { } - var i; + let i; if (opts.debug) console.log('\n############## RAW macros: ', dict_macros); @@ -13475,13 +13592,13 @@ function prepareMacros(dict_macros, opts) { // expand macros in a regex; expands them recursively function expandMacros(src, macros, opts) { - var expansion_count = 0; + let expansion_count = 0; // By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! // Hence things should be easy in there: function expandAllMacrosInSet(s) { - var i, m, x; + let i, m, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { @@ -13489,7 +13606,7 @@ function expandMacros(src, macros, opts) { if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = m.in_set; @@ -13520,7 +13637,7 @@ function expandMacros(src, macros, opts) { } function expandAllMacrosElsewhere(s) { - var i, m, x; + let i, m, x; // When we process the main macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13536,7 +13653,7 @@ function expandMacros(src, macros, opts) { if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { // These are all main macro expansions, hence CAPTURING grouping is applied: x = m.elsewhere; @@ -13572,7 +13689,7 @@ function expandMacros(src, macros, opts) { // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! - var s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); + let s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); // propagate deferred exceptions = error reports. if (s2 instanceof Error) { throw s2; @@ -13597,8 +13714,8 @@ function expandMacros(src, macros, opts) { } function prepareStartConditions(conditions) { - var sc; - var hash = {}; + let sc; + let hash = {}; for (sc in conditions) { if (conditions.hasOwnProperty(sc)) { @@ -13612,22 +13729,22 @@ function prepareStartConditions(conditions) { } function buildActions(dict, tokens, opts) { - var actions = [dict.actionInclude || '', 'var YYSTATE = YY_START;']; - var tok; - var toks = {}; - var caseHelper = []; + let actions = [ dict.actionInclude || '', 'var YYSTATE = YY_START;' ]; + let tok; + let toks = {}; + let caseHelper = []; // tokens: map/array of token numbers to token names for (tok in tokens) { - var idx = parseInt(tok); + let idx = parseInt(tok); if (idx && idx > 0) { toks[tokens[tok]] = idx; } } - var gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); + let gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); - var code = actions.join('\n'); + let code = actions.join('\n'); 'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function (yy) { code = code.replace(new RegExp('\\b(' + yy + ')\\b', 'g'), 'yy_.$1'); }); @@ -13645,7 +13762,7 @@ function buildActions(dict, tokens, opts) { macros: gen.macros, // propagate these for debugging/diagnostic purposes regular_rule_count: gen.regular_rule_count, - simple_rule_count: gen.simple_rule_count, + simple_rule_count: gen.simple_rule_count }; } @@ -13656,7 +13773,7 @@ function buildActions(dict, tokens, opts) { function generateErrorClass() { // --- START lexer error class --- -var prelude = `/** +const prelude = `/** * 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 @@ -13667,8 +13784,6 @@ var prelude = `/** * @nocollapse */ function JisonLexerError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -13685,9 +13800,9 @@ function JisonLexerError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -13748,8 +13863,8 @@ function generateFakeXRegExpClassSrcCode() { /** @constructor */ function RegExpLexer(dict, input, tokens, build_options) { - var opts; - var dump = false; + let opts; + let dump = false; function test_me(tweak_cb, description, src_exception, ex_callback) { opts = processGrammar(dict, tokens, build_options); @@ -13759,7 +13874,7 @@ function RegExpLexer(dict, input, tokens, build_options) { if (tweak_cb) { tweak_cb(); } - var source = generateModuleBody(opts); + let source = generateModuleBody(opts); try { // The generated code will always have the `lexer` variable declared at local scope // as `eval()` will use the local scope. @@ -13767,16 +13882,16 @@ function RegExpLexer(dict, input, tokens, build_options) { // The compiled code will look something like this: // // ``` - // var lexer; + // let lexer; // bla bla... // ``` // // or // // ``` - // var lexer = { bla... }; + // const lexer = { bla... }; // ``` - var testcode = [ + let testcode = [ '// provide a local version for test purposes:', jisonLexerErrorDefinition, '', @@ -13784,14 +13899,33 @@ function RegExpLexer(dict, input, tokens, build_options) { '', source, '', + rmCommonWS$2` + // JISON INJECTED VALIDATION CODE + // which attempts to ascertain you have defined a minimal viable lexer at least: + if (typeof lexer === "undefined") { + throw new SyntaxError("user-defined lexer does not define the required 'lexer' instance."); + } + if (!lexer) { + throw new SyntaxError("user-defined lexer does not define a non-NULL 'lexer' instance."); + } + if (typeof lexer.setInput !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.setInput()' API function."); + } + if (typeof lexer.lex !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.lex()' API function."); + } + // END OF JISON INJECTED VALIDATION CODE + `, 'return lexer;' ].join('\n'); - var lexer = code_exec$1(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { + let lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { //console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$2(sourcecode); - var lexer_f = new Function('', sourcecode); + let lexer_f = new Function('', sourcecode); return lexer_f(); - }, opts.options, "lexer"); + }, Object.assign({}, opts.options, { + throwErrorOnCompileFailure: true + }), 'lexer'); if (!lexer) { throw new Error('no lexer defined *at all*?!'); @@ -13808,7 +13942,7 @@ function RegExpLexer(dict, input, tokens, build_options) { // When we do NOT crash, we found/killed the problem area just before this call! if (src_exception && description) { - var msg = description; + let msg = description; if (typeof description === 'function') { msg = description(); } @@ -13817,8 +13951,8 @@ function RegExpLexer(dict, input, tokens, build_options) { // patch the pre and post handlers in there, now that we have some live code to work with: if (opts.options) { - var pre = opts.options.pre_lex; - var post = opts.options.post_lex; + let pre = opts.options.pre_lex; + let post = opts.options.post_lex; // since JSON cannot encode functions, we'll have to do it manually now: if (typeof pre === 'function') { lexer.options.pre_lex = pre; @@ -13832,7 +13966,7 @@ function RegExpLexer(dict, input, tokens, build_options) { if (typeof opts.options.showSource === 'function') { opts.options.showSource(lexer, source, opts, RegExpLexer); } else { - console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n"); + console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n', source, '\n----------------------------------------\n'); } } return lexer; @@ -13851,13 +13985,13 @@ function RegExpLexer(dict, input, tokens, build_options) { } /** @constructor */ - var lexer = test_me(null, null, null, function (ex) { + let lexer = test_me(null, null, null, function (ex) { // When we get an exception here, it means some part of the user-specified lexer is botched. // // Now we go and try to narrow down the problem area/category: assert__default['default'](opts.options); assert__default['default'](opts.options.xregexp !== undefined); - var orig_xregexp_opt = !!opts.options.xregexp; + let orig_xregexp_opt = !!opts.options.xregexp; if (!test_me(function () { assert__default['default'](opts.options.xregexp !== undefined); opts.options.xregexp = false; @@ -13876,7 +14010,7 @@ function RegExpLexer(dict, input, tokens, build_options) { 'Your custom lexer is somehow botched.' ); }, ex, null)) { - var rulesSpecSize; + let rulesSpecSize; if (!test_me(function () { // store the parsed rule set size so we can use that info in case // this attempt also fails: @@ -13889,7 +14023,7 @@ function RegExpLexer(dict, input, tokens, build_options) { opts.__in_rules_failure_analysis_mode__ = true; }, 'One or more of your lexer rules are possibly botched?', ex, null)) { // kill each rule action block, one at a time and test again after each 'edit': - var rv = false; + let rv = false; for (var i = 0, len = rulesSpecSize; i < len; i++) { var lastEditedRuleSpec; rv = test_me(function () { @@ -13901,10 +14035,10 @@ function RegExpLexer(dict, input, tokens, build_options) { // opts.__in_rules_failure_analysis_mode__ = true; // nuke all rules' actions up to and including rule numero `i`: - for (var j = 0; j <= i; j++) { + for (let j = 0; j <= i; j++) { // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; // now we want to edit the *action* part: - var rule = opts.rules[j]; + let rule = opts.rules[j]; assert__default['default'](Array.isArray(rule)); assert__default['default'](rule.length === 2 || rule.length === 3); rule.pop(); @@ -14038,8 +14172,6 @@ return `{ * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -14049,14 +14181,14 @@ return `{ } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\\n\\s*$/.test(msg)) { msg += '\\n'; } msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') { msg += '\\n' + pos_str; @@ -14067,14 +14199,14 @@ return `{ } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the \`upcomingInput\` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -14094,9 +14226,8 @@ return `{ // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -14116,8 +14247,6 @@ return `{ * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -14138,16 +14267,14 @@ return `{ * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -14168,8 +14295,6 @@ return `{ * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -14177,8 +14302,8 @@ return `{ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -14196,8 +14321,6 @@ return `{ * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -14207,14 +14330,14 @@ return `{ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -14225,8 +14348,6 @@ return `{ * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -14234,40 +14355,40 @@ return `{ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -14279,7 +14400,7 @@ return `{ this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -14287,7 +14408,7 @@ return `{ last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -14348,9 +14469,7 @@ return `{ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -14369,8 +14488,6 @@ return `{ * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set \`done\` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -14379,7 +14496,7 @@ return `{ this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -14389,13 +14506,13 @@ return `{ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\\n') { lines = true; } else if (ch === '\\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\\n') { slice_len++; ch += ch2; @@ -14427,10 +14544,8 @@ return `{ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -14462,8 +14577,8 @@ return `{ // Get last entirely matched line into the \`pre_lines[]\` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -14481,9 +14596,9 @@ return `{ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -14493,14 +14608,12 @@ return `{ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -14511,8 +14624,6 @@ return `{ * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -14525,19 +14636,17 @@ return `{ * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the \`parseError()\` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // \`.lex()\` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -14550,8 +14659,6 @@ return `{ * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -14574,24 +14681,24 @@ return `{ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substr\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14603,8 +14710,8 @@ return `{ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to \`maxSize\` (default: 20). @@ -14630,24 +14737,25 @@ return `{ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > \`lookAhead()\` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substring\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -14656,7 +14764,7 @@ return `{ } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14675,10 +14783,8 @@ return `{ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^'; }, @@ -14700,15 +14806,13 @@ return `{ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -14839,58 +14943,54 @@ return `{ * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\\t/g, ' '); @@ -14899,13 +14999,13 @@ return `{ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -14927,15 +15027,13 @@ return `{ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -14947,8 +15045,8 @@ return `{ rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -14977,13 +15075,7 @@ return `{ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -15012,10 +15104,10 @@ return `{ }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -15043,7 +15135,7 @@ return `{ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -15054,7 +15146,7 @@ return `{ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -15076,8 +15168,6 @@ return `{ * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -15086,17 +15176,13 @@ return `{ this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -15106,67 +15192,75 @@ return `{ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that \`parseError()\` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) \`parseError()\` @@ -15193,9 +15287,7 @@ return `{ * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15238,24 +15330,24 @@ return `{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15275,9 +15367,7 @@ return `{ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15287,24 +15377,24 @@ return `{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15312,7 +15402,7 @@ return `{ this._clear_state = 0; } - + return r; }, @@ -15325,9 +15415,7 @@ return `{ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -15335,7 +15423,7 @@ return `{ (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -15350,8 +15438,6 @@ return `{ * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -15363,8 +15449,6 @@ return `{ * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -15378,15 +15462,12 @@ return `{ * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -15398,14 +15479,11 @@ return `{ * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -15416,16 +15494,14 @@ return `{ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -15435,8 +15511,6 @@ return `{ * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; } }`; @@ -15468,18 +15542,17 @@ function stripUnusedLexerCode(src, opt) { // ............................. ${opt.lexerActionsUseDisplayAPIs} // uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC} - var new_src; + let new_src; try { - var ast = helpers.parseCodeChunkToAST(src, opt); + let ast = helpers.parseCodeChunkToAST(src, opt); new_src = helpers.prettyPrintAST(ast, opt); - } - catch (ex) { + } catch (ex) { let line = ex.lineNumber || 0; let a = src.split(/\r?\n/g); let len = a.length; let minl = Math.max(0, line - 10); let b = a.slice(minl, line + 10); - let c = b.splice(line - minl, 0, "", "^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", ""); + let c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); let offendingChunk = ' ' + b.join('\n '); console.error(rmCommonWS$2` stripUnusedLexerCode WARNING: @@ -15495,17 +15568,11 @@ function stripUnusedLexerCode(src, opt) { ${offendingChunk} `); - + new_src = src; } - - - - - - // inject analysis report now: new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2` // Code Generator Information Report @@ -15560,7 +15627,7 @@ function stripUnusedLexerCode(src, opt) { // generate lexer source from a grammar /** @public */ function generate(dict, tokens, build_options) { - var opt = processGrammar(dict, tokens, build_options); + let opt = processGrammar(dict, tokens, build_options); return generateFromOpts(opt); } @@ -15569,7 +15636,7 @@ function generate(dict, tokens, build_options) { /** @public */ function processGrammar(dict, tokens, build_options) { build_options = build_options || {}; - var opts = { + let opts = { // include the knowledge passed through `build_options` about which lexer // features will actually be *used* by the environment (which in 99.9% // of cases is a jison *parser*): @@ -15609,7 +15676,7 @@ function processGrammar(dict, tokens, build_options) { lexerActionsUseReject: '???', lexerActionsUseLess: '???', lexerActionsUseDisplayAPIs: '???', - lexerActionsUseDescribeYYLOC: '???', + lexerActionsUseDescribeYYLOC: '???' }; dict = autodetectAndConvertToJSONformat(dict, build_options) || {}; @@ -15634,7 +15701,7 @@ function processGrammar(dict, tokens, build_options) { // only produce rule action code blocks when there are any rules at all; // a "custom lexer" has ZERO rules and must be defined entirely in // other code blocks: - var code = (dict.rules ? buildActions(dict, tokens, opts) : {}); + let code = (dict.rules ? buildActions(dict, tokens, opts) : {}); opts.performAction = code.actions; opts.caseHelperInclude = code.caseHelperInclude; opts.rules = code.rules || []; @@ -15643,7 +15710,7 @@ function processGrammar(dict, tokens, build_options) { opts.regular_rule_count = code.regular_rule_count; opts.simple_rule_count = code.simple_rule_count; - opts.conditionStack = ['INITIAL']; + opts.conditionStack = [ 'INITIAL' ]; opts.actionInclude = (dict.actionInclude || ''); opts.moduleInclude = (opts.moduleInclude || '') + (dict.moduleInclude || '').trim(); @@ -15654,7 +15721,7 @@ function processGrammar(dict, tokens, build_options) { // Assemble the final source from the processed grammar /** @public */ function generateFromOpts(opt) { - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -15677,12 +15744,12 @@ function generateFromOpts(opt) { } function generateRegexesInitTableCode(opt) { - var a = opt.rules; - var print_xregexp = opt.options && opt.options.xregexp; - var id_display_width = (1 + Math.log10(a.length | 1) | 0); - var ws_prefix = new Array(id_display_width).join(' '); - var b = a.map(function generateXRegExpInitCode(re, idx) { - var idx_str = (ws_prefix + idx).substr(-id_display_width); + let a = opt.rules; + let print_xregexp = opt.options && opt.options.xregexp; + let id_display_width = (1 + Math.log10(a.length | 1) | 0); + let ws_prefix = new Array(id_display_width).join(' '); + let b = a.map(function generateXRegExpInitCode(re, idx) { + let idx_str = (ws_prefix + idx).substr(-id_display_width); if (re instanceof XRegExp__default['default']) { // When we don't need the special XRegExp sauce at run-time, we do with the original @@ -15692,11 +15759,11 @@ function generateRegexesInitTableCode(opt) { } // And make sure to escape the regex to make it suitable for placement inside a *string* // as it is passed as a string argument to the XRegExp constructor here. - var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); + let re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); return `/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`; - } else { - return `/* ${idx_str}: */ ${re}`; } + return `/* ${idx_str}: */ ${re}`; + }); return b.join(',\n'); } @@ -15704,77 +15771,77 @@ function generateRegexesInitTableCode(opt) { function generateModuleBody(opt) { // make the JSON output look more like JavaScript: function cleanupJSON(str) { - str = str.replace(/ "rules": \[/g, ' rules: ['); - str = str.replace(/ "inclusive": /g, ' inclusive: '); + str = str.replace(/ {2}"rules": \[/g, ' rules: ['); + str = str.replace(/ {2}"inclusive": /g, ' inclusive: '); return str; } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - json: 1, - _: 1, - noMain: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - lexerErrorsAreRecoverable: 0, - flex: 0, - backtrack_lexer: 0, - caseInsensitive: 0, - showSource: 1, - exportAST: 1, - exportAllTables: 1, - exportSourceCode: 1, - prettyCfg: 1, - parseActionsUseYYLENG: 1, - parseActionsUseYYLINENO: 1, - parseActionsUseYYTEXT: 1, - parseActionsUseYYLOC: 1, - parseActionsUseParseError: 1, - parseActionsUseYYERROR: 1, - parseActionsUseYYRECOVERING: 1, - parseActionsUseYYERROK: 1, - parseActionsUseYYCLEARIN: 1, - parseActionsUseValueTracking: 1, - parseActionsUseValueAssignment: 1, - parseActionsUseLocationTracking: 1, - parseActionsUseLocationAssignment: 1, - parseActionsUseYYSTACK: 1, - parseActionsUseYYSSTACK: 1, - parseActionsUseYYSTACKPOINTER: 1, - parseActionsUseYYRULELENGTH: 1, - parseActionsUseYYMERGELOCATIONINFO: 1, - parserHasErrorRecovery: 1, - parserHasErrorReporting: 1, - lexerActionsUseYYLENG: 1, - lexerActionsUseYYLINENO: 1, - lexerActionsUseYYTEXT: 1, - lexerActionsUseYYLOC: 1, - lexerActionsUseParseError: 1, - lexerActionsUseYYERROR: 1, - lexerActionsUseLocationTracking: 1, - lexerActionsUseMore: 1, - lexerActionsUseUnput: 1, - lexerActionsUseReject: 1, - lexerActionsUseLess: 1, - lexerActionsUseDisplayAPIs: 1, - lexerActionsUseDescribeYYLOC: 1, + let obj = {}; + const do_not_pass = { + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + json: 1, + _: 1, + noMain: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + lexerErrorsAreRecoverable: 0, + flex: 0, + backtrack_lexer: 0, + caseInsensitive: 0, + showSource: 1, + exportAST: 1, + exportAllTables: 1, + exportSourceCode: 1, + prettyCfg: 1, + parseActionsUseYYLENG: 1, + parseActionsUseYYLINENO: 1, + parseActionsUseYYTEXT: 1, + parseActionsUseYYLOC: 1, + parseActionsUseParseError: 1, + parseActionsUseYYERROR: 1, + parseActionsUseYYRECOVERING: 1, + parseActionsUseYYERROK: 1, + parseActionsUseYYCLEARIN: 1, + parseActionsUseValueTracking: 1, + parseActionsUseValueAssignment: 1, + parseActionsUseLocationTracking: 1, + parseActionsUseLocationAssignment: 1, + parseActionsUseYYSTACK: 1, + parseActionsUseYYSSTACK: 1, + parseActionsUseYYSTACKPOINTER: 1, + parseActionsUseYYRULELENGTH: 1, + parseActionsUseYYMERGELOCATIONINFO: 1, + parserHasErrorRecovery: 1, + parserHasErrorReporting: 1, + lexerActionsUseYYLENG: 1, + lexerActionsUseYYLINENO: 1, + lexerActionsUseYYTEXT: 1, + lexerActionsUseYYLOC: 1, + lexerActionsUseParseError: 1, + lexerActionsUseYYERROR: 1, + lexerActionsUseLocationTracking: 1, + lexerActionsUseMore: 1, + lexerActionsUseUnput: 1, + lexerActionsUseReject: 1, + lexerActionsUseLess: 1, + lexerActionsUseDisplayAPIs: 1, + lexerActionsUseDescribeYYLOC: 1 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -15785,8 +15852,8 @@ function generateModuleBody(opt) { } // And now some options which should receive some special processing: - var pre = obj.pre_lex; - var post = obj.post_lex; + let pre = obj.pre_lex; + let post = obj.post_lex; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_lex = true; @@ -15795,7 +15862,7 @@ function generateModuleBody(opt) { obj.post_lex = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$1})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_lex: true(,)?$/gm, function (m, ls, tc) { @@ -15808,17 +15875,17 @@ function generateModuleBody(opt) { } - var out; + let out; if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) { // we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. - var code = [rmCommonWS$2` - var lexer = { - `, '/*JISON-LEX-ANALYTICS-REPORT*/' /* slot #1: placeholder for analysis report further below */ + let code = [ rmCommonWS$2` + const lexer = { + `, '/* JISON-LEX-ANALYTICS-REPORT */\n' /* slot #1: placeholder for analysis report further below */ ]; // get the RegExpLexer.prototype in source code form: - var protosrc = getRegExpLexerPrototype(); + let protosrc = getRegExpLexerPrototype(); // and strip off the surrounding bits we don't want: protosrc = protosrc .replace(/^[\s\r\n]*\{/, '') @@ -15845,10 +15912,10 @@ function generateModuleBody(opt) { } */ - var performActionCode = String(opt.performAction); - var simpleCaseActionClustersCode = String(opt.caseHelperInclude); - var rulesCode = generateRegexesInitTableCode(opt); - var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); + let performActionCode = String(opt.performAction); + let simpleCaseActionClustersCode = String(opt.caseHelperInclude); + let rulesCode = generateRegexesInitTableCode(opt); + let conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); code.push(rmCommonWS$2`, JisonLexerError: JisonLexerError, performAction: ${performActionCode}, @@ -15868,9 +15935,9 @@ function generateModuleBody(opt) { // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // - // Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter + // Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. - out = 'var lexer;\n'; + out = '\n'; assert__default['default'](opt.regular_rule_count === 0); assert__default['default'](opt.simple_rule_count === 0); @@ -15884,8 +15951,6 @@ function generateModuleBody(opt) { // The output of this function is guaranteed to read something like this: // // ``` - // var lexer; - // // bla bla bla bla ... lotsa bla bla; // ``` // @@ -15894,7 +15959,7 @@ function generateModuleBody(opt) { } function generateGenericHeaderComment() { - var out = rmCommonWS$2` + let out = rmCommonWS$2` /* lexer generated by jison-lex ${version} */ /* @@ -16123,7 +16188,7 @@ function prepareOptions(opt) { // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else { @@ -16141,9 +16206,9 @@ function prepareOptions(opt) { function generateModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -16166,9 +16231,9 @@ function generateModule(opt) { function generateAMDModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} define([], function () { @@ -16191,12 +16256,12 @@ function generateAMDModule(opt) { function generateESModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} - var lexer = (function () { + const lexer = (function () { "use strict"; ${jisonLexerErrorDefinition} @@ -16225,9 +16290,9 @@ function generateESModule(opt) { function generateCommonJSModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -16269,7 +16334,6 @@ RegExpLexer.autodetectAndConvertToJSONformat = autodetectAndConvertToJSONformat; // 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. function JisonParserError$1(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -16286,9 +16350,9 @@ function JisonParserError$1(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -16321,10 +16385,10 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp$1(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -16339,18 +16403,18 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt$1(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -16381,7 +16445,7 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // `this` references an array function s$1(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -16398,9 +16462,9 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$1(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -16413,7 +16477,7 @@ JisonParserError$1.prototype.name = 'JisonParserError'; } -var parser$1 = { +let parser$1 = { // Code Generator Information Report // --------------------------------- // @@ -16539,7 +16603,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -16547,7 +16610,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -16559,8 +16621,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -16573,14 +16635,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -16596,10 +16657,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -16607,10 +16668,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -16654,9 +16715,9 @@ performAction: function parser__PerformAction(yystate /* action[1] */, yysp, yyv /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; @@ -16664,17 +16725,17 @@ performAction: function parser__PerformAction(yystate /* action[1] */, yysp, yyv case 0: /*! Production:: $accept : production $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-) break; case 1: /*! Production:: production : handle EOF */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-) return yyvstack[yysp - 1]; @@ -16910,7 +16971,6 @@ defaultActions: { 19: 3 }, parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -16927,37 +16987,32 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) + let vstack = new Array(128); // semantic value stack - var vstack = new Array(128); // semantic value stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks + let symbol = 0; - + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - var symbol = 0; - - - - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -16965,20 +17020,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -16995,7 +17048,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -17003,18 +17055,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -17022,18 +17075,14 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -17055,7 +17104,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -17068,7 +17116,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -17082,11 +17129,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -17140,8 +17186,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -17290,8 +17336,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -17300,10 +17345,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -17311,7 +17356,7 @@ parse: function parse(input) { stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -17322,9 +17367,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -17350,8 +17400,7 @@ parse: function parse(input) { function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -17360,21 +17409,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -17384,21 +17432,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -17407,20 +17454,20 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; try { @@ -17433,7 +17480,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -17486,14 +17533,11 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { - var errStr; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let errStr; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); // Report error errStr = 'Parse error'; @@ -17530,9 +17574,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -17561,7 +17603,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -17603,21 +17645,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, newState, sp - 1, vstack); +r = this.performAction.call(yyval, newState, sp - 1, vstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -17648,14 +17688,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -17665,6 +17706,7 @@ parse: function parse(input) { + } continue; // accept: @@ -17717,8 +17759,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -17978,7 +18019,6 @@ var lexer$1 = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -17995,10 +18035,10 @@ var lexer$1 = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -18030,7 +18070,7 @@ var lexer$1 = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -18072,7 +18112,9 @@ var lexer$1 = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -18158,7 +18200,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -18166,7 +18208,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -18179,7 +18221,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -18205,10 +18247,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -18231,7 +18276,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -18254,16 +18298,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -18285,7 +18329,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -18293,8 +18336,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -18323,7 +18366,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -18348,7 +18391,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -18360,17 +18403,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -18464,7 +18507,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -18485,7 +18528,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -18496,7 +18538,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -18507,15 +18549,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -18549,8 +18591,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -18583,9 +18625,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -18604,9 +18646,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -18616,8 +18658,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -18644,20 +18686,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -18697,17 +18738,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -18716,7 +18759,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -18731,8 +18774,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -18758,24 +18801,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -18786,7 +18831,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -18808,8 +18853,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -18831,8 +18876,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -18976,21 +19020,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -19005,11 +19049,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -19028,13 +19072,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -19058,13 +19102,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -19079,8 +19123,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -19111,7 +19155,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -19143,9 +19187,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -19174,7 +19218,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -19192,7 +19236,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -19217,7 +19261,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -19227,8 +19270,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -19237,7 +19278,7 @@ EOF: 1, this.clear(); } - 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. @@ -19249,13 +19290,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -19265,68 +19306,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -19351,7 +19398,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -19399,24 +19446,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -19436,7 +19483,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -19446,24 +19493,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -19484,8 +19531,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -19525,14 +19571,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -19548,9 +19594,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -19561,8 +19607,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -19570,7 +19616,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -19723,9 +19769,9 @@ const ID_REGEX_BASE$2 = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // guaranteed not to collide with previously generated / already existing // rules (~ symbols). function generateUniqueSymbol(id, postfix, opts) { - var sym = id + postfix; + let sym = id + postfix; if (opts.grammar[sym]) { - var i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. + let i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. do { sym = id + postfix + i; i++; @@ -19735,8 +19781,8 @@ function generateUniqueSymbol(id, postfix, opts) { } function generatePushAction(handle, offset) { - var terms = handle.terms; - var rv = []; + const terms = handle.terms; + let rv = []; for (var i = 0, len = terms.length; i < len; i++) { rv.push('$' + (i + offset)); @@ -19752,11 +19798,11 @@ function generatePushAction(handle, offset) { } function transformExpression(e, opts, emit) { - var type = e[0], - value = e[1], - name = false, - has_transformed = 0; - var list, n; + let type = e[0]; + let value = e[1]; + let name = false; + let has_transformed = 0; + let list, n; if (type === 'xalias') { type = e[1]; @@ -19783,7 +19829,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ list.fragment, @@ -19803,7 +19849,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ '', @@ -19823,7 +19869,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); // you want to be able to check if 0 or 1 occurrences were recognized: since jison // by default *copies* the lexer token value, i.e. `$$ = $1` is the (optional) default action, // we will need to set the action up explicitly in case of the 0-count match: @@ -19859,7 +19905,7 @@ function transformExpression(e, opts, emit) { opts = optsForProduction(name, opts.grammar); opts.grammar[name] = value.map(function (handle) { - var list = transformExpressionList(handle, opts); + let list = transformExpressionList(handle, opts); return [ list.fragment, '$$ = ' + generatePushAction(list, 1) + ';' @@ -19872,11 +19918,11 @@ function transformExpression(e, opts, emit) { } function transformExpressionList(list, opts) { - var first_transformed_term_index = false; - var terms = list.reduce(function (tot, e) { - var ci = tot.length; + let first_transformed_term_index = false; + let terms = list.reduce(function (tot, e) { + let ci = tot.length; - var has_transformed = transformExpression(e, opts, function (name) { + let has_transformed = transformExpression(e, opts, function (name) { if (name.terms) { tot.push.apply(tot, name.terms); } else { @@ -19905,42 +19951,42 @@ function optsForProduction(id, grammar) { } function transformProduction(id, production, grammar) { - var transform_opts = optsForProduction(id, grammar); + let transform_opts = optsForProduction(id, grammar); return production.map(function (handle) { - var action = null, - opts = null; - var i, len, n; + let action = null; + let opts = null; + let i, len, n; if (typeof handle !== 'string') { action = handle[1]; opts = handle[2]; handle = handle[0]; } - var expressions = handle; + let expressions = handle; if (typeof expressions === 'string') { expressions = parser$2.parse(handle); } - var list = transformExpressionList(expressions, transform_opts); + let list = transformExpressionList(expressions, transform_opts); - var ret = [list.fragment]; + let ret = [ list.fragment ]; if (action) { // make sure the action doesn't address any inner items. if (list.first_transformed_term_index) { // seek out all names and aliases; strip out literal tokens first as those cannot serve as $names: - var alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); + let alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); - var alias_re = new XRegExp__default['default'](`\\[${ID_REGEX_BASE$2}\\]`); - var term_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$2}$`); + let alias_re = new XRegExp__default['default'](`\\[${ID_REGEX_BASE$2}\\]`); + let term_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$2}$`); // and collect the PERMITTED aliases: the names of the terms and all the remaining aliases - var good_aliases = {}; - var alias_cnt = {}; - var donotalias = {}; + let good_aliases = {}; + let alias_cnt = {}; + let donotalias = {}; // WARNING: this replicates the knowledge/code of jison.js::addName() - var addName = function addNameEBNF(s, i) { - var base = s.replace(/[0-9]+$/, ''); - var dna = donotalias[base]; + let addName = function addNameEBNF(s, i) { + let base = s.replace(/[0-9]+$/, ''); + let dna = donotalias[base]; if (good_aliases[s]) { alias_cnt[s]++; @@ -19959,7 +20005,7 @@ function transformProduction(id, production, grammar) { }; // WARNING: this replicates the knowledge/code of jison.js::markBasename() - var markBasename = function markBasenameEBNF(s) { + let markBasename = function markBasenameEBNF(s) { if (/[0-9]$/.test(s)) { s = s.replace(/[0-9]+$/, ''); donotalias[s] = true; @@ -19996,13 +20042,13 @@ function transformProduction(id, production, grammar) { // now scan the action for all named and numeric semantic values ($nonterminal / $1 / @1, ##1, ...) // // Note that `#name` are straight **static** symbol translations, which are okay as they don't - // require access to the parse stack: `#n` references can be resolved completely + // require access to the parse stack: `#n` references can be resolved completely // at grammar compile time. // - var nameref_re = new XRegExp__default['default'](`(?:[$@]|##)${ID_REGEX_BASE$2}`, 'g'); - var named_spots = nameref_re.exec(action); - var numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); - var max_term_index = list.terms.length; + let nameref_re = new XRegExp__default['default'](`(?:[$@]|##)${ID_REGEX_BASE$2}`, 'g'); + let named_spots = nameref_re.exec(action); + let numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); + let max_term_index = list.terms.length; // loop through the XRegExp alias regex matches in `action` while (named_spots) { @@ -20032,7 +20078,7 @@ function transformProduction(id, production, grammar) { for (i = 0, len = numbered_spots.length; i < len; i++) { n = parseInt(numbered_spots[i].replace(/^(?:[$@]|##)/, '')); if (n > max_term_index) { - /* @const */ var n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; + /* @const */ let n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; throw new Error('The action block references the ' + n + n_suffixes[Math.max(0, Math.min(3, n - 1))] + ' term, ' + 'which is not available in production "' + handle + '"; ' + 'Be reminded that you cannot reference sub-elements within EBNF */+/? groups, ' + @@ -20050,13 +20096,14 @@ function transformProduction(id, production, grammar) { if (ret.length === 1) { return ret[0]; - } else { - return ret; } + return ret; + }); } -var ref_list; -var ref_names; + +let ref_list; +let ref_names; // create a deep copy of the input, so we will keep the input constant. function deepClone(from, sub) { @@ -20071,7 +20118,7 @@ function deepClone(from, sub) { return from; } - var idx = ref_list.indexOf(from); + let idx = ref_list.indexOf(from); if (idx >= 0) { throw new Error('[Circular/Xref:' + ref_names[i] + ']'); // circular or cross reference } @@ -20087,7 +20134,7 @@ function deepClone(from, sub) { sub += '.'; var to = new from.constructor(); - for (var name in from) { + for (let name in from) { to[name] = deepClone(from[name], sub + name); } } @@ -20103,8 +20150,9 @@ function transformGrammar(grammar) { return grammar; } + function transform(ebnf) { - var rv = transformGrammar(ebnf); + let rv = transformGrammar(ebnf); return rv; } @@ -20114,7 +20162,6 @@ function transform(ebnf) { // 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. function JisonParserError$2(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -20131,9 +20178,9 @@ function JisonParserError$2(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -20166,10 +20213,10 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp$2(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -20182,11 +20229,11 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda$1(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -20196,18 +20243,18 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt$2(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -20238,7 +20285,7 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // `this` references an array function s$2(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -20255,9 +20302,9 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$2(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -20270,7 +20317,7 @@ JisonParserError$2.prototype.name = 'JisonParserError'; } -var parser$3 = { +let parser$3 = { // Code Generator Information Report // --------------------------------- // @@ -20506,7 +20553,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -20514,7 +20560,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -20526,8 +20571,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -20540,14 +20585,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -20563,10 +20607,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -20574,10 +20618,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -20758,26 +20802,26 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; switch (yystate) { case 0: /*! Production:: $accept : spec $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break; case 1: /*! Production:: spec : declaration_list "%%" grammar optional_end_block EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4]; @@ -20789,10 +20833,10 @@ case 1: case 2: /*! Production:: spec : declaration_list "%%" grammar error EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -20811,10 +20855,10 @@ case 2: case 3: /*! Production:: spec : declaration_list error EOF */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -20836,9 +20880,9 @@ case 118: case 133: /*! Production:: optional_module_code_chunk : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -20847,9 +20891,9 @@ case 133: case 5: /*! Production:: optional_end_block : "%%" extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20869,9 +20913,9 @@ case 6: case 10: /*! Production:: declaration_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; @@ -20882,9 +20926,9 @@ case 7: case 8: /*! Production:: optional_action_header_block : optional_action_header_block include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -20903,9 +20947,9 @@ case 8: case 9: /*! Production:: declaration_list : declaration_list declaration */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20914,10 +20958,10 @@ case 9: case 11: /*! Production:: declaration_list : declaration_list error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -20932,9 +20976,9 @@ case 11: case 12: /*! Production:: declaration : START id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {start: yyvstack[yysp]}; @@ -20943,9 +20987,9 @@ case 12: case 13: /*! Production:: declaration : LEX_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {lex: {text: yyvstack[yysp], position: yylstack[yysp]}}; @@ -20954,9 +20998,9 @@ case 13: case 14: /*! Production:: declaration : operator */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {operator: yyvstack[yysp]}; @@ -20965,9 +21009,9 @@ case 14: case 15: /*! Production:: declaration : TOKEN full_token_definitions */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {token_list: yyvstack[yysp]}; @@ -20976,9 +21020,9 @@ case 15: case 16: /*! Production:: declaration : ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20996,9 +21040,9 @@ case 16: case 17: /*! Production:: declaration : include_macro_code */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21016,9 +21060,9 @@ case 17: case 18: /*! Production:: declaration : parse_params */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parseParams: yyvstack[yysp]}; @@ -21027,9 +21071,9 @@ case 18: case 19: /*! Production:: declaration : parser_type */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parserType: yyvstack[yysp]}; @@ -21038,9 +21082,9 @@ case 19: case 20: /*! Production:: declaration : options */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: yyvstack[yysp]}; @@ -21049,9 +21093,9 @@ case 20: case 21: /*! Production:: declaration : DEBUG */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: [['debug', true]]}; @@ -21060,9 +21104,9 @@ case 21: case 22: /*! Production:: declaration : EBNF */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) ebnf = true; @@ -21072,9 +21116,9 @@ case 22: case 23: /*! Production:: declaration : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {unknownDecl: yyvstack[yysp]}; @@ -21083,9 +21127,9 @@ case 23: case 24: /*! Production:: declaration : IMPORT import_name import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = {imports: {name: yyvstack[yysp - 1], path: yyvstack[yysp]}}; @@ -21094,10 +21138,10 @@ case 24: case 25: /*! Production:: declaration : IMPORT import_name error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21113,10 +21157,10 @@ case 25: case 26: /*! Production:: declaration : IMPORT error import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21132,9 +21176,9 @@ case 26: case 27: /*! Production:: declaration : INIT_CODE init_code_name action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21157,10 +21201,10 @@ case 27: case 28: /*! Production:: declaration : INIT_CODE error action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21176,10 +21220,10 @@ case 28: case 29: /*! Production:: declaration : START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21194,10 +21238,10 @@ case 29: case 30: /*! Production:: declaration : TOKEN error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21212,10 +21256,10 @@ case 30: case 31: /*! Production:: declaration : IMPORT error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21280,9 +21324,9 @@ case 129: case 132: /*! Production:: optional_module_code_chunk : module_code_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -21293,9 +21337,9 @@ case 39: case 111: /*! Production:: action_ne : "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21304,10 +21348,10 @@ case 111: case 40: /*! Production:: options : OPTIONS error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21322,10 +21366,10 @@ case 40: case 41: /*! Production:: options : OPTIONS error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21344,9 +21388,9 @@ case 59: case 70: /*! Production:: id_list : id_list id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21361,9 +21405,9 @@ case 71: case 84: /*! Production:: handle_list : handle_action */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -21372,9 +21416,9 @@ case 84: case 44: /*! Production:: option : NAME */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -21383,9 +21427,9 @@ case 44: case 45: /*! Production:: option : NAME "=" OPTION_STRING_VALUE */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -21396,9 +21440,9 @@ case 46: case 47: /*! Production:: option : NAME "=" NAME */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], parseValue$1(yyvstack[yysp])]; @@ -21407,10 +21451,10 @@ case 47: case 48: /*! Production:: option : NAME "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21425,10 +21469,10 @@ case 48: case 49: /*! Production:: option : NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21445,9 +21489,9 @@ case 50: case 52: /*! Production:: parser_type : PARSER_TYPE symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -21456,10 +21500,10 @@ case 52: case 51: /*! Production:: parse_params : PARSE_PARAM error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21477,10 +21521,10 @@ case 51: case 53: /*! Production:: parser_type : PARSER_TYPE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21498,9 +21542,9 @@ case 53: case 54: /*! Production:: operator : associativity token_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1]]; this.$.push.apply(this.$, yyvstack[yysp]); @@ -21509,10 +21553,10 @@ case 54: case 55: /*! Production:: operator : associativity error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21530,9 +21574,9 @@ case 55: case 56: /*! Production:: associativity : LEFT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'left'; @@ -21541,9 +21585,9 @@ case 56: case 57: /*! Production:: associativity : RIGHT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'right'; @@ -21552,9 +21596,9 @@ case 57: case 58: /*! Production:: associativity : NONASSOC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'nonassoc'; @@ -21563,9 +21607,9 @@ case 58: case 61: /*! Production:: full_token_definitions : optional_token_type id_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var rv = []; @@ -21584,9 +21628,9 @@ case 61: case 62: /*! Production:: full_token_definitions : optional_token_type one_full_token */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var m = yyvstack[yysp]; @@ -21599,9 +21643,9 @@ case 62: case 63: /*! Production:: one_full_token : id token_value token_description */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21614,9 +21658,9 @@ case 63: case 64: /*! Production:: one_full_token : id token_description */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21628,9 +21672,9 @@ case 64: case 65: /*! Production:: one_full_token : id token_value */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21642,9 +21686,9 @@ case 65: case 66: /*! Production:: optional_token_type : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = false; @@ -21653,9 +21697,9 @@ case 66: case 72: /*! Production:: grammar : optional_action_header_block production_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21665,9 +21709,9 @@ case 72: case 73: /*! Production:: production_list : production_list production */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21681,9 +21725,9 @@ case 73: case 74: /*! Production:: production_list : production */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; this.$[yyvstack[yysp][0]] = yyvstack[yysp][1]; @@ -21692,9 +21736,9 @@ case 74: case 75: /*! Production:: production : production_id handle_list ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp - 1]]; @@ -21703,10 +21747,10 @@ case 75: case 76: /*! Production:: production : production_id error ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21724,10 +21768,10 @@ case 76: case 77: /*! Production:: production : production_id error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21745,9 +21789,9 @@ case 77: case 78: /*! Production:: production_id : id optional_production_description ":" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21758,10 +21802,10 @@ case 78: case 79: /*! Production:: production_id : id optional_production_description error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21779,10 +21823,10 @@ case 79: case 80: /*! Production:: production_id : id optional_production_description ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21806,18 +21850,18 @@ case 80: case 82: /*! Production:: optional_production_description : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) break; case 83: /*! Production:: handle_list : handle_list "|" handle_action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21827,10 +21871,10 @@ case 83: case 85: /*! Production:: handle_list : handle_list "|" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21848,10 +21892,10 @@ case 85: case 86: /*! Production:: handle_list : handle_list ":" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21866,9 +21910,9 @@ case 86: case 87: /*! Production:: handle_action : handle prec action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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(' ') : '')]; @@ -21903,9 +21947,9 @@ case 87: case 88: /*! Production:: handle_action : EPSILON action */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = ['']; @@ -21929,10 +21973,10 @@ case 88: case 89: /*! Production:: handle_action : EPSILON error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21947,9 +21991,9 @@ case 89: case 90: /*! Production:: handle : handle suffixed_expression */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21959,9 +22003,9 @@ case 90: case 91: /*! Production:: handle : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -21970,9 +22014,9 @@ case 91: case 92: /*! Production:: handle_sublist : handle_sublist "|" handle */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21982,9 +22026,9 @@ case 92: case 93: /*! Production:: handle_sublist : handle */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp].join(' ')]; @@ -21993,9 +22037,9 @@ case 93: case 94: /*! Production:: suffixed_expression : expression suffix ALIAS */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + "[" + yyvstack[yysp] + "]"; @@ -22008,9 +22052,9 @@ case 124: case 130: /*! Production:: module_code_chunk : module_code_chunk CODE */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22019,9 +22063,9 @@ case 130: case 97: /*! Production:: expression : EOF_ID */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$end'; @@ -22030,9 +22074,9 @@ case 97: case 98: /*! Production:: expression : STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // Re-encode the string *anyway* as it will @@ -22045,9 +22089,9 @@ case 98: case 99: /*! Production:: expression : "(" handle_sublist ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1].join(' | ') + ')'; @@ -22056,10 +22100,10 @@ case 99: case 100: /*! Production:: expression : "(" handle_sublist error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22073,9 +22117,9 @@ case 100: case 105: /*! Production:: prec : PREC symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { prec: yyvstack[yysp] }; @@ -22084,10 +22128,10 @@ case 105: case 106: /*! Production:: prec : PREC error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -22105,9 +22149,9 @@ case 106: case 107: /*! Production:: prec : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = null; @@ -22116,10 +22160,10 @@ case 107: case 112: /*! Production:: action_ne : "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22133,9 +22177,9 @@ case 112: case 116: /*! Production:: action : ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$$ = (' + yyvstack[yysp] + ');'; @@ -22144,9 +22188,9 @@ case 116: case 120: /*! Production:: action_body : action_body "{" action_body "}" action_comments_body */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4] + yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22155,9 +22199,9 @@ case 120: case 121: /*! Production:: action_body : action_body "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22166,10 +22210,10 @@ case 121: case 122: /*! Production:: action_body : action_body "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22183,9 +22227,9 @@ case 122: case 126: /*! Production:: extra_parser_module_code : optional_module_code_chunk include_macro_code extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22194,9 +22238,9 @@ case 126: case 127: /*! Production:: include_macro_code : INCLUDE PATH */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' }); @@ -22216,10 +22260,10 @@ case 127: case 128: /*! Production:: include_macro_code : INCLUDE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22232,10 +22276,10 @@ case 128: case 131: /*! Production:: module_code_chunk : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -23628,7 +23672,6 @@ defaultActions: bda$1({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -23645,38 +23688,34 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -23684,20 +23723,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -23719,7 +23756,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -23727,18 +23763,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -23746,24 +23783,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -23801,18 +23833,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -23833,7 +23862,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -23851,7 +23880,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -23864,7 +23892,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -23878,11 +23905,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -23936,8 +23962,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -23945,8 +23971,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -23978,19 +24004,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -24001,7 +24026,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -24014,7 +24039,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -24026,29 +24051,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -24056,7 +24079,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -24076,8 +24099,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -24086,10 +24108,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -24097,7 +24119,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -24108,9 +24130,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -24126,8 +24153,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -24196,11 +24222,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -24211,8 +24240,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -24221,21 +24249,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -24245,21 +24272,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -24268,28 +24294,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -24302,8 +24327,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -24326,8 +24350,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -24339,8 +24362,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -24357,8 +24379,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -24372,8 +24393,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -24387,7 +24407,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -24440,16 +24460,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -24483,9 +24500,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -24508,9 +24523,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -24537,17 +24550,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -24594,8 +24606,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -24607,8 +24619,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -24626,6 +24637,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -24634,7 +24646,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -24645,7 +24657,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -24705,10 +24717,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -24743,9 +24755,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -24758,7 +24768,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -24779,9 +24789,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -24803,12 +24811,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -24817,7 +24825,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -24858,7 +24866,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -24905,7 +24913,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -24923,21 +24931,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -24971,14 +24977,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -24988,6 +24995,7 @@ parse: function parse(input) { + } continue; // accept: @@ -25039,7 +25047,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -25055,9 +25063,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -25086,7 +25092,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -25103,8 +25109,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -25115,8 +25121,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -25128,21 +25134,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -25173,14 +25177,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -25190,6 +25195,7 @@ parse: function parse(input) { + } continue; // accept: @@ -25242,8 +25248,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -25504,7 +25509,6 @@ var lexer$2 = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -25521,10 +25525,10 @@ var lexer$2 = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -25556,7 +25560,7 @@ var lexer$2 = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -25598,7 +25602,9 @@ var lexer$2 = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -25684,7 +25690,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -25692,7 +25698,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -25705,7 +25711,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -25731,10 +25737,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -25757,7 +25766,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -25780,16 +25788,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -25811,7 +25819,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -25819,8 +25826,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -25849,7 +25856,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -25874,7 +25881,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -25886,17 +25893,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -25990,7 +25997,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -26011,7 +26018,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -26022,7 +26028,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -26033,15 +26039,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -26075,8 +26081,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -26109,9 +26115,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -26130,9 +26136,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -26142,8 +26148,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -26170,20 +26176,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -26223,17 +26228,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -26242,7 +26249,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -26257,8 +26264,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -26284,24 +26291,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -26312,7 +26321,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -26334,8 +26343,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -26357,8 +26366,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -26502,21 +26510,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -26531,11 +26539,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -26554,13 +26562,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -26584,13 +26592,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -26605,8 +26613,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -26637,7 +26645,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -26669,9 +26677,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -26700,7 +26708,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -26718,7 +26726,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -26743,7 +26751,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -26753,8 +26760,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -26763,7 +26768,7 @@ EOF: 1, this.clear(); } - 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. @@ -26775,13 +26780,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -26791,68 +26796,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -26877,7 +26888,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -26925,24 +26936,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -26962,7 +26973,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -26972,24 +26983,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -27010,8 +27021,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -27051,14 +27061,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -27074,9 +27084,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -27087,8 +27097,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -27096,7 +27106,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -28141,7 +28151,7 @@ var bnf = { }; -var version$1 = '0.6.2-220'; // require('./package.json').version; +const version$1 = '0.6.2-220'; // require('./package.json').version; function parse(grammar) { return bnf.parser.parse(grammar); @@ -28207,7 +28217,7 @@ bnf.parser.yy.addDeclaration = function bnfAddDeclaration(grammar, decl) { if (decl.options) { if (!grammar.options) grammar.options = {}; // last occurrence of `%options` wins: - for (var i = 0; i < decl.options.length; i++) { + for (let i = 0; i < decl.options.length; i++) { grammar.options[decl.options[i][0]] = decl.options[i][1]; } } @@ -28247,9 +28257,9 @@ function parseLex(text, position) { // which matches the original input file: position = position || {}; position.range = position.range || []; - var l = position.first_line | 0; - var c = position.range[0] | 0; - var prelude = ''; + let l = position.first_line | 0; + let c = position.range[0] | 0; + let prelude = ''; if (l > 1) { prelude += (new Array(l)).join('\n'); c -= prelude.length; @@ -28274,10 +28284,10 @@ var ebnfParser = { ebnf_parser, bnf_lexer: lexParser, - version: version$1, + version: version$1 }; -var rmCommonWS$4 = helpers.rmCommonWS; +const rmCommonWS$4 = helpers.rmCommonWS; /** @@ -28303,14 +28313,14 @@ function grammarPrinter(raw, options) { case 'json5': options.format = 'json5'; break; - + case '.y': case '.yacc': options.format = 'jison'; options.showLexer = false; options.showParser = true; break; - + case '.l': case '.lex': options.format = 'jison'; @@ -28332,20 +28342,20 @@ function grammarPrinter(raw, options) { // which MAY get corrupted that way as their actual content would change then! // construct fake nesting levels to arrive at the intended start indent value: `num` - var nesting_levels = num / 2; - var pre = '// **PRE**', - post = '// **POST**'; - for ( ; nesting_levels > 0; nesting_levels--) { + let nesting_levels = num / 2; + let pre = '// **PRE**'; + let post = '// **POST**'; + for (; nesting_levels > 0; nesting_levels--) { pre = 'function x() {\n' + pre; post += '\n}'; } - src = '\n' + pre + '\n' + src + '\n' + post + '\n'; + src = '\n' + pre + '\n' + src + '\n' + post + '\n'; - var ast = helpers.parseCodeChunkToAST(src, options); - var new_src = helpers.prettyPrintAST(ast, options); + let ast = helpers.parseCodeChunkToAST(src, options); + let new_src = helpers.prettyPrintAST(ast, options); - var start = new_src.indexOf('// **PRE**'); - var end = new_src.lastIndexOf('// **POST**'); + let start = new_src.indexOf('// **PRE**'); + let end = new_src.lastIndexOf('// **POST**'); new_src = new_src .substring(start + 10, end) .trim(); @@ -28354,13 +28364,13 @@ function grammarPrinter(raw, options) { } function isEmptyObj(obj) { - var keys = obj && typeof obj === 'object' && Object.keys(obj); + let keys = obj && typeof obj === 'object' && Object.keys(obj); return keys && keys.length === 0; } function isEmptyArr(arr) { if (arr && arr instanceof Array) { - for (var i = 0, len = arr.length; i < len; i++) { + for (let i = 0, len = arr.length; i < len; i++) { if (arr[i] !== undefined) { return false; } @@ -28373,8 +28383,8 @@ function grammarPrinter(raw, options) { // Copied from Crokford's implementation of JSON // See https://github.com/douglascrockford/JSON-js/blob/e39db4b7e6249f04a195e7dd0840e610cc9e941e/json2.js#L195 // Begin - var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - meta = { // table of character substitutions + let escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; + let meta = { // table of character substitutions '\b': '\\b', '\t': '\\t', '\n': '\\n', @@ -28391,15 +28401,15 @@ function grammarPrinter(raw, options) { // sequences. escapable.lastIndex = 0; return escapable.test(string) ? '"' + string.replace(escapable, function (a) { - var c = meta[a]; + let c = meta[a]; return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }) + '"' : '"' + string + '"'; } - var ref_list; - var ref_names; + let ref_list; + let ref_names; // create a deep copy of the input, so we can delete the parts we converted and dump the remainder // so that we always output the entire thing, even when we don't know all the details about the @@ -28416,7 +28426,7 @@ function grammarPrinter(raw, options) { return from; } - for (var i = 0, len = ref_list.length; i < len; i++) { + for (let i = 0, len = ref_list.length; i < len; i++) { if (ref_list[i] === from) { return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference } @@ -28425,204 +28435,211 @@ function grammarPrinter(raw, options) { ref_names.push(sub); sub += '.'; - var to = new from.constructor(); - for (var name in from) { + let to = new from.constructor(); + for (let name in from) { to[name] = deepClone(from[name], sub + name); } return to; } - var originalInput = raw; + let originalInput = raw; raw = deepClone(raw); - var lex_out_str = ''; + let lex_out_str = ''; if (raw.lex) { var lex_pre = []; - var lex_rules = []; - var lex_post = []; - var key, src; + let lex_rules = []; + let lex_post = []; + + { + let src = raw.lex.macros; + delete raw.lex.macros; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // macros: + `); - src = raw.lex.macros; - delete raw.lex.macros; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // macros: - `); + let keylen = 0; + for (let key in src) { + keylen = Math.max(keylen, key.length); + } + console.log('macros keylen:', keylen); + keylen = ((keylen / 4) | 0) * 4 + 4; + console.log('macros keylen B:', keylen); + for (let key in src) { + lex_pre.push(padRight(key, keylen) + src[key]); + } - var keylen = 0; - for (key in src) { - keylen = Math.max(keylen, key.length); - } - console.log('macros keylen:', keylen); - keylen = ((keylen / 4) | 0) * 4 + 4; - console.log('macros keylen B:', keylen); - for (key in src) { - lex_pre.push(padRight(key, keylen) + src[key]); + lex_pre.push(rmCommonWS$4` + // END of the lexer macros. + `); } - - lex_pre.push(rmCommonWS$4` - // END of the lexer macros. - `); } - src = raw.lex.unknownDecls; - delete raw.lex.unknownDecls; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // unknown declarations: - `); + { + let src = raw.lex.unknownDecls; + delete raw.lex.unknownDecls; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // unknown declarations: + `); - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry.name; + let value = entry.value; - lex_pre.push('%' + key + ' ' + value); - } + lex_pre.push('%' + key + ' ' + value); + } - lex_pre.push(rmCommonWS$4` - // END of unknown declarations. - `); + lex_pre.push(rmCommonWS$4` + // END of unknown declarations. + `); + } } - src = raw.lex.options; - delete raw.lex.options; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // options: - `); + { + let src = raw.lex.options; + delete raw.lex.options; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // options: + `); - for (key in src) { - var value = src[key]; - if (value) { - lex_pre.push('%options ' + key + '=' + value); - } - else { - lex_pre.push('%options ' + key); + for (let key in src) { + let value = src[key]; + if (value) { + lex_pre.push('%options ' + key + '=' + value); + } else { + lex_pre.push('%options ' + key); + } } } } - src = raw.lex.startConditions; - delete raw.lex.startConditions; - if (src && !isEmptyObj(src)) { - for (key in src) { - var value = src[key]; + { + let src = raw.lex.startConditions; + delete raw.lex.startConditions; + if (src && !isEmptyObj(src)) { + for (let key in src) { + let value = src[key]; - lex_pre.push((value ? '%x ' : '%s ') + key); + lex_pre.push((value ? '%x ' : '%s ') + key); + } } } - src = raw.lex.actionInclude; - delete raw.lex.actionInclude; - if (src && src.trim()) { - lex_pre.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + { + let src = raw.lex.actionInclude; + delete raw.lex.actionInclude; + if (src && src.trim()) { + lex_pre.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + } } - src = raw.lex.rules; - delete raw.lex.rules; - if (src) { - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - key = entry[0]; - var action = indentAction(entry[1], 4); - - var actionHasLF = /[\r\n]/.test(action); - console.log('indented action:', { - entry: entry[1], - action, - actionHasLF - }); - if (key.length <= 12) { - if (!actionHasLF) { - lex_rules.push(padRight(key, 16) + indentAction(action, 16)); - } - else { - lex_rules.push(padRight(key, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); - } - } - else { - if (!actionHasLF) { + { + let src = raw.lex.rules; + delete raw.lex.rules; + if (src) { + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry[0]; + let action = indentAction(entry[1], 4); + + let actionHasLF = /[\r\n]/.test(action); + console.log('indented action:', { + entry: entry[1], + action, + actionHasLF + }); + if (key.length <= 12) { + if (!actionHasLF) { + lex_rules.push(padRight(key, 16) + indentAction(action, 16)); + } else { + lex_rules.push(padRight(key, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + } + } else if (!actionHasLF) { lex_rules.push(key, makeIndent(16) + indentAction(action, 16)); - } - else { + } else { lex_rules.push(key, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } } } - src = raw.lex.moduleInclude; - delete raw.lex.moduleInclude; - if (src && src.trim()) { - lex_post.push(indentAction(src.trim(), 0)); + { + let src = raw.lex.moduleInclude; + delete raw.lex.moduleInclude; + if (src && src.trim()) { + lex_post.push(indentAction(src.trim(), 0)); + } } - var out = ''; + { + let out = ''; - if (!isEmptyObj(raw.lex)) { - // dump the remainder as a comment: - var rem = JSON5__default['default'].stringify(raw.lex, null, 2); - out += rmCommonWS$4` - /* - * Lexer stuff that's unknown to the JISON prettyPrint service: - * - * ${rem.replace(/\*\//g, '*\\/')} - */ + if (!isEmptyObj(raw.lex)) { + // dump the remainder as a comment: + let rem = JSON5__default['default'].stringify(raw.lex, null, 2); + out += rmCommonWS$4` + /* + * Lexer stuff that's unknown to the JISON prettyPrint service: + * + * ${rem.replace(/\*\//g, '*\\/')} + */ - `; - } - delete raw.lex; - - out += lex_pre.join('\n') + '\n\n'; - out += rmCommonWS$4` - - %% + `; + } + delete raw.lex; - ` + lex_rules.join('\n') + '\n\n'; - if (lex_post.length > 0) { + out += lex_pre.join('\n') + '\n\n'; out += rmCommonWS$4` %% - ` + lex_post.join('\n') + '\n\n'; + ` + lex_rules.join('\n') + '\n\n'; + if (lex_post.length > 0) { + out += rmCommonWS$4` + + %% + + ` + lex_post.join('\n') + '\n\n'; + } + lex_out_str = out; } - lex_out_str = out; } - var grammar_pre = []; - var grammar_mid = []; - var ebnf_rules = []; - var bnf_rules = []; - var grammar_post = []; - var key, src; + let grammar_pre = []; + let grammar_mid = []; + let ebnf_rules = []; + let bnf_rules = []; + let grammar_post = []; - var fmtprod = function fmtprod(rule, prodset) { - var backup = deepClone(prodset); + let fmtprod = function fmtprod(rule, prodset) { + let backup = deepClone(prodset); rule += prodset[0] ? prodset[0] : '%epsilon'; - var prec = null; - var lead = rule.split(/\r\n\|\n|\r/).pop(); + let prec = null; + let lead = rule.split(/\r\n\|\n|\r/).pop(); delete prodset[0]; if (prodset.length === 3 && typeof prodset[2] === 'object') { prec = '%prec ' + prodset[2].prec; if (lead.length < 12) { rule += makeIndent(12 - lead.length); - } + } rule += ' ' + prec; delete prodset[2].prec; if (isEmptyObj(prodset[2])) { delete prodset[2]; } - } - else if (prodset.length === 2 && typeof prodset[1] === 'object') { + } else if (prodset.length === 2 && typeof prodset[1] === 'object') { prec = '%prec ' + prodset[1].prec; if (lead.length < 12) { rule += makeIndent(12 - lead.length); - } + } rule += ' ' + prec; delete prodset[1].prec; @@ -28631,84 +28648,73 @@ function grammarPrinter(raw, options) { } } if (typeof prodset[1] === 'string') { - var action = prodset[1]; + let action = prodset[1]; if (lead.length < 12 - 1) { - rule += makeIndent(12 - lead.length) + indentAction('{ ' + action + ' }', 12); - } - else { - rule += '\n' + makeIndent(12) + indentAction('{ ' + action + ' }', 12); + rule += makeIndent(12 - lead.length) + indentAction('{ ' + action + ' }', 12); + } else { + rule += '\n' + makeIndent(12) + indentAction('{ ' + action + ' }', 12); } delete prodset[1]; } if (isEmptyArr(prodset)) { prodset.length = 0; - } - else { + } else { prodset = backup; } return rule; }; - var grammarfmt = function grammarfmt(src) { - var key; - var dst = []; + let grammarfmt = function grammarfmt(src) { + let dst = []; - for (key in src) { - var prodset = src[key]; - var rule; + for (let key in src) { + let prodset = src[key]; + let rule; console.log('format one rule:', { - key, + key, prodset }); if (typeof prodset === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; + rule = fmtprod(key + ' : ', [ prodset ]) + ';'; delete src[key]; - } - else if (prodset instanceof Array) { + } else if (prodset instanceof Array) { if (prodset.length === 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; + rule = fmtprod(key + ' : ', [ prodset ]) + ';'; delete src[key]; - } - else if (prodset[0] instanceof Array) { + } else if (prodset[0] instanceof Array) { rule = fmtprod(key + ' : ', prodset[0]); rule += '\n ;'; if (prodset[0].length === 0) { delete src[key]; } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - } - else if (prodset.length > 1) { + } else if (prodset.length > 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + '\n : ', [prodset[0]]); + rule = fmtprod(key + '\n : ', [ prodset[0] ]); delete prodset[0]; - } - else if (prodset[0] instanceof Array) { + } else if (prodset[0] instanceof Array) { rule = fmtprod(key + '\n : ', prodset[0]); if (prodset[0].length === 0) { delete prodset[0]; } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - for (var i = 1, len = prodset.length; i < len; i++) { + for (let i = 1, len = prodset.length; i < len; i++) { if (typeof prodset[i] === 'string') { - rule += fmtprod('\n | ', [prodset[i]]); + rule += fmtprod('\n | ', [ prodset[i] ]); delete prodset[i]; - } - else if (prodset[i] instanceof Array) { + } else if (prodset[i] instanceof Array) { rule += fmtprod('\n | ', prodset[i]); if (prodset[i].length === 0) { delete prodset[i]; } - } - else { + } else { rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[i]; } } @@ -28718,8 +28724,7 @@ function grammarPrinter(raw, options) { delete src[key]; } } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; } dst.push(rule); @@ -28728,46 +28733,52 @@ function grammarPrinter(raw, options) { return dst; }; - src = raw.ebnf; - if (src) { - ebnf_rules = grammarfmt(src); + { + let src = raw.ebnf; + if (src) { + ebnf_rules = grammarfmt(src); - if (isEmptyObj(src)) { - delete raw.ebnf; + if (isEmptyObj(src)) { + delete raw.ebnf; + } } } - src = raw.bnf; - //delete raw.bnf; - if (src) { - bnf_rules = grammarfmt(src); + { + let src = raw.bnf; + //delete raw.bnf; + if (src) { + bnf_rules = grammarfmt(src); - if (isEmptyObj(src)) { - delete raw.bnf; + if (isEmptyObj(src)) { + delete raw.bnf; + } } } - src = raw.unknownDecls; - delete raw.unknownDecls; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // unknown declarations: - `); + { + let src = raw.unknownDecls; + delete raw.unknownDecls; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // unknown declarations: + `); - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry.name; + let value = entry.value; - lex_pre.push('%' + key + ' ' + value); - } + lex_pre.push('%' + key + ' ' + value); + } - lex_pre.push(rmCommonWS$4` - // END of unknown declarations. - `); + lex_pre.push(rmCommonWS$4` + // END of unknown declarations. + `); + } } - //src = raw.lex; + //let src = raw.lex; //delete raw.lex; //if (src) { if (lex_out_str.trim() && options.showLexer) { @@ -28785,294 +28796,305 @@ function grammarPrinter(raw, options) { `); } - src = raw.options; - delete raw.options; - if (src && !isEmptyObj(src)) { - var a = []; - for (key in src) { - var value = src[key]; - switch (key) { - default: - if (value !== true) { - a.push('options', '%options ' + key + '=' + value); - } - else { - a.push('options', '%options ' + key); - } - break; + { + let src = raw.options; + delete raw.options; + if (src && !isEmptyObj(src)) { + let a = []; + for (let key in src) { + let value = src[key]; + switch (key) { + default: + if (value !== true) { + a.push('options', '%options ' + key + '=' + value); + } else { + a.push('options', '%options ' + key); + } + break; - case 'ebnf': - if (value) { - a.push(key, '%ebnf'); - } - break; + case 'ebnf': + if (value) { + a.push(key, '%ebnf'); + } + break; - case 'type': - if (value) { - a.push(key, '%parser-type ' + value); - } - break; + case 'type': + if (value) { + a.push(key, '%parser-type ' + value); + } + break; - case 'debug': - if (typeof value !== 'boolean') { - a.push(key, '%debug ' + value); - } - else if (value) { - a.push(key, '%debug'); + case 'debug': + if (typeof value !== 'boolean') { + a.push(key, '%debug ' + value); + } else if (value) { + a.push(key, '%debug'); + } + break; } - break; } - } - var type = null; - for (var i = 0, len = a.length; i < len; i += 2) { - var t = a[i]; - var line = a[i + 1]; - if (t !== type) { - type = t; - grammar_pre.push(''); + let type = null; + for (let i = 0, len = a.length; i < len; i += 2) { + let t = a[i]; + let line = a[i + 1]; + if (t !== type) { + type = t; + grammar_pre.push(''); + } + grammar_pre.push(line); } - grammar_pre.push(line); + grammar_pre.push(''); } - grammar_pre.push(''); } - src = raw.imports; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - - grammar_pre.push('%import ' + entry.name + ' ' + entry.path); - delete entry.name; - delete entry.path; - if (isEmptyObj(entry)) { - delete src[i]; + { + let src = raw.imports; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + + grammar_pre.push('%import ' + entry.name + ' ' + entry.path); + delete entry.name; + delete entry.path; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } + } + if (clean) { + delete raw.imports; } - else { - clean = false; - } - } - if (clean) { - delete raw.imports; } } - src = raw.moduleInit; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - - grammar_pre.push('%code ' + entry.qualifier + ' ' + entry.include); - delete entry.qualifier; - delete entry.include; - if (isEmptyObj(entry)) { - delete src[i]; + { + let src = raw.moduleInit; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + + grammar_pre.push('%code ' + entry.qualifier + ' ' + entry.include); + delete entry.qualifier; + delete entry.include; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } + } + if (clean) { + delete raw.moduleInit; } - else { - clean = false; - } - } - if (clean) { - delete raw.moduleInit; } } - src = raw.operators; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var tokens = entry[1]; - var line = '%' + entry[0] + ' '; - - for (var t = 0, tlen = tokens.length; t < tlen; t++) { - line += ' ' + tokens[t]; - } + { + let src = raw.operators; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let tokens = entry[1]; + let line = '%' + entry[0] + ' '; + + for (let t = 0, tlen = tokens.length; t < tlen; t++) { + line += ' ' + tokens[t]; + } - grammar_pre.push(line); + grammar_pre.push(line); - if (entry.length === 2) { - delete src[i]; + if (entry.length === 2) { + delete src[i]; + } else { + clean = false; + } } - else { - clean = false; + if (clean) { + delete raw.operators; } } - if (clean) { - delete raw.operators; - } } - src = raw.extra_tokens; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var line = '%token ' + entry.id; - - if (entry.type) { - line += ' <' + entry.type + '>'; - delete entry.type; - } - if (entry.value) { - line += ' ' + entry.value; - delete entry.value; - } - if (entry.description) { - line += ' ' + escapeString(entry.description); - delete entry.description; - } + { + let src = raw.extra_tokens; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let line = '%token ' + entry.id; + + if (entry.type) { + line += ' <' + entry.type + '>'; + delete entry.type; + } + if (entry.value) { + line += ' ' + entry.value; + delete entry.value; + } + if (entry.description) { + line += ' ' + escapeString(entry.description); + delete entry.description; + } - grammar_pre.push(line); + grammar_pre.push(line); - delete entry.id; - if (isEmptyObj(entry)) { - delete src[i]; + delete entry.id; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } } - else { - clean = false; + if (clean) { + delete raw.extra_tokens; } } - if (clean) { - delete raw.extra_tokens; - } } - src = raw.parseParams; - delete raw.parseParams; - if (src) { - grammar_pre.push('%parse-param ' + src.join(' ')); + { + let src = raw.parseParams; + delete raw.parseParams; + if (src) { + grammar_pre.push('%parse-param ' + src.join(' ')); + } } - src = raw.start; - delete raw.start; - if (src) { - grammar_pre.push('%start ' + src); + { + let src = raw.start; + delete raw.start; + if (src) { + grammar_pre.push('%start ' + src); + } } - src = raw.moduleInclude; - delete raw.moduleInclude; - if (src && src.trim()) { - grammar_post.push(indentAction(src.trim(), 0)); + { + let src = raw.moduleInclude; + delete raw.moduleInclude; + if (src && src.trim()) { + grammar_post.push(indentAction(src.trim(), 0)); + } } - src = raw.actionInclude; - delete raw.actionInclude; - if (src && src.trim()) { - grammar_mid.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + { + let src = raw.actionInclude; + delete raw.actionInclude; + if (src && src.trim()) { + grammar_mid.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + } } - var out = ''; + { + let out = ''; - if (!isEmptyObj(raw)) { - // dump the remainder as a comment: - var rem = JSON5__default['default'].stringify(raw, null, 2); - out += rmCommonWS$4` - /* - * Parser stuff that's unknown to the JISON prettyPrint service: - * - * ${rem.replace(/\*\//g, '*\\/')} - */ + if (!isEmptyObj(raw)) { + // dump the remainder as a comment: + let rem = JSON5__default['default'].stringify(raw, null, 2); + out += rmCommonWS$4` + /* + * Parser stuff that's unknown to the JISON prettyPrint service: + * + * ${rem.replace(/\*\//g, '*\\/')} + */ - `; - // delete raw; - } + `; + // delete raw; + } - if (!options.showParser) { - out += lex_out_str; - } - else { - out += grammar_pre.join('\n') + '\n\n'; - out += rmCommonWS$4` + if (!options.showParser) { + out += lex_out_str; + } else { + out += grammar_pre.join('\n') + '\n\n'; + out += rmCommonWS$4` - %% + %% - `; - if (grammar_mid.length > 0) { - out += grammar_mid.join('\n') + '\n\n'; - } - if (ebnf_rules.length > 0) { - if (bnf_rules.length > 0) { + `; + if (grammar_mid.length > 0) { + out += grammar_mid.join('\n') + '\n\n'; + } + if (ebnf_rules.length > 0) { + if (bnf_rules.length > 0) { // dump the original EBNF grammar as source and dump the BNF derivative as COMMENT: - var bnf_deriv = bnf_rules.join('\n\n'); - var a = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); + let bnf_deriv = bnf_rules.join('\n\n'); + let a = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - out += rmCommonWS$4` - // - // JISON says: - // - // This is a EBNF grammar. The resulting **BNF** grammar has been - // reproduced here for your convenience: - // - // ---------------------------- START --------------------------- - ${a.join('\n')} - // ---------------------------- END OF BNF grammar -------------- - // + out += rmCommonWS$4` + // + // JISON says: + // + // This is a EBNF grammar. The resulting **BNF** grammar has been + // reproduced here for your convenience: + // + // ---------------------------- START --------------------------- + ${a.join('\n')} + // ---------------------------- END OF BNF grammar -------------- + // - `; + `; + } + out += ebnf_rules.join('\n\n') + '\n\n'; + } else if (bnf_rules.length > 0) { + out += bnf_rules.join('\n\n') + '\n\n'; } - out += ebnf_rules.join('\n\n') + '\n\n'; - } - else if (bnf_rules.length > 0) { - out += bnf_rules.join('\n\n') + '\n\n'; - } - if (grammar_post.length > 0) { - out += rmCommonWS$4` + if (grammar_post.length > 0) { + out += rmCommonWS$4` - %% + %% - ` + grammar_post.join('\n') + '\n\n'; + ` + grammar_post.join('\n') + '\n\n'; + } } - } - if (options.format === 'json5') { - var a = out.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); + if (options.format === 'json5') { + let a = out.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - out = rmCommonWS$4` - // - // JISON says: - // - // The JISON ${options.showParser ? 'grammar' : 'lexer'} has been - // reproduced here for your convenience: - // - // ---------------------------- START --------------------------- - ${a.join('\n')} - // ---------------------------- END ----------------------------- - // + out = rmCommonWS$4` + // + // JISON says: + // + // The JISON ${options.showParser ? 'grammar' : 'lexer'} has been + // reproduced here for your convenience: + // + // ---------------------------- START --------------------------- + ${a.join('\n')} + // ---------------------------- END ----------------------------- + // - `; + `; - // process the original input once again: this time via JSON5 - raw = deepClone(originalInput); + // process the original input once again: this time via JSON5 + raw = deepClone(originalInput); - if (!options.showLexer) { - delete raw.lex; - out += JSON5__default['default'].stringify(raw, null, 2); - } - else if (!options.showParser) { - out += JSON5__default['default'].stringify(raw.lex, null, 2); + if (!options.showLexer) { + delete raw.lex; + out += JSON5__default['default'].stringify(raw, null, 2); + } else if (!options.showParser) { + out += JSON5__default['default'].stringify(raw.lex, null, 2); + } } - } - return out; + return out; + } } // Jison, an LR(0), SLR(1), LARL(1), LR(1) Parser Generator -var rmCommonWS$5 = helpers.rmCommonWS; -var mkIdentifier$4 = helpers.mkIdentifier; -var code_exec$2 = helpers.exec; +const rmCommonWS$5 = helpers.rmCommonWS; +const mkIdentifier$4 = helpers.mkIdentifier; +const code_exec$1 = helpers.exec; -var version$2 = '0.6.2-220'; +const version$2 = '0.7.0-220'; -var devDebug = 0; +let devDebug = 0; function chkBugger$3(src) { src = '' + src; @@ -29088,7 +29110,7 @@ function chkBugger$3(src) { // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE$3 = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -var Jison$1 = { +let Jison$1 = { version: version$2 }; @@ -29103,8 +29125,8 @@ const defaultJisonOptions = { compressTables: 2, // 0, 1, 2 outputDebugTables: false, noDefaultResolve: false, - defaultActionMode: ["classic", "merge"], // {classic, ast, none, skip}, {classic, ast, merge, none, skip} - testCompileActionCode: "parser:*,lexer:*", + defaultActionMode: [ 'classic', 'merge' ], // {classic, ast, none, skip}, {classic, ast, merge, none, skip} + testCompileActionCode: 'parser:*,lexer:*', noTryCatch: false, hasPartialLrUpgradeOnConflict: true, errorRecoveryTokenDiscardCount: 3, @@ -29162,7 +29184,7 @@ const defaultJisonOptions = { actionsUseYYSTACKPOINTER: false, actionsUseYYTEXT: false, hasErrorRecovery: false, - hasErrorReporting: false, + hasErrorReporting: false }; Jison$1.defaultJisonOptions = defaultJisonOptions; @@ -29183,25 +29205,25 @@ Jison$1.defaultJisonOptions = defaultJisonOptions; // Return a fresh set of options. /** @public */ function mkStdOptions$1(...args) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - //var args = Array.prototype.concat.apply([], args); + let opts = {}; + //let args = Array.prototype.concat.apply([], args); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(Jison$1.defaultJisonOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; - for (var p in o) { + for (let p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { o2[mkIdentifier$4(p)] = o[p]; } @@ -29233,7 +29255,7 @@ function mkStdOptions$1(...args) { } // fall through case 'string': - var a = String(o2.defaultActionMode).split(',').map(function (m) { + let a = String(o2.defaultActionMode).split(',').map(function (m) { return m.trim(); }); if (a.length === 1) { @@ -29297,7 +29319,7 @@ function mkStdOptions$1(...args) { } // now see if we have an overriding option here: - for (var p in o2) { + for (let p in o2) { if (h.call(o2, p)) { if (typeof o2[p] !== 'undefined') { opts[p] = o2[p]; @@ -29313,7 +29335,7 @@ function mkStdOptions$1(...args) { function prepExportStructures$1(options) { // set up the 'option' `exportAllTables` as a hash object for returning // all generated tables to the caller - var exportDest = options.exportAllTables; + let exportDest = options.exportAllTables; if (!exportDest || typeof exportDest !== 'object') { exportDest = { enabled: !!exportDest @@ -29325,7 +29347,7 @@ function prepExportStructures$1(options) { // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -29346,128 +29368,128 @@ function prepExportStructures$1(options) { // Otherwise return the *parsed* grammar and optional lexer specs as they have // been processed through EBNFParser and LEXParser respectively. function autodetectAndConvertToJSONformat$1(grammar, optionalLexerSection, options) { - var chk_g = null; - var chk_l = null; - var ex1, err; + let chk_g = null; + let chk_l = null; + let ex1, err; if (typeof grammar === 'string') { - if (options.json) { - try { - chk_g = JSON5__default['default'].parse(grammar); + if (options.json) { + try { + chk_g = JSON5__default['default'].parse(grammar); - // When JSON5-based parsing of the grammar succeeds, this implies the grammar is specified in `JSON mode` - // *OR* there's a JSON/JSON5 format error in the input: - } catch (e) { - ex1 = e; + // When JSON5-based parsing of the grammar succeeds, this implies the grammar is specified in `JSON mode` + // *OR* there's a JSON/JSON5 format error in the input: + } catch (e) { + ex1 = e; + } } - } - if (!chk_g) { - try { - chk_g = ebnfParser.parse(grammar); - } catch (e) { - if (options.json) { - // When both JSON5 and JISON input modes barf a hairball, assume the most important - // error is the JISON one (show that one first!), while it MAY be a JSON5 format - // error that triggered it (show that one last!). - // - // Also check for common JISON errors which are obviously never triggered by any - // odd JSON5 input format error: when we encounter such an error here, we don't - // confuse matters and forget about the JSON5 fail as it's irrelevant: - const commonErrors = [ - /does not compile/, - /you did not correctly separate trailing code/, - /You did not specify/, - /You cannot specify/, - /must be qualified/, - /%start/, - /%token/, - /%import/, - /%include/, - /%options/, - /%parse-params/, - /%parser-type/, - /%epsilon/, - /definition list error/, - /token list error/, - /declaration error/, - /should be followed/, - /should be separated/, - /an error in one or more of your lexer regex rules/, - /an error in your lexer epilogue/, - /unsupported definition type/, - ]; - var cmnerr = commonErrors.filter(function check(re) { - return e.message.match(re); - }); - if (cmnerr.length > 0) { - err = e; + if (!chk_g) { + try { + chk_g = ebnfParser.parse(grammar); + } catch (e) { + if (options.json) { + // When both JSON5 and JISON input modes barf a hairball, assume the most important + // error is the JISON one (show that one first!), while it MAY be a JSON5 format + // error that triggered it (show that one last!). + // + // Also check for common JISON errors which are obviously never triggered by any + // odd JSON5 input format error: when we encounter such an error here, we don't + // confuse matters and forget about the JSON5 fail as it's irrelevant: + const commonErrors = [ + /does not compile/, + /you did not correctly separate trailing code/, + /You did not specify/, + /You cannot specify/, + /must be qualified/, + /%start/, + /%token/, + /%import/, + /%include/, + /%options/, + /%parse-params/, + /%parser-type/, + /%epsilon/, + /definition list error/, + /token list error/, + /declaration error/, + /should be followed/, + /should be separated/, + /an error in one or more of your lexer regex rules/, + /an error in your lexer epilogue/, + /unsupported definition type/ + ]; + let cmnerr = commonErrors.filter(function check(re) { + return e.message.match(re); + }); + if (cmnerr.length > 0) { + err = e; + } else { + err = new Error('Could not parse jison grammar in JSON AUTODETECT mode:\nin JISON Mode we get Error: ' + e.message + '\nwhile JSON5 Mode produces Error: ' + ex1.message); + err.secondary_exception = e; + err.stack = ex1.stack; + } } else { - err = new Error('Could not parse jison grammar in JSON AUTODETECT mode:\nin JISON Mode we get Error: ' + e.message + '\nwhile JSON5 Mode produces Error: ' + ex1.message); - err.secondary_exception = e; - err.stack = ex1.stack; + err = new Error('Could not parse jison grammar\nError: ' + e.message); + err.stack = e.stack; } - } else { - err = new Error('Could not parse jison grammar\nError: ' + e.message); - err.stack = e.stack; + throw err; } - throw err; } - } - // Save time! Don't reparse the entire grammar *again* inside the code generators when that's not necessary: - // if (chk_g) { - // grammar = chk_g; - // } + // Save time! Don't reparse the entire grammar *again* inside the code generators when that's not necessary: + // if (chk_g) { + // grammar = chk_g; + // } } else { chk_g = grammar; } // Now the same treatment for the lexer: if (chk_g && optionalLexerSection) { - if (chk_g.lex) { - throw new Error('Cannot invoke with both a lexer section in the grammar input and a separate lexer input at the same time!'); - } + if (chk_g.lex) { + throw new Error('Cannot invoke with both a lexer section in the grammar input and a separate lexer input at the same time!'); + } - if (typeof optionalLexerSection === 'string') { - if (options.json) { - try { - chk_l = JSON5__default['default'].parse(optionalLexerSection); + if (typeof optionalLexerSection === 'string') { + if (options.json) { + try { + chk_l = JSON5__default['default'].parse(optionalLexerSection); - // When JSON5-based parsing of the lexer spec succeeds, this implies the lexer spec is specified in `JSON mode` - // *OR* there's a JSON/JSON5 format error in the input: - } catch (e) { - ex1 = e; - } - } - if (!chk_l) { - // // WARNING: the lexer may receive options specified in the **grammar spec file**, - // // hence we should mix the options to ensure the lexParser always - // // receives the full set! - // // - // // make sure all options are 'standardized' before we go and mix them together: - // options = mkStdOptions(grammar.options, options); - try { - chk_l = lexParser.parse(optionalLexerSection); - } catch (e) { - if (options.json) { - err = new Error('Could not parse lexer spec in JSON AUTODETECT mode\nError: ' + ex1.message + ' (' + e.message + ')'); - err.secondary_exception = e; - err.stack = ex1.stack; - } else { - err = new Error('Could not parse lexer spec\nError: ' + e.message); - err.stack = e.stack; - } - throw err; - } + // When JSON5-based parsing of the lexer spec succeeds, this implies the lexer spec is specified in `JSON mode` + // *OR* there's a JSON/JSON5 format error in the input: + } catch (e) { + ex1 = e; + } + } + if (!chk_l) { + // // WARNING: the lexer may receive options specified in the **grammar spec file**, + // // hence we should mix the options to ensure the lexParser always + // // receives the full set! + // // + // // make sure all options are 'standardized' before we go and mix them together: + // options = mkStdOptions(grammar.options, options); + try { + chk_l = lexParser.parse(optionalLexerSection); + } catch (e) { + if (options.json) { + err = new Error('Could not parse lexer spec in JSON AUTODETECT mode\nError: ' + ex1.message + ' (' + e.message + ')'); + err.secondary_exception = e; + err.stack = ex1.stack; + } else { + err = new Error('Could not parse lexer spec\nError: ' + e.message); + err.stack = e.stack; + } + throw err; + } + } + } else { + chk_l = optionalLexerSection; } - } else { - chk_l = optionalLexerSection; - } - // Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: - if (chk_l) { - chk_g.lex = chk_l; - } + // Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: + if (chk_l) { + chk_g.lex = chk_l; + } } return chk_g; @@ -29484,7 +29506,7 @@ if (typeof console !== 'undefined' && console.log) { // wrap console.log to prevent 'Illegal Invocation' exceptions when Jison.print() is used, e.g. // in the web tryout pages where this code is employed. Jison$1.print = function console_log(/* ... */) { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); args.unshift(''); // prevent `%.` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args console.log.apply(console, args); }; @@ -29505,7 +29527,7 @@ if (typeof console !== 'undefined' && console.log) { Jison$1.Lexer = RegExpLexer; Jison$1.ebnfParser = ebnfParser; Jison$1.lexParser = lexParser; -Jison$1.codeExec = code_exec$2; +Jison$1.codeExec = code_exec$1; Jison$1.XRegExp = XRegExp__default['default']; Jison$1.recast = recast__default['default']; Jison$1.astUtils = astUtils__default['default']; @@ -29520,7 +29542,7 @@ function each(obj, func) { if (typeof obj.forEach === 'function') { obj.forEach(func); } else { - var p; + let p; for (p in obj) { if (obj.hasOwnProperty(p)) { func.call(obj, obj[p], p, obj); @@ -29550,10 +29572,10 @@ function union(a, b) { // site for this jscore grammar as the naive scan consistently // outperformed the old smarter hash-object code for smaller // thresholds (10, 20, 32, 42!) - var k, len; + let k, len; if (a.length > 52) { - var ar = {}; + let ar = {}; for (k = 0, len = a.length; k < len; k++) { ar[a[k]] = true; } @@ -29563,7 +29585,7 @@ function union(a, b) { } } } else { - var bn = []; + let bn = []; for (k = 0, len = b.length; k < len; k++) { if (a.indexOf(b[k]) < 0) { bn.push(b[k]); @@ -29574,17 +29596,17 @@ function union(a, b) { return a; } -var Nonterminal = typal.construct({ +let Nonterminal = typal.construct({ constructor: function Nonterminal(symbol) { this.symbol = symbol; - this.productions = new Set(); + this.productions = new Set$1(); this.first = []; this.follows = []; this.nullable = false; }, toString: function Nonterminal_toString() { - var str = this.symbol; - var attr_str = []; + let str = this.symbol; + let attr_str = []; if (this.nullable) { attr_str.push('nullable'); @@ -29601,7 +29623,7 @@ var Nonterminal = typal.construct({ } }); -var Production = typal.construct({ +let Production = typal.construct({ constructor: function Production(symbol, handle, id, handle_aliases, handle_action) { this.symbol = symbol; this.handle = handle; @@ -29615,9 +29637,9 @@ var Production = typal.construct({ this.reachable = false; }, toString: function Production_toString() { - var str = this.symbol; + let str = this.symbol; - var attr_str = []; + let attr_str = []; if (this.nullable) { attr_str.push('~'); @@ -29637,9 +29659,9 @@ var Production = typal.construct({ return str; }, describe: function Production_describe() { - var str = this.symbol; + let str = this.symbol; - var attr_str = []; + let attr_str = []; if (this.nullable) { attr_str.push('nullable'); @@ -29660,7 +29682,7 @@ var Production = typal.construct({ -var generator = typal.beget(); +let generator = typal.beget(); // `optionalLexerSection` is an optional {String} argument, specifying the lexer rules. // May only be specified when the specified `grammar` also is a yet-unparsed @@ -29735,11 +29757,11 @@ var generator = typal.beget(); generator.constructor = function Jison_Generator(grammar, optionalLexerSection, options) { // pick the correct argument for the `options` for this call: if (!options && optionalLexerSection && typeof optionalLexerSection !== 'string') { - options = optionalLexerSection; - optionalLexerSection = null; + options = optionalLexerSection; + optionalLexerSection = null; } // and standardize it: - var preliminary_options = mkStdOptions$1(options); + let preliminary_options = mkStdOptions$1(options); grammar = autodetectAndConvertToJSONformat$1(grammar, optionalLexerSection, preliminary_options); @@ -29787,7 +29809,7 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, // } // calculate the input path; if none is specified, it's the present working directory - var inpath = options.file || options.outfile || './dummy'; + let inpath = options.file || options.outfile || './dummy'; inpath = path__default['default'].normalize(inpath); options.inputPath = path__default['default'].dirname(inpath); options.inputFilename = path__default['default'].basename(inpath); @@ -29818,7 +29840,7 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, this.processGrammar(grammar); if (grammar.lex) { - var lexer_options = { + let lexer_options = { // include the knowledge about which parser/lexer // features will actually be *used* by the environment: // @@ -29873,7 +29895,7 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, exportAST: this.options.exportAST, prettyCfg: this.options.prettyCfg, pre_lex: this.options.pre_lex, - post_lex: this.options.post_lex, + post_lex: this.options.post_lex }; this.lexer = new RegExpLexer(grammar.lex, null, this.terminals_, lexer_options); @@ -29881,10 +29903,10 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, }; generator.processGrammar = function processGrammarDef(grammar) { - var bnf = grammar.bnf, - tokens = grammar.tokens, - nonterminals = this.nonterminals = {}, - productions = this.productions; + let bnf = grammar.bnf; + let tokens = grammar.tokens; + let nonterminals = this.nonterminals = {}; + let productions = this.productions; if (!grammar.bnf && grammar.ebnf) { bnf = grammar.bnf = ebnfParser.transform(grammar.ebnf); @@ -29900,18 +29922,18 @@ generator.processGrammar = function processGrammarDef(grammar) { // did the grammar user also provide a predefined set of symbols to be (re)used with this grammar? // (This is used when you want to generate multiple lexers and parsers which share a common symbol set // so as to make the parsers and lexers mutually interchangeable.) - var predefined_symbols = null; + let predefined_symbols = null; if (grammar.imports) { - var symbols_import = grammar.imports.find(function (el, idx) { + let symbols_import = grammar.imports.find(function (el, idx) { if (el.name === 'symbols') { return el; } return false; }); if (symbols_import) { - var filepath = path__default['default'].resolve(symbols_import.path); + let filepath = path__default['default'].resolve(symbols_import.path); - var source = fs__default['default'].readFileSync(filepath, 'utf8'); + let source = fs__default['default'].readFileSync(filepath, 'utf8'); // It's either a JSON file or a JISON generated output file: // // symbols_: { @@ -29921,7 +29943,7 @@ generator.processGrammar = function processGrammarDef(grammar) { predefined_symbols = JSON5__default['default'].parse(source); } catch (ex) { try { - var m = /[\r\n]\s*symbols_:\s*(\{[\s\S]*?\}),\s*[\r\n]/.exec(source); + let m = /[\r\n]\s*symbols_:\s*(\{[\s\S]*?\}),\s*[\r\n]/.exec(source); if (m && m[1]) { source = m[1]; predefined_symbols = JSON5__default['default'].parse(source); @@ -29936,18 +29958,18 @@ generator.processGrammar = function processGrammarDef(grammar) { } // Make sure all predefined symbols are unique and *numeric* and do not include predefined tokens JISON already defines to a fixed ID on its own: - delete predefined_symbols['$accept']; - delete predefined_symbols['$end']; - delete predefined_symbols['error']; - delete predefined_symbols['$eof']; - delete predefined_symbols['EOF']; + delete predefined_symbols.$accept; + delete predefined_symbols.$end; + delete predefined_symbols.error; + delete predefined_symbols.$eof; + delete predefined_symbols.EOF; - var symdef_uniq_check = {}; + let symdef_uniq_check = {}; // Only these symbols are allowed to have the values 1 or 2: symdef_uniq_check[1] = 'EOF'; symdef_uniq_check[2] = 'error'; Object.keys(predefined_symbols).forEach(function cvt_symbol_id_to_numeric(sym) { - var v = predefined_symbols[sym]; + let v = predefined_symbols[sym]; // Symbol value may be defined as boolean TRUE, in which case we let JISON pick the value for us: if (v === true) return; @@ -29955,17 +29977,17 @@ generator.processGrammar = function processGrammarDef(grammar) { // Symbol value may be defined as a one-character string: if (typeof v !== 'number') { if (typeof v !== 'string' || v.length !== 1) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a non-numeric symbol ID value must be a single-character string.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a non-numeric symbol ID value must be a single-character string."); } v = v.charCodeAt(0); } - v = v | 0; + v |= 0; if (!v || v < 0) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a symbol ID value must be an integer value, 3 or greater.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a symbol ID value must be an integer value, 3 or greater."); } if (symdef_uniq_check[v]) { if (symdef_uniq_check[v] !== sym) { - throw new Error('Error: `%import symbols `: symbol table contains duplicate ID values for keys \'' + sym + '\' and \'' + symdef_uniq_check[v] + '\''); + throw new Error("Error: `%import symbols `: symbol table contains duplicate ID values for keys '" + sym + "' and '" + symdef_uniq_check[v] + "'"); } } symdef_uniq_check[v] = sym; @@ -29974,15 +29996,15 @@ generator.processGrammar = function processGrammarDef(grammar) { } } - var symbols = this.symbols = []; + let symbols = this.symbols = []; // calculate precedence of operators - var operators = this.operators = processOperators(grammar.operators); + let operators = this.operators = processOperators(grammar.operators); // build productions from CFG and calculate the symbol sets (terminals and nonterminals) and their name-to-ID mappings this.buildProductions(bnf, productions, nonterminals, symbols, operators, predefined_symbols, grammar.extra_tokens); if (tokens) { - var termset = this.terminals.filter(function (t) { + let termset = this.terminals.filter(function (t) { switch (t) { case 'EOF': case 'error': @@ -29994,7 +30016,7 @@ generator.processGrammar = function processGrammarDef(grammar) { return true; } }); - var diffset = termset.filter(function (t) { + let diffset = termset.filter(function (t) { return tokens.indexOf(t) === -1; }); diffset = diffset.concat(tokens.filter(function (t) { @@ -30051,7 +30073,7 @@ generator.augmentGrammar = function augmentGrammar(grammar) { // return true; // the default parse result if the rule actions don't produce anything // %} // - var acceptProduction = new Production('$accept', [this.startSymbol, '$end'], 0); + let acceptProduction = new Production('$accept', [ this.startSymbol, '$end' ], 0); this.productions.unshift(acceptProduction); // prepend parser tokens // moved to generator.buildProductions() @@ -30070,14 +30092,13 @@ generator.augmentGrammar = function augmentGrammar(grammar) { // Mark unused productions generator.signalUnusedProductions = function () { - var mark = {}; + let mark = {}; - var productions = this.productions; - var nonterminals = this.nonterminals; - var i, len, nt, sym; + let productions = this.productions; + let nonterminals = this.nonterminals; - for (i = 0, len = nonterminals.length; i < len; i++) { - nt = nonterminals[i]; + for (let i = 0, len = nonterminals.length; i < len; i++) { + let nt = nonterminals[i]; assert__default['default'](nt.symbol); mark[nt.symbol] = false; } @@ -30088,15 +30109,15 @@ generator.signalUnusedProductions = function () { assert__default['default'](nt.symbol); mark[nt.symbol] = true; - var prods = nt.productions; + let prods = nt.productions; assert__default['default'](prods); prods.forEach(function (p) { assert__default['default'](p.symbol === nt.symbol); assert__default['default'](p.handle); - var rhs = p.handle; + let rhs = p.handle; - for (var j = 0, len = rhs.length; j < len; j++) { - var sym = rhs[j]; + for (let j = 0, len = rhs.length; j < len; j++) { + let sym = rhs[j]; assert__default['default'](!sym ? !nonterminals[sym] : true); if (nonterminals[sym] && !mark[sym]) { traverseGrammar(nonterminals[sym]); @@ -30105,15 +30126,15 @@ generator.signalUnusedProductions = function () { }); } - traverseGrammar(nonterminals['$accept' /* this.startSymbol */ ]); + traverseGrammar(nonterminals['$accept' /* this.startSymbol */]); // now any production which is not yet marked is *unused*: - for (sym in mark) { - nt = nonterminals[sym]; + for (let sym in mark) { + let nt = nonterminals[sym]; assert__default['default'](nt); - var prods = nt.productions; + let prods = nt.productions; assert__default['default'](prods); - var in_use = mark[sym]; + let in_use = mark[sym]; prods.forEach(function (p) { assert__default['default'](p); if (in_use) { @@ -30142,8 +30163,8 @@ generator.signalUnusedProductions = function () { // set precedence and associativity of operators function processOperators(ops) { if (!ops) return {}; - var operators = {}; - for (var i = 0, k, prec; (prec = ops[i]); i++) { + let operators = {}; + for (let i = 0, k, prec; (prec = ops[i]); i++) { for (k = 1; k < prec.length; k++) { operators[prec[k]] = { precedence: i + 1, @@ -30158,8 +30179,8 @@ function processOperators(ops) { // // Note that the first line doesn't count as the chunk is very probably trimmed! function reindentCodeBlock(action, indent_level) { - var width = 0; - var lines = action + let width = 0; + let lines = action .trim() .split('\n') // measure the indent: @@ -30176,7 +30197,7 @@ function reindentCodeBlock(action, indent_level) { return s.replace(/\t/g, ' '); }); - var m = /^[ ]+/.exec(line); + let m = /^[ ]+/.exec(line); if (m) { width = Math.min(m[0].length, width); } @@ -30187,8 +30208,8 @@ function reindentCodeBlock(action, indent_level) { .map(function checkIndentation(line, idx) { line = line .replace(/^[ ]*/, function adjustIndent(s) { - var l = Math.max(s.length - width, 0) + indent_level; - var shift = (new Array(l + 1)).join(' '); + let l = Math.max(s.length - width, 0) + indent_level; + let shift = (new Array(l + 1)).join(' '); return shift; }); return line; @@ -30199,21 +30220,21 @@ function reindentCodeBlock(action, indent_level) { generator.buildProductions = function buildProductions(bnf, productions, nonterminals, symbols, operators, predefined_symbols, descriptions) { - var self = this; - var prods, symbol, symId; - var productions_ = []; - var symbols_ = {}; - var descriptions_ = {}; - var usedSymbolIds = [/* $accept = 0 */ true, /* $end = 1 */ true, /* error = 2 */ true]; - var usedSymbolIdsLowIndex = 3; + let self = this; + let prods, symId; + let productions_ = []; + let symbols_ = {}; + let descriptions_ = {}; + let usedSymbolIds = [/* $accept = 0 */ true, /* $end = 1 */ true, /* error = 2 */ true ]; + let usedSymbolIdsLowIndex = 3; // set up the required symbols `$accept` and `$end` (a.k.a. EOF) and make sure they occupy the expected slots: this.EOF = '$end'; symbols_.$accept = 0; symbols_[this.EOF] = 1; - symbols_['$eof'] = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! - symbols_['EOF'] = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.$eof = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.EOF = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! symbols[0] = '$accept'; symbols[1] = this.EOF; @@ -30224,7 +30245,7 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm symbols[2] = 'error'; if (predefined_symbols) { - for (symbol in predefined_symbols) { + for (let symbol in predefined_symbols) { symId = predefined_symbols[symbol]; if (symId === true) { // add symbol to queue which must be assigned a value by JISON; after all the other predefined symbols have been processed. @@ -30247,7 +30268,7 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm // preferably assign readable ASCII-range token IDs to tokens added from the predefined list // but only when maximum table compression isn't demanded: usedSymbolIdsLowIndex = ((this.options.compressTables | 0) < 2 ? 32 : 3); - for (symbol in predefined_symbols) { + for (let symbol in predefined_symbols) { symId = predefined_symbols[symbol]; addSymbol(symbol); } @@ -30267,11 +30288,11 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm } - var hasErrorRecovery = false; // has error recovery + let hasErrorRecovery = false; // has error recovery // Produce the next available unique symbolID: function getNextSymbolId() { - for (var i = usedSymbolIdsLowIndex; ; i++) { + for (let i = usedSymbolIdsLowIndex; ; i++) { if (!usedSymbolIds[i]) { usedSymbolIds[i] = true; usedSymbolIdsLowIndex = i + 1; @@ -30282,7 +30303,7 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm function addSymbol(s) { if (s && !symbols_[s]) { - var i; + let i; // assign the Unicode codepoint index to single-character symbols, // but only when maximum table compression isn't demanded: @@ -30306,46 +30327,45 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm // `this` is options object with `maxTokenLength` option to guide us which literal tokens we want to process: function collectLiteralTokensInProduction(handle) { - var rhs, i, sym; + let rhs; - try{ - if (devDebug) ; + try { + if (devDebug) ; - var maxlen = this.maxTokenLength || Infinity; + let maxlen = this.maxTokenLength || Infinity; - if (handle.constructor === Array) { - var rhs_i; - rhs = (typeof handle[0] === 'string') ? - splitStringIntoSymbols(handle[0]) : - handle[0].slice(0); + if (handle.constructor === Array) { + rhs = (typeof handle[0] === 'string') ? + splitStringIntoSymbols(handle[0]) : + handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; - // check for aliased names, e.g., id[alias] and strip them - rhs_i = sym.match(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]$`)); - if (rhs_i) { - sym = sym.substr(0, sym.length - rhs_i[0].length); - } + for (let i = 0; i < rhs.length; i++) { + let sym = rhs[i]; + // check for aliased names, e.g., id[alias] and strip them + let rhs_i = sym.match(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]$`)); + if (rhs_i) { + sym = sym.substr(0, sym.length - rhs_i[0].length); + } - if (!bnf[sym] && sym.length <= maxlen) { - addSymbol(sym); + if (!bnf[sym] && sym.length <= maxlen) { + addSymbol(sym); + } } - } - } else { - // no action -> don't care about aliases; strip them. - handle = handle.replace(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); - rhs = splitStringIntoSymbols(handle); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; - if (!bnf[sym] && sym.length <= maxlen) { - addSymbol(sym); + } else { + // no action -> don't care about aliases; strip them. + handle = handle.replace(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); + rhs = splitStringIntoSymbols(handle); + for (let i = 0; i < rhs.length; i++) { + let sym = rhs[i]; + if (!bnf[sym] && sym.length <= maxlen) { + addSymbol(sym); + } } } + } catch (ex) { + console.error(ex, '\ncollectLiteralTokensInProduction: ', this.symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { rhs }); + throw ex; } - }catch (ex) { -console.error(ex, '\ncollectLiteralTokensInProduction: ', symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { i, sym, rhs }); -throw ex; - } } // Before we go process the grammar for real, we collect the 'literal' non-terminals and add them to the symbol table @@ -30353,8 +30373,8 @@ throw ex; // which helps debugging/diagnosis of generated grammars. // (This is why previously we had set `usedSymbolIdsLowIndex` to 127 instead of 3!) - var prodsLUT = {}; - for (symbol in bnf) { + let prodsLUT = {}; + for (let symbol in bnf) { if (!bnf.hasOwnProperty(symbol)) continue; if (typeof bnf[symbol] === 'string') { @@ -30367,21 +30387,23 @@ throw ex; } // First we collect all single-character literal tokens: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: 1 + maxTokenLength: 1, + symbol }); } // Next we collect all other literal tokens: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: Infinity + maxTokenLength: Infinity, + symbol }); } @@ -30390,7 +30412,7 @@ throw ex; // for each of those: nonterminals should all have IDs assigned before they // should be processed as part of a *production* rule, where these MAY be // referenced: - for (symbol in bnf) { + for (let symbol in bnf) { if (!bnf.hasOwnProperty(symbol)) continue; addSymbol(symbol); @@ -30399,15 +30421,15 @@ throw ex; // now that we have collected all nonterminals in our symbol table, it's finally // time to process the productions: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; - prods.forEach(buildProduction); + prods.forEach(buildProduction, { symbol }); } - var terms = [], - terms_ = {}; + let terms = []; + let terms_ = {}; each(symbols_, function (id, sym) { // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number @@ -30423,7 +30445,7 @@ throw ex; // fix error recovery related options now that we know whether we actually have any recovery // rules at all: if (!this.hasErrorRecovery) { - var chk_er_opt = function check_error_recovery_option(opt, label) { + let chk_er_opt = function check_error_recovery_option(opt, label) { if (self.options[opt]) { self.options[opt] = false; self.warn('The grammar does not have any error recovery rules, so using the ' + label + ' is rather useless.'); @@ -30435,9 +30457,9 @@ throw ex; // Hmmmm... why would lexer errors need to be NON-recoverable when there's no ERROR rules in the GRAMMAR?! chk_er_opt('lexerErrorsAreRecoverable', 'lexer-errors-are-recoverable feature/option'); - chk_er_opt('parseActionsUseYYRECOVERING', 'YYRECOVERING macro/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYERROK', 'yyerrok() function/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYCLEARIN', 'yyclearin() function/API in grammar rules\' action code'); + chk_er_opt('parseActionsUseYYRECOVERING', "YYRECOVERING macro/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYERROK', "yyerrok() function/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYCLEARIN', "yyclearin() function/API in grammar rules' action code"); } this.terminals = terms; @@ -30456,8 +30478,8 @@ throw ex; function splitStringIntoSymbols(rhs) { // when there's no literal tokens in there, we can fast-track this baby: rhs = rhs.trim(); - var pos1 = rhs.indexOf("'"); - var pos2 = rhs.indexOf('"'); + let pos1 = rhs.indexOf("'"); + let pos2 = rhs.indexOf('"'); if (pos1 < 0 && pos2 < 0) { return rhs.split(' '); } @@ -30465,10 +30487,10 @@ throw ex; // // rhs has at least one literal: we will need to parse the rhs into tokens // with a little more effort now. - var tokens = []; + let tokens = []; while (pos1 >= 0 || pos2 >= 0) { - var pos = pos1; - var marker = "'"; + let pos = pos1; + let marker = "'"; if (pos < 0) { assert__default['default'](pos2 >= 0); pos = pos2; @@ -30477,7 +30499,7 @@ throw ex; pos = pos2; marker = '"'; } - var ls = rhs.substr(0, pos).trim(); + let ls = rhs.substr(0, pos).trim(); if (ls.length > 0) { tokens.push.apply(tokens, ls.split(' ')); } @@ -30486,7 +30508,7 @@ throw ex; // // Edge case: token MAY include the ESCAPED MARKER... or other escapes! // Hence we need to skip over ALL escapes inside the token! - var pos3 = rhs.indexOf('\\'); + let pos3 = rhs.indexOf('\\'); pos = rhs.indexOf(marker); ls = ''; while (pos3 >= 0 && pos3 < pos) { @@ -30501,7 +30523,7 @@ throw ex; ls += rhs.substr(0, pos); // check for aliased literals, e.g., `'>'[gt]` and keep it and the alias together rhs = rhs.substr(pos + 1); - var alias = rhs.match(new XRegExp__default['default'](`^\\[${ID_REGEX_BASE$3}\\]`)); + let alias = rhs.match(new XRegExp__default['default'](`^\\[${ID_REGEX_BASE$3}\\]`)); if (alias) { ls += alias[0]; rhs = rhs.substr(alias[0].length); @@ -30521,22 +30543,21 @@ throw ex; return tokens; } + // options object { symbol } is `this` for this functon/callback: function buildProduction(handle) { - var r, rhs, i, - precedence_override, - aliased = [], - action = null; + let rhs; + let precedence_override = null; + let aliased = []; + let action = null; if (handle.constructor === Array) { - var rhs_i; - rhs = (typeof handle[0] === 'string') ? - splitStringIntoSymbols(handle[0]) : - handle[0].slice(0); + splitStringIntoSymbols(handle[0]) : + handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // check for aliased names, e.g., id[alias] and strip them - rhs_i = rhs[i].match(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]$`)); + let rhs_i = rhs[i].match(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]$`)); if (rhs_i) { rhs[i] = rhs[i].substr(0, rhs[i].length - rhs_i[0].length); rhs_i = rhs_i[0].substr(1, rhs_i[0].length - 2); @@ -30578,7 +30599,7 @@ throw ex; // no action -> don't care about aliases; strip them. handle = handle.replace(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { if (rhs[i] === 'error') { hasErrorRecovery = true; } @@ -30588,35 +30609,33 @@ throw ex; } } - r = new Production(symbol, rhs, productions.length + 1, aliased, action); + let r = new Production(this.symbol, rhs, productions.length + 1, aliased, action); // set precedence assert__default['default'](r.precedence === 0); if (precedence_override) { r.precedence = precedence_override.spec.precedence; - } - else { - var prec_symbols = []; - var winning_symbol; + } else { + let prec_symbols = []; + let winning_symbol; - for (i = r.handle.length - 1; i >= 0; i--) { + for (let i = r.handle.length - 1; i >= 0; i--) { if (!(r.handle[i] in nonterminals) && r.handle[i] in operators) { - var old_prec = r.precedence; - var new_prec = operators[r.handle[i]].precedence; + let old_prec = r.precedence; + let new_prec = operators[r.handle[i]].precedence; if (old_prec !== 0 && old_prec !== new_prec) { prec_symbols.push(r.handle[i]); - // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], symbol, handle[0]); + // 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[i]; - } - else { + } else { // keep previously set precedence: new_prec = old_prec; } } else if (old_prec === 0) { prec_symbols.push(r.handle[i]); winning_symbol = r.handle[i]; - // Jison.print('precedence set first time: ', old_prec, r.handle[i], symbol, handle[0]); + // Jison.print('precedence set first time: ', old_prec, r.handle[i], this.symbol, handle[0]); } r.precedence = new_prec; } @@ -30624,14 +30643,14 @@ throw ex; if (prec_symbols.length > 1) { if (self.DEBUG || 1) { - self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); + self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + this.symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); } } } productions.push(r); - productions_.push([symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length]); - nonterminals[symbol].productions.push(r); + productions_.push([ symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length ]); + nonterminals[this.symbol].productions.push(r); } }; @@ -30736,8 +30755,9 @@ function preprocessActionCode(s) { // with our pants down in constructs like // `'"' + $$ + '"'` vs. `"'" + $$ + "'"` - var dqpos, sqpos, ccmtpos, cppcmtpos, first = -1; - for (var c = 0;; c++) { + let dqpos, sqpos, ccmtpos, cppcmtpos; + let first = -1; + for (let c = 0; ; c++) { first++; dqpos = s.indexOf('"', first); sqpos = s.indexOf("'", first); @@ -30781,11 +30801,11 @@ function postprocessActionCode(s) { .replace(/\x01\x82/g, '$') .replace(/\x01\x83/g, '@') // and revert the string and regex markers: - .replace(/\x01\x87/g, '\'') + .replace(/\x01\x87/g, "'") .replace(/\x01\x88/g, '\"') .replace(/\x01\x89/g, '##') .replace(/\x01\x90/g, '\\\\') - .replace(/\x01\x91/g, '\\\'') + .replace(/\x01\x91/g, "\\'") .replace(/\x01\x92/g, '\\\"') .replace(/\x01\x93/g, '\\\/') .replace(/\x01\x94/g, 'YYABORT') @@ -30818,7 +30838,7 @@ function mkHashIndex(s) { } function analyzeFeatureUsage(sourcecode, feature, threshold) { - var found = sourcecode.match(feature); + let found = sourcecode.match(feature); return !!(found && found.length > threshold); } @@ -30826,7 +30846,7 @@ function analyzeFeatureUsage(sourcecode, feature, threshold) { function mkParserFeatureHash(self) { assert__default['default'](self.options.exportAllTables); // check that this function isn't called too early in the process or the hash will be bogus assert__default['default'](self.options.exportSourceCode); - var h = [ + let h = [ self.actionsAreAllDefault, self.actionsUseLocationAssignment, self.actionsUseLocationTracking, @@ -30875,7 +30895,7 @@ function mkParserFeatureHash(self) { self.options.prettyCfg, '======================================', self.performAction, - '======================================', + '======================================' ]; return JSON.stringify(h); } @@ -30890,23 +30910,23 @@ generator.buildProductionActions = function buildProductionActions() { this.productions_ = productions_; assert(this.productions === productions); */ - var productions = this.productions, - nonterminals = this.nonterminals, - symbols = this.symbols, - operators = this.operators, - self = this; + let productions = this.productions; + let nonterminals = this.nonterminals; + let symbols = this.symbols; + let operators = this.operators; + let self = this; // As a SIDE EFFECT of this call, we also fixup // the other code chunks specified in the grammar file: // // Replace direct symbol references, e.g. #NUMBER# when there's a `%token NUMBER` for your grammar. // We allow these tokens to be referenced anywhere in your code as #TOKEN#. - var moduleInclude = preprocessActionCode(this.moduleInclude) + let moduleInclude = preprocessActionCode(this.moduleInclude) .replace(new XRegExp__default['default'](`#(${ID_REGEX_BASE$3})#`, 'g'), function (_, sym) { return provideSymbolAsSourcecode(sym); }); // and COPY the `moduleInit` array, after preprocessing the individual COPIES: - var moduleInit = this.moduleInit.map(function (chunk) { + let moduleInit = this.moduleInit.map(function (chunk) { assert__default['default'](chunk.qualifier); assert__default['default'](typeof chunk.include === 'string'); return { @@ -30922,39 +30942,38 @@ generator.buildProductionActions = function buildProductionActions() { // We potentially need multiple (2+) rounds to produce the correct actions // as userland action code determines whether the default actions should // include location tracking or not: - var gen_level = 0; - var prev_gen_hash = 'n'; - var gen_hash = 'y'; + let gen_level = 0; + let prev_gen_hash = 'n'; + let gen_hash = 'y'; this.performAction = null; while (gen_hash !== prev_gen_hash) { - var preludeCode = preprocessActionCode(this.actionInclude || ''); - var actions = [` + let preludeCode = preprocessActionCode(this.actionInclude || ''); + let actions = [ ` /* this == yyval */ // the JS engine itself can go and remove these statements when \`yy\` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; ${preludeCode} switch (yystate) {` ]; - var actionGroups = {}; // used to combine identical actions into single instances: no use duplicating action code needlessly - var actionGroupValue = {}; // stores the unaltered, expanded, user-defined action code for each action group. - var stateHasAction = []; // marks which state IDs have an action, either user-specified or default. - var symbol; + let actionGroups = {}; // used to combine identical actions into single instances: no use duplicating action code needlessly + let actionGroupValue = {}; // stores the unaltered, expanded, user-defined action code for each action group. + let stateHasAction = []; // marks which state IDs have an action, either user-specified or default. // and now go and process the entire grammar: - productions.forEach(buildProductionAction); + productions.forEach(buildProductionAction, { actionGroups, actionGroupValue, stateHasAction }); - for (var hash in actionGroups) { + for (let hash in actionGroups) { actions.push([].concat.apply([], actionGroups[hash]).join('\n') + '\n\n' + actionGroupValue[hash] + '\n break;\n'); } // add the special error recovery reduction action: if (this.hasErrorRecovery) { - var userland_err_recov_redux_code = ''; + let userland_err_recov_redux_code = ''; actions.push(`case YY_ERROR_RECOVERY_COMBINE_ID: // === NO_ACTION[1] :: ensures that anyone (but us) using this new state will fail dramatically! // error recovery reduction action (action generated by jison, @@ -30967,16 +30986,16 @@ generator.buildProductionActions = function buildProductionActions() { } // check if all IDs have an action now: - var missingActions = []; - for (var idx = 0, len = stateHasAction.length; idx < len; idx++) { + let missingActions = []; + for (let idx = 0, len = stateHasAction.length; idx < len; idx++) { if (!stateHasAction[idx]) { missingActions.push(idx); } } - this.missingActions = missingActions; + this.missingActions = missingActions; if (missingActions.length) { if ( this.DEBUG) { - this.warn("WARNING: missing actions for states: ", missingActions); + this.warn('WARNING: missing actions for states: ', missingActions); } actions.push(`default: @@ -30984,7 +31003,7 @@ generator.buildProductionActions = function buildProductionActions() { // When we hit this entry, it's always a non-recoverable issue as this is a severe internal parser state failure: function __b0rk_on_internal_failure(str) { - var hash = yyparser.constructParseErrorInfo(str, null, null, false); + let hash = yyparser.constructParseErrorInfo(str, null, null, false); return yyparser.parseError(str, hash, yyparser.JisonParserError); } @@ -30994,7 +31013,7 @@ generator.buildProductionActions = function buildProductionActions() { } actions.push('}'); - var parameters = 'yytext, yyleng, yylineno, yyloc, yystate /* action[1] */, yysp, yyrulelength, yyvstack, yylstack, yystack, yysstack'; + let parameters = 'yytext, yyleng, yylineno, yyloc, yystate /* action[1] */, yysp, yyrulelength, yyvstack, yylstack, yystack, yysstack'; this.performAction = [].concat( 'function parser__PerformAction(' + parameters + ') {', @@ -31113,7 +31132,7 @@ generator.buildProductionActions = function buildProductionActions() { moduleInit.forEach(function (chunk) { assert__default['default'](chunk.qualifier); assert__default['default'](typeof chunk.include === 'string'); - var moduleInclude = chunk.include; + let moduleInclude = chunk.include; //self.actionsUseYYLENG = self.actionsUseYYLENG || analyzeFeatureUsage(moduleInclude, /\byyleng\b/g, 0); //self.actionsUseYYLINENO = self.actionsUseYYLINENO || analyzeFeatureUsage(moduleInclude, /\byylineno\b/g, 0); @@ -31181,8 +31200,8 @@ generator.buildProductionActions = function buildProductionActions() { this.actionsUseValueAssignment = true; break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": // <-- this one injects *nothing* + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'skip': // <-- this one injects *nothing* break; } this.actionsUseValueTracking = this.actionsUseValueTracking || this.actionsUseYYLENG || this.actionsUseYYTEXT || this.actionsUseValueAssignment; @@ -31191,8 +31210,8 @@ generator.buildProductionActions = function buildProductionActions() { default: break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": // <-- this one injects *nothing* + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'skip': // <-- this one injects *nothing* break; } this.actionsUseLocationTracking = this.actionsUseLocationTracking || this.actionsUseYYLINENO || this.actionsUseYYLOC || this.actionsUseLocationAssignment || this.actionsUseYYMERGELOCATIONINFO; @@ -31213,7 +31232,7 @@ generator.buildProductionActions = function buildProductionActions() { gen_hash = null; // create check hash of the new generated code: - var new_hash = mkParserFeatureHash(this); + let new_hash = mkParserFeatureHash(this); if ( this.DEBUG) { Jison$1.print('Optimization analysis:\n', { @@ -31242,7 +31261,7 @@ generator.buildProductionActions = function buildProductionActions() { hasErrorReporting: this.hasErrorReporting, defaultActionMode: this.options.defaultActionMode, testCompileActionCode: this.options.testCompileActionCode, - noTryCatch: this.options.noTryCatch, + noTryCatch: this.options.noTryCatch }); } @@ -31265,9 +31284,9 @@ generator.buildProductionActions = function buildProductionActions() { moduleInit.__consumedInitCodeSlots__ = []; moduleInit.getInitCodeSection = function getInitCodeSection(section) { - var rv = []; - for (var i = 0, len = this.length; i < len; i++) { - var m = this[i]; + let rv = []; + for (let i = 0, len = this.length; i < len; i++) { + let m = this[i]; if (m.qualifier === section) { if (m.include.trim()) { rv.push(m.include); @@ -31279,9 +31298,9 @@ generator.buildProductionActions = function buildProductionActions() { }; moduleInit.getRemainingInitCodeSections = function getRemainingInitCodeSections() { - var rv = []; - for (var i = 0, len = this.length; i < len; i++) { - var m = this[i]; + let rv = []; + for (let i = 0, len = this.length; i < len; i++) { + let m = this[i]; if (!this.__consumedInitCodeSlots__[i]) { rv.push(rmCommonWS$5` @@ -31297,8 +31316,6 @@ generator.buildProductionActions = function buildProductionActions() { }; - - // make sure a comment does not contain any embedded '*/' end-of-comment marker // as that would break the generated code function postprocessComment(str) { @@ -31322,13 +31339,13 @@ generator.buildProductionActions = function buildProductionActions() { } function provideSymbolAsSourcecode(sym) { - var ss = String(sym); + let ss = String(sym); return ' /* ' + postprocessComment(ss) + ' */ ' + getSymbolId(sym); } // helper: convert index string/number to proper JS add/subtract expression function indexToJsExpr(n, len, rule4msg) { - var v = parseInt(n, 10); + let v = parseInt(n, 10); // the usual situation: `$3`; MUST reference an rhs[] element or it will be considered an ERROR: if (v > 0) { if (v > len) { @@ -31358,35 +31375,33 @@ generator.buildProductionActions = function buildProductionActions() { return ''; } + // options object { actionGroups, actionGroupValue, stateHasAction } is `this` for this function/callback: function buildProductionAction(handle) { - var i; - var aliased = handle.aliases, - rhs_i; + let aliased = handle.aliases; - var rhs = handle.handle; - var named_token_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$3}$`); + let rhs = handle.handle; + let named_token_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$3}$`); // semantic action specified - var label = [ + let label = [ 'case ', handle.id, ':', '\n /*! Production:: ', postprocessComment(handle.symbol), ' : ' ].concat(postprocessComment(rhs.map(function (sym) { // check if the symbol is a literal terminal, and if it is, quote it: if (sym && !self.nonterminals[sym] && !named_token_re.test(sym) && sym !== self.EOF) { return '"' + sym.replace(/["]/g, '\\"') + '"'; - } - else if (!sym) { + } else if (!sym) { sym = '%epsilon'; } return sym; })), ' */').join(''); - var action = preprocessActionCode(handle.action || ''); - var rule4msg = handle.symbol + ': ' + rhs.join(' '); + let action = preprocessActionCode(handle.action || ''); + let rule4msg = handle.symbol + ': ' + rhs.join(' '); assert__default['default'](typeof handle.id === 'number'); assert__default['default'](handle.id >= 0); - stateHasAction[handle.id] = true; + this.stateHasAction[handle.id] = true; // before anything else, replace direct symbol references, e.g. #NUMBER# when there's a %token NUMBER for your grammar. // This is done to prevent incorrect expansions where tokens are used in rules as RHS elements: we allow these to @@ -31401,9 +31416,9 @@ generator.buildProductionActions = function buildProductionActions() { // replace named semantic values ($nonterminal) if (action.match(new XRegExp__default['default'](`(?:[$@#]|##)${ID_REGEX_BASE$3}`))) { - var count = {}, - names = {}, - donotalias = {}; + let count = {}; + let names = {}; + let donotalias = {}; // When the rule is fitted with aliases it doesn't mean that the action code MUST use those: // we therefor allow access to both the original (non)terminal and the alias. @@ -31434,9 +31449,9 @@ generator.buildProductionActions = function buildProductionActions() { // as an explicit alias: adding auto-alias `e1` would then break the system, // while `e2` would be ambiguous from the human perspective as he *might* then // expect `e2` and `e3`. - var addName = function addName(s) { - var base = s.replace(/[0-9]+$/, ''); - var dna = donotalias[base]; + let addName = function addName(s, i) { + let base = s.replace(/[0-9]+$/, ''); + let dna = donotalias[base]; if (names[s]) { count[s]++; @@ -31457,28 +31472,28 @@ generator.buildProductionActions = function buildProductionActions() { // register the alias/rule name when the real one ends with a number, e.g. `rule5` as // *blocking* the auto-aliasing process for the term of the same base, e.g. `rule`. // This will catch the `WORD[e1]` example above too, via `e1` --> `donotalias['e']` - var markBasename = function markBasename(s) { + let markBasename = function markBasename(s) { if (/[0-9]$/.test(s)) { s = s.replace(/[0-9]+$/, ''); donotalias[s] = true; } }; - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // mark both regular and aliased names, e.g., `id[alias1]` and `id1` - rhs_i = aliased[i]; + let rhs_i = aliased[i]; markBasename(rhs_i); if (rhs_i !== rhs[i]) { markBasename(rhs[i]); } } - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // check for aliased names, e.g., id[alias] - rhs_i = aliased[i]; - addName(rhs_i); + let rhs_i = aliased[i]; + addName(rhs_i, i); if (rhs_i !== rhs[i]) { - addName(rhs[i]); + addName(rhs[i], i); } } action = action.replace( @@ -31495,7 +31510,7 @@ generator.buildProductionActions = function buildProductionActions() { .replace(/\$\$/g, 'this.$') .replace(/@\$/g, 'this._$') .replace(/#\$/g, function (_) { - return provideSymbolAsSourcecode(symbol); + return provideSymbolAsSourcecode(handle.symbol); }) // replace semantic value references ($n) with stack value (stack[n]) .replace(/\$(-?\d+)\b/g, function (_, n) { @@ -31514,7 +31529,7 @@ generator.buildProductionActions = function buildProductionActions() { }) // same as above for token ID references (#n) .replace(/#(-?\d+)\b/g, function (_, n) { - var i = parseInt(n, 10) - 1; + let i = parseInt(n, 10) - 1; if (!rhs[i]) { throw new Error(`invalid token location reference in action code for rule: "${rule4msg}" - location reference: "${_}"`); } @@ -31558,7 +31573,7 @@ generator.buildProductionActions = function buildProductionActions() { // the action code: if some Smart Alec decides to code `this.$` instead of // `$$` it SHOULD NOT confuse the code analysis here! - var uses_$$ = analyzeFeatureUsage(action, /\bthis\.\$[^\w]/g, 0); // use includes assignment, not just read accesses! + let uses_$$ = analyzeFeatureUsage(action, /\bthis\.\$[^\w]/g, 0); // use includes assignment, not just read accesses! // the next check is very rough; we need the AST of the code to do better than this. function analyzeFeatureAssignmentBeforeUse(source, assignment_re, access_re) { @@ -31567,8 +31582,8 @@ generator.buildProductionActions = function buildProductionActions() { // // If no assignment can be found at all, we're probably looking at access-only // OR weird constructs we don't yet understand, in which case we play it safe. - var prelude = source; - var m = source.match(assignment_re); + let prelude = source; + let m = source.match(assignment_re); if (m) { // check the closure exists in the regex: m[1] is filled with its content: assert__default['default'](m[1] != null); @@ -31598,21 +31613,21 @@ generator.buildProductionActions = function buildProductionActions() { return false; // assignment before access (or no usage and assignments at all!) } - var uses_$$_before_assignment = uses_$$ && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\.\$\s*=[^=>]/, /\bthis\.\$[^\w]/g); + let uses_$$_before_assignment = uses_$$ && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\.\$\s*=[^=>]/, /\bthis\.\$[^\w]/g); // ditto for location tracking, but only iff we use it at all: - var uses_$loc = false; - var uses_$loc_before_assignment = false; + let uses_$loc = false; + let uses_$loc_before_assignment = false; if (self.actionsUseLocationTracking) { uses_$loc = analyzeFeatureUsage(action, /\bthis\._\$[^\w]/g, 0); uses_$loc_before_assignment = uses_$loc && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\._\$\s*=[^=>]/, /\bthis\._\$[^\w]/g); } - var inject_default_value_action = (uses_$$_before_assignment || (self.actionsUseValueTracking && !uses_$$)); - var inject_default_loc_action = (uses_$loc_before_assignment || (self.actionsUseLocationTracking && !uses_$loc)); + let inject_default_value_action = (uses_$$_before_assignment || (self.actionsUseValueTracking && !uses_$$)); + let inject_default_loc_action = (uses_$loc_before_assignment || (self.actionsUseLocationTracking && !uses_$loc)); - var default_action = []; + let default_action = []; // Note: // @@ -31623,26 +31638,27 @@ generator.buildProductionActions = function buildProductionActions() { // $$ = undefined; // $@ = undefined; // - var vmode = !inject_default_value_action ? "skip" : self.options.defaultActionMode[0]; - var lmode = !inject_default_loc_action ? "skip" : self.options.defaultActionMode[1]; + let vmode = !inject_default_value_action ? 'skip' : self.options.defaultActionMode[0]; + let lmode = !inject_default_loc_action ? 'skip' : self.options.defaultActionMode[1]; // check if there's no user action specified. Insert default action if it isn't. // first determine the actual number of terms in the production: - var rhs = handle.handle.slice(0); - var real_rhs_length = rhs.length; + let rhs_reduced_length = rhs.length; + let real_rhs_length = rhs.length; // strip away EOF terms at the end of the rule, ditto for epsilon terms: - if (rhs.length) { - switch (rhs[rhs.length - 1]) { + while (rhs_reduced_length) { + switch (rhs[rhs_reduced_length - 1]) { case '$end': - rhs.length--; - break; + rhs_reduced_length--; + continue; case '': // %epsilon - rhs.length--; - break; + rhs_reduced_length--; + continue; } + break; } // then we can choose what to do, depending on the number of terms in the production. @@ -31659,18 +31675,18 @@ generator.buildProductionActions = function buildProductionActions() { // // Ditto for location tracking default actions... // - switch (rhs.length) { + switch (rhs_reduced_length) { case 0: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; <-- but that would cause nondeterministic behaviour, so // we fall back to the default here! - case "ast": - case "none": - default_action.push("this.$ = undefined;"); + case 'ast': + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31679,22 +31695,22 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // an empty production has no location as there are no terms parsed. // ergo: we produce a zero-width location which points at the tail // end of the previous content: // @$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);"); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31705,19 +31721,19 @@ generator.buildProductionActions = function buildProductionActions() { case 1: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; // // WARNING: be careful with the ACCEPT rule as that one's production has - // rhs.length === 1 **BUT** has real_rhs_length === 2 as we have discarded + // rhs_reduced_length === 1 **BUT** has real_rhs_length === 2 as we have discarded // the `$end` term at the end! // Here we need to account for that magick though! - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // As we're looking at a production which has one(1) useful term, we can simply // reference-copy that one intom a fresh array, instead of `slice()`-ing it out // of the vstack. @@ -31726,14 +31742,14 @@ generator.buildProductionActions = function buildProductionActions() { // WARNING/NOTE: as above, and ditto BTW for rule productions which end with // `EOF` as a last term: as we now construct an entire AST, we DO NOT include // those 'values' here! - default_action.push("this.$ = [yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "]];"); + default_action.push('this.$ = [yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ']];'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31742,23 +31758,23 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: // as we have a production length of 1 only, we can simply ref-copy @1: // @$ = @1; // // WARNING: same as above for the value copying: we may have discarded an `EOF` or `$end` term! - default_action.push("this._$ = yylstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this._$ = yylstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31769,29 +31785,29 @@ generator.buildProductionActions = function buildProductionActions() { default: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // - // WARNING: as with the situation further above where rhs.length === 1 after we + // WARNING: as with the situation further above where rhs_reduced_length === 1 after we // have got rid of a possible `EOF` or `$end` at the end of the production, // we again have to account for our trickery earlier and compensate the // action above: again we DO NOT include the value of the EOF/$end token in the // resulting array 'AST', hence our `slice()` end index may vary by one(1): - var end_offset = 1 - real_rhs_length + rhs.length; - default_action.push("this.$ = yyvstack.slice(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp" + /* CANNOT USE indexToJsExpr(rhs.length + 1, real_rhs_length, rule4msg) HERE! */ (end_offset === 0 ? "" : " + " + end_offset) + ");"); + let end_offset = 1 - real_rhs_length + rhs_reduced_length; + default_action.push('this.$ = yyvstack.slice(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp' + /* CANNOT USE indexToJsExpr(rhs_reduced_length + 1, real_rhs_length, rule4msg) HERE! */ (end_offset === 0 ? '' : ' + ' + end_offset) + ');'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31800,20 +31816,20 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: - // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs.length - 1}, yysp); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp);"); + // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs_reduced_length - 1}, yysp); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31826,16 +31842,16 @@ generator.buildProductionActions = function buildProductionActions() { // comment/mark the default action chunk, if any, so we can simply observe // what is user code and what is generated by us in the final product: if (default_action.length > 0) { - var flags = [ - rhs.length, - self.actionsUseValueTracking ? "VT" : "-", - self.actionsUseValueAssignment ? "VA" : "-", - uses_$$ ? "VU" : "-", - uses_$$_before_assignment ? "VUbA" : "-", - self.actionsUseLocationTracking ? "LT" : "-", - self.actionsUseLocationAssignment ? "LA" : "-", - uses_$loc ? "LU" : "-", - uses_$loc_before_assignment ? "LUbA" : "-", + let flags = [ + rhs_reduced_length + '/' + real_rhs_length, + self.actionsUseValueTracking ? 'VT' : '-', + self.actionsUseValueAssignment ? 'VA' : '-', + uses_$$ ? 'VU' : '-', + uses_$$_before_assignment ? 'VUbA' : '-', + self.actionsUseLocationTracking ? 'LT' : '-', + self.actionsUseLocationAssignment ? 'LA' : '-', + uses_$loc ? 'LU' : '-', + uses_$loc_before_assignment ? 'LUbA' : '-' ].join(','); default_action.unshift(`// default action (generated by JISON mode ${self.options.defaultActionMode[0]}/${self.options.defaultActionMode[1]} :: ${flags}):`); @@ -31849,16 +31865,16 @@ generator.buildProductionActions = function buildProductionActions() { action = reindentCodeBlock(action, 4); - var actionHash = mkHashIndex(action); + let actionHash = mkHashIndex(action); // Delay running the postprocess (restore) process until we've done ALL macro expansions: //action = postprocessActionCode(action); - if (actionHash in actionGroups) { - actionGroups[actionHash].push(label); + if (actionHash in this.actionGroups) { + this.actionGroups[actionHash].push(label); } else { - actionGroups[actionHash] = [label]; - actionGroupValue[actionHash] = action; + this.actionGroups[actionHash] = [ label ]; + this.actionGroupValue[actionHash] = action; } } }; @@ -31878,7 +31894,7 @@ generator.trace = (new Function('', 'function no_op_trace() { }\nreturn no_op_tr //generator.trace.name = 'no_op_trace'; generator.warn = function warn() { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); Jison$1.print.call(null, args.join('')); }; @@ -31925,9 +31941,9 @@ generator.reportGrammarInformation = function reportGrammarInformation() { // LR specific mixin class later on, so that we can have another // implementation/report for LL and PEG type grammars. - var rows = 0, cols = 0; - var colmarks = {}; - var i, j, len; + let rows = 0, cols = 0; + let colmarks = {}; + let i, j, len; for (i = 0, len = this.table.length; i < len; i++) { rows++; @@ -31938,8 +31954,8 @@ generator.reportGrammarInformation = function reportGrammarInformation() { } } } - var defrows = 0; - var rowmarks = {}; + let defrows = 0; + let rowmarks = {}; for (j in this.defaultActions) { if (!rowmarks[j]) { rowmarks[j] = true; @@ -31947,8 +31963,8 @@ generator.reportGrammarInformation = function reportGrammarInformation() { } } - var ntc = 0; - for (var nt in this.nonterminals) { + let ntc = 0; + for (let nt in this.nonterminals) { ntc++; } @@ -31967,14 +31983,12 @@ generator.reportGrammarInformation = function reportGrammarInformation() { // --- START of debugTraceSrc chunk --- const debugTraceSrc = ` function debug_trace() { - "use strict"; - if (typeof Jison !== 'undefined' && Jison.print) { Jison.print.apply(null, arguments); } else if (typeof print !== 'undefined') { print.apply(null, arguments); } else if (typeof console !== 'undefined' && console.log) { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); args.unshift(''); // prevent \`%.\` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args console.log.apply(null, args); } @@ -31984,14 +31998,14 @@ function debug_trace() { // Generator debug mixin -var generatorDebug = { +const generatorDebug = { trace: (new Function('', debugTraceSrc + ` return debug_trace;`))(), beforeprocessGrammar: function () { this.trace('Processing grammar.'); }, afteraugmentGrammar: function () { - var trace = this.trace; + let trace = this.trace; trace('\nSymbols:\n'); each(this.symbols, function (sym, i) { trace(sym + '(' + i + ')'); @@ -32005,7 +32019,7 @@ var generatorDebug = { /* * Mixin for common behaviors of lookahead parsers */ -var lookaheadMixin = {}; +let lookaheadMixin = {}; lookaheadMixin.computeLookaheads = function computeLookaheads() { if (this.DEBUG) { @@ -32019,11 +32033,11 @@ lookaheadMixin.computeLookaheads = function computeLookaheads() { }; lookaheadMixin.displayFollowSets = function displayFollowSets() { - var self = this; - var symfollowdbg = {}; + let self = this; + let symfollowdbg = {}; this.productions.forEach(function Follow_prod_forEach_debugOut(production, k) { - var key = ['prod-', k, ': ', production.symbol, ' := ', production.handle.join(' ')].join(''); - var flw = '[' + self.nonterminals[production.symbol].follows.join('] [') + ']'; + let key = [ 'prod-', k, ': ', production.symbol, ' := ', production.handle.join(' ') ].join(''); + let flw = '[' + self.nonterminals[production.symbol].follows.join('] [') + ']'; if (!symfollowdbg[flw]) { symfollowdbg[flw] = {}; } @@ -32034,9 +32048,9 @@ lookaheadMixin.displayFollowSets = function displayFollowSets() { symfollowdbg[flw][key]++; } }); - for (var l in symfollowdbg) { - var lst = []; - for (var k in symfollowdbg[l]) { + for (let l in symfollowdbg) { + let lst = []; + for (let k in symfollowdbg[l]) { lst.push(k); } self.trace('Symbol/Follows:\n ', lst.join('\n '), ' -->\n ', l); @@ -32045,10 +32059,10 @@ lookaheadMixin.displayFollowSets = function displayFollowSets() { // calculate follow sets based on first and nullable lookaheadMixin.followSets = function followSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true; + let productions = this.productions; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { @@ -32057,23 +32071,23 @@ lookaheadMixin.followSets = function followSets() { productions.forEach(function Follow_prod_forEach(production, k) { // q is used in Simple LALR algorithm determine follows in context - var q; - var ctx = !!self.go_; + let q; + let ctx = !!self.go_; - for (var i = 0, t; (t = production.handle[i]); ++i) { + for (let i = 0, t; (t = production.handle[i]); ++i) { if (!nonterminals[t]) continue; // for Simple LALR algorithm, self.go_ checks if if (ctx) { q = self.go_(production.symbol, production.handle.slice(0, i)); } - var bool = (!ctx || q === self.nterms_[t]); - var set; + let bool = (!ctx || q === self.nterms_[t]); + let set; if (i === production.handle.length - 1 && bool) { set = nonterminals[production.symbol].follows; } else { - var part = production.handle.slice(i + 1); + let part = production.handle.slice(i + 1); set = self.first(part); if (self.nullable(part) && bool) { @@ -32081,8 +32095,8 @@ lookaheadMixin.followSets = function followSets() { set.push.apply(set, nonterminals[production.symbol].follows); } } - var follows = nonterminals[t].follows; - var oldcount = follows.length; + let follows = nonterminals[t].follows; + let oldcount = follows.length; follows = union(follows, set); if (oldcount !== follows.length) { cont = true; @@ -32104,8 +32118,8 @@ lookaheadMixin.first = function first(symbol) { return []; // RHS } else if (symbol instanceof Array) { - var firsts = []; - for (var i = 0, t; (t = symbol[i]); ++i) { + let firsts = []; + for (let i = 0, t; (t = symbol[i]); ++i) { if (!this.nonterminals[t]) { if (firsts.indexOf(t) === -1) { firsts.push(t); @@ -32113,41 +32127,39 @@ lookaheadMixin.first = function first(symbol) { } else { firsts = union(firsts, this.nonterminals[t].first); } - if (!this.nullable(t)) - break; + if (!this.nullable(t)) { break; } } return firsts; // terminal } else if (!this.nonterminals[symbol]) { - return [symbol]; + return [ symbol ]; // nonterminal - } else { - return this.nonterminals[symbol].first; } + return this.nonterminals[symbol].first; + }; // fixed-point calculation of FIRST sets lookaheadMixin.firstSets = function firstSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true, - symbol, firsts; + let productions = this.productions; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { cont = false; productions.forEach(function FirstSets_forEach(production, k) { - var firsts = self.first(production.handle); + let firsts = self.first(production.handle); if (firsts.length !== production.first.length) { production.first = firsts; cont = true; } }); - for (symbol in nonterminals) { - firsts = []; + for (let symbol in nonterminals) { + let firsts = []; nonterminals[symbol].productions.forEach(function FirstSets_forEachNonTerm(production) { firsts = union(firsts, production.first); }); @@ -32161,9 +32173,9 @@ lookaheadMixin.firstSets = function firstSets() { // fixed-point calculation of NULLABLE lookaheadMixin.nullableSets = function nullableSets() { - var nonterminals = this.nonterminals, - self = this, - cont = true; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { @@ -32172,7 +32184,9 @@ lookaheadMixin.nullableSets = function nullableSets() { // check if each production is nullable this.productions.forEach(function isEachProductionNullable(production, k) { if (!production.nullable) { - for (var i = 0, n = 0, t; (t = production.handle[i]); ++i) { + let i = 0; + let n = 0; + for (let t; (t = production.handle[i]); ++i) { if (self.nullable(t)) n++; } if (n === i) { // production is nullable if all tokens are nullable @@ -32182,9 +32196,9 @@ lookaheadMixin.nullableSets = function nullableSets() { }); // check if each symbol is nullable - for (var symbol in nonterminals) { + for (let symbol in nonterminals) { if (!this.nullable(symbol)) { - for (var i = 0, production; (production = nonterminals[symbol].productions.item(i)); i++) { + for (let i = 0, production; (production = nonterminals[symbol].productions.item(i)); i++) { if (production.nullable) { nonterminals[symbol].nullable = cont = true; } @@ -32201,7 +32215,7 @@ lookaheadMixin.nullable = function nullable(symbol) { return true; // RHS } else if (symbol instanceof Array) { - for (var i = 0, t; (t = symbol[i]); ++i) { + for (let i = 0, t; (t = symbol[i]); ++i) { if (!this.nullable(t)) { return false; } @@ -32211,14 +32225,14 @@ lookaheadMixin.nullable = function nullable(symbol) { } else if (!this.nonterminals[symbol]) { return false; // nonterminal - } else { - return this.nonterminals[symbol].nullable; } + return this.nonterminals[symbol].nullable; + }; // lookahead debug mixin -var lookaheadDebug = { +const lookaheadDebug = { beforenullableSets: function () { this.trace('Computing Nullable sets.'); }, @@ -32229,7 +32243,7 @@ var lookaheadDebug = { this.trace('Computing Follow sets.'); }, afterfollowSets: function () { - var trace = this.trace; + let trace = this.trace; trace('\nNonterminals:\n'); each(this.nonterminals, function (nt, t) { trace(nt.toString(), '\n'); @@ -32241,7 +32255,7 @@ var lookaheadDebug = { /* * Mixin for common LR parser behavior */ -var lrGeneratorMixin = {}; +let lrGeneratorMixin = {}; // LR state machine actions: @@ -32294,16 +32308,16 @@ lrGeneratorMixin.Item = typal.construct({ return e.id === this.id; }, handleToString: function () { - var handle = this.production.handle.slice(0); + let handle = this.production.handle.slice(0); handle[this.dotPosition] = '.' + (handle[this.dotPosition] || ''); return handle.join(' '); }, toString: function () { - var temp = this.production.handle.slice(0); + let temp = this.production.handle.slice(0); temp[this.dotPosition] = '.' + (temp[this.dotPosition] || ''); - var s = this.production.symbol + ' -> ' + temp.join(' '); - var padlen = Math.max(4, 40 - s.length); - var pad = new Array(padlen); + let s = this.production.symbol + ' -> ' + temp.join(' '); + let padlen = Math.max(4, 40 - s.length); + let pad = new Array(padlen); if (this.follows.length) { s += pad.join(' ') + '#lookaheads= [' + this.follows.join('] [') + ']'; pad = new Array(2); @@ -32316,7 +32330,7 @@ lrGeneratorMixin.Item = typal.construct({ } }); -lrGeneratorMixin.ItemSet = Set.prototype.construct({ +lrGeneratorMixin.ItemSet = Set$1.prototype.construct({ afterconstructor: function () { this.reductions = []; this.goes = {}; @@ -32324,13 +32338,13 @@ lrGeneratorMixin.ItemSet = Set.prototype.construct({ this.shifts = false; this.inadequate = false; this.hash_ = {}; - for (var i = this._items.length - 1; i >= 0; i--) { + for (let i = this._items.length - 1; i >= 0; i--) { this.hash_[this._items[i].id] = true; //i; } }, concat: function concat(set) { - var a = set._items || set; - for (var i = a.length - 1; i >= 0; i--) { + let a = set._items || set; + for (let i = a.length - 1; i >= 0; i--) { this.hash_[a[i].id] = true; } this._items.push.apply(this._items, a); @@ -32344,31 +32358,31 @@ lrGeneratorMixin.ItemSet = Set.prototype.construct({ return this.hash_[item.id]; }, valueOf: function toValue() { - var v = this._items.map(function (a) { return a.id; }).sort().join('|'); + let v = this._items.map(function (a) { return a.id; }).sort().join('|'); this.valueOf = function valueOf_inner() { return v; }; return v; } }); lrGeneratorMixin.closureOperation = function closureOperation(itemSet) { - var closureSet = new this.ItemSet(); - var self = this; + let closureSet = new this.ItemSet(); + let self = this; - var set = itemSet, - itemQueue, - syms = {}; + let set = itemSet; + let itemQueue; + let syms = {}; do { - itemQueue = new Set(); + itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function CO_set_forEach(item) { - var symbol = item.markedSymbol; + let symbol = item.markedSymbol; // if token is a non-terminal, recursively add closures if (symbol && self.nonterminals[symbol]) { if (!syms[symbol]) { self.nonterminals[symbol].productions.forEach(function CO_nt_forEach(production) { - var newItem = new self.Item(production, 0); + let newItem = new self.Item(production, 0); if (!closureSet.contains(newItem)) { itemQueue.push(newItem); } @@ -32393,8 +32407,8 @@ lrGeneratorMixin.closureOperation = function closureOperation(itemSet) { }; lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) { - var gotoSet = new this.ItemSet(), - self = this; + let gotoSet = new this.ItemSet(); + let self = this; itemSet.forEach(function goto_forEach(item, n) { if (item.markedSymbol === symbol) { @@ -32409,14 +32423,14 @@ lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) { * Create unique set of item sets */ lrGeneratorMixin.canonicalCollection = function canonicalCollection() { - var item1 = new this.Item(this.productions[0], 0, [this.EOF]); - var firstStateNoClosure = new this.ItemSet(item1), - firstState = this.closureOperation(firstStateNoClosure), - states = new Set(firstState), - marked = 0, - self = this, - itemSet, - markedSymbols; + let item1 = new this.Item(this.productions[0], 0, [ this.EOF ]); + let firstStateNoClosure = new this.ItemSet(item1); + let firstState = this.closureOperation(firstStateNoClosure); + let states = new Set$1(firstState); + let marked = 0; + let self = this; + let itemSet; + let markedSymbols; states.has = {}; states.has[firstStateNoClosure.valueOf()] = 0; @@ -32438,8 +32452,8 @@ lrGeneratorMixin.canonicalCollection = function canonicalCollection() { // Pushes a unique state into the queue. Some parsing algorithms may perform additional operations lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert(symbol, itemSet, states, stateNum) { - var g = this.gotoOperation(itemSet, symbol), - state = states.has[g.valueOf()]; + let g = this.gotoOperation(itemSet, symbol); + let state = states.has[g.valueOf()]; if (typeof state !== 'undefined') { itemSet.edges[symbol] = state; // store goto transition for table @@ -32454,36 +32468,36 @@ lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert( } itemSet.edges[symbol] = states.size(); // store goto transition for table states.push(g); - g.predecessors[symbol] = [stateNum]; + g.predecessors[symbol] = [ stateNum ]; } } }; lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { - var states = [], - nonterminals = this.nonterminals, - operators = this.operators, - conflictedStates = {}, // set of [state, token] tuples - self = this; + let states = []; + let nonterminals = this.nonterminals; + let operators = this.operators; + let conflictedStates = {}; // set of [state, token] tuples + let self = this; // for each item set itemSets.forEach(function parseTableItem(itemSet, k) { k = +k; - var state = states[k] = {}; - var action, stackSymbol; + let state = states[k] = {}; + let action, stackSymbol; // set shift and goto actions for (stackSymbol in itemSet.edges) { itemSet.forEach(function findShiftAndGotoActions(item, j) { // find shift and goto actions if (item.markedSymbol === stackSymbol) { - var gotoState = itemSet.edges[stackSymbol]; + let gotoState = itemSet.edges[stackSymbol]; assert__default['default'](gotoState); if (nonterminals[stackSymbol]) { // store state to go to after a reduce state[self.symbols_[stackSymbol]] = gotoState; } else { - state[self.symbols_[stackSymbol]] = [SHIFT, gotoState]; + state[self.symbols_[stackSymbol]] = [ SHIFT, gotoState ]; } } }); @@ -32493,25 +32507,25 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { itemSet.forEach(function setAcceptAction(item, j) { if (item.markedSymbol === self.EOF) { // accept - state[self.symbols_[self.EOF]] = [ACCEPT]; + state[self.symbols_[self.EOF]] = [ ACCEPT ]; } }); - var allterms = self.lookAheads ? false : self.terminals; + let allterms = self.lookAheads ? false : self.terminals; // set reductions and resolve potential conflicts itemSet.reductions.forEach(function calcReduction(item, j) { // if parser uses lookahead, only enumerate those terminals - var terminals = allterms || self.lookAheads(itemSet, item); + let terminals = allterms || self.lookAheads(itemSet, item); terminals.forEach(function (stackSymbol) { action = state[self.symbols_[stackSymbol]]; - var op = operators[stackSymbol]; + let op = operators[stackSymbol]; // Reading a terminal and current position is at the end of a production, try to reduce if (action) { - var sol = resolveConflict(item.production, op, [REDUCE, item.production.id], action[0] instanceof Array ? action[0] : action); - self.resolutions.push([k, stackSymbol, sol]); + let sol = resolveConflict(item.production, op, [ REDUCE, item.production.id ], action[0] instanceof Array ? action[0] : action); + self.resolutions.push([ k, stackSymbol, sol ]); if (sol.bydefault) { self.conflicts++; @@ -32549,7 +32563,7 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { if (self.options.noDefaultResolve) { if (!(action[0] instanceof Array)) { - action = [action]; + action = [ action ]; } action.push(sol.r); } @@ -32557,7 +32571,7 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { action = sol.action; } } else { - action = [REDUCE, item.production.id]; + action = [ REDUCE, item.production.id ]; } if (action && action.length) { state[self.symbols_[stackSymbol]] = action; @@ -32608,25 +32622,25 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { // only this time we are careful about the TERROR symbol as a state carrying that one // is an explicitly encoded error recovery rule and should remain as-is. function findDefaults(states, hasErrorRecovery) { - var defaults = {}; + let defaults = {}; states.forEach(function (state, k) { - var act, sym, st; - var i = 0; - var gotos = {}; + let act; + let i = 0; + let gotos = {}; - for (sym in state) { + for (let sym in state) { assert__default['default']({}.hasOwnProperty.call(state, sym)); // it this isn't true, the last part of this function won't work! // keep state rows where there's an error recovery state: if (sym === 2 /* TERROR */) { return; } - st = state[sym]; + let st = state[sym]; if (typeof st !== 'number') { if (st[0] !== REDUCE) { // not a reduce action: forget about this row! return; } - var go = st[1]; + let go = st[1]; if (!gotos[go]) { gotos[go] = true; i++; @@ -32654,8 +32668,8 @@ function findDefaults(states, hasErrorRecovery) { // ... hence we only nuke these table entries (as that makes for a smaller table --> smaller parser file) // when there's no error recovery code included in the generated parser: if (!hasErrorRecovery) { - for (sym in state) { - st = state[sym]; + for (let sym in state) { + let st = state[sym]; if (typeof st !== 'number') { delete state[sym]; } @@ -32670,9 +32684,7 @@ function findDefaults(states, hasErrorRecovery) { // Remove all NONASSOC state transitions from the generated table now that we don't need them any longer function cleanupTable(table) { table.forEach(function (state, k) { - var symbol; - - for (symbol in state) { + for (let symbol in state) { if (state[symbol] === NONASSOC) { delete state[symbol]; } @@ -32682,16 +32694,16 @@ function cleanupTable(table) { // resolves shift-reduce and reduce-reduce conflicts function resolveConflict(production, op, reduce, shift) { - var sln = { - production: production, - operator: op, - r: reduce, - s: shift, - - msg: null, - action: null, - bydefault: false - }; + let sln = { + production: production, + operator: op, + r: reduce, + s: shift, + + msg: null, + action: null, + bydefault: false + }; if (shift[0] === REDUCE) { sln.msg = 'Resolved R/R conflict: use first production declared in grammar.'; @@ -32729,7 +32741,7 @@ function resolveConflict(production, op, reduce, shift) { /* * Mixin for common LR/LL/*any* parser behavior */ -var generatorMixin = {}; +let generatorMixin = {}; // internal helper function: generatorMixin.__prepareOptions = function parser___prepare_Options(opt) { @@ -32743,7 +32755,7 @@ generatorMixin.__prepareOptions = function parser___prepare_Options(opt) { // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*?[a-zA-Z0-9_$]$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "parser" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "parser" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else if (opt.warn_cb) { @@ -32759,7 +32771,7 @@ generatorMixin.__prepareOptions = function parser___prepare_Options(opt) { }; generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComment() { - var out = ` + let out = ` /* parser generated by jison ${version$2} */ /* @@ -32923,9 +32935,9 @@ generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComm * Produces a new errorInfo 'hash object' which can be passed into \`parseError()\`. * See it's use in this parser kernel in many places; example usage: * - * var infoObj = parser.constructParseErrorInfo('fail!', null, + * let infoObj = parser.constructParseErrorInfo('fail!', null, * parser.collect_expected_token_set(state), true); - * var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); + * let retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); * * originalParseError: function(str, hash, ExceptionClass), * The basic \`parseError\` handler provided by JISON. @@ -33127,212 +33139,7 @@ generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComm * flex: boolean * optional: \`true\` ==> flex-like lexing behaviour where the rules are tested * exhaustively to find the longest match. - * backtrack_lexer: boolean (⅏ 센 ⅊ ⁖ ⁘ ⁙ ⁚ ⁛ ⁜ ⁝ ⁞ † ‡ - a⯈b - ∀ ∁ ∂ ∃ ∄ ∅ ∆ ∇ ∈ ∉ ∊ ∋ ∌ ∍ ∎ ∏ -U+221x ∐ ∑ − ∓ ∔ ∕ ∖ ∗ ∘ ∙ √ ∛ ∜ ∝ ∞ ∟ -U+222x ∠ ∡ ∢ ∣ ∤ ∥ ∦ ∧ ∨ ∩ ∪ ∫ ∬ ∭ ∮ ∯ -U+223x ∰ ∱ ∲ ∳ ∴ ∵ ∶ ∷ ∸ ∹ ∺ ∻ ∼ ∽ ∾ ∿ -U+224x ≀ ≁ ≂ ≃ ≄ ≅ ≆ ≇ ≈ ≉ ≊ ≋ ≌ ≍ ≎ ≏ -U+225x ≐ ≑ ≒ ≓ ≔ ≕ ≖ ≗ ≘ ≙ ≚ ≛ ≜ ≝ ≞ ≟ -U+226x ≠ ≡ ≢ ≣ ≤ ≥ ≦ ≧ ≨ ≩ ≪ ≫ ≬ ≭ ≮ ≯ -U+227x ≰ ≱ ≲ ≳ ≴ ≵ ≶ ≷ ≸ ≹ ≺ ≻ ≼ ≽ ≾ ≿ -U+228x ⊀ ⊁ ⊂ ⊃ ⊄ ⊅ ⊆ ⊇ ⊈ ⊉ ⊊ ⊋ ⊌ ⊍ ⊎ ⊏ -U+229x ⊐ ⊑ ⊒ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊜ ⊝ ⊞ ⊟ -U+22Ax ⊠ ⊡ ⊢ ⊣ ⊤ ⊥ ⊦ ⊧ ⊨ ⊩ ⊪ ⊫ ⊬ ⊭ ⊮ ⊯ -U+22Bx ⊰ ⊱ ⊲ ⊳ ⊴ ⊵ ⊶ ⊷ ⊸ ⊹ ⊺ ⊻ ⊼ ⊽ ⊾ ⊿ -U+22Cx ⋀ ⋁ ⋂ ⋃ ⋄ ⋅ ⋆ ⋇ ⋈ ⋉ ⋊ ⋋ ⋌ ⋍ ⋎ ⋏ -U+22Dx ⋐ ⋑ ⋒ ⋓ ⋔ ⋕ ⋖ ⋗ ⋘ ⋙ ⋚ ⋛ ⋜ ⋝ ⋞ ⋟ -U+22Ex ⋠ ⋡ ⋢ ⋣ ⋤ ⋥ ⋦ ⋧ ⋨ ⋩ ⋪ ⋫ ⋬ ⋭ ⋮ ⋯ -U+22Fx ⋰ ⋱ ⋲ ⋳ ⋴ ⋵ ⋶ ⋷ ⋸ ⋹ ⋺ ⋻ ⋼ ⋽ ⋾ ⋿) -U+230x ⌀ ⌁ ⌂ ⌃ ⌄ ⌅ ⌆ ⌇ ⌈ ⌉ ⌊ ⌋ ⌌ ⌍ ⌎ ⌏ -U+231x ⌐ ⌑ ⌒ ⌓ ⌔ ⌕ ⌖ ⌗ ⌘ ⌙ ⌚ ⌛ ⌜ ⌝ ⌞ ⌟ -U+232x ⌠ ⌡ ⌢ ⌣ ⌤ ⌥ ⌦ ⌧ ⌨ 〈 〉 ⌫ ⌬ ⌭ ⌮ ⌯ -U+233x ⌰ ⌱ ⌲ ⌳ ⌴ ⌵ ⌶ ⌷ ⌸ ⌹ ⌺ ⌻ ⌼ ⌽ ⌾ ⌿ -U+234x ⍀ ⍁ ⍂ ⍃ ⍄ ⍅ ⍆ ⍇ ⍈ ⍉ ⍊ ⍋ ⍌ ⍍ ⍎ ⍏ -U+235x ⍐ ⍑ ⍒ ⍓ ⍔ ⍕ ⍖ ⍗ ⍘ ⍙ ⍚ ⍛ ⍜ ⍝ ⍞ ⍟ -U+236x ⍠ ⍡ ⍢ ⍣ ⍤ ⍥ ⍦ ⍧ ⍨ ⍩ ⍪ ⍫ ⍬ ⍭ ⍮ ⍯ -U+237x ⍰ ⍱ ⍲ ⍳ ⍴ ⍵ ⍶ ⍷ ⍸ ⍹ ⍺ ⍻ ⍼ ⍽ ⍾ ⍿ -U+238x ⎀ ⎁ ⎂ ⎃ ⎄ ⎅ ⎆ ⎇ ⎈ ⎉ ⎊ ⎋ ⎌ ⎍ ⎎ ⎏ -U+239x ⎐ ⎑ ⎒ ⎓ ⎔ ⎕ ⎖ ⎗ ⎘ ⎙ ⎚ ⎛ ⎜ ⎝ ⎞ ⎟ -U+23Ax ⎠ ⎡ ⎢ ⎣ ⎤ ⎥ ⎦ ⎧ ⎨ ⎩ ⎪ ⎫ ⎬ ⎭ ⎮ ⎯ -U+23Bx ⎰ ⎱ ⎲ ⎳ ⎴ ⎵ ⎶ ⎷ ⎸ ⎹ ⎺ ⎻ ⎼ ⎽ ⎾ ⎿ -U+23Cx ⏀ ⏁ ⏂ ⏃ ⏄ ⏅ ⏆ ⏇ ⏈ ⏉ ⏊ ⏋ ⏌ ⏍ ⏎ ⏏ -U+23Dx ⏐ ⏑ ⏒ ⏓ ⏔ ⏕ ⏖ ⏗ ⏘ ⏙ ⏚ ⏛ ⏜ ⏝ ⏞ ⏟ -U+23Ex ⏠ ⏡ ⏢ ⏣ ⏤ ⏥ ⏦ ⏧ ⏨ ⏩ ⏪ ⏫ ⏬ ⏭ ⏮ ⏯ -U+23Fx ⏰ ⏱ ⏲ ⏳ ⏴ ⏵ ⏶ ⏷ ⏸ ⏹ ⏺ ⏻ ⏼ ⏽ ⏾ ⏿ - -U+260x ☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☎ ☏ -U+261x ☐ ☑ ☒ ☓ ☔ ☕ ☖ ☗ ☘ ☙ ☚ ☛ ☜ ☝ ☞ ☟ -U+262x ☠ ☡ ☢ ☣ ☤ ☥ ☦ ☧ ☨ ☩ ☪ ☫ ☬ ☭ ☮ ☯ -U+263x ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷ ☸ ☹ ☺ ☻ ☼ ☽ ☾ ☿ -U+264x ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇ ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ -U+265x ♐ ♑ ♒ ♓ ♔ ♕ ♖ ♗ ♘ ♙ ♚ ♛ ♜ ♝ ♞ ♟ -U+266x ♠ ♡ ♢ ♣ ♤ ♥ ♦ ♧ ♨ ♩ ♪ ♫ ♬ ♭ ♮ ♯ -U+267x ♰ ♱ ♲ ♳ ♴ ♵ ♶ ♷ ♸ ♹ ♺ ♻ ♼ ♽ ♾ ♿ -U+268x ⚀ ⚁ ⚂ ⚃ ⚄ ⚅ ⚆ ⚇ ⚈ ⚉ ⚊ ⚋ ⚌ ⚍ ⚎ ⚏ -U+269x ⚐ ⚑ ⚒ ⚓ ⚔ ⚕ ⚖ ⚗ ⚘ ⚙ ⚚ ⚛ ⚜ ⚝ ⚞ ⚟ -U+26Ax ⚠ ⚡ ⚢ ⚣ ⚤ ⚥ ⚦ ⚧ ⚨ ⚩ ⚪ ⚫ ⚬ ⚭ ⚮ ⚯ -U+26Bx ⚰ ⚱ ⚲ ⚳ ⚴ ⚵ ⚶ ⚷ ⚸ ⚹ ⚺ ⚻ ⚼ ⚽ ⚾ ⚿ -U+26Cx ⛀ ⛁ ⛂ ⛃ ⛄ ⛅ ⛆ ⛇ ⛈ ⛉ ⛊ ⛋ ⛌ ⛍ ⛎ ⛏ -U+26Dx ⛐ ⛑ ⛒ ⛓ ⛔ ⛕ ⛖ ⛗ ⛘ ⛙ ⛚ ⛛ ⛜ ⛝ ⛞ ⛟ -U+26Ex ⛠ ⛡ ⛢ ⛣ ⛤ ⛥ ⛦ ⛧ ⛨ ⛩ ⛪ ⛫ ⛬ ⛭ ⛮ ⛯ -U+26Fx ⛰ ⛱ ⛲ ⛳ ⛴ ⛵ ⛶ ⛷ ⛸ ⛹ ⛺ ⛻ ⛼ ⛽ ⛾ ⛿ - - ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ☛ ☞ ✌ ✍ ✎ ✏ -✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -✠ ✡ ✢ ✣ ✤ ✥ ✦ ✧ ★ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ● ❍ ■ ❏ -☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ❐ ❑ ❒ ▲ ▼ ◆ ❖ -◗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ - -U+270x ✀ ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ✊ ✋ ✌ ✍ ✎ ✏ -U+271x ✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -U+272x ✠ ✡ ✢ ✣ a✤b a✥b a✦b a✧b ✨ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -U+273x ✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -U+274x ❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ❌ ❍ ❎ ❏ -U+275x ❐ ❑ ❒ ❓ ❔ ❕ ❖ ❗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ ❟ -U+276x ❠ ❡ ❢ ❣ ❤ ❥ ❦ ❧ ❨ ❩ ❪ ❫ ❬ ❭ ❮ a❯b -U+277x ❰ ❱ ❲ ❳ ❴ ❵ ❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ ❾ ❿ -U+278x ➀ ➁ ➂ ➃ ➄ ➅ ➆ ➇ ➈ ➉ ➊ ➋ ➌ ➍ ➎ ➏ -U+279x ➐ ➑ ➒ ➓ ➔ ➕ ➖ ➗ ➘ ➙ ➚ ➛ ➜ ➝ ➞ ➟ -U+27Ax ➠ ➡ ➢ ➣ ➤ ➥ ➦ ➧ a➨b ➩ ➪ ➫ ➬ ➭ ➮ ➯ -U+27Bx ➰ a➱b ➲ ➳ ➴ ➵ ➶ ➷ ➸ ➹ ➺ ➻ ➼ ➽ ➾ ➿ - -U+2580 ▀ Upper half block -U+2581 ▁ Lower one eighth block -U+2582 ▂ Lower one quarter block -U+2583 ▃ Lower three eighths block -U+2584 ▄ Lower half block -U+2585 ▅ Lower five eighths block -U+2586 ▆ Lower three quarters block -U+2587 ▇ Lower seven eighths block -U+2588 █ Full block -U+2589 ▉ Left seven eighths block -U+258A ▊ Left three quarters block -U+258B ▋ Left five eighths block -U+258C ▌ Left half block -U+258D ▍ Left three eighths block -U+258E ▎ Left one quarter block -U+258F ▏ Left one eighth block -U+2590 ▐ Right half block -U+2591 ░ Light shade -U+2592 ▒ Medium shade -U+2593 ▓ Dark shade -U+2594 ▔ Upper one eighth block -U+2595 ▕ Right one eighth block -U+2596 ▖ Quadrant lower left -U+2597 ▗ Quadrant lower right -U+2598 ▘ Quadrant upper left -U+2599 ▙ Quadrant upper left and lower left and lower right -U+259A ▚ Quadrant upper left and lower right -U+259B ▛ Quadrant upper left and upper right and lower left -U+259C ▜ Quadrant upper left and upper right and lower right -U+259D ▝ Quadrant upper right -U+259E ▞ Quadrant upper right and lower left -U+259F ▟ Quadrant upper right and lower left and lower right -Geometric Shapes -Main articles: Geometric Shapes (Unicode block) and Geometric Shapes Extended (Unicode block) -[hide]Code Glyph Description -U+25A0 ■ Black square -U+25A1 □ White square -U+25A2 ▢ White square with rounded corners -U+25A3 ▣ White square containing small black square -U+25A4 ▤ Square with horizontal fill -U+25A5 ▥ Square with vertical fill -U+25A6 ▦ Square with orthogonal crosshatch fill -U+25A7 ▧ Square with upper left to lower right fill -U+25A8 ▨ Square with upper right to lower left fill -U+25A9 ▩ Square with diagonal crosshatch fill -U+25AA ▪ Black small square -U+25AB ▫ White small square -U+25AC ▬ Black rectangle -U+25AD ▭ White rectangle -U+25AE ▮ Black vertical rectangle -U+25AF ▯ White vertical rectangle -U+25B0 ▰ Black parallelogram -U+25B1 ▱ White parallelogram -U+25B2 ▲ Black up-pointing triangle -U+25B3 △ White up-pointing triangle -U+25B4 ▴ Black up-pointing small triangle -U+25B5 ▵ White up-pointing small triangle -U+25B6 ▶ Black right-pointing triangle -U+25B7 ▷ White right-pointing triangle -U+25B8 ▸ Black right-pointing small triangle -U+25B9 ▹ White right-pointing small triangle -U+25BA ► Black right-pointing pointer -U+25BB ▻ White right-pointing pointer -U+25BC ▼ Black down-pointing triangle -U+25BD ▽ White down-pointing triangle -U+25BE ▾ Black down-pointing small triangle -U+25BF ▿ White down-pointing small triangle -U+25C0 ◀ Black left-pointing triangle -U+25C1 ◁ White left-pointing triangle -U+25C2 ◂ Black left-pointing small triangle -U+25C3 ◃ White left-pointing small triangle -U+25C4 ◄ Black left-pointing pointer -U+25C5 ◅ White left-pointing pointer -U+25C6 ◆ Black diamond -U+25C7 ◇ White diamond -U+25C8 ◈ White diamond containing small black diamond -U+25C9 ◉ Fisheye -U+25CA ◊ Lozenge -U+25CB ○ White circle -U+25CC ◌ Dotted circle -U+25CD ◍ Circle with vertical fill -U+25CE ◎ Bullseye -U+25CF ● Black circle -U+25D0 ◐ Circle with left half black -U+25D1 ◑ Circle with right half black -U+25D2 ◒ Circle with lower half black -U+25D3 ◓ Circle with upper half black -U+25D4 ◔ Circle with upper right quadrant black -U+25D5 ◕ Circle with all but upper left quadrant black -U+25D6 ◖ Left half circle black -U+25D7 ◗ Right half black circle -U+25D8 ◘ Inverse bullet -U+25D9 ◙ Inverse white circle -U+25DA ◚ Upper half inverse white circle -U+25DB ◛ Lower half inverse white circle -U+25DC ◜ Upper left quadrant circular arc -U+25DD ◝ Upper right quadrant circular arc -U+25DE ◞ Lower right quadrant circular arc -U+25DF ◟ Lower left quadrant circular arc -U+25E0 ◠ Upper half circle -U+25E1 ◡ Lower half circle -U+25E2 ◢ Black lower right triangle -U+25E3 ◣ Black lower left triangle -U+25E4 ◤ Black upper left triangle -U+25E5 ◥ Black upper right triangle -U+25E6 ◦ White bullet -U+25E7 ◧ Square with left half black -U+25E8 ◨ Square with right half black -U+25E9 ◩ Square with upper left diagonal half black -U+25EA ◪ Square with lower right diagonal half black -U+25EB ◫ White square with vertical bisecting line -U+25EC ◬ White up-pointing triangle with dot -U+25ED ◭ Up-pointing triangle with left half black -U+25EE ◮ Up-pointing triangle with right half black -U+25EF ◯ Large circle -U+25F0 ◰ White square with upper left quadrant -U+25F1 ◱ White square with lower left quadrant -U+25F2 ◲ White square with lower right quadrant -U+25F3 ◳ White square with upper right quadrant -U+25F4 ◴ White circle with upper left quadrant -U+25F5 ◵ White circle with lower left quadrant -U+25F6 ◶ White circle with lower right quadrant -U+25F7 ◷ White circle with upper right quadrant -U+25F8 ◸ Upper left triangle -U+25F9 ◹ Upper right triangle -U+25FA ◺ Lower-left triangle -U+25FB ◻ White medium square -U+25FC ◼ Black medium square -U+25FD ◽ White medium small square -U+25FE ◾ Black medium small square -U+25FF ◿ Lower right triangle - - + * backtrack_lexer: boolean * optional: \`true\` ==> lexer regexes are tested in order and for invoked; * the lexer terminates the scan when a token is returned by the action code. * xregexp: boolean @@ -33349,7 +33156,7 @@ U+25FF ◿ Lower right triangle generatorMixin.generate = function parser_generate(opt) { opt = this.__prepareOptions(opt); - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -33375,19 +33182,19 @@ generatorMixin.generate = function parser_generate(opt) { generatorMixin.generateAMDModule = function generateAMDModule(opt) { opt = this.__prepareOptions(opt); - var module = this.generateModule_(); - var out = [ + let module = this.generateModule_(); + let out = [ this.generateGenericHeaderComment(), '', 'define(function (require) {', module.initCode, module.commonCode, '', - 'var parser = ' + module.moduleCode, + 'let parser = ' + module.moduleCode, module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(lexSrc); out.push('parser.lexer = lexer;'); @@ -33395,7 +33202,7 @@ generatorMixin.generateAMDModule = function generateAMDModule(opt) { out.push('', module.moduleInclude, '', 'return parser;'); out.push('});'); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; }; @@ -33403,35 +33210,35 @@ generatorMixin.generateAMDModule = function generateAMDModule(opt) { lrGeneratorMixin.generateESModule = function generateESModule(opt) { opt = this.__prepareOptions(opt); - var module = this.generateModule_(); - var out = [ + let module = this.generateModule_(); + let out = [ this.generateGenericHeaderComment(), '', module.initCode, module.commonCode, '', - 'var parser = ' + module.moduleCode, - module.modulePostlude, + 'let parser = ' + module.moduleCode, + module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(this.lexer.generateModule()); out.push('parser.lexer = lexer;'); } out.push('', module.moduleInclude, ''); - var exportMain = ''; - var invokeMain = ''; + let exportMain = ''; + let invokeMain = ''; if (!opt.noMain) { - var moduleNameAsCode = String(opt.moduleMain || commonJsMain); - var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); + let moduleNameAsCode = String(opt.moduleMain || commonJsMain); + let moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); out.push(rmCommonWS$5` ${moduleImportsAsCode} - var yymain = ${moduleNameAsCode.trim()}; + let yymain = ${moduleNameAsCode.trim()}; function yyExecMain() { yymain(process.argv.slice(1)); @@ -33467,7 +33274,7 @@ lrGeneratorMixin.generateESModule = function generateESModule(opt) { }; `); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; }; @@ -33475,11 +33282,11 @@ lrGeneratorMixin.generateESModule = function generateESModule(opt) { generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { opt = this.__prepareOptions(opt); - var moduleName = opt.moduleName; - var main = ''; + let moduleName = opt.moduleName; + let main = ''; if (!opt.noMain) { - var moduleNameAsCode = String(opt.moduleMain || commonJsMain); - var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); + let moduleNameAsCode = String(opt.moduleMain || commonJsMain); + let moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); main = rmCommonWS$5` @@ -33494,7 +33301,7 @@ generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { } `; } - var out = this.generateModule(opt) + + let out = this.generateModule(opt) + rmCommonWS$5` @@ -33515,17 +33322,16 @@ generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { generatorMixin.generateModule = function generateModule(opt) { opt = this.__prepareOptions(opt); - var moduleName = opt.moduleName; - var out = this.generateGenericHeaderComment(); + let moduleName = opt.moduleName; + let out = this.generateGenericHeaderComment(); - var self = this; + let self = this; function _generateNamespace(namespaces, previousNamespace, callback) { - var subModuleName = namespaces.shift(); + let subModuleName = namespaces.shift(); if (subModuleName != null) { - var moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; + let moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; if (namespaces.length > 0) { - return 'var ' + subModuleName + ';\n' - + '(function (' + subModuleName + ') {\n' + return '(function (' + subModuleName + ') {\n' + _generateNamespace(namespaces, subModuleName, callback) + '\n})(' + subModuleName + (previousNamespace == null ? '' : ' = ' + moduleName) + ' || (' + moduleName + ' = {}));\n'; } @@ -33534,14 +33340,14 @@ generatorMixin.generateModule = function generateModule(opt) { return ''; } - var sourceCodeDef = self.generateModuleExpr(); + let sourceCodeDef = self.generateModuleExpr(); out += ` ${sourceCodeDef.init} `; out += _generateNamespace(moduleName.split('.'), null, function _generateNamespace_cb(moduleName) { - var name = (moduleName.match(/\./) ? moduleName : 'var ' + moduleName); + let name = (moduleName.match(/\./) ? moduleName : 'let ' + moduleName); return ` ${name} = ${sourceCodeDef.src} `; @@ -33553,24 +33359,23 @@ generatorMixin.generateModule = function generateModule(opt) { generatorMixin.generateModuleExpr = function generateModuleExpr() { - var out; - var opt = this.__prepareOptions(); - var module = this.generateModule_(); + let opt = this.__prepareOptions(); + let module = this.generateModule_(); - out = [ + let out = [ '(function () {', module.commonCode, '', - 'var parser = ' + module.moduleCode, - module.modulePostlude, + 'let parser = ' + module.moduleCode, + module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(lexSrc); out.push('parser.lexer = lexer;'); } - out = out.concat(['', + out = out.concat([ '', module.moduleInclude, '', 'function Parser() {', @@ -33583,7 +33388,7 @@ generatorMixin.generateModuleExpr = function generateModuleExpr() { '})();' ]); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return { @@ -33593,7 +33398,7 @@ generatorMixin.generateModuleExpr = function generateModuleExpr() { }; function removeUnusedKernelFeatures(parseFn, info) { - var actionFn = info.performAction; + let actionFn = info.performAction; if (info.actionsAreAllDefault) { // in this case, there's no need to call the parseAction function at all: @@ -33635,7 +33440,7 @@ function removeUnusedKernelFeatures(parseFn, info) { // if (typeof lexer.yyleng === 'undefined') { // lexer.yyleng = 0; // } - // var yyleng; + // let yyleng; // ... parseFn = parseFn @@ -33654,7 +33459,7 @@ function removeUnusedKernelFeatures(parseFn, info) { // remove: // - // var yylineno; + // let yylineno; // ... parseFn = parseFn @@ -33709,7 +33514,7 @@ function removeUnusedKernelFeatures(parseFn, info) { // remove: // - // var yyloc = lexer.yylloc; + // let yyloc = lexer.yylloc; // lstack[sp] = yyloc; // ... // lstack[sp] = copy_yylloc(lexer.yylloc); @@ -33749,11 +33554,11 @@ function removeUnusedKernelFeatures(parseFn, info) { // } // // and - // + // // if (sp >= 0 && typeof vstack[sp] !== 'undefined') { // retval = vstack[sp]; // } - // + // // but keep the yyval declaration as either location tracking MAY // still be employed by the grammar OR the grammar uses advanced // code which uses `yyval` as a run-time store which carries data @@ -33799,13 +33604,13 @@ function removeUnusedKernelFeatures(parseFn, info) { if (info.actionsAreAllDefault) { // remove // - // var yyval = { + // let yyval = { // $: true, // _$: undefined, // yy: sharedState_yy // }; parseFn = parseFn - .replace(/\s+var yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); + .replace(/\s+let yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); } } @@ -33820,10 +33625,14 @@ function removeUnusedKernelFeatures(parseFn, info) { // remove: // - // var yydebug = false; + // let yydebug = false; // ... and delete yydebug function definition ... // ... // if (yydebug) yydebug(...); + // ... + // if (yydebug) { + // yydebug(...); + // } // // and // @@ -33834,9 +33643,10 @@ function removeUnusedKernelFeatures(parseFn, info) { parseFn = parseFn - .replace(/\s+var yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') - // strip multi-line `if (debug) yydebug(..., {...});` statements + .replace(/\s+let yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') + // strip multi-line `if (debug) { yydebug(..., {...}); }` statements // also strip simple yet possibly multi-line `if (debug) yydebug('...');` statements + .replace(/\n\s+if\s+\(yydebug\)\s+\{[\r\n]+\s+yydebug\([^]+?}\);[\s\r\n]+}\s*/g, '\n\n\n\n\n\n\n\n\n') .replace(/\n\s+if\s+\(yydebug\)\s+yydebug\([^]+?['}]\);[^\r\n]*?/g, '\n\n\n\n\n\n\n\n\n') // strip single-line `yydebug(...);` statements .replace(/^.*?\byydebug\b[^;]+?\);[^\r\n]*?$/gm, '') @@ -33921,8 +33731,8 @@ function removeUnusedKernelFeatures(parseFn, info) { */ parseFn = parseFn .replace(/\s+try \{([\s\r\n]+this\.__reentrant_call_depth[\s\S]+?)\} catch \(ex\) \{[\s\S]+?\} finally \{([^]+?)\}\s+\/\/\s+\/finally/, function replace_noTryCatch(m, p1, p2) { - p1 = p1.replace(/^ /mg, ' '); - p2 = p2.replace(/^ /mg, ' '); + p1 = p1.replace(/^ {8}/mg, ' '); + p2 = p2.replace(/^ {8}/mg, ' '); return '\n' + p1 + '\n // ... AND FINALLY ...\n' + p2; }) .replace(/^[^\n]+\b__reentrant_call_depth\b[^\n]+$/gm, '\n'); @@ -33980,29 +33790,29 @@ function removeUnusedKernelFeatures(parseFn, info) { // // https://github.com/zaach/jison/pull/332 function expandParseArguments(parseFn, self) { - var arglist = self.parseParams; + let arglist = self.parseParams; if (!arglist || arglist.length === 0) { parseFn = parseFn.replace(/, parseParams\b/g, ''); parseFn = parseFn.replace(/\bparseParams\b/g, ''); - parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers:\s+parseParamsAsMembers\b/g, ''); + parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers\b/g, ''); } else { parseFn = parseFn.replace(/, parseParams\b/g, ', ' + arglist.join(', ')); parseFn = parseFn.replace(/\bparseParams\b/g, arglist.join(', ')); - parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers:\s+parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { - var s = ','; + parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { + let s = ','; // determine longest name of the bunch (for formatting the generated code) - var max_k_len = 0; - for (var i = 0, len = arglist.length; i < len; i++) { - var k = arglist[i]; + let max_k_len = 0; + for (let i = 0, len = arglist.length; i < len; i++) { + let k = arglist[i]; max_k_len = Math.max(max_k_len, k.length); } - var wsi2 = (new Array(max_k_len + 1)).join(' '); + let 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 i = 0, len = arglist.length; i < len; i++) { - var k = arglist[i]; + for (let i = 0, len = arglist.length; i < len; i++) { + let k = arglist[i]; s += '\n' + ws + k + ': ' + k + (i < len - 1 ? ',' + wsi2.substr(0, max_k_len - k.length - 1) : wsi2.substr(0, max_k_len - k.length)) + ' // parseParams::' + k; } return s; @@ -34037,17 +33847,17 @@ function pickOneOfTwoCodeAlternatives(parseFn, pick_A_not_B, A_start_marker, B_s } function addOrRemoveTokenStack(fn, wantTokenStack) { - var parseFn = fn; + let parseFn = fn; // We don't use the Esprima+Escodegen toolchain as those loose the code comments easily; // instead we just chop the code using labels as sentinels for our chopping-it-up regexes: // // if (wantTokenStack) { // try { - // var ast = esprima.parse(parseFn); - // var stackAst = esprima.parse(String(tokenStackLex)).body[0]; + // let ast = esprima.parse(parseFn); + // let stackAst = esprima.parse(String(tokenStackLex)).body[0]; // stackAst.id.name = 'lex'; // - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); // // labeled[0].body = stackAst; // @@ -34057,7 +33867,7 @@ function addOrRemoveTokenStack(fn, wantTokenStack) { // } // } else { // // remove the line: - // // var tstack = []; // token stack + // // let tstack = []; // token stack // parseFn = parseFn.replace(/tstack = .*$/m, ''); // return parseFn; // } @@ -34066,23 +33876,23 @@ function addOrRemoveTokenStack(fn, wantTokenStack) { if (wantTokenStack) { // And rename the `tokenStackLex` function to become the new `lex`: return parseFn.replace(/\btokenStackLex\b/g, 'lex'); - } else { - // Also nuke the support declaration statement: - // var tstack = []; - return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); } + // Also nuke the support declaration statement: + // let tstack = []; + return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); + } // returns parse function with/without error recovery code function pickErrorHandlingChunk(fn, hasErrorRecovery) { - var parseFn = fn; + let parseFn = fn; // We don't use the Esprima+Escodegen toolchain as those loose the code comments easily; // instead we just chop the code using labels as sentinels for our chopping-it-up regexes: // try { - // var ast = esprima.parse(parseFn); + // let ast = esprima.parse(parseFn); - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("' + + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("' + // (!hasErrorRecovery ? '_handle_error_with_recovery' : '_handle_error_no_recovery') + // '"))', ast); // Jison.print('labeled: ', labeled); @@ -34098,7 +33908,7 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // and some post-coital touch-ups: if (!hasErrorRecovery) { // Also nuke the support declaration statement: - // var recovering = 0; + // let recovering = 0; // and the recovery support statements: // if (recovering > 0) { // recovering--; @@ -34107,7 +33917,7 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // , recovering: recovering // ASSERT(recovering === 0); parseFn = parseFn - .replace(/^\s*var recovering.*$/gm, '') + .replace(/^\s*let recovering.*$/gm, '') .replace(/, recovering: recovering/g, '') .replace(/^.*?recovering =.*$/gm, '') .replace(/^\s+recovering[,]?\s*$/gm, '') @@ -34119,11 +33929,11 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // ... KILL this chunk ... // } .replace(/\s+if[^a-z]+preErrorSymbol.*?\{\s*\/\/[^\n]+([\s\S]+?)\} else \{[\s\S]+?\}\n\s+\}\n/g, '\n$1\n\n\n\n') - .replace(/^\s+(?:var )?preErrorSymbol = .*$/gm, '') + .replace(/^\s+(?:let )?preErrorSymbol = .*$/gm, '') .replace(/^.*?\bpreErrorSymbol =.*$/gm, '') // And nuke the support declaration statement: - // var lastEofErrorStateDepth = 0; - .replace(/^\s*var lastEofErrorStateDepth.*$/gm, ''); + // let lastEofErrorStateDepth = 0; + .replace(/^\s*let lastEofErrorStateDepth.*$/gm, ''); } return parseFn; } @@ -34132,7 +33942,7 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // - module.commonCode: initialization code that should be placed before the module // - module.moduleCode: code that creates the module object lrGeneratorMixin.generateModule_ = function generateModule_() { - var parseFn = String(parser$4.parse); + let parseFn = String(parser$4.parse); parseFn = pickErrorHandlingChunk(parseFn, this.hasErrorRecovery); parseFn = addOrRemoveTokenStack(parseFn, this.options.tokenStack); @@ -34141,9 +33951,9 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { parseFn = expandParseArguments(parseFn, this); - var errorClassCode = this.generateErrorClass(); + let errorClassCode = this.generateErrorClass(); - var exportDest = this.options.exportAllTables; + let exportDest = this.options.exportAllTables; assert__default['default'](exportDest); // store the parse tables: @@ -34151,10 +33961,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { exportDest.defaultParseActions = this.defaultActions; exportDest.parseProductions = this.productions_; - var exportSourceCode = this.options.exportSourceCode; - assert__default['default'](exportSourceCode); - - var tableCode; + let tableCode; switch (this.options.compressTables | 0) { case 0: // no compression tableCode = this.generateTableCode0(this.table, this.defaultActions, this.productions_); @@ -34177,29 +33984,27 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // Generate the initialization code - var initCode = [].concat( + let initCode = [].concat( this.moduleInit.getInitCodeSection('imports'), this.moduleInit.getInitCodeSection('init') ); - var commonCode = [].concat( + let commonCode = [].concat( this.moduleInit.getInitCodeSection('required'), errorClassCode.commonCode, errorClassCode.moduleCode, - ['\nYY_REMAINING_INIT_CODE_SECTIONS_GO_HERE\n'], + [ '\nYY_REMAINING_INIT_CODE_SECTIONS_GO_HERE\n' ], tableCode.commonCode ); - // sort hash table by key to produce a nicer output: function produceSymbolTable(tbl) { - var a = Object.keys(tbl); + let a = Object.keys(tbl); a.sort(); - var nt = {}; - var k; - for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; + let nt = {}; + for (let i = 0, len = a.length; i < len; i++) { + let k = a[i]; // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number // and we do not want `$eof`/`EOF` to show up in the symbol tables of generated parsers @@ -34213,12 +34018,11 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // swap key and value and then sort hash table by key to produce a nicer output: function produceTerminalTable(tbl) { - var a = Object.keys(tbl); - var nt = {}; - var k, v; - for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; - v = tbl[k]; + let a = Object.keys(tbl); + let nt = {}; + for (let i = 0, len = a.length; i < len; i++) { + let k = a[i]; + let v = tbl[k]; nt[v] = +k; // convert numeric key back to number type; all terminals have numeric keys } return produceSymbolTable(nt); @@ -34226,71 +34030,71 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { function produceProductionsForDebugging(options, symbols, base) { function get_orig_symbol(s) { - var a = s.split(':'); + let a = s.split(':'); if (a.length === 1 || a[0] === '') { return { state: -1, symbol: s }; } - var state = a[0]; + let state = a[0]; a.shift(); return { state: +state, - symbol: a.join(':'), + symbol: a.join(':') }; } function get_orig_symbol_set(arr) { - var rv = {}; - for (var i = 0, len = arr.length; i < len; i++) { - var item = arr[i]; - var symbol = get_orig_symbol(item); + let rv = {}; + for (let i = 0, len = arr.length; i < len; i++) { + let item = arr[i]; + let symbol = get_orig_symbol(item); rv[symbol.symbol] = symbol.state; } return Object.keys(rv); } - var tbl = this.nonterminals; - var sym = this.symbols_ || symbols; + let tbl = this.nonterminals; + let sym = this.symbols_ || symbols; if (!options.outputDebugTables && !options.exportAllTables.enabled) { return undefined; } - var prods = { + let prods = { ids: {}, states: {}, rules: {}, nonterminals: {}, symbols: {}, first: {}, - follows: {}, + follows: {} }; - var self = this; + let self = this; this.productions.forEach(function Follow_prod_forEach_genDebugTable(production, k) { - var nonterm = production.symbol; + let nonterm = production.symbol; prods.states[k] = nonterm; prods.ids[nonterm] = sym[nonterm]; - var lst = prods.rules[nonterm] || {}; + let lst = prods.rules[nonterm] || {}; lst[k] = gen_lalr_states_production(production, k, false, k, true); prods.rules[nonterm] = lst; }); function gen_nonterminal(nt) { - var l = nt.productions._items; - var lst = l.map(function (p, i) { + let l = nt.productions._items; + let lst = l.map(function (p, i) { return gen_lalr_states_production(p, i, false, false, false); }); - var rv = { + let rv = { symbol: nt.symbol, productions: lst, first: nt.first, base_first: get_orig_symbol_set(nt.first), follows: nt.follows, base_follows: get_orig_symbol_set(nt.follows), - nullable: nt.nullable, + nullable: nt.nullable }; // clean up structure: ditch superfluous elements: @@ -34304,7 +34108,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { return rv; } - for (var key in tbl) { + for (let key in tbl) { prods.nonterminals[key] = gen_nonterminal(tbl[key]); } @@ -34313,9 +34117,9 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { } function gen_lalr_states_production(production, index, dotPosition, state, patch_base) { - var nonterm = production.symbol; - var hlen = production.handle.length; - var rulestr = production.handle.map(function (t, idx) { + let nonterm = production.symbol; + let hlen = production.handle.length; + let rulestr = production.handle.map(function (t, idx) { if (!t) { t = '%epsilon'; } @@ -34329,7 +34133,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { rulestr += ' ⬤'; } - var base_rulestr = production.handle.map(function (t) { + let base_rulestr = production.handle.map(function (t) { if (!t) { t = '%epsilon'; } @@ -34337,7 +34141,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { return t; }).join(' '); - var rv = { + let rv = { symbol: nonterm, base_symbol: get_orig_symbol(nonterm).symbol, handle: rulestr, @@ -34356,12 +34160,11 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { }; // Determine state for given production, if it's not a production that's listed as part of a state: - var chk, idx; - var lst = prods.rules[nonterm]; - chk = rv.symbol + ' : ' + rv.handle; - for (idx in lst) { + let lst = prods.rules[nonterm]; + let chk = rv.symbol + ' : ' + rv.handle; + for (let idx in lst) { idx = +idx; - var p = lst[idx]; + let p = lst[idx]; if (p) { if (p.symbol + ' : ' + p.handle === chk) { assert__default['default'](rv.state === -1); @@ -34374,9 +34177,9 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // Try to reference base productions from newg child productions and vice versa: chk = rv.base_symbol + ' : ' + rv.base_handle; if (base && base.rules) { - var pr = base.rules[rv.base_symbol]; - for (idx in pr) { - var bprod = pr[idx]; + let pr = base.rules[rv.base_symbol]; + for (let idx in pr) { + let bprod = pr[idx]; if (bprod.symbol + ' : ' + bprod.handle === chk) { assert__default['default'](rv.base_state === -1); rv.base_state = bprod.state; @@ -34410,13 +34213,13 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { if (this.states) { prods.lalr_states = []; - var these_states = this.states; + let these_states = this.states; these_states.forEach(function traverse_states(state, i) { //assert(state.inadequate ? these_states.inadequate : true); state.forEach(function traverse_state(item, j) { // is this a REDUCE state? - var nterm_first = self.nonterminals[item.production.symbol].first; - var rv = { + let nterm_first = self.nonterminals[item.production.symbol].first; + let rv = { state: i, item_index: j, is_reduce_state: (item.dotPosition === item.production.handle.length), @@ -34429,7 +34232,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { nterm_first: nterm_first, base_nterm_first: get_orig_symbol_set(nterm_first), prod_first: item.production.first, - base_prod_first: get_orig_symbol_set(item.production.first), + base_prod_first: get_orig_symbol_set(item.production.first) }; // clean up structure: ditch superfluous elements: @@ -34448,13 +34251,12 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { }); } - var nt = tbl; - var sbn; - for (sbn in nt) { - var orig_symbol = get_orig_symbol(sbn); - var item = nt[sbn]; - var firsts = item.first; - var follows = item.follows; + let nt = tbl; + for (let sbn in nt) { + let orig_symbol = get_orig_symbol(sbn); + let item = nt[sbn]; + let firsts = item.first; + let follows = item.follows; if (!prods.symbols[orig_symbol.symbol]) { prods.symbols[orig_symbol.symbol] = orig_symbol.state; } @@ -34469,10 +34271,10 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { prods.follows[orig_symbol.symbol] = prods.follows[orig_symbol.symbol].concat(follows); } } - for (sbn in prods.first) { + for (let sbn in prods.first) { prods.first[sbn] = get_orig_symbol_set(prods.first[sbn]); } - for (sbn in prods.follows) { + for (let sbn in prods.follows) { prods.follows[sbn] = get_orig_symbol_set(prods.follows[sbn]); } @@ -34483,11 +34285,11 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { } function produceTerminalDescriptions(tbl, sym) { - var rv = {}; - var count = 0; - for (var k in tbl) { - var descr = tbl[k]; - var id = sym[k]; + let rv = {}; + let count = 0; + for (let k in tbl) { + let descr = tbl[k]; + let id = sym[k]; if (id && descr && descr !== id) { rv[id] = descr; count++; @@ -34497,56 +34299,56 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - type: 0, // CLI: --parserType option - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - numExpectedConflictStates: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - json: 1, - _: 1, - noMain: 1, - moduleMain: 1, - moduleMainImports: 1, - noDefaultResolve: 1, - defaultActionMode: 1, - testCompileActionCode: 1, - noTryCatch: 1, - hasPartialLrUpgradeOnConflict: 0, - compressTables: 1, - outputDebugTables: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - lexfile: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - exportAllTables: 1, - exportSourceCode: 1, - tokenStack: 0, - parserErrorsAreRecoverable: 0, - lexerErrorsAreRecoverable: 1, - showSource: 1, - exportAST: 1, - prettyCfg: 1, - - errorRecoveryTokenDiscardCount: 0, - - warn_cb: 0, // function(msg) | true (= use Jison.Print) | false (= throw Exception) - - parseParams: 1, - ranges: 0, + let obj = {}; + let do_not_pass = { + type: 0, // CLI: --parserType option + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + numExpectedConflictStates: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + json: 1, + _: 1, + noMain: 1, + moduleMain: 1, + moduleMainImports: 1, + noDefaultResolve: 1, + defaultActionMode: 1, + testCompileActionCode: 1, + noTryCatch: 1, + hasPartialLrUpgradeOnConflict: 0, + compressTables: 1, + outputDebugTables: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + lexfile: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + exportAllTables: 1, + exportSourceCode: 1, + tokenStack: 0, + parserErrorsAreRecoverable: 0, + lexerErrorsAreRecoverable: 1, + showSource: 1, + exportAST: 1, + prettyCfg: 1, + + errorRecoveryTokenDiscardCount: 0, + + warn_cb: 0, // function(msg) | true (= use Jison.Print) | false (= throw Exception) + + parseParams: 1, + ranges: 0 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -34558,12 +34360,12 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // And now some options which should receive some special processing: if (!obj.hasPartialLrUpgradeOnConflict) { - // only list this option when it's actually TRUE: - delete obj.hasPartialLrUpgradeOnConflict; + // only list this option when it's actually TRUE: + delete obj.hasPartialLrUpgradeOnConflict; } - var pre = obj.pre_parse; - var post = obj.post_parse; + let pre = obj.pre_parse; + let post = obj.post_parse; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_parse = true; @@ -34572,7 +34374,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { obj.post_parse = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$3})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_parse: true(,)?$/gm, function (m, ls, tc) { @@ -34586,27 +34388,27 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // Generate the module creation code - var termDescrs = produceTerminalDescriptions(this.descriptions_, this.symbols_); + let termDescrs = produceTerminalDescriptions(this.descriptions_, this.symbols_); exportDest.terminalDescriptions = termDescrs; - var descrLst = JSON.stringify(termDescrs, null, 2); + let descrLst = JSON.stringify(termDescrs, null, 2); if (descrLst) { descrLst = descrLst.replace(/"([0-9]+)":/g, '$1:'); } - var rules4Dbg = produceProductionsForDebugging.call(this, this.options); + let rules4Dbg = produceProductionsForDebugging.call(this, this.options); exportDest.parseRules = rules4Dbg; - var rulesLst = ((this.options.outputDebugTables || this.options.exportAllTables.enabled) ? JSON.stringify(rules4Dbg, null, 2) : undefined); + let rulesLst = ((this.options.outputDebugTables || this.options.exportAllTables.enabled) ? JSON.stringify(rules4Dbg, null, 2) : undefined); if (rulesLst) { rulesLst = rulesLst.replace(/"([0-9]+)":/g, '$1:').replace(/^(\s+)"([a-z_][a-z_0-9]*)":/gmi, '$1$2:'); } - var symbolTable = produceSymbolTable(this.symbols_); + let symbolTable = produceSymbolTable(this.symbols_); exportDest.symbolTable = symbolTable; // produce a hash lookup table from the terminal set exportDest.terminalTable = produceTerminalTable(this.terminals_); - var moduleCode = `{ + let moduleCode = `{ // Code Generator Information Report // --------------------------------- // @@ -34670,22 +34472,22 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { 'yy: {}', 'options: ' + produceOptions(this.options), 'symbols_: ' + JSON.stringify(symbolTable, null, 2), - 'terminals_: ' + JSON.stringify(this.terminals_, null, 2).replace(/"([0-9]+)":/g, '$1:'), + 'terminals_: ' + JSON.stringify(this.terminals_, null, 2).replace(/"([0-9]+)":/g, '$1:') ].concat( rulesLst ? - 'nonterminals_: ' + rulesLst : - [] + 'nonterminals_: ' + rulesLst : + [] ).concat( descrLst ? - 'terminal_descriptions_: ' + descrLst : - [] + 'terminal_descriptions_: ' + descrLst : + [] ).concat([ define_parser_APIs_1.trim(), 'productions_: ' + tableCode.productionsCode ]).concat( String(this.performAction).trim() !== '' ? - 'performAction: ' + String(this.performAction) : - [] + 'performAction: ' + String(this.performAction) : + [] ).concat([ 'table: ' + tableCode.tableCode, 'defaultActions: ' + tableCode.defaultActionsCode, @@ -34693,24 +34495,24 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { 'parse: ' + parseFn.trim() ]).concat( this.actionsUseYYERROR ? - 'yyError: 1' : - [] + 'yyError: 1' : + [] ).concat( this.actionsUseYYRECOVERING ? - 'yyRecovering: 1' : - [] + 'yyRecovering: 1' : + [] ).concat( this.actionsUseYYERROK ? - 'yyErrOk: 1' : - [] + 'yyErrOk: 1' : + [] ).concat( this.actionsUseYYCLEARIN ? - 'yyClearIn: 1' : - [] + 'yyClearIn: 1' : + [] ).join(',\n'); moduleCode += '\n};'; - var exportSourceCode = this.options.exportSourceCode; + const exportSourceCode = this.options.exportSourceCode; assert__default['default'](exportSourceCode); exportSourceCode.parserChunks = { initCode: expandConstantsInGeneratedCode(initCode.join('\n'), this), @@ -34718,8 +34520,8 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { moduleCode: expandConstantsInGeneratedCode(moduleCode, this), modulePostlude: [ 'parser.originalParseError = parser.parseError;', - 'parser.originalQuoteName = parser.quoteName;', - ].join('\n'), + 'parser.originalQuoteName = parser.quoteName;' + ].join('\n'), moduleInclude: expandConstantsInGeneratedCode(this.moduleInclude, this) }; return exportSourceCode.parserChunks; @@ -34733,8 +34535,6 @@ lrGeneratorMixin.generateErrorClass = function () { // 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. function JisonParserError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -34751,9 +34551,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -34791,14 +34591,14 @@ JisonParserError.prototype.name = 'JisonParserError'; // Generate code that represents the specified parser table lrGeneratorMixin.generateTableCode0 = function (table, defaultActions, productions) { - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); // Don't surround numerical property name numbers in quotes tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); - var prelude = []; + let prelude = []; // Return the variable initialization code and the table code return { @@ -34811,10 +34611,10 @@ lrGeneratorMixin.generateTableCode0 = function (table, defaultActions, productio // Function that extends an object with the given value for all given keys // e.g., x([1, 3, 4], [6, 7], { x: 1, y: 2 }) = { 1: [6, 7]; 3: [6, 7], 4: [6, 7], x: 1, y: 2 } -var compressor1ObjectCode = ` +let compressor1ObjectCode = ` function x(k, v, o) { o = o || {}; - for (var l = k.length; l--; ) { + for (let l = k.length; l--; ) { o[k[l]] = v; } return o; @@ -34823,10 +34623,10 @@ function x(k, v, o) { // Generate code that represents the specified parser table lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productions) { - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); - var usesCompressor = false; + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); + let usesCompressor = false; // Don't surround numerical property name numbers in quotes tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); @@ -34835,22 +34635,21 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio // e.g., { 1: [6, 7]; 3: [6, 7], 4: [6, 7], 5: 8 } = x([1, 3, 4], [6, 7], { 5: 8 }) tableCode = tableCode.replace(/\{[\s\r\n]*\d+:[^\}]+,[\s\r\n]*\d+:[^\}]+\}/g, function (object) { // Find the value that occurs with the highest number of keys - var value, frequentValue, key, - keys = {}, - keyCount, - maxKeyCount = 0, - keyValue, - keyValues = [], - keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; + let frequentValue; + let keys = {}; + let maxKeyCount = 0; + let keyValue; + let keyValues = []; + let keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; while ((keyValue = keyValueMatcher.exec(object))) { // For each value, store the keys where that value occurs - key = keyValue[1]; - value = keyValue[2].trim(); - keyCount = 1; + let key = keyValue[1]; + let value = keyValue[2].trim(); + let keyCount = 1; if (!(value in keys)) { - keys[value] = [key]; + keys[value] = [ key ]; } else { keyCount = keys[value].push(key); } @@ -34863,9 +34662,9 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio // Construct the object with a function call if the most frequent value occurs multiple times if (maxKeyCount > 1) { // Collect all non-frequent values into a remainder object - for (value in keys) { + for (let value in keys) { if (value !== frequentValue) { - for (var k = keys[value], i = 0, l = k.length; i < l; i++) { + for (let k = keys[value], i = 0, l = k.length; i < l; i++) { keyValues.push(k[i] + ':' + value); } } @@ -34879,10 +34678,10 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio }); // Count occurrences of number lists - var list; - var lists = {}; - var listMatcher = /\[[0-9,]+\]/g; - var frequentLists = []; + let list; + let lists = {}; + let listMatcher = /\[[0-9,]+\]/g; + let frequentLists = []; while ((list = listMatcher.exec(tableCode))) { lists[list] = (lists[list] || 0) + 1; @@ -34890,7 +34689,7 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio // Replace frequently occurring number lists with variables tableCode = tableCode.replace(listMatcher, function (list) { - var listId = lists[list]; + let listId = lists[list]; // If listId is a number, it represents the list's occurrence frequency if (typeof listId === 'number') { // If the list does not occur frequently, represent it by the list @@ -34905,7 +34704,7 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio return listId; }); - var prelude = []; + let prelude = []; // Only include the expander function when it's actually used // (tiny grammars don't have much state duplication, so this shaves off @@ -34916,7 +34715,7 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio } if (frequentLists.length > 0) { - prelude.push('var u = [\n ' + frequentLists.join(',\n ') + '\n];'); + prelude.push('let u = [\n ' + frequentLists.join(',\n ') + '\n];'); prelude.push(''); } @@ -34935,9 +34734,9 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio throw new Error("Table Compression mode 2 corrupts the table when the 'noDefaultResolve' option is turned on and one or more conflicts occur. Please use a different compression mode and/or disable this option."); } - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); // We know a couple of things about the parse table: // @@ -34965,33 +34764,29 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); - - function reportColumnsForCompression(def_arr) { - var i, key, len; - var report = []; + let report = []; - len = 0; - for (key in def_arr) { + let len = 0; + for (let key in def_arr) { len = Math.max(len, def_arr[key].length); } - var col_width = 6; - var col_delta_width = 4; + let col_width = 6; + let col_delta_width = 4; function clip(val, width) { - var s = ' ' + val; + let s = ' ' + val; s = s.substr(s.length - width); return s; } - var track_prev4delta = {}; - var c, delta, val, delta_val; - var line = []; + let track_prev4delta = {}; + let line = []; line.push('║'); - for (c in def_arr) { - key = clip(c, col_width); - delta = clip('∆', col_delta_width); + for (let c in def_arr) { + let key = clip(c, col_width); + let delta = clip('∆', col_delta_width); line.push(key); line.push('┊'); line.push(delta); @@ -35001,12 +34796,13 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } report.push(line.join('')); - for (i = 0; i < len; i++) { + for (let i = 0; i < len; i++) { line = []; line.push('║'); - for (c in def_arr) { - var tbl = def_arr[c]; + for (let c in def_arr) { + let val, delta_val; + let tbl = def_arr[c]; if (tbl.length > i) { val = tbl[i] || 0; @@ -35021,8 +34817,8 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio delta_val = '.'; } - key = clip(val, col_width); - delta = clip(delta_val, col_delta_width); + let key = clip(val, col_width); + let delta = clip(delta_val, col_delta_width); line.push(key); line.push('┊'); line.push(delta); @@ -35038,16 +34834,16 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // table is array of 1/2-len arrays: function analyzeTableForCompression(table) { // column: productions' row length - var len_col = []; + let len_col = []; // column: productions' shift size / action column - var pop_col = []; + let pop_col = []; // column: rule number for each slot ('rule'): - var rule_col = []; + let rule_col = []; - var i; - var row_count = table.length; + let i; + let row_count = table.length; for (i = 0; i < row_count; i++) { - var prod = table[i]; + let prod = table[i]; len_col.push(prod.length); assert__default['default'](prod.length <= 2); @@ -35058,10 +34854,10 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio rule_col.push(prod[1]); } - var def_arr = { - 'len': len_col, - 'pop': pop_col, - 'rule': rule_col, + let def_arr = { + len: len_col, + pop: pop_col, + rule: rule_col }; return def_arr; } @@ -35072,14 +34868,14 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // table is hash of 1/2-len arrays: function analyzeSetForCompression(table) { // column: row index - var idx_col = []; + let idx_col = []; // column: REDUCE productions' goto column - var goto_col = []; + let goto_col = []; - var i; + let i; for (i in table) { i = +i; - var prod = table[i]; + let prod = table[i]; idx_col.push(i); // and the special knowledge about the defaultActions[] table: @@ -35087,9 +34883,9 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio goto_col.push(prod); } - var def_arr = { - 'idx': idx_col, - 'goto': goto_col, + let def_arr = { + idx: idx_col, + goto: goto_col }; return def_arr; } @@ -35098,30 +34894,29 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function analyzeGotoTableForCompression(table) { // column: number of symbol hash entries per state slot ('length'): - var len_col = []; + let len_col = []; // column: symbol hash entry key for each slot ('symbol'): - var symbol_col = []; + let symbol_col = []; // column: symbol hash entry value type: number (0) or array (array.length) ('type'): - var type_col = []; + let type_col = []; // column: symbol hash entry value if single GOTO state number ('state'): - var state_col = []; + let state_col = []; // column: symbol hash entry mode value if array slot type (reduce/shift/accept): - var mode_col = []; + let mode_col = []; // column: symbol hash entry goto state value if array slot type: - var goto_col = []; + let goto_col = []; // // column: merged: state_col + goto_col: - // var next_col = []; - - var row_count = table.length; - for (var state = 0; state < row_count; state++) { - var hashtable = table[state]; - var count = 0; - var symbol; - for (symbol in hashtable) { + // let next_col = []; + + let row_count = table.length; + for (let state = 0; state < row_count; state++) { + let hashtable = table[state]; + let count = 0; + for (let symbol in hashtable) { symbol = +symbol; symbol_col.push(symbol); - var slot = hashtable[symbol]; + let slot = hashtable[symbol]; if (slot && slot.length) { // array type slot: assert__default['default'](slot.length === 2 || slot.length === 1); @@ -35148,40 +34943,40 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio len_col.push(count); } - var def_arr = { - 'len': len_col, - 'symbol': symbol_col, - 'type': type_col, - 'state': state_col, - 'mode': mode_col, - 'goto': goto_col, + let def_arr = { + len: len_col, + symbol: symbol_col, + type: type_col, + state: state_col, + mode: mode_col, + goto: goto_col //'next': next_col, }; return def_arr; } - var has_compressed_a_table = false; + let has_compressed_a_table = false; function generateColumn(name, col) { - var rv = []; - var i, j, len, l; + let rv = []; - for (i = 0, len = col.length; i < len; i++) { + for (let i = 0, len = col.length; i < len; i++) { // try basic run-length encoding first: - var v = col[i]; + let v = col[i]; + let j; for (j = i + 1; j < len; j++) { if (col[j] !== v) { break; } } - var runlength = j - i; + let runlength = j - i; // try stepped run-length encoding next: - var delta = col[i + 1] - v; - var steplength = 0; + let delta = col[i + 1] - v; + let steplength = 0; // we don't want to replicate the runlength result, so only look for a match // when delta !== 0: @@ -35195,10 +34990,11 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } // try to match the pattern in history: - var best_pos = 0; - var best_len = 0; - var upper_bound = i - 2; + let best_pos = 0; + let best_len = 0; + let upper_bound = i - 2; for (j = 0; j < upper_bound; j++) { + let l; for (l = 0; col[j + l] === col[i + l]; l++) { // No need to check for: // if (j + l === i) break; @@ -35222,28 +35018,24 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } // weight our options now: - var gain = [ + let gain = [ runlength - 2, steplength - 3, best_len - 2 ]; - var optimum_gain = Math.max.apply(null, gain); + let optimum_gain = Math.max.apply(null, gain); if (optimum_gain <= 0) { rv.push(v); - } - else if (optimum_gain === gain[0]) { + } else if (optimum_gain === gain[0]) { rv.push('s', '[' + v + ', ' + runlength + ']'); i += runlength - 1; - } - else if (optimum_gain === gain[1]) { + } else if (optimum_gain === gain[1]) { rv.push('s', '[' + v + ', ' + steplength + ', ' + delta + ']'); i += steplength - 1; - } - else if (optimum_gain === gain[2]) { + } else if (optimum_gain === gain[2]) { rv.push('c', '[' + best_pos + ', ' + best_len + ']'); i += best_len - 1; - } - else { + } else { rv.push(v); //assert(0); // should never get here! } @@ -35253,11 +35045,11 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } } - var code = [ + let code = [ ' ', name, ': ', 'u([', '\n ', - rv.join(',\n '), // JSON.stringify(col, null, 2), + rv.join(',\n '), // JSON.stringify(col, null, 2), '\n', '])' ].join(''); @@ -35266,7 +35058,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function generateCompressedTable(def_arr) { - var code = [ + let code = [ 'bp({', generateColumn('pop', def_arr.pop) + ',', generateColumn('rule', def_arr.rule), @@ -35277,7 +35069,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function generateCompressedSet(def_arr) { - var code = [ + let code = [ 'bda({', generateColumn('idx', def_arr.idx) + ',', generateColumn('goto', def_arr.goto), @@ -35288,7 +35080,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function generateCompressedGotoTable(def_arr) { - var code = [ + let code = [ 'bt({', generateColumn('len', def_arr.len) + ',', generateColumn('symbol', def_arr.symbol) + ',', @@ -35302,18 +35094,18 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } - var tableDef = analyzeGotoTableForCompression(table); - var defaultActionsDef = analyzeSetForCompression(defaultActions); - var productionsDef = analyzeTableForCompression(productions); + let tableDef = analyzeGotoTableForCompression(table); + let defaultActionsDef = analyzeSetForCompression(defaultActions); + let productionsDef = analyzeTableForCompression(productions); const bp_code_container = ` // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -35326,11 +35118,11 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio const bda_code_container = ` // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -35340,18 +35132,18 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio const bt_code_container = ` // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -35382,7 +35174,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // \`this\` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -35399,9 +35191,9 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -35415,25 +35207,25 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio `; has_compressed_a_table = false; - var tc = generateCompressedGotoTable(tableDef); - var compressGotoTable = has_compressed_a_table; + let tc = generateCompressedGotoTable(tableDef); + let compressGotoTable = has_compressed_a_table; has_compressed_a_table = false; - var dac = generateCompressedSet(defaultActionsDef); - var compressDefaultActions = has_compressed_a_table; + let dac = generateCompressedSet(defaultActionsDef); + let compressDefaultActions = has_compressed_a_table; has_compressed_a_table = false; - var pc = generateCompressedTable(productionsDef); - var compressProductions = has_compressed_a_table; + let pc = generateCompressedTable(productionsDef); + let compressProductions = has_compressed_a_table; - var compressAnything = (compressProductions || compressDefaultActions || compressGotoTable); + let compressAnything = (compressProductions || compressDefaultActions || compressGotoTable); tableCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(tableDef) : '') + (compressGotoTable ? tc : tableCode); defaultActionsCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(defaultActionsDef) : '') + (compressDefaultActions ? dac : defaultActionsCode); productionsCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(productionsDef) : '') + (compressProductions ? pc : productionsCode); - var prelude = [ + let prelude = [ '', compressProductions ? bp_code_container : '', '', @@ -35441,7 +35233,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio '', compressGotoTable ? bt_code_container : '', '', - c_s_u_code_container, + c_s_u_code_container ]; if (!compressAnything) { prelude = []; @@ -35457,31 +35249,29 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio }; // --- START of commonJsMain chunk --- -// +// // default main method for generated commonjs modules const commonJsMain = ` -function (args) { - "use strict"; - +function __jison_default_main__(args) { // When the parser comes with its own \`main\` function, then use that one: if (typeof exports.parser.main === 'function') { - return exports.parser.main(args); + return exports.parser.main(args); } if (!args[1]) { console.log('Usage:', path.basename(args[0]) + ' FILE'); process.exit(1); } - var source = fs.readFileSync(path.normalize(args[1]), 'utf8'); - var dst = exports.parser.parse(source); + const source = fs.readFileSync(path.normalize(args[1]), 'utf8'); + const dst = exports.parser.parse(source); console.log('parser output:\\n\\n', { type: typeof dst, value: dst }); try { - console.log("\\n\\nor as JSON:\\n", JSON.stringify(dst, null, 2)); + 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... */ } - var rv = 0; + let rv = 0; if (typeof dst === 'number' || typeof dst === 'boolean') { rv = dst; } @@ -35491,16 +35281,16 @@ function (args) { // --- END of commonJsMain chunk --- const commonJsMainImports = ` -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); `; // debug mixin for LR parser generators function printAction(a, gen) { - var s = a[0] === SHIFT ? 'shift token (then go to state ' + a[1] + ')' : + let s = a[0] === SHIFT ? 'shift token (then go to state ' + a[1] + ')' : a[0] === REDUCE ? 'reduce by rule: ' + gen.productions[a[1]] : - a[0] === ACCEPT ? 'accept' : 'UNDEFINED ACTION: ' + a[0]; + a[0] === ACCEPT ? 'accept' : 'UNDEFINED ACTION: ' + a[0]; return s; } @@ -35514,13 +35304,13 @@ function traceStates(trace, states, title) { trace('\n'); } -var lrGeneratorDebug = { +const lrGeneratorDebug = { beforeparseTable: function () { this.trace('Building parse table.'); }, afterparseTable: function () { - var trace = this.trace; - var self = this; + let trace = this.trace; + let self = this; if (this.conflicts > 0) { trace('\nConflicts:\n'); this.resolutions.forEach(function (r, i) { @@ -35532,21 +35322,21 @@ var lrGeneratorDebug = { } trace('Done.\n'); }, - aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */ ) { + aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */) { traceStates(this.trace, states, 'as produced by LR::canonicalCollection()'); } }; -var parser$4 = typal.beget(); +const parser$4 = typal.beget(); generatorMixin.createParser = function createParser() { - var sourceCodeDef = this.generateModuleExpr(); + let sourceCodeDef = this.generateModuleExpr(); // produce a chunk of sourcecode that's suitable for evaluation through `eval()`: - var sourcecode = rmCommonWS$5` + let sourcecode = rmCommonWS$5` ${sourceCodeDef.init} - var yy__parser = ${sourceCodeDef.src}; + let yy__parser = ${sourceCodeDef.src}; // produce the generated parser function/class as the last value // in this chunk of code so that we can be sure to produce *that* @@ -35557,15 +35347,15 @@ generatorMixin.createParser = function createParser() { yy__parser; `; - var p = code_exec$2(sourcecode, function generated_code_exec_wrapper_jison(sourcecode) { + let 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); - var rv = eval(sourcecode); + let rv = eval(sourcecode); return rv; }, mkStdOptions$1(this.options, { dumpSourceCodeOnFailure: this.DEBUG, throwErrorOnCompileFailure: true - }), "parser"); + }), 'parser'); assert__default['default'](typeof p === 'object'); assert__default['default'](typeof p.parse === 'function'); assert__default['default'](typeof p.parser === 'undefined'); @@ -35609,7 +35399,7 @@ generatorMixin.createParser = function createParser() { } p.sourceCode = sourceCodeDef; - var self = this; + let self = this; function bind(method) { return function () { self.lexer = p.lexer; @@ -35636,8 +35426,6 @@ parser$4.error = generator.error; // --- START parser Error class chunk --- const parseErrorSourceCode = ` function parseError(str, hash, ExceptionClass) { - "use strict"; - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -35662,7 +35450,7 @@ parser$4.parseError = lrGeneratorMixin.parseError = eval(parseErrorSourceCode + generatorMixin.createLexer = function createLexer(lexerSpec, input, tokens, options) { // TODO: construct options from generator options: // lexer_options = ... - var lexer = new RegExpLexer(lexerSpec, input, tokens, options); + let lexer = new RegExpLexer(lexerSpec, input, tokens, options); return lexer; }; @@ -35701,8 +35489,6 @@ const define_parser_APIs_1 = ` // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - "use strict"; - return '"' + id_str + '"'; }, @@ -35710,8 +35496,6 @@ const define_parser_APIs_1 = ` // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - "use strict"; - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -35723,8 +35507,8 @@ const define_parser_APIs_1 = ` // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -35737,15 +35521,13 @@ const define_parser_APIs_1 = ` // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - "use strict"; - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -35761,11 +35543,10 @@ const define_parser_APIs_1 = ` // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { - "use strict"; + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -35773,10 +35554,10 @@ const define_parser_APIs_1 = ` this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -35788,8 +35569,8 @@ const define_parser_APIs_1 = ` `; // --- END of define_parser_APIs_1 chunk --- -var api_set = (new Function('', 'return { ' + define_parser_APIs_1 + ' };'))(); -for (var api in api_set) { +const api_set = (new Function('', 'return { ' + define_parser_APIs_1 + ' };'))(); +for (let api in api_set) { parser$4[api] = api_set[api]; } @@ -35797,39 +35578,37 @@ for (var api in api_set) { // --- START parser kernel --- parser$4.parse = ` function parse(input, parseParams) { - "use strict"; - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - var tstack = []; // token stack (only used when \`%options token_stack\` support has been enabled) - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - var yytext; - var yylineno; - var yyleng; - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + let tstack = []; // token stack (only used when \`%options token_stack\` support has been enabled) + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + let yytext; + let yylineno; + let yyleng; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -35838,21 +35617,18 @@ function parse(input, parseParams) { post_parse: undefined, pre_lex: undefined, post_lex: undefined, - parseParamsAsMembers: parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - "use strict"; - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -35877,8 +35653,6 @@ function parse(input, parseParams) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - "use strict"; - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -35886,18 +35660,19 @@ function parse(input, parseParams) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -35905,26 +35680,19 @@ function parse(input, parseParams) { // - either the element does not yet exist in \`src\` // - or exists in \`src\` but is NULL or UNDEFINED there, while its value is non-NULL in \`dst\` function shallow_copy_noclobber(dst, src) { - "use strict"; - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - "use strict"; - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -35942,17 +35710,13 @@ function parse(input, parseParams) { this.copy_yytext = this.options.copy_yytext || sharedState_yy.copy_yytext || shallow_copy; this.copy_yylloc = this.options.copy_yylloc || sharedState_yy.copy_yylloc || copy_yylloc_native; - var yydebug = false; + let yydebug = false; if (this.options.debug) { yydebug = function yydebug_impl(msg, obj) { - "use strict"; - - var ref_list; - var ref_names; + let ref_list; + let ref_names; function deepClone(from, sub) { - "use strict"; - if (sub == null) { ref_list = []; ref_names = []; @@ -35964,15 +35728,15 @@ function parse(input, parseParams) { return from; } - var i = ref_list.indexOf(from); + let i = ref_list.indexOf(from); if (i >= 0) { return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference } ref_list.push(from); ref_names.push(sub); - var to = new from.constructor(); - for (var name in from) { + let to = new from.constructor(); + for (let name in from) { if (name === 'parser') continue; if (name === 'lexer') continue; to[name] = deepClone(from[name], name); @@ -36000,13 +35764,11 @@ function parse(input, parseParams) { // wrap try/catch in a function to help the V8 JIT compiler... function yydebug_cvt(obj) { - "use strict"; - - var js; + let js; try { - var re1; + let re1; if (typeof XRegExp === 'undefined') { - re1 = / \\"([a-z_][a-z_0-9. ]*)\\": /ig; + re1 = / {2}\\"([a-z_][a-z_0-9. ]*)\\": /ig; } else { re1 = new XRegExp(' \\"([\\\\p{Alphabetic}_][\\\\p{Alphabetic}\\\\p{Number}_. ]*)\\": ', 'g'); } @@ -36038,21 +35800,25 @@ function parse(input, parseParams) { // them up. Hence we MUST set them up at the start of every \`parse()\` run! if (this.yyError) { this.yyError = function yyError(str /*, ...args */) { - "use strict"; - - if (yydebug) yydebug('yyerror: ', { message: str, args: arguments, symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('yyerror: ', { + message: str, + args: arguments, + symbol, state, newState, recovering, action + }); + } //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); + let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -36073,13 +35839,13 @@ function parse(input, parseParams) { //_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, false); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, false); //_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -36092,18 +35858,14 @@ function parse(input, parseParams) { if (this.yyRecovering) { this.yyRecovering = function yyRecovering() { - "use strict"; - - if (yydebug) yydebug('yyrecovering: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) yydebug('yyrecovering: ', { symbol, state, newState, recovering, action }); return recovering; }; } if (this.yyErrOk) { this.yyErrOk = function yyErrOk() { - "use strict"; - - if (yydebug) yydebug('yyerrok: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) yydebug('yyerrok: ', { symbol, state, newState, recovering, action }); recovering = 0; // DO NOT reset/cleanup \`recoveringErrorInfo\` yet: userland code @@ -36125,9 +35887,7 @@ function parse(input, parseParams) { if (this.yyClearIn) { this.yyClearIn = function yyClearIn() { - "use strict"; - - if (yydebug) yydebug('yyclearin: ', { symbol: symbol, newState: newState, recovering: recovering, action: action, preErrorSymbol: preErrorSymbol }); + if (yydebug) yydebug('yyclearin: ', { symbol, newState, recovering, action, preErrorSymbol }); if (symbol === TERROR) { symbol = 0; yytext = null; @@ -36144,8 +35904,6 @@ function parse(input, parseParams) { // Does the shared state override the default \`parseError\` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -36158,8 +35916,6 @@ function parse(input, parseParams) { // Does the shared state override the default \`quoteName\` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - "use strict"; - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -36173,12 +35929,10 @@ function parse(input, parseParams) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your \`sharedState\`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - "use strict"; - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -36232,8 +35986,8 @@ function parse(input, parseParams) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -36242,8 +35996,8 @@ function parse(input, parseParams) { //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -36277,20 +36031,18 @@ function parse(input, parseParams) { // // Note: epsilon rule's yylloc situation is detected by passing both \`first_index\` and \`first_yylloc\` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - "use strict"; - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -36301,7 +36053,7 @@ function parse(input, parseParams) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -36314,7 +36066,7 @@ function parse(input, parseParams) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -36326,29 +36078,27 @@ function parse(input, parseParams) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or \`dont_look_back\` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -36356,7 +36106,7 @@ function parse(input, parseParams) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -36376,9 +36126,7 @@ function parse(input, parseParams) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your \`lexer\`, \`sharedState\`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - "use strict"; - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -36387,10 +36135,10 @@ function parse(input, parseParams) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -36398,7 +36146,7 @@ function parse(input, parseParams) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -36415,10 +36163,8 @@ function parse(input, parseParams) { // info.value = null; // info.value_stack = null; // ... - "use strict"; - - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -36434,9 +36180,7 @@ function parse(input, parseParams) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - "use strict"; - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -36505,11 +36249,14 @@ function parse(input, parseParams) { // - root_failure_pointer: // copy of the \`stack_pointer\`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -36520,9 +36267,7 @@ function parse(input, parseParams) { }; function getNonTerminalFromCode(symbol) { - "use strict"; - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -36532,22 +36277,20 @@ function parse(input, parseParams) { //_lexer_without_token_stack: function stdLex() { - "use strict"; - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36557,22 +36300,20 @@ function parse(input, parseParams) { } function fastLex() { - "use strict"; - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36581,15 +36322,13 @@ function parse(input, parseParams) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; //_lexer_with_token_stack: // lex function that supports token stacks function tokenStackLex() { - "use strict"; - - var token; + let token; token = tstack.pop() || lexer.lex() || EOF; // if token isn't its numeric value, convert if (typeof token !== 'number') { @@ -36608,13 +36347,13 @@ function parse(input, parseParams) { } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36625,33 +36364,37 @@ function parse(input, parseParams) { //_lexer_with_token_stack_end: - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - "use strict"; - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { // check for error recovery rule in this state - if (yydebug) yydebug('locateNearestErrorRecoveryRule #test#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); - var t = (table[state] && table[state][TERROR]) || NO_ACTION; + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #test#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } + const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we \`yyerrok()\` an error, we must @@ -36666,12 +36409,24 @@ function parse(input, parseParams) { // terminate the parse in a controlled fashion even when we have // very complex error/recovery code interplay in the core + user // action code blocks: - if (yydebug) yydebug('locateNearestErrorRecoveryRule #found#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #found#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { - if (yydebug) yydebug('locateNearestErrorRecoveryRule #skip#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #skip#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; @@ -36681,14 +36436,26 @@ function parse(input, parseParams) { return depth; } if (state === 0 /* $accept rule */ || stack_probe < 1) { - if (yydebug) yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; } - if (yydebug) yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } return -1; // No suitable error recovery rule available. } @@ -36705,7 +36472,7 @@ function parse(input, parseParams) { // whether we'll go with the standard, slower, lex() API or the // \`fast_lex()\` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -36751,17 +36518,23 @@ function parse(input, parseParams) { newState = t[1]; action = t[0]; - if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('after FETCH/LEX: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol], + state, newState, recovering, action + }); + } //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules // handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -36788,7 +36561,13 @@ function parse(input, parseParams) { // invoke the parser's cleanup API! recoveringErrorInfo = this.shallowCopyErrorInfo(p); - if (yydebug) yydebug('error recovery rule detected: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p }); + if (yydebug) { + yydebug('error recovery rule detected: ', { + error_rule_depth, + error: p.errStr, + error_hash: p + }); + } r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { @@ -36806,9 +36585,15 @@ function parse(input, parseParams) { } } - if (yydebug) yydebug('after ERROR DETECT: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p }); + if (yydebug) { + yydebug('after ERROR DETECT: ', { + error_rule_depth, + error: p.errStr, + error_hash: p + }); + } - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -36828,17 +36613,22 @@ function parse(input, parseParams) { preErrorSymbol = 0; symbol = lex(); - if (yydebug) yydebug('after ERROR RECOVERY-3: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol] }); + if (yydebug) { + yydebug('after ERROR RECOVERY-3: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol] + }); + } } // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -36885,20 +36675,18 @@ function parse(input, parseParams) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; - if (yydebug) yydebug('Error recovery process: pushed error info item on the info stack: ', { - item: vstack[sp], - sp, - esp, - vstack, - stack, - sstack, - combineState: NO_ACTION[1] - }); + if (yydebug) { + yydebug('Error recovery process: pushed error info item on the info stack: ', { + item: vstack[sp], + sp, esp, vstack, stack, sstack, + combineState: NO_ACTION[1] + }); + } } else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), @@ -36917,11 +36705,17 @@ function parse(input, parseParams) { yyrulelen = error_rule_depth; - if (yydebug) yydebug('Error recovery process: performAction: COMBINE: ', { - yyval, yytext, sp, pop_size: yyrulelen, vstack, stack, sstack, - combineState: NO_ACTION[1] - }); - r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, NO_ACTION[1], sp - 1, yyrulelen, vstack, lstack, stack, sstack); + let combineState = NO_ACTION[1]; + + if (yydebug) { + yydebug('Error recovery process: performAction: COMBINE: ', { + yyval, yytext, sp, + pop_size: yyrulelen, + vstack, stack, sstack, + combineState + }); + } + r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, combineState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof r !== 'undefined') { retval = r; @@ -36932,7 +36726,7 @@ function parse(input, parseParams) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -36959,7 +36753,7 @@ function parse(input, parseParams) { // allow N (default: 3) real symbols to be shifted before reporting a new error recovering = ERROR_RECOVERY_TOKEN_DISCARD_COUNT; - if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth: error_rule_depth, symbol: symbol, preErrorSymbol: preErrorSymbol }); + if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth, symbol, preErrorSymbol }); // Now duplicate the standard parse machine here, at least its initial // couple of rounds until the TERROR symbol is **pushed onto the parse stack**, @@ -36985,10 +36779,10 @@ function parse(input, parseParams) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -37016,14 +36810,20 @@ function parse(input, parseParams) { newState = t[1]; action = t[0]; - if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('after FETCH/LEX: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol], + state, newState, recovering, action + }); + } // encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { if (yydebug) yydebug('**NESTED ERROR DETECTED** while still recovering from previous error'); - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the \`continue;\` @@ -37037,15 +36837,26 @@ function parse(input, parseParams) { } } - if (yydebug) yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) { - "use strict"; - - if (!nt || !nt.states || !nt.rules) - return ''; - var rulename = nt.states[state]; - var rulespec = nt.rules[rulename][state]; - return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; - })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' + + (action === 1 ? + 'shift token ' + symbol + ' (then go to state ' + newState + ')' : + action === 2 ? + 'reduce by rule: ' + newState + (function __print_rule(nt, state) { + if (!nt || !nt.states || !nt.rules) { + return ''; + } + let rulename = nt.states[state]; + let rulespec = nt.rules[rulename][state]; + return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; + })(this.nonterminals_, newState) : + action === 3 ? + 'accept' : + '???unexpected???' + ), { + action, newState, recovering, symbol + }); + } switch (action) { // catch misc. parse failures: @@ -37069,12 +36880,12 @@ function parse(input, parseParams) { // Push a special value onto the stack when we're // shifting the \`error\` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -37083,7 +36894,7 @@ function parse(input, parseParams) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -37112,14 +36923,14 @@ function parse(input, parseParams) { if (recovering > 0) { recovering--; - if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering, symbol }); } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; - if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering, symbol }); // read action for current state and first input t = (table[newState] && table[newState][symbol]) || NO_ACTION; if (!t[0] || symbol === TERROR) { @@ -37131,7 +36942,7 @@ function parse(input, parseParams) { // recovery, for then this we would we idling (cycling) on the error forever. // Yes, this does not take into account the possibility that the *lexer* may have // produced a *new* TERROR token all by itself, but that would be a very peculiar grammar! - if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering, symbol }); symbol = 0; } } @@ -37147,7 +36958,7 @@ function parse(input, parseParams) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -37158,21 +36969,26 @@ function parse(input, parseParams) { this_production = this.productions_[newState - 1]; // \`this.productions_[]\` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; - if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('~~~ REDUCE: ', { + pop_size: yyrulelen, + newState, recovering, symbol + }); + } r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -37206,15 +37022,17 @@ function parse(input, parseParams) { sp -= yyrulelen; // don't overwrite the \`symbol\` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; - if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol }); + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol }); + } continue; // accept: @@ -37266,7 +37084,7 @@ function parse(input, parseParams) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the \`switch/default\` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -37276,9 +37094,9 @@ function parse(input, parseParams) { // handle parse error if (!action) { - var errStr; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let errStr; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); // Report error errStr = 'Parse error'; @@ -37309,15 +37127,26 @@ function parse(input, parseParams) { } - if (yydebug) yydebug('::: MAIN CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) { - "use strict"; - - if (!nt || !nt.states || !nt.rules) - return ''; - var rulename = nt.states[state]; - var rulespec = nt.rules[rulename][state]; - return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; - })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('::: MAIN CYCLE action: ' + + (action === 1 ? + 'shift token ' + symbol + ' (then go to state ' + newState + ')' : + action === 2 ? + 'reduce by rule: ' + newState + (function __print_rule(nt, state) { + if (!nt || !nt.states || !nt.rules) { + return ''; + } + let rulename = nt.states[state]; + let rulespec = nt.rules[rulename][state]; + return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; + })(this.nonterminals_, newState) : + action === 3 ? + 'accept' : + '???unexpected???' + ), { + action, newState, recovering, symbol + }); + } switch (action) { // catch misc. parse failures: @@ -37348,7 +37177,7 @@ function parse(input, parseParams) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -37365,8 +37194,8 @@ function parse(input, parseParams) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyleng = lexer.yyleng; @@ -37377,27 +37206,32 @@ function parse(input, parseParams) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // \`this.productions_[]\` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; - if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('~~~ REDUCE: ', { + pop_size: yyrulelen, + newState, recovering, symbol + }); + } r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -37428,15 +37262,17 @@ function parse(input, parseParams) { sp -= yyrulelen; // don't overwrite the \`symbol\` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; - if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol }); + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol }); + } continue; // accept: @@ -37489,8 +37325,7 @@ function parse(input, parseParams) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -37523,30 +37358,30 @@ function parse(input, parseParams) { * LR(0) Parser */ -var lr0 = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { +const lr0 = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LR(0)', afterconstructor: function lr0_afterconstructor() { this.buildTable(); } }); -var LR0Generator = Jison$1.LR0Generator = lr0.construct(); +const LR0Generator = Jison$1.LR0Generator = lr0.construct(); /* * Simple LALR(1) */ -var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { +const lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LALR(1)', afterconstructor: function lalr_afterconstructor() { - var self = this; + let self = this; if (this.DEBUG) { this.mix(lrGeneratorDebug, lalrGeneratorDebug); // mixin debug methods } - for (var round = 1; /* infinite loop if it weren't for the `break`s at the end */ ; round++) { + for (let round = 1; /* infinite loop if it weren't for the `break`s at the end */ ; round++) { this.states = this.canonicalCollection(); if (this.DEBUG || devDebug) { @@ -37557,13 +37392,13 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { this.terms_ = {}; - var newg = this.newg = typal.beget(lookaheadMixin, { + let newg = this.newg = typal.beget(lookaheadMixin, { oldg: this, trace: this.trace, nterms_: {}, DEBUG: false, go_: function (productionSymbol, productionHandle) { - var stateNum = productionSymbol.split(':')[0]; // grab state # + let stateNum = productionSymbol.split(':')[0]; // grab state # assert__default['default'](stateNum == +stateNum); stateNum = +stateNum; productionHandle = productionHandle.map(function (rhsElem) { @@ -37600,8 +37435,8 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { // backprop `nullable` value for each nonterminal and production back to original grammar: each(newg.nonterminals, function (newg_nt, t) { // extract original symbol: - var sym; - var a = newg_nt.symbol.split(':'); + let sym; + let a = newg_nt.symbol.split(':'); if (a.length === 1 || a[0] === '') { sym = newg_nt.symbol; } else { @@ -37676,8 +37511,8 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { go: function LALR_go(stateNum, productionHandle, productionSymbol) { assert__default['default'](typeof stateNum === 'number'); - var endStateNum = stateNum; - for (var i = 0; i < productionHandle.length; i++) { + let endStateNum = stateNum; + for (let i = 0; i < productionHandle.length; i++) { endStateNum = this.states.item(endStateNum).edges[productionHandle[i]] || endStateNum; } return endStateNum; @@ -37685,10 +37520,10 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { goPath: function LALR_goPath(stateNum, productionHandle, productionSymbol) { assert__default['default'](typeof stateNum === 'number'); - var endStateNum = stateNum, - t, - path = []; - for (var i = 0; i < productionHandle.length; i++) { + let endStateNum = stateNum, + t, + path = []; + for (let i = 0; i < productionHandle.length; i++) { t = productionHandle[i] ? endStateNum + ':' + productionHandle[i] /* + ':' + productionSymbol */ : ''; if (t) { this.newg.nterms_[t] = endStateNum; @@ -37706,34 +37541,34 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { // every disjoint reduction of a nonterminal becomes a production in G' buildNewGrammar: function LALR_buildNewGrammar() { - var self = this, - newg = this.newg; + let self = this, + newg = this.newg; this.states.forEach(function (state, i) { i = +i; state.forEach(function LALR_buildNewHandle(item) { if (item.dotPosition === 0) { // new symbols are a combination of state and transition symbol - var symbol = i + ':' + item.production.symbol; + let symbol = i + ':' + item.production.symbol; assert__default['default'](typeof self.terms_[symbol] === 'undefined' || self.terms_[symbol] === item.production.symbol); self.terms_[symbol] = item.production.symbol; newg.nterms_[symbol] = i; if (!newg.nonterminals[symbol]) { newg.nonterminals[symbol] = new Nonterminal(symbol); } - var pathInfo = self.goPath(i, item.production.handle, item.production.symbol); - var p = new Production(symbol, pathInfo.path, newg.productions.length); + let pathInfo = self.goPath(i, item.production.handle, item.production.symbol); + let p = new Production(symbol, pathInfo.path, newg.productions.length); newg.productions.push(p); newg.nonterminals[symbol].productions.push(p); // store the transition that gets 'backed up to' after reduction on path - var handle = item.production.handle.join(' '); + let handle = item.production.handle.join(' '); if (self.conflict_fixing_round && self.conflict_states_LU[i]) ; if (self.conflict_fixing_round && self.conflict_productions_LU[item.production.id]) { handle += ':P' + item.production.id; } - var goes = self.states.item(pathInfo.endState).goes; + let goes = self.states.item(pathInfo.endState).goes; if (!goes[handle]) { goes[handle] = []; } @@ -37747,22 +37582,22 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { }, unionLookaheads: function LALR_unionLookaheads() { - var self = this, - newg = this.newg; - // var states = !!this.onDemandLookahead ? this.inadequateStates : this.states; + let self = this, + newg = this.newg; + // let states = !!this.onDemandLookahead ? this.inadequateStates : this.states; - var these_states = this.states; + let these_states = this.states; these_states.forEach(function union_states_forEach(state, i) { i = +i; //assert(state.inadequate ? these_states.inadequate : true); - var treat_me = (self.onDemandLookahead ? these_states.inadequate || state.inadequate : true); + let treat_me = (self.onDemandLookahead ? these_states.inadequate || state.inadequate : true); if (state.reductions.length && treat_me) { state.reductions.forEach(function union_reduction_forEach(item) { - var follows = {}; - for (var k = 0; k < item.follows.length; k++) { + let follows = {}; + for (let k = 0; k < item.follows.length; k++) { follows[item.follows[k]] = true; } - var handle = item.production.handle.join(' '); + let handle = item.production.handle.join(' '); if (self.conflict_fixing_round && self.conflict_states_LU[i]) ; if (self.conflict_fixing_round && self.conflict_productions_LU[item.production.id]) { handle += ':P' + item.production.id; @@ -37773,7 +37608,7 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { state.goes[handle].forEach(function reduction_goes_forEach(symbol) { newg.nonterminals[symbol].follows.forEach(function goes_follows_forEach(symbol) { - var terminal = self.terms_[symbol]; + let terminal = self.terms_[symbol]; if (!follows[terminal]) { follows[terminal] = true; @@ -37787,11 +37622,11 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { } }); -var LALRGenerator = Jison$1.LALRGenerator = lalr.construct(); +const LALRGenerator = Jison$1.LALRGenerator = lalr.construct(); // LALR generator debug mixin -var lalrGeneratorDebug = { +const lalrGeneratorDebug = { beforebuildNewGrammar: function () { this.trace(this.states.size() + ' states.'); this.trace('Building lookahead grammar.'); @@ -37808,7 +37643,7 @@ var lalrGeneratorDebug = { aftercomputeLookaheads: function () { traceStates(this.trace, this.states, 'after LALR::computeLookaheads()'); }, - aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */ ) { + aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */) { traceStates(this.trace, states, 'as produced by LALR::canonicalCollection()'); } }; @@ -37818,7 +37653,7 @@ var lalrGeneratorDebug = { * * Define base type */ -var lrLookaheadGenerator = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { +const lrLookaheadGenerator = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { afterconstructor: function lr_aftercontructor() { this.computeLookaheads(); @@ -37835,7 +37670,7 @@ var lrLookaheadGenerator = generator.beget(lookaheadMixin, generatorMixin, lrGen /* * SLR Parser */ -var SLRGenerator = Jison$1.SLRGenerator = lrLookaheadGenerator.construct({ +const SLRGenerator = Jison$1.SLRGenerator = lrLookaheadGenerator.construct({ type: 'SLR(1)', lookAheads: function SLR_lookAhead(state, item) { @@ -37847,7 +37682,7 @@ var SLRGenerator = Jison$1.SLRGenerator = lrLookaheadGenerator.construct({ /* * LR(1) Parser */ -var lr1 = lrLookaheadGenerator.beget({ +const lr1 = lrLookaheadGenerator.beget({ type: 'Canonical LR(1)', lookAheads: function LR_lookAheads(state, item) { @@ -37864,28 +37699,26 @@ var lr1 = lrLookaheadGenerator.beget({ }), closureOperation: function LR_ClosureOperation(itemSet) { - var closureSet = new this.ItemSet(); - var self = this; + let closureSet = new this.ItemSet(); + let self = this; - var set = itemSet, - itemQueue; + let set = itemSet; do { - itemQueue = new Set(); + let itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function LR_AddItemToClosureSets(item) { - var symbol = item.markedSymbol; - var b, r; + let symbol = item.markedSymbol; // if token is a nonterminal, recursively add closures if (symbol && self.nonterminals[symbol]) { - r = item.remainingHandle(); - b = self.first(r); + let r = item.remainingHandle(); + let b = self.first(r); if (b.length === 0 || item.production.nullable || self.nullable(r)) { b = b.concat(item.follows); } self.nonterminals[symbol].productions.forEach(function (production) { - var newItem = new self.Item(production, 0, b); + let newItem = new self.Item(production, 0, b); if (!closureSet.contains(newItem) && !itemQueue.contains(newItem)) { itemQueue.push(newItem); } @@ -37897,18 +37730,18 @@ var lr1 = lrLookaheadGenerator.beget({ }); set = itemQueue; - } while (!itemQueue.isEmpty()); + } while (!set.isEmpty()); return closureSet; } }); -var LR1Generator = Jison$1.LR1Generator = lr1.construct(); +const LR1Generator = Jison$1.LR1Generator = lr1.construct(); /* * LL Parser */ -var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { +const ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LL(1)', afterconstructor: function ll_aftercontructor() { @@ -37931,13 +37764,13 @@ var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { }, parseTable: function ll_ParseTable(productions) { - var table = {}, - symbols_ = this.symbols_, - self = this; + let table = {}; + let symbols_ = this.symbols_; + let self = this; productions.forEach(function (production, i) { - var row = table[production.symbol] || {}; - var tokens = production.first; + let row = table[production.symbol] || {}; + let tokens = production.first; if (self.nullable(production.handle)) { tokens = union(tokens, self.nonterminals[production.symbol].follows); } @@ -37946,7 +37779,7 @@ var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { row[token].push(i); self.conflicts++; } else { - row[token] = [i]; + row[token] = [ i ]; } }); table[production.symbol] = row; @@ -37957,16 +37790,16 @@ var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { } }); -var LLGenerator = Jison$1.LLGenerator = ll.construct(); +const LLGenerator = Jison$1.LLGenerator = ll.construct(); Jison$1.Generator = function Jison_Generator(grammar, optionalLexerSection, options) { // pick the correct argument for the `options` for this call: if (!options && optionalLexerSection && typeof optionalLexerSection !== 'string') { - options = optionalLexerSection; - optionalLexerSection = null; + options = optionalLexerSection; + optionalLexerSection = null; } // and standardize it: - var preliminary_options = mkStdOptions$1(options); + let preliminary_options = mkStdOptions$1(options); // Provisionally parse the grammar, really only to obtain the *options.type* // specified within the grammar, if specified (via `%parser-type`). @@ -37988,7 +37821,7 @@ Jison$1.Generator = function Jison_Generator(grammar, optionalLexerSection, opti // // Anyway, API/CLI options **override** options coming in from the grammar spec. // - options = mkStdOptions$1("NODEFAULT", grammar.options, options); + options = mkStdOptions$1('NODEFAULT', grammar.options, options); switch (options.type || Jison$1.defaultJisonOptions.type) { case 'lr0': options.hasPartialLrUpgradeOnConflict = false; // kill this unsupported option @@ -38014,14 +37847,28 @@ Jison$1.Generator = function Jison_Generator(grammar, optionalLexerSection, opti }; function Parser$3(g, l, options) { - var gen = Jison$1.Generator(g, l, options); + let gen = Jison$1.Generator(g, l, options); return gen.createParser(); } Jison$1.Parser = Parser$3; -var rmCommonWS$6 = helpers.rmCommonWS; -var mkIdentifier$5 = helpers.mkIdentifier; +// exports for unit/system testing purposes: +Jison$1.TestExports = { + lookaheadMixin, generatorMixin, lrGeneratorMixin, + lalr, + lr0, + lr1, + ll, + parser: parser$4, + pickErrorHandlingChunk, + addOrRemoveTokenStack, + removeUnusedKernelFeatures, + expandParseArguments +}; + +const rmCommonWS$6 = helpers.rmCommonWS; +const mkIdentifier$5 = helpers.mkIdentifier; assert__default['default'](Jison$1); @@ -38031,13 +37878,12 @@ assert__default['default'](typeof Jison$1.mkStdOptions === 'function'); assert__default['default'](typeof Jison$1.Generator === 'function'); -var version$3 = '0.6.2-220'; // require('./package.json').version; +const version$3 = '0.7.0-220'; // require('./package.json').version; function getCommandlineOptions() { - - var defaults = Jison$1.defaultJisonOptions; - var opts = nomnom__default['default'] + const defaults = Jison$1.defaultJisonOptions; + let opts = nomnom__default['default'] .script('jison') .unknownOptionTreatment(false) // do not accept unknown options! .produceExplicitOptionsOnly(true) @@ -38093,7 +37939,7 @@ function getCommandlineOptions() { abbr: 'm', default: defaults.moduleType, metavar: 'TYPE', - choices: ['commonjs', 'cjs', 'amd', 'umd', 'js', 'iife', 'es'], + choices: [ 'commonjs', 'cjs', 'amd', 'umd', 'js', 'iife', 'es' ], help: 'The type of module to generate.' }, moduleName: { @@ -38115,7 +37961,7 @@ function getCommandlineOptions() { abbr: 'c', flag: false, default: defaults.compressTables, // 0, 1, 2 - choices: [0, 1, 2], + choices: [ 0, 1, 2 ], help: 'Output compressed parser tables in generated modules. (0 = no compression, 1 = default compression, 2 = deep compression)' }, outputDebugTables: { @@ -38145,7 +37991,7 @@ function getCommandlineOptions() { // FAIL when found: return this.help; }, - help: 'OBSOLETED. Use \'--default-action=[for-value,for-location]\' instead. (See below in \'--help\' output.)' + help: "OBSOLETED. Use '--default-action=[for-value,for-location]' instead. (See below in '--help' output.)" }, defaultActionMode: { full: 'default-action', @@ -38153,21 +37999,21 @@ function getCommandlineOptions() { default: defaults.defaultActionMode, callback: function (val) { // split value at comma, expect zero, one or two values: - var v = ('' + val).split(','); + let v = ('' + val).split(','); if (v.length > 2) { return 'default-action=yyval,yylloc expects at most 2 modes! You specified ' + v.length; } }, transform: function (val) { // split value at comma, expect zero, one or two values: - var option = this; - var def = option.default; - var v = ('' + val).split(',').map(function cvt_modes(mode, idx) { + let option = this; + let def = option.default; + let v = ('' + val).split(',').map(function cvt_modes(mode, idx) { mode = mode.trim(); switch (mode) { case 'false': case '0': - return "none"; + return 'none'; case 'true': case '1': @@ -38193,7 +38039,7 @@ function getCommandlineOptions() { - classic : generate a parser which includes the default $$ = $1; action for every rule. - - 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 dentical to "classic" mode. + - 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. - 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;" - 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! @@ -38209,7 +38055,7 @@ function getCommandlineOptions() { --default-action=ast equals: --default-action=ast,ast - - when you do not specify an explicit default mode or only a "true"/"1" value, the default is assumed: "${defaults.defaultActionMode.join(",")}". + - when you do not specify an explicit default mode or only a "true"/"1" value, the default is assumed: "${defaults.defaultActionMode.join(',')}". - when you specify "false"/"0" as an explicit default mode, "none,none" is assumed. This produces the fastest deterministic parser. ` }, @@ -38226,11 +38072,11 @@ function getCommandlineOptions() { default: defaults.errorRecoveryTokenDiscardCount, callback: function (count) { if (count != parseInt(count)) { - return "count must be an integer"; + return 'count must be an integer'; } count = parseInt(count); if (count < 2) { - return "count must be >= 2"; + return 'count must be >= 2'; } }, transform: function (val) { @@ -38243,7 +38089,7 @@ function getCommandlineOptions() { abbr: 'E', flag: true, default: defaults.exportAllTables, - help: 'Next to producing a grammar source file, also export the symbols, terminals, grammar and parse tables to separate JSON files for further use by other tools. The files\' names will be derived from the outputFile name by appending a suffix.' + help: "Next to producing a grammar source file, also export the symbols, terminals, grammar and parse tables to separate JSON files for further use by other tools. The files' names will be derived from the outputFile name by appending a suffix." }, exportAST: { full: 'export-ast', @@ -38271,7 +38117,7 @@ function getCommandlineOptions() { flag: true, metavar: 'false|true|CFGFILE', default: defaults.prettyCfg, - help: 'Output the generated code pretty-formatted; turning this option OFF will output the generated code as-is a.k.a. \'raw\'.', + help: "Output the generated code pretty-formatted; turning this option OFF will output the generated code as-is a.k.a. 'raw'." }, main: { full: 'main', @@ -38298,7 +38144,7 @@ function getCommandlineOptions() { }).parse(); if (opts.debug) { - console.log("JISON CLI options:\n", opts); + console.log('JISON CLI options:\n', opts); } return opts; @@ -38325,7 +38171,7 @@ function cliMain(opts) { return true; } catch (e) { if (e.code === 'ENOENT') { - var parent = path__default['default'].dirname(fp); + let parent = path__default['default'].dirname(fp); // Did we hit the root directory by now? If so, abort! // Else, create the parent; iff that fails, we fail too... if (parent !== fp && mkdirp(parent)) { @@ -38344,20 +38190,20 @@ function cliMain(opts) { function processInputFile() { // getting raw files - var lex; - var original_cwd = process__default['default'].cwd(); + let lex; + const original_cwd = process__default['default'].cwd(); if (opts.lexfile) { lex = fs__default['default'].readFileSync(path__default['default'].normalize(opts.lexfile), 'utf8'); } - var raw = fs__default['default'].readFileSync(path__default['default'].normalize(opts.file), 'utf8'); + let raw = fs__default['default'].readFileSync(path__default['default'].normalize(opts.file), 'utf8'); // making best guess at json mode opts.json = path__default['default'].extname(opts.file) === '.json' || opts.json; // When only the directory part of the output path was specified, then we // do NOT have the target module name in there as well! - var outpath = opts.outfile; + let outpath = opts.outfile; if (typeof outpath === 'string') { if (/[\\\/]$/.test(outpath) || isDirectory(outpath)) { opts.outfile = null; @@ -38376,7 +38222,7 @@ function cliMain(opts) { // setting output file name and module name based on input file name // if they aren't specified. - var name = path__default['default'].basename(opts.outfile || opts.file); + let name = path__default['default'].basename(opts.outfile || opts.file); // get the base name (i.e. the file name without extension) // i.e. strip off only the extension and keep any other dots in the filename @@ -38433,10 +38279,10 @@ function cliMain(opts) { // Change CWD to the directory where the source grammar resides: this helps us properly // %include any files mentioned in the grammar with relative paths: - var new_cwd = path__default['default'].dirname(path__default['default'].normalize(opts.file)); + let new_cwd = path__default['default'].dirname(path__default['default'].normalize(opts.file)); process__default['default'].chdir(new_cwd); - var parser = cli.generateParserString(raw, lex, opts); + let parser = cli.generateParserString(raw, lex, opts); // and change back to the CWD we started out with: process__default['default'].chdir(original_cwd); @@ -38449,11 +38295,11 @@ function cliMain(opts) { if (opts.exportAllTables.enabled) { // Determine the output file path 'template' for use by the exportAllTables // functionality: - var out_base_fname = path__default['default'].join(path__default['default'].dirname(opts.outfile), path__default['default'].basename(opts.outfile, path__default['default'].extname(opts.outfile))); + let out_base_fname = path__default['default'].join(path__default['default'].dirname(opts.outfile), path__default['default'].basename(opts.outfile, path__default['default'].extname(opts.outfile))); - var t = opts.exportAllTables; + let t = opts.exportAllTables; - for (var id in t) { + for (let id in t) { if (t.hasOwnProperty(id) && id !== 'enabled') { var content = t[id]; if (content) { @@ -38494,8 +38340,8 @@ function cliMain(opts) { } function readin(cb) { - var stdin = process__default['default'].openStdin(), - data = ''; + let stdin = process__default['default'].openStdin(), + data = ''; stdin.setEncoding('utf8'); stdin.addListener('data', function (chunk) { @@ -38523,10 +38369,11 @@ function cliMain(opts) { function generateParserString(grammar, optionalLexSection, opts) { + // var settings = Jison.mkStdOptions(opts); - var generator = new Jison$1.Generator(grammar, optionalLexSection, opts); - var srcCode = generator.generate(opts); + let generator = new Jison$1.Generator(grammar, optionalLexSection, opts); + let srcCode = generator.generate(opts); generator.reportGrammarInformation(); // as `opts` is cloned inside `generator.generate()`, we need to fetch @@ -38545,7 +38392,7 @@ var cli = { if (require.main === module) { - var opts = getCommandlineOptions(); + let opts = getCommandlineOptions(); cli.main(opts); } diff --git a/dist/cli-es6.js b/dist/cli-es6.js index 7bedce539..e0acc5238 100644 --- a/dist/cli-es6.js +++ b/dist/cli-es6.js @@ -4,6 +4,7 @@ import fs from 'fs'; import path$1 from 'path'; import JSON5 from '@gerhobbelt/json5'; +import mkdirp from 'mkdirp'; import XRegExp from '@gerhobbelt/xregexp'; import recast from 'recast'; import { transformSync } from '@babel/core'; @@ -12,7 +13,7 @@ import astUtils from 'ast-util'; import process$1 from 'process'; import nomnom from '@gerhobbelt/nomnom'; -// Return TRUE if `src` starts with `searchString`. +// Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -35,19 +36,19 @@ function rmCommonWS(strings, ...values) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -66,19 +67,21 @@ function rmCommonWS(strings, ...values) { // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -87,16 +90,19 @@ function rmCommonWS(strings, ...values) { } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -107,27 +113,79 @@ function camelCase(s) { return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } +// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; +})([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' +]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -145,6 +203,11 @@ function mkIdentifier(s) { .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -153,13 +216,13 @@ function mkIdentifier(s) { function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -170,23 +233,17 @@ function scanRegExp(s) { break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -209,34 +266,33 @@ function isLineTerminator(cp) { /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote$1(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -259,28 +315,76 @@ function chkBugger(src) { // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } +function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; +} + + +function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); +} + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path$1.dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path$1.basename(options.inputFilename || options.moduleName || (options.outfile ? path$1.dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path$1.dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path$1.basename(options.inputFilename || options.moduleName || (options.outfile ? path$1.dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -291,27 +395,37 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path$1.normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path$1.normalize(path$1.join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5.stringify(dump, null, 2); + let d = JSON5.stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp(path$1.dirname(dumpfile)); fs.writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -321,7 +435,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -329,7 +443,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -355,27 +469,43 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; } - const debug = 0; + const debug = options.debug || 0; - var p; + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); + } + + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -388,9 +518,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -412,22 +543,22 @@ assert$1(recast); // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; -// Determine which Unicode NonAsciiIdentifierStart characters +// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -435,40 +566,40 @@ const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -476,30 +607,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -510,59 +641,59 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -604,38 +735,38 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -647,18 +778,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -669,56 +800,56 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -726,97 +857,97 @@ function generateMapper4JisonGrammarIdentifiers(input) { typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp(`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp(`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp(`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp(`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp(`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp(`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp(`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp(`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp(`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp(`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp(`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -824,7 +955,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -837,7 +968,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -850,7 +981,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -863,7 +994,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -882,37 +1013,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -944,7 +1075,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -961,37 +1092,37 @@ function parseCodeChunkToAST(src, options) { .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast.parse(src); + const ast = recast.parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return transformSync(src, options); // => { code, map, ast } @@ -999,8 +1130,8 @@ function compileCodeToES5(src, options) { function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1009,7 +1140,7 @@ function prettyPrintAST(ast, options) { // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1032,25 +1163,25 @@ function prettyPrintAST(ast, options) { // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1061,9 +1192,9 @@ function checkActionBlock(src, yylloc, options) { // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1071,7 +1202,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1080,14 +1211,14 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1141,7 +1272,7 @@ var parse2AST = { trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1155,7 +1286,7 @@ function chkBugger$1(src) { /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1167,24 +1298,24 @@ const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?: /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1201,8 +1332,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1213,14 +1344,14 @@ function printFunctionSourceCodeContainer(f) { action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1231,17 +1362,17 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; -// -// -// +// +// +// function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1267,7 +1398,7 @@ function detectIstanbulGlobal() { // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1315,7 +1446,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1378,13 +1509,13 @@ var reHelpers = { getRegExpInfo: getRegExpInfo }; -var cycleref = []; -var cyclerefpath = []; +let cycleref = []; +let cyclerefpath = []; -var linkref = []; -var linkrefpath = []; +let linkref = []; +let linkrefpath = []; -var path = []; +let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1392,14 +1523,14 @@ function shallow_copy(src) { return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1412,11 +1543,11 @@ function shallow_copy(src) { function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1429,9 +1560,9 @@ function shallow_copy_and_strip_depth(src, parentKey) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1446,16 +1577,52 @@ function shallow_copy_and_strip_depth(src, parentKey) { } +// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } +// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; +} + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1470,7 +1637,7 @@ function trim_array_tail(arr) { function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1496,10 +1663,10 @@ function treat_value_stack(v) { } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1597,7 +1764,7 @@ function treat_hash(h) { function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1614,7 +1781,7 @@ function treat_error_report_info(e) { path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1642,7 +1809,7 @@ function treat_error_report_info(e) { function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1658,7 +1825,7 @@ function treat_object(e) { linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1670,14 +1837,14 @@ function treat_object(e) { // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1687,7 +1854,7 @@ function trimErrorForTestReporting(e) { cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1701,12 +1868,14 @@ var helpers = { dquote: dquote$1, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1721,7 +1890,7 @@ var helpers = { printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; /* @@ -1731,23 +1900,23 @@ var helpers = { * By Zachary Carter * MIT Licensed */ -var mkIdentifier$1 = helpers.mkIdentifier; +let mkIdentifier$1 = helpers.mkIdentifier; -var create = Object.create || function (o) { - function F(){} - F.prototype = o; - return new F(); +let create = Object.create || function (o) { + function F() {} + F.prototype = o; + return new F(); }; -var position = /^(before|after)/; +let position = /^(before|after)/; // basic method layering // always returns original method's return value function layerMethod(pos, key, prop, fun) { if (pos === 'after') { return function () { - var ret = prop.apply(this, arguments); - var args = [].slice.call(arguments); + let ret = prop.apply(this, arguments); + let args = [].slice.call(arguments); args.splice(0, 0, ret); fun.apply(this, args); return ret; @@ -1755,7 +1924,7 @@ function layerMethod(pos, key, prop, fun) { } else if (pos === 'before') { return function () { fun.apply(this, arguments); - var ret = prop.apply(this, arguments); + let ret = prop.apply(this, arguments); return ret; }; } @@ -1766,7 +1935,7 @@ function layerMethod(pos, key, prop, fun) { // overwriting them or layering them. i.e. an object method 'meth' is // layered by mixin methods 'beforemeth' or 'aftermeth' function typal_mix() { - var i, o, k; + let i, o, k; for (i = 0; i < arguments.length; i++) { o = arguments[i]; if (!o) continue; @@ -1778,8 +1947,8 @@ function typal_mix() { } for (k in o) { if (Object.prototype.hasOwnProperty.call(o, k)) { - var match = k.match(position); - var key = k.replace(position, ''); + let match = k.match(position); + let key = k.replace(position, ''); if (match && typeof this[key] === 'function') { this[key] = layerMethod(match[0], key, this[key], o[k]); } else { @@ -1793,15 +1962,15 @@ function typal_mix() { // Same as typal_mix but also camelCases every object member and 'standardizes' the key set of every input // argument through a caLLback function. -// +// // This is useful for processing options with dashes in their key, e.g. `token-stack` --> tokenStack. function typal_camel_mix(cb) { - var i, o, k; + let i, o, k; // Convert first character to lowercase function lcase0(s) { - return s.replace(/^\w/, function (match) { - return match.toLowerCase(); + return s.replace(/^\w/, function (match) { + return match.toLowerCase(); }); } @@ -1819,16 +1988,15 @@ function typal_camel_mix(cb) { } for (k in o) { if (Object.prototype.hasOwnProperty.call(o, k)) { - var nk = mkIdentifier$1(k); - var match = k.match(position); - var key = k.replace(position, ''); + let nk = mkIdentifier$1(k); + let match = k.match(position); + let key = k.replace(position, ''); // This anticipates before/after members to be camelcased already, e.g. - // 'afterParse()' for layering 'parse()': - var alt_key = lcase0(key); + // 'afterParse()' for layering 'parse()': + let alt_key = lcase0(key); if (match && typeof this[key] === 'function') { this[key] = layerMethod(match[0], key, this[key], o[k]); - } - else if (match && typeof this[alt_key] === 'function') { + } else if (match && typeof this[alt_key] === 'function') { this[alt_key] = layerMethod(match[0], alt_key, this[alt_key], o[k]); } else { this[nk] = o[k]; @@ -1839,7 +2007,7 @@ function typal_camel_mix(cb) { return this; } -var typal = { +let typal = { // extend object with own properties of each argument mix: typal_mix, @@ -1854,9 +2022,9 @@ var typal = { // Creates a new Class function based on an object with a constructor method construct: function typal_construct() { - var o = typal_mix.apply(create(this), arguments); - var constructor = o.constructor; - var Klass = o.constructor = function () { return constructor.apply(this, arguments); }; + let o = typal_mix.apply(create(this), arguments); + let constructor = o.constructor; + let Klass = o.constructor = function () { return constructor.apply(this, arguments); }; Klass.prototype = o; Klass.mix = typal_mix; // allow for easy singleton property extension return Klass; @@ -1868,13 +2036,12 @@ var typal = { // Set class to wrap arrays -var setMixin = { +let setMixin = { constructor: function Set_constructor(set, raw) { this._items = []; if (set && set.constructor === Array) { - this._items = raw ? set: set.slice(0); - } - else if (arguments.length) { + this._items = raw ? set : set.slice(0); + } else if (arguments.length) { this._items = [].slice.call(arguments, 0); } }, @@ -1887,7 +2054,7 @@ var setMixin = { }, indexOf: function indexOf(item) { if (item && item.eq) { - for (var k = 0; k < this._items.length; k++) { + for (let k = 0; k < this._items.length; k++) { if (item.eq(this._items[k])) { return k; } @@ -1902,14 +2069,14 @@ var setMixin = { }); }, complement: function complement(set) { - var that = this; + let that = this; return set.filter(function sub_complement(elm) { return !that.contains(elm); }); }, subset: function subset(set) { - var cont = true; - for (var i = 0; i < this._items.length && cont; i++) { + let cont = true; + for (let i = 0; i < this._items.length && cont; i++) { cont = cont && set.contains(this._items[i]); } return cont; @@ -1920,60 +2087,59 @@ var setMixin = { joinSet: function joinSet(set) { return this.concat(this.complement(set)); }, - contains: function contains(item) { - return this.indexOf(item) !== -1; + contains: function contains(item) { + return this.indexOf(item) !== -1; }, - item: function item(v) { - return this._items[v]; + item: function item(v) { + return this._items[v]; }, - i: function i(v) { - return this._items[v]; + i: function i(v) { + return this._items[v]; }, - assign: function assign(index, value) { + assign: function assign(index, value) { this._items[index] = value; - return this; + return this; }, - first: function first() { - return this._items[0]; + first: function first() { + return this._items[0]; }, - last: function last() { - return this._items[this._items.length - 1]; + last: function last() { + return this._items[this._items.length - 1]; }, - size: function size() { - return this._items.length; + size: function size() { + return this._items.length; }, - isEmpty: function isEmpty() { - return this._items.length === 0; + isEmpty: function isEmpty() { + return this._items.length === 0; }, - copy: function copy() { - return new Set(this._items); + copy: function copy() { + return new Set$1(this._items); }, - toString: function toString() { - return this._items.toString(); + toString: function toString() { + return this._items.toString(); } }; 'push shift unshift forEach some every join sort'.split(' ').forEach(function (e, i) { - setMixin[e] = function () { - return Array.prototype[e].apply(this._items, arguments); + setMixin[e] = function () { + return Array.prototype[e].apply(this._items, arguments); }; //setMixin[e].name = e; }); 'filter slice map'.split(' ').forEach(function (e, i) { - setMixin[e] = function () { - return new Set(Array.prototype[e].apply(this._items, arguments), true); + setMixin[e] = function () { + return new Set$1(Array.prototype[e].apply(this._items, arguments), true); }; //setMixin[e].name = e; }); -var Set = typal.construct(setMixin); +var Set$1 = typal.construct(setMixin); // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1990,9 +2156,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -2025,10 +2191,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -2041,11 +2207,11 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -2055,18 +2221,18 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -2097,7 +2263,7 @@ JisonParserError.prototype.name = 'JisonParserError'; // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -2114,9 +2280,9 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -2129,7 +2295,7 @@ JisonParserError.prototype.name = 'JisonParserError'; } -var parser = { +let parser = { // Code Generator Information Report // --------------------------------- // @@ -2379,7 +2545,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2387,7 +2552,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2399,8 +2563,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2413,14 +2577,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2436,10 +2599,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2447,10 +2610,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2605,9 +2768,9 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -2619,18 +2782,18 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2660,9 +2823,9 @@ case 1: case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -2675,10 +2838,10 @@ case 2: case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2705,9 +2868,9 @@ case 3: case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -2716,10 +2879,10 @@ case 4: case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2747,9 +2910,9 @@ case 5: case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -2758,10 +2921,10 @@ case 6: case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -2800,9 +2963,9 @@ case 7: case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2867,9 +3030,9 @@ case 8: case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2884,9 +3047,9 @@ case 9: case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -2921,10 +3084,10 @@ case 10: case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2941,9 +3104,9 @@ case 11: case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2960,10 +3123,10 @@ case 12: case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2980,9 +3143,9 @@ case 13: case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2999,10 +3162,10 @@ case 14: case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3019,9 +3182,9 @@ case 15: case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3045,9 +3208,9 @@ case 17: case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3058,9 +3221,9 @@ case 132: case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3080,9 +3243,9 @@ case 18: case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3106,9 +3269,9 @@ case 19: case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -3121,10 +3284,10 @@ case 20: case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3141,9 +3304,9 @@ case 21: case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -3155,9 +3318,9 @@ case 22: case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -3197,10 +3360,10 @@ case 23: case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3220,9 +3383,9 @@ case 24: case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3272,10 +3435,10 @@ case 25: case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -3299,10 +3462,10 @@ case 26: case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3322,10 +3485,10 @@ case 27: case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3349,10 +3512,10 @@ case 28: case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3373,10 +3536,10 @@ case 29: case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3388,10 +3551,10 @@ case 31: case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3401,10 +3564,10 @@ case 33: case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3414,10 +3577,10 @@ case 32: case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3427,10 +3590,10 @@ case 34: case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3440,10 +3603,10 @@ case 35: case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -3453,10 +3616,10 @@ case 36: case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3466,10 +3629,10 @@ case 37: case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3479,9 +3642,9 @@ case 38: case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -3490,9 +3653,9 @@ case 39: case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -3501,9 +3664,9 @@ case 40: case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3525,9 +3688,9 @@ case 41: case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3538,9 +3701,9 @@ case 42: case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3560,9 +3723,9 @@ case 43: case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3616,9 +3779,9 @@ case 49: case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3638,9 +3801,9 @@ case 51: case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -3649,9 +3812,9 @@ case 58: case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -3663,9 +3826,9 @@ case 52: case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -3679,10 +3842,10 @@ case 53: case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3702,10 +3865,10 @@ case 54: case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3725,10 +3888,10 @@ case 55: case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3748,9 +3911,9 @@ case 56: case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3761,9 +3924,9 @@ case 59: case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3782,9 +3945,9 @@ case 60: case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -3825,9 +3988,9 @@ case 61: case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3851,9 +4014,9 @@ case 62: case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3879,9 +4042,9 @@ case 63: case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3926,9 +4089,9 @@ case 64: case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -3954,9 +4117,9 @@ case 106: case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -3965,9 +4128,9 @@ case 127: case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -3976,10 +4139,10 @@ case 67: case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3993,10 +4156,10 @@ case 68: case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4010,10 +4173,10 @@ case 69: case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4027,10 +4190,10 @@ case 70: case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4049,9 +4212,9 @@ case 72: case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4060,9 +4223,9 @@ case 77: case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -4100,10 +4263,10 @@ case 73: case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -4127,9 +4290,9 @@ case 74: case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -4208,9 +4371,9 @@ case 110: case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -4219,9 +4382,9 @@ case 129: case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -4230,9 +4393,9 @@ case 78: case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -4241,9 +4404,9 @@ case 79: case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -4252,9 +4415,9 @@ case 80: case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -4263,9 +4426,9 @@ case 81: case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -4274,9 +4437,9 @@ case 85: case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -4287,10 +4450,10 @@ case 87: case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4307,9 +4470,9 @@ case 88: case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -4318,9 +4481,9 @@ case 89: case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -4329,9 +4492,9 @@ case 90: case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -4340,9 +4503,9 @@ case 91: case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -4351,9 +4514,9 @@ case 92: case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -4372,18 +4535,18 @@ case 107: case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -4392,9 +4555,9 @@ case 97: case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -4403,9 +4566,9 @@ case 98: case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -4414,9 +4577,9 @@ case 99: case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -4425,9 +4588,9 @@ case 102: case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -4436,10 +4599,10 @@ case 104: case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4456,9 +4619,9 @@ case 105: case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -4475,9 +4638,9 @@ case 109: case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -4489,9 +4652,9 @@ case 111: case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -4501,9 +4664,9 @@ case 112: case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4538,9 +4701,9 @@ case 113: case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4559,9 +4722,9 @@ case 114: case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -4570,9 +4733,9 @@ case 115: case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -4581,9 +4744,9 @@ case 116: case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4601,10 +4764,10 @@ case 117: case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -4622,10 +4785,10 @@ case 118: case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -4646,9 +4809,9 @@ case 119: case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4681,9 +4844,9 @@ case 120: case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4709,9 +4872,9 @@ case 121: case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5.parse(yyvstack[yysp]); @@ -4720,9 +4883,9 @@ case 122: case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue(yyvstack[yysp]); @@ -4731,9 +4894,9 @@ case 123: case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4742,9 +4905,9 @@ case 124: case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -4765,10 +4928,10 @@ case 125: case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4785,9 +4948,9 @@ case 126: case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -4806,9 +4969,9 @@ case 128: case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4832,9 +4995,9 @@ case 130: case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -4854,9 +5017,9 @@ case 131: case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4867,9 +5030,9 @@ case 133: case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -4925,10 +5088,10 @@ case 134: case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6531,7 +6694,6 @@ defaultActions: bda({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -6548,38 +6710,34 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -6587,20 +6745,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -6622,7 +6778,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -6630,18 +6785,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -6649,24 +6805,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -6704,18 +6855,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -6736,7 +6884,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -6754,7 +6902,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -6767,7 +6914,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -6781,11 +6927,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -6839,8 +6984,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6848,8 +6993,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6881,19 +7026,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -6904,7 +7048,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -6917,7 +7061,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -6929,29 +7073,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -6959,7 +7101,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -6979,8 +7121,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -6989,10 +7130,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -7000,7 +7141,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -7011,9 +7152,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -7029,8 +7175,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -7099,11 +7244,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -7114,8 +7262,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -7124,21 +7271,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -7148,21 +7294,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -7171,28 +7316,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -7205,8 +7349,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -7229,8 +7372,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -7242,8 +7384,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -7260,8 +7401,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -7275,8 +7415,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -7290,7 +7429,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -7343,16 +7482,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -7386,9 +7522,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -7411,9 +7545,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -7440,17 +7572,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -7497,8 +7628,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -7510,8 +7641,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -7529,6 +7659,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -7537,7 +7668,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -7548,7 +7679,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -7608,10 +7739,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -7646,9 +7777,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -7661,7 +7790,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -7682,9 +7811,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7706,12 +7833,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -7720,7 +7847,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7761,7 +7888,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -7808,7 +7935,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -7826,21 +7953,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7874,14 +7999,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7891,6 +8017,7 @@ parse: function parse(input) { + } continue; // accept: @@ -7942,7 +8069,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -7958,9 +8085,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7989,7 +8114,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -8006,8 +8131,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -8018,8 +8143,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -8031,21 +8156,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -8076,14 +8199,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -8093,6 +8217,7 @@ parse: function parse(input) { + } continue; // accept: @@ -8145,8 +8270,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -8407,7 +8531,6 @@ var lexer = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -8424,10 +8547,10 @@ var lexer = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -8459,7 +8582,7 @@ var lexer = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -8501,7 +8624,9 @@ var lexer = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -8587,7 +8712,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -8595,7 +8720,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -8608,7 +8733,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -8634,10 +8759,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -8660,7 +8788,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -8683,16 +8810,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -8714,7 +8841,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -8722,8 +8848,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -8752,7 +8878,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -8777,7 +8903,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -8789,17 +8915,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -8893,7 +9019,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -8914,7 +9040,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -8925,7 +9050,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -8936,15 +9061,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -8978,8 +9103,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -9012,9 +9137,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -9033,9 +9158,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -9045,8 +9170,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -9073,20 +9198,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -9126,17 +9250,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -9145,7 +9271,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -9160,8 +9286,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -9187,24 +9313,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -9215,7 +9343,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -9237,8 +9365,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -9260,8 +9388,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -9405,21 +9532,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -9434,11 +9561,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -9457,13 +9584,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -9487,13 +9614,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -9508,8 +9635,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -9540,7 +9667,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -9572,9 +9699,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -9603,7 +9730,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -9621,7 +9748,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -9646,7 +9773,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -9656,8 +9782,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -9666,7 +9790,7 @@ EOF: 1, this.clear(); } - 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. @@ -9678,13 +9802,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -9694,68 +9818,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -9780,7 +9910,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -9828,24 +9958,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9865,7 +9995,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -9875,24 +10005,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9913,8 +10043,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -9954,14 +10083,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -9977,9 +10106,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -9990,8 +10119,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -9999,7 +10128,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -11689,7 +11818,7 @@ const UNICODE_BASE_PLANE_MAX_CP = 65535; // The expanded regex sets which are equivalent to the given `\\{c}` escapes: // // `/\s/`: -const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; +const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; // `/\d/`: const DIGIT_SETSTR = '0-9'; // `/\w/`: @@ -11701,7 +11830,7 @@ const WORDCHAR_SETSTR = 'A-Za-z0-9_'; // Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex function i2c(i) { - var c, x; + let c, x; switch (i) { case 10: @@ -11741,7 +11870,7 @@ function i2c(i) { || i > 0xFFF0 /* Unicode Specials, also in UTF16 */ || (i >= 0xD800 && i <= 0xDFFF) /* Unicode Supplementary Planes; we're TOAST in JavaScript as we're NOT UTF-16 but UCS-2! */ || String.fromCharCode(i).match(/[\u2028\u2029]/) /* Code compilation via `new Function()` does not like to see these, or rather: treats them as just another form of CRLF, which breaks your generated regex code! */ - ) { + ) { // Detail about a detail: // U+2028 and U+2029 are part of the `\s` regex escape code (`\s` and `[\s]` match either of these) and when placed in a JavaScript // source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report @@ -11749,11 +11878,10 @@ function i2c(i) { // Hence we MUST escape these buggers everywhere we go... x = i.toString(16); if (x.length >= 1 && i <= 0xFFFF) { - c = '0000' + x; - return '\\u' + c.substr(c.length - 4); - } else { - return '\\u{' + x + '}'; + c = '0000' + x; + return '\\u' + c.substr(c.length - 4); } + return '\\u{' + x + '}'; } return String.fromCharCode(i); } @@ -11762,18 +11890,18 @@ function i2c(i) { // Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating // this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a // `\\p{NAME}` shorthand to represent [part of] the bitarray: -var Pcodes_bitarray_cache = {}; -var Pcodes_bitarray_cache_test_order = []; +let Pcodes_bitarray_cache = {}; +let Pcodes_bitarray_cache_test_order = []; -// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by +// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. -var EscCode_bitarray_output_refs; +let EscCode_bitarray_output_refs; // now initialize the EscCodes_... table above: init_EscCode_lookup_table(); function init_EscCode_lookup_table() { - var s, bitarr, set2esc = {}, esc2bitarr = {}; + let s, bitarr, set2esc = {}, esc2bitarr = {}; // patch global lookup tables for the time being, while we calculate their *real* content in this function: EscCode_bitarray_output_refs = { @@ -11842,13 +11970,13 @@ function init_EscCode_lookup_table() { }; updatePcodesBitarrayCacheTestOrder(); -} +} function updatePcodesBitarrayCacheTestOrder(opts) { - var t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var l = {}; - var user_has_xregexp = opts && opts.options && opts.options.xregexp; - var i, j, k, ba; + let t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let l = {}; + let user_has_xregexp = opts && opts.options && opts.options.xregexp; + let i, j, k, ba; // mark every character with which regex pcodes they are part of: for (k in Pcodes_bitarray_cache) { @@ -11858,12 +11986,12 @@ function updatePcodesBitarrayCacheTestOrder(opts) { continue; } - var cnt = 0; + let cnt = 0; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { cnt++; if (!t[i]) { - t[i] = [k]; + t[i] = [ k ]; } else { t[i].push(k); } @@ -11873,27 +12001,27 @@ function updatePcodesBitarrayCacheTestOrder(opts) { } // now dig out the unique ones: only need one per pcode. - // + // // We ASSUME every \\p{NAME} 'pcode' has at least ONE character - // in it that is ONLY matched by that particular pcode. + // in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode - // won't be tested during optimization. - // + // won't be tested during optimization. + // // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to // look for markers which match multiple escapes/pcodes for those // ones where a unique item isn't available... - var lut = []; - var done = {}; - var keys = Object.keys(Pcodes_bitarray_cache); + let lut = []; + let done = {}; + let keys = Object.keys(Pcodes_bitarray_cache); for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { k = t[i][0]; if (t[i].length === 1 && !done[k]) { assert$1(l[k] > 0); - lut.push([i, k]); + lut.push([ i, k ]); done[k] = true; } } @@ -11904,19 +12032,19 @@ function updatePcodesBitarrayCacheTestOrder(opts) { if (!user_has_xregexp && k.indexOf('\\p{') >= 0) { continue; } - + if (!done[k]) { assert$1(l[k] > 0); // find a minimum span character to mark this one: - var w = Infinity; + let w = Infinity; var rv; ba = Pcodes_bitarray_cache[k]; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { - var tl = t[i].length; + let tl = t[i].length; if (tl > 1 && tl < w) { assert$1(l[k] > 0); - rv = [i, k]; + rv = [ i, k ]; w = tl; } } @@ -11930,16 +12058,16 @@ function updatePcodesBitarrayCacheTestOrder(opts) { // order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. - // + // // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more - // optimal minification of the regex set expression. - // + // optimal minification of the regex set expression. + // // This is a guestimate/heuristic only! lut.sort(function (a, b) { - var k1 = a[1]; - var k2 = b[1]; - var ld = l[k2] - l[k1]; + let k1 = a[1]; + let k2 = b[1]; + let ld = l[k2] - l[k1]; if (ld) { return ld; } @@ -11957,19 +12085,19 @@ function updatePcodesBitarrayCacheTestOrder(opts) { // 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set. function set2bitarray(bitarr, s, opts) { - var orig = s; - var set_is_inverted = false; - var bitarr_orig; + let orig = s; + let set_is_inverted = false; + let bitarr_orig; function mark(d1, d2) { if (d2 == null) d2 = d1; - for (var i = d1; i <= d2; i++) { + for (let i = d1; i <= d2; i++) { bitarr[i] = true; } } function add2bitarray(dst, src) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (src[i]) { dst[i] = true; } @@ -11977,10 +12105,10 @@ function set2bitarray(bitarr, s, opts) { } function eval_escaped_code(s) { - var c; + let c; // decode escaped code? If none, just take the character as-is if (s.indexOf('\\') === 0) { - var l = s.substr(0, 2); + let l = s.substr(0, 2); switch (l) { case '\\c': c = s.charCodeAt(2) - 'A'.charCodeAt(0) + 1; @@ -11998,7 +12126,7 @@ function set2bitarray(bitarr, s, opts) { } c = parseInt(s, 16); if (c >= 0x10000) { - return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); + return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); } return String.fromCharCode(c); @@ -12042,7 +12170,7 @@ function set2bitarray(bitarr, s, opts) { } if (s && s.length) { - var c1, c2; + let c1, c2; // inverted set? if (s[0] === '^') { @@ -12073,13 +12201,13 @@ function set2bitarray(bitarr, s, opts) { c2 = c2[0]; s = s.substr(c2.length); // do we have this one cached already? - var pex = c1 + c2; - var ba4p = Pcodes_bitarray_cache[pex]; + let pex = c1 + c2; + let ba4p = Pcodes_bitarray_cache[pex]; if (!ba4p) { // expand escape: - var xr = new XRegExp('[' + pex + ']'); // TODO: case-insensitive grammar??? + let xr = new XRegExp('[' + pex + ']'); // TODO: case-insensitive grammar??? // rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`: - var xs = '' + xr; + let xs = '' + xr; // remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: xs = xs.substr(1, xs.length - 2); @@ -12114,7 +12242,7 @@ function set2bitarray(bitarr, s, opts) { break; } } - var v1 = eval_escaped_code(c1); + let v1 = eval_escaped_code(c1); // propagate deferred exceptions = error reports. if (v1 instanceof Error) { return v1; @@ -12132,7 +12260,7 @@ function set2bitarray(bitarr, s, opts) { } else { c2 = c2[0]; } - var v2 = eval_escaped_code(c2); + let v2 = eval_escaped_code(c2); // propagate deferred exceptions = error reports. if (v2 instanceof Error) { return v1; @@ -12155,12 +12283,12 @@ function set2bitarray(bitarr, s, opts) { } // When we have marked all slots, '^' NEGATES the set, hence we flip all slots. - // + // // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. if (set_is_inverted) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (!bitarr[i]) { bitarr_orig[i] = true; } @@ -12179,10 +12307,10 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // below can be simple and fast: l[UNICODE_BASE_PLANE_MAX_CP + 1] = 1; // now reconstruct the regex set: - var rv = []; - var i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; - var bitarr_is_cloned = false; - var l_orig = l; + let rv = []; + let i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; + let bitarr_is_cloned = false; + let l_orig = l; if (output_inverted_variant) { // generate the inverted set, hence all unmarked slots are part of the output range: @@ -12196,8 +12324,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. // BUT... since we output the INVERTED set, we output the match-all set instead: return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` // BUT... since we output the INVERTED set, we output the match-nothing set instead: @@ -12229,9 +12356,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12258,7 +12385,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } } - + i = 0; while (i <= UNICODE_BASE_PLANE_MAX_CP) { // find first character not in original set: @@ -12289,8 +12416,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. return '^\\S\\s'; } @@ -12320,9 +12446,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12374,11 +12500,11 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } assert$1(rv.length); - var s = rv.join(''); + let s = rv.join(''); assert$1(s); // Check if the set is better represented by one of the regex escapes: - var esc4s = EscCode_bitarray_output_refs.set2esc[s]; + let esc4s = EscCode_bitarray_output_refs.set2esc[s]; if (esc4s) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return '\\' + esc4s; @@ -12393,25 +12519,24 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there; // ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`. function reduceRegexToSetBitArray(s, name, opts) { - var orig = s; + let orig = s; // propagate deferred exceptions = error reports. if (s instanceof Error) { return s; } - var l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var internal_state = 0; - var derr; + let l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let internal_state = 0; + let derr; while (s.length) { - var c1 = s.match(CHR_RE); + let c1 = s.match(CHR_RE); if (!c1) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"'); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12419,15 +12544,14 @@ function reduceRegexToSetBitArray(s, name, opts) { // this is starting a set within the regex: scan until end of set! var set_content = []; while (s.length) { - var inner = s.match(SET_PART_RE); + let inner = s.match(SET_PART_RE); if (!inner) { inner = s.match(CHR_RE); if (!inner) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"'); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12441,9 +12565,8 @@ function reduceRegexToSetBitArray(s, name, opts) { if (!c2) { // cope with illegal escape sequences too! return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error('regex set expression is broken in regex: ' + orig); } @@ -12527,10 +12650,9 @@ function reduceRegexToSetBitArray(s, name, opts) { // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; assert$1(s); assert$1(!(s instanceof Error)); - re = new XRegExp('[' + s + ']'); + let re = new XRegExp('[' + s + ']'); re.test(s[0]); // One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` @@ -12555,25 +12677,24 @@ function reduceRegexToSetBitArray(s, name, opts) { -// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` +// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! function produceOptimizedRegex4Set(bitarr) { // First try to produce a minimum regex from the bitarray directly: - var s1 = bitarray2set(bitarr, false, true); + let s1 = bitarray2set(bitarr, false, true); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s1.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s1; - } else { - s1 = '[' + s1 + ']'; } + s1 = '[' + s1 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s2 = bitarray2set(bitarr, true, true); + let s2 = bitarray2set(bitarr, true, true); if (s2[0] === '^') { s2 = s2.substr(1); @@ -12588,23 +12709,22 @@ function produceOptimizedRegex4Set(bitarr) { // Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: - // + // // First try to produce a minimum regex from the bitarray directly: - var s3 = bitarray2set(bitarr, false, false); + let s3 = bitarray2set(bitarr, false, false); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s3.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s3; - } else { - s3 = '[' + s3 + ']'; } + s3 = '[' + s3 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s4 = bitarray2set(bitarr, true, false); + let s4 = bitarray2set(bitarr, true, false); if (s4[0] === '^') { s4 = s4.substr(1); @@ -12636,30 +12756,30 @@ function produceOptimizedRegex4Set(bitarr) { var setmgmt = { - XREGEXP_UNICODE_ESCAPE_RE, - CHR_RE, - SET_PART_RE, - NOTHING_SPECIAL_RE, - SET_IS_SINGLE_PCODE_RE, - - UNICODE_BASE_PLANE_MAX_CP, - - WHITESPACE_SETSTR, - DIGIT_SETSTR, - WORDCHAR_SETSTR, - - set2bitarray, - bitarray2set, - produceOptimizedRegex4Set, - reduceRegexToSetBitArray, + XREGEXP_UNICODE_ESCAPE_RE, + CHR_RE, + SET_PART_RE, + NOTHING_SPECIAL_RE, + SET_IS_SINGLE_PCODE_RE, + + UNICODE_BASE_PLANE_MAX_CP, + + WHITESPACE_SETSTR, + DIGIT_SETSTR, + WORDCHAR_SETSTR, + + set2bitarray, + bitarray2set, + produceOptimizedRegex4Set, + reduceRegexToSetBitArray }; // Basic Lexer implemented using JavaScript regular expressions -var rmCommonWS$2 = helpers.rmCommonWS; -var mkIdentifier$3 = helpers.mkIdentifier; -var code_exec$1 = helpers.exec; +const rmCommonWS$2 = helpers.rmCommonWS; +const mkIdentifier$3 = helpers.mkIdentifier; +const code_exec = helpers.exec; -var version = '0.6.2-220'; // require('./package.json').version; +const version = '0.6.2-220'; // require('./package.json').version; @@ -12720,7 +12840,7 @@ const defaultJisonLexOptions = { exportAST: false, prettyCfg: true, pre_lex: undefined, - post_lex: undefined, + post_lex: undefined }; @@ -12738,23 +12858,23 @@ const defaultJisonLexOptions = { // Return a fresh set of options. /** @public */ function mkStdOptions(/*...args*/) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - var args = [].concat.apply([], arguments); + let opts = {}; + let args = [].concat.apply([], arguments); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(defaultJisonLexOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; for (var p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { @@ -12792,7 +12912,7 @@ function mkStdOptions(/*...args*/) { function prepExportStructures(options) { // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -12813,8 +12933,8 @@ function prepExportStructures(options) { // Otherwise return the *parsed* lexer spec as it has // been processed through LexParser. function autodetectAndConvertToJSONformat(lexerSpec, options) { - var chk_l = null; - var ex1, err; + let chk_l = null; + let ex1, err; if (typeof lexerSpec === 'string') { if (options.json) { @@ -12866,9 +12986,9 @@ function autodetectAndConvertToJSONformat(lexerSpec, options) { /should be separated/, /an error in one or more of your lexer regex rules/, /an error in your lexer epilogue/, - /unsupported definition type/, + /unsupported definition type/ ]; - var cmnerr = commonErrors.filter(function check(re) { + let cmnerr = commonErrors.filter(function check(re) { return e.message.match(re); }); if (cmnerr.length > 0) { @@ -12897,14 +13017,14 @@ function autodetectAndConvertToJSONformat(lexerSpec, options) { // expand macros and convert matchers to RegExp's function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) { - var m, i, k, rule, action, conditions; - var active_conditions; + let m, i, k, rule, action, conditions; + let active_conditions; assert$1(Array.isArray(dict.rules)); - var rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! - var newRules = []; - var macros = {}; - var regular_rule_count = 0; - var simple_rule_count = 0; + let rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! + let newRules = []; + let macros = {}; + let regular_rule_count = 0; + let simple_rule_count = 0; // Assure all options are camelCased: assert$1(typeof opts.options['case-insensitive'] === 'undefined'); @@ -12914,7 +13034,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) } if (opts.options.flex && rules.length > 0) { - rules.push(['.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']); + rules.push([ '.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */' ]); } // Depending on the location within the regex we need different expansions of the macros: @@ -12938,7 +13058,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) return str; } - var routingCode = ['switch(yyrulenumber) {']; + let routingCode = [ 'switch(yyrulenumber) {' ]; for (i = 0; i < rules.length; i++) { rule = rules[i].slice(0); // shallow copy: do not modify input rules @@ -12992,7 +13112,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) action = action.replace(/return\s*\(?'((?:\\'|[^']+)+)'\)?/g, tokenNumberReplacement); action = action.replace(/return\s*\(?"((?:\\"|[^"]+)+)"\)?/g, tokenNumberReplacement); - var code = ['\n/*! Conditions::']; + let code = [ '\n/*! Conditions::' ]; code.push(postprocessComment(active_conditions)); code.push('*/', '\n/*! Rule:: '); code.push(postprocessComment(rule[0])); @@ -13013,7 +13133,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) // 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'. - var match_nr = /^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim()); + 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 ')); @@ -13040,7 +13160,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) macros: macros, regular_rule_count: regular_rule_count, - simple_rule_count: simple_rule_count, + simple_rule_count: simple_rule_count }; } @@ -13053,14 +13173,13 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) // 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. function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElsewhere_cb) { - var orig = s; + let orig = s; function errinfo() { if (name) { return 'macro [[' + name + ']]'; - } else { - return 'regex [[' + orig + ']]'; } + return 'regex [[' + orig + ']]'; } // propagate deferred exceptions = error reports. @@ -13068,19 +13187,18 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse return s; } - var c1, c2; - var rv = []; - var derr; - var se; + let c1, c2; + let rv = []; + let derr; + let se; while (s.length) { c1 = s.match(CHR_RE$1); if (!c1) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -13090,15 +13208,14 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse var l = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1); while (s.length) { - var inner = s.match(SET_PART_RE$1); + let inner = s.match(SET_PART_RE$1); if (!inner) { inner = s.match(CHR_RE$1); if (!inner) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -13112,9 +13229,8 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse if (!c2) { // cope with illegal escape sequences too! return new Error(errinfo() + ': regex set expression is broken: "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error(errinfo() + ': regex set expression is broken: apparently unterminated'); } @@ -13175,7 +13291,7 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse c2 = c2[0]; s = s.substr(c2.length); - var c3 = s[0]; + let c3 = s[0]; s = s.substr(c3.length); if (c3 === '}') { // possibly a macro name in there... Expand if possible: @@ -13228,7 +13344,7 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; + let re; re = new XRegExp(s); re.test(s[0]); } catch (ex) { @@ -13244,11 +13360,11 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse // expand macros within macros and cache the result function prepareMacros(dict_macros, opts) { - var macros = {}; + let macros = {}; // expand a `{NAME}` macro which exists inside a `[...]` set: function expandMacroInSet(i) { - var k, a, m; + let k, a, m; if (!macros[i]) { m = dict_macros[i]; @@ -13282,7 +13398,7 @@ function prepareMacros(dict_macros, opts) { a = m.split('{' + k + '}'); if (a.length > 1) { - var x = expandMacroInSet(k); + let x = expandMacroInSet(k); assert$1(x); if (x instanceof Error) { m = x; @@ -13294,9 +13410,9 @@ function prepareMacros(dict_macros, opts) { } } - var mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); + let mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); - var s1; + let s1; // propagate deferred exceptions = error reports. if (mba instanceof Error) { @@ -13330,7 +13446,7 @@ function prepareMacros(dict_macros, opts) { } function expandMacroElsewhere(i) { - var m; + let m; if (macros[i].elsewhere == null) { m = dict_macros[i]; @@ -13365,13 +13481,13 @@ function prepareMacros(dict_macros, opts) { } function expandAllMacrosInSet(s) { - var i, x; + let i, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { for (i in macros) { if (macros.hasOwnProperty(i)) { - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroInSet(i); assert$1(x); @@ -13393,7 +13509,7 @@ function prepareMacros(dict_macros, opts) { } function expandAllMacrosElsewhere(s) { - var i, x; + let i, x; // When we process the remaining macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13408,7 +13524,7 @@ function prepareMacros(dict_macros, opts) { for (i in macros) { if (macros.hasOwnProperty(i)) { // These are all submacro expansions, hence non-capturing grouping is applied: - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroElsewhere(i); assert$1(x); @@ -13430,7 +13546,7 @@ function prepareMacros(dict_macros, opts) { } - var i; + let i; if (opts.debug) console.log('\n############## RAW macros: ', dict_macros); @@ -13461,13 +13577,13 @@ function prepareMacros(dict_macros, opts) { // expand macros in a regex; expands them recursively function expandMacros(src, macros, opts) { - var expansion_count = 0; + let expansion_count = 0; // By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! // Hence things should be easy in there: function expandAllMacrosInSet(s) { - var i, m, x; + let i, m, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { @@ -13475,7 +13591,7 @@ function expandMacros(src, macros, opts) { if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = m.in_set; @@ -13506,7 +13622,7 @@ function expandMacros(src, macros, opts) { } function expandAllMacrosElsewhere(s) { - var i, m, x; + let i, m, x; // When we process the main macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13522,7 +13638,7 @@ function expandMacros(src, macros, opts) { if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { // These are all main macro expansions, hence CAPTURING grouping is applied: x = m.elsewhere; @@ -13558,7 +13674,7 @@ function expandMacros(src, macros, opts) { // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! - var s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); + let s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); // propagate deferred exceptions = error reports. if (s2 instanceof Error) { throw s2; @@ -13583,8 +13699,8 @@ function expandMacros(src, macros, opts) { } function prepareStartConditions(conditions) { - var sc; - var hash = {}; + let sc; + let hash = {}; for (sc in conditions) { if (conditions.hasOwnProperty(sc)) { @@ -13598,22 +13714,22 @@ function prepareStartConditions(conditions) { } function buildActions(dict, tokens, opts) { - var actions = [dict.actionInclude || '', 'var YYSTATE = YY_START;']; - var tok; - var toks = {}; - var caseHelper = []; + let actions = [ dict.actionInclude || '', 'var YYSTATE = YY_START;' ]; + let tok; + let toks = {}; + let caseHelper = []; // tokens: map/array of token numbers to token names for (tok in tokens) { - var idx = parseInt(tok); + let idx = parseInt(tok); if (idx && idx > 0) { toks[tokens[tok]] = idx; } } - var gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); + let gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); - var code = actions.join('\n'); + let code = actions.join('\n'); 'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function (yy) { code = code.replace(new RegExp('\\b(' + yy + ')\\b', 'g'), 'yy_.$1'); }); @@ -13631,7 +13747,7 @@ function buildActions(dict, tokens, opts) { macros: gen.macros, // propagate these for debugging/diagnostic purposes regular_rule_count: gen.regular_rule_count, - simple_rule_count: gen.simple_rule_count, + simple_rule_count: gen.simple_rule_count }; } @@ -13642,7 +13758,7 @@ function buildActions(dict, tokens, opts) { function generateErrorClass() { // --- START lexer error class --- -var prelude = `/** +const prelude = `/** * 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 @@ -13653,8 +13769,6 @@ var prelude = `/** * @nocollapse */ function JisonLexerError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -13671,9 +13785,9 @@ function JisonLexerError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -13734,8 +13848,8 @@ function generateFakeXRegExpClassSrcCode() { /** @constructor */ function RegExpLexer(dict, input, tokens, build_options) { - var opts; - var dump = false; + let opts; + let dump = false; function test_me(tweak_cb, description, src_exception, ex_callback) { opts = processGrammar(dict, tokens, build_options); @@ -13745,7 +13859,7 @@ function RegExpLexer(dict, input, tokens, build_options) { if (tweak_cb) { tweak_cb(); } - var source = generateModuleBody(opts); + let source = generateModuleBody(opts); try { // The generated code will always have the `lexer` variable declared at local scope // as `eval()` will use the local scope. @@ -13753,16 +13867,16 @@ function RegExpLexer(dict, input, tokens, build_options) { // The compiled code will look something like this: // // ``` - // var lexer; + // let lexer; // bla bla... // ``` // // or // // ``` - // var lexer = { bla... }; + // const lexer = { bla... }; // ``` - var testcode = [ + let testcode = [ '// provide a local version for test purposes:', jisonLexerErrorDefinition, '', @@ -13770,14 +13884,33 @@ function RegExpLexer(dict, input, tokens, build_options) { '', source, '', + rmCommonWS$2` + // JISON INJECTED VALIDATION CODE + // which attempts to ascertain you have defined a minimal viable lexer at least: + if (typeof lexer === "undefined") { + throw new SyntaxError("user-defined lexer does not define the required 'lexer' instance."); + } + if (!lexer) { + throw new SyntaxError("user-defined lexer does not define a non-NULL 'lexer' instance."); + } + if (typeof lexer.setInput !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.setInput()' API function."); + } + if (typeof lexer.lex !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.lex()' API function."); + } + // END OF JISON INJECTED VALIDATION CODE + `, 'return lexer;' ].join('\n'); - var lexer = code_exec$1(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { + let lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { //console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$2(sourcecode); - var lexer_f = new Function('', sourcecode); + let lexer_f = new Function('', sourcecode); return lexer_f(); - }, opts.options, "lexer"); + }, Object.assign({}, opts.options, { + throwErrorOnCompileFailure: true + }), 'lexer'); if (!lexer) { throw new Error('no lexer defined *at all*?!'); @@ -13794,7 +13927,7 @@ function RegExpLexer(dict, input, tokens, build_options) { // When we do NOT crash, we found/killed the problem area just before this call! if (src_exception && description) { - var msg = description; + let msg = description; if (typeof description === 'function') { msg = description(); } @@ -13803,8 +13936,8 @@ function RegExpLexer(dict, input, tokens, build_options) { // patch the pre and post handlers in there, now that we have some live code to work with: if (opts.options) { - var pre = opts.options.pre_lex; - var post = opts.options.post_lex; + let pre = opts.options.pre_lex; + let post = opts.options.post_lex; // since JSON cannot encode functions, we'll have to do it manually now: if (typeof pre === 'function') { lexer.options.pre_lex = pre; @@ -13818,7 +13951,7 @@ function RegExpLexer(dict, input, tokens, build_options) { if (typeof opts.options.showSource === 'function') { opts.options.showSource(lexer, source, opts, RegExpLexer); } else { - console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n"); + console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n', source, '\n----------------------------------------\n'); } } return lexer; @@ -13837,13 +13970,13 @@ function RegExpLexer(dict, input, tokens, build_options) { } /** @constructor */ - var lexer = test_me(null, null, null, function (ex) { + let lexer = test_me(null, null, null, function (ex) { // When we get an exception here, it means some part of the user-specified lexer is botched. // // Now we go and try to narrow down the problem area/category: assert$1(opts.options); assert$1(opts.options.xregexp !== undefined); - var orig_xregexp_opt = !!opts.options.xregexp; + let orig_xregexp_opt = !!opts.options.xregexp; if (!test_me(function () { assert$1(opts.options.xregexp !== undefined); opts.options.xregexp = false; @@ -13862,7 +13995,7 @@ function RegExpLexer(dict, input, tokens, build_options) { 'Your custom lexer is somehow botched.' ); }, ex, null)) { - var rulesSpecSize; + let rulesSpecSize; if (!test_me(function () { // store the parsed rule set size so we can use that info in case // this attempt also fails: @@ -13875,7 +14008,7 @@ function RegExpLexer(dict, input, tokens, build_options) { opts.__in_rules_failure_analysis_mode__ = true; }, 'One or more of your lexer rules are possibly botched?', ex, null)) { // kill each rule action block, one at a time and test again after each 'edit': - var rv = false; + let rv = false; for (var i = 0, len = rulesSpecSize; i < len; i++) { var lastEditedRuleSpec; rv = test_me(function () { @@ -13887,10 +14020,10 @@ function RegExpLexer(dict, input, tokens, build_options) { // opts.__in_rules_failure_analysis_mode__ = true; // nuke all rules' actions up to and including rule numero `i`: - for (var j = 0; j <= i; j++) { + for (let j = 0; j <= i; j++) { // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; // now we want to edit the *action* part: - var rule = opts.rules[j]; + let rule = opts.rules[j]; assert$1(Array.isArray(rule)); assert$1(rule.length === 2 || rule.length === 3); rule.pop(); @@ -14024,8 +14157,6 @@ return `{ * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -14035,14 +14166,14 @@ return `{ } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\\n\\s*$/.test(msg)) { msg += '\\n'; } msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') { msg += '\\n' + pos_str; @@ -14053,14 +14184,14 @@ return `{ } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the \`upcomingInput\` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -14080,9 +14211,8 @@ return `{ // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -14102,8 +14232,6 @@ return `{ * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -14124,16 +14252,14 @@ return `{ * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -14154,8 +14280,6 @@ return `{ * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -14163,8 +14287,8 @@ return `{ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -14182,8 +14306,6 @@ return `{ * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -14193,14 +14315,14 @@ return `{ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -14211,8 +14333,6 @@ return `{ * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -14220,40 +14340,40 @@ return `{ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -14265,7 +14385,7 @@ return `{ this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -14273,7 +14393,7 @@ return `{ last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -14334,9 +14454,7 @@ return `{ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -14355,8 +14473,6 @@ return `{ * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set \`done\` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -14365,7 +14481,7 @@ return `{ this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -14375,13 +14491,13 @@ return `{ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\\n') { lines = true; } else if (ch === '\\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\\n') { slice_len++; ch += ch2; @@ -14413,10 +14529,8 @@ return `{ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -14448,8 +14562,8 @@ return `{ // Get last entirely matched line into the \`pre_lines[]\` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -14467,9 +14581,9 @@ return `{ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -14479,14 +14593,12 @@ return `{ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -14497,8 +14609,6 @@ return `{ * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -14511,19 +14621,17 @@ return `{ * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the \`parseError()\` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // \`.lex()\` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -14536,8 +14644,6 @@ return `{ * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -14560,24 +14666,24 @@ return `{ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substr\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14589,8 +14695,8 @@ return `{ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to \`maxSize\` (default: 20). @@ -14616,24 +14722,25 @@ return `{ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > \`lookAhead()\` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substring\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -14642,7 +14749,7 @@ return `{ } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14661,10 +14768,8 @@ return `{ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^'; }, @@ -14686,15 +14791,13 @@ return `{ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -14825,58 +14928,54 @@ return `{ * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\\t/g, ' '); @@ -14885,13 +14984,13 @@ return `{ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -14913,15 +15012,13 @@ return `{ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -14933,8 +15030,8 @@ return `{ rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -14963,13 +15060,7 @@ return `{ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -14998,10 +15089,10 @@ return `{ }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -15029,7 +15120,7 @@ return `{ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -15040,7 +15131,7 @@ return `{ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -15062,8 +15153,6 @@ return `{ * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -15072,17 +15161,13 @@ return `{ this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -15092,67 +15177,75 @@ return `{ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that \`parseError()\` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) \`parseError()\` @@ -15179,9 +15272,7 @@ return `{ * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15224,24 +15315,24 @@ return `{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15261,9 +15352,7 @@ return `{ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15273,24 +15362,24 @@ return `{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15298,7 +15387,7 @@ return `{ this._clear_state = 0; } - + return r; }, @@ -15311,9 +15400,7 @@ return `{ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -15321,7 +15408,7 @@ return `{ (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -15336,8 +15423,6 @@ return `{ * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -15349,8 +15434,6 @@ return `{ * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -15364,15 +15447,12 @@ return `{ * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -15384,14 +15464,11 @@ return `{ * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -15402,16 +15479,14 @@ return `{ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -15421,8 +15496,6 @@ return `{ * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; } }`; @@ -15454,18 +15527,17 @@ function stripUnusedLexerCode(src, opt) { // ............................. ${opt.lexerActionsUseDisplayAPIs} // uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC} - var new_src; + let new_src; try { - var ast = helpers.parseCodeChunkToAST(src, opt); + let ast = helpers.parseCodeChunkToAST(src, opt); new_src = helpers.prettyPrintAST(ast, opt); - } - catch (ex) { + } catch (ex) { let line = ex.lineNumber || 0; let a = src.split(/\r?\n/g); let len = a.length; let minl = Math.max(0, line - 10); let b = a.slice(minl, line + 10); - let c = b.splice(line - minl, 0, "", "^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", ""); + let c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); let offendingChunk = ' ' + b.join('\n '); console.error(rmCommonWS$2` stripUnusedLexerCode WARNING: @@ -15481,17 +15553,11 @@ function stripUnusedLexerCode(src, opt) { ${offendingChunk} `); - + new_src = src; } - - - - - - // inject analysis report now: new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2` // Code Generator Information Report @@ -15546,7 +15612,7 @@ function stripUnusedLexerCode(src, opt) { // generate lexer source from a grammar /** @public */ function generate(dict, tokens, build_options) { - var opt = processGrammar(dict, tokens, build_options); + let opt = processGrammar(dict, tokens, build_options); return generateFromOpts(opt); } @@ -15555,7 +15621,7 @@ function generate(dict, tokens, build_options) { /** @public */ function processGrammar(dict, tokens, build_options) { build_options = build_options || {}; - var opts = { + let opts = { // include the knowledge passed through `build_options` about which lexer // features will actually be *used* by the environment (which in 99.9% // of cases is a jison *parser*): @@ -15595,7 +15661,7 @@ function processGrammar(dict, tokens, build_options) { lexerActionsUseReject: '???', lexerActionsUseLess: '???', lexerActionsUseDisplayAPIs: '???', - lexerActionsUseDescribeYYLOC: '???', + lexerActionsUseDescribeYYLOC: '???' }; dict = autodetectAndConvertToJSONformat(dict, build_options) || {}; @@ -15620,7 +15686,7 @@ function processGrammar(dict, tokens, build_options) { // only produce rule action code blocks when there are any rules at all; // a "custom lexer" has ZERO rules and must be defined entirely in // other code blocks: - var code = (dict.rules ? buildActions(dict, tokens, opts) : {}); + let code = (dict.rules ? buildActions(dict, tokens, opts) : {}); opts.performAction = code.actions; opts.caseHelperInclude = code.caseHelperInclude; opts.rules = code.rules || []; @@ -15629,7 +15695,7 @@ function processGrammar(dict, tokens, build_options) { opts.regular_rule_count = code.regular_rule_count; opts.simple_rule_count = code.simple_rule_count; - opts.conditionStack = ['INITIAL']; + opts.conditionStack = [ 'INITIAL' ]; opts.actionInclude = (dict.actionInclude || ''); opts.moduleInclude = (opts.moduleInclude || '') + (dict.moduleInclude || '').trim(); @@ -15640,7 +15706,7 @@ function processGrammar(dict, tokens, build_options) { // Assemble the final source from the processed grammar /** @public */ function generateFromOpts(opt) { - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -15663,12 +15729,12 @@ function generateFromOpts(opt) { } function generateRegexesInitTableCode(opt) { - var a = opt.rules; - var print_xregexp = opt.options && opt.options.xregexp; - var id_display_width = (1 + Math.log10(a.length | 1) | 0); - var ws_prefix = new Array(id_display_width).join(' '); - var b = a.map(function generateXRegExpInitCode(re, idx) { - var idx_str = (ws_prefix + idx).substr(-id_display_width); + let a = opt.rules; + let print_xregexp = opt.options && opt.options.xregexp; + let id_display_width = (1 + Math.log10(a.length | 1) | 0); + let ws_prefix = new Array(id_display_width).join(' '); + let b = a.map(function generateXRegExpInitCode(re, idx) { + let idx_str = (ws_prefix + idx).substr(-id_display_width); if (re instanceof XRegExp) { // When we don't need the special XRegExp sauce at run-time, we do with the original @@ -15678,11 +15744,11 @@ function generateRegexesInitTableCode(opt) { } // And make sure to escape the regex to make it suitable for placement inside a *string* // as it is passed as a string argument to the XRegExp constructor here. - var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); + let re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); return `/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`; - } else { - return `/* ${idx_str}: */ ${re}`; } + return `/* ${idx_str}: */ ${re}`; + }); return b.join(',\n'); } @@ -15690,77 +15756,77 @@ function generateRegexesInitTableCode(opt) { function generateModuleBody(opt) { // make the JSON output look more like JavaScript: function cleanupJSON(str) { - str = str.replace(/ "rules": \[/g, ' rules: ['); - str = str.replace(/ "inclusive": /g, ' inclusive: '); + str = str.replace(/ {2}"rules": \[/g, ' rules: ['); + str = str.replace(/ {2}"inclusive": /g, ' inclusive: '); return str; } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - json: 1, - _: 1, - noMain: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - lexerErrorsAreRecoverable: 0, - flex: 0, - backtrack_lexer: 0, - caseInsensitive: 0, - showSource: 1, - exportAST: 1, - exportAllTables: 1, - exportSourceCode: 1, - prettyCfg: 1, - parseActionsUseYYLENG: 1, - parseActionsUseYYLINENO: 1, - parseActionsUseYYTEXT: 1, - parseActionsUseYYLOC: 1, - parseActionsUseParseError: 1, - parseActionsUseYYERROR: 1, - parseActionsUseYYRECOVERING: 1, - parseActionsUseYYERROK: 1, - parseActionsUseYYCLEARIN: 1, - parseActionsUseValueTracking: 1, - parseActionsUseValueAssignment: 1, - parseActionsUseLocationTracking: 1, - parseActionsUseLocationAssignment: 1, - parseActionsUseYYSTACK: 1, - parseActionsUseYYSSTACK: 1, - parseActionsUseYYSTACKPOINTER: 1, - parseActionsUseYYRULELENGTH: 1, - parseActionsUseYYMERGELOCATIONINFO: 1, - parserHasErrorRecovery: 1, - parserHasErrorReporting: 1, - lexerActionsUseYYLENG: 1, - lexerActionsUseYYLINENO: 1, - lexerActionsUseYYTEXT: 1, - lexerActionsUseYYLOC: 1, - lexerActionsUseParseError: 1, - lexerActionsUseYYERROR: 1, - lexerActionsUseLocationTracking: 1, - lexerActionsUseMore: 1, - lexerActionsUseUnput: 1, - lexerActionsUseReject: 1, - lexerActionsUseLess: 1, - lexerActionsUseDisplayAPIs: 1, - lexerActionsUseDescribeYYLOC: 1, + let obj = {}; + const do_not_pass = { + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + json: 1, + _: 1, + noMain: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + lexerErrorsAreRecoverable: 0, + flex: 0, + backtrack_lexer: 0, + caseInsensitive: 0, + showSource: 1, + exportAST: 1, + exportAllTables: 1, + exportSourceCode: 1, + prettyCfg: 1, + parseActionsUseYYLENG: 1, + parseActionsUseYYLINENO: 1, + parseActionsUseYYTEXT: 1, + parseActionsUseYYLOC: 1, + parseActionsUseParseError: 1, + parseActionsUseYYERROR: 1, + parseActionsUseYYRECOVERING: 1, + parseActionsUseYYERROK: 1, + parseActionsUseYYCLEARIN: 1, + parseActionsUseValueTracking: 1, + parseActionsUseValueAssignment: 1, + parseActionsUseLocationTracking: 1, + parseActionsUseLocationAssignment: 1, + parseActionsUseYYSTACK: 1, + parseActionsUseYYSSTACK: 1, + parseActionsUseYYSTACKPOINTER: 1, + parseActionsUseYYRULELENGTH: 1, + parseActionsUseYYMERGELOCATIONINFO: 1, + parserHasErrorRecovery: 1, + parserHasErrorReporting: 1, + lexerActionsUseYYLENG: 1, + lexerActionsUseYYLINENO: 1, + lexerActionsUseYYTEXT: 1, + lexerActionsUseYYLOC: 1, + lexerActionsUseParseError: 1, + lexerActionsUseYYERROR: 1, + lexerActionsUseLocationTracking: 1, + lexerActionsUseMore: 1, + lexerActionsUseUnput: 1, + lexerActionsUseReject: 1, + lexerActionsUseLess: 1, + lexerActionsUseDisplayAPIs: 1, + lexerActionsUseDescribeYYLOC: 1 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -15771,8 +15837,8 @@ function generateModuleBody(opt) { } // And now some options which should receive some special processing: - var pre = obj.pre_lex; - var post = obj.post_lex; + let pre = obj.pre_lex; + let post = obj.post_lex; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_lex = true; @@ -15781,7 +15847,7 @@ function generateModuleBody(opt) { obj.post_lex = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp(` "(${ID_REGEX_BASE$1})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_lex: true(,)?$/gm, function (m, ls, tc) { @@ -15794,17 +15860,17 @@ function generateModuleBody(opt) { } - var out; + let out; if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) { // we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. - var code = [rmCommonWS$2` - var lexer = { - `, '/*JISON-LEX-ANALYTICS-REPORT*/' /* slot #1: placeholder for analysis report further below */ + let code = [ rmCommonWS$2` + const lexer = { + `, '/* JISON-LEX-ANALYTICS-REPORT */\n' /* slot #1: placeholder for analysis report further below */ ]; // get the RegExpLexer.prototype in source code form: - var protosrc = getRegExpLexerPrototype(); + let protosrc = getRegExpLexerPrototype(); // and strip off the surrounding bits we don't want: protosrc = protosrc .replace(/^[\s\r\n]*\{/, '') @@ -15831,10 +15897,10 @@ function generateModuleBody(opt) { } */ - var performActionCode = String(opt.performAction); - var simpleCaseActionClustersCode = String(opt.caseHelperInclude); - var rulesCode = generateRegexesInitTableCode(opt); - var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); + let performActionCode = String(opt.performAction); + let simpleCaseActionClustersCode = String(opt.caseHelperInclude); + let rulesCode = generateRegexesInitTableCode(opt); + let conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); code.push(rmCommonWS$2`, JisonLexerError: JisonLexerError, performAction: ${performActionCode}, @@ -15854,9 +15920,9 @@ function generateModuleBody(opt) { // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // - // Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter + // Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. - out = 'var lexer;\n'; + out = '\n'; assert$1(opt.regular_rule_count === 0); assert$1(opt.simple_rule_count === 0); @@ -15870,8 +15936,6 @@ function generateModuleBody(opt) { // The output of this function is guaranteed to read something like this: // // ``` - // var lexer; - // // bla bla bla bla ... lotsa bla bla; // ``` // @@ -15880,7 +15944,7 @@ function generateModuleBody(opt) { } function generateGenericHeaderComment() { - var out = rmCommonWS$2` + let out = rmCommonWS$2` /* lexer generated by jison-lex ${version} */ /* @@ -16109,7 +16173,7 @@ function prepareOptions(opt) { // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else { @@ -16127,9 +16191,9 @@ function prepareOptions(opt) { function generateModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -16152,9 +16216,9 @@ function generateModule(opt) { function generateAMDModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} define([], function () { @@ -16177,12 +16241,12 @@ function generateAMDModule(opt) { function generateESModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} - var lexer = (function () { + const lexer = (function () { "use strict"; ${jisonLexerErrorDefinition} @@ -16211,9 +16275,9 @@ function generateESModule(opt) { function generateCommonJSModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -16255,7 +16319,6 @@ RegExpLexer.autodetectAndConvertToJSONformat = autodetectAndConvertToJSONformat; // 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. function JisonParserError$1(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -16272,9 +16335,9 @@ function JisonParserError$1(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -16307,10 +16370,10 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp$1(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -16325,18 +16388,18 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt$1(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -16367,7 +16430,7 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // `this` references an array function s$1(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -16384,9 +16447,9 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$1(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -16399,7 +16462,7 @@ JisonParserError$1.prototype.name = 'JisonParserError'; } -var parser$1 = { +let parser$1 = { // Code Generator Information Report // --------------------------------- // @@ -16525,7 +16588,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -16533,7 +16595,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -16545,8 +16606,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -16559,14 +16620,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -16582,10 +16642,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -16593,10 +16653,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -16640,9 +16700,9 @@ performAction: function parser__PerformAction(yystate /* action[1] */, yysp, yyv /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; @@ -16650,17 +16710,17 @@ performAction: function parser__PerformAction(yystate /* action[1] */, yysp, yyv case 0: /*! Production:: $accept : production $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-) break; case 1: /*! Production:: production : handle EOF */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-) return yyvstack[yysp - 1]; @@ -16896,7 +16956,6 @@ defaultActions: { 19: 3 }, parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -16913,37 +16972,32 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) + let vstack = new Array(128); // semantic value stack - var vstack = new Array(128); // semantic value stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks + let symbol = 0; - + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - var symbol = 0; - - - - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -16951,20 +17005,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -16981,7 +17033,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -16989,18 +17040,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -17008,18 +17060,14 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -17041,7 +17089,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -17054,7 +17101,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -17068,11 +17114,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -17126,8 +17171,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -17276,8 +17321,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -17286,10 +17330,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -17297,7 +17341,7 @@ parse: function parse(input) { stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -17308,9 +17352,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -17336,8 +17385,7 @@ parse: function parse(input) { function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -17346,21 +17394,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -17370,21 +17417,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -17393,20 +17439,20 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; try { @@ -17419,7 +17465,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -17472,14 +17518,11 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { - var errStr; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let errStr; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); // Report error errStr = 'Parse error'; @@ -17516,9 +17559,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -17547,7 +17588,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -17589,21 +17630,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, newState, sp - 1, vstack); +r = this.performAction.call(yyval, newState, sp - 1, vstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -17634,14 +17673,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -17651,6 +17691,7 @@ parse: function parse(input) { + } continue; // accept: @@ -17703,8 +17744,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -17964,7 +18004,6 @@ var lexer$1 = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -17981,10 +18020,10 @@ var lexer$1 = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -18016,7 +18055,7 @@ var lexer$1 = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -18058,7 +18097,9 @@ var lexer$1 = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -18144,7 +18185,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -18152,7 +18193,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -18165,7 +18206,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -18191,10 +18232,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -18217,7 +18261,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -18240,16 +18283,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -18271,7 +18314,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -18279,8 +18321,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -18309,7 +18351,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -18334,7 +18376,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -18346,17 +18388,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -18450,7 +18492,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -18471,7 +18513,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -18482,7 +18523,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -18493,15 +18534,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -18535,8 +18576,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -18569,9 +18610,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -18590,9 +18631,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -18602,8 +18643,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -18630,20 +18671,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -18683,17 +18723,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -18702,7 +18744,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -18717,8 +18759,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -18744,24 +18786,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -18772,7 +18816,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -18794,8 +18838,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -18817,8 +18861,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -18962,21 +19005,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -18991,11 +19034,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -19014,13 +19057,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -19044,13 +19087,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -19065,8 +19108,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -19097,7 +19140,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -19129,9 +19172,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -19160,7 +19203,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -19178,7 +19221,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -19203,7 +19246,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -19213,8 +19255,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -19223,7 +19263,7 @@ EOF: 1, this.clear(); } - 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. @@ -19235,13 +19275,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -19251,68 +19291,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -19337,7 +19383,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -19385,24 +19431,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -19422,7 +19468,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -19432,24 +19478,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -19470,8 +19516,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -19511,14 +19556,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -19534,9 +19579,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -19547,8 +19592,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -19556,7 +19601,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -19709,9 +19754,9 @@ const ID_REGEX_BASE$2 = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // guaranteed not to collide with previously generated / already existing // rules (~ symbols). function generateUniqueSymbol(id, postfix, opts) { - var sym = id + postfix; + let sym = id + postfix; if (opts.grammar[sym]) { - var i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. + let i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. do { sym = id + postfix + i; i++; @@ -19721,8 +19766,8 @@ function generateUniqueSymbol(id, postfix, opts) { } function generatePushAction(handle, offset) { - var terms = handle.terms; - var rv = []; + const terms = handle.terms; + let rv = []; for (var i = 0, len = terms.length; i < len; i++) { rv.push('$' + (i + offset)); @@ -19738,11 +19783,11 @@ function generatePushAction(handle, offset) { } function transformExpression(e, opts, emit) { - var type = e[0], - value = e[1], - name = false, - has_transformed = 0; - var list, n; + let type = e[0]; + let value = e[1]; + let name = false; + let has_transformed = 0; + let list, n; if (type === 'xalias') { type = e[1]; @@ -19769,7 +19814,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ list.fragment, @@ -19789,7 +19834,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ '', @@ -19809,7 +19854,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); // you want to be able to check if 0 or 1 occurrences were recognized: since jison // by default *copies* the lexer token value, i.e. `$$ = $1` is the (optional) default action, // we will need to set the action up explicitly in case of the 0-count match: @@ -19845,7 +19890,7 @@ function transformExpression(e, opts, emit) { opts = optsForProduction(name, opts.grammar); opts.grammar[name] = value.map(function (handle) { - var list = transformExpressionList(handle, opts); + let list = transformExpressionList(handle, opts); return [ list.fragment, '$$ = ' + generatePushAction(list, 1) + ';' @@ -19858,11 +19903,11 @@ function transformExpression(e, opts, emit) { } function transformExpressionList(list, opts) { - var first_transformed_term_index = false; - var terms = list.reduce(function (tot, e) { - var ci = tot.length; + let first_transformed_term_index = false; + let terms = list.reduce(function (tot, e) { + let ci = tot.length; - var has_transformed = transformExpression(e, opts, function (name) { + let has_transformed = transformExpression(e, opts, function (name) { if (name.terms) { tot.push.apply(tot, name.terms); } else { @@ -19891,42 +19936,42 @@ function optsForProduction(id, grammar) { } function transformProduction(id, production, grammar) { - var transform_opts = optsForProduction(id, grammar); + let transform_opts = optsForProduction(id, grammar); return production.map(function (handle) { - var action = null, - opts = null; - var i, len, n; + let action = null; + let opts = null; + let i, len, n; if (typeof handle !== 'string') { action = handle[1]; opts = handle[2]; handle = handle[0]; } - var expressions = handle; + let expressions = handle; if (typeof expressions === 'string') { expressions = parser$2.parse(handle); } - var list = transformExpressionList(expressions, transform_opts); + let list = transformExpressionList(expressions, transform_opts); - var ret = [list.fragment]; + let ret = [ list.fragment ]; if (action) { // make sure the action doesn't address any inner items. if (list.first_transformed_term_index) { // seek out all names and aliases; strip out literal tokens first as those cannot serve as $names: - var alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); + let alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); - var alias_re = new XRegExp(`\\[${ID_REGEX_BASE$2}\\]`); - var term_re = new XRegExp(`^${ID_REGEX_BASE$2}$`); + let alias_re = new XRegExp(`\\[${ID_REGEX_BASE$2}\\]`); + let term_re = new XRegExp(`^${ID_REGEX_BASE$2}$`); // and collect the PERMITTED aliases: the names of the terms and all the remaining aliases - var good_aliases = {}; - var alias_cnt = {}; - var donotalias = {}; + let good_aliases = {}; + let alias_cnt = {}; + let donotalias = {}; // WARNING: this replicates the knowledge/code of jison.js::addName() - var addName = function addNameEBNF(s, i) { - var base = s.replace(/[0-9]+$/, ''); - var dna = donotalias[base]; + let addName = function addNameEBNF(s, i) { + let base = s.replace(/[0-9]+$/, ''); + let dna = donotalias[base]; if (good_aliases[s]) { alias_cnt[s]++; @@ -19945,7 +19990,7 @@ function transformProduction(id, production, grammar) { }; // WARNING: this replicates the knowledge/code of jison.js::markBasename() - var markBasename = function markBasenameEBNF(s) { + let markBasename = function markBasenameEBNF(s) { if (/[0-9]$/.test(s)) { s = s.replace(/[0-9]+$/, ''); donotalias[s] = true; @@ -19982,13 +20027,13 @@ function transformProduction(id, production, grammar) { // now scan the action for all named and numeric semantic values ($nonterminal / $1 / @1, ##1, ...) // // Note that `#name` are straight **static** symbol translations, which are okay as they don't - // require access to the parse stack: `#n` references can be resolved completely + // require access to the parse stack: `#n` references can be resolved completely // at grammar compile time. // - var nameref_re = new XRegExp(`(?:[$@]|##)${ID_REGEX_BASE$2}`, 'g'); - var named_spots = nameref_re.exec(action); - var numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); - var max_term_index = list.terms.length; + let nameref_re = new XRegExp(`(?:[$@]|##)${ID_REGEX_BASE$2}`, 'g'); + let named_spots = nameref_re.exec(action); + let numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); + let max_term_index = list.terms.length; // loop through the XRegExp alias regex matches in `action` while (named_spots) { @@ -20018,7 +20063,7 @@ function transformProduction(id, production, grammar) { for (i = 0, len = numbered_spots.length; i < len; i++) { n = parseInt(numbered_spots[i].replace(/^(?:[$@]|##)/, '')); if (n > max_term_index) { - /* @const */ var n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; + /* @const */ let n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; throw new Error('The action block references the ' + n + n_suffixes[Math.max(0, Math.min(3, n - 1))] + ' term, ' + 'which is not available in production "' + handle + '"; ' + 'Be reminded that you cannot reference sub-elements within EBNF */+/? groups, ' + @@ -20036,13 +20081,14 @@ function transformProduction(id, production, grammar) { if (ret.length === 1) { return ret[0]; - } else { - return ret; } + return ret; + }); } -var ref_list; -var ref_names; + +let ref_list; +let ref_names; // create a deep copy of the input, so we will keep the input constant. function deepClone(from, sub) { @@ -20057,7 +20103,7 @@ function deepClone(from, sub) { return from; } - var idx = ref_list.indexOf(from); + let idx = ref_list.indexOf(from); if (idx >= 0) { throw new Error('[Circular/Xref:' + ref_names[i] + ']'); // circular or cross reference } @@ -20073,7 +20119,7 @@ function deepClone(from, sub) { sub += '.'; var to = new from.constructor(); - for (var name in from) { + for (let name in from) { to[name] = deepClone(from[name], sub + name); } } @@ -20089,8 +20135,9 @@ function transformGrammar(grammar) { return grammar; } + function transform(ebnf) { - var rv = transformGrammar(ebnf); + let rv = transformGrammar(ebnf); return rv; } @@ -20100,7 +20147,6 @@ function transform(ebnf) { // 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. function JisonParserError$2(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -20117,9 +20163,9 @@ function JisonParserError$2(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -20152,10 +20198,10 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp$2(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -20168,11 +20214,11 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda$1(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -20182,18 +20228,18 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt$2(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -20224,7 +20270,7 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // `this` references an array function s$2(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -20241,9 +20287,9 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$2(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -20256,7 +20302,7 @@ JisonParserError$2.prototype.name = 'JisonParserError'; } -var parser$3 = { +let parser$3 = { // Code Generator Information Report // --------------------------------- // @@ -20492,7 +20538,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -20500,7 +20545,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -20512,8 +20556,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -20526,14 +20570,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -20549,10 +20592,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -20560,10 +20603,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -20744,26 +20787,26 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; switch (yystate) { case 0: /*! Production:: $accept : spec $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break; case 1: /*! Production:: spec : declaration_list "%%" grammar optional_end_block EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4]; @@ -20775,10 +20818,10 @@ case 1: case 2: /*! Production:: spec : declaration_list "%%" grammar error EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -20797,10 +20840,10 @@ case 2: case 3: /*! Production:: spec : declaration_list error EOF */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -20822,9 +20865,9 @@ case 118: case 133: /*! Production:: optional_module_code_chunk : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -20833,9 +20876,9 @@ case 133: case 5: /*! Production:: optional_end_block : "%%" extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20855,9 +20898,9 @@ case 6: case 10: /*! Production:: declaration_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; @@ -20868,9 +20911,9 @@ case 7: case 8: /*! Production:: optional_action_header_block : optional_action_header_block include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -20889,9 +20932,9 @@ case 8: case 9: /*! Production:: declaration_list : declaration_list declaration */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20900,10 +20943,10 @@ case 9: case 11: /*! Production:: declaration_list : declaration_list error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -20918,9 +20961,9 @@ case 11: case 12: /*! Production:: declaration : START id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {start: yyvstack[yysp]}; @@ -20929,9 +20972,9 @@ case 12: case 13: /*! Production:: declaration : LEX_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {lex: {text: yyvstack[yysp], position: yylstack[yysp]}}; @@ -20940,9 +20983,9 @@ case 13: case 14: /*! Production:: declaration : operator */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {operator: yyvstack[yysp]}; @@ -20951,9 +20994,9 @@ case 14: case 15: /*! Production:: declaration : TOKEN full_token_definitions */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {token_list: yyvstack[yysp]}; @@ -20962,9 +21005,9 @@ case 15: case 16: /*! Production:: declaration : ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20982,9 +21025,9 @@ case 16: case 17: /*! Production:: declaration : include_macro_code */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21002,9 +21045,9 @@ case 17: case 18: /*! Production:: declaration : parse_params */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parseParams: yyvstack[yysp]}; @@ -21013,9 +21056,9 @@ case 18: case 19: /*! Production:: declaration : parser_type */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parserType: yyvstack[yysp]}; @@ -21024,9 +21067,9 @@ case 19: case 20: /*! Production:: declaration : options */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: yyvstack[yysp]}; @@ -21035,9 +21078,9 @@ case 20: case 21: /*! Production:: declaration : DEBUG */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: [['debug', true]]}; @@ -21046,9 +21089,9 @@ case 21: case 22: /*! Production:: declaration : EBNF */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) ebnf = true; @@ -21058,9 +21101,9 @@ case 22: case 23: /*! Production:: declaration : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {unknownDecl: yyvstack[yysp]}; @@ -21069,9 +21112,9 @@ case 23: case 24: /*! Production:: declaration : IMPORT import_name import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = {imports: {name: yyvstack[yysp - 1], path: yyvstack[yysp]}}; @@ -21080,10 +21123,10 @@ case 24: case 25: /*! Production:: declaration : IMPORT import_name error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21099,10 +21142,10 @@ case 25: case 26: /*! Production:: declaration : IMPORT error import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21118,9 +21161,9 @@ case 26: case 27: /*! Production:: declaration : INIT_CODE init_code_name action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21143,10 +21186,10 @@ case 27: case 28: /*! Production:: declaration : INIT_CODE error action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21162,10 +21205,10 @@ case 28: case 29: /*! Production:: declaration : START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21180,10 +21223,10 @@ case 29: case 30: /*! Production:: declaration : TOKEN error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21198,10 +21241,10 @@ case 30: case 31: /*! Production:: declaration : IMPORT error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21266,9 +21309,9 @@ case 129: case 132: /*! Production:: optional_module_code_chunk : module_code_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -21279,9 +21322,9 @@ case 39: case 111: /*! Production:: action_ne : "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21290,10 +21333,10 @@ case 111: case 40: /*! Production:: options : OPTIONS error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21308,10 +21351,10 @@ case 40: case 41: /*! Production:: options : OPTIONS error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21330,9 +21373,9 @@ case 59: case 70: /*! Production:: id_list : id_list id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21347,9 +21390,9 @@ case 71: case 84: /*! Production:: handle_list : handle_action */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -21358,9 +21401,9 @@ case 84: case 44: /*! Production:: option : NAME */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -21369,9 +21412,9 @@ case 44: case 45: /*! Production:: option : NAME "=" OPTION_STRING_VALUE */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -21382,9 +21425,9 @@ case 46: case 47: /*! Production:: option : NAME "=" NAME */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], parseValue$1(yyvstack[yysp])]; @@ -21393,10 +21436,10 @@ case 47: case 48: /*! Production:: option : NAME "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21411,10 +21454,10 @@ case 48: case 49: /*! Production:: option : NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21431,9 +21474,9 @@ case 50: case 52: /*! Production:: parser_type : PARSER_TYPE symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -21442,10 +21485,10 @@ case 52: case 51: /*! Production:: parse_params : PARSE_PARAM error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21463,10 +21506,10 @@ case 51: case 53: /*! Production:: parser_type : PARSER_TYPE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21484,9 +21527,9 @@ case 53: case 54: /*! Production:: operator : associativity token_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1]]; this.$.push.apply(this.$, yyvstack[yysp]); @@ -21495,10 +21538,10 @@ case 54: case 55: /*! Production:: operator : associativity error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21516,9 +21559,9 @@ case 55: case 56: /*! Production:: associativity : LEFT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'left'; @@ -21527,9 +21570,9 @@ case 56: case 57: /*! Production:: associativity : RIGHT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'right'; @@ -21538,9 +21581,9 @@ case 57: case 58: /*! Production:: associativity : NONASSOC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'nonassoc'; @@ -21549,9 +21592,9 @@ case 58: case 61: /*! Production:: full_token_definitions : optional_token_type id_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var rv = []; @@ -21570,9 +21613,9 @@ case 61: case 62: /*! Production:: full_token_definitions : optional_token_type one_full_token */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var m = yyvstack[yysp]; @@ -21585,9 +21628,9 @@ case 62: case 63: /*! Production:: one_full_token : id token_value token_description */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21600,9 +21643,9 @@ case 63: case 64: /*! Production:: one_full_token : id token_description */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21614,9 +21657,9 @@ case 64: case 65: /*! Production:: one_full_token : id token_value */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21628,9 +21671,9 @@ case 65: case 66: /*! Production:: optional_token_type : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = false; @@ -21639,9 +21682,9 @@ case 66: case 72: /*! Production:: grammar : optional_action_header_block production_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21651,9 +21694,9 @@ case 72: case 73: /*! Production:: production_list : production_list production */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21667,9 +21710,9 @@ case 73: case 74: /*! Production:: production_list : production */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; this.$[yyvstack[yysp][0]] = yyvstack[yysp][1]; @@ -21678,9 +21721,9 @@ case 74: case 75: /*! Production:: production : production_id handle_list ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp - 1]]; @@ -21689,10 +21732,10 @@ case 75: case 76: /*! Production:: production : production_id error ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21710,10 +21753,10 @@ case 76: case 77: /*! Production:: production : production_id error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21731,9 +21774,9 @@ case 77: case 78: /*! Production:: production_id : id optional_production_description ":" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21744,10 +21787,10 @@ case 78: case 79: /*! Production:: production_id : id optional_production_description error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21765,10 +21808,10 @@ case 79: case 80: /*! Production:: production_id : id optional_production_description ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21792,18 +21835,18 @@ case 80: case 82: /*! Production:: optional_production_description : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) break; case 83: /*! Production:: handle_list : handle_list "|" handle_action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21813,10 +21856,10 @@ case 83: case 85: /*! Production:: handle_list : handle_list "|" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21834,10 +21877,10 @@ case 85: case 86: /*! Production:: handle_list : handle_list ":" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21852,9 +21895,9 @@ case 86: case 87: /*! Production:: handle_action : handle prec action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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(' ') : '')]; @@ -21889,9 +21932,9 @@ case 87: case 88: /*! Production:: handle_action : EPSILON action */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = ['']; @@ -21915,10 +21958,10 @@ case 88: case 89: /*! Production:: handle_action : EPSILON error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21933,9 +21976,9 @@ case 89: case 90: /*! Production:: handle : handle suffixed_expression */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21945,9 +21988,9 @@ case 90: case 91: /*! Production:: handle : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -21956,9 +21999,9 @@ case 91: case 92: /*! Production:: handle_sublist : handle_sublist "|" handle */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21968,9 +22011,9 @@ case 92: case 93: /*! Production:: handle_sublist : handle */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp].join(' ')]; @@ -21979,9 +22022,9 @@ case 93: case 94: /*! Production:: suffixed_expression : expression suffix ALIAS */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + "[" + yyvstack[yysp] + "]"; @@ -21994,9 +22037,9 @@ case 124: case 130: /*! Production:: module_code_chunk : module_code_chunk CODE */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22005,9 +22048,9 @@ case 130: case 97: /*! Production:: expression : EOF_ID */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$end'; @@ -22016,9 +22059,9 @@ case 97: case 98: /*! Production:: expression : STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // Re-encode the string *anyway* as it will @@ -22031,9 +22074,9 @@ case 98: case 99: /*! Production:: expression : "(" handle_sublist ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1].join(' | ') + ')'; @@ -22042,10 +22085,10 @@ case 99: case 100: /*! Production:: expression : "(" handle_sublist error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22059,9 +22102,9 @@ case 100: case 105: /*! Production:: prec : PREC symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { prec: yyvstack[yysp] }; @@ -22070,10 +22113,10 @@ case 105: case 106: /*! Production:: prec : PREC error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -22091,9 +22134,9 @@ case 106: case 107: /*! Production:: prec : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = null; @@ -22102,10 +22145,10 @@ case 107: case 112: /*! Production:: action_ne : "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22119,9 +22162,9 @@ case 112: case 116: /*! Production:: action : ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$$ = (' + yyvstack[yysp] + ');'; @@ -22130,9 +22173,9 @@ case 116: case 120: /*! Production:: action_body : action_body "{" action_body "}" action_comments_body */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4] + yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22141,9 +22184,9 @@ case 120: case 121: /*! Production:: action_body : action_body "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22152,10 +22195,10 @@ case 121: case 122: /*! Production:: action_body : action_body "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22169,9 +22212,9 @@ case 122: case 126: /*! Production:: extra_parser_module_code : optional_module_code_chunk include_macro_code extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22180,9 +22223,9 @@ case 126: case 127: /*! Production:: include_macro_code : INCLUDE PATH */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' }); @@ -22202,10 +22245,10 @@ case 127: case 128: /*! Production:: include_macro_code : INCLUDE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22218,10 +22261,10 @@ case 128: case 131: /*! Production:: module_code_chunk : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -23614,7 +23657,6 @@ defaultActions: bda$1({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -23631,38 +23673,34 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -23670,20 +23708,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -23705,7 +23741,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -23713,18 +23748,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -23732,24 +23768,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -23787,18 +23818,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -23819,7 +23847,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -23837,7 +23865,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -23850,7 +23877,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -23864,11 +23890,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -23922,8 +23947,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -23931,8 +23956,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -23964,19 +23989,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -23987,7 +24011,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -24000,7 +24024,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -24012,29 +24036,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -24042,7 +24064,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -24062,8 +24084,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -24072,10 +24093,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -24083,7 +24104,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -24094,9 +24115,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -24112,8 +24138,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -24182,11 +24207,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -24197,8 +24225,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -24207,21 +24234,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -24231,21 +24257,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -24254,28 +24279,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -24288,8 +24312,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -24312,8 +24335,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -24325,8 +24347,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -24343,8 +24364,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -24358,8 +24378,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -24373,7 +24392,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -24426,16 +24445,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -24469,9 +24485,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -24494,9 +24508,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -24523,17 +24535,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -24580,8 +24591,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -24593,8 +24604,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -24612,6 +24622,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -24620,7 +24631,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -24631,7 +24642,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -24691,10 +24702,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -24729,9 +24740,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -24744,7 +24753,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -24765,9 +24774,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -24789,12 +24796,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -24803,7 +24810,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -24844,7 +24851,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -24891,7 +24898,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -24909,21 +24916,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -24957,14 +24962,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -24974,6 +24980,7 @@ parse: function parse(input) { + } continue; // accept: @@ -25025,7 +25032,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -25041,9 +25048,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -25072,7 +25077,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -25089,8 +25094,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -25101,8 +25106,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -25114,21 +25119,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -25159,14 +25162,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -25176,6 +25180,7 @@ parse: function parse(input) { + } continue; // accept: @@ -25228,8 +25233,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -25490,7 +25494,6 @@ var lexer$2 = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -25507,10 +25510,10 @@ var lexer$2 = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -25542,7 +25545,7 @@ var lexer$2 = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -25584,7 +25587,9 @@ var lexer$2 = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -25670,7 +25675,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -25678,7 +25683,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -25691,7 +25696,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -25717,10 +25722,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -25743,7 +25751,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -25766,16 +25773,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -25797,7 +25804,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -25805,8 +25811,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -25835,7 +25841,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -25860,7 +25866,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -25872,17 +25878,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -25976,7 +25982,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -25997,7 +26003,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -26008,7 +26013,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -26019,15 +26024,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -26061,8 +26066,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -26095,9 +26100,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -26116,9 +26121,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -26128,8 +26133,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -26156,20 +26161,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -26209,17 +26213,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -26228,7 +26234,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -26243,8 +26249,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -26270,24 +26276,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -26298,7 +26306,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -26320,8 +26328,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -26343,8 +26351,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -26488,21 +26495,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -26517,11 +26524,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -26540,13 +26547,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -26570,13 +26577,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -26591,8 +26598,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -26623,7 +26630,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -26655,9 +26662,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -26686,7 +26693,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -26704,7 +26711,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -26729,7 +26736,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -26739,8 +26745,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -26749,7 +26753,7 @@ EOF: 1, this.clear(); } - 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. @@ -26761,13 +26765,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -26777,68 +26781,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -26863,7 +26873,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -26911,24 +26921,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -26948,7 +26958,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -26958,24 +26968,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -26996,8 +27006,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -27037,14 +27046,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -27060,9 +27069,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -27073,8 +27082,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -27082,7 +27091,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -28127,7 +28136,7 @@ var bnf = { }; -var version$1 = '0.6.2-220'; // require('./package.json').version; +const version$1 = '0.6.2-220'; // require('./package.json').version; function parse(grammar) { return bnf.parser.parse(grammar); @@ -28193,7 +28202,7 @@ bnf.parser.yy.addDeclaration = function bnfAddDeclaration(grammar, decl) { if (decl.options) { if (!grammar.options) grammar.options = {}; // last occurrence of `%options` wins: - for (var i = 0; i < decl.options.length; i++) { + for (let i = 0; i < decl.options.length; i++) { grammar.options[decl.options[i][0]] = decl.options[i][1]; } } @@ -28233,9 +28242,9 @@ function parseLex(text, position) { // which matches the original input file: position = position || {}; position.range = position.range || []; - var l = position.first_line | 0; - var c = position.range[0] | 0; - var prelude = ''; + let l = position.first_line | 0; + let c = position.range[0] | 0; + let prelude = ''; if (l > 1) { prelude += (new Array(l)).join('\n'); c -= prelude.length; @@ -28260,10 +28269,10 @@ var ebnfParser = { ebnf_parser, bnf_lexer: lexParser, - version: version$1, + version: version$1 }; -var rmCommonWS$4 = helpers.rmCommonWS; +const rmCommonWS$4 = helpers.rmCommonWS; /** @@ -28289,14 +28298,14 @@ function grammarPrinter(raw, options) { case 'json5': options.format = 'json5'; break; - + case '.y': case '.yacc': options.format = 'jison'; options.showLexer = false; options.showParser = true; break; - + case '.l': case '.lex': options.format = 'jison'; @@ -28318,20 +28327,20 @@ function grammarPrinter(raw, options) { // which MAY get corrupted that way as their actual content would change then! // construct fake nesting levels to arrive at the intended start indent value: `num` - var nesting_levels = num / 2; - var pre = '// **PRE**', - post = '// **POST**'; - for ( ; nesting_levels > 0; nesting_levels--) { + let nesting_levels = num / 2; + let pre = '// **PRE**'; + let post = '// **POST**'; + for (; nesting_levels > 0; nesting_levels--) { pre = 'function x() {\n' + pre; post += '\n}'; } - src = '\n' + pre + '\n' + src + '\n' + post + '\n'; + src = '\n' + pre + '\n' + src + '\n' + post + '\n'; - var ast = helpers.parseCodeChunkToAST(src, options); - var new_src = helpers.prettyPrintAST(ast, options); + let ast = helpers.parseCodeChunkToAST(src, options); + let new_src = helpers.prettyPrintAST(ast, options); - var start = new_src.indexOf('// **PRE**'); - var end = new_src.lastIndexOf('// **POST**'); + let start = new_src.indexOf('// **PRE**'); + let end = new_src.lastIndexOf('// **POST**'); new_src = new_src .substring(start + 10, end) .trim(); @@ -28340,13 +28349,13 @@ function grammarPrinter(raw, options) { } function isEmptyObj(obj) { - var keys = obj && typeof obj === 'object' && Object.keys(obj); + let keys = obj && typeof obj === 'object' && Object.keys(obj); return keys && keys.length === 0; } function isEmptyArr(arr) { if (arr && arr instanceof Array) { - for (var i = 0, len = arr.length; i < len; i++) { + for (let i = 0, len = arr.length; i < len; i++) { if (arr[i] !== undefined) { return false; } @@ -28359,8 +28368,8 @@ function grammarPrinter(raw, options) { // Copied from Crokford's implementation of JSON // See https://github.com/douglascrockford/JSON-js/blob/e39db4b7e6249f04a195e7dd0840e610cc9e941e/json2.js#L195 // Begin - var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - meta = { // table of character substitutions + let escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; + let meta = { // table of character substitutions '\b': '\\b', '\t': '\\t', '\n': '\\n', @@ -28377,15 +28386,15 @@ function grammarPrinter(raw, options) { // sequences. escapable.lastIndex = 0; return escapable.test(string) ? '"' + string.replace(escapable, function (a) { - var c = meta[a]; + let c = meta[a]; return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }) + '"' : '"' + string + '"'; } - var ref_list; - var ref_names; + let ref_list; + let ref_names; // create a deep copy of the input, so we can delete the parts we converted and dump the remainder // so that we always output the entire thing, even when we don't know all the details about the @@ -28402,7 +28411,7 @@ function grammarPrinter(raw, options) { return from; } - for (var i = 0, len = ref_list.length; i < len; i++) { + for (let i = 0, len = ref_list.length; i < len; i++) { if (ref_list[i] === from) { return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference } @@ -28411,204 +28420,211 @@ function grammarPrinter(raw, options) { ref_names.push(sub); sub += '.'; - var to = new from.constructor(); - for (var name in from) { + let to = new from.constructor(); + for (let name in from) { to[name] = deepClone(from[name], sub + name); } return to; } - var originalInput = raw; + let originalInput = raw; raw = deepClone(raw); - var lex_out_str = ''; + let lex_out_str = ''; if (raw.lex) { var lex_pre = []; - var lex_rules = []; - var lex_post = []; - var key, src; + let lex_rules = []; + let lex_post = []; + + { + let src = raw.lex.macros; + delete raw.lex.macros; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // macros: + `); - src = raw.lex.macros; - delete raw.lex.macros; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // macros: - `); + let keylen = 0; + for (let key in src) { + keylen = Math.max(keylen, key.length); + } + console.log('macros keylen:', keylen); + keylen = ((keylen / 4) | 0) * 4 + 4; + console.log('macros keylen B:', keylen); + for (let key in src) { + lex_pre.push(padRight(key, keylen) + src[key]); + } - var keylen = 0; - for (key in src) { - keylen = Math.max(keylen, key.length); - } - console.log('macros keylen:', keylen); - keylen = ((keylen / 4) | 0) * 4 + 4; - console.log('macros keylen B:', keylen); - for (key in src) { - lex_pre.push(padRight(key, keylen) + src[key]); + lex_pre.push(rmCommonWS$4` + // END of the lexer macros. + `); } - - lex_pre.push(rmCommonWS$4` - // END of the lexer macros. - `); } - src = raw.lex.unknownDecls; - delete raw.lex.unknownDecls; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // unknown declarations: - `); + { + let src = raw.lex.unknownDecls; + delete raw.lex.unknownDecls; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // unknown declarations: + `); - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry.name; + let value = entry.value; - lex_pre.push('%' + key + ' ' + value); - } + lex_pre.push('%' + key + ' ' + value); + } - lex_pre.push(rmCommonWS$4` - // END of unknown declarations. - `); + lex_pre.push(rmCommonWS$4` + // END of unknown declarations. + `); + } } - src = raw.lex.options; - delete raw.lex.options; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // options: - `); + { + let src = raw.lex.options; + delete raw.lex.options; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // options: + `); - for (key in src) { - var value = src[key]; - if (value) { - lex_pre.push('%options ' + key + '=' + value); - } - else { - lex_pre.push('%options ' + key); + for (let key in src) { + let value = src[key]; + if (value) { + lex_pre.push('%options ' + key + '=' + value); + } else { + lex_pre.push('%options ' + key); + } } } } - src = raw.lex.startConditions; - delete raw.lex.startConditions; - if (src && !isEmptyObj(src)) { - for (key in src) { - var value = src[key]; + { + let src = raw.lex.startConditions; + delete raw.lex.startConditions; + if (src && !isEmptyObj(src)) { + for (let key in src) { + let value = src[key]; - lex_pre.push((value ? '%x ' : '%s ') + key); + lex_pre.push((value ? '%x ' : '%s ') + key); + } } } - src = raw.lex.actionInclude; - delete raw.lex.actionInclude; - if (src && src.trim()) { - lex_pre.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + { + let src = raw.lex.actionInclude; + delete raw.lex.actionInclude; + if (src && src.trim()) { + lex_pre.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + } } - src = raw.lex.rules; - delete raw.lex.rules; - if (src) { - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - key = entry[0]; - var action = indentAction(entry[1], 4); - - var actionHasLF = /[\r\n]/.test(action); - console.log('indented action:', { - entry: entry[1], - action, - actionHasLF - }); - if (key.length <= 12) { - if (!actionHasLF) { - lex_rules.push(padRight(key, 16) + indentAction(action, 16)); - } - else { - lex_rules.push(padRight(key, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); - } - } - else { - if (!actionHasLF) { + { + let src = raw.lex.rules; + delete raw.lex.rules; + if (src) { + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry[0]; + let action = indentAction(entry[1], 4); + + let actionHasLF = /[\r\n]/.test(action); + console.log('indented action:', { + entry: entry[1], + action, + actionHasLF + }); + if (key.length <= 12) { + if (!actionHasLF) { + lex_rules.push(padRight(key, 16) + indentAction(action, 16)); + } else { + lex_rules.push(padRight(key, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + } + } else if (!actionHasLF) { lex_rules.push(key, makeIndent(16) + indentAction(action, 16)); - } - else { + } else { lex_rules.push(key, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } } } - src = raw.lex.moduleInclude; - delete raw.lex.moduleInclude; - if (src && src.trim()) { - lex_post.push(indentAction(src.trim(), 0)); + { + let src = raw.lex.moduleInclude; + delete raw.lex.moduleInclude; + if (src && src.trim()) { + lex_post.push(indentAction(src.trim(), 0)); + } } - var out = ''; + { + let out = ''; - if (!isEmptyObj(raw.lex)) { - // dump the remainder as a comment: - var rem = JSON5.stringify(raw.lex, null, 2); - out += rmCommonWS$4` - /* - * Lexer stuff that's unknown to the JISON prettyPrint service: - * - * ${rem.replace(/\*\//g, '*\\/')} - */ + if (!isEmptyObj(raw.lex)) { + // dump the remainder as a comment: + let rem = JSON5.stringify(raw.lex, null, 2); + out += rmCommonWS$4` + /* + * Lexer stuff that's unknown to the JISON prettyPrint service: + * + * ${rem.replace(/\*\//g, '*\\/')} + */ - `; - } - delete raw.lex; - - out += lex_pre.join('\n') + '\n\n'; - out += rmCommonWS$4` - - %% + `; + } + delete raw.lex; - ` + lex_rules.join('\n') + '\n\n'; - if (lex_post.length > 0) { + out += lex_pre.join('\n') + '\n\n'; out += rmCommonWS$4` %% - ` + lex_post.join('\n') + '\n\n'; + ` + lex_rules.join('\n') + '\n\n'; + if (lex_post.length > 0) { + out += rmCommonWS$4` + + %% + + ` + lex_post.join('\n') + '\n\n'; + } + lex_out_str = out; } - lex_out_str = out; } - var grammar_pre = []; - var grammar_mid = []; - var ebnf_rules = []; - var bnf_rules = []; - var grammar_post = []; - var key, src; + let grammar_pre = []; + let grammar_mid = []; + let ebnf_rules = []; + let bnf_rules = []; + let grammar_post = []; - var fmtprod = function fmtprod(rule, prodset) { - var backup = deepClone(prodset); + let fmtprod = function fmtprod(rule, prodset) { + let backup = deepClone(prodset); rule += prodset[0] ? prodset[0] : '%epsilon'; - var prec = null; - var lead = rule.split(/\r\n\|\n|\r/).pop(); + let prec = null; + let lead = rule.split(/\r\n\|\n|\r/).pop(); delete prodset[0]; if (prodset.length === 3 && typeof prodset[2] === 'object') { prec = '%prec ' + prodset[2].prec; if (lead.length < 12) { rule += makeIndent(12 - lead.length); - } + } rule += ' ' + prec; delete prodset[2].prec; if (isEmptyObj(prodset[2])) { delete prodset[2]; } - } - else if (prodset.length === 2 && typeof prodset[1] === 'object') { + } else if (prodset.length === 2 && typeof prodset[1] === 'object') { prec = '%prec ' + prodset[1].prec; if (lead.length < 12) { rule += makeIndent(12 - lead.length); - } + } rule += ' ' + prec; delete prodset[1].prec; @@ -28617,84 +28633,73 @@ function grammarPrinter(raw, options) { } } if (typeof prodset[1] === 'string') { - var action = prodset[1]; + let action = prodset[1]; if (lead.length < 12 - 1) { - rule += makeIndent(12 - lead.length) + indentAction('{ ' + action + ' }', 12); - } - else { - rule += '\n' + makeIndent(12) + indentAction('{ ' + action + ' }', 12); + rule += makeIndent(12 - lead.length) + indentAction('{ ' + action + ' }', 12); + } else { + rule += '\n' + makeIndent(12) + indentAction('{ ' + action + ' }', 12); } delete prodset[1]; } if (isEmptyArr(prodset)) { prodset.length = 0; - } - else { + } else { prodset = backup; } return rule; }; - var grammarfmt = function grammarfmt(src) { - var key; - var dst = []; + let grammarfmt = function grammarfmt(src) { + let dst = []; - for (key in src) { - var prodset = src[key]; - var rule; + for (let key in src) { + let prodset = src[key]; + let rule; console.log('format one rule:', { - key, + key, prodset }); if (typeof prodset === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; + rule = fmtprod(key + ' : ', [ prodset ]) + ';'; delete src[key]; - } - else if (prodset instanceof Array) { + } else if (prodset instanceof Array) { if (prodset.length === 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; + rule = fmtprod(key + ' : ', [ prodset ]) + ';'; delete src[key]; - } - else if (prodset[0] instanceof Array) { + } else if (prodset[0] instanceof Array) { rule = fmtprod(key + ' : ', prodset[0]); rule += '\n ;'; if (prodset[0].length === 0) { delete src[key]; } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - } - else if (prodset.length > 1) { + } else if (prodset.length > 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + '\n : ', [prodset[0]]); + rule = fmtprod(key + '\n : ', [ prodset[0] ]); delete prodset[0]; - } - else if (prodset[0] instanceof Array) { + } else if (prodset[0] instanceof Array) { rule = fmtprod(key + '\n : ', prodset[0]); if (prodset[0].length === 0) { delete prodset[0]; } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - for (var i = 1, len = prodset.length; i < len; i++) { + for (let i = 1, len = prodset.length; i < len; i++) { if (typeof prodset[i] === 'string') { - rule += fmtprod('\n | ', [prodset[i]]); + rule += fmtprod('\n | ', [ prodset[i] ]); delete prodset[i]; - } - else if (prodset[i] instanceof Array) { + } else if (prodset[i] instanceof Array) { rule += fmtprod('\n | ', prodset[i]); if (prodset[i].length === 0) { delete prodset[i]; } - } - else { + } else { rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[i]; } } @@ -28704,8 +28709,7 @@ function grammarPrinter(raw, options) { delete src[key]; } } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; } dst.push(rule); @@ -28714,46 +28718,52 @@ function grammarPrinter(raw, options) { return dst; }; - src = raw.ebnf; - if (src) { - ebnf_rules = grammarfmt(src); + { + let src = raw.ebnf; + if (src) { + ebnf_rules = grammarfmt(src); - if (isEmptyObj(src)) { - delete raw.ebnf; + if (isEmptyObj(src)) { + delete raw.ebnf; + } } } - src = raw.bnf; - //delete raw.bnf; - if (src) { - bnf_rules = grammarfmt(src); + { + let src = raw.bnf; + //delete raw.bnf; + if (src) { + bnf_rules = grammarfmt(src); - if (isEmptyObj(src)) { - delete raw.bnf; + if (isEmptyObj(src)) { + delete raw.bnf; + } } } - src = raw.unknownDecls; - delete raw.unknownDecls; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // unknown declarations: - `); + { + let src = raw.unknownDecls; + delete raw.unknownDecls; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // unknown declarations: + `); - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry.name; + let value = entry.value; - lex_pre.push('%' + key + ' ' + value); - } + lex_pre.push('%' + key + ' ' + value); + } - lex_pre.push(rmCommonWS$4` - // END of unknown declarations. - `); + lex_pre.push(rmCommonWS$4` + // END of unknown declarations. + `); + } } - //src = raw.lex; + //let src = raw.lex; //delete raw.lex; //if (src) { if (lex_out_str.trim() && options.showLexer) { @@ -28771,294 +28781,305 @@ function grammarPrinter(raw, options) { `); } - src = raw.options; - delete raw.options; - if (src && !isEmptyObj(src)) { - var a = []; - for (key in src) { - var value = src[key]; - switch (key) { - default: - if (value !== true) { - a.push('options', '%options ' + key + '=' + value); - } - else { - a.push('options', '%options ' + key); - } - break; + { + let src = raw.options; + delete raw.options; + if (src && !isEmptyObj(src)) { + let a = []; + for (let key in src) { + let value = src[key]; + switch (key) { + default: + if (value !== true) { + a.push('options', '%options ' + key + '=' + value); + } else { + a.push('options', '%options ' + key); + } + break; - case 'ebnf': - if (value) { - a.push(key, '%ebnf'); - } - break; + case 'ebnf': + if (value) { + a.push(key, '%ebnf'); + } + break; - case 'type': - if (value) { - a.push(key, '%parser-type ' + value); - } - break; + case 'type': + if (value) { + a.push(key, '%parser-type ' + value); + } + break; - case 'debug': - if (typeof value !== 'boolean') { - a.push(key, '%debug ' + value); - } - else if (value) { - a.push(key, '%debug'); + case 'debug': + if (typeof value !== 'boolean') { + a.push(key, '%debug ' + value); + } else if (value) { + a.push(key, '%debug'); + } + break; } - break; } - } - var type = null; - for (var i = 0, len = a.length; i < len; i += 2) { - var t = a[i]; - var line = a[i + 1]; - if (t !== type) { - type = t; - grammar_pre.push(''); + let type = null; + for (let i = 0, len = a.length; i < len; i += 2) { + let t = a[i]; + let line = a[i + 1]; + if (t !== type) { + type = t; + grammar_pre.push(''); + } + grammar_pre.push(line); } - grammar_pre.push(line); + grammar_pre.push(''); } - grammar_pre.push(''); } - src = raw.imports; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - - grammar_pre.push('%import ' + entry.name + ' ' + entry.path); - delete entry.name; - delete entry.path; - if (isEmptyObj(entry)) { - delete src[i]; + { + let src = raw.imports; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + + grammar_pre.push('%import ' + entry.name + ' ' + entry.path); + delete entry.name; + delete entry.path; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } + } + if (clean) { + delete raw.imports; } - else { - clean = false; - } - } - if (clean) { - delete raw.imports; } } - src = raw.moduleInit; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - - grammar_pre.push('%code ' + entry.qualifier + ' ' + entry.include); - delete entry.qualifier; - delete entry.include; - if (isEmptyObj(entry)) { - delete src[i]; + { + let src = raw.moduleInit; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + + grammar_pre.push('%code ' + entry.qualifier + ' ' + entry.include); + delete entry.qualifier; + delete entry.include; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } + } + if (clean) { + delete raw.moduleInit; } - else { - clean = false; - } - } - if (clean) { - delete raw.moduleInit; } } - src = raw.operators; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var tokens = entry[1]; - var line = '%' + entry[0] + ' '; - - for (var t = 0, tlen = tokens.length; t < tlen; t++) { - line += ' ' + tokens[t]; - } + { + let src = raw.operators; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let tokens = entry[1]; + let line = '%' + entry[0] + ' '; + + for (let t = 0, tlen = tokens.length; t < tlen; t++) { + line += ' ' + tokens[t]; + } - grammar_pre.push(line); + grammar_pre.push(line); - if (entry.length === 2) { - delete src[i]; + if (entry.length === 2) { + delete src[i]; + } else { + clean = false; + } } - else { - clean = false; + if (clean) { + delete raw.operators; } } - if (clean) { - delete raw.operators; - } } - src = raw.extra_tokens; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var line = '%token ' + entry.id; - - if (entry.type) { - line += ' <' + entry.type + '>'; - delete entry.type; - } - if (entry.value) { - line += ' ' + entry.value; - delete entry.value; - } - if (entry.description) { - line += ' ' + escapeString(entry.description); - delete entry.description; - } + { + let src = raw.extra_tokens; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let line = '%token ' + entry.id; + + if (entry.type) { + line += ' <' + entry.type + '>'; + delete entry.type; + } + if (entry.value) { + line += ' ' + entry.value; + delete entry.value; + } + if (entry.description) { + line += ' ' + escapeString(entry.description); + delete entry.description; + } - grammar_pre.push(line); + grammar_pre.push(line); - delete entry.id; - if (isEmptyObj(entry)) { - delete src[i]; + delete entry.id; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } } - else { - clean = false; + if (clean) { + delete raw.extra_tokens; } } - if (clean) { - delete raw.extra_tokens; - } } - src = raw.parseParams; - delete raw.parseParams; - if (src) { - grammar_pre.push('%parse-param ' + src.join(' ')); + { + let src = raw.parseParams; + delete raw.parseParams; + if (src) { + grammar_pre.push('%parse-param ' + src.join(' ')); + } } - src = raw.start; - delete raw.start; - if (src) { - grammar_pre.push('%start ' + src); + { + let src = raw.start; + delete raw.start; + if (src) { + grammar_pre.push('%start ' + src); + } } - src = raw.moduleInclude; - delete raw.moduleInclude; - if (src && src.trim()) { - grammar_post.push(indentAction(src.trim(), 0)); + { + let src = raw.moduleInclude; + delete raw.moduleInclude; + if (src && src.trim()) { + grammar_post.push(indentAction(src.trim(), 0)); + } } - src = raw.actionInclude; - delete raw.actionInclude; - if (src && src.trim()) { - grammar_mid.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + { + let src = raw.actionInclude; + delete raw.actionInclude; + if (src && src.trim()) { + grammar_mid.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + } } - var out = ''; + { + let out = ''; - if (!isEmptyObj(raw)) { - // dump the remainder as a comment: - var rem = JSON5.stringify(raw, null, 2); - out += rmCommonWS$4` - /* - * Parser stuff that's unknown to the JISON prettyPrint service: - * - * ${rem.replace(/\*\//g, '*\\/')} - */ + if (!isEmptyObj(raw)) { + // dump the remainder as a comment: + let rem = JSON5.stringify(raw, null, 2); + out += rmCommonWS$4` + /* + * Parser stuff that's unknown to the JISON prettyPrint service: + * + * ${rem.replace(/\*\//g, '*\\/')} + */ - `; - // delete raw; - } + `; + // delete raw; + } - if (!options.showParser) { - out += lex_out_str; - } - else { - out += grammar_pre.join('\n') + '\n\n'; - out += rmCommonWS$4` + if (!options.showParser) { + out += lex_out_str; + } else { + out += grammar_pre.join('\n') + '\n\n'; + out += rmCommonWS$4` - %% + %% - `; - if (grammar_mid.length > 0) { - out += grammar_mid.join('\n') + '\n\n'; - } - if (ebnf_rules.length > 0) { - if (bnf_rules.length > 0) { + `; + if (grammar_mid.length > 0) { + out += grammar_mid.join('\n') + '\n\n'; + } + if (ebnf_rules.length > 0) { + if (bnf_rules.length > 0) { // dump the original EBNF grammar as source and dump the BNF derivative as COMMENT: - var bnf_deriv = bnf_rules.join('\n\n'); - var a = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); + let bnf_deriv = bnf_rules.join('\n\n'); + let a = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - out += rmCommonWS$4` - // - // JISON says: - // - // This is a EBNF grammar. The resulting **BNF** grammar has been - // reproduced here for your convenience: - // - // ---------------------------- START --------------------------- - ${a.join('\n')} - // ---------------------------- END OF BNF grammar -------------- - // + out += rmCommonWS$4` + // + // JISON says: + // + // This is a EBNF grammar. The resulting **BNF** grammar has been + // reproduced here for your convenience: + // + // ---------------------------- START --------------------------- + ${a.join('\n')} + // ---------------------------- END OF BNF grammar -------------- + // - `; + `; + } + out += ebnf_rules.join('\n\n') + '\n\n'; + } else if (bnf_rules.length > 0) { + out += bnf_rules.join('\n\n') + '\n\n'; } - out += ebnf_rules.join('\n\n') + '\n\n'; - } - else if (bnf_rules.length > 0) { - out += bnf_rules.join('\n\n') + '\n\n'; - } - if (grammar_post.length > 0) { - out += rmCommonWS$4` + if (grammar_post.length > 0) { + out += rmCommonWS$4` - %% + %% - ` + grammar_post.join('\n') + '\n\n'; + ` + grammar_post.join('\n') + '\n\n'; + } } - } - if (options.format === 'json5') { - var a = out.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); + if (options.format === 'json5') { + let a = out.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - out = rmCommonWS$4` - // - // JISON says: - // - // The JISON ${options.showParser ? 'grammar' : 'lexer'} has been - // reproduced here for your convenience: - // - // ---------------------------- START --------------------------- - ${a.join('\n')} - // ---------------------------- END ----------------------------- - // + out = rmCommonWS$4` + // + // JISON says: + // + // The JISON ${options.showParser ? 'grammar' : 'lexer'} has been + // reproduced here for your convenience: + // + // ---------------------------- START --------------------------- + ${a.join('\n')} + // ---------------------------- END ----------------------------- + // - `; + `; - // process the original input once again: this time via JSON5 - raw = deepClone(originalInput); + // process the original input once again: this time via JSON5 + raw = deepClone(originalInput); - if (!options.showLexer) { - delete raw.lex; - out += JSON5.stringify(raw, null, 2); - } - else if (!options.showParser) { - out += JSON5.stringify(raw.lex, null, 2); + if (!options.showLexer) { + delete raw.lex; + out += JSON5.stringify(raw, null, 2); + } else if (!options.showParser) { + out += JSON5.stringify(raw.lex, null, 2); + } } - } - return out; + return out; + } } // Jison, an LR(0), SLR(1), LARL(1), LR(1) Parser Generator -var rmCommonWS$5 = helpers.rmCommonWS; -var mkIdentifier$4 = helpers.mkIdentifier; -var code_exec$2 = helpers.exec; +const rmCommonWS$5 = helpers.rmCommonWS; +const mkIdentifier$4 = helpers.mkIdentifier; +const code_exec$1 = helpers.exec; -var version$2 = '0.6.2-220'; +const version$2 = '0.7.0-220'; -var devDebug = 0; +let devDebug = 0; function chkBugger$3(src) { src = '' + src; @@ -29074,7 +29095,7 @@ function chkBugger$3(src) { // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE$3 = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -var Jison$1 = { +let Jison$1 = { version: version$2 }; @@ -29089,8 +29110,8 @@ const defaultJisonOptions = { compressTables: 2, // 0, 1, 2 outputDebugTables: false, noDefaultResolve: false, - defaultActionMode: ["classic", "merge"], // {classic, ast, none, skip}, {classic, ast, merge, none, skip} - testCompileActionCode: "parser:*,lexer:*", + defaultActionMode: [ 'classic', 'merge' ], // {classic, ast, none, skip}, {classic, ast, merge, none, skip} + testCompileActionCode: 'parser:*,lexer:*', noTryCatch: false, hasPartialLrUpgradeOnConflict: true, errorRecoveryTokenDiscardCount: 3, @@ -29148,7 +29169,7 @@ const defaultJisonOptions = { actionsUseYYSTACKPOINTER: false, actionsUseYYTEXT: false, hasErrorRecovery: false, - hasErrorReporting: false, + hasErrorReporting: false }; Jison$1.defaultJisonOptions = defaultJisonOptions; @@ -29169,25 +29190,25 @@ Jison$1.defaultJisonOptions = defaultJisonOptions; // Return a fresh set of options. /** @public */ function mkStdOptions$1(...args) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - //var args = Array.prototype.concat.apply([], args); + let opts = {}; + //let args = Array.prototype.concat.apply([], args); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(Jison$1.defaultJisonOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; - for (var p in o) { + for (let p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { o2[mkIdentifier$4(p)] = o[p]; } @@ -29219,7 +29240,7 @@ function mkStdOptions$1(...args) { } // fall through case 'string': - var a = String(o2.defaultActionMode).split(',').map(function (m) { + let a = String(o2.defaultActionMode).split(',').map(function (m) { return m.trim(); }); if (a.length === 1) { @@ -29283,7 +29304,7 @@ function mkStdOptions$1(...args) { } // now see if we have an overriding option here: - for (var p in o2) { + for (let p in o2) { if (h.call(o2, p)) { if (typeof o2[p] !== 'undefined') { opts[p] = o2[p]; @@ -29299,7 +29320,7 @@ function mkStdOptions$1(...args) { function prepExportStructures$1(options) { // set up the 'option' `exportAllTables` as a hash object for returning // all generated tables to the caller - var exportDest = options.exportAllTables; + let exportDest = options.exportAllTables; if (!exportDest || typeof exportDest !== 'object') { exportDest = { enabled: !!exportDest @@ -29311,7 +29332,7 @@ function prepExportStructures$1(options) { // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -29332,128 +29353,128 @@ function prepExportStructures$1(options) { // Otherwise return the *parsed* grammar and optional lexer specs as they have // been processed through EBNFParser and LEXParser respectively. function autodetectAndConvertToJSONformat$1(grammar, optionalLexerSection, options) { - var chk_g = null; - var chk_l = null; - var ex1, err; + let chk_g = null; + let chk_l = null; + let ex1, err; if (typeof grammar === 'string') { - if (options.json) { - try { - chk_g = JSON5.parse(grammar); + if (options.json) { + try { + chk_g = JSON5.parse(grammar); - // When JSON5-based parsing of the grammar succeeds, this implies the grammar is specified in `JSON mode` - // *OR* there's a JSON/JSON5 format error in the input: - } catch (e) { - ex1 = e; + // When JSON5-based parsing of the grammar succeeds, this implies the grammar is specified in `JSON mode` + // *OR* there's a JSON/JSON5 format error in the input: + } catch (e) { + ex1 = e; + } } - } - if (!chk_g) { - try { - chk_g = ebnfParser.parse(grammar); - } catch (e) { - if (options.json) { - // When both JSON5 and JISON input modes barf a hairball, assume the most important - // error is the JISON one (show that one first!), while it MAY be a JSON5 format - // error that triggered it (show that one last!). - // - // Also check for common JISON errors which are obviously never triggered by any - // odd JSON5 input format error: when we encounter such an error here, we don't - // confuse matters and forget about the JSON5 fail as it's irrelevant: - const commonErrors = [ - /does not compile/, - /you did not correctly separate trailing code/, - /You did not specify/, - /You cannot specify/, - /must be qualified/, - /%start/, - /%token/, - /%import/, - /%include/, - /%options/, - /%parse-params/, - /%parser-type/, - /%epsilon/, - /definition list error/, - /token list error/, - /declaration error/, - /should be followed/, - /should be separated/, - /an error in one or more of your lexer regex rules/, - /an error in your lexer epilogue/, - /unsupported definition type/, - ]; - var cmnerr = commonErrors.filter(function check(re) { - return e.message.match(re); - }); - if (cmnerr.length > 0) { - err = e; + if (!chk_g) { + try { + chk_g = ebnfParser.parse(grammar); + } catch (e) { + if (options.json) { + // When both JSON5 and JISON input modes barf a hairball, assume the most important + // error is the JISON one (show that one first!), while it MAY be a JSON5 format + // error that triggered it (show that one last!). + // + // Also check for common JISON errors which are obviously never triggered by any + // odd JSON5 input format error: when we encounter such an error here, we don't + // confuse matters and forget about the JSON5 fail as it's irrelevant: + const commonErrors = [ + /does not compile/, + /you did not correctly separate trailing code/, + /You did not specify/, + /You cannot specify/, + /must be qualified/, + /%start/, + /%token/, + /%import/, + /%include/, + /%options/, + /%parse-params/, + /%parser-type/, + /%epsilon/, + /definition list error/, + /token list error/, + /declaration error/, + /should be followed/, + /should be separated/, + /an error in one or more of your lexer regex rules/, + /an error in your lexer epilogue/, + /unsupported definition type/ + ]; + let cmnerr = commonErrors.filter(function check(re) { + return e.message.match(re); + }); + if (cmnerr.length > 0) { + err = e; + } else { + err = new Error('Could not parse jison grammar in JSON AUTODETECT mode:\nin JISON Mode we get Error: ' + e.message + '\nwhile JSON5 Mode produces Error: ' + ex1.message); + err.secondary_exception = e; + err.stack = ex1.stack; + } } else { - err = new Error('Could not parse jison grammar in JSON AUTODETECT mode:\nin JISON Mode we get Error: ' + e.message + '\nwhile JSON5 Mode produces Error: ' + ex1.message); - err.secondary_exception = e; - err.stack = ex1.stack; + err = new Error('Could not parse jison grammar\nError: ' + e.message); + err.stack = e.stack; } - } else { - err = new Error('Could not parse jison grammar\nError: ' + e.message); - err.stack = e.stack; + throw err; } - throw err; } - } - // Save time! Don't reparse the entire grammar *again* inside the code generators when that's not necessary: - // if (chk_g) { - // grammar = chk_g; - // } + // Save time! Don't reparse the entire grammar *again* inside the code generators when that's not necessary: + // if (chk_g) { + // grammar = chk_g; + // } } else { chk_g = grammar; } // Now the same treatment for the lexer: if (chk_g && optionalLexerSection) { - if (chk_g.lex) { - throw new Error('Cannot invoke with both a lexer section in the grammar input and a separate lexer input at the same time!'); - } + if (chk_g.lex) { + throw new Error('Cannot invoke with both a lexer section in the grammar input and a separate lexer input at the same time!'); + } - if (typeof optionalLexerSection === 'string') { - if (options.json) { - try { - chk_l = JSON5.parse(optionalLexerSection); + if (typeof optionalLexerSection === 'string') { + if (options.json) { + try { + chk_l = JSON5.parse(optionalLexerSection); - // When JSON5-based parsing of the lexer spec succeeds, this implies the lexer spec is specified in `JSON mode` - // *OR* there's a JSON/JSON5 format error in the input: - } catch (e) { - ex1 = e; - } - } - if (!chk_l) { - // // WARNING: the lexer may receive options specified in the **grammar spec file**, - // // hence we should mix the options to ensure the lexParser always - // // receives the full set! - // // - // // make sure all options are 'standardized' before we go and mix them together: - // options = mkStdOptions(grammar.options, options); - try { - chk_l = lexParser.parse(optionalLexerSection); - } catch (e) { - if (options.json) { - err = new Error('Could not parse lexer spec in JSON AUTODETECT mode\nError: ' + ex1.message + ' (' + e.message + ')'); - err.secondary_exception = e; - err.stack = ex1.stack; - } else { - err = new Error('Could not parse lexer spec\nError: ' + e.message); - err.stack = e.stack; - } - throw err; - } + // When JSON5-based parsing of the lexer spec succeeds, this implies the lexer spec is specified in `JSON mode` + // *OR* there's a JSON/JSON5 format error in the input: + } catch (e) { + ex1 = e; + } + } + if (!chk_l) { + // // WARNING: the lexer may receive options specified in the **grammar spec file**, + // // hence we should mix the options to ensure the lexParser always + // // receives the full set! + // // + // // make sure all options are 'standardized' before we go and mix them together: + // options = mkStdOptions(grammar.options, options); + try { + chk_l = lexParser.parse(optionalLexerSection); + } catch (e) { + if (options.json) { + err = new Error('Could not parse lexer spec in JSON AUTODETECT mode\nError: ' + ex1.message + ' (' + e.message + ')'); + err.secondary_exception = e; + err.stack = ex1.stack; + } else { + err = new Error('Could not parse lexer spec\nError: ' + e.message); + err.stack = e.stack; + } + throw err; + } + } + } else { + chk_l = optionalLexerSection; } - } else { - chk_l = optionalLexerSection; - } - // Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: - if (chk_l) { - chk_g.lex = chk_l; - } + // Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: + if (chk_l) { + chk_g.lex = chk_l; + } } return chk_g; @@ -29470,7 +29491,7 @@ if (typeof console !== 'undefined' && console.log) { // wrap console.log to prevent 'Illegal Invocation' exceptions when Jison.print() is used, e.g. // in the web tryout pages where this code is employed. Jison$1.print = function console_log(/* ... */) { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); args.unshift(''); // prevent `%.` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args console.log.apply(console, args); }; @@ -29491,7 +29512,7 @@ if (typeof console !== 'undefined' && console.log) { Jison$1.Lexer = RegExpLexer; Jison$1.ebnfParser = ebnfParser; Jison$1.lexParser = lexParser; -Jison$1.codeExec = code_exec$2; +Jison$1.codeExec = code_exec$1; Jison$1.XRegExp = XRegExp; Jison$1.recast = recast; Jison$1.astUtils = astUtils; @@ -29506,7 +29527,7 @@ function each(obj, func) { if (typeof obj.forEach === 'function') { obj.forEach(func); } else { - var p; + let p; for (p in obj) { if (obj.hasOwnProperty(p)) { func.call(obj, obj[p], p, obj); @@ -29536,10 +29557,10 @@ function union(a, b) { // site for this jscore grammar as the naive scan consistently // outperformed the old smarter hash-object code for smaller // thresholds (10, 20, 32, 42!) - var k, len; + let k, len; if (a.length > 52) { - var ar = {}; + let ar = {}; for (k = 0, len = a.length; k < len; k++) { ar[a[k]] = true; } @@ -29549,7 +29570,7 @@ function union(a, b) { } } } else { - var bn = []; + let bn = []; for (k = 0, len = b.length; k < len; k++) { if (a.indexOf(b[k]) < 0) { bn.push(b[k]); @@ -29560,17 +29581,17 @@ function union(a, b) { return a; } -var Nonterminal = typal.construct({ +let Nonterminal = typal.construct({ constructor: function Nonterminal(symbol) { this.symbol = symbol; - this.productions = new Set(); + this.productions = new Set$1(); this.first = []; this.follows = []; this.nullable = false; }, toString: function Nonterminal_toString() { - var str = this.symbol; - var attr_str = []; + let str = this.symbol; + let attr_str = []; if (this.nullable) { attr_str.push('nullable'); @@ -29587,7 +29608,7 @@ var Nonterminal = typal.construct({ } }); -var Production = typal.construct({ +let Production = typal.construct({ constructor: function Production(symbol, handle, id, handle_aliases, handle_action) { this.symbol = symbol; this.handle = handle; @@ -29601,9 +29622,9 @@ var Production = typal.construct({ this.reachable = false; }, toString: function Production_toString() { - var str = this.symbol; + let str = this.symbol; - var attr_str = []; + let attr_str = []; if (this.nullable) { attr_str.push('~'); @@ -29623,9 +29644,9 @@ var Production = typal.construct({ return str; }, describe: function Production_describe() { - var str = this.symbol; + let str = this.symbol; - var attr_str = []; + let attr_str = []; if (this.nullable) { attr_str.push('nullable'); @@ -29646,7 +29667,7 @@ var Production = typal.construct({ -var generator = typal.beget(); +let generator = typal.beget(); // `optionalLexerSection` is an optional {String} argument, specifying the lexer rules. // May only be specified when the specified `grammar` also is a yet-unparsed @@ -29721,11 +29742,11 @@ var generator = typal.beget(); generator.constructor = function Jison_Generator(grammar, optionalLexerSection, options) { // pick the correct argument for the `options` for this call: if (!options && optionalLexerSection && typeof optionalLexerSection !== 'string') { - options = optionalLexerSection; - optionalLexerSection = null; + options = optionalLexerSection; + optionalLexerSection = null; } // and standardize it: - var preliminary_options = mkStdOptions$1(options); + let preliminary_options = mkStdOptions$1(options); grammar = autodetectAndConvertToJSONformat$1(grammar, optionalLexerSection, preliminary_options); @@ -29773,7 +29794,7 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, // } // calculate the input path; if none is specified, it's the present working directory - var inpath = options.file || options.outfile || './dummy'; + let inpath = options.file || options.outfile || './dummy'; inpath = path$1.normalize(inpath); options.inputPath = path$1.dirname(inpath); options.inputFilename = path$1.basename(inpath); @@ -29804,7 +29825,7 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, this.processGrammar(grammar); if (grammar.lex) { - var lexer_options = { + let lexer_options = { // include the knowledge about which parser/lexer // features will actually be *used* by the environment: // @@ -29859,7 +29880,7 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, exportAST: this.options.exportAST, prettyCfg: this.options.prettyCfg, pre_lex: this.options.pre_lex, - post_lex: this.options.post_lex, + post_lex: this.options.post_lex }; this.lexer = new RegExpLexer(grammar.lex, null, this.terminals_, lexer_options); @@ -29867,10 +29888,10 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, }; generator.processGrammar = function processGrammarDef(grammar) { - var bnf = grammar.bnf, - tokens = grammar.tokens, - nonterminals = this.nonterminals = {}, - productions = this.productions; + let bnf = grammar.bnf; + let tokens = grammar.tokens; + let nonterminals = this.nonterminals = {}; + let productions = this.productions; if (!grammar.bnf && grammar.ebnf) { bnf = grammar.bnf = ebnfParser.transform(grammar.ebnf); @@ -29886,18 +29907,18 @@ generator.processGrammar = function processGrammarDef(grammar) { // did the grammar user also provide a predefined set of symbols to be (re)used with this grammar? // (This is used when you want to generate multiple lexers and parsers which share a common symbol set // so as to make the parsers and lexers mutually interchangeable.) - var predefined_symbols = null; + let predefined_symbols = null; if (grammar.imports) { - var symbols_import = grammar.imports.find(function (el, idx) { + let symbols_import = grammar.imports.find(function (el, idx) { if (el.name === 'symbols') { return el; } return false; }); if (symbols_import) { - var filepath = path$1.resolve(symbols_import.path); + let filepath = path$1.resolve(symbols_import.path); - var source = fs.readFileSync(filepath, 'utf8'); + let source = fs.readFileSync(filepath, 'utf8'); // It's either a JSON file or a JISON generated output file: // // symbols_: { @@ -29907,7 +29928,7 @@ generator.processGrammar = function processGrammarDef(grammar) { predefined_symbols = JSON5.parse(source); } catch (ex) { try { - var m = /[\r\n]\s*symbols_:\s*(\{[\s\S]*?\}),\s*[\r\n]/.exec(source); + let m = /[\r\n]\s*symbols_:\s*(\{[\s\S]*?\}),\s*[\r\n]/.exec(source); if (m && m[1]) { source = m[1]; predefined_symbols = JSON5.parse(source); @@ -29922,18 +29943,18 @@ generator.processGrammar = function processGrammarDef(grammar) { } // Make sure all predefined symbols are unique and *numeric* and do not include predefined tokens JISON already defines to a fixed ID on its own: - delete predefined_symbols['$accept']; - delete predefined_symbols['$end']; - delete predefined_symbols['error']; - delete predefined_symbols['$eof']; - delete predefined_symbols['EOF']; + delete predefined_symbols.$accept; + delete predefined_symbols.$end; + delete predefined_symbols.error; + delete predefined_symbols.$eof; + delete predefined_symbols.EOF; - var symdef_uniq_check = {}; + let symdef_uniq_check = {}; // Only these symbols are allowed to have the values 1 or 2: symdef_uniq_check[1] = 'EOF'; symdef_uniq_check[2] = 'error'; Object.keys(predefined_symbols).forEach(function cvt_symbol_id_to_numeric(sym) { - var v = predefined_symbols[sym]; + let v = predefined_symbols[sym]; // Symbol value may be defined as boolean TRUE, in which case we let JISON pick the value for us: if (v === true) return; @@ -29941,17 +29962,17 @@ generator.processGrammar = function processGrammarDef(grammar) { // Symbol value may be defined as a one-character string: if (typeof v !== 'number') { if (typeof v !== 'string' || v.length !== 1) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a non-numeric symbol ID value must be a single-character string.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a non-numeric symbol ID value must be a single-character string."); } v = v.charCodeAt(0); } - v = v | 0; + v |= 0; if (!v || v < 0) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a symbol ID value must be an integer value, 3 or greater.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a symbol ID value must be an integer value, 3 or greater."); } if (symdef_uniq_check[v]) { if (symdef_uniq_check[v] !== sym) { - throw new Error('Error: `%import symbols `: symbol table contains duplicate ID values for keys \'' + sym + '\' and \'' + symdef_uniq_check[v] + '\''); + throw new Error("Error: `%import symbols `: symbol table contains duplicate ID values for keys '" + sym + "' and '" + symdef_uniq_check[v] + "'"); } } symdef_uniq_check[v] = sym; @@ -29960,15 +29981,15 @@ generator.processGrammar = function processGrammarDef(grammar) { } } - var symbols = this.symbols = []; + let symbols = this.symbols = []; // calculate precedence of operators - var operators = this.operators = processOperators(grammar.operators); + let operators = this.operators = processOperators(grammar.operators); // build productions from CFG and calculate the symbol sets (terminals and nonterminals) and their name-to-ID mappings this.buildProductions(bnf, productions, nonterminals, symbols, operators, predefined_symbols, grammar.extra_tokens); if (tokens) { - var termset = this.terminals.filter(function (t) { + let termset = this.terminals.filter(function (t) { switch (t) { case 'EOF': case 'error': @@ -29980,7 +30001,7 @@ generator.processGrammar = function processGrammarDef(grammar) { return true; } }); - var diffset = termset.filter(function (t) { + let diffset = termset.filter(function (t) { return tokens.indexOf(t) === -1; }); diffset = diffset.concat(tokens.filter(function (t) { @@ -30037,7 +30058,7 @@ generator.augmentGrammar = function augmentGrammar(grammar) { // return true; // the default parse result if the rule actions don't produce anything // %} // - var acceptProduction = new Production('$accept', [this.startSymbol, '$end'], 0); + let acceptProduction = new Production('$accept', [ this.startSymbol, '$end' ], 0); this.productions.unshift(acceptProduction); // prepend parser tokens // moved to generator.buildProductions() @@ -30056,14 +30077,13 @@ generator.augmentGrammar = function augmentGrammar(grammar) { // Mark unused productions generator.signalUnusedProductions = function () { - var mark = {}; + let mark = {}; - var productions = this.productions; - var nonterminals = this.nonterminals; - var i, len, nt, sym; + let productions = this.productions; + let nonterminals = this.nonterminals; - for (i = 0, len = nonterminals.length; i < len; i++) { - nt = nonterminals[i]; + for (let i = 0, len = nonterminals.length; i < len; i++) { + let nt = nonterminals[i]; assert$1(nt.symbol); mark[nt.symbol] = false; } @@ -30074,15 +30094,15 @@ generator.signalUnusedProductions = function () { assert$1(nt.symbol); mark[nt.symbol] = true; - var prods = nt.productions; + let prods = nt.productions; assert$1(prods); prods.forEach(function (p) { assert$1(p.symbol === nt.symbol); assert$1(p.handle); - var rhs = p.handle; + let rhs = p.handle; - for (var j = 0, len = rhs.length; j < len; j++) { - var sym = rhs[j]; + for (let j = 0, len = rhs.length; j < len; j++) { + let sym = rhs[j]; assert$1(!sym ? !nonterminals[sym] : true); if (nonterminals[sym] && !mark[sym]) { traverseGrammar(nonterminals[sym]); @@ -30091,15 +30111,15 @@ generator.signalUnusedProductions = function () { }); } - traverseGrammar(nonterminals['$accept' /* this.startSymbol */ ]); + traverseGrammar(nonterminals['$accept' /* this.startSymbol */]); // now any production which is not yet marked is *unused*: - for (sym in mark) { - nt = nonterminals[sym]; + for (let sym in mark) { + let nt = nonterminals[sym]; assert$1(nt); - var prods = nt.productions; + let prods = nt.productions; assert$1(prods); - var in_use = mark[sym]; + let in_use = mark[sym]; prods.forEach(function (p) { assert$1(p); if (in_use) { @@ -30128,8 +30148,8 @@ generator.signalUnusedProductions = function () { // set precedence and associativity of operators function processOperators(ops) { if (!ops) return {}; - var operators = {}; - for (var i = 0, k, prec; (prec = ops[i]); i++) { + let operators = {}; + for (let i = 0, k, prec; (prec = ops[i]); i++) { for (k = 1; k < prec.length; k++) { operators[prec[k]] = { precedence: i + 1, @@ -30144,8 +30164,8 @@ function processOperators(ops) { // // Note that the first line doesn't count as the chunk is very probably trimmed! function reindentCodeBlock(action, indent_level) { - var width = 0; - var lines = action + let width = 0; + let lines = action .trim() .split('\n') // measure the indent: @@ -30162,7 +30182,7 @@ function reindentCodeBlock(action, indent_level) { return s.replace(/\t/g, ' '); }); - var m = /^[ ]+/.exec(line); + let m = /^[ ]+/.exec(line); if (m) { width = Math.min(m[0].length, width); } @@ -30173,8 +30193,8 @@ function reindentCodeBlock(action, indent_level) { .map(function checkIndentation(line, idx) { line = line .replace(/^[ ]*/, function adjustIndent(s) { - var l = Math.max(s.length - width, 0) + indent_level; - var shift = (new Array(l + 1)).join(' '); + let l = Math.max(s.length - width, 0) + indent_level; + let shift = (new Array(l + 1)).join(' '); return shift; }); return line; @@ -30185,21 +30205,21 @@ function reindentCodeBlock(action, indent_level) { generator.buildProductions = function buildProductions(bnf, productions, nonterminals, symbols, operators, predefined_symbols, descriptions) { - var self = this; - var prods, symbol, symId; - var productions_ = []; - var symbols_ = {}; - var descriptions_ = {}; - var usedSymbolIds = [/* $accept = 0 */ true, /* $end = 1 */ true, /* error = 2 */ true]; - var usedSymbolIdsLowIndex = 3; + let self = this; + let prods, symId; + let productions_ = []; + let symbols_ = {}; + let descriptions_ = {}; + let usedSymbolIds = [/* $accept = 0 */ true, /* $end = 1 */ true, /* error = 2 */ true ]; + let usedSymbolIdsLowIndex = 3; // set up the required symbols `$accept` and `$end` (a.k.a. EOF) and make sure they occupy the expected slots: this.EOF = '$end'; symbols_.$accept = 0; symbols_[this.EOF] = 1; - symbols_['$eof'] = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! - symbols_['EOF'] = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.$eof = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.EOF = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! symbols[0] = '$accept'; symbols[1] = this.EOF; @@ -30210,7 +30230,7 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm symbols[2] = 'error'; if (predefined_symbols) { - for (symbol in predefined_symbols) { + for (let symbol in predefined_symbols) { symId = predefined_symbols[symbol]; if (symId === true) { // add symbol to queue which must be assigned a value by JISON; after all the other predefined symbols have been processed. @@ -30233,7 +30253,7 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm // preferably assign readable ASCII-range token IDs to tokens added from the predefined list // but only when maximum table compression isn't demanded: usedSymbolIdsLowIndex = ((this.options.compressTables | 0) < 2 ? 32 : 3); - for (symbol in predefined_symbols) { + for (let symbol in predefined_symbols) { symId = predefined_symbols[symbol]; addSymbol(symbol); } @@ -30253,11 +30273,11 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm } - var hasErrorRecovery = false; // has error recovery + let hasErrorRecovery = false; // has error recovery // Produce the next available unique symbolID: function getNextSymbolId() { - for (var i = usedSymbolIdsLowIndex; ; i++) { + for (let i = usedSymbolIdsLowIndex; ; i++) { if (!usedSymbolIds[i]) { usedSymbolIds[i] = true; usedSymbolIdsLowIndex = i + 1; @@ -30268,7 +30288,7 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm function addSymbol(s) { if (s && !symbols_[s]) { - var i; + let i; // assign the Unicode codepoint index to single-character symbols, // but only when maximum table compression isn't demanded: @@ -30292,46 +30312,45 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm // `this` is options object with `maxTokenLength` option to guide us which literal tokens we want to process: function collectLiteralTokensInProduction(handle) { - var rhs, i, sym; + let rhs; - try{ - if (devDebug) ; + try { + if (devDebug) ; - var maxlen = this.maxTokenLength || Infinity; + let maxlen = this.maxTokenLength || Infinity; - if (handle.constructor === Array) { - var rhs_i; - rhs = (typeof handle[0] === 'string') ? - splitStringIntoSymbols(handle[0]) : - handle[0].slice(0); + if (handle.constructor === Array) { + rhs = (typeof handle[0] === 'string') ? + splitStringIntoSymbols(handle[0]) : + handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; - // check for aliased names, e.g., id[alias] and strip them - rhs_i = sym.match(new XRegExp(`\\[${ID_REGEX_BASE$3}\\]$`)); - if (rhs_i) { - sym = sym.substr(0, sym.length - rhs_i[0].length); - } + for (let i = 0; i < rhs.length; i++) { + let sym = rhs[i]; + // check for aliased names, e.g., id[alias] and strip them + let rhs_i = sym.match(new XRegExp(`\\[${ID_REGEX_BASE$3}\\]$`)); + if (rhs_i) { + sym = sym.substr(0, sym.length - rhs_i[0].length); + } - if (!bnf[sym] && sym.length <= maxlen) { - addSymbol(sym); + if (!bnf[sym] && sym.length <= maxlen) { + addSymbol(sym); + } } - } - } else { - // no action -> don't care about aliases; strip them. - handle = handle.replace(new XRegExp(`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); - rhs = splitStringIntoSymbols(handle); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; - if (!bnf[sym] && sym.length <= maxlen) { - addSymbol(sym); + } else { + // no action -> don't care about aliases; strip them. + handle = handle.replace(new XRegExp(`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); + rhs = splitStringIntoSymbols(handle); + for (let i = 0; i < rhs.length; i++) { + let sym = rhs[i]; + if (!bnf[sym] && sym.length <= maxlen) { + addSymbol(sym); + } } } + } catch (ex) { + console.error(ex, '\ncollectLiteralTokensInProduction: ', this.symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { rhs }); + throw ex; } - }catch (ex) { -console.error(ex, '\ncollectLiteralTokensInProduction: ', symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { i, sym, rhs }); -throw ex; - } } // Before we go process the grammar for real, we collect the 'literal' non-terminals and add them to the symbol table @@ -30339,8 +30358,8 @@ throw ex; // which helps debugging/diagnosis of generated grammars. // (This is why previously we had set `usedSymbolIdsLowIndex` to 127 instead of 3!) - var prodsLUT = {}; - for (symbol in bnf) { + let prodsLUT = {}; + for (let symbol in bnf) { if (!bnf.hasOwnProperty(symbol)) continue; if (typeof bnf[symbol] === 'string') { @@ -30353,21 +30372,23 @@ throw ex; } // First we collect all single-character literal tokens: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: 1 + maxTokenLength: 1, + symbol }); } // Next we collect all other literal tokens: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: Infinity + maxTokenLength: Infinity, + symbol }); } @@ -30376,7 +30397,7 @@ throw ex; // for each of those: nonterminals should all have IDs assigned before they // should be processed as part of a *production* rule, where these MAY be // referenced: - for (symbol in bnf) { + for (let symbol in bnf) { if (!bnf.hasOwnProperty(symbol)) continue; addSymbol(symbol); @@ -30385,15 +30406,15 @@ throw ex; // now that we have collected all nonterminals in our symbol table, it's finally // time to process the productions: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; - prods.forEach(buildProduction); + prods.forEach(buildProduction, { symbol }); } - var terms = [], - terms_ = {}; + let terms = []; + let terms_ = {}; each(symbols_, function (id, sym) { // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number @@ -30409,7 +30430,7 @@ throw ex; // fix error recovery related options now that we know whether we actually have any recovery // rules at all: if (!this.hasErrorRecovery) { - var chk_er_opt = function check_error_recovery_option(opt, label) { + let chk_er_opt = function check_error_recovery_option(opt, label) { if (self.options[opt]) { self.options[opt] = false; self.warn('The grammar does not have any error recovery rules, so using the ' + label + ' is rather useless.'); @@ -30421,9 +30442,9 @@ throw ex; // Hmmmm... why would lexer errors need to be NON-recoverable when there's no ERROR rules in the GRAMMAR?! chk_er_opt('lexerErrorsAreRecoverable', 'lexer-errors-are-recoverable feature/option'); - chk_er_opt('parseActionsUseYYRECOVERING', 'YYRECOVERING macro/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYERROK', 'yyerrok() function/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYCLEARIN', 'yyclearin() function/API in grammar rules\' action code'); + chk_er_opt('parseActionsUseYYRECOVERING', "YYRECOVERING macro/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYERROK', "yyerrok() function/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYCLEARIN', "yyclearin() function/API in grammar rules' action code"); } this.terminals = terms; @@ -30442,8 +30463,8 @@ throw ex; function splitStringIntoSymbols(rhs) { // when there's no literal tokens in there, we can fast-track this baby: rhs = rhs.trim(); - var pos1 = rhs.indexOf("'"); - var pos2 = rhs.indexOf('"'); + let pos1 = rhs.indexOf("'"); + let pos2 = rhs.indexOf('"'); if (pos1 < 0 && pos2 < 0) { return rhs.split(' '); } @@ -30451,10 +30472,10 @@ throw ex; // // rhs has at least one literal: we will need to parse the rhs into tokens // with a little more effort now. - var tokens = []; + let tokens = []; while (pos1 >= 0 || pos2 >= 0) { - var pos = pos1; - var marker = "'"; + let pos = pos1; + let marker = "'"; if (pos < 0) { assert$1(pos2 >= 0); pos = pos2; @@ -30463,7 +30484,7 @@ throw ex; pos = pos2; marker = '"'; } - var ls = rhs.substr(0, pos).trim(); + let ls = rhs.substr(0, pos).trim(); if (ls.length > 0) { tokens.push.apply(tokens, ls.split(' ')); } @@ -30472,7 +30493,7 @@ throw ex; // // Edge case: token MAY include the ESCAPED MARKER... or other escapes! // Hence we need to skip over ALL escapes inside the token! - var pos3 = rhs.indexOf('\\'); + let pos3 = rhs.indexOf('\\'); pos = rhs.indexOf(marker); ls = ''; while (pos3 >= 0 && pos3 < pos) { @@ -30487,7 +30508,7 @@ throw ex; ls += rhs.substr(0, pos); // check for aliased literals, e.g., `'>'[gt]` and keep it and the alias together rhs = rhs.substr(pos + 1); - var alias = rhs.match(new XRegExp(`^\\[${ID_REGEX_BASE$3}\\]`)); + let alias = rhs.match(new XRegExp(`^\\[${ID_REGEX_BASE$3}\\]`)); if (alias) { ls += alias[0]; rhs = rhs.substr(alias[0].length); @@ -30507,22 +30528,21 @@ throw ex; return tokens; } + // options object { symbol } is `this` for this functon/callback: function buildProduction(handle) { - var r, rhs, i, - precedence_override, - aliased = [], - action = null; + let rhs; + let precedence_override = null; + let aliased = []; + let action = null; if (handle.constructor === Array) { - var rhs_i; - rhs = (typeof handle[0] === 'string') ? - splitStringIntoSymbols(handle[0]) : - handle[0].slice(0); + splitStringIntoSymbols(handle[0]) : + handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // check for aliased names, e.g., id[alias] and strip them - rhs_i = rhs[i].match(new XRegExp(`\\[${ID_REGEX_BASE$3}\\]$`)); + let rhs_i = rhs[i].match(new XRegExp(`\\[${ID_REGEX_BASE$3}\\]$`)); if (rhs_i) { rhs[i] = rhs[i].substr(0, rhs[i].length - rhs_i[0].length); rhs_i = rhs_i[0].substr(1, rhs_i[0].length - 2); @@ -30564,7 +30584,7 @@ throw ex; // no action -> don't care about aliases; strip them. handle = handle.replace(new XRegExp(`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { if (rhs[i] === 'error') { hasErrorRecovery = true; } @@ -30574,35 +30594,33 @@ throw ex; } } - r = new Production(symbol, rhs, productions.length + 1, aliased, action); + let r = new Production(this.symbol, rhs, productions.length + 1, aliased, action); // set precedence assert$1(r.precedence === 0); if (precedence_override) { r.precedence = precedence_override.spec.precedence; - } - else { - var prec_symbols = []; - var winning_symbol; + } else { + let prec_symbols = []; + let winning_symbol; - for (i = r.handle.length - 1; i >= 0; i--) { + for (let i = r.handle.length - 1; i >= 0; i--) { if (!(r.handle[i] in nonterminals) && r.handle[i] in operators) { - var old_prec = r.precedence; - var new_prec = operators[r.handle[i]].precedence; + let old_prec = r.precedence; + let new_prec = operators[r.handle[i]].precedence; if (old_prec !== 0 && old_prec !== new_prec) { prec_symbols.push(r.handle[i]); - // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], symbol, handle[0]); + // 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[i]; - } - else { + } else { // keep previously set precedence: new_prec = old_prec; } } else if (old_prec === 0) { prec_symbols.push(r.handle[i]); winning_symbol = r.handle[i]; - // Jison.print('precedence set first time: ', old_prec, r.handle[i], symbol, handle[0]); + // Jison.print('precedence set first time: ', old_prec, r.handle[i], this.symbol, handle[0]); } r.precedence = new_prec; } @@ -30610,14 +30628,14 @@ throw ex; if (prec_symbols.length > 1) { if (self.DEBUG || 1) { - self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); + self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + this.symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); } } } productions.push(r); - productions_.push([symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length]); - nonterminals[symbol].productions.push(r); + productions_.push([ symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length ]); + nonterminals[this.symbol].productions.push(r); } }; @@ -30722,8 +30740,9 @@ function preprocessActionCode(s) { // with our pants down in constructs like // `'"' + $$ + '"'` vs. `"'" + $$ + "'"` - var dqpos, sqpos, ccmtpos, cppcmtpos, first = -1; - for (var c = 0;; c++) { + let dqpos, sqpos, ccmtpos, cppcmtpos; + let first = -1; + for (let c = 0; ; c++) { first++; dqpos = s.indexOf('"', first); sqpos = s.indexOf("'", first); @@ -30767,11 +30786,11 @@ function postprocessActionCode(s) { .replace(/\x01\x82/g, '$') .replace(/\x01\x83/g, '@') // and revert the string and regex markers: - .replace(/\x01\x87/g, '\'') + .replace(/\x01\x87/g, "'") .replace(/\x01\x88/g, '\"') .replace(/\x01\x89/g, '##') .replace(/\x01\x90/g, '\\\\') - .replace(/\x01\x91/g, '\\\'') + .replace(/\x01\x91/g, "\\'") .replace(/\x01\x92/g, '\\\"') .replace(/\x01\x93/g, '\\\/') .replace(/\x01\x94/g, 'YYABORT') @@ -30804,7 +30823,7 @@ function mkHashIndex(s) { } function analyzeFeatureUsage(sourcecode, feature, threshold) { - var found = sourcecode.match(feature); + let found = sourcecode.match(feature); return !!(found && found.length > threshold); } @@ -30812,7 +30831,7 @@ function analyzeFeatureUsage(sourcecode, feature, threshold) { function mkParserFeatureHash(self) { assert$1(self.options.exportAllTables); // check that this function isn't called too early in the process or the hash will be bogus assert$1(self.options.exportSourceCode); - var h = [ + let h = [ self.actionsAreAllDefault, self.actionsUseLocationAssignment, self.actionsUseLocationTracking, @@ -30861,7 +30880,7 @@ function mkParserFeatureHash(self) { self.options.prettyCfg, '======================================', self.performAction, - '======================================', + '======================================' ]; return JSON.stringify(h); } @@ -30876,23 +30895,23 @@ generator.buildProductionActions = function buildProductionActions() { this.productions_ = productions_; assert(this.productions === productions); */ - var productions = this.productions, - nonterminals = this.nonterminals, - symbols = this.symbols, - operators = this.operators, - self = this; + let productions = this.productions; + let nonterminals = this.nonterminals; + let symbols = this.symbols; + let operators = this.operators; + let self = this; // As a SIDE EFFECT of this call, we also fixup // the other code chunks specified in the grammar file: // // Replace direct symbol references, e.g. #NUMBER# when there's a `%token NUMBER` for your grammar. // We allow these tokens to be referenced anywhere in your code as #TOKEN#. - var moduleInclude = preprocessActionCode(this.moduleInclude) + let moduleInclude = preprocessActionCode(this.moduleInclude) .replace(new XRegExp(`#(${ID_REGEX_BASE$3})#`, 'g'), function (_, sym) { return provideSymbolAsSourcecode(sym); }); // and COPY the `moduleInit` array, after preprocessing the individual COPIES: - var moduleInit = this.moduleInit.map(function (chunk) { + let moduleInit = this.moduleInit.map(function (chunk) { assert$1(chunk.qualifier); assert$1(typeof chunk.include === 'string'); return { @@ -30908,39 +30927,38 @@ generator.buildProductionActions = function buildProductionActions() { // We potentially need multiple (2+) rounds to produce the correct actions // as userland action code determines whether the default actions should // include location tracking or not: - var gen_level = 0; - var prev_gen_hash = 'n'; - var gen_hash = 'y'; + let gen_level = 0; + let prev_gen_hash = 'n'; + let gen_hash = 'y'; this.performAction = null; while (gen_hash !== prev_gen_hash) { - var preludeCode = preprocessActionCode(this.actionInclude || ''); - var actions = [` + let preludeCode = preprocessActionCode(this.actionInclude || ''); + let actions = [ ` /* this == yyval */ // the JS engine itself can go and remove these statements when \`yy\` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; ${preludeCode} switch (yystate) {` ]; - var actionGroups = {}; // used to combine identical actions into single instances: no use duplicating action code needlessly - var actionGroupValue = {}; // stores the unaltered, expanded, user-defined action code for each action group. - var stateHasAction = []; // marks which state IDs have an action, either user-specified or default. - var symbol; + let actionGroups = {}; // used to combine identical actions into single instances: no use duplicating action code needlessly + let actionGroupValue = {}; // stores the unaltered, expanded, user-defined action code for each action group. + let stateHasAction = []; // marks which state IDs have an action, either user-specified or default. // and now go and process the entire grammar: - productions.forEach(buildProductionAction); + productions.forEach(buildProductionAction, { actionGroups, actionGroupValue, stateHasAction }); - for (var hash in actionGroups) { + for (let hash in actionGroups) { actions.push([].concat.apply([], actionGroups[hash]).join('\n') + '\n\n' + actionGroupValue[hash] + '\n break;\n'); } // add the special error recovery reduction action: if (this.hasErrorRecovery) { - var userland_err_recov_redux_code = ''; + let userland_err_recov_redux_code = ''; actions.push(`case YY_ERROR_RECOVERY_COMBINE_ID: // === NO_ACTION[1] :: ensures that anyone (but us) using this new state will fail dramatically! // error recovery reduction action (action generated by jison, @@ -30953,16 +30971,16 @@ generator.buildProductionActions = function buildProductionActions() { } // check if all IDs have an action now: - var missingActions = []; - for (var idx = 0, len = stateHasAction.length; idx < len; idx++) { + let missingActions = []; + for (let idx = 0, len = stateHasAction.length; idx < len; idx++) { if (!stateHasAction[idx]) { missingActions.push(idx); } } - this.missingActions = missingActions; + this.missingActions = missingActions; if (missingActions.length) { if ( this.DEBUG) { - this.warn("WARNING: missing actions for states: ", missingActions); + this.warn('WARNING: missing actions for states: ', missingActions); } actions.push(`default: @@ -30970,7 +30988,7 @@ generator.buildProductionActions = function buildProductionActions() { // When we hit this entry, it's always a non-recoverable issue as this is a severe internal parser state failure: function __b0rk_on_internal_failure(str) { - var hash = yyparser.constructParseErrorInfo(str, null, null, false); + let hash = yyparser.constructParseErrorInfo(str, null, null, false); return yyparser.parseError(str, hash, yyparser.JisonParserError); } @@ -30980,7 +30998,7 @@ generator.buildProductionActions = function buildProductionActions() { } actions.push('}'); - var parameters = 'yytext, yyleng, yylineno, yyloc, yystate /* action[1] */, yysp, yyrulelength, yyvstack, yylstack, yystack, yysstack'; + let parameters = 'yytext, yyleng, yylineno, yyloc, yystate /* action[1] */, yysp, yyrulelength, yyvstack, yylstack, yystack, yysstack'; this.performAction = [].concat( 'function parser__PerformAction(' + parameters + ') {', @@ -31099,7 +31117,7 @@ generator.buildProductionActions = function buildProductionActions() { moduleInit.forEach(function (chunk) { assert$1(chunk.qualifier); assert$1(typeof chunk.include === 'string'); - var moduleInclude = chunk.include; + let moduleInclude = chunk.include; //self.actionsUseYYLENG = self.actionsUseYYLENG || analyzeFeatureUsage(moduleInclude, /\byyleng\b/g, 0); //self.actionsUseYYLINENO = self.actionsUseYYLINENO || analyzeFeatureUsage(moduleInclude, /\byylineno\b/g, 0); @@ -31167,8 +31185,8 @@ generator.buildProductionActions = function buildProductionActions() { this.actionsUseValueAssignment = true; break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": // <-- this one injects *nothing* + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'skip': // <-- this one injects *nothing* break; } this.actionsUseValueTracking = this.actionsUseValueTracking || this.actionsUseYYLENG || this.actionsUseYYTEXT || this.actionsUseValueAssignment; @@ -31177,8 +31195,8 @@ generator.buildProductionActions = function buildProductionActions() { default: break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": // <-- this one injects *nothing* + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'skip': // <-- this one injects *nothing* break; } this.actionsUseLocationTracking = this.actionsUseLocationTracking || this.actionsUseYYLINENO || this.actionsUseYYLOC || this.actionsUseLocationAssignment || this.actionsUseYYMERGELOCATIONINFO; @@ -31199,7 +31217,7 @@ generator.buildProductionActions = function buildProductionActions() { gen_hash = null; // create check hash of the new generated code: - var new_hash = mkParserFeatureHash(this); + let new_hash = mkParserFeatureHash(this); if ( this.DEBUG) { Jison$1.print('Optimization analysis:\n', { @@ -31228,7 +31246,7 @@ generator.buildProductionActions = function buildProductionActions() { hasErrorReporting: this.hasErrorReporting, defaultActionMode: this.options.defaultActionMode, testCompileActionCode: this.options.testCompileActionCode, - noTryCatch: this.options.noTryCatch, + noTryCatch: this.options.noTryCatch }); } @@ -31251,9 +31269,9 @@ generator.buildProductionActions = function buildProductionActions() { moduleInit.__consumedInitCodeSlots__ = []; moduleInit.getInitCodeSection = function getInitCodeSection(section) { - var rv = []; - for (var i = 0, len = this.length; i < len; i++) { - var m = this[i]; + let rv = []; + for (let i = 0, len = this.length; i < len; i++) { + let m = this[i]; if (m.qualifier === section) { if (m.include.trim()) { rv.push(m.include); @@ -31265,9 +31283,9 @@ generator.buildProductionActions = function buildProductionActions() { }; moduleInit.getRemainingInitCodeSections = function getRemainingInitCodeSections() { - var rv = []; - for (var i = 0, len = this.length; i < len; i++) { - var m = this[i]; + let rv = []; + for (let i = 0, len = this.length; i < len; i++) { + let m = this[i]; if (!this.__consumedInitCodeSlots__[i]) { rv.push(rmCommonWS$5` @@ -31283,8 +31301,6 @@ generator.buildProductionActions = function buildProductionActions() { }; - - // make sure a comment does not contain any embedded '*/' end-of-comment marker // as that would break the generated code function postprocessComment(str) { @@ -31308,13 +31324,13 @@ generator.buildProductionActions = function buildProductionActions() { } function provideSymbolAsSourcecode(sym) { - var ss = String(sym); + let ss = String(sym); return ' /* ' + postprocessComment(ss) + ' */ ' + getSymbolId(sym); } // helper: convert index string/number to proper JS add/subtract expression function indexToJsExpr(n, len, rule4msg) { - var v = parseInt(n, 10); + let v = parseInt(n, 10); // the usual situation: `$3`; MUST reference an rhs[] element or it will be considered an ERROR: if (v > 0) { if (v > len) { @@ -31344,35 +31360,33 @@ generator.buildProductionActions = function buildProductionActions() { return ''; } + // options object { actionGroups, actionGroupValue, stateHasAction } is `this` for this function/callback: function buildProductionAction(handle) { - var i; - var aliased = handle.aliases, - rhs_i; + let aliased = handle.aliases; - var rhs = handle.handle; - var named_token_re = new XRegExp(`^${ID_REGEX_BASE$3}$`); + let rhs = handle.handle; + let named_token_re = new XRegExp(`^${ID_REGEX_BASE$3}$`); // semantic action specified - var label = [ + let label = [ 'case ', handle.id, ':', '\n /*! Production:: ', postprocessComment(handle.symbol), ' : ' ].concat(postprocessComment(rhs.map(function (sym) { // check if the symbol is a literal terminal, and if it is, quote it: if (sym && !self.nonterminals[sym] && !named_token_re.test(sym) && sym !== self.EOF) { return '"' + sym.replace(/["]/g, '\\"') + '"'; - } - else if (!sym) { + } else if (!sym) { sym = '%epsilon'; } return sym; })), ' */').join(''); - var action = preprocessActionCode(handle.action || ''); - var rule4msg = handle.symbol + ': ' + rhs.join(' '); + let action = preprocessActionCode(handle.action || ''); + let rule4msg = handle.symbol + ': ' + rhs.join(' '); assert$1(typeof handle.id === 'number'); assert$1(handle.id >= 0); - stateHasAction[handle.id] = true; + this.stateHasAction[handle.id] = true; // before anything else, replace direct symbol references, e.g. #NUMBER# when there's a %token NUMBER for your grammar. // This is done to prevent incorrect expansions where tokens are used in rules as RHS elements: we allow these to @@ -31387,9 +31401,9 @@ generator.buildProductionActions = function buildProductionActions() { // replace named semantic values ($nonterminal) if (action.match(new XRegExp(`(?:[$@#]|##)${ID_REGEX_BASE$3}`))) { - var count = {}, - names = {}, - donotalias = {}; + let count = {}; + let names = {}; + let donotalias = {}; // When the rule is fitted with aliases it doesn't mean that the action code MUST use those: // we therefor allow access to both the original (non)terminal and the alias. @@ -31420,9 +31434,9 @@ generator.buildProductionActions = function buildProductionActions() { // as an explicit alias: adding auto-alias `e1` would then break the system, // while `e2` would be ambiguous from the human perspective as he *might* then // expect `e2` and `e3`. - var addName = function addName(s) { - var base = s.replace(/[0-9]+$/, ''); - var dna = donotalias[base]; + let addName = function addName(s, i) { + let base = s.replace(/[0-9]+$/, ''); + let dna = donotalias[base]; if (names[s]) { count[s]++; @@ -31443,28 +31457,28 @@ generator.buildProductionActions = function buildProductionActions() { // register the alias/rule name when the real one ends with a number, e.g. `rule5` as // *blocking* the auto-aliasing process for the term of the same base, e.g. `rule`. // This will catch the `WORD[e1]` example above too, via `e1` --> `donotalias['e']` - var markBasename = function markBasename(s) { + let markBasename = function markBasename(s) { if (/[0-9]$/.test(s)) { s = s.replace(/[0-9]+$/, ''); donotalias[s] = true; } }; - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // mark both regular and aliased names, e.g., `id[alias1]` and `id1` - rhs_i = aliased[i]; + let rhs_i = aliased[i]; markBasename(rhs_i); if (rhs_i !== rhs[i]) { markBasename(rhs[i]); } } - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // check for aliased names, e.g., id[alias] - rhs_i = aliased[i]; - addName(rhs_i); + let rhs_i = aliased[i]; + addName(rhs_i, i); if (rhs_i !== rhs[i]) { - addName(rhs[i]); + addName(rhs[i], i); } } action = action.replace( @@ -31481,7 +31495,7 @@ generator.buildProductionActions = function buildProductionActions() { .replace(/\$\$/g, 'this.$') .replace(/@\$/g, 'this._$') .replace(/#\$/g, function (_) { - return provideSymbolAsSourcecode(symbol); + return provideSymbolAsSourcecode(handle.symbol); }) // replace semantic value references ($n) with stack value (stack[n]) .replace(/\$(-?\d+)\b/g, function (_, n) { @@ -31500,7 +31514,7 @@ generator.buildProductionActions = function buildProductionActions() { }) // same as above for token ID references (#n) .replace(/#(-?\d+)\b/g, function (_, n) { - var i = parseInt(n, 10) - 1; + let i = parseInt(n, 10) - 1; if (!rhs[i]) { throw new Error(`invalid token location reference in action code for rule: "${rule4msg}" - location reference: "${_}"`); } @@ -31544,7 +31558,7 @@ generator.buildProductionActions = function buildProductionActions() { // the action code: if some Smart Alec decides to code `this.$` instead of // `$$` it SHOULD NOT confuse the code analysis here! - var uses_$$ = analyzeFeatureUsage(action, /\bthis\.\$[^\w]/g, 0); // use includes assignment, not just read accesses! + let uses_$$ = analyzeFeatureUsage(action, /\bthis\.\$[^\w]/g, 0); // use includes assignment, not just read accesses! // the next check is very rough; we need the AST of the code to do better than this. function analyzeFeatureAssignmentBeforeUse(source, assignment_re, access_re) { @@ -31553,8 +31567,8 @@ generator.buildProductionActions = function buildProductionActions() { // // If no assignment can be found at all, we're probably looking at access-only // OR weird constructs we don't yet understand, in which case we play it safe. - var prelude = source; - var m = source.match(assignment_re); + let prelude = source; + let m = source.match(assignment_re); if (m) { // check the closure exists in the regex: m[1] is filled with its content: assert$1(m[1] != null); @@ -31584,21 +31598,21 @@ generator.buildProductionActions = function buildProductionActions() { return false; // assignment before access (or no usage and assignments at all!) } - var uses_$$_before_assignment = uses_$$ && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\.\$\s*=[^=>]/, /\bthis\.\$[^\w]/g); + let uses_$$_before_assignment = uses_$$ && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\.\$\s*=[^=>]/, /\bthis\.\$[^\w]/g); // ditto for location tracking, but only iff we use it at all: - var uses_$loc = false; - var uses_$loc_before_assignment = false; + let uses_$loc = false; + let uses_$loc_before_assignment = false; if (self.actionsUseLocationTracking) { uses_$loc = analyzeFeatureUsage(action, /\bthis\._\$[^\w]/g, 0); uses_$loc_before_assignment = uses_$loc && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\._\$\s*=[^=>]/, /\bthis\._\$[^\w]/g); } - var inject_default_value_action = (uses_$$_before_assignment || (self.actionsUseValueTracking && !uses_$$)); - var inject_default_loc_action = (uses_$loc_before_assignment || (self.actionsUseLocationTracking && !uses_$loc)); + let inject_default_value_action = (uses_$$_before_assignment || (self.actionsUseValueTracking && !uses_$$)); + let inject_default_loc_action = (uses_$loc_before_assignment || (self.actionsUseLocationTracking && !uses_$loc)); - var default_action = []; + let default_action = []; // Note: // @@ -31609,26 +31623,27 @@ generator.buildProductionActions = function buildProductionActions() { // $$ = undefined; // $@ = undefined; // - var vmode = !inject_default_value_action ? "skip" : self.options.defaultActionMode[0]; - var lmode = !inject_default_loc_action ? "skip" : self.options.defaultActionMode[1]; + let vmode = !inject_default_value_action ? 'skip' : self.options.defaultActionMode[0]; + let lmode = !inject_default_loc_action ? 'skip' : self.options.defaultActionMode[1]; // check if there's no user action specified. Insert default action if it isn't. // first determine the actual number of terms in the production: - var rhs = handle.handle.slice(0); - var real_rhs_length = rhs.length; + let rhs_reduced_length = rhs.length; + let real_rhs_length = rhs.length; // strip away EOF terms at the end of the rule, ditto for epsilon terms: - if (rhs.length) { - switch (rhs[rhs.length - 1]) { + while (rhs_reduced_length) { + switch (rhs[rhs_reduced_length - 1]) { case '$end': - rhs.length--; - break; + rhs_reduced_length--; + continue; case '': // %epsilon - rhs.length--; - break; + rhs_reduced_length--; + continue; } + break; } // then we can choose what to do, depending on the number of terms in the production. @@ -31645,18 +31660,18 @@ generator.buildProductionActions = function buildProductionActions() { // // Ditto for location tracking default actions... // - switch (rhs.length) { + switch (rhs_reduced_length) { case 0: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; <-- but that would cause nondeterministic behaviour, so // we fall back to the default here! - case "ast": - case "none": - default_action.push("this.$ = undefined;"); + case 'ast': + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31665,22 +31680,22 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // an empty production has no location as there are no terms parsed. // ergo: we produce a zero-width location which points at the tail // end of the previous content: // @$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);"); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31691,19 +31706,19 @@ generator.buildProductionActions = function buildProductionActions() { case 1: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; // // WARNING: be careful with the ACCEPT rule as that one's production has - // rhs.length === 1 **BUT** has real_rhs_length === 2 as we have discarded + // rhs_reduced_length === 1 **BUT** has real_rhs_length === 2 as we have discarded // the `$end` term at the end! // Here we need to account for that magick though! - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // As we're looking at a production which has one(1) useful term, we can simply // reference-copy that one intom a fresh array, instead of `slice()`-ing it out // of the vstack. @@ -31712,14 +31727,14 @@ generator.buildProductionActions = function buildProductionActions() { // WARNING/NOTE: as above, and ditto BTW for rule productions which end with // `EOF` as a last term: as we now construct an entire AST, we DO NOT include // those 'values' here! - default_action.push("this.$ = [yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "]];"); + default_action.push('this.$ = [yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ']];'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31728,23 +31743,23 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: // as we have a production length of 1 only, we can simply ref-copy @1: // @$ = @1; // // WARNING: same as above for the value copying: we may have discarded an `EOF` or `$end` term! - default_action.push("this._$ = yylstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this._$ = yylstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31755,29 +31770,29 @@ generator.buildProductionActions = function buildProductionActions() { default: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // - // WARNING: as with the situation further above where rhs.length === 1 after we + // WARNING: as with the situation further above where rhs_reduced_length === 1 after we // have got rid of a possible `EOF` or `$end` at the end of the production, // we again have to account for our trickery earlier and compensate the // action above: again we DO NOT include the value of the EOF/$end token in the // resulting array 'AST', hence our `slice()` end index may vary by one(1): - var end_offset = 1 - real_rhs_length + rhs.length; - default_action.push("this.$ = yyvstack.slice(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp" + /* CANNOT USE indexToJsExpr(rhs.length + 1, real_rhs_length, rule4msg) HERE! */ (end_offset === 0 ? "" : " + " + end_offset) + ");"); + let end_offset = 1 - real_rhs_length + rhs_reduced_length; + default_action.push('this.$ = yyvstack.slice(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp' + /* CANNOT USE indexToJsExpr(rhs_reduced_length + 1, real_rhs_length, rule4msg) HERE! */ (end_offset === 0 ? '' : ' + ' + end_offset) + ');'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31786,20 +31801,20 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: - // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs.length - 1}, yysp); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp);"); + // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs_reduced_length - 1}, yysp); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31812,16 +31827,16 @@ generator.buildProductionActions = function buildProductionActions() { // comment/mark the default action chunk, if any, so we can simply observe // what is user code and what is generated by us in the final product: if (default_action.length > 0) { - var flags = [ - rhs.length, - self.actionsUseValueTracking ? "VT" : "-", - self.actionsUseValueAssignment ? "VA" : "-", - uses_$$ ? "VU" : "-", - uses_$$_before_assignment ? "VUbA" : "-", - self.actionsUseLocationTracking ? "LT" : "-", - self.actionsUseLocationAssignment ? "LA" : "-", - uses_$loc ? "LU" : "-", - uses_$loc_before_assignment ? "LUbA" : "-", + let flags = [ + rhs_reduced_length + '/' + real_rhs_length, + self.actionsUseValueTracking ? 'VT' : '-', + self.actionsUseValueAssignment ? 'VA' : '-', + uses_$$ ? 'VU' : '-', + uses_$$_before_assignment ? 'VUbA' : '-', + self.actionsUseLocationTracking ? 'LT' : '-', + self.actionsUseLocationAssignment ? 'LA' : '-', + uses_$loc ? 'LU' : '-', + uses_$loc_before_assignment ? 'LUbA' : '-' ].join(','); default_action.unshift(`// default action (generated by JISON mode ${self.options.defaultActionMode[0]}/${self.options.defaultActionMode[1]} :: ${flags}):`); @@ -31835,16 +31850,16 @@ generator.buildProductionActions = function buildProductionActions() { action = reindentCodeBlock(action, 4); - var actionHash = mkHashIndex(action); + let actionHash = mkHashIndex(action); // Delay running the postprocess (restore) process until we've done ALL macro expansions: //action = postprocessActionCode(action); - if (actionHash in actionGroups) { - actionGroups[actionHash].push(label); + if (actionHash in this.actionGroups) { + this.actionGroups[actionHash].push(label); } else { - actionGroups[actionHash] = [label]; - actionGroupValue[actionHash] = action; + this.actionGroups[actionHash] = [ label ]; + this.actionGroupValue[actionHash] = action; } } }; @@ -31864,7 +31879,7 @@ generator.trace = (new Function('', 'function no_op_trace() { }\nreturn no_op_tr //generator.trace.name = 'no_op_trace'; generator.warn = function warn() { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); Jison$1.print.call(null, args.join('')); }; @@ -31911,9 +31926,9 @@ generator.reportGrammarInformation = function reportGrammarInformation() { // LR specific mixin class later on, so that we can have another // implementation/report for LL and PEG type grammars. - var rows = 0, cols = 0; - var colmarks = {}; - var i, j, len; + let rows = 0, cols = 0; + let colmarks = {}; + let i, j, len; for (i = 0, len = this.table.length; i < len; i++) { rows++; @@ -31924,8 +31939,8 @@ generator.reportGrammarInformation = function reportGrammarInformation() { } } } - var defrows = 0; - var rowmarks = {}; + let defrows = 0; + let rowmarks = {}; for (j in this.defaultActions) { if (!rowmarks[j]) { rowmarks[j] = true; @@ -31933,8 +31948,8 @@ generator.reportGrammarInformation = function reportGrammarInformation() { } } - var ntc = 0; - for (var nt in this.nonterminals) { + let ntc = 0; + for (let nt in this.nonterminals) { ntc++; } @@ -31953,14 +31968,12 @@ generator.reportGrammarInformation = function reportGrammarInformation() { // --- START of debugTraceSrc chunk --- const debugTraceSrc = ` function debug_trace() { - "use strict"; - if (typeof Jison !== 'undefined' && Jison.print) { Jison.print.apply(null, arguments); } else if (typeof print !== 'undefined') { print.apply(null, arguments); } else if (typeof console !== 'undefined' && console.log) { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); args.unshift(''); // prevent \`%.\` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args console.log.apply(null, args); } @@ -31970,14 +31983,14 @@ function debug_trace() { // Generator debug mixin -var generatorDebug = { +const generatorDebug = { trace: (new Function('', debugTraceSrc + ` return debug_trace;`))(), beforeprocessGrammar: function () { this.trace('Processing grammar.'); }, afteraugmentGrammar: function () { - var trace = this.trace; + let trace = this.trace; trace('\nSymbols:\n'); each(this.symbols, function (sym, i) { trace(sym + '(' + i + ')'); @@ -31991,7 +32004,7 @@ var generatorDebug = { /* * Mixin for common behaviors of lookahead parsers */ -var lookaheadMixin = {}; +let lookaheadMixin = {}; lookaheadMixin.computeLookaheads = function computeLookaheads() { if (this.DEBUG) { @@ -32005,11 +32018,11 @@ lookaheadMixin.computeLookaheads = function computeLookaheads() { }; lookaheadMixin.displayFollowSets = function displayFollowSets() { - var self = this; - var symfollowdbg = {}; + let self = this; + let symfollowdbg = {}; this.productions.forEach(function Follow_prod_forEach_debugOut(production, k) { - var key = ['prod-', k, ': ', production.symbol, ' := ', production.handle.join(' ')].join(''); - var flw = '[' + self.nonterminals[production.symbol].follows.join('] [') + ']'; + let key = [ 'prod-', k, ': ', production.symbol, ' := ', production.handle.join(' ') ].join(''); + let flw = '[' + self.nonterminals[production.symbol].follows.join('] [') + ']'; if (!symfollowdbg[flw]) { symfollowdbg[flw] = {}; } @@ -32020,9 +32033,9 @@ lookaheadMixin.displayFollowSets = function displayFollowSets() { symfollowdbg[flw][key]++; } }); - for (var l in symfollowdbg) { - var lst = []; - for (var k in symfollowdbg[l]) { + for (let l in symfollowdbg) { + let lst = []; + for (let k in symfollowdbg[l]) { lst.push(k); } self.trace('Symbol/Follows:\n ', lst.join('\n '), ' -->\n ', l); @@ -32031,10 +32044,10 @@ lookaheadMixin.displayFollowSets = function displayFollowSets() { // calculate follow sets based on first and nullable lookaheadMixin.followSets = function followSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true; + let productions = this.productions; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { @@ -32043,23 +32056,23 @@ lookaheadMixin.followSets = function followSets() { productions.forEach(function Follow_prod_forEach(production, k) { // q is used in Simple LALR algorithm determine follows in context - var q; - var ctx = !!self.go_; + let q; + let ctx = !!self.go_; - for (var i = 0, t; (t = production.handle[i]); ++i) { + for (let i = 0, t; (t = production.handle[i]); ++i) { if (!nonterminals[t]) continue; // for Simple LALR algorithm, self.go_ checks if if (ctx) { q = self.go_(production.symbol, production.handle.slice(0, i)); } - var bool = (!ctx || q === self.nterms_[t]); - var set; + let bool = (!ctx || q === self.nterms_[t]); + let set; if (i === production.handle.length - 1 && bool) { set = nonterminals[production.symbol].follows; } else { - var part = production.handle.slice(i + 1); + let part = production.handle.slice(i + 1); set = self.first(part); if (self.nullable(part) && bool) { @@ -32067,8 +32080,8 @@ lookaheadMixin.followSets = function followSets() { set.push.apply(set, nonterminals[production.symbol].follows); } } - var follows = nonterminals[t].follows; - var oldcount = follows.length; + let follows = nonterminals[t].follows; + let oldcount = follows.length; follows = union(follows, set); if (oldcount !== follows.length) { cont = true; @@ -32090,8 +32103,8 @@ lookaheadMixin.first = function first(symbol) { return []; // RHS } else if (symbol instanceof Array) { - var firsts = []; - for (var i = 0, t; (t = symbol[i]); ++i) { + let firsts = []; + for (let i = 0, t; (t = symbol[i]); ++i) { if (!this.nonterminals[t]) { if (firsts.indexOf(t) === -1) { firsts.push(t); @@ -32099,41 +32112,39 @@ lookaheadMixin.first = function first(symbol) { } else { firsts = union(firsts, this.nonterminals[t].first); } - if (!this.nullable(t)) - break; + if (!this.nullable(t)) { break; } } return firsts; // terminal } else if (!this.nonterminals[symbol]) { - return [symbol]; + return [ symbol ]; // nonterminal - } else { - return this.nonterminals[symbol].first; } + return this.nonterminals[symbol].first; + }; // fixed-point calculation of FIRST sets lookaheadMixin.firstSets = function firstSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true, - symbol, firsts; + let productions = this.productions; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { cont = false; productions.forEach(function FirstSets_forEach(production, k) { - var firsts = self.first(production.handle); + let firsts = self.first(production.handle); if (firsts.length !== production.first.length) { production.first = firsts; cont = true; } }); - for (symbol in nonterminals) { - firsts = []; + for (let symbol in nonterminals) { + let firsts = []; nonterminals[symbol].productions.forEach(function FirstSets_forEachNonTerm(production) { firsts = union(firsts, production.first); }); @@ -32147,9 +32158,9 @@ lookaheadMixin.firstSets = function firstSets() { // fixed-point calculation of NULLABLE lookaheadMixin.nullableSets = function nullableSets() { - var nonterminals = this.nonterminals, - self = this, - cont = true; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { @@ -32158,7 +32169,9 @@ lookaheadMixin.nullableSets = function nullableSets() { // check if each production is nullable this.productions.forEach(function isEachProductionNullable(production, k) { if (!production.nullable) { - for (var i = 0, n = 0, t; (t = production.handle[i]); ++i) { + let i = 0; + let n = 0; + for (let t; (t = production.handle[i]); ++i) { if (self.nullable(t)) n++; } if (n === i) { // production is nullable if all tokens are nullable @@ -32168,9 +32181,9 @@ lookaheadMixin.nullableSets = function nullableSets() { }); // check if each symbol is nullable - for (var symbol in nonterminals) { + for (let symbol in nonterminals) { if (!this.nullable(symbol)) { - for (var i = 0, production; (production = nonterminals[symbol].productions.item(i)); i++) { + for (let i = 0, production; (production = nonterminals[symbol].productions.item(i)); i++) { if (production.nullable) { nonterminals[symbol].nullable = cont = true; } @@ -32187,7 +32200,7 @@ lookaheadMixin.nullable = function nullable(symbol) { return true; // RHS } else if (symbol instanceof Array) { - for (var i = 0, t; (t = symbol[i]); ++i) { + for (let i = 0, t; (t = symbol[i]); ++i) { if (!this.nullable(t)) { return false; } @@ -32197,14 +32210,14 @@ lookaheadMixin.nullable = function nullable(symbol) { } else if (!this.nonterminals[symbol]) { return false; // nonterminal - } else { - return this.nonterminals[symbol].nullable; } + return this.nonterminals[symbol].nullable; + }; // lookahead debug mixin -var lookaheadDebug = { +const lookaheadDebug = { beforenullableSets: function () { this.trace('Computing Nullable sets.'); }, @@ -32215,7 +32228,7 @@ var lookaheadDebug = { this.trace('Computing Follow sets.'); }, afterfollowSets: function () { - var trace = this.trace; + let trace = this.trace; trace('\nNonterminals:\n'); each(this.nonterminals, function (nt, t) { trace(nt.toString(), '\n'); @@ -32227,7 +32240,7 @@ var lookaheadDebug = { /* * Mixin for common LR parser behavior */ -var lrGeneratorMixin = {}; +let lrGeneratorMixin = {}; // LR state machine actions: @@ -32280,16 +32293,16 @@ lrGeneratorMixin.Item = typal.construct({ return e.id === this.id; }, handleToString: function () { - var handle = this.production.handle.slice(0); + let handle = this.production.handle.slice(0); handle[this.dotPosition] = '.' + (handle[this.dotPosition] || ''); return handle.join(' '); }, toString: function () { - var temp = this.production.handle.slice(0); + let temp = this.production.handle.slice(0); temp[this.dotPosition] = '.' + (temp[this.dotPosition] || ''); - var s = this.production.symbol + ' -> ' + temp.join(' '); - var padlen = Math.max(4, 40 - s.length); - var pad = new Array(padlen); + let s = this.production.symbol + ' -> ' + temp.join(' '); + let padlen = Math.max(4, 40 - s.length); + let pad = new Array(padlen); if (this.follows.length) { s += pad.join(' ') + '#lookaheads= [' + this.follows.join('] [') + ']'; pad = new Array(2); @@ -32302,7 +32315,7 @@ lrGeneratorMixin.Item = typal.construct({ } }); -lrGeneratorMixin.ItemSet = Set.prototype.construct({ +lrGeneratorMixin.ItemSet = Set$1.prototype.construct({ afterconstructor: function () { this.reductions = []; this.goes = {}; @@ -32310,13 +32323,13 @@ lrGeneratorMixin.ItemSet = Set.prototype.construct({ this.shifts = false; this.inadequate = false; this.hash_ = {}; - for (var i = this._items.length - 1; i >= 0; i--) { + for (let i = this._items.length - 1; i >= 0; i--) { this.hash_[this._items[i].id] = true; //i; } }, concat: function concat(set) { - var a = set._items || set; - for (var i = a.length - 1; i >= 0; i--) { + let a = set._items || set; + for (let i = a.length - 1; i >= 0; i--) { this.hash_[a[i].id] = true; } this._items.push.apply(this._items, a); @@ -32330,31 +32343,31 @@ lrGeneratorMixin.ItemSet = Set.prototype.construct({ return this.hash_[item.id]; }, valueOf: function toValue() { - var v = this._items.map(function (a) { return a.id; }).sort().join('|'); + let v = this._items.map(function (a) { return a.id; }).sort().join('|'); this.valueOf = function valueOf_inner() { return v; }; return v; } }); lrGeneratorMixin.closureOperation = function closureOperation(itemSet) { - var closureSet = new this.ItemSet(); - var self = this; + let closureSet = new this.ItemSet(); + let self = this; - var set = itemSet, - itemQueue, - syms = {}; + let set = itemSet; + let itemQueue; + let syms = {}; do { - itemQueue = new Set(); + itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function CO_set_forEach(item) { - var symbol = item.markedSymbol; + let symbol = item.markedSymbol; // if token is a non-terminal, recursively add closures if (symbol && self.nonterminals[symbol]) { if (!syms[symbol]) { self.nonterminals[symbol].productions.forEach(function CO_nt_forEach(production) { - var newItem = new self.Item(production, 0); + let newItem = new self.Item(production, 0); if (!closureSet.contains(newItem)) { itemQueue.push(newItem); } @@ -32379,8 +32392,8 @@ lrGeneratorMixin.closureOperation = function closureOperation(itemSet) { }; lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) { - var gotoSet = new this.ItemSet(), - self = this; + let gotoSet = new this.ItemSet(); + let self = this; itemSet.forEach(function goto_forEach(item, n) { if (item.markedSymbol === symbol) { @@ -32395,14 +32408,14 @@ lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) { * Create unique set of item sets */ lrGeneratorMixin.canonicalCollection = function canonicalCollection() { - var item1 = new this.Item(this.productions[0], 0, [this.EOF]); - var firstStateNoClosure = new this.ItemSet(item1), - firstState = this.closureOperation(firstStateNoClosure), - states = new Set(firstState), - marked = 0, - self = this, - itemSet, - markedSymbols; + let item1 = new this.Item(this.productions[0], 0, [ this.EOF ]); + let firstStateNoClosure = new this.ItemSet(item1); + let firstState = this.closureOperation(firstStateNoClosure); + let states = new Set$1(firstState); + let marked = 0; + let self = this; + let itemSet; + let markedSymbols; states.has = {}; states.has[firstStateNoClosure.valueOf()] = 0; @@ -32424,8 +32437,8 @@ lrGeneratorMixin.canonicalCollection = function canonicalCollection() { // Pushes a unique state into the queue. Some parsing algorithms may perform additional operations lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert(symbol, itemSet, states, stateNum) { - var g = this.gotoOperation(itemSet, symbol), - state = states.has[g.valueOf()]; + let g = this.gotoOperation(itemSet, symbol); + let state = states.has[g.valueOf()]; if (typeof state !== 'undefined') { itemSet.edges[symbol] = state; // store goto transition for table @@ -32440,36 +32453,36 @@ lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert( } itemSet.edges[symbol] = states.size(); // store goto transition for table states.push(g); - g.predecessors[symbol] = [stateNum]; + g.predecessors[symbol] = [ stateNum ]; } } }; lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { - var states = [], - nonterminals = this.nonterminals, - operators = this.operators, - conflictedStates = {}, // set of [state, token] tuples - self = this; + let states = []; + let nonterminals = this.nonterminals; + let operators = this.operators; + let conflictedStates = {}; // set of [state, token] tuples + let self = this; // for each item set itemSets.forEach(function parseTableItem(itemSet, k) { k = +k; - var state = states[k] = {}; - var action, stackSymbol; + let state = states[k] = {}; + let action, stackSymbol; // set shift and goto actions for (stackSymbol in itemSet.edges) { itemSet.forEach(function findShiftAndGotoActions(item, j) { // find shift and goto actions if (item.markedSymbol === stackSymbol) { - var gotoState = itemSet.edges[stackSymbol]; + let gotoState = itemSet.edges[stackSymbol]; assert$1(gotoState); if (nonterminals[stackSymbol]) { // store state to go to after a reduce state[self.symbols_[stackSymbol]] = gotoState; } else { - state[self.symbols_[stackSymbol]] = [SHIFT, gotoState]; + state[self.symbols_[stackSymbol]] = [ SHIFT, gotoState ]; } } }); @@ -32479,25 +32492,25 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { itemSet.forEach(function setAcceptAction(item, j) { if (item.markedSymbol === self.EOF) { // accept - state[self.symbols_[self.EOF]] = [ACCEPT]; + state[self.symbols_[self.EOF]] = [ ACCEPT ]; } }); - var allterms = self.lookAheads ? false : self.terminals; + let allterms = self.lookAheads ? false : self.terminals; // set reductions and resolve potential conflicts itemSet.reductions.forEach(function calcReduction(item, j) { // if parser uses lookahead, only enumerate those terminals - var terminals = allterms || self.lookAheads(itemSet, item); + let terminals = allterms || self.lookAheads(itemSet, item); terminals.forEach(function (stackSymbol) { action = state[self.symbols_[stackSymbol]]; - var op = operators[stackSymbol]; + let op = operators[stackSymbol]; // Reading a terminal and current position is at the end of a production, try to reduce if (action) { - var sol = resolveConflict(item.production, op, [REDUCE, item.production.id], action[0] instanceof Array ? action[0] : action); - self.resolutions.push([k, stackSymbol, sol]); + let sol = resolveConflict(item.production, op, [ REDUCE, item.production.id ], action[0] instanceof Array ? action[0] : action); + self.resolutions.push([ k, stackSymbol, sol ]); if (sol.bydefault) { self.conflicts++; @@ -32535,7 +32548,7 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { if (self.options.noDefaultResolve) { if (!(action[0] instanceof Array)) { - action = [action]; + action = [ action ]; } action.push(sol.r); } @@ -32543,7 +32556,7 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { action = sol.action; } } else { - action = [REDUCE, item.production.id]; + action = [ REDUCE, item.production.id ]; } if (action && action.length) { state[self.symbols_[stackSymbol]] = action; @@ -32594,25 +32607,25 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { // only this time we are careful about the TERROR symbol as a state carrying that one // is an explicitly encoded error recovery rule and should remain as-is. function findDefaults(states, hasErrorRecovery) { - var defaults = {}; + let defaults = {}; states.forEach(function (state, k) { - var act, sym, st; - var i = 0; - var gotos = {}; + let act; + let i = 0; + let gotos = {}; - for (sym in state) { + for (let sym in state) { assert$1({}.hasOwnProperty.call(state, sym)); // it this isn't true, the last part of this function won't work! // keep state rows where there's an error recovery state: if (sym === 2 /* TERROR */) { return; } - st = state[sym]; + let st = state[sym]; if (typeof st !== 'number') { if (st[0] !== REDUCE) { // not a reduce action: forget about this row! return; } - var go = st[1]; + let go = st[1]; if (!gotos[go]) { gotos[go] = true; i++; @@ -32640,8 +32653,8 @@ function findDefaults(states, hasErrorRecovery) { // ... hence we only nuke these table entries (as that makes for a smaller table --> smaller parser file) // when there's no error recovery code included in the generated parser: if (!hasErrorRecovery) { - for (sym in state) { - st = state[sym]; + for (let sym in state) { + let st = state[sym]; if (typeof st !== 'number') { delete state[sym]; } @@ -32656,9 +32669,7 @@ function findDefaults(states, hasErrorRecovery) { // Remove all NONASSOC state transitions from the generated table now that we don't need them any longer function cleanupTable(table) { table.forEach(function (state, k) { - var symbol; - - for (symbol in state) { + for (let symbol in state) { if (state[symbol] === NONASSOC) { delete state[symbol]; } @@ -32668,16 +32679,16 @@ function cleanupTable(table) { // resolves shift-reduce and reduce-reduce conflicts function resolveConflict(production, op, reduce, shift) { - var sln = { - production: production, - operator: op, - r: reduce, - s: shift, - - msg: null, - action: null, - bydefault: false - }; + let sln = { + production: production, + operator: op, + r: reduce, + s: shift, + + msg: null, + action: null, + bydefault: false + }; if (shift[0] === REDUCE) { sln.msg = 'Resolved R/R conflict: use first production declared in grammar.'; @@ -32715,7 +32726,7 @@ function resolveConflict(production, op, reduce, shift) { /* * Mixin for common LR/LL/*any* parser behavior */ -var generatorMixin = {}; +let generatorMixin = {}; // internal helper function: generatorMixin.__prepareOptions = function parser___prepare_Options(opt) { @@ -32729,7 +32740,7 @@ generatorMixin.__prepareOptions = function parser___prepare_Options(opt) { // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*?[a-zA-Z0-9_$]$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "parser" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "parser" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else if (opt.warn_cb) { @@ -32745,7 +32756,7 @@ generatorMixin.__prepareOptions = function parser___prepare_Options(opt) { }; generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComment() { - var out = ` + let out = ` /* parser generated by jison ${version$2} */ /* @@ -32909,9 +32920,9 @@ generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComm * Produces a new errorInfo 'hash object' which can be passed into \`parseError()\`. * See it's use in this parser kernel in many places; example usage: * - * var infoObj = parser.constructParseErrorInfo('fail!', null, + * let infoObj = parser.constructParseErrorInfo('fail!', null, * parser.collect_expected_token_set(state), true); - * var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); + * let retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); * * originalParseError: function(str, hash, ExceptionClass), * The basic \`parseError\` handler provided by JISON. @@ -33113,212 +33124,7 @@ generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComm * flex: boolean * optional: \`true\` ==> flex-like lexing behaviour where the rules are tested * exhaustively to find the longest match. - * backtrack_lexer: boolean (⅏ 센 ⅊ ⁖ ⁘ ⁙ ⁚ ⁛ ⁜ ⁝ ⁞ † ‡ - a⯈b - ∀ ∁ ∂ ∃ ∄ ∅ ∆ ∇ ∈ ∉ ∊ ∋ ∌ ∍ ∎ ∏ -U+221x ∐ ∑ − ∓ ∔ ∕ ∖ ∗ ∘ ∙ √ ∛ ∜ ∝ ∞ ∟ -U+222x ∠ ∡ ∢ ∣ ∤ ∥ ∦ ∧ ∨ ∩ ∪ ∫ ∬ ∭ ∮ ∯ -U+223x ∰ ∱ ∲ ∳ ∴ ∵ ∶ ∷ ∸ ∹ ∺ ∻ ∼ ∽ ∾ ∿ -U+224x ≀ ≁ ≂ ≃ ≄ ≅ ≆ ≇ ≈ ≉ ≊ ≋ ≌ ≍ ≎ ≏ -U+225x ≐ ≑ ≒ ≓ ≔ ≕ ≖ ≗ ≘ ≙ ≚ ≛ ≜ ≝ ≞ ≟ -U+226x ≠ ≡ ≢ ≣ ≤ ≥ ≦ ≧ ≨ ≩ ≪ ≫ ≬ ≭ ≮ ≯ -U+227x ≰ ≱ ≲ ≳ ≴ ≵ ≶ ≷ ≸ ≹ ≺ ≻ ≼ ≽ ≾ ≿ -U+228x ⊀ ⊁ ⊂ ⊃ ⊄ ⊅ ⊆ ⊇ ⊈ ⊉ ⊊ ⊋ ⊌ ⊍ ⊎ ⊏ -U+229x ⊐ ⊑ ⊒ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊜ ⊝ ⊞ ⊟ -U+22Ax ⊠ ⊡ ⊢ ⊣ ⊤ ⊥ ⊦ ⊧ ⊨ ⊩ ⊪ ⊫ ⊬ ⊭ ⊮ ⊯ -U+22Bx ⊰ ⊱ ⊲ ⊳ ⊴ ⊵ ⊶ ⊷ ⊸ ⊹ ⊺ ⊻ ⊼ ⊽ ⊾ ⊿ -U+22Cx ⋀ ⋁ ⋂ ⋃ ⋄ ⋅ ⋆ ⋇ ⋈ ⋉ ⋊ ⋋ ⋌ ⋍ ⋎ ⋏ -U+22Dx ⋐ ⋑ ⋒ ⋓ ⋔ ⋕ ⋖ ⋗ ⋘ ⋙ ⋚ ⋛ ⋜ ⋝ ⋞ ⋟ -U+22Ex ⋠ ⋡ ⋢ ⋣ ⋤ ⋥ ⋦ ⋧ ⋨ ⋩ ⋪ ⋫ ⋬ ⋭ ⋮ ⋯ -U+22Fx ⋰ ⋱ ⋲ ⋳ ⋴ ⋵ ⋶ ⋷ ⋸ ⋹ ⋺ ⋻ ⋼ ⋽ ⋾ ⋿) -U+230x ⌀ ⌁ ⌂ ⌃ ⌄ ⌅ ⌆ ⌇ ⌈ ⌉ ⌊ ⌋ ⌌ ⌍ ⌎ ⌏ -U+231x ⌐ ⌑ ⌒ ⌓ ⌔ ⌕ ⌖ ⌗ ⌘ ⌙ ⌚ ⌛ ⌜ ⌝ ⌞ ⌟ -U+232x ⌠ ⌡ ⌢ ⌣ ⌤ ⌥ ⌦ ⌧ ⌨ 〈 〉 ⌫ ⌬ ⌭ ⌮ ⌯ -U+233x ⌰ ⌱ ⌲ ⌳ ⌴ ⌵ ⌶ ⌷ ⌸ ⌹ ⌺ ⌻ ⌼ ⌽ ⌾ ⌿ -U+234x ⍀ ⍁ ⍂ ⍃ ⍄ ⍅ ⍆ ⍇ ⍈ ⍉ ⍊ ⍋ ⍌ ⍍ ⍎ ⍏ -U+235x ⍐ ⍑ ⍒ ⍓ ⍔ ⍕ ⍖ ⍗ ⍘ ⍙ ⍚ ⍛ ⍜ ⍝ ⍞ ⍟ -U+236x ⍠ ⍡ ⍢ ⍣ ⍤ ⍥ ⍦ ⍧ ⍨ ⍩ ⍪ ⍫ ⍬ ⍭ ⍮ ⍯ -U+237x ⍰ ⍱ ⍲ ⍳ ⍴ ⍵ ⍶ ⍷ ⍸ ⍹ ⍺ ⍻ ⍼ ⍽ ⍾ ⍿ -U+238x ⎀ ⎁ ⎂ ⎃ ⎄ ⎅ ⎆ ⎇ ⎈ ⎉ ⎊ ⎋ ⎌ ⎍ ⎎ ⎏ -U+239x ⎐ ⎑ ⎒ ⎓ ⎔ ⎕ ⎖ ⎗ ⎘ ⎙ ⎚ ⎛ ⎜ ⎝ ⎞ ⎟ -U+23Ax ⎠ ⎡ ⎢ ⎣ ⎤ ⎥ ⎦ ⎧ ⎨ ⎩ ⎪ ⎫ ⎬ ⎭ ⎮ ⎯ -U+23Bx ⎰ ⎱ ⎲ ⎳ ⎴ ⎵ ⎶ ⎷ ⎸ ⎹ ⎺ ⎻ ⎼ ⎽ ⎾ ⎿ -U+23Cx ⏀ ⏁ ⏂ ⏃ ⏄ ⏅ ⏆ ⏇ ⏈ ⏉ ⏊ ⏋ ⏌ ⏍ ⏎ ⏏ -U+23Dx ⏐ ⏑ ⏒ ⏓ ⏔ ⏕ ⏖ ⏗ ⏘ ⏙ ⏚ ⏛ ⏜ ⏝ ⏞ ⏟ -U+23Ex ⏠ ⏡ ⏢ ⏣ ⏤ ⏥ ⏦ ⏧ ⏨ ⏩ ⏪ ⏫ ⏬ ⏭ ⏮ ⏯ -U+23Fx ⏰ ⏱ ⏲ ⏳ ⏴ ⏵ ⏶ ⏷ ⏸ ⏹ ⏺ ⏻ ⏼ ⏽ ⏾ ⏿ - -U+260x ☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☎ ☏ -U+261x ☐ ☑ ☒ ☓ ☔ ☕ ☖ ☗ ☘ ☙ ☚ ☛ ☜ ☝ ☞ ☟ -U+262x ☠ ☡ ☢ ☣ ☤ ☥ ☦ ☧ ☨ ☩ ☪ ☫ ☬ ☭ ☮ ☯ -U+263x ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷ ☸ ☹ ☺ ☻ ☼ ☽ ☾ ☿ -U+264x ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇ ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ -U+265x ♐ ♑ ♒ ♓ ♔ ♕ ♖ ♗ ♘ ♙ ♚ ♛ ♜ ♝ ♞ ♟ -U+266x ♠ ♡ ♢ ♣ ♤ ♥ ♦ ♧ ♨ ♩ ♪ ♫ ♬ ♭ ♮ ♯ -U+267x ♰ ♱ ♲ ♳ ♴ ♵ ♶ ♷ ♸ ♹ ♺ ♻ ♼ ♽ ♾ ♿ -U+268x ⚀ ⚁ ⚂ ⚃ ⚄ ⚅ ⚆ ⚇ ⚈ ⚉ ⚊ ⚋ ⚌ ⚍ ⚎ ⚏ -U+269x ⚐ ⚑ ⚒ ⚓ ⚔ ⚕ ⚖ ⚗ ⚘ ⚙ ⚚ ⚛ ⚜ ⚝ ⚞ ⚟ -U+26Ax ⚠ ⚡ ⚢ ⚣ ⚤ ⚥ ⚦ ⚧ ⚨ ⚩ ⚪ ⚫ ⚬ ⚭ ⚮ ⚯ -U+26Bx ⚰ ⚱ ⚲ ⚳ ⚴ ⚵ ⚶ ⚷ ⚸ ⚹ ⚺ ⚻ ⚼ ⚽ ⚾ ⚿ -U+26Cx ⛀ ⛁ ⛂ ⛃ ⛄ ⛅ ⛆ ⛇ ⛈ ⛉ ⛊ ⛋ ⛌ ⛍ ⛎ ⛏ -U+26Dx ⛐ ⛑ ⛒ ⛓ ⛔ ⛕ ⛖ ⛗ ⛘ ⛙ ⛚ ⛛ ⛜ ⛝ ⛞ ⛟ -U+26Ex ⛠ ⛡ ⛢ ⛣ ⛤ ⛥ ⛦ ⛧ ⛨ ⛩ ⛪ ⛫ ⛬ ⛭ ⛮ ⛯ -U+26Fx ⛰ ⛱ ⛲ ⛳ ⛴ ⛵ ⛶ ⛷ ⛸ ⛹ ⛺ ⛻ ⛼ ⛽ ⛾ ⛿ - - ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ☛ ☞ ✌ ✍ ✎ ✏ -✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -✠ ✡ ✢ ✣ ✤ ✥ ✦ ✧ ★ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ● ❍ ■ ❏ -☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ❐ ❑ ❒ ▲ ▼ ◆ ❖ -◗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ - -U+270x ✀ ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ✊ ✋ ✌ ✍ ✎ ✏ -U+271x ✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -U+272x ✠ ✡ ✢ ✣ a✤b a✥b a✦b a✧b ✨ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -U+273x ✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -U+274x ❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ❌ ❍ ❎ ❏ -U+275x ❐ ❑ ❒ ❓ ❔ ❕ ❖ ❗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ ❟ -U+276x ❠ ❡ ❢ ❣ ❤ ❥ ❦ ❧ ❨ ❩ ❪ ❫ ❬ ❭ ❮ a❯b -U+277x ❰ ❱ ❲ ❳ ❴ ❵ ❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ ❾ ❿ -U+278x ➀ ➁ ➂ ➃ ➄ ➅ ➆ ➇ ➈ ➉ ➊ ➋ ➌ ➍ ➎ ➏ -U+279x ➐ ➑ ➒ ➓ ➔ ➕ ➖ ➗ ➘ ➙ ➚ ➛ ➜ ➝ ➞ ➟ -U+27Ax ➠ ➡ ➢ ➣ ➤ ➥ ➦ ➧ a➨b ➩ ➪ ➫ ➬ ➭ ➮ ➯ -U+27Bx ➰ a➱b ➲ ➳ ➴ ➵ ➶ ➷ ➸ ➹ ➺ ➻ ➼ ➽ ➾ ➿ - -U+2580 ▀ Upper half block -U+2581 ▁ Lower one eighth block -U+2582 ▂ Lower one quarter block -U+2583 ▃ Lower three eighths block -U+2584 ▄ Lower half block -U+2585 ▅ Lower five eighths block -U+2586 ▆ Lower three quarters block -U+2587 ▇ Lower seven eighths block -U+2588 █ Full block -U+2589 ▉ Left seven eighths block -U+258A ▊ Left three quarters block -U+258B ▋ Left five eighths block -U+258C ▌ Left half block -U+258D ▍ Left three eighths block -U+258E ▎ Left one quarter block -U+258F ▏ Left one eighth block -U+2590 ▐ Right half block -U+2591 ░ Light shade -U+2592 ▒ Medium shade -U+2593 ▓ Dark shade -U+2594 ▔ Upper one eighth block -U+2595 ▕ Right one eighth block -U+2596 ▖ Quadrant lower left -U+2597 ▗ Quadrant lower right -U+2598 ▘ Quadrant upper left -U+2599 ▙ Quadrant upper left and lower left and lower right -U+259A ▚ Quadrant upper left and lower right -U+259B ▛ Quadrant upper left and upper right and lower left -U+259C ▜ Quadrant upper left and upper right and lower right -U+259D ▝ Quadrant upper right -U+259E ▞ Quadrant upper right and lower left -U+259F ▟ Quadrant upper right and lower left and lower right -Geometric Shapes -Main articles: Geometric Shapes (Unicode block) and Geometric Shapes Extended (Unicode block) -[hide]Code Glyph Description -U+25A0 ■ Black square -U+25A1 □ White square -U+25A2 ▢ White square with rounded corners -U+25A3 ▣ White square containing small black square -U+25A4 ▤ Square with horizontal fill -U+25A5 ▥ Square with vertical fill -U+25A6 ▦ Square with orthogonal crosshatch fill -U+25A7 ▧ Square with upper left to lower right fill -U+25A8 ▨ Square with upper right to lower left fill -U+25A9 ▩ Square with diagonal crosshatch fill -U+25AA ▪ Black small square -U+25AB ▫ White small square -U+25AC ▬ Black rectangle -U+25AD ▭ White rectangle -U+25AE ▮ Black vertical rectangle -U+25AF ▯ White vertical rectangle -U+25B0 ▰ Black parallelogram -U+25B1 ▱ White parallelogram -U+25B2 ▲ Black up-pointing triangle -U+25B3 △ White up-pointing triangle -U+25B4 ▴ Black up-pointing small triangle -U+25B5 ▵ White up-pointing small triangle -U+25B6 ▶ Black right-pointing triangle -U+25B7 ▷ White right-pointing triangle -U+25B8 ▸ Black right-pointing small triangle -U+25B9 ▹ White right-pointing small triangle -U+25BA ► Black right-pointing pointer -U+25BB ▻ White right-pointing pointer -U+25BC ▼ Black down-pointing triangle -U+25BD ▽ White down-pointing triangle -U+25BE ▾ Black down-pointing small triangle -U+25BF ▿ White down-pointing small triangle -U+25C0 ◀ Black left-pointing triangle -U+25C1 ◁ White left-pointing triangle -U+25C2 ◂ Black left-pointing small triangle -U+25C3 ◃ White left-pointing small triangle -U+25C4 ◄ Black left-pointing pointer -U+25C5 ◅ White left-pointing pointer -U+25C6 ◆ Black diamond -U+25C7 ◇ White diamond -U+25C8 ◈ White diamond containing small black diamond -U+25C9 ◉ Fisheye -U+25CA ◊ Lozenge -U+25CB ○ White circle -U+25CC ◌ Dotted circle -U+25CD ◍ Circle with vertical fill -U+25CE ◎ Bullseye -U+25CF ● Black circle -U+25D0 ◐ Circle with left half black -U+25D1 ◑ Circle with right half black -U+25D2 ◒ Circle with lower half black -U+25D3 ◓ Circle with upper half black -U+25D4 ◔ Circle with upper right quadrant black -U+25D5 ◕ Circle with all but upper left quadrant black -U+25D6 ◖ Left half circle black -U+25D7 ◗ Right half black circle -U+25D8 ◘ Inverse bullet -U+25D9 ◙ Inverse white circle -U+25DA ◚ Upper half inverse white circle -U+25DB ◛ Lower half inverse white circle -U+25DC ◜ Upper left quadrant circular arc -U+25DD ◝ Upper right quadrant circular arc -U+25DE ◞ Lower right quadrant circular arc -U+25DF ◟ Lower left quadrant circular arc -U+25E0 ◠ Upper half circle -U+25E1 ◡ Lower half circle -U+25E2 ◢ Black lower right triangle -U+25E3 ◣ Black lower left triangle -U+25E4 ◤ Black upper left triangle -U+25E5 ◥ Black upper right triangle -U+25E6 ◦ White bullet -U+25E7 ◧ Square with left half black -U+25E8 ◨ Square with right half black -U+25E9 ◩ Square with upper left diagonal half black -U+25EA ◪ Square with lower right diagonal half black -U+25EB ◫ White square with vertical bisecting line -U+25EC ◬ White up-pointing triangle with dot -U+25ED ◭ Up-pointing triangle with left half black -U+25EE ◮ Up-pointing triangle with right half black -U+25EF ◯ Large circle -U+25F0 ◰ White square with upper left quadrant -U+25F1 ◱ White square with lower left quadrant -U+25F2 ◲ White square with lower right quadrant -U+25F3 ◳ White square with upper right quadrant -U+25F4 ◴ White circle with upper left quadrant -U+25F5 ◵ White circle with lower left quadrant -U+25F6 ◶ White circle with lower right quadrant -U+25F7 ◷ White circle with upper right quadrant -U+25F8 ◸ Upper left triangle -U+25F9 ◹ Upper right triangle -U+25FA ◺ Lower-left triangle -U+25FB ◻ White medium square -U+25FC ◼ Black medium square -U+25FD ◽ White medium small square -U+25FE ◾ Black medium small square -U+25FF ◿ Lower right triangle - - + * backtrack_lexer: boolean * optional: \`true\` ==> lexer regexes are tested in order and for invoked; * the lexer terminates the scan when a token is returned by the action code. * xregexp: boolean @@ -33335,7 +33141,7 @@ U+25FF ◿ Lower right triangle generatorMixin.generate = function parser_generate(opt) { opt = this.__prepareOptions(opt); - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -33361,19 +33167,19 @@ generatorMixin.generate = function parser_generate(opt) { generatorMixin.generateAMDModule = function generateAMDModule(opt) { opt = this.__prepareOptions(opt); - var module = this.generateModule_(); - var out = [ + let module = this.generateModule_(); + let out = [ this.generateGenericHeaderComment(), '', 'define(function (require) {', module.initCode, module.commonCode, '', - 'var parser = ' + module.moduleCode, + 'let parser = ' + module.moduleCode, module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(lexSrc); out.push('parser.lexer = lexer;'); @@ -33381,7 +33187,7 @@ generatorMixin.generateAMDModule = function generateAMDModule(opt) { out.push('', module.moduleInclude, '', 'return parser;'); out.push('});'); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; }; @@ -33389,35 +33195,35 @@ generatorMixin.generateAMDModule = function generateAMDModule(opt) { lrGeneratorMixin.generateESModule = function generateESModule(opt) { opt = this.__prepareOptions(opt); - var module = this.generateModule_(); - var out = [ + let module = this.generateModule_(); + let out = [ this.generateGenericHeaderComment(), '', module.initCode, module.commonCode, '', - 'var parser = ' + module.moduleCode, - module.modulePostlude, + 'let parser = ' + module.moduleCode, + module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(this.lexer.generateModule()); out.push('parser.lexer = lexer;'); } out.push('', module.moduleInclude, ''); - var exportMain = ''; - var invokeMain = ''; + let exportMain = ''; + let invokeMain = ''; if (!opt.noMain) { - var moduleNameAsCode = String(opt.moduleMain || commonJsMain); - var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); + let moduleNameAsCode = String(opt.moduleMain || commonJsMain); + let moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); out.push(rmCommonWS$5` ${moduleImportsAsCode} - var yymain = ${moduleNameAsCode.trim()}; + let yymain = ${moduleNameAsCode.trim()}; function yyExecMain() { yymain(process.argv.slice(1)); @@ -33453,7 +33259,7 @@ lrGeneratorMixin.generateESModule = function generateESModule(opt) { }; `); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; }; @@ -33461,11 +33267,11 @@ lrGeneratorMixin.generateESModule = function generateESModule(opt) { generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { opt = this.__prepareOptions(opt); - var moduleName = opt.moduleName; - var main = ''; + let moduleName = opt.moduleName; + let main = ''; if (!opt.noMain) { - var moduleNameAsCode = String(opt.moduleMain || commonJsMain); - var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); + let moduleNameAsCode = String(opt.moduleMain || commonJsMain); + let moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); main = rmCommonWS$5` @@ -33480,7 +33286,7 @@ generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { } `; } - var out = this.generateModule(opt) + + let out = this.generateModule(opt) + rmCommonWS$5` @@ -33501,17 +33307,16 @@ generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { generatorMixin.generateModule = function generateModule(opt) { opt = this.__prepareOptions(opt); - var moduleName = opt.moduleName; - var out = this.generateGenericHeaderComment(); + let moduleName = opt.moduleName; + let out = this.generateGenericHeaderComment(); - var self = this; + let self = this; function _generateNamespace(namespaces, previousNamespace, callback) { - var subModuleName = namespaces.shift(); + let subModuleName = namespaces.shift(); if (subModuleName != null) { - var moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; + let moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; if (namespaces.length > 0) { - return 'var ' + subModuleName + ';\n' - + '(function (' + subModuleName + ') {\n' + return '(function (' + subModuleName + ') {\n' + _generateNamespace(namespaces, subModuleName, callback) + '\n})(' + subModuleName + (previousNamespace == null ? '' : ' = ' + moduleName) + ' || (' + moduleName + ' = {}));\n'; } @@ -33520,14 +33325,14 @@ generatorMixin.generateModule = function generateModule(opt) { return ''; } - var sourceCodeDef = self.generateModuleExpr(); + let sourceCodeDef = self.generateModuleExpr(); out += ` ${sourceCodeDef.init} `; out += _generateNamespace(moduleName.split('.'), null, function _generateNamespace_cb(moduleName) { - var name = (moduleName.match(/\./) ? moduleName : 'var ' + moduleName); + let name = (moduleName.match(/\./) ? moduleName : 'let ' + moduleName); return ` ${name} = ${sourceCodeDef.src} `; @@ -33539,24 +33344,23 @@ generatorMixin.generateModule = function generateModule(opt) { generatorMixin.generateModuleExpr = function generateModuleExpr() { - var out; - var opt = this.__prepareOptions(); - var module = this.generateModule_(); + let opt = this.__prepareOptions(); + let module = this.generateModule_(); - out = [ + let out = [ '(function () {', module.commonCode, '', - 'var parser = ' + module.moduleCode, - module.modulePostlude, + 'let parser = ' + module.moduleCode, + module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(lexSrc); out.push('parser.lexer = lexer;'); } - out = out.concat(['', + out = out.concat([ '', module.moduleInclude, '', 'function Parser() {', @@ -33569,7 +33373,7 @@ generatorMixin.generateModuleExpr = function generateModuleExpr() { '})();' ]); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return { @@ -33579,7 +33383,7 @@ generatorMixin.generateModuleExpr = function generateModuleExpr() { }; function removeUnusedKernelFeatures(parseFn, info) { - var actionFn = info.performAction; + let actionFn = info.performAction; if (info.actionsAreAllDefault) { // in this case, there's no need to call the parseAction function at all: @@ -33621,7 +33425,7 @@ function removeUnusedKernelFeatures(parseFn, info) { // if (typeof lexer.yyleng === 'undefined') { // lexer.yyleng = 0; // } - // var yyleng; + // let yyleng; // ... parseFn = parseFn @@ -33640,7 +33444,7 @@ function removeUnusedKernelFeatures(parseFn, info) { // remove: // - // var yylineno; + // let yylineno; // ... parseFn = parseFn @@ -33695,7 +33499,7 @@ function removeUnusedKernelFeatures(parseFn, info) { // remove: // - // var yyloc = lexer.yylloc; + // let yyloc = lexer.yylloc; // lstack[sp] = yyloc; // ... // lstack[sp] = copy_yylloc(lexer.yylloc); @@ -33735,11 +33539,11 @@ function removeUnusedKernelFeatures(parseFn, info) { // } // // and - // + // // if (sp >= 0 && typeof vstack[sp] !== 'undefined') { // retval = vstack[sp]; // } - // + // // but keep the yyval declaration as either location tracking MAY // still be employed by the grammar OR the grammar uses advanced // code which uses `yyval` as a run-time store which carries data @@ -33785,13 +33589,13 @@ function removeUnusedKernelFeatures(parseFn, info) { if (info.actionsAreAllDefault) { // remove // - // var yyval = { + // let yyval = { // $: true, // _$: undefined, // yy: sharedState_yy // }; parseFn = parseFn - .replace(/\s+var yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); + .replace(/\s+let yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); } } @@ -33806,10 +33610,14 @@ function removeUnusedKernelFeatures(parseFn, info) { // remove: // - // var yydebug = false; + // let yydebug = false; // ... and delete yydebug function definition ... // ... // if (yydebug) yydebug(...); + // ... + // if (yydebug) { + // yydebug(...); + // } // // and // @@ -33820,9 +33628,10 @@ function removeUnusedKernelFeatures(parseFn, info) { parseFn = parseFn - .replace(/\s+var yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') - // strip multi-line `if (debug) yydebug(..., {...});` statements + .replace(/\s+let yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') + // strip multi-line `if (debug) { yydebug(..., {...}); }` statements // also strip simple yet possibly multi-line `if (debug) yydebug('...');` statements + .replace(/\n\s+if\s+\(yydebug\)\s+\{[\r\n]+\s+yydebug\([^]+?}\);[\s\r\n]+}\s*/g, '\n\n\n\n\n\n\n\n\n') .replace(/\n\s+if\s+\(yydebug\)\s+yydebug\([^]+?['}]\);[^\r\n]*?/g, '\n\n\n\n\n\n\n\n\n') // strip single-line `yydebug(...);` statements .replace(/^.*?\byydebug\b[^;]+?\);[^\r\n]*?$/gm, '') @@ -33907,8 +33716,8 @@ function removeUnusedKernelFeatures(parseFn, info) { */ parseFn = parseFn .replace(/\s+try \{([\s\r\n]+this\.__reentrant_call_depth[\s\S]+?)\} catch \(ex\) \{[\s\S]+?\} finally \{([^]+?)\}\s+\/\/\s+\/finally/, function replace_noTryCatch(m, p1, p2) { - p1 = p1.replace(/^ /mg, ' '); - p2 = p2.replace(/^ /mg, ' '); + p1 = p1.replace(/^ {8}/mg, ' '); + p2 = p2.replace(/^ {8}/mg, ' '); return '\n' + p1 + '\n // ... AND FINALLY ...\n' + p2; }) .replace(/^[^\n]+\b__reentrant_call_depth\b[^\n]+$/gm, '\n'); @@ -33966,29 +33775,29 @@ function removeUnusedKernelFeatures(parseFn, info) { // // https://github.com/zaach/jison/pull/332 function expandParseArguments(parseFn, self) { - var arglist = self.parseParams; + let arglist = self.parseParams; if (!arglist || arglist.length === 0) { parseFn = parseFn.replace(/, parseParams\b/g, ''); parseFn = parseFn.replace(/\bparseParams\b/g, ''); - parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers:\s+parseParamsAsMembers\b/g, ''); + parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers\b/g, ''); } else { parseFn = parseFn.replace(/, parseParams\b/g, ', ' + arglist.join(', ')); parseFn = parseFn.replace(/\bparseParams\b/g, arglist.join(', ')); - parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers:\s+parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { - var s = ','; + parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { + let s = ','; // determine longest name of the bunch (for formatting the generated code) - var max_k_len = 0; - for (var i = 0, len = arglist.length; i < len; i++) { - var k = arglist[i]; + let max_k_len = 0; + for (let i = 0, len = arglist.length; i < len; i++) { + let k = arglist[i]; max_k_len = Math.max(max_k_len, k.length); } - var wsi2 = (new Array(max_k_len + 1)).join(' '); + let 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 i = 0, len = arglist.length; i < len; i++) { - var k = arglist[i]; + for (let i = 0, len = arglist.length; i < len; i++) { + let k = arglist[i]; s += '\n' + ws + k + ': ' + k + (i < len - 1 ? ',' + wsi2.substr(0, max_k_len - k.length - 1) : wsi2.substr(0, max_k_len - k.length)) + ' // parseParams::' + k; } return s; @@ -34023,17 +33832,17 @@ function pickOneOfTwoCodeAlternatives(parseFn, pick_A_not_B, A_start_marker, B_s } function addOrRemoveTokenStack(fn, wantTokenStack) { - var parseFn = fn; + let parseFn = fn; // We don't use the Esprima+Escodegen toolchain as those loose the code comments easily; // instead we just chop the code using labels as sentinels for our chopping-it-up regexes: // // if (wantTokenStack) { // try { - // var ast = esprima.parse(parseFn); - // var stackAst = esprima.parse(String(tokenStackLex)).body[0]; + // let ast = esprima.parse(parseFn); + // let stackAst = esprima.parse(String(tokenStackLex)).body[0]; // stackAst.id.name = 'lex'; // - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); // // labeled[0].body = stackAst; // @@ -34043,7 +33852,7 @@ function addOrRemoveTokenStack(fn, wantTokenStack) { // } // } else { // // remove the line: - // // var tstack = []; // token stack + // // let tstack = []; // token stack // parseFn = parseFn.replace(/tstack = .*$/m, ''); // return parseFn; // } @@ -34052,23 +33861,23 @@ function addOrRemoveTokenStack(fn, wantTokenStack) { if (wantTokenStack) { // And rename the `tokenStackLex` function to become the new `lex`: return parseFn.replace(/\btokenStackLex\b/g, 'lex'); - } else { - // Also nuke the support declaration statement: - // var tstack = []; - return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); } + // Also nuke the support declaration statement: + // let tstack = []; + return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); + } // returns parse function with/without error recovery code function pickErrorHandlingChunk(fn, hasErrorRecovery) { - var parseFn = fn; + let parseFn = fn; // We don't use the Esprima+Escodegen toolchain as those loose the code comments easily; // instead we just chop the code using labels as sentinels for our chopping-it-up regexes: // try { - // var ast = esprima.parse(parseFn); + // let ast = esprima.parse(parseFn); - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("' + + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("' + // (!hasErrorRecovery ? '_handle_error_with_recovery' : '_handle_error_no_recovery') + // '"))', ast); // Jison.print('labeled: ', labeled); @@ -34084,7 +33893,7 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // and some post-coital touch-ups: if (!hasErrorRecovery) { // Also nuke the support declaration statement: - // var recovering = 0; + // let recovering = 0; // and the recovery support statements: // if (recovering > 0) { // recovering--; @@ -34093,7 +33902,7 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // , recovering: recovering // ASSERT(recovering === 0); parseFn = parseFn - .replace(/^\s*var recovering.*$/gm, '') + .replace(/^\s*let recovering.*$/gm, '') .replace(/, recovering: recovering/g, '') .replace(/^.*?recovering =.*$/gm, '') .replace(/^\s+recovering[,]?\s*$/gm, '') @@ -34105,11 +33914,11 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // ... KILL this chunk ... // } .replace(/\s+if[^a-z]+preErrorSymbol.*?\{\s*\/\/[^\n]+([\s\S]+?)\} else \{[\s\S]+?\}\n\s+\}\n/g, '\n$1\n\n\n\n') - .replace(/^\s+(?:var )?preErrorSymbol = .*$/gm, '') + .replace(/^\s+(?:let )?preErrorSymbol = .*$/gm, '') .replace(/^.*?\bpreErrorSymbol =.*$/gm, '') // And nuke the support declaration statement: - // var lastEofErrorStateDepth = 0; - .replace(/^\s*var lastEofErrorStateDepth.*$/gm, ''); + // let lastEofErrorStateDepth = 0; + .replace(/^\s*let lastEofErrorStateDepth.*$/gm, ''); } return parseFn; } @@ -34118,7 +33927,7 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // - module.commonCode: initialization code that should be placed before the module // - module.moduleCode: code that creates the module object lrGeneratorMixin.generateModule_ = function generateModule_() { - var parseFn = String(parser$4.parse); + let parseFn = String(parser$4.parse); parseFn = pickErrorHandlingChunk(parseFn, this.hasErrorRecovery); parseFn = addOrRemoveTokenStack(parseFn, this.options.tokenStack); @@ -34127,9 +33936,9 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { parseFn = expandParseArguments(parseFn, this); - var errorClassCode = this.generateErrorClass(); + let errorClassCode = this.generateErrorClass(); - var exportDest = this.options.exportAllTables; + let exportDest = this.options.exportAllTables; assert$1(exportDest); // store the parse tables: @@ -34137,10 +33946,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { exportDest.defaultParseActions = this.defaultActions; exportDest.parseProductions = this.productions_; - var exportSourceCode = this.options.exportSourceCode; - assert$1(exportSourceCode); - - var tableCode; + let tableCode; switch (this.options.compressTables | 0) { case 0: // no compression tableCode = this.generateTableCode0(this.table, this.defaultActions, this.productions_); @@ -34163,29 +33969,27 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // Generate the initialization code - var initCode = [].concat( + let initCode = [].concat( this.moduleInit.getInitCodeSection('imports'), this.moduleInit.getInitCodeSection('init') ); - var commonCode = [].concat( + let commonCode = [].concat( this.moduleInit.getInitCodeSection('required'), errorClassCode.commonCode, errorClassCode.moduleCode, - ['\nYY_REMAINING_INIT_CODE_SECTIONS_GO_HERE\n'], + [ '\nYY_REMAINING_INIT_CODE_SECTIONS_GO_HERE\n' ], tableCode.commonCode ); - // sort hash table by key to produce a nicer output: function produceSymbolTable(tbl) { - var a = Object.keys(tbl); + let a = Object.keys(tbl); a.sort(); - var nt = {}; - var k; - for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; + let nt = {}; + for (let i = 0, len = a.length; i < len; i++) { + let k = a[i]; // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number // and we do not want `$eof`/`EOF` to show up in the symbol tables of generated parsers @@ -34199,12 +34003,11 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // swap key and value and then sort hash table by key to produce a nicer output: function produceTerminalTable(tbl) { - var a = Object.keys(tbl); - var nt = {}; - var k, v; - for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; - v = tbl[k]; + let a = Object.keys(tbl); + let nt = {}; + for (let i = 0, len = a.length; i < len; i++) { + let k = a[i]; + let v = tbl[k]; nt[v] = +k; // convert numeric key back to number type; all terminals have numeric keys } return produceSymbolTable(nt); @@ -34212,71 +34015,71 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { function produceProductionsForDebugging(options, symbols, base) { function get_orig_symbol(s) { - var a = s.split(':'); + let a = s.split(':'); if (a.length === 1 || a[0] === '') { return { state: -1, symbol: s }; } - var state = a[0]; + let state = a[0]; a.shift(); return { state: +state, - symbol: a.join(':'), + symbol: a.join(':') }; } function get_orig_symbol_set(arr) { - var rv = {}; - for (var i = 0, len = arr.length; i < len; i++) { - var item = arr[i]; - var symbol = get_orig_symbol(item); + let rv = {}; + for (let i = 0, len = arr.length; i < len; i++) { + let item = arr[i]; + let symbol = get_orig_symbol(item); rv[symbol.symbol] = symbol.state; } return Object.keys(rv); } - var tbl = this.nonterminals; - var sym = this.symbols_ || symbols; + let tbl = this.nonterminals; + let sym = this.symbols_ || symbols; if (!options.outputDebugTables && !options.exportAllTables.enabled) { return undefined; } - var prods = { + let prods = { ids: {}, states: {}, rules: {}, nonterminals: {}, symbols: {}, first: {}, - follows: {}, + follows: {} }; - var self = this; + let self = this; this.productions.forEach(function Follow_prod_forEach_genDebugTable(production, k) { - var nonterm = production.symbol; + let nonterm = production.symbol; prods.states[k] = nonterm; prods.ids[nonterm] = sym[nonterm]; - var lst = prods.rules[nonterm] || {}; + let lst = prods.rules[nonterm] || {}; lst[k] = gen_lalr_states_production(production, k, false, k, true); prods.rules[nonterm] = lst; }); function gen_nonterminal(nt) { - var l = nt.productions._items; - var lst = l.map(function (p, i) { + let l = nt.productions._items; + let lst = l.map(function (p, i) { return gen_lalr_states_production(p, i, false, false, false); }); - var rv = { + let rv = { symbol: nt.symbol, productions: lst, first: nt.first, base_first: get_orig_symbol_set(nt.first), follows: nt.follows, base_follows: get_orig_symbol_set(nt.follows), - nullable: nt.nullable, + nullable: nt.nullable }; // clean up structure: ditch superfluous elements: @@ -34290,7 +34093,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { return rv; } - for (var key in tbl) { + for (let key in tbl) { prods.nonterminals[key] = gen_nonterminal(tbl[key]); } @@ -34299,9 +34102,9 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { } function gen_lalr_states_production(production, index, dotPosition, state, patch_base) { - var nonterm = production.symbol; - var hlen = production.handle.length; - var rulestr = production.handle.map(function (t, idx) { + let nonterm = production.symbol; + let hlen = production.handle.length; + let rulestr = production.handle.map(function (t, idx) { if (!t) { t = '%epsilon'; } @@ -34315,7 +34118,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { rulestr += ' ⬤'; } - var base_rulestr = production.handle.map(function (t) { + let base_rulestr = production.handle.map(function (t) { if (!t) { t = '%epsilon'; } @@ -34323,7 +34126,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { return t; }).join(' '); - var rv = { + let rv = { symbol: nonterm, base_symbol: get_orig_symbol(nonterm).symbol, handle: rulestr, @@ -34342,12 +34145,11 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { }; // Determine state for given production, if it's not a production that's listed as part of a state: - var chk, idx; - var lst = prods.rules[nonterm]; - chk = rv.symbol + ' : ' + rv.handle; - for (idx in lst) { + let lst = prods.rules[nonterm]; + let chk = rv.symbol + ' : ' + rv.handle; + for (let idx in lst) { idx = +idx; - var p = lst[idx]; + let p = lst[idx]; if (p) { if (p.symbol + ' : ' + p.handle === chk) { assert$1(rv.state === -1); @@ -34360,9 +34162,9 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // Try to reference base productions from newg child productions and vice versa: chk = rv.base_symbol + ' : ' + rv.base_handle; if (base && base.rules) { - var pr = base.rules[rv.base_symbol]; - for (idx in pr) { - var bprod = pr[idx]; + let pr = base.rules[rv.base_symbol]; + for (let idx in pr) { + let bprod = pr[idx]; if (bprod.symbol + ' : ' + bprod.handle === chk) { assert$1(rv.base_state === -1); rv.base_state = bprod.state; @@ -34396,13 +34198,13 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { if (this.states) { prods.lalr_states = []; - var these_states = this.states; + let these_states = this.states; these_states.forEach(function traverse_states(state, i) { //assert(state.inadequate ? these_states.inadequate : true); state.forEach(function traverse_state(item, j) { // is this a REDUCE state? - var nterm_first = self.nonterminals[item.production.symbol].first; - var rv = { + let nterm_first = self.nonterminals[item.production.symbol].first; + let rv = { state: i, item_index: j, is_reduce_state: (item.dotPosition === item.production.handle.length), @@ -34415,7 +34217,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { nterm_first: nterm_first, base_nterm_first: get_orig_symbol_set(nterm_first), prod_first: item.production.first, - base_prod_first: get_orig_symbol_set(item.production.first), + base_prod_first: get_orig_symbol_set(item.production.first) }; // clean up structure: ditch superfluous elements: @@ -34434,13 +34236,12 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { }); } - var nt = tbl; - var sbn; - for (sbn in nt) { - var orig_symbol = get_orig_symbol(sbn); - var item = nt[sbn]; - var firsts = item.first; - var follows = item.follows; + let nt = tbl; + for (let sbn in nt) { + let orig_symbol = get_orig_symbol(sbn); + let item = nt[sbn]; + let firsts = item.first; + let follows = item.follows; if (!prods.symbols[orig_symbol.symbol]) { prods.symbols[orig_symbol.symbol] = orig_symbol.state; } @@ -34455,10 +34256,10 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { prods.follows[orig_symbol.symbol] = prods.follows[orig_symbol.symbol].concat(follows); } } - for (sbn in prods.first) { + for (let sbn in prods.first) { prods.first[sbn] = get_orig_symbol_set(prods.first[sbn]); } - for (sbn in prods.follows) { + for (let sbn in prods.follows) { prods.follows[sbn] = get_orig_symbol_set(prods.follows[sbn]); } @@ -34469,11 +34270,11 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { } function produceTerminalDescriptions(tbl, sym) { - var rv = {}; - var count = 0; - for (var k in tbl) { - var descr = tbl[k]; - var id = sym[k]; + let rv = {}; + let count = 0; + for (let k in tbl) { + let descr = tbl[k]; + let id = sym[k]; if (id && descr && descr !== id) { rv[id] = descr; count++; @@ -34483,56 +34284,56 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - type: 0, // CLI: --parserType option - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - numExpectedConflictStates: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - json: 1, - _: 1, - noMain: 1, - moduleMain: 1, - moduleMainImports: 1, - noDefaultResolve: 1, - defaultActionMode: 1, - testCompileActionCode: 1, - noTryCatch: 1, - hasPartialLrUpgradeOnConflict: 0, - compressTables: 1, - outputDebugTables: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - lexfile: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - exportAllTables: 1, - exportSourceCode: 1, - tokenStack: 0, - parserErrorsAreRecoverable: 0, - lexerErrorsAreRecoverable: 1, - showSource: 1, - exportAST: 1, - prettyCfg: 1, - - errorRecoveryTokenDiscardCount: 0, - - warn_cb: 0, // function(msg) | true (= use Jison.Print) | false (= throw Exception) - - parseParams: 1, - ranges: 0, + let obj = {}; + let do_not_pass = { + type: 0, // CLI: --parserType option + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + numExpectedConflictStates: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + json: 1, + _: 1, + noMain: 1, + moduleMain: 1, + moduleMainImports: 1, + noDefaultResolve: 1, + defaultActionMode: 1, + testCompileActionCode: 1, + noTryCatch: 1, + hasPartialLrUpgradeOnConflict: 0, + compressTables: 1, + outputDebugTables: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + lexfile: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + exportAllTables: 1, + exportSourceCode: 1, + tokenStack: 0, + parserErrorsAreRecoverable: 0, + lexerErrorsAreRecoverable: 1, + showSource: 1, + exportAST: 1, + prettyCfg: 1, + + errorRecoveryTokenDiscardCount: 0, + + warn_cb: 0, // function(msg) | true (= use Jison.Print) | false (= throw Exception) + + parseParams: 1, + ranges: 0 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -34544,12 +34345,12 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // And now some options which should receive some special processing: if (!obj.hasPartialLrUpgradeOnConflict) { - // only list this option when it's actually TRUE: - delete obj.hasPartialLrUpgradeOnConflict; + // only list this option when it's actually TRUE: + delete obj.hasPartialLrUpgradeOnConflict; } - var pre = obj.pre_parse; - var post = obj.post_parse; + let pre = obj.pre_parse; + let post = obj.post_parse; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_parse = true; @@ -34558,7 +34359,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { obj.post_parse = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp(` "(${ID_REGEX_BASE$3})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_parse: true(,)?$/gm, function (m, ls, tc) { @@ -34572,27 +34373,27 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // Generate the module creation code - var termDescrs = produceTerminalDescriptions(this.descriptions_, this.symbols_); + let termDescrs = produceTerminalDescriptions(this.descriptions_, this.symbols_); exportDest.terminalDescriptions = termDescrs; - var descrLst = JSON.stringify(termDescrs, null, 2); + let descrLst = JSON.stringify(termDescrs, null, 2); if (descrLst) { descrLst = descrLst.replace(/"([0-9]+)":/g, '$1:'); } - var rules4Dbg = produceProductionsForDebugging.call(this, this.options); + let rules4Dbg = produceProductionsForDebugging.call(this, this.options); exportDest.parseRules = rules4Dbg; - var rulesLst = ((this.options.outputDebugTables || this.options.exportAllTables.enabled) ? JSON.stringify(rules4Dbg, null, 2) : undefined); + let rulesLst = ((this.options.outputDebugTables || this.options.exportAllTables.enabled) ? JSON.stringify(rules4Dbg, null, 2) : undefined); if (rulesLst) { rulesLst = rulesLst.replace(/"([0-9]+)":/g, '$1:').replace(/^(\s+)"([a-z_][a-z_0-9]*)":/gmi, '$1$2:'); } - var symbolTable = produceSymbolTable(this.symbols_); + let symbolTable = produceSymbolTable(this.symbols_); exportDest.symbolTable = symbolTable; // produce a hash lookup table from the terminal set exportDest.terminalTable = produceTerminalTable(this.terminals_); - var moduleCode = `{ + let moduleCode = `{ // Code Generator Information Report // --------------------------------- // @@ -34656,22 +34457,22 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { 'yy: {}', 'options: ' + produceOptions(this.options), 'symbols_: ' + JSON.stringify(symbolTable, null, 2), - 'terminals_: ' + JSON.stringify(this.terminals_, null, 2).replace(/"([0-9]+)":/g, '$1:'), + 'terminals_: ' + JSON.stringify(this.terminals_, null, 2).replace(/"([0-9]+)":/g, '$1:') ].concat( rulesLst ? - 'nonterminals_: ' + rulesLst : - [] + 'nonterminals_: ' + rulesLst : + [] ).concat( descrLst ? - 'terminal_descriptions_: ' + descrLst : - [] + 'terminal_descriptions_: ' + descrLst : + [] ).concat([ define_parser_APIs_1.trim(), 'productions_: ' + tableCode.productionsCode ]).concat( String(this.performAction).trim() !== '' ? - 'performAction: ' + String(this.performAction) : - [] + 'performAction: ' + String(this.performAction) : + [] ).concat([ 'table: ' + tableCode.tableCode, 'defaultActions: ' + tableCode.defaultActionsCode, @@ -34679,24 +34480,24 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { 'parse: ' + parseFn.trim() ]).concat( this.actionsUseYYERROR ? - 'yyError: 1' : - [] + 'yyError: 1' : + [] ).concat( this.actionsUseYYRECOVERING ? - 'yyRecovering: 1' : - [] + 'yyRecovering: 1' : + [] ).concat( this.actionsUseYYERROK ? - 'yyErrOk: 1' : - [] + 'yyErrOk: 1' : + [] ).concat( this.actionsUseYYCLEARIN ? - 'yyClearIn: 1' : - [] + 'yyClearIn: 1' : + [] ).join(',\n'); moduleCode += '\n};'; - var exportSourceCode = this.options.exportSourceCode; + const exportSourceCode = this.options.exportSourceCode; assert$1(exportSourceCode); exportSourceCode.parserChunks = { initCode: expandConstantsInGeneratedCode(initCode.join('\n'), this), @@ -34704,8 +34505,8 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { moduleCode: expandConstantsInGeneratedCode(moduleCode, this), modulePostlude: [ 'parser.originalParseError = parser.parseError;', - 'parser.originalQuoteName = parser.quoteName;', - ].join('\n'), + 'parser.originalQuoteName = parser.quoteName;' + ].join('\n'), moduleInclude: expandConstantsInGeneratedCode(this.moduleInclude, this) }; return exportSourceCode.parserChunks; @@ -34719,8 +34520,6 @@ lrGeneratorMixin.generateErrorClass = function () { // 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. function JisonParserError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -34737,9 +34536,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -34777,14 +34576,14 @@ JisonParserError.prototype.name = 'JisonParserError'; // Generate code that represents the specified parser table lrGeneratorMixin.generateTableCode0 = function (table, defaultActions, productions) { - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); // Don't surround numerical property name numbers in quotes tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); - var prelude = []; + let prelude = []; // Return the variable initialization code and the table code return { @@ -34797,10 +34596,10 @@ lrGeneratorMixin.generateTableCode0 = function (table, defaultActions, productio // Function that extends an object with the given value for all given keys // e.g., x([1, 3, 4], [6, 7], { x: 1, y: 2 }) = { 1: [6, 7]; 3: [6, 7], 4: [6, 7], x: 1, y: 2 } -var compressor1ObjectCode = ` +let compressor1ObjectCode = ` function x(k, v, o) { o = o || {}; - for (var l = k.length; l--; ) { + for (let l = k.length; l--; ) { o[k[l]] = v; } return o; @@ -34809,10 +34608,10 @@ function x(k, v, o) { // Generate code that represents the specified parser table lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productions) { - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); - var usesCompressor = false; + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); + let usesCompressor = false; // Don't surround numerical property name numbers in quotes tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); @@ -34821,22 +34620,21 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio // e.g., { 1: [6, 7]; 3: [6, 7], 4: [6, 7], 5: 8 } = x([1, 3, 4], [6, 7], { 5: 8 }) tableCode = tableCode.replace(/\{[\s\r\n]*\d+:[^\}]+,[\s\r\n]*\d+:[^\}]+\}/g, function (object) { // Find the value that occurs with the highest number of keys - var value, frequentValue, key, - keys = {}, - keyCount, - maxKeyCount = 0, - keyValue, - keyValues = [], - keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; + let frequentValue; + let keys = {}; + let maxKeyCount = 0; + let keyValue; + let keyValues = []; + let keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; while ((keyValue = keyValueMatcher.exec(object))) { // For each value, store the keys where that value occurs - key = keyValue[1]; - value = keyValue[2].trim(); - keyCount = 1; + let key = keyValue[1]; + let value = keyValue[2].trim(); + let keyCount = 1; if (!(value in keys)) { - keys[value] = [key]; + keys[value] = [ key ]; } else { keyCount = keys[value].push(key); } @@ -34849,9 +34647,9 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio // Construct the object with a function call if the most frequent value occurs multiple times if (maxKeyCount > 1) { // Collect all non-frequent values into a remainder object - for (value in keys) { + for (let value in keys) { if (value !== frequentValue) { - for (var k = keys[value], i = 0, l = k.length; i < l; i++) { + for (let k = keys[value], i = 0, l = k.length; i < l; i++) { keyValues.push(k[i] + ':' + value); } } @@ -34865,10 +34663,10 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio }); // Count occurrences of number lists - var list; - var lists = {}; - var listMatcher = /\[[0-9,]+\]/g; - var frequentLists = []; + let list; + let lists = {}; + let listMatcher = /\[[0-9,]+\]/g; + let frequentLists = []; while ((list = listMatcher.exec(tableCode))) { lists[list] = (lists[list] || 0) + 1; @@ -34876,7 +34674,7 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio // Replace frequently occurring number lists with variables tableCode = tableCode.replace(listMatcher, function (list) { - var listId = lists[list]; + let listId = lists[list]; // If listId is a number, it represents the list's occurrence frequency if (typeof listId === 'number') { // If the list does not occur frequently, represent it by the list @@ -34891,7 +34689,7 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio return listId; }); - var prelude = []; + let prelude = []; // Only include the expander function when it's actually used // (tiny grammars don't have much state duplication, so this shaves off @@ -34902,7 +34700,7 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio } if (frequentLists.length > 0) { - prelude.push('var u = [\n ' + frequentLists.join(',\n ') + '\n];'); + prelude.push('let u = [\n ' + frequentLists.join(',\n ') + '\n];'); prelude.push(''); } @@ -34921,9 +34719,9 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio throw new Error("Table Compression mode 2 corrupts the table when the 'noDefaultResolve' option is turned on and one or more conflicts occur. Please use a different compression mode and/or disable this option."); } - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); // We know a couple of things about the parse table: // @@ -34951,33 +34749,29 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); - - function reportColumnsForCompression(def_arr) { - var i, key, len; - var report = []; + let report = []; - len = 0; - for (key in def_arr) { + let len = 0; + for (let key in def_arr) { len = Math.max(len, def_arr[key].length); } - var col_width = 6; - var col_delta_width = 4; + let col_width = 6; + let col_delta_width = 4; function clip(val, width) { - var s = ' ' + val; + let s = ' ' + val; s = s.substr(s.length - width); return s; } - var track_prev4delta = {}; - var c, delta, val, delta_val; - var line = []; + let track_prev4delta = {}; + let line = []; line.push('║'); - for (c in def_arr) { - key = clip(c, col_width); - delta = clip('∆', col_delta_width); + for (let c in def_arr) { + let key = clip(c, col_width); + let delta = clip('∆', col_delta_width); line.push(key); line.push('┊'); line.push(delta); @@ -34987,12 +34781,13 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } report.push(line.join('')); - for (i = 0; i < len; i++) { + for (let i = 0; i < len; i++) { line = []; line.push('║'); - for (c in def_arr) { - var tbl = def_arr[c]; + for (let c in def_arr) { + let val, delta_val; + let tbl = def_arr[c]; if (tbl.length > i) { val = tbl[i] || 0; @@ -35007,8 +34802,8 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio delta_val = '.'; } - key = clip(val, col_width); - delta = clip(delta_val, col_delta_width); + let key = clip(val, col_width); + let delta = clip(delta_val, col_delta_width); line.push(key); line.push('┊'); line.push(delta); @@ -35024,16 +34819,16 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // table is array of 1/2-len arrays: function analyzeTableForCompression(table) { // column: productions' row length - var len_col = []; + let len_col = []; // column: productions' shift size / action column - var pop_col = []; + let pop_col = []; // column: rule number for each slot ('rule'): - var rule_col = []; + let rule_col = []; - var i; - var row_count = table.length; + let i; + let row_count = table.length; for (i = 0; i < row_count; i++) { - var prod = table[i]; + let prod = table[i]; len_col.push(prod.length); assert$1(prod.length <= 2); @@ -35044,10 +34839,10 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio rule_col.push(prod[1]); } - var def_arr = { - 'len': len_col, - 'pop': pop_col, - 'rule': rule_col, + let def_arr = { + len: len_col, + pop: pop_col, + rule: rule_col }; return def_arr; } @@ -35058,14 +34853,14 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // table is hash of 1/2-len arrays: function analyzeSetForCompression(table) { // column: row index - var idx_col = []; + let idx_col = []; // column: REDUCE productions' goto column - var goto_col = []; + let goto_col = []; - var i; + let i; for (i in table) { i = +i; - var prod = table[i]; + let prod = table[i]; idx_col.push(i); // and the special knowledge about the defaultActions[] table: @@ -35073,9 +34868,9 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio goto_col.push(prod); } - var def_arr = { - 'idx': idx_col, - 'goto': goto_col, + let def_arr = { + idx: idx_col, + goto: goto_col }; return def_arr; } @@ -35084,30 +34879,29 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function analyzeGotoTableForCompression(table) { // column: number of symbol hash entries per state slot ('length'): - var len_col = []; + let len_col = []; // column: symbol hash entry key for each slot ('symbol'): - var symbol_col = []; + let symbol_col = []; // column: symbol hash entry value type: number (0) or array (array.length) ('type'): - var type_col = []; + let type_col = []; // column: symbol hash entry value if single GOTO state number ('state'): - var state_col = []; + let state_col = []; // column: symbol hash entry mode value if array slot type (reduce/shift/accept): - var mode_col = []; + let mode_col = []; // column: symbol hash entry goto state value if array slot type: - var goto_col = []; + let goto_col = []; // // column: merged: state_col + goto_col: - // var next_col = []; - - var row_count = table.length; - for (var state = 0; state < row_count; state++) { - var hashtable = table[state]; - var count = 0; - var symbol; - for (symbol in hashtable) { + // let next_col = []; + + let row_count = table.length; + for (let state = 0; state < row_count; state++) { + let hashtable = table[state]; + let count = 0; + for (let symbol in hashtable) { symbol = +symbol; symbol_col.push(symbol); - var slot = hashtable[symbol]; + let slot = hashtable[symbol]; if (slot && slot.length) { // array type slot: assert$1(slot.length === 2 || slot.length === 1); @@ -35134,40 +34928,40 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio len_col.push(count); } - var def_arr = { - 'len': len_col, - 'symbol': symbol_col, - 'type': type_col, - 'state': state_col, - 'mode': mode_col, - 'goto': goto_col, + let def_arr = { + len: len_col, + symbol: symbol_col, + type: type_col, + state: state_col, + mode: mode_col, + goto: goto_col //'next': next_col, }; return def_arr; } - var has_compressed_a_table = false; + let has_compressed_a_table = false; function generateColumn(name, col) { - var rv = []; - var i, j, len, l; + let rv = []; - for (i = 0, len = col.length; i < len; i++) { + for (let i = 0, len = col.length; i < len; i++) { // try basic run-length encoding first: - var v = col[i]; + let v = col[i]; + let j; for (j = i + 1; j < len; j++) { if (col[j] !== v) { break; } } - var runlength = j - i; + let runlength = j - i; // try stepped run-length encoding next: - var delta = col[i + 1] - v; - var steplength = 0; + let delta = col[i + 1] - v; + let steplength = 0; // we don't want to replicate the runlength result, so only look for a match // when delta !== 0: @@ -35181,10 +34975,11 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } // try to match the pattern in history: - var best_pos = 0; - var best_len = 0; - var upper_bound = i - 2; + let best_pos = 0; + let best_len = 0; + let upper_bound = i - 2; for (j = 0; j < upper_bound; j++) { + let l; for (l = 0; col[j + l] === col[i + l]; l++) { // No need to check for: // if (j + l === i) break; @@ -35208,28 +35003,24 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } // weight our options now: - var gain = [ + let gain = [ runlength - 2, steplength - 3, best_len - 2 ]; - var optimum_gain = Math.max.apply(null, gain); + let optimum_gain = Math.max.apply(null, gain); if (optimum_gain <= 0) { rv.push(v); - } - else if (optimum_gain === gain[0]) { + } else if (optimum_gain === gain[0]) { rv.push('s', '[' + v + ', ' + runlength + ']'); i += runlength - 1; - } - else if (optimum_gain === gain[1]) { + } else if (optimum_gain === gain[1]) { rv.push('s', '[' + v + ', ' + steplength + ', ' + delta + ']'); i += steplength - 1; - } - else if (optimum_gain === gain[2]) { + } else if (optimum_gain === gain[2]) { rv.push('c', '[' + best_pos + ', ' + best_len + ']'); i += best_len - 1; - } - else { + } else { rv.push(v); //assert(0); // should never get here! } @@ -35239,11 +35030,11 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } } - var code = [ + let code = [ ' ', name, ': ', 'u([', '\n ', - rv.join(',\n '), // JSON.stringify(col, null, 2), + rv.join(',\n '), // JSON.stringify(col, null, 2), '\n', '])' ].join(''); @@ -35252,7 +35043,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function generateCompressedTable(def_arr) { - var code = [ + let code = [ 'bp({', generateColumn('pop', def_arr.pop) + ',', generateColumn('rule', def_arr.rule), @@ -35263,7 +35054,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function generateCompressedSet(def_arr) { - var code = [ + let code = [ 'bda({', generateColumn('idx', def_arr.idx) + ',', generateColumn('goto', def_arr.goto), @@ -35274,7 +35065,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function generateCompressedGotoTable(def_arr) { - var code = [ + let code = [ 'bt({', generateColumn('len', def_arr.len) + ',', generateColumn('symbol', def_arr.symbol) + ',', @@ -35288,18 +35079,18 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } - var tableDef = analyzeGotoTableForCompression(table); - var defaultActionsDef = analyzeSetForCompression(defaultActions); - var productionsDef = analyzeTableForCompression(productions); + let tableDef = analyzeGotoTableForCompression(table); + let defaultActionsDef = analyzeSetForCompression(defaultActions); + let productionsDef = analyzeTableForCompression(productions); const bp_code_container = ` // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -35312,11 +35103,11 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio const bda_code_container = ` // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -35326,18 +35117,18 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio const bt_code_container = ` // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -35368,7 +35159,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // \`this\` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -35385,9 +35176,9 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -35401,25 +35192,25 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio `; has_compressed_a_table = false; - var tc = generateCompressedGotoTable(tableDef); - var compressGotoTable = has_compressed_a_table; + let tc = generateCompressedGotoTable(tableDef); + let compressGotoTable = has_compressed_a_table; has_compressed_a_table = false; - var dac = generateCompressedSet(defaultActionsDef); - var compressDefaultActions = has_compressed_a_table; + let dac = generateCompressedSet(defaultActionsDef); + let compressDefaultActions = has_compressed_a_table; has_compressed_a_table = false; - var pc = generateCompressedTable(productionsDef); - var compressProductions = has_compressed_a_table; + let pc = generateCompressedTable(productionsDef); + let compressProductions = has_compressed_a_table; - var compressAnything = (compressProductions || compressDefaultActions || compressGotoTable); + let compressAnything = (compressProductions || compressDefaultActions || compressGotoTable); tableCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(tableDef) : '') + (compressGotoTable ? tc : tableCode); defaultActionsCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(defaultActionsDef) : '') + (compressDefaultActions ? dac : defaultActionsCode); productionsCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(productionsDef) : '') + (compressProductions ? pc : productionsCode); - var prelude = [ + let prelude = [ '', compressProductions ? bp_code_container : '', '', @@ -35427,7 +35218,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio '', compressGotoTable ? bt_code_container : '', '', - c_s_u_code_container, + c_s_u_code_container ]; if (!compressAnything) { prelude = []; @@ -35443,31 +35234,29 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio }; // --- START of commonJsMain chunk --- -// +// // default main method for generated commonjs modules const commonJsMain = ` -function (args) { - "use strict"; - +function __jison_default_main__(args) { // When the parser comes with its own \`main\` function, then use that one: if (typeof exports.parser.main === 'function') { - return exports.parser.main(args); + return exports.parser.main(args); } if (!args[1]) { console.log('Usage:', path.basename(args[0]) + ' FILE'); process.exit(1); } - var source = fs.readFileSync(path.normalize(args[1]), 'utf8'); - var dst = exports.parser.parse(source); + const source = fs.readFileSync(path.normalize(args[1]), 'utf8'); + const dst = exports.parser.parse(source); console.log('parser output:\\n\\n', { type: typeof dst, value: dst }); try { - console.log("\\n\\nor as JSON:\\n", JSON.stringify(dst, null, 2)); + 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... */ } - var rv = 0; + let rv = 0; if (typeof dst === 'number' || typeof dst === 'boolean') { rv = dst; } @@ -35477,16 +35266,16 @@ function (args) { // --- END of commonJsMain chunk --- const commonJsMainImports = ` -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); `; // debug mixin for LR parser generators function printAction(a, gen) { - var s = a[0] === SHIFT ? 'shift token (then go to state ' + a[1] + ')' : + let s = a[0] === SHIFT ? 'shift token (then go to state ' + a[1] + ')' : a[0] === REDUCE ? 'reduce by rule: ' + gen.productions[a[1]] : - a[0] === ACCEPT ? 'accept' : 'UNDEFINED ACTION: ' + a[0]; + a[0] === ACCEPT ? 'accept' : 'UNDEFINED ACTION: ' + a[0]; return s; } @@ -35500,13 +35289,13 @@ function traceStates(trace, states, title) { trace('\n'); } -var lrGeneratorDebug = { +const lrGeneratorDebug = { beforeparseTable: function () { this.trace('Building parse table.'); }, afterparseTable: function () { - var trace = this.trace; - var self = this; + let trace = this.trace; + let self = this; if (this.conflicts > 0) { trace('\nConflicts:\n'); this.resolutions.forEach(function (r, i) { @@ -35518,21 +35307,21 @@ var lrGeneratorDebug = { } trace('Done.\n'); }, - aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */ ) { + aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */) { traceStates(this.trace, states, 'as produced by LR::canonicalCollection()'); } }; -var parser$4 = typal.beget(); +const parser$4 = typal.beget(); generatorMixin.createParser = function createParser() { - var sourceCodeDef = this.generateModuleExpr(); + let sourceCodeDef = this.generateModuleExpr(); // produce a chunk of sourcecode that's suitable for evaluation through `eval()`: - var sourcecode = rmCommonWS$5` + let sourcecode = rmCommonWS$5` ${sourceCodeDef.init} - var yy__parser = ${sourceCodeDef.src}; + let yy__parser = ${sourceCodeDef.src}; // produce the generated parser function/class as the last value // in this chunk of code so that we can be sure to produce *that* @@ -35543,15 +35332,15 @@ generatorMixin.createParser = function createParser() { yy__parser; `; - var p = code_exec$2(sourcecode, function generated_code_exec_wrapper_jison(sourcecode) { + let 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); - var rv = eval(sourcecode); + let rv = eval(sourcecode); return rv; }, mkStdOptions$1(this.options, { dumpSourceCodeOnFailure: this.DEBUG, throwErrorOnCompileFailure: true - }), "parser"); + }), 'parser'); assert$1(typeof p === 'object'); assert$1(typeof p.parse === 'function'); assert$1(typeof p.parser === 'undefined'); @@ -35595,7 +35384,7 @@ generatorMixin.createParser = function createParser() { } p.sourceCode = sourceCodeDef; - var self = this; + let self = this; function bind(method) { return function () { self.lexer = p.lexer; @@ -35622,8 +35411,6 @@ parser$4.error = generator.error; // --- START parser Error class chunk --- const parseErrorSourceCode = ` function parseError(str, hash, ExceptionClass) { - "use strict"; - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -35648,7 +35435,7 @@ parser$4.parseError = lrGeneratorMixin.parseError = eval(parseErrorSourceCode + generatorMixin.createLexer = function createLexer(lexerSpec, input, tokens, options) { // TODO: construct options from generator options: // lexer_options = ... - var lexer = new RegExpLexer(lexerSpec, input, tokens, options); + let lexer = new RegExpLexer(lexerSpec, input, tokens, options); return lexer; }; @@ -35687,8 +35474,6 @@ const define_parser_APIs_1 = ` // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - "use strict"; - return '"' + id_str + '"'; }, @@ -35696,8 +35481,6 @@ const define_parser_APIs_1 = ` // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - "use strict"; - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -35709,8 +35492,8 @@ const define_parser_APIs_1 = ` // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -35723,15 +35506,13 @@ const define_parser_APIs_1 = ` // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - "use strict"; - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -35747,11 +35528,10 @@ const define_parser_APIs_1 = ` // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { - "use strict"; + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -35759,10 +35539,10 @@ const define_parser_APIs_1 = ` this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -35774,8 +35554,8 @@ const define_parser_APIs_1 = ` `; // --- END of define_parser_APIs_1 chunk --- -var api_set = (new Function('', 'return { ' + define_parser_APIs_1 + ' };'))(); -for (var api in api_set) { +const api_set = (new Function('', 'return { ' + define_parser_APIs_1 + ' };'))(); +for (let api in api_set) { parser$4[api] = api_set[api]; } @@ -35783,39 +35563,37 @@ for (var api in api_set) { // --- START parser kernel --- parser$4.parse = ` function parse(input, parseParams) { - "use strict"; - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - var tstack = []; // token stack (only used when \`%options token_stack\` support has been enabled) - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - var yytext; - var yylineno; - var yyleng; - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + let tstack = []; // token stack (only used when \`%options token_stack\` support has been enabled) + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + let yytext; + let yylineno; + let yyleng; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -35824,21 +35602,18 @@ function parse(input, parseParams) { post_parse: undefined, pre_lex: undefined, post_lex: undefined, - parseParamsAsMembers: parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - "use strict"; - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -35863,8 +35638,6 @@ function parse(input, parseParams) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - "use strict"; - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -35872,18 +35645,19 @@ function parse(input, parseParams) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -35891,26 +35665,19 @@ function parse(input, parseParams) { // - either the element does not yet exist in \`src\` // - or exists in \`src\` but is NULL or UNDEFINED there, while its value is non-NULL in \`dst\` function shallow_copy_noclobber(dst, src) { - "use strict"; - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - "use strict"; - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -35928,17 +35695,13 @@ function parse(input, parseParams) { this.copy_yytext = this.options.copy_yytext || sharedState_yy.copy_yytext || shallow_copy; this.copy_yylloc = this.options.copy_yylloc || sharedState_yy.copy_yylloc || copy_yylloc_native; - var yydebug = false; + let yydebug = false; if (this.options.debug) { yydebug = function yydebug_impl(msg, obj) { - "use strict"; - - var ref_list; - var ref_names; + let ref_list; + let ref_names; function deepClone(from, sub) { - "use strict"; - if (sub == null) { ref_list = []; ref_names = []; @@ -35950,15 +35713,15 @@ function parse(input, parseParams) { return from; } - var i = ref_list.indexOf(from); + let i = ref_list.indexOf(from); if (i >= 0) { return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference } ref_list.push(from); ref_names.push(sub); - var to = new from.constructor(); - for (var name in from) { + let to = new from.constructor(); + for (let name in from) { if (name === 'parser') continue; if (name === 'lexer') continue; to[name] = deepClone(from[name], name); @@ -35986,13 +35749,11 @@ function parse(input, parseParams) { // wrap try/catch in a function to help the V8 JIT compiler... function yydebug_cvt(obj) { - "use strict"; - - var js; + let js; try { - var re1; + let re1; if (typeof XRegExp === 'undefined') { - re1 = / \\"([a-z_][a-z_0-9. ]*)\\": /ig; + re1 = / {2}\\"([a-z_][a-z_0-9. ]*)\\": /ig; } else { re1 = new XRegExp(' \\"([\\\\p{Alphabetic}_][\\\\p{Alphabetic}\\\\p{Number}_. ]*)\\": ', 'g'); } @@ -36024,21 +35785,25 @@ function parse(input, parseParams) { // them up. Hence we MUST set them up at the start of every \`parse()\` run! if (this.yyError) { this.yyError = function yyError(str /*, ...args */) { - "use strict"; - - if (yydebug) yydebug('yyerror: ', { message: str, args: arguments, symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('yyerror: ', { + message: str, + args: arguments, + symbol, state, newState, recovering, action + }); + } //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); + let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -36059,13 +35824,13 @@ function parse(input, parseParams) { //_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, false); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, false); //_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -36078,18 +35843,14 @@ function parse(input, parseParams) { if (this.yyRecovering) { this.yyRecovering = function yyRecovering() { - "use strict"; - - if (yydebug) yydebug('yyrecovering: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) yydebug('yyrecovering: ', { symbol, state, newState, recovering, action }); return recovering; }; } if (this.yyErrOk) { this.yyErrOk = function yyErrOk() { - "use strict"; - - if (yydebug) yydebug('yyerrok: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) yydebug('yyerrok: ', { symbol, state, newState, recovering, action }); recovering = 0; // DO NOT reset/cleanup \`recoveringErrorInfo\` yet: userland code @@ -36111,9 +35872,7 @@ function parse(input, parseParams) { if (this.yyClearIn) { this.yyClearIn = function yyClearIn() { - "use strict"; - - if (yydebug) yydebug('yyclearin: ', { symbol: symbol, newState: newState, recovering: recovering, action: action, preErrorSymbol: preErrorSymbol }); + if (yydebug) yydebug('yyclearin: ', { symbol, newState, recovering, action, preErrorSymbol }); if (symbol === TERROR) { symbol = 0; yytext = null; @@ -36130,8 +35889,6 @@ function parse(input, parseParams) { // Does the shared state override the default \`parseError\` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -36144,8 +35901,6 @@ function parse(input, parseParams) { // Does the shared state override the default \`quoteName\` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - "use strict"; - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -36159,12 +35914,10 @@ function parse(input, parseParams) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your \`sharedState\`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - "use strict"; - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -36218,8 +35971,8 @@ function parse(input, parseParams) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -36228,8 +35981,8 @@ function parse(input, parseParams) { //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -36263,20 +36016,18 @@ function parse(input, parseParams) { // // Note: epsilon rule's yylloc situation is detected by passing both \`first_index\` and \`first_yylloc\` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - "use strict"; - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -36287,7 +36038,7 @@ function parse(input, parseParams) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -36300,7 +36051,7 @@ function parse(input, parseParams) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -36312,29 +36063,27 @@ function parse(input, parseParams) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or \`dont_look_back\` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -36342,7 +36091,7 @@ function parse(input, parseParams) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -36362,9 +36111,7 @@ function parse(input, parseParams) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your \`lexer\`, \`sharedState\`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - "use strict"; - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -36373,10 +36120,10 @@ function parse(input, parseParams) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -36384,7 +36131,7 @@ function parse(input, parseParams) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -36401,10 +36148,8 @@ function parse(input, parseParams) { // info.value = null; // info.value_stack = null; // ... - "use strict"; - - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -36420,9 +36165,7 @@ function parse(input, parseParams) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - "use strict"; - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -36491,11 +36234,14 @@ function parse(input, parseParams) { // - root_failure_pointer: // copy of the \`stack_pointer\`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -36506,9 +36252,7 @@ function parse(input, parseParams) { }; function getNonTerminalFromCode(symbol) { - "use strict"; - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -36518,22 +36262,20 @@ function parse(input, parseParams) { //_lexer_without_token_stack: function stdLex() { - "use strict"; - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36543,22 +36285,20 @@ function parse(input, parseParams) { } function fastLex() { - "use strict"; - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36567,15 +36307,13 @@ function parse(input, parseParams) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; //_lexer_with_token_stack: // lex function that supports token stacks function tokenStackLex() { - "use strict"; - - var token; + let token; token = tstack.pop() || lexer.lex() || EOF; // if token isn't its numeric value, convert if (typeof token !== 'number') { @@ -36594,13 +36332,13 @@ function parse(input, parseParams) { } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36611,33 +36349,37 @@ function parse(input, parseParams) { //_lexer_with_token_stack_end: - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - "use strict"; - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { // check for error recovery rule in this state - if (yydebug) yydebug('locateNearestErrorRecoveryRule #test#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); - var t = (table[state] && table[state][TERROR]) || NO_ACTION; + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #test#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } + const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we \`yyerrok()\` an error, we must @@ -36652,12 +36394,24 @@ function parse(input, parseParams) { // terminate the parse in a controlled fashion even when we have // very complex error/recovery code interplay in the core + user // action code blocks: - if (yydebug) yydebug('locateNearestErrorRecoveryRule #found#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #found#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { - if (yydebug) yydebug('locateNearestErrorRecoveryRule #skip#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #skip#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; @@ -36667,14 +36421,26 @@ function parse(input, parseParams) { return depth; } if (state === 0 /* $accept rule */ || stack_probe < 1) { - if (yydebug) yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; } - if (yydebug) yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } return -1; // No suitable error recovery rule available. } @@ -36691,7 +36457,7 @@ function parse(input, parseParams) { // whether we'll go with the standard, slower, lex() API or the // \`fast_lex()\` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -36737,17 +36503,23 @@ function parse(input, parseParams) { newState = t[1]; action = t[0]; - if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('after FETCH/LEX: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol], + state, newState, recovering, action + }); + } //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules // handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -36774,7 +36546,13 @@ function parse(input, parseParams) { // invoke the parser's cleanup API! recoveringErrorInfo = this.shallowCopyErrorInfo(p); - if (yydebug) yydebug('error recovery rule detected: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p }); + if (yydebug) { + yydebug('error recovery rule detected: ', { + error_rule_depth, + error: p.errStr, + error_hash: p + }); + } r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { @@ -36792,9 +36570,15 @@ function parse(input, parseParams) { } } - if (yydebug) yydebug('after ERROR DETECT: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p }); + if (yydebug) { + yydebug('after ERROR DETECT: ', { + error_rule_depth, + error: p.errStr, + error_hash: p + }); + } - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -36814,17 +36598,22 @@ function parse(input, parseParams) { preErrorSymbol = 0; symbol = lex(); - if (yydebug) yydebug('after ERROR RECOVERY-3: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol] }); + if (yydebug) { + yydebug('after ERROR RECOVERY-3: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol] + }); + } } // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -36871,20 +36660,18 @@ function parse(input, parseParams) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; - if (yydebug) yydebug('Error recovery process: pushed error info item on the info stack: ', { - item: vstack[sp], - sp, - esp, - vstack, - stack, - sstack, - combineState: NO_ACTION[1] - }); + if (yydebug) { + yydebug('Error recovery process: pushed error info item on the info stack: ', { + item: vstack[sp], + sp, esp, vstack, stack, sstack, + combineState: NO_ACTION[1] + }); + } } else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), @@ -36903,11 +36690,17 @@ function parse(input, parseParams) { yyrulelen = error_rule_depth; - if (yydebug) yydebug('Error recovery process: performAction: COMBINE: ', { - yyval, yytext, sp, pop_size: yyrulelen, vstack, stack, sstack, - combineState: NO_ACTION[1] - }); - r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, NO_ACTION[1], sp - 1, yyrulelen, vstack, lstack, stack, sstack); + let combineState = NO_ACTION[1]; + + if (yydebug) { + yydebug('Error recovery process: performAction: COMBINE: ', { + yyval, yytext, sp, + pop_size: yyrulelen, + vstack, stack, sstack, + combineState + }); + } + r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, combineState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof r !== 'undefined') { retval = r; @@ -36918,7 +36711,7 @@ function parse(input, parseParams) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -36945,7 +36738,7 @@ function parse(input, parseParams) { // allow N (default: 3) real symbols to be shifted before reporting a new error recovering = ERROR_RECOVERY_TOKEN_DISCARD_COUNT; - if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth: error_rule_depth, symbol: symbol, preErrorSymbol: preErrorSymbol }); + if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth, symbol, preErrorSymbol }); // Now duplicate the standard parse machine here, at least its initial // couple of rounds until the TERROR symbol is **pushed onto the parse stack**, @@ -36971,10 +36764,10 @@ function parse(input, parseParams) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -37002,14 +36795,20 @@ function parse(input, parseParams) { newState = t[1]; action = t[0]; - if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('after FETCH/LEX: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol], + state, newState, recovering, action + }); + } // encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { if (yydebug) yydebug('**NESTED ERROR DETECTED** while still recovering from previous error'); - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the \`continue;\` @@ -37023,15 +36822,26 @@ function parse(input, parseParams) { } } - if (yydebug) yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) { - "use strict"; - - if (!nt || !nt.states || !nt.rules) - return ''; - var rulename = nt.states[state]; - var rulespec = nt.rules[rulename][state]; - return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; - })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' + + (action === 1 ? + 'shift token ' + symbol + ' (then go to state ' + newState + ')' : + action === 2 ? + 'reduce by rule: ' + newState + (function __print_rule(nt, state) { + if (!nt || !nt.states || !nt.rules) { + return ''; + } + let rulename = nt.states[state]; + let rulespec = nt.rules[rulename][state]; + return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; + })(this.nonterminals_, newState) : + action === 3 ? + 'accept' : + '???unexpected???' + ), { + action, newState, recovering, symbol + }); + } switch (action) { // catch misc. parse failures: @@ -37055,12 +36865,12 @@ function parse(input, parseParams) { // Push a special value onto the stack when we're // shifting the \`error\` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -37069,7 +36879,7 @@ function parse(input, parseParams) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -37098,14 +36908,14 @@ function parse(input, parseParams) { if (recovering > 0) { recovering--; - if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering, symbol }); } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; - if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering, symbol }); // read action for current state and first input t = (table[newState] && table[newState][symbol]) || NO_ACTION; if (!t[0] || symbol === TERROR) { @@ -37117,7 +36927,7 @@ function parse(input, parseParams) { // recovery, for then this we would we idling (cycling) on the error forever. // Yes, this does not take into account the possibility that the *lexer* may have // produced a *new* TERROR token all by itself, but that would be a very peculiar grammar! - if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering, symbol }); symbol = 0; } } @@ -37133,7 +36943,7 @@ function parse(input, parseParams) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -37144,21 +36954,26 @@ function parse(input, parseParams) { this_production = this.productions_[newState - 1]; // \`this.productions_[]\` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; - if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('~~~ REDUCE: ', { + pop_size: yyrulelen, + newState, recovering, symbol + }); + } r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -37192,15 +37007,17 @@ function parse(input, parseParams) { sp -= yyrulelen; // don't overwrite the \`symbol\` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; - if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol }); + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol }); + } continue; // accept: @@ -37252,7 +37069,7 @@ function parse(input, parseParams) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the \`switch/default\` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -37262,9 +37079,9 @@ function parse(input, parseParams) { // handle parse error if (!action) { - var errStr; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let errStr; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); // Report error errStr = 'Parse error'; @@ -37295,15 +37112,26 @@ function parse(input, parseParams) { } - if (yydebug) yydebug('::: MAIN CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) { - "use strict"; - - if (!nt || !nt.states || !nt.rules) - return ''; - var rulename = nt.states[state]; - var rulespec = nt.rules[rulename][state]; - return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; - })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('::: MAIN CYCLE action: ' + + (action === 1 ? + 'shift token ' + symbol + ' (then go to state ' + newState + ')' : + action === 2 ? + 'reduce by rule: ' + newState + (function __print_rule(nt, state) { + if (!nt || !nt.states || !nt.rules) { + return ''; + } + let rulename = nt.states[state]; + let rulespec = nt.rules[rulename][state]; + return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; + })(this.nonterminals_, newState) : + action === 3 ? + 'accept' : + '???unexpected???' + ), { + action, newState, recovering, symbol + }); + } switch (action) { // catch misc. parse failures: @@ -37334,7 +37162,7 @@ function parse(input, parseParams) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -37351,8 +37179,8 @@ function parse(input, parseParams) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyleng = lexer.yyleng; @@ -37363,27 +37191,32 @@ function parse(input, parseParams) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // \`this.productions_[]\` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; - if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('~~~ REDUCE: ', { + pop_size: yyrulelen, + newState, recovering, symbol + }); + } r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -37414,15 +37247,17 @@ function parse(input, parseParams) { sp -= yyrulelen; // don't overwrite the \`symbol\` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; - if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol }); + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol }); + } continue; // accept: @@ -37475,8 +37310,7 @@ function parse(input, parseParams) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -37509,30 +37343,30 @@ function parse(input, parseParams) { * LR(0) Parser */ -var lr0 = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { +const lr0 = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LR(0)', afterconstructor: function lr0_afterconstructor() { this.buildTable(); } }); -var LR0Generator = Jison$1.LR0Generator = lr0.construct(); +const LR0Generator = Jison$1.LR0Generator = lr0.construct(); /* * Simple LALR(1) */ -var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { +const lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LALR(1)', afterconstructor: function lalr_afterconstructor() { - var self = this; + let self = this; if (this.DEBUG) { this.mix(lrGeneratorDebug, lalrGeneratorDebug); // mixin debug methods } - for (var round = 1; /* infinite loop if it weren't for the `break`s at the end */ ; round++) { + for (let round = 1; /* infinite loop if it weren't for the `break`s at the end */ ; round++) { this.states = this.canonicalCollection(); if (this.DEBUG || devDebug) { @@ -37543,13 +37377,13 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { this.terms_ = {}; - var newg = this.newg = typal.beget(lookaheadMixin, { + let newg = this.newg = typal.beget(lookaheadMixin, { oldg: this, trace: this.trace, nterms_: {}, DEBUG: false, go_: function (productionSymbol, productionHandle) { - var stateNum = productionSymbol.split(':')[0]; // grab state # + let stateNum = productionSymbol.split(':')[0]; // grab state # assert$1(stateNum == +stateNum); stateNum = +stateNum; productionHandle = productionHandle.map(function (rhsElem) { @@ -37586,8 +37420,8 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { // backprop `nullable` value for each nonterminal and production back to original grammar: each(newg.nonterminals, function (newg_nt, t) { // extract original symbol: - var sym; - var a = newg_nt.symbol.split(':'); + let sym; + let a = newg_nt.symbol.split(':'); if (a.length === 1 || a[0] === '') { sym = newg_nt.symbol; } else { @@ -37662,8 +37496,8 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { go: function LALR_go(stateNum, productionHandle, productionSymbol) { assert$1(typeof stateNum === 'number'); - var endStateNum = stateNum; - for (var i = 0; i < productionHandle.length; i++) { + let endStateNum = stateNum; + for (let i = 0; i < productionHandle.length; i++) { endStateNum = this.states.item(endStateNum).edges[productionHandle[i]] || endStateNum; } return endStateNum; @@ -37671,10 +37505,10 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { goPath: function LALR_goPath(stateNum, productionHandle, productionSymbol) { assert$1(typeof stateNum === 'number'); - var endStateNum = stateNum, - t, - path = []; - for (var i = 0; i < productionHandle.length; i++) { + let endStateNum = stateNum, + t, + path = []; + for (let i = 0; i < productionHandle.length; i++) { t = productionHandle[i] ? endStateNum + ':' + productionHandle[i] /* + ':' + productionSymbol */ : ''; if (t) { this.newg.nterms_[t] = endStateNum; @@ -37692,34 +37526,34 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { // every disjoint reduction of a nonterminal becomes a production in G' buildNewGrammar: function LALR_buildNewGrammar() { - var self = this, - newg = this.newg; + let self = this, + newg = this.newg; this.states.forEach(function (state, i) { i = +i; state.forEach(function LALR_buildNewHandle(item) { if (item.dotPosition === 0) { // new symbols are a combination of state and transition symbol - var symbol = i + ':' + item.production.symbol; + let symbol = i + ':' + item.production.symbol; assert$1(typeof self.terms_[symbol] === 'undefined' || self.terms_[symbol] === item.production.symbol); self.terms_[symbol] = item.production.symbol; newg.nterms_[symbol] = i; if (!newg.nonterminals[symbol]) { newg.nonterminals[symbol] = new Nonterminal(symbol); } - var pathInfo = self.goPath(i, item.production.handle, item.production.symbol); - var p = new Production(symbol, pathInfo.path, newg.productions.length); + let pathInfo = self.goPath(i, item.production.handle, item.production.symbol); + let p = new Production(symbol, pathInfo.path, newg.productions.length); newg.productions.push(p); newg.nonterminals[symbol].productions.push(p); // store the transition that gets 'backed up to' after reduction on path - var handle = item.production.handle.join(' '); + let handle = item.production.handle.join(' '); if (self.conflict_fixing_round && self.conflict_states_LU[i]) ; if (self.conflict_fixing_round && self.conflict_productions_LU[item.production.id]) { handle += ':P' + item.production.id; } - var goes = self.states.item(pathInfo.endState).goes; + let goes = self.states.item(pathInfo.endState).goes; if (!goes[handle]) { goes[handle] = []; } @@ -37733,22 +37567,22 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { }, unionLookaheads: function LALR_unionLookaheads() { - var self = this, - newg = this.newg; - // var states = !!this.onDemandLookahead ? this.inadequateStates : this.states; + let self = this, + newg = this.newg; + // let states = !!this.onDemandLookahead ? this.inadequateStates : this.states; - var these_states = this.states; + let these_states = this.states; these_states.forEach(function union_states_forEach(state, i) { i = +i; //assert(state.inadequate ? these_states.inadequate : true); - var treat_me = (self.onDemandLookahead ? these_states.inadequate || state.inadequate : true); + let treat_me = (self.onDemandLookahead ? these_states.inadequate || state.inadequate : true); if (state.reductions.length && treat_me) { state.reductions.forEach(function union_reduction_forEach(item) { - var follows = {}; - for (var k = 0; k < item.follows.length; k++) { + let follows = {}; + for (let k = 0; k < item.follows.length; k++) { follows[item.follows[k]] = true; } - var handle = item.production.handle.join(' '); + let handle = item.production.handle.join(' '); if (self.conflict_fixing_round && self.conflict_states_LU[i]) ; if (self.conflict_fixing_round && self.conflict_productions_LU[item.production.id]) { handle += ':P' + item.production.id; @@ -37759,7 +37593,7 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { state.goes[handle].forEach(function reduction_goes_forEach(symbol) { newg.nonterminals[symbol].follows.forEach(function goes_follows_forEach(symbol) { - var terminal = self.terms_[symbol]; + let terminal = self.terms_[symbol]; if (!follows[terminal]) { follows[terminal] = true; @@ -37773,11 +37607,11 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { } }); -var LALRGenerator = Jison$1.LALRGenerator = lalr.construct(); +const LALRGenerator = Jison$1.LALRGenerator = lalr.construct(); // LALR generator debug mixin -var lalrGeneratorDebug = { +const lalrGeneratorDebug = { beforebuildNewGrammar: function () { this.trace(this.states.size() + ' states.'); this.trace('Building lookahead grammar.'); @@ -37794,7 +37628,7 @@ var lalrGeneratorDebug = { aftercomputeLookaheads: function () { traceStates(this.trace, this.states, 'after LALR::computeLookaheads()'); }, - aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */ ) { + aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */) { traceStates(this.trace, states, 'as produced by LALR::canonicalCollection()'); } }; @@ -37804,7 +37638,7 @@ var lalrGeneratorDebug = { * * Define base type */ -var lrLookaheadGenerator = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { +const lrLookaheadGenerator = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { afterconstructor: function lr_aftercontructor() { this.computeLookaheads(); @@ -37821,7 +37655,7 @@ var lrLookaheadGenerator = generator.beget(lookaheadMixin, generatorMixin, lrGen /* * SLR Parser */ -var SLRGenerator = Jison$1.SLRGenerator = lrLookaheadGenerator.construct({ +const SLRGenerator = Jison$1.SLRGenerator = lrLookaheadGenerator.construct({ type: 'SLR(1)', lookAheads: function SLR_lookAhead(state, item) { @@ -37833,7 +37667,7 @@ var SLRGenerator = Jison$1.SLRGenerator = lrLookaheadGenerator.construct({ /* * LR(1) Parser */ -var lr1 = lrLookaheadGenerator.beget({ +const lr1 = lrLookaheadGenerator.beget({ type: 'Canonical LR(1)', lookAheads: function LR_lookAheads(state, item) { @@ -37850,28 +37684,26 @@ var lr1 = lrLookaheadGenerator.beget({ }), closureOperation: function LR_ClosureOperation(itemSet) { - var closureSet = new this.ItemSet(); - var self = this; + let closureSet = new this.ItemSet(); + let self = this; - var set = itemSet, - itemQueue; + let set = itemSet; do { - itemQueue = new Set(); + let itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function LR_AddItemToClosureSets(item) { - var symbol = item.markedSymbol; - var b, r; + let symbol = item.markedSymbol; // if token is a nonterminal, recursively add closures if (symbol && self.nonterminals[symbol]) { - r = item.remainingHandle(); - b = self.first(r); + let r = item.remainingHandle(); + let b = self.first(r); if (b.length === 0 || item.production.nullable || self.nullable(r)) { b = b.concat(item.follows); } self.nonterminals[symbol].productions.forEach(function (production) { - var newItem = new self.Item(production, 0, b); + let newItem = new self.Item(production, 0, b); if (!closureSet.contains(newItem) && !itemQueue.contains(newItem)) { itemQueue.push(newItem); } @@ -37883,18 +37715,18 @@ var lr1 = lrLookaheadGenerator.beget({ }); set = itemQueue; - } while (!itemQueue.isEmpty()); + } while (!set.isEmpty()); return closureSet; } }); -var LR1Generator = Jison$1.LR1Generator = lr1.construct(); +const LR1Generator = Jison$1.LR1Generator = lr1.construct(); /* * LL Parser */ -var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { +const ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LL(1)', afterconstructor: function ll_aftercontructor() { @@ -37917,13 +37749,13 @@ var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { }, parseTable: function ll_ParseTable(productions) { - var table = {}, - symbols_ = this.symbols_, - self = this; + let table = {}; + let symbols_ = this.symbols_; + let self = this; productions.forEach(function (production, i) { - var row = table[production.symbol] || {}; - var tokens = production.first; + let row = table[production.symbol] || {}; + let tokens = production.first; if (self.nullable(production.handle)) { tokens = union(tokens, self.nonterminals[production.symbol].follows); } @@ -37932,7 +37764,7 @@ var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { row[token].push(i); self.conflicts++; } else { - row[token] = [i]; + row[token] = [ i ]; } }); table[production.symbol] = row; @@ -37943,16 +37775,16 @@ var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { } }); -var LLGenerator = Jison$1.LLGenerator = ll.construct(); +const LLGenerator = Jison$1.LLGenerator = ll.construct(); Jison$1.Generator = function Jison_Generator(grammar, optionalLexerSection, options) { // pick the correct argument for the `options` for this call: if (!options && optionalLexerSection && typeof optionalLexerSection !== 'string') { - options = optionalLexerSection; - optionalLexerSection = null; + options = optionalLexerSection; + optionalLexerSection = null; } // and standardize it: - var preliminary_options = mkStdOptions$1(options); + let preliminary_options = mkStdOptions$1(options); // Provisionally parse the grammar, really only to obtain the *options.type* // specified within the grammar, if specified (via `%parser-type`). @@ -37974,7 +37806,7 @@ Jison$1.Generator = function Jison_Generator(grammar, optionalLexerSection, opti // // Anyway, API/CLI options **override** options coming in from the grammar spec. // - options = mkStdOptions$1("NODEFAULT", grammar.options, options); + options = mkStdOptions$1('NODEFAULT', grammar.options, options); switch (options.type || Jison$1.defaultJisonOptions.type) { case 'lr0': options.hasPartialLrUpgradeOnConflict = false; // kill this unsupported option @@ -38000,14 +37832,28 @@ Jison$1.Generator = function Jison_Generator(grammar, optionalLexerSection, opti }; function Parser$3(g, l, options) { - var gen = Jison$1.Generator(g, l, options); + let gen = Jison$1.Generator(g, l, options); return gen.createParser(); } Jison$1.Parser = Parser$3; -var rmCommonWS$6 = helpers.rmCommonWS; -var mkIdentifier$5 = helpers.mkIdentifier; +// exports for unit/system testing purposes: +Jison$1.TestExports = { + lookaheadMixin, generatorMixin, lrGeneratorMixin, + lalr, + lr0, + lr1, + ll, + parser: parser$4, + pickErrorHandlingChunk, + addOrRemoveTokenStack, + removeUnusedKernelFeatures, + expandParseArguments +}; + +const rmCommonWS$6 = helpers.rmCommonWS; +const mkIdentifier$5 = helpers.mkIdentifier; assert$1(Jison$1); @@ -38017,13 +37863,12 @@ assert$1(typeof Jison$1.mkStdOptions === 'function'); assert$1(typeof Jison$1.Generator === 'function'); -var version$3 = '0.6.2-220'; // require('./package.json').version; +const version$3 = '0.7.0-220'; // require('./package.json').version; function getCommandlineOptions() { - - var defaults = Jison$1.defaultJisonOptions; - var opts = nomnom + const defaults = Jison$1.defaultJisonOptions; + let opts = nomnom .script('jison') .unknownOptionTreatment(false) // do not accept unknown options! .produceExplicitOptionsOnly(true) @@ -38079,7 +37924,7 @@ function getCommandlineOptions() { abbr: 'm', default: defaults.moduleType, metavar: 'TYPE', - choices: ['commonjs', 'cjs', 'amd', 'umd', 'js', 'iife', 'es'], + choices: [ 'commonjs', 'cjs', 'amd', 'umd', 'js', 'iife', 'es' ], help: 'The type of module to generate.' }, moduleName: { @@ -38101,7 +37946,7 @@ function getCommandlineOptions() { abbr: 'c', flag: false, default: defaults.compressTables, // 0, 1, 2 - choices: [0, 1, 2], + choices: [ 0, 1, 2 ], help: 'Output compressed parser tables in generated modules. (0 = no compression, 1 = default compression, 2 = deep compression)' }, outputDebugTables: { @@ -38131,7 +37976,7 @@ function getCommandlineOptions() { // FAIL when found: return this.help; }, - help: 'OBSOLETED. Use \'--default-action=[for-value,for-location]\' instead. (See below in \'--help\' output.)' + help: "OBSOLETED. Use '--default-action=[for-value,for-location]' instead. (See below in '--help' output.)" }, defaultActionMode: { full: 'default-action', @@ -38139,21 +37984,21 @@ function getCommandlineOptions() { default: defaults.defaultActionMode, callback: function (val) { // split value at comma, expect zero, one or two values: - var v = ('' + val).split(','); + let v = ('' + val).split(','); if (v.length > 2) { return 'default-action=yyval,yylloc expects at most 2 modes! You specified ' + v.length; } }, transform: function (val) { // split value at comma, expect zero, one or two values: - var option = this; - var def = option.default; - var v = ('' + val).split(',').map(function cvt_modes(mode, idx) { + let option = this; + let def = option.default; + let v = ('' + val).split(',').map(function cvt_modes(mode, idx) { mode = mode.trim(); switch (mode) { case 'false': case '0': - return "none"; + return 'none'; case 'true': case '1': @@ -38179,7 +38024,7 @@ function getCommandlineOptions() { - classic : generate a parser which includes the default $$ = $1; action for every rule. - - 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 dentical to "classic" mode. + - 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. - 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;" - 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! @@ -38195,7 +38040,7 @@ function getCommandlineOptions() { --default-action=ast equals: --default-action=ast,ast - - when you do not specify an explicit default mode or only a "true"/"1" value, the default is assumed: "${defaults.defaultActionMode.join(",")}". + - when you do not specify an explicit default mode or only a "true"/"1" value, the default is assumed: "${defaults.defaultActionMode.join(',')}". - when you specify "false"/"0" as an explicit default mode, "none,none" is assumed. This produces the fastest deterministic parser. ` }, @@ -38212,11 +38057,11 @@ function getCommandlineOptions() { default: defaults.errorRecoveryTokenDiscardCount, callback: function (count) { if (count != parseInt(count)) { - return "count must be an integer"; + return 'count must be an integer'; } count = parseInt(count); if (count < 2) { - return "count must be >= 2"; + return 'count must be >= 2'; } }, transform: function (val) { @@ -38229,7 +38074,7 @@ function getCommandlineOptions() { abbr: 'E', flag: true, default: defaults.exportAllTables, - help: 'Next to producing a grammar source file, also export the symbols, terminals, grammar and parse tables to separate JSON files for further use by other tools. The files\' names will be derived from the outputFile name by appending a suffix.' + help: "Next to producing a grammar source file, also export the symbols, terminals, grammar and parse tables to separate JSON files for further use by other tools. The files' names will be derived from the outputFile name by appending a suffix." }, exportAST: { full: 'export-ast', @@ -38257,7 +38102,7 @@ function getCommandlineOptions() { flag: true, metavar: 'false|true|CFGFILE', default: defaults.prettyCfg, - help: 'Output the generated code pretty-formatted; turning this option OFF will output the generated code as-is a.k.a. \'raw\'.', + help: "Output the generated code pretty-formatted; turning this option OFF will output the generated code as-is a.k.a. 'raw'." }, main: { full: 'main', @@ -38284,7 +38129,7 @@ function getCommandlineOptions() { }).parse(); if (opts.debug) { - console.log("JISON CLI options:\n", opts); + console.log('JISON CLI options:\n', opts); } return opts; @@ -38311,7 +38156,7 @@ function cliMain(opts) { return true; } catch (e) { if (e.code === 'ENOENT') { - var parent = path$1.dirname(fp); + let parent = path$1.dirname(fp); // Did we hit the root directory by now? If so, abort! // Else, create the parent; iff that fails, we fail too... if (parent !== fp && mkdirp(parent)) { @@ -38330,20 +38175,20 @@ function cliMain(opts) { function processInputFile() { // getting raw files - var lex; - var original_cwd = process$1.cwd(); + let lex; + const original_cwd = process$1.cwd(); if (opts.lexfile) { lex = fs.readFileSync(path$1.normalize(opts.lexfile), 'utf8'); } - var raw = fs.readFileSync(path$1.normalize(opts.file), 'utf8'); + let raw = fs.readFileSync(path$1.normalize(opts.file), 'utf8'); // making best guess at json mode opts.json = path$1.extname(opts.file) === '.json' || opts.json; // When only the directory part of the output path was specified, then we // do NOT have the target module name in there as well! - var outpath = opts.outfile; + let outpath = opts.outfile; if (typeof outpath === 'string') { if (/[\\\/]$/.test(outpath) || isDirectory(outpath)) { opts.outfile = null; @@ -38362,7 +38207,7 @@ function cliMain(opts) { // setting output file name and module name based on input file name // if they aren't specified. - var name = path$1.basename(opts.outfile || opts.file); + let name = path$1.basename(opts.outfile || opts.file); // get the base name (i.e. the file name without extension) // i.e. strip off only the extension and keep any other dots in the filename @@ -38419,10 +38264,10 @@ function cliMain(opts) { // Change CWD to the directory where the source grammar resides: this helps us properly // %include any files mentioned in the grammar with relative paths: - var new_cwd = path$1.dirname(path$1.normalize(opts.file)); + let new_cwd = path$1.dirname(path$1.normalize(opts.file)); process$1.chdir(new_cwd); - var parser = cli.generateParserString(raw, lex, opts); + let parser = cli.generateParserString(raw, lex, opts); // and change back to the CWD we started out with: process$1.chdir(original_cwd); @@ -38435,11 +38280,11 @@ function cliMain(opts) { if (opts.exportAllTables.enabled) { // Determine the output file path 'template' for use by the exportAllTables // functionality: - var out_base_fname = path$1.join(path$1.dirname(opts.outfile), path$1.basename(opts.outfile, path$1.extname(opts.outfile))); + let out_base_fname = path$1.join(path$1.dirname(opts.outfile), path$1.basename(opts.outfile, path$1.extname(opts.outfile))); - var t = opts.exportAllTables; + let t = opts.exportAllTables; - for (var id in t) { + for (let id in t) { if (t.hasOwnProperty(id) && id !== 'enabled') { var content = t[id]; if (content) { @@ -38480,8 +38325,8 @@ function cliMain(opts) { } function readin(cb) { - var stdin = process$1.openStdin(), - data = ''; + let stdin = process$1.openStdin(), + data = ''; stdin.setEncoding('utf8'); stdin.addListener('data', function (chunk) { @@ -38509,10 +38354,11 @@ function cliMain(opts) { function generateParserString(grammar, optionalLexSection, opts) { + // var settings = Jison.mkStdOptions(opts); - var generator = new Jison$1.Generator(grammar, optionalLexSection, opts); - var srcCode = generator.generate(opts); + let generator = new Jison$1.Generator(grammar, optionalLexSection, opts); + let srcCode = generator.generate(opts); generator.reportGrammarInformation(); // as `opts` is cloned inside `generator.generate()`, we need to fetch @@ -38531,7 +38377,7 @@ var cli = { if (require.main === module) { - var opts = getCommandlineOptions(); + let opts = getCommandlineOptions(); cli.main(opts); } diff --git a/dist/cli-umd-es5.js b/dist/cli-umd-es5.js index 389563d6d..667428828 100644 --- a/dist/cli-umd-es5.js +++ b/dist/cli-umd-es5.js @@ -3,8 +3,18 @@ "use strict"; +function _templateObject163() { + 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 "]); + + _templateObject163 = function _templateObject163() { + return data; + }; + + return data; +} + function _templateObject162() { - 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 dentical 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 dentical 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 "]); + 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 "]); _templateObject162 = function _templateObject162() { return data; @@ -14,7 +24,7 @@ function _templateObject162() { } function _templateObject161() { - var data = _taggedTemplateLiteral(["\n ", "\n\n var 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 var 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 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 "]); _templateObject161 = function _templateObject161() { return data; @@ -24,7 +34,7 @@ function _templateObject161() { } function _templateObject160() { - 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\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 "]); _templateObject160 = function _templateObject160() { return data; @@ -34,7 +44,7 @@ function _templateObject160() { } function _templateObject159() { - 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 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 "]); _templateObject159 = function _templateObject159() { return data; @@ -44,7 +54,7 @@ function _templateObject159() { } function _templateObject158() { - 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 // 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 "]); _templateObject158 = function _templateObject158() { return data; @@ -54,7 +64,7 @@ function _templateObject158() { } function _templateObject157() { - 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 ", "\n\n let yymain = ", ";\n\n function yyExecMain() {\n yymain(process.argv.slice(1));\n }\n "]); _templateObject157 = function _templateObject157() { return data; @@ -64,7 +74,7 @@ function _templateObject157() { } function _templateObject156() { - var data = _taggedTemplateLiteral(["\n\n ", "\n\n var yymain = ", ";\n\n function yyExecMain() {\n yymain(process.argv.slice(1));\n }\n "]); + var data = _taggedTemplateLiteral(["\n\n // START code section \"", "\"\n ", "\n // END code section \"", "\"\n\n "]); _templateObject156 = function _templateObject156() { return data; @@ -74,7 +84,7 @@ function _templateObject156() { } function _templateObject155() { - var data = _taggedTemplateLiteral(["\n\n // START code section \"", "\"\n ", "\n // END code section \"", "\"\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 "]); _templateObject155 = function _templateObject155() { return data; @@ -84,7 +94,7 @@ function _templateObject155() { } function _templateObject154() { - 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 %%\n\n "]); _templateObject154 = function _templateObject154() { return data; @@ -94,7 +104,7 @@ function _templateObject154() { } function _templateObject153() { - var data = _taggedTemplateLiteral(["\n\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 "]); _templateObject153 = function _templateObject153() { return data; @@ -104,7 +114,7 @@ function _templateObject153() { } function _templateObject152() { - 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 %%\n\n "]); _templateObject152 = function _templateObject152() { return data; @@ -114,7 +124,7 @@ function _templateObject152() { } function _templateObject151() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n /*\n * Parser stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); _templateObject151 = function _templateObject151() { return data; @@ -124,7 +134,7 @@ function _templateObject151() { } function _templateObject150() { - var data = _taggedTemplateLiteral(["\n /*\n * Parser stuff that's unknown to the JISON prettyPrint service:\n *\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 "]); _templateObject150 = function _templateObject150() { return data; @@ -134,7 +144,7 @@ function _templateObject150() { } function _templateObject149() { - 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 // END of unknown declarations.\n "]); _templateObject149 = function _templateObject149() { return data; @@ -144,7 +154,7 @@ function _templateObject149() { } function _templateObject148() { - var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); + var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); _templateObject148 = function _templateObject148() { return data; @@ -154,7 +164,7 @@ function _templateObject148() { } function _templateObject147() { - var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject147 = function _templateObject147() { return data; @@ -174,7 +184,7 @@ function _templateObject146() { } function _templateObject145() { - 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 "]); _templateObject145 = function _templateObject145() { return data; @@ -184,7 +194,7 @@ function _templateObject145() { } function _templateObject144() { - var data = _taggedTemplateLiteral(["\n /*\n * Lexer stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); + var data = _taggedTemplateLiteral(["\n // options:\n "]); _templateObject144 = function _templateObject144() { return data; @@ -194,7 +204,7 @@ function _templateObject144() { } function _templateObject143() { - var data = _taggedTemplateLiteral(["\n // options:\n "]); + var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); _templateObject143 = function _templateObject143() { return data; @@ -204,7 +214,7 @@ function _templateObject143() { } function _templateObject142() { - var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); + var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); _templateObject142 = function _templateObject142() { return data; @@ -214,7 +224,7 @@ function _templateObject142() { } function _templateObject141() { - var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); + var data = _taggedTemplateLiteral(["\n // END of the lexer macros.\n "]); _templateObject141 = function _templateObject141() { return data; @@ -224,7 +234,7 @@ function _templateObject141() { } function _templateObject140() { - var data = _taggedTemplateLiteral(["\n // END of the lexer macros.\n "]); + var data = _taggedTemplateLiteral(["\n // macros:\n "]); _templateObject140 = function _templateObject140() { return data; @@ -234,7 +244,7 @@ function _templateObject140() { } function _templateObject139() { - var data = _taggedTemplateLiteral(["\n // macros:\n "]); + var data = _taggedTemplateLiteral(["\n unsupported parser input: ", "\n while lexing in ", " state.\n \n Erroneous area:\n "]); _templateObject139 = function _templateObject139() { return data; @@ -244,7 +254,7 @@ function _templateObject139() { } function _templateObject138() { - 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 "]); _templateObject138 = function _templateObject138() { return data; @@ -274,7 +284,7 @@ function _templateObject136() { } function _templateObject135() { - 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 "]); _templateObject135 = function _templateObject135() { return data; @@ -304,7 +314,7 @@ function _templateObject133() { } function _templateObject132() { - 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 "]); _templateObject132 = function _templateObject132() { return data; @@ -334,7 +344,7 @@ function _templateObject130() { } function _templateObject129() { - 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 "]); _templateObject129 = function _templateObject129() { return data; @@ -344,7 +354,7 @@ function _templateObject129() { } function _templateObject128() { - var data = _taggedTemplateLiteral(["\n EBNF: ignoring unsupported parser option ", "\n while lexing in ", " state.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n module code declaration error?\n \n Erroneous area:\n "]); _templateObject128 = function _templateObject128() { return data; @@ -354,7 +364,7 @@ function _templateObject128() { } function _templateObject127() { - var data = _taggedTemplateLiteral(["\n module code declaration error?\n \n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n "]); _templateObject127 = function _templateObject127() { return data; @@ -364,7 +374,7 @@ function _templateObject127() { } function _templateObject126() { - var data = _taggedTemplateLiteral(["\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n "]); + var data = _taggedTemplateLiteral(["\n included action code file \"", "\" does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject126 = function _templateObject126() { return data; @@ -374,7 +384,7 @@ function _templateObject126() { } function _templateObject125() { - 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 match curly braces '{ ... }' in a parser rule action block.\n \n Erroneous area:\n ", "\n "]); _templateObject125 = function _templateObject125() { return data; @@ -384,7 +394,7 @@ function _templateObject125() { } function _templateObject124() { - 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 Seems you did not correctly bracket a parser rule action block in curly braces: '{ ... }'.\n \n Erroneous area:\n ", "\n "]); _templateObject124 = function _templateObject124() { return data; @@ -394,7 +404,7 @@ function _templateObject124() { } function _templateObject123() { - 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 %prec precedence override declaration error?\n \n Erroneous precedence declaration:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject123 = function _templateObject123() { return data; @@ -404,7 +414,7 @@ function _templateObject123() { } function _templateObject122() { - 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 Seems you did not correctly bracket a grammar rule sublist in '( ... )' brackets.\n \n Erroneous area:\n ", "\n "]); _templateObject122 = function _templateObject122() { return data; @@ -414,7 +424,7 @@ function _templateObject122() { } function _templateObject121() { - 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 rule action declaration error?\n \n Erroneous area:\n ", "\n "]); _templateObject121 = function _templateObject121() { return data; @@ -424,7 +434,7 @@ function _templateObject121() { } function _templateObject120() { - 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 "]); _templateObject120 = function _templateObject120() { return data; @@ -434,7 +444,7 @@ function _templateObject120() { } function _templateObject119() { - 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 "]); _templateObject119 = function _templateObject119() { return data; @@ -444,7 +454,7 @@ function _templateObject119() { } function _templateObject118() { - 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 action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject118 = function _templateObject118() { return data; @@ -454,7 +464,7 @@ function _templateObject118() { } function _templateObject117() { - var data = _taggedTemplateLiteral(["\n production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n multiple alternative rule productions should be separated by a '|' pipe character, not a ':' colon!\n \n Erroneous area:\n ", "\n "]); _templateObject117 = function _templateObject117() { return data; @@ -464,7 +474,7 @@ function _templateObject117() { } function _templateObject116() { - var data = _taggedTemplateLiteral(["\n multiple alternative rule productions should be separated by a '|' pipe character, not a ':' colon!\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n rule alternative production declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject116 = function _templateObject116() { return data; @@ -474,7 +484,7 @@ function _templateObject116() { } function _templateObject115() { - var data = _taggedTemplateLiteral(["\n rule alternative production declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Production for rule '", "' is missing: arrows introduce action code in Jison.\n \n Jison does not support rule production definition using arrows (->, =>, \u2192) but expects\n colons (:) instead, so maybe you intended this:\n \n ", " : ", "\n \n while the user-defined action code block MAY be an arrow function, e.g.\n \n rule: math_production -> Math.min($math_production, 42);\n \n Erroneous area:\n ", "\n "]); _templateObject115 = function _templateObject115() { return data; @@ -484,7 +494,7 @@ function _templateObject115() { } function _templateObject114() { - var data = _taggedTemplateLiteral(["\n Production for rule '", "' is missing: arrows introduce action code in Jison.\n \n Jison does not support rule production definition using arrows (->, =>, \u2192) but expects\n colons (:) instead, so maybe you intended this:\n \n ", " : ", "\n \n while the user-defined action code block MAY be an arrow function, e.g.\n \n rule: math_production -> Math.min($math_production, 42);\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n rule id should be followed by a colon, but that one seems missing?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject114 = function _templateObject114() { return data; @@ -494,7 +504,7 @@ function _templateObject114() { } function _templateObject113() { - var data = _taggedTemplateLiteral(["\n rule id should be followed by a colon, but that one seems missing?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n rule production declaration error: did you terminate the rule production set with a semicolon?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject113 = function _templateObject113() { return data; @@ -504,7 +514,7 @@ function _templateObject113() { } function _templateObject112() { - var data = _taggedTemplateLiteral(["\n rule production declaration error: did you terminate the rule production set with a semicolon?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n rule production declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject112 = function _templateObject112() { return data; @@ -514,7 +524,7 @@ function _templateObject112() { } function _templateObject111() { - var data = _taggedTemplateLiteral(["\n rule production declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n operator token list error in an associativity statement?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject111 = function _templateObject111() { return data; @@ -524,7 +534,7 @@ function _templateObject111() { } function _templateObject110() { - var data = _taggedTemplateLiteral(["\n operator token list error in an associativity statement?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %parser-type declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject110 = function _templateObject110() { return data; @@ -534,7 +544,7 @@ function _templateObject110() { } function _templateObject109() { - var data = _taggedTemplateLiteral(["\n %parser-type declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %parse-params declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject109 = function _templateObject109() { return data; @@ -544,7 +554,7 @@ function _templateObject109() { } function _templateObject108() { - var data = _taggedTemplateLiteral(["\n %parse-params declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n named %option value assignment error?\n \n Erroneous area:\n ", "\n "]); _templateObject108 = function _templateObject108() { return data; @@ -554,7 +564,7 @@ function _templateObject108() { } function _templateObject107() { - var data = _taggedTemplateLiteral(["\n named %option value assignment error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n named %option value error for ", "?\n \n Erroneous area:\n ", "\n "]); _templateObject107 = function _templateObject107() { return data; @@ -564,7 +574,7 @@ function _templateObject107() { } function _templateObject106() { - var data = _taggedTemplateLiteral(["\n named %option value error for ", "?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %options don't seem terminated?\n \n Erroneous area:\n ", "\n "]); _templateObject106 = function _templateObject106() { return data; @@ -574,7 +584,7 @@ function _templateObject106() { } function _templateObject105() { - var data = _taggedTemplateLiteral(["\n %options don't seem terminated?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %options ill defined / error?\n \n Erroneous area:\n ", "\n "]); _templateObject105 = function _templateObject105() { return data; @@ -584,7 +594,7 @@ function _templateObject105() { } function _templateObject104() { - var data = _taggedTemplateLiteral(["\n %options ill defined / error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %import name or source filename missing maybe?\n \n Erroneous area:\n ", "\n "]); _templateObject104 = function _templateObject104() { return data; @@ -594,7 +604,7 @@ function _templateObject104() { } function _templateObject103() { - var data = _taggedTemplateLiteral(["\n %import name or source filename missing maybe?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %token definition list error?\n \n Erroneous area:\n ", "\n "]); _templateObject103 = function _templateObject103() { return data; @@ -604,7 +614,7 @@ function _templateObject103() { } function _templateObject102() { - var data = _taggedTemplateLiteral(["\n %token definition list error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %start token error?\n \n Erroneous area:\n ", "\n "]); _templateObject102 = function _templateObject102() { return data; @@ -614,7 +624,7 @@ function _templateObject102() { } function _templateObject101() { - var data = _taggedTemplateLiteral(["\n %start token error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Each '%code' initialization code section must be qualified by a name, e.g. 'required' before the action code itself:\n \n %code qualifier_name {action code}\n \n Erroneous area:\n ", "\n "]); _templateObject101 = function _templateObject101() { return data; @@ -624,7 +634,7 @@ function _templateObject101() { } function _templateObject100() { - var data = _taggedTemplateLiteral(["\n Each '%code' initialization code section must be qualified by a name, e.g. 'required' before the action code itself:\n \n %code qualifier_name {action code}\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %code \"", "\" initialization section action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject100 = function _templateObject100() { return data; @@ -634,7 +644,7 @@ function _templateObject100() { } function _templateObject99() { - var data = _taggedTemplateLiteral(["\n %code \"", "\" initialization section action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Each '%import'-ed initialization code section must be qualified by a name, e.g. 'required' before the import path itself:\n \n %import qualifier_name file_path\n \n Erroneous area:\n ", "\n "]); _templateObject99 = function _templateObject99() { return data; @@ -644,7 +654,7 @@ function _templateObject99() { } function _templateObject98() { - var data = _taggedTemplateLiteral(["\n Each '%import'-ed initialization code section must be qualified by a name, e.g. 'required' before the import path itself:\n \n %import qualifier_name file_path\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n You did not specify a legal file path for the '%import' initialization code statement, which must have the format:\n \n %import qualifier_name file_path\n \n Erroneous area:\n ", "\n "]); _templateObject98 = function _templateObject98() { return data; @@ -654,7 +664,7 @@ function _templateObject98() { } function _templateObject97() { - var data = _taggedTemplateLiteral(["\n You did not specify a legal file path for the '%import' initialization code statement, which must have the format:\n \n %import qualifier_name file_path\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n action header code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject97 = function _templateObject97() { return data; @@ -664,7 +674,7 @@ function _templateObject97() { } function _templateObject96() { - var data = _taggedTemplateLiteral(["\n action header code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject96 = function _templateObject96() { return data; @@ -674,7 +684,7 @@ function _templateObject96() { } function _templateObject95() { - var data = _taggedTemplateLiteral(["\n action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n declaration list error?\n \n Erroneous area:\n ", "\n "]); _templateObject95 = function _templateObject95() { return data; @@ -684,7 +694,7 @@ function _templateObject95() { } function _templateObject94() { - var data = _taggedTemplateLiteral(["\n declaration list error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n action header code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject94 = function _templateObject94() { return data; @@ -694,7 +704,7 @@ function _templateObject94() { } function _templateObject93() { - var data = _taggedTemplateLiteral(["\n action header code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n The extra parser module code section (a.k.a. 'epilogue') does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject93 = function _templateObject93() { return data; @@ -704,7 +714,7 @@ function _templateObject93() { } function _templateObject92() { - var data = _taggedTemplateLiteral(["\n The extra parser module code section (a.k.a. 'epilogue') does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Maybe you did not correctly separate the parse 'header section' (token definitions, options, lexer spec, etc.) from the grammar rule set with a '%%' on an otherwise empty line?\n \n Erroneous area:\n ", "\n "]); _templateObject92 = function _templateObject92() { return data; @@ -714,7 +724,7 @@ function _templateObject92() { } function _templateObject91() { - var data = _taggedTemplateLiteral(["\n Maybe you did not correctly separate the parse 'header section' (token definitions, options, lexer spec, etc.) from the grammar rule set with a '%%' on an otherwise empty line?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n illegal input in the parser grammar productions definition section.\n \n Maybe you did not correctly separate trailing code from the grammar rule set with a '%%' marker on an otherwise empty line?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject91 = function _templateObject91() { return data; @@ -724,7 +734,7 @@ function _templateObject91() { } function _templateObject90() { - var data = _taggedTemplateLiteral(["\n illegal input in the parser grammar productions definition section.\n \n Maybe you did not correctly separate trailing code from the grammar rule set with a '%%' marker on an otherwise empty line?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n ", "\n\n var ", " = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n\n if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\n exports.lexer = ", ";\n exports.lex = function () {\n return ", ".lex.apply(lexer, arguments);\n };\n }\n "]); _templateObject90 = function _templateObject90() { return data; @@ -734,7 +744,7 @@ function _templateObject90() { } function _templateObject89() { - var data = _taggedTemplateLiteral(["\n ", "\n\n var ", " = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n\n if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\n exports.lexer = ", ";\n exports.lex = function () {\n return ", ".lex.apply(lexer, arguments);\n };\n }\n "]); + var data = _taggedTemplateLiteral(["\n ", "\n\n const lexer = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n\n function yylex() {\n return lexer.lex.apply(lexer, arguments);\n }\n\n export {\n lexer,\n yylex as lex\n };\n "]); _templateObject89 = function _templateObject89() { return data; @@ -744,7 +754,7 @@ function _templateObject89() { } function _templateObject88() { - var data = _taggedTemplateLiteral(["\n ", "\n\n var lexer = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n\n function yylex() {\n return lexer.lex.apply(lexer, arguments);\n }\n\n export {\n lexer,\n yylex as lex\n };\n "]); + var data = _taggedTemplateLiteral(["\n ", "\n\n define([], function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n });\n "]); _templateObject88 = function _templateObject88() { return data; @@ -754,7 +764,7 @@ function _templateObject88() { } function _templateObject87() { - var data = _taggedTemplateLiteral(["\n ", "\n\n define([], function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n });\n "]); + var data = _taggedTemplateLiteral(["\n ", "\n\n var ", " = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n "]); _templateObject87 = function _templateObject87() { return data; @@ -764,7 +774,7 @@ function _templateObject87() { } function _templateObject86() { - var data = _taggedTemplateLiteral(["\n ", "\n\n var ", " = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n "]); + var data = _taggedTemplateLiteral(["\n /* lexer generated by jison-lex ", " */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" `yy` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This \"shared context\" object was passed to the lexer by way of\n * the `lexer.setInput(str, yy)` API before you may use it.\n *\n * This \"shared context\" object is passed to the lexer action code in `performAction()`\n * so userland code in the lexer actions may communicate with the outside world\n * and/or other lexer rules' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall \"shared context\" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `lexer` instance.\n * `yy_` is an alias for `this` lexer instance reference used internally.\n *\n * - `yy` : a reference to the `yy` \"shared state\" object which was passed to the lexer\n * by way of the `lexer.setInput(str, yy)` API before.\n *\n * Note:\n * The extra arguments you specified in the `%parse-param` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - `yyrulenumber` : index of the matched lexer rule (regex), used internally.\n *\n * - `YY_START`: the current lexer \"start condition\" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.\n * See it's use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo('fail!', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the `lexer.setInput()` API.\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of the **lexer** grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Lexer's additional `args...` parameters (via lexer's `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the **parser** or the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.\n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (`yylloc`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a 'hash' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal \"shared state\" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while `this` will reference the current lexer instance.\n *\n * When `parseError` is invoked by the lexer, the default implementation will\n * attempt to invoke `yy.parser.parseError()`; when this callback is not provided\n * it will try to invoke `yy.parseError()` instead. When that callback is also not\n * provided, a `JisonLexerError` exception will be thrown containing the error\n * message and `hash`, as constructed by the `constructLexErrorInfo()` API.\n *\n * Note that the lexer's `JisonLexerError` error class is passed via the\n * `ExceptionClass` argument, which is invoked to construct the exception\n * instance to be thrown, so technically `parseError` will throw the object\n * produced by the `new ExceptionClass(str, hash)` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the `.options` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n *\n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are \"extended regex format\" requiring the\n * `XRegExp` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n "], ["\n /* lexer generated by jison-lex ", " */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" \\`yy\\` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This \"shared context\" object was passed to the lexer by way of\n * the \\`lexer.setInput(str, yy)\\` API before you may use it.\n *\n * This \"shared context\" object is passed to the lexer action code in \\`performAction()\\`\n * so userland code in the lexer actions may communicate with the outside world\n * and/or other lexer rules' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall \"shared context\" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and \\`this\\` have the following value/meaning:\n * - \\`this\\` : reference to the \\`lexer\\` instance.\n * \\`yy_\\` is an alias for \\`this\\` lexer instance reference used internally.\n *\n * - \\`yy\\` : a reference to the \\`yy\\` \"shared state\" object which was passed to the lexer\n * by way of the \\`lexer.setInput(str, yy)\\` API before.\n *\n * Note:\n * The extra arguments you specified in the \\`%parse-param\\` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - \\`yyrulenumber\\` : index of the matched lexer rule (regex), used internally.\n *\n * - \\`YY_START\\`: the current lexer \"start condition\" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo \\'hash object\\' which can be passed into \\`parseError()\\`.\n * See it\\'s use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo(\\'fail!\\', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the \\`lexer.setInput()\\` API.\n * You MAY use the additional \\`args...\\` parameters as per \\`%parse-param\\` spec of the **lexer** grammar:\n * these extra \\`args...\\` are added verbatim to the \\`yy\\` object reference as member variables.\n *\n * WARNING:\n * Lexer's additional \\`args...\\` parameters (via lexer's \\`%parse-param\\`) MAY conflict with\n * any attributes already added to \\`yy\\` by the **parser** or the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.\n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (\\`yylloc\\`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The \\`parseError\\` function receives a \\'hash\\' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal \"shared state\" \\`yy\\`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while \\`this\\` will reference the current lexer instance.\n *\n * When \\`parseError\\` is invoked by the lexer, the default implementation will\n * attempt to invoke \\`yy.parser.parseError()\\`; when this callback is not provided\n * it will try to invoke \\`yy.parseError()\\` instead. When that callback is also not\n * provided, a \\`JisonLexerError\\` exception will be thrown containing the error\n * message and \\`hash\\`, as constructed by the \\`constructLexErrorInfo()\\` API.\n *\n * Note that the lexer\\'s \\`JisonLexerError\\` error class is passed via the\n * \\`ExceptionClass\\` argument, which is invoked to construct the exception\n * instance to be thrown, so technically \\`parseError\\` will throw the object\n * produced by the \\`new ExceptionClass(str, hash)\\` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the \\`.options\\` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n *\n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default \\`parseError\\` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * \\`this\\` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token \\`token\\`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original \\`token\\`.\n * \\`this\\` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: \\`true\\` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: \\`true\\` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: \\`true\\` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: \\`true\\` ==> lexer rule regexes are \"extended regex format\" requiring the\n * \\`XRegExp\\` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n "]); _templateObject86 = function _templateObject86() { return data; @@ -774,7 +784,7 @@ function _templateObject86() { } function _templateObject85() { - var data = _taggedTemplateLiteral(["\n /* lexer generated by jison-lex ", " */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" `yy` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This \"shared context\" object was passed to the lexer by way of\n * the `lexer.setInput(str, yy)` API before you may use it.\n *\n * This \"shared context\" object is passed to the lexer action code in `performAction()`\n * so userland code in the lexer actions may communicate with the outside world\n * and/or other lexer rules' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall \"shared context\" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `lexer` instance.\n * `yy_` is an alias for `this` lexer instance reference used internally.\n *\n * - `yy` : a reference to the `yy` \"shared state\" object which was passed to the lexer\n * by way of the `lexer.setInput(str, yy)` API before.\n *\n * Note:\n * The extra arguments you specified in the `%parse-param` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - `yyrulenumber` : index of the matched lexer rule (regex), used internally.\n *\n * - `YY_START`: the current lexer \"start condition\" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.\n * See it's use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo('fail!', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the `lexer.setInput()` API.\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of the **lexer** grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Lexer's additional `args...` parameters (via lexer's `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the **parser** or the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.\n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (`yylloc`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a 'hash' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal \"shared state\" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while `this` will reference the current lexer instance.\n *\n * When `parseError` is invoked by the lexer, the default implementation will\n * attempt to invoke `yy.parser.parseError()`; when this callback is not provided\n * it will try to invoke `yy.parseError()` instead. When that callback is also not\n * provided, a `JisonLexerError` exception will be thrown containing the error\n * message and `hash`, as constructed by the `constructLexErrorInfo()` API.\n *\n * Note that the lexer's `JisonLexerError` error class is passed via the\n * `ExceptionClass` argument, which is invoked to construct the exception\n * instance to be thrown, so technically `parseError` will throw the object\n * produced by the `new ExceptionClass(str, hash)` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the `.options` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n *\n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are \"extended regex format\" requiring the\n * `XRegExp` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n "], ["\n /* lexer generated by jison-lex ", " */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" \\`yy\\` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This \"shared context\" object was passed to the lexer by way of\n * the \\`lexer.setInput(str, yy)\\` API before you may use it.\n *\n * This \"shared context\" object is passed to the lexer action code in \\`performAction()\\`\n * so userland code in the lexer actions may communicate with the outside world\n * and/or other lexer rules' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall \"shared context\" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and \\`this\\` have the following value/meaning:\n * - \\`this\\` : reference to the \\`lexer\\` instance.\n * \\`yy_\\` is an alias for \\`this\\` lexer instance reference used internally.\n *\n * - \\`yy\\` : a reference to the \\`yy\\` \"shared state\" object which was passed to the lexer\n * by way of the \\`lexer.setInput(str, yy)\\` API before.\n *\n * Note:\n * The extra arguments you specified in the \\`%parse-param\\` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - \\`yyrulenumber\\` : index of the matched lexer rule (regex), used internally.\n *\n * - \\`YY_START\\`: the current lexer \"start condition\" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo \\'hash object\\' which can be passed into \\`parseError()\\`.\n * See it\\'s use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo(\\'fail!\\', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the \\`lexer.setInput()\\` API.\n * You MAY use the additional \\`args...\\` parameters as per \\`%parse-param\\` spec of the **lexer** grammar:\n * these extra \\`args...\\` are added verbatim to the \\`yy\\` object reference as member variables.\n *\n * WARNING:\n * Lexer's additional \\`args...\\` parameters (via lexer's \\`%parse-param\\`) MAY conflict with\n * any attributes already added to \\`yy\\` by the **parser** or the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.\n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (\\`yylloc\\`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The \\`parseError\\` function receives a \\'hash\\' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal \"shared state\" \\`yy\\`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while \\`this\\` will reference the current lexer instance.\n *\n * When \\`parseError\\` is invoked by the lexer, the default implementation will\n * attempt to invoke \\`yy.parser.parseError()\\`; when this callback is not provided\n * it will try to invoke \\`yy.parseError()\\` instead. When that callback is also not\n * provided, a \\`JisonLexerError\\` exception will be thrown containing the error\n * message and \\`hash\\`, as constructed by the \\`constructLexErrorInfo()\\` API.\n *\n * Note that the lexer\\'s \\`JisonLexerError\\` error class is passed via the\n * \\`ExceptionClass\\` argument, which is invoked to construct the exception\n * instance to be thrown, so technically \\`parseError\\` will throw the object\n * produced by the \\`new ExceptionClass(str, hash)\\` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the \\`.options\\` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n *\n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default \\`parseError\\` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * \\`this\\` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token \\`token\\`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original \\`token\\`.\n * \\`this\\` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: \\`true\\` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: \\`true\\` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: \\`true\\` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: \\`true\\` ==> lexer rule regexes are \"extended regex format\" requiring the\n * \\`XRegExp\\` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n "]); + var data = _taggedTemplateLiteral([",\n JisonLexerError: JisonLexerError,\n performAction: ", ",\n simpleCaseActionClusters: ", ",\n rules: [\n ", "\n ],\n conditions: ", "\n };\n "]); _templateObject85 = function _templateObject85() { return data; @@ -784,7 +794,7 @@ function _templateObject85() { } function _templateObject84() { - var data = _taggedTemplateLiteral([",\n JisonLexerError: JisonLexerError,\n performAction: ", ",\n simpleCaseActionClusters: ", ",\n rules: [\n ", "\n ],\n conditions: ", "\n };\n "]); + var data = _taggedTemplateLiteral(["\n const lexer = {\n "]); _templateObject84 = function _templateObject84() { return data; @@ -794,7 +804,7 @@ function _templateObject84() { } function _templateObject83() { - var data = _taggedTemplateLiteral(["\n var lexer = {\n "]); + var data = _taggedTemplateLiteral(["\n // Code Generator Information Report\n // ---------------------------------\n //\n // Options:\n //\n // backtracking: .................... ", "\n // location.ranges: ................. ", "\n // location line+column tracking: ... ", "\n //\n //\n // Forwarded Parser Analysis flags:\n //\n // uses yyleng: ..................... ", "\n // uses yylineno: ................... ", "\n // uses yytext: ..................... ", "\n // uses yylloc: ..................... ", "\n // uses lexer values: ............... ", " / ", "\n // location tracking: ............... ", "\n // location assignment: ............. ", "\n //\n //\n // Lexer Analysis flags:\n //\n // uses yyleng: ..................... ", "\n // uses yylineno: ................... ", "\n // uses yytext: ..................... ", "\n // uses yylloc: ..................... ", "\n // uses ParseError API: ............. ", "\n // uses yyerror: .................... ", "\n // uses location tracking & editing: ", "\n // uses more() API: ................. ", "\n // uses unput() API: ................ ", "\n // uses reject() API: ............... ", "\n // uses less() API: ................. ", "\n // uses display APIs pastInput(), upcomingInput(), showPosition():\n // ............................. ", "\n // uses describeYYLLOC() API: ....... ", "\n //\n // --------- END OF REPORT -----------\n\n "]); _templateObject83 = function _templateObject83() { return data; @@ -804,7 +814,7 @@ function _templateObject83() { } function _templateObject82() { - var data = _taggedTemplateLiteral(["\n // Code Generator Information Report\n // ---------------------------------\n //\n // Options:\n //\n // backtracking: .................... ", "\n // location.ranges: ................. ", "\n // location line+column tracking: ... ", "\n //\n //\n // Forwarded Parser Analysis flags:\n //\n // uses yyleng: ..................... ", "\n // uses yylineno: ................... ", "\n // uses yytext: ..................... ", "\n // uses yylloc: ..................... ", "\n // uses lexer values: ............... ", " / ", "\n // location tracking: ............... ", "\n // location assignment: ............. ", "\n //\n //\n // Lexer Analysis flags:\n //\n // uses yyleng: ..................... ", "\n // uses yylineno: ................... ", "\n // uses yytext: ..................... ", "\n // uses yylloc: ..................... ", "\n // uses ParseError API: ............. ", "\n // uses yyerror: .................... ", "\n // uses location tracking & editing: ", "\n // uses more() API: ................. ", "\n // uses unput() API: ................ ", "\n // uses reject() API: ............... ", "\n // uses less() API: ................. ", "\n // uses display APIs pastInput(), upcomingInput(), showPosition():\n // ............................. ", "\n // uses describeYYLLOC() API: ....... ", "\n //\n // --------- END OF REPORT -----------\n\n "]); + var data = _taggedTemplateLiteral(["\n stripUnusedLexerCode WARNING: \n\n JISON failed to reformat the generated lexer.\n Using the generated code as-is instead and pray it works in your final output!\n\n Internal error report:\n\n ", "\n\n The offending action code chunk as reported above:\n\n ", "\n "]); _templateObject82 = function _templateObject82() { return data; @@ -814,7 +824,7 @@ function _templateObject82() { } function _templateObject81() { - var data = _taggedTemplateLiteral(["\n stripUnusedLexerCode WARNING: \n\n JISON failed to reformat the generated lexer.\n Using the generated code as-is instead and pray it works in your final output!\n\n Internal error report:\n\n ", "\n\n The offending action code chunk as reported above:\n\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n \"use strict\";\n\n return ", ";\n"]); _templateObject81 = function _templateObject81() { return data; @@ -824,7 +834,7 @@ function _templateObject81() { } function _templateObject80() { - var data = _taggedTemplateLiteral(["\n \"use strict\";\n\n return ", ";\n"]); + var data = _taggedTemplateLiteral(["\n // JISON INJECTED VALIDATION CODE\n // which attempts to ascertain you have defined a minimal viable lexer at least:\n if (typeof lexer === \"undefined\") {\n throw new SyntaxError(\"user-defined lexer does not define the required 'lexer' instance.\");\n }\n if (!lexer) {\n throw new SyntaxError(\"user-defined lexer does not define a non-NULL 'lexer' instance.\");\n }\n if (typeof lexer.setInput !== 'function') {\n throw new SyntaxError(\"user-defined lexer does not provide the mandatory 'lexer.setInput()' API function.\");\n }\n if (typeof lexer.lex !== 'function') {\n throw new SyntaxError(\"user-defined lexer does not provide the mandatory 'lexer.lex()' API function.\");\n }\n // END OF JISON INJECTED VALIDATION CODE\n "]); _templateObject80 = function _templateObject80() { return data; @@ -1627,11 +1637,17 @@ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice( function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } (function (global, factory) { - (typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('fs'), require('path'), require('@gerhobbelt/json5'), require('@gerhobbelt/xregexp'), require('recast'), require('@babel/core'), require('assert'), require('ast-util'), require('process'), require('@gerhobbelt/nomnom')) : typeof define === 'function' && define.amd ? define(['fs', 'path', '@gerhobbelt/json5', '@gerhobbelt/xregexp', 'recast', '@babel/core', 'assert', 'ast-util', 'process', '@gerhobbelt/nomnom'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['jison-cli'] = factory(global.fs, global.path$1, global.JSON5, global.XRegExp, global.recast, global.babel, global.assert$1, global.astUtils, global.process$1, global.nomnom)); -})(void 0, function (fs, path$1, JSON5, XRegExp, recast, babel, assert$1, astUtils, process$1, nomnom) { + (typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('fs'), require('path'), require('@gerhobbelt/json5'), require('mkdirp'), require('@gerhobbelt/xregexp'), require('recast'), require('@babel/core'), require('assert'), require('ast-util'), require('process'), require('@gerhobbelt/nomnom')) : typeof define === 'function' && define.amd ? define(['fs', 'path', '@gerhobbelt/json5', 'mkdirp', '@gerhobbelt/xregexp', 'recast', '@babel/core', 'assert', 'ast-util', 'process', '@gerhobbelt/nomnom'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['jison-cli'] = factory(global.fs, global.path$1, global.JSON5, global.mkdirp, global.XRegExp, global.recast, global.babel, global.assert$1, global.astUtils, global.process$1, global.nomnom)); +})(void 0, function (fs, path$1, JSON5, mkdirp, XRegExp, recast, babel, assert$1, astUtils, process$1, nomnom) { 'use strict'; function _interopDefaultLegacy(e) { @@ -1646,6 +1662,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); + var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); + var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); @@ -1656,7 +1674,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var process__default = /*#__PURE__*/_interopDefaultLegacy(process$1); - var nomnom__default = /*#__PURE__*/_interopDefaultLegacy(nomnom); // Return TRUE if `src` starts with `searchString`. + var nomnom__default = /*#__PURE__*/_interopDefaultLegacy(nomnom); // Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { @@ -1679,7 +1697,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look @@ -1708,37 +1726,42 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); // Done removing common indentation. - // + { + var a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; // only correct indentation at start of line, i.e. only check for + var _a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { - if (startsWith(a[j], indent_str)) { - a[j] = a[j].substr(indent_str.length); + for (var j = 1, linecnt = _a.length; j < linecnt; j++) { + if (startsWith(_a[j], indent_str)) { + _a[j] = _a[j].substr(indent_str.length); } } } } // now merge everything to construct the template result: - var rv = []; + { + var rv = []; + var _i = 0; - for (var i = 0, len = arguments.length <= 1 ? 0 : arguments.length - 1; i < len; i++) { - rv.push(src[i].join('\n')); - rv.push(i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1]); - } // the last value is always followed by a last template string partial: + for (var _len = arguments.length <= 1 ? 0 : arguments.length - 1; _i < _len; _i++) { + rv.push(src[_i].join('\n')); + rv.push(_i + 1 < 1 || arguments.length <= _i + 1 ? undefined : arguments[_i + 1]); + } // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + rv.push(src[_i].join('\n')); + var sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` /** @public */ @@ -1758,14 +1781,36 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return rv; }); - } // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers + } // https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words + + + var reservedWords = function (list) { + var rv = new Set(); + + var _iterator = _createForOfIteratorHelper(list), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var w = _step.value; + //console.error('reserved word:', w); + rv.add(w); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + return rv; + }(['await', 'break', 'case', 'catch', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'enum', 'export', 'extends', 'finally', 'for', 'function', 'if', 'implements', 'import', 'in', 'instanceof', 'interface', 'new', 'package', 'private', 'protected', 'public', 'return', 'super', 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'yield']); // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + var rv = s // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { var c = match.charAt(1); @@ -1781,6 +1826,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi .replace(/^[^\w_]/, '_') // do not accept numerics at the leading position, despite those matching regex `\w`: .replace(/^\d/, '_').replace(/[^\w\d_]/g, '_') // and only accept multiple (double, not triple) underscores at start or end of identifier name: .replace(/^__+/, '#').replace(/__+$/, '#').replace(/_+/g, '_').replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + + return rv; } // Check if the start of the given input matches a regex expression. // Return the length of the regex expression or -1 if none was found. @@ -1816,13 +1867,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (ch === ']') { classMarker = false; } - } else { - if (ch === '/') { - terminated = true; - break; - } else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } @@ -1846,7 +1895,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function isLegalIdentifierInput(s) { - s = '' + s; // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + s = '' + s; // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` var ref = s.replace(/-\w/g, function (match) { @@ -1896,6 +1945,55 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi p = p || 2; var rv = '0000' + n; return rv.slice(-p); + } + + function convertExceptionToObject(ex) { + if (!ex) return ex; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + + var rv = Object.assign({}, ex); // - Set up the default fields which should ALWAYS be present: + + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + + if (Array.isArray(ex.errors)) { + rv.errors = []; + + var _iterator2 = _createForOfIteratorHelper(ex.errors), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var se = _step2.value; + rv.errors.push(convertExceptionToObject(se)); + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + } + + return rv; + } + + function find_suitable_app_dump_path() { + return process.cwd().replace(/\\/g, '/').replace(/\/node_modules\/.*$/, function (m) { + return '/___nm___/'; + }).replace(/(\/jison\/)(.*)$/, function (m, p1, p2) { + return p1 + '___' + p2.split('/').map(function (d) { + return d.charAt(0).toUpperCase(); + }).join('_'); + }); } // attempt to dump in one of several locations: first winner is *it*! @@ -1904,15 +2002,27 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi options = options || {}; try { - var dumpPaths = [options.outfile ? path__default['default'].dirname(options.outfile) : null, options.inputPath, process.cwd()]; + var dumpPaths = [options.outfile ? path__default['default'].dirname(options.outfile) : null, options.inputPath, find_suitable_app_dump_path()]; var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname).replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; + } // generate a stacktrace for the dump no matter what: + + + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } } err_id = err_id || 'XXX'; + err_id = err_id.replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); var ts = new Date(); var tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + '' + pad(ts.getUTCMinutes()) + '' + pad(ts.getUTCSeconds()) + '.' + pad(ts.getUTCMilliseconds(), 3) + 'Z'; dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; @@ -1923,21 +2033,34 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); var dump = { errname: errname, err_id: err_id, options: options, - ex: ex + ex: convertExceptionToObject(ex) }; - var d = JSON5__default['default'].stringify(dump, null, 2); // make sure each line is a comment line: + var d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + + return value; + }, + space: 2, + circularRefHandler: function circularRefHandler(value, circusPos, stack, keyStack, key, err) { + return '[!circular ref!]'; + } + }); // make sure each line is a comment line: d = d.split('\n').map(function (l) { return '// ' + l; }); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -1947,7 +2070,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -1978,25 +2101,36 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + var errname = '' + (title || 'exec_test'); + var err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + + var debug = options.debug || 0; + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + + if (debug > 1) { + console.warn("\n ######################## source code ##########################\n ".concat(sourcecode, "\n ######################## source code ##########################\n ")); } - var debug = 0; var p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + if (debug > 1) console.log('exec-and-diagnose options:', options); + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } @@ -2009,9 +2143,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return p; } - var code_exec = { + var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject: convertExceptionToObject }; // assert__default['default'](recast__default['default']); //var types = recast.types; @@ -2025,18 +2160,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! - var ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries + var ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: - var IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; // Determine which Unicode NonAsciiIdentifierStart characters + var IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; // Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. - // + // // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action - // code chunks. - // + // code chunks. + // // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -2048,37 +2183,37 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -2086,30 +2221,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -2120,58 +2255,58 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -2216,27 +2351,27 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return set[lsidx]; } - var escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: + var escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: - var typeIdCharSets = ["ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", + var typeIdCharSets = ['ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ"]; //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ']; //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - var reStr = escCharSet + typeIdCharSets.join(""); + var reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); var re = new RegExp("[".concat(reStr, "]"), 'g'); var hash = new Array(0xD800); @@ -2247,18 +2382,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi hash[i] = (hash[i] || 0) + 1; } // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -2269,64 +2404,64 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // var escChar = pickChar(escCharSet); var typeIdChar = []; - for (var _i = 0, l = typeIdCharSets.length; _i < l; _i++) { - typeIdChar[_i] = pickChar(typeIdCharSets[_i]); - } // produce a function set for encoding and decoding content, + for (var _i2 = 0, l = typeIdCharSets.length; _i2 < l; _i2++) { + typeIdChar[_i2] = pickChar(typeIdCharSets[_i2]); + } // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: @@ -2334,47 +2469,47 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return _ref = { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default']("#(".concat(ID_REGEX_BASE, ")#"), 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default']("$(".concat(ID_REGEX_BASE, ")|$([0-9]+)"), 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default']("@(".concat(ID_REGEX_BASE, ")|@([0-9]+)"), 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default']("#(".concat(ID_REGEX_BASE, ")|#([0-9]+)"), 'g'), // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default']("##(".concat(ID_REGEX_BASE, ")|##([0-9]+)"), 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4] - }, _defineProperty(_ref, "tokenValueReferenceRe", new XRegExp__default['default']("$-([0-9]+)", 'g')), _defineProperty(_ref, "tokenNegativeLocationStart", escChar + typeIdChar[5]), _defineProperty(_ref, "tokenNegativeLocationRe", new XRegExp__default['default']("@-([0-9]+)", 'g')), _defineProperty(_ref, "tokenNegativeStackIndexStart", escChar + typeIdChar[6]), _defineProperty(_ref, "tokenNegativeStackIndexRe", new XRegExp__default['default']("#-([0-9]+)", 'g')), _defineProperty(_ref, "tokenDetect4EncodeRe", new XRegExp__default['default']("([^$@#".concat(IN_ID_CHARSET, "])([$@#]|##)(").concat(ID_REGEX_BASE, "|[$]|-?[0-9]+)(#?)(?![$@#").concat(IN_ID_CHARSET, "])"), 'g')), _defineProperty(_ref, "tokenDetect4DecodeRe", new XRegExp__default['default']("([^$".concat(IN_ID_CHARSET, "])(").concat(escChar, "[").concat(typeIdChar.slice(0, 7).join(''), "])(").concat(ID_REGEX_BASE, "|[$]|[0-9]+)(?![$@#").concat(IN_ID_CHARSET, "])"), 'g')), _defineProperty(_ref, "encode", function encodeJisonTokens(src, locationOffsetSpec) { + }, _defineProperty(_ref, "tokenValueReferenceRe", new XRegExp__default['default']('$-([0-9]+)', 'g')), _defineProperty(_ref, "tokenNegativeLocationStart", escChar + typeIdChar[5]), _defineProperty(_ref, "tokenNegativeLocationRe", new XRegExp__default['default']('@-([0-9]+)', 'g')), _defineProperty(_ref, "tokenNegativeStackIndexStart", escChar + typeIdChar[6]), _defineProperty(_ref, "tokenNegativeStackIndexRe", new XRegExp__default['default']('#-([0-9]+)', 'g')), _defineProperty(_ref, "tokenDetect4EncodeRe", new XRegExp__default['default']("([^$@#".concat(IN_ID_CHARSET, "])([$@#]|##)(").concat(ID_REGEX_BASE, "|[$]|-?[0-9]+)(#?)(?![$@#").concat(IN_ID_CHARSET, "])"), 'g')), _defineProperty(_ref, "tokenDetect4DecodeRe", new XRegExp__default['default']("([^$".concat(IN_ID_CHARSET, "])(").concat(escChar, "[").concat(typeIdChar.slice(0, 7).join(''), "])(").concat(ID_REGEX_BASE, "|[$]|[0-9]+)(?![$@#").concat(IN_ID_CHARSET, "])"), 'g')), _defineProperty(_ref, "encode", function encodeJisonTokens(src, locationOffsetSpec) { var _this = this; var re = this.tokenDetect4EncodeRe; // reset regex @@ -2382,10 +2517,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -2469,10 +2604,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -2481,19 +2616,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // p1 is only serving as lookbehind emulation switch (p2) { case _this2.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case _this2.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case _this2.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case _this2.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case _this2.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case _this2.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -2549,13 +2684,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi sourceRoot: '.', sourceType: 'module', babelrc: false, - ignore: ["node_modules/**/*.js"], + ignore: ['node_modules/**/*.js'], compact: false, retainLines: false, - presets: [["@babel/preset-env", { + presets: [['@babel/preset-env', { targets: { - browsers: ["last 2 versions"], - node: "8.0" + browsers: ['last 2 versions'], + node: '8.0' } }]] }, options); @@ -2563,7 +2698,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } function prettyPrintAST(ast, options) { - var options = options || {}; + options = options || {}; var defaultOptions = { tabWidth: 2, quote: 'single', @@ -2586,8 +2721,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi .replace(/\uFFDA/g, '@').replace(/\uFFDB/g, '#'); return new_src; } // validate the given JISON+JavaScript snippet: does it compile? - // - // Return either the parsed AST (object) or an error message (string). + // + // Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { @@ -2607,16 +2742,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } // The rough-and-ready preprocessor for any action code block: // this one trims off any surplus whitespace and removes any // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. - // + // // Returns the trimmed sourcecode which was provided via `src`. - // + // // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -2624,7 +2759,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: - // + // // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -2633,12 +2768,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} - // + // // Of course the example would be 'ludicrous' action code but the - // key point here is that users will certainly be able to come up with + // key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! - // + // function trimActionCode(src, startMarker) { @@ -2715,16 +2850,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var funcRe = /^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/; var arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/; /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. - /// + /// /// Also supports ES6's Arrow Functions: - /// + /// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' - /// + /// /** @public */ @@ -2753,8 +2888,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -2780,12 +2915,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var stringifier = { printFunctionSourceCode: printFunctionSourceCode, printFunctionSourceCodeContainer: printFunctionSourceCodeContainer - }; // - // - // + }; // + // + // function detectIstanbulGlobal() { - var gcv = "__coverage__"; + var gcv = '__coverage__'; var globalvar = new Function('return this')(); var coverage = globalvar[gcv]; return coverage || false; @@ -2972,12 +3107,44 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } return src; - } + } // strip developer machine specific parts off any paths in a given stacktrace (string) + // to ease cross-platform comparison of these stacktraces. + function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: - msg = msg.replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)').replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + msg = msg.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; + } // strip off the line/position info from any stacktrace as a assert.deepEqual() on these + // will otherwise FAIL due to us running this stuff through both regular `node` and + // the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing + // exceptions and stacktraces which point completely somewhere else and this would b0rk + // our test rigs for the jison subpackages. + + + function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + var msg = obj.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + + var keys = Object.keys(obj); + + for (var i in keys) { + var key = keys[i]; + var el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + + return obj; } function trim_array_tail(arr) { @@ -3025,33 +3192,33 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi trim_array_tail(inf); for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + var _err = inf[key]; - if (err) { + if (_err) { path.push('[' + key + ']'); - err = treat_object(err); + _err = treat_object(_err); - if (_typeof(err) === 'object') { - if (err.lexer) { - err.lexer = '[lexer]'; + if (_typeof(_err) === 'object') { + if (_err.lexer) { + _err.lexer = '[lexer]'; } - if (err.parser) { - err.parser = '[parser]'; + if (_err.parser) { + _err.parser = '[parser]'; } - trim_array_tail(err.symbol_stack); - trim_array_tail(err.state_stack); - trim_array_tail(err.location_stack); + trim_array_tail(_err.symbol_stack); + trim_array_tail(_err.state_stack); + trim_array_tail(_err.location_stack); - if (err.value_stack) { + if (_err.value_stack) { path.push('value_stack'); - err.value_stack = treat_value_stack(err.value_stack); + _err.value_stack = treat_value_stack(_err.value_stack); path.pop(); } } - inf[key] = err; + inf[key] = _err; path.pop(); } } @@ -3198,7 +3365,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return e; } // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. - // + // // Internal use in the unit test rigs. @@ -3230,10 +3397,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi dquote: dquote$1, trimErrorForTestReporting: trimErrorForTestReporting, stripErrorStackPaths: stripErrorStackPaths, + cleanStackTrace4Comparison: cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, compileCodeToES5: parse2AST.compileCodeToES5, @@ -3321,7 +3490,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return this; } // Same as typal_mix but also camelCases every object member and 'standardizes' the key set of every input // argument through a caLLback function. - // + // // This is useful for processing options with dashes in their key, e.g. `token-stack` --> tokenStack. @@ -3355,7 +3524,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var nk = mkIdentifier$1(k); var match = k.match(position); var key = k.replace(position, ''); // This anticipates before/after members to be camelcased already, e.g. - // 'afterParse()' for layering 'parse()': + // 'afterParse()' for layering 'parse()': var alt_key = lcase0(key); @@ -3486,7 +3655,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return this._items.length === 0; }, copy: function copy() { - return new Set(this._items); + return new Set$1(this._items); }, toString: function toString() { return this._items.toString(); @@ -3500,11 +3669,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }); 'filter slice map'.split(' ').forEach(function (e, i) { setMixin[e] = function () { - return new Set(Array.prototype[e].apply(this._items, arguments), true); + return new Set$1(Array.prototype[e].apply(this._items, arguments), true); }; //setMixin[e].name = e; }); - var Set = typal.construct(setMixin); // See also: + var Set$1 = typal.construct(setMixin); // 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. @@ -4007,16 +4176,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi switch (yystate) { case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; - this._$ = yylstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4045,8 +4214,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { @@ -4063,17 +4232,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp - 1].errStr)); break; case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { rules: yyvstack[yysp] @@ -4082,17 +4251,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject2(), yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr)); break; case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { rules: [] @@ -4101,9 +4270,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; if (!yy.options) yy.options = {}; @@ -4142,8 +4311,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4193,8 +4362,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { macros: {}, @@ -4212,8 +4381,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` // macros here: @@ -4236,17 +4405,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject6(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4263,17 +4432,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject7(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4290,17 +4459,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject8(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4322,8 +4491,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. @@ -4332,8 +4501,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -4343,8 +4512,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -4354,8 +4523,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4368,17 +4537,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject12(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { type: 'unknown', @@ -4388,8 +4557,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4416,17 +4585,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject15(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 5, yysp); // END of default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4460,9 +4629,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + 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 : ''; @@ -4472,36 +4641,36 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1(_templateObject20(), yylexer.prettyPrintRange(yylstack[yysp - 3], yylstack[yysp - 4]), yyvstack[yysp - 3].errStr)); break; case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject21(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1(_templateObject22(), yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = yyvstack[yysp]; @@ -4512,9 +4681,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; yy.__options_category_description__ = yyvstack[yysp]; @@ -4522,9 +4691,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; yy.__options_category_description__ = yyvstack[yysp]; @@ -4532,9 +4701,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = 'the inclusive lexer start conditions set (%s)'; @@ -4542,9 +4711,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = 'the exclusive lexer start conditions set (%x)'; @@ -4552,9 +4721,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; yy.__options_category_description__ = 'the <...> delimited set of lexer start conditions'; @@ -4562,9 +4731,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; yy.__options_category_description__ = 'the lexer rules definition section'; @@ -4572,9 +4741,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; yy.__options_category_description__ = 'the lexer epilogue section'; @@ -4582,24 +4751,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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].concat(yyvstack[yysp]); break; case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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].concat([yyvstack[yysp]]); break; case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4618,8 +4787,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. @@ -4628,8 +4797,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -4639,8 +4808,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4675,8 +4844,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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(_templateObject27(), yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp]))); this.$ = yyvstack[yysp - 1]; @@ -4687,16 +4856,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (yyvstack[yysp - 1]) { yyvstack[yysp].unshift(yyvstack[yysp - 1]); @@ -4707,8 +4876,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (yyvstack[yysp - 3]) { yyvstack[yysp - 1].forEach(function (d) { @@ -4721,35 +4890,35 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + 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$1(_templateObject28(), yyvstack[yysp - 3].join(','), yylexer.prettyPrintRange(yyparser.mergeLocationInfo(yysp - 3, yysp), yylstack[yysp - 3]), yyvstack[yysp - 1].errStr)); break; case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject29(), yyvstack[yysp - 2].join(','), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject30(), yyvstack[yysp - 2].join(','), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push(yyvstack[yysp]); @@ -4760,8 +4929,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -4775,8 +4944,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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. @@ -4807,8 +4976,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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(_templateObject33(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); @@ -4816,8 +4985,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO: REWRITE this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -4826,8 +4995,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO: REWRITE this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -4836,8 +5005,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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], yyvstack[yysp]]; yyparser.yyError(rmCommonWS$1(_templateObject36(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); @@ -4857,52 +5026,52 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + yyvstack[yysp]; break; case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '\n\n' + yyvstack[yysp] + '\n\n'; break; case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject37(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]))); break; case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject38(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]))); break; case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject39(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]))); break; case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject40(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]))); break; @@ -4912,16 +5081,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -4940,9 +5109,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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) { @@ -4953,8 +5122,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -5034,56 +5203,56 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; break; case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '|'; break; case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; break; case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '|'; break; case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + ')'; break; case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + ')'; break; @@ -5093,49 +5262,49 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject43(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '+'; break; case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '*'; break; case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '?'; break; case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + ')'; break; case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + ')'; break; @@ -5157,65 +5326,65 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '.'; break; case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '^'; break; case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '$'; break; case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); break; case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + yyvstack[yysp]; break; case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject44(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) && yyvstack[yysp].toUpperCase() !== yyvstack[yysp]) { // treat this as part of an XRegExp `\p{...}` Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories @@ -5229,8 +5398,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -5240,8 +5409,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -5249,8 +5418,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -5271,8 +5440,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -5285,24 +5454,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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], true]; break; case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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_VALUE) { @@ -5314,9 +5483,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... yyparser.yyError(rmCommonWS$1(_templateObject49(), $option, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 4]), yyvstack[yysp].errStr)); @@ -5324,9 +5493,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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)'; @@ -5339,8 +5508,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -5366,8 +5535,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -5386,32 +5555,32 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = parseValue(yyvstack[yysp]); break; case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = ''; break; case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -5428,17 +5597,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject54(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$1(_templateObject55(), yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr)); @@ -5447,8 +5616,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -5468,8 +5637,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -5479,8 +5648,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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. @@ -5489,8 +5658,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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]; @@ -5525,9 +5694,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject61(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; @@ -5606,20 +5775,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + var ASSERT = typeof assert !== 'function' ? function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : assert; this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -5652,13 +5815,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + var _dst = {}; + shallow_copy_noclobber(_dst, src); + return _dst; + } } return src; @@ -5675,10 +5839,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (chk.call(src, k)) { dst[k] = src[k]; } - } else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -5847,11 +6009,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (var _i3 = this.__error_recovery_infos.length - 1; _i3 >= 0; _i3--) { + var _el = this.__error_recovery_infos[_i3]; - if (el && typeof el.destroy === 'function') { - el.destroy(); + if (_el && typeof _el.destroy === 'function') { + _el.destroy(); } } @@ -5879,10 +6041,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; + var i1 = first_index | 0; + var i2 = last_index | 0; + var l1 = first_yylloc; + var l2 = last_yylloc; var rv; // rules: // - first/last yylloc entries override first/last indexes @@ -5900,8 +6062,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { - l2 = lstack[i]; + for (var _i4 = i2; _i4 >= i1; _i4--) { + l2 = lstack[_i4]; if (l2) { break; @@ -5914,8 +6076,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 i = (i1 || sp) - 1; i >= 0; i--) { - l1 = lstack[i]; + for (var _i5 = (i1 || sp) - 1; _i5 >= 0; _i5--) { + l1 = lstack[_i5]; if (l1) { break; @@ -5928,30 +6090,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; - } + return null; + } // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + + rv = this.copy_yylloc(l2); return rv; + } // shallow-copy L1, then adjust first col/row 1 column past the end. + + + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; } + + return rv; } if (!l1) { @@ -5960,7 +6122,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... @@ -6010,6 +6172,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -6092,11 +6260,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty - } + { + var i; + + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty + } - rv.base_pointer = i; - rv.info_stack_pointer = i; + rv.base_pointer = i; + rv.info_stack_pointer = i; + } rv.root_failure_pointer = rv.stack_pointer; // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_recovery_infos.push(rv); @@ -6182,9 +6354,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi while (stack_probe >= 0) { // check for error recovery rule in this state - var t = table[state] && table[state][TERROR] || NO_ACTION; + var _t = table[state] && table[state][TERROR] || NO_ACTION; - if (t[0]) { + if (_t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must // prevent the core from running forever, @@ -6347,7 +6519,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: @@ -6403,7 +6575,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errSymbolDescr: errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -6422,7 +6594,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi yyval.$ = recoveringErrorInfo; yyval._$ = undefined; yyrulelen = error_rule_depth; - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + var combineState = NO_ACTION[1]; + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -6479,9 +6652,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); var errorSymbolFromParser = true; for (;;) { @@ -6514,7 +6687,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // and take it from there! if (!action) { - ASSERT(recoveringErrorInfo, "line 1087"); // Prep state variables so that upon breaking out of + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` // statement in the outer "fast parse loop" we redo // the exact same state table lookup as the one above @@ -6549,12 +6722,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -6596,7 +6769,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; // read action for current state and first input @@ -6626,7 +6799,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; @@ -6686,15 +6859,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -6748,7 +6923,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; @@ -6790,25 +6965,25 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + var _tokenName = this.getSymbolName(symbol || EOF); - if (!tokenName) { - tokenName = symbol; + if (!_tokenName) { + _tokenName = symbol; } Jison.parserDebugger.push({ action: 'shift', text: lexer.yytext, - terminal: tokenName, + terminal: _tokenName, terminal_id: symbol }); } ++sp; symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc = this.copy_yylloc(lexer.yylloc); @@ -6816,9 +6991,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... @@ -6826,25 +7001,28 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; + var _prereduceValue = vstack.slice(sp - yyrulelen, sp); - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); - debuggableProductions.push(debuggableProduction); + var _debuggableProductions = []; + + for (var _debugIdx = yyrulelen - 1; _debugIdx >= 0; _debugIdx--) { + var _debuggableProduction = getNonTerminalFromCode(stack[sp - _debugIdx]); + + _debuggableProductions.push(_debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + var _currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + + var _currentNonterminal = getNonTerminalFromCode(_currentNonterminalCode); - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', - nonterminal: currentNonterminal, - nonterminal_id: currentNonterminalCode, - prereduce: prereduceValue, + nonterminal: _currentNonterminal, + nonterminal_id: _currentNonterminalCode, + prereduce: _prereduceValue, result: r, - productions: debuggableProductions, + productions: _debuggableProductions, text: yyval.$ }); } @@ -6866,15 +7044,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var _ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = _ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][_ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -7383,6 +7563,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -7764,9 +7948,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -7776,8 +7960,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -7853,12 +8037,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi */ pastInput: function lexer_pastInput(maxSize, maxLines) { var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) maxSize = Infinity;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substr` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = Infinity; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: @@ -7875,8 +8069,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -7902,20 +8096,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { var next = this.match; var source = this._input || ''; - if (maxSize < 0) maxSize = next.length + source.length;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substring` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = next.length + source.length; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + if (next.length < maxSize * 2 + 2) { next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8 } // now that we have a significantly reduced string to process, transform the newlines @@ -8240,7 +8444,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + var backup; if (this.options.backtrack_lexer) { // save context @@ -8268,9 +8472,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + var match_str = match[0]; + var match_str_len = match_str.length; + var lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -8296,7 +8500,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] + var token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */ ); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -8342,8 +8546,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -8375,65 +8577,73 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; // 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! + { + var rule_ids = spec.rules; + var regexes = spec.__rule_regexes; + var len = spec.__rule_count; + var match; + var index; // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + for (var i = 1; i <= len; i++) { + var tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + var token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + var _token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + if (_token !== false) { + return _token; + } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + var _lineno_msg = 'Lexical error'; if (this.yylloc) { - lineno_msg += ' on line ' + (this.yylineno + 1); + _lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var _p = this.constructLexErrorInfo(_lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var pendingInput = this._input; var activeCondition = this.topState(); var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; - if (token === this.ERROR) { + var _token2 = this.parseError(_p.errStr, _p, this.JisonLexerError) || this.ERROR; + + if (_token2 === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: @@ -8445,7 +8655,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - return token; + return _token2; } }, @@ -8502,24 +8712,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -8546,24 +8756,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -8627,9 +8837,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -8645,9 +8855,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -8667,7 +8877,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -10294,9 +10504,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (x.length >= 1 && i <= 0xFFFF) { c = '0000' + x; return "\\u" + c.substr(c.length - 4); - } else { - return "\\u{" + x + '}'; } + + return "\\u{" + x + '}'; } return String.fromCharCode(i); @@ -10306,7 +10516,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var Pcodes_bitarray_cache = {}; - var Pcodes_bitarray_cache_test_order = []; // Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by + var Pcodes_bitarray_cache_test_order = []; // Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. var EscCode_bitarray_output_refs; // now initialize the EscCodes_... table above: @@ -10408,13 +10618,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi l[k] = cnt; } // now dig out the unique ones: only need one per pcode. - // + // // We ASSUME every \\p{NAME} 'pcode' has at least ONE character - // in it that is ONLY matched by that particular pcode. + // in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode - // won't be tested during optimization. - // + // won't be tested during optimization. + // // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to @@ -10469,11 +10679,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } // order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. - // + // // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more - // optimal minification of the regex set expression. - // + // optimal minification of the regex set expression. + // // This is a guestimate/heuristic only! @@ -10710,7 +10920,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi mark(v1); } // When we have marked all slots, '^' NEGATES the set, hence we flip all slots. - // + // // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. @@ -10787,9 +10997,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi break; } } - } // We're only interested in matches which actually cover some + } // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: @@ -10890,9 +11100,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi break; } } - } // We're only interested in matches which actually cover some + } // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: @@ -10988,10 +11198,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!c1) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"'); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -11008,10 +11217,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!inner) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"'); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -11027,10 +11235,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!c2) { // cope with illegal escape sequences too! return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; + if (c2 !== ']') { return new Error('regex set expression is broken in regex: ' + orig); } @@ -11118,10 +11326,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // inside a regex set: try { - var re; assert__default['default'](s); assert__default['default'](!(s instanceof Error)); - re = new XRegExp__default['default']('[' + s + ']'); + var re = new XRegExp__default['default']('[' + s + ']'); re.test(s[0]); // One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` // so we check for lingering UNESCAPED brackets in here as those cannot be: @@ -11141,7 +11348,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } return l; - } // Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` + } // Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! @@ -11153,13 +11360,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (s1.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s1; - } else { - s1 = '[' + s1 + ']'; - } // Now try to produce a minimum regex from the *inverted* bitarray via negation: + } + + s1 = '[' + s1 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s2 = bitarray2set(bitarr, true, true); if (s2[0] === '^') { @@ -11175,7 +11381,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi s2 = '[' + s2 + ']'; // Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: - // + // // First try to produce a minimum regex from the bitarray directly: var s3 = bitarray2set(bitarr, false, false); // and when the regex set turns out to match a single pcode/escape, then @@ -11184,13 +11390,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (s3.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s3; - } else { - s3 = '[' + s3 + ']'; - } // Now try to produce a minimum regex from the *inverted* bitarray via negation: + } + + s3 = '[' + s3 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s4 = bitarray2set(bitarr, true, false); if (s4[0] === '^') { @@ -11239,7 +11444,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var rmCommonWS$2 = helpers.rmCommonWS; var mkIdentifier$3 = helpers.mkIdentifier; - var code_exec$1 = helpers.exec; + var code_exec = helpers.exec; var version = '0.6.2-220'; // require('./package.json').version; function chkBugger$2(src) { @@ -11320,7 +11525,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var opts = {}; var args = [].concat.apply([], arguments); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(defaultJisonLexOptions); } else { args.shift(); @@ -11616,9 +11821,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function errinfo() { if (name) { return 'macro [[' + name + ']]'; - } else { - return 'regex [[' + orig + ']]'; } + + return 'regex [[' + orig + ']]'; } // propagate deferred exceptions = error reports. @@ -11637,10 +11842,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!c1) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -11658,10 +11862,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!inner) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -11677,10 +11880,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!c2) { // cope with illegal escape sequences too! return new Error(errinfo() + ': regex set expression is broken: "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; + if (c2 !== ']') { return new Error(errinfo() + ': regex set expression is broken: apparently unterminated'); } @@ -12195,7 +12398,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function generateErrorClass() { // --- START lexer error class --- - var prelude = "/**\n * See also:\n * http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n * but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n * with userland code which might access the derived class in a 'classic' way.\n *\n * @public\n * @constructor\n * @nocollapse\n */\nfunction JisonLexerError(msg, hash) {\n \"use strict\";\n\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'JisonLexerError'\n });\n\n if (msg == null) msg = '???';\n\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n var stacktrace;\n if (hash && hash.exception instanceof Error) {\n var ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty('captureStackTrace')) { // V8\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(JisonLexerError.prototype, Error.prototype);\n} else {\n JisonLexerError.prototype = Object.create(Error.prototype);\n}\nJisonLexerError.prototype.constructor = JisonLexerError;\nJisonLexerError.prototype.name = 'JisonLexerError';"; // --- END lexer error class --- + var prelude = "/**\n * See also:\n * http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n * but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n * with userland code which might access the derived class in a 'classic' way.\n *\n * @public\n * @constructor\n * @nocollapse\n */\nfunction JisonLexerError(msg, hash) {\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'JisonLexerError'\n });\n\n if (msg == null) msg = '???';\n\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n let stacktrace;\n if (hash && hash.exception instanceof Error) {\n const ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty('captureStackTrace')) { // V8\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(JisonLexerError.prototype, Error.prototype);\n} else {\n JisonLexerError.prototype = Object.create(Error.prototype);\n}\nJisonLexerError.prototype.constructor = JisonLexerError;\nJisonLexerError.prototype.name = 'JisonLexerError';"; // --- END lexer error class --- return prelude; } @@ -12231,36 +12434,39 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // The compiled code will look something like this: // // ``` - // var lexer; + // let lexer; // bla bla... // ``` // // or // // ``` - // var lexer = { bla... }; + // const lexer = { bla... }; // ``` - var testcode = ['// provide a local version for test purposes:', jisonLexerErrorDefinition, '', generateFakeXRegExpClassSrcCode(), '', source, '', 'return lexer;'].join('\n'); - var lexer = code_exec$1(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { + var testcode = ['// provide a local version for test purposes:', jisonLexerErrorDefinition, '', generateFakeXRegExpClassSrcCode(), '', source, '', rmCommonWS$2(_templateObject80()), 'return lexer;'].join('\n'); + + var _lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { //console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$2(sourcecode); var lexer_f = new Function('', sourcecode); return lexer_f(); - }, opts.options, "lexer"); + }, Object.assign({}, opts.options, { + throwErrorOnCompileFailure: true + }), 'lexer'); - if (!lexer) { + if (!_lexer) { throw new Error('no lexer defined *at all*?!'); } - if (_typeof(lexer.options) !== 'object' || lexer.options == null) { + if (_typeof(_lexer.options) !== 'object' || _lexer.options == null) { throw new Error('your lexer class MUST have an .options member object or it won\'t fly!'); } - if (typeof lexer.setInput !== 'function') { + if (typeof _lexer.setInput !== 'function') { throw new Error('your lexer class MUST have a .setInput function member or it won\'t fly!'); } - if (lexer.EOF !== 1 && lexer.ERROR !== 2) { + if (_lexer.EOF !== 1 && _lexer.ERROR !== 2) { throw new Error('your lexer class MUST have these constants defined: lexer.EOF = 1 and lexer.ERROR = 2 or it won\'t fly!'); } // When we do NOT crash, we found/killed the problem area just before this call! @@ -12281,23 +12487,23 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var post = opts.options.post_lex; // since JSON cannot encode functions, we'll have to do it manually now: if (typeof pre === 'function') { - lexer.options.pre_lex = pre; + _lexer.options.pre_lex = pre; } if (typeof post === 'function') { - lexer.options.post_lex = post; + _lexer.options.post_lex = post; } } if (opts.options.showSource) { if (typeof opts.options.showSource === 'function') { - opts.options.showSource(lexer, source, opts, RegExpLexer); + opts.options.showSource(_lexer, source, opts, RegExpLexer); } else { - console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n"); + console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n', source, '\n----------------------------------------\n'); } } - return lexer; + return _lexer; } catch (ex) { // if (src_exception) { // src_exception.message += '\n (' + description + ': ' + ex.message + ')'; @@ -12336,62 +12542,66 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi assert__default['default'](Array.isArray(opts.rules)); return opts.rules.length > 0 ? 'One or more of your lexer state names are possibly botched?' : 'Your custom lexer is somehow botched.'; }, ex, null)) { - var rulesSpecSize; - - if (!test_me(function () { - // store the parsed rule set size so we can use that info in case - // this attempt also fails: - assert__default['default'](Array.isArray(opts.rules)); - rulesSpecSize = opts.rules.length; // opts.conditions = []; - - opts.rules = []; - opts.showSource = false; - opts.__in_rules_failure_analysis_mode__ = true; - }, 'One or more of your lexer rules are possibly botched?', ex, null)) { - // kill each rule action block, one at a time and test again after each 'edit': - var rv = false; - - for (var i = 0, len = rulesSpecSize; i < len; i++) { - var lastEditedRuleSpec; - rv = test_me(function () { - assert__default['default'](Array.isArray(opts.rules)); - assert__default['default'](opts.rules.length === rulesSpecSize); // opts.conditions = []; - // opts.rules = []; - // opts.__in_rules_failure_analysis_mode__ = true; - // nuke all rules' actions up to and including rule numero `i`: - - for (var j = 0; j <= i; j++) { - // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; - // now we want to edit the *action* part: - var rule = opts.rules[j]; - assert__default['default'](Array.isArray(rule)); - assert__default['default'](rule.length === 2 || rule.length === 3); - rule.pop(); - rule.push('{ /* nada */ }'); - lastEditedRuleSpec = rule; - } - }, function () { - return 'Your lexer rule "' + lastEditedRuleSpec[0] + '" action code block is botched?'; - }, ex, null); + var i, len; + var lastEditedRuleSpec; + + (function () { + var rulesSpecSize; + + if (!test_me(function () { + // store the parsed rule set size so we can use that info in case + // this attempt also fails: + assert__default['default'](Array.isArray(opts.rules)); + rulesSpecSize = opts.rules.length; // opts.conditions = []; + + opts.rules = []; + opts.showSource = false; + opts.__in_rules_failure_analysis_mode__ = true; + }, 'One or more of your lexer rules are possibly botched?', ex, null)) { + // kill each rule action block, one at a time and test again after each 'edit': + var rv = false; + + for (i = 0, len = rulesSpecSize; i < len; i++) { + rv = test_me(function () { + assert__default['default'](Array.isArray(opts.rules)); + assert__default['default'](opts.rules.length === rulesSpecSize); // opts.conditions = []; + // opts.rules = []; + // opts.__in_rules_failure_analysis_mode__ = true; + // nuke all rules' actions up to and including rule numero `i`: + + for (var j = 0; j <= i; j++) { + // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; + // now we want to edit the *action* part: + var rule = opts.rules[j]; + assert__default['default'](Array.isArray(rule)); + assert__default['default'](rule.length === 2 || rule.length === 3); + rule.pop(); + rule.push('{ /* nada */ }'); + lastEditedRuleSpec = rule; + } + }, function () { + return 'Your lexer rule "' + lastEditedRuleSpec[0] + '" action code block is botched?'; + }, ex, null); - if (rv) { - break; + if (rv) { + break; + } } - } - if (!rv) { - test_me(function () { - opts.conditions = []; - opts.rules = []; - opts.performAction = 'null'; // opts.options = {}; - // opts.caseHelperInclude = '{}'; - - opts.showSource = false; - opts.__in_rules_failure_analysis_mode__ = true; - dump = false; - }, 'One or more of your lexer rule action code block(s) are possibly botched?', ex, null); + if (!rv) { + test_me(function () { + opts.conditions = []; + opts.rules = []; + opts.performAction = 'null'; // opts.options = {}; + // opts.caseHelperInclude = '{}'; + + opts.showSource = false; + opts.__in_rules_failure_analysis_mode__ = true; + dump = false; + }, 'One or more of your lexer rule action code block(s) are possibly botched?', ex, null); + } } - } + })(); } } @@ -12464,11 +12674,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function getRegExpLexerPrototype() { // --- START lexer kernel --- - return "{\n EOF: 1,\n ERROR: 2,\n\n // JisonLexerError: JisonLexerError, /// <-- injected by the code generator\n\n // options: {}, /// <-- injected by the code generator\n\n // yy: ..., /// <-- injected by setInput()\n\n __currentRuleSet__: null, /// INTERNAL USE ONLY: internal rule set cache for the current lexer state\n\n __error_infos: [], /// INTERNAL USE ONLY: the set of lexErrorInfo objects created since the last cleanup\n\n __decompressed: false, /// INTERNAL USE ONLY: mark whether the lexer instance has been 'unfolded' completely and is now ready for use\n\n done: false, /// INTERNAL USE ONLY\n _backtrack: false, /// INTERNAL USE ONLY\n _input: '', /// INTERNAL USE ONLY\n _more: false, /// INTERNAL USE ONLY\n _signaled_error_token: false, /// INTERNAL USE ONLY\n _clear_state: 0, /// INTERNAL USE ONLY; 0: clear to do, 1: clear done for lex()/next(); -1: clear done for inut()/unput()/...\n\n conditionStack: [], /// INTERNAL USE ONLY; managed via `pushState()`, `popState()`, `topState()` and `stateStackSize()`\n\n match: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction. `match` is identical to `yytext` except that this one still contains the matched input string after `lexer.performAction()` has been invoked, where userland code MAY have changed/replaced the `yytext` value entirely!\n matched: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks entire input which has been matched so far\n matches: false, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks RE match result for last (successful) match attempt\n yytext: '', /// ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction; this value is transferred to the parser as the 'token value' when the parser consumes the lexer token produced through a call to the `lex()` API.\n offset: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks the 'cursor position' in the input string, i.e. the number of characters matched so far. (**WARNING:** this value MAY be negative if you `unput()` more text than you have already lexed. This type of behaviour is generally observed for one kind of 'lexer/parser hack' where custom token-illiciting characters are pushed in front of the input stream to help simulate multiple-START-points in the parser. When this happens, `base_position` will be adjusted to help track the original input's starting point in the `_input` buffer.)\n base_position: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: index to the original starting point of the input; always ZERO(0) unless `unput()` has pushed content before the input: see the `offset` **WARNING** just above.\n yyleng: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: length of matched input for the token under construction (`yytext`)\n yylineno: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: 'line number' at which the token under construction is located\n yylloc: null, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks location info (lines + columns) for the token under construction\n CRLF_Re: /\\r\\n?|\\n/, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: regex used to split lines while tracking the lexer cursor position.\n\n /**\n * INTERNAL USE: construct a suitable error info hash object instance for `parseError`.\n *\n * @public\n * @this {RegExpLexer}\n */\n constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) {\n \"use strict\";\n \n msg = '' + msg;\n\n // heuristic to determine if the error message already contains a (partial) source code dump\n // as produced by either `showPosition()` or `prettyPrintRange()`:\n if (show_input_position == undefined) {\n show_input_position = !(msg.indexOf('\\n') > 0 && msg.indexOf('^') > 0);\n }\n if (this.yylloc && show_input_position) {\n if (typeof this.prettyPrintRange === 'function') {\n var pretty_src = this.prettyPrintRange(this.yylloc);\n\n if (!/\\n\\s*$/.test(msg)) {\n msg += '\\n';\n }\n msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc);\n } else if (typeof this.showPosition === 'function') {\n var pos_str = this.showPosition();\n if (pos_str) {\n if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') {\n msg += '\\n' + pos_str;\n } else {\n msg += pos_str;\n }\n }\n }\n }\n /** @constructor */\n var pei = {\n errStr: msg,\n recoverable: !!recoverable,\n text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'...\n token: null,\n line: this.yylineno,\n loc: this.yylloc,\n yy: this.yy, \n lexer: this,\n\n /**\n * and make sure the error info doesn't stay due to potential\n * ref cycle via userland code manipulations.\n * These would otherwise all be memory leak opportunities!\n *\n * Note that only array and object references are nuked as those\n * constitute the set of elements which can produce a cyclic ref.\n * The rest of the members is kept intact as they are harmless.\n *\n * @public\n * @this {LexErrorInfo}\n */\n destroy: function destructLexErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // ...\n \"use strict\";\n var rec = !!this.recoverable;\n for (var key in this) {\n if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n },\n\n /**\n * handler which is invoked when a lexer error occurs.\n *\n * @public\n * @this {RegExpLexer}\n */\n parseError: function lexer_parseError(str, hash, ExceptionClass) {\n \"use strict\";\n\n if (!ExceptionClass) {\n ExceptionClass = this.JisonLexerError;\n }\n if (this.yy) {\n if (this.yy.parser && typeof this.yy.parser.parseError === 'function') {\n return this.yy.parser.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n } else if (typeof this.yy.parseError === 'function') {\n return this.yy.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n }\n }\n throw new ExceptionClass(str, hash);\n },\n\n /**\n * method which implements `yyerror(str, ...args)` functionality for use inside lexer actions.\n *\n * @public\n * @this {RegExpLexer}\n */\n yyerror: function yyError(str /*, ...args */) {\n \"use strict\";\n\n var lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable);\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n var args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n p.extra_error_attributes = args;\n }\n\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n },\n\n /**\n * final cleanup function for when we have completed lexing the input;\n * make it an API so that external code can use this one once userland\n * code has decided it's time to destroy any lingering lexer error\n * hash object instances and the like: this function helps to clean\n * up these constructs, which *may* carry cyclic references which would\n * otherwise prevent the instances from being properly and timely\n * garbage-collected, i.e. this function helps prevent memory leaks!\n *\n * @public\n * @this {RegExpLexer}\n */\n cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) {\n \"use strict\";\n\n // prevent lingering circular references from causing memory leaks:\n this.setInput('', {});\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (var i = this.__error_infos.length - 1; i >= 0; i--) {\n var el = this.__error_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n }\n\n return this;\n },\n\n /**\n * clear the lexer token context; intended for internal use only\n *\n * @public\n * @this {RegExpLexer}\n */\n clear: function lexer_clear() {\n \"use strict\";\n\n this.yytext = '';\n this.yyleng = 0;\n this.match = '';\n // - DO NOT reset `this.matched`\n this.matches = false;\n\n this._more = false;\n this._backtrack = false;\n\n var col = this.yylloc.last_column;\n this.yylloc = {\n first_line: this.yylineno + 1,\n first_column: col,\n last_line: this.yylineno + 1,\n last_column: col,\n\n range: [this.offset, this.offset]\n };\n },\n\n /**\n * resets the lexer, sets new input\n *\n * @public\n * @this {RegExpLexer}\n */\n setInput: function lexer_setInput(input, yy) {\n \"use strict\";\n\n this.yy = yy || this.yy || {};\n\n // also check if we've fully initialized the lexer instance,\n // including expansion work to be done to go from a loaded\n // lexer to a usable lexer:\n if (!this.__decompressed) {\n // step 1: decompress the regex list:\n var rules = this.rules;\n for (var i = 0, len = rules.length; i < len; i++) {\n var rule_re = rules[i];\n\n // compression: is the RE an xref to another RE slot in the rules[] table?\n if (typeof rule_re === 'number') {\n rules[i] = rules[rule_re];\n }\n }\n\n // step 2: unfold the conditions[] set to make these ready for use:\n var conditions = this.conditions;\n for (var k in conditions) {\n var spec = conditions[k];\n\n var rule_ids = spec.rules;\n\n var len = rule_ids.length;\n var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple!\n var rule_new_ids = new Array(len + 1);\n\n for (var i = 0; i < len; i++) {\n var idx = rule_ids[i];\n var rule_re = rules[idx];\n rule_regexes[i + 1] = rule_re;\n rule_new_ids[i + 1] = idx;\n }\n\n spec.rules = rule_new_ids;\n spec.__rule_regexes = rule_regexes;\n spec.__rule_count = len;\n }\n\n this.__decompressed = true;\n }\n\n if (input && typeof input !== 'string') {\n input = '' + input;\n }\n this._input = input || '';\n this._clear_state = -1;\n this._signaled_error_token = false;\n this.done = false;\n this.yylineno = 0;\n this.matched = '';\n this.conditionStack = ['INITIAL'];\n this.__currentRuleSet__ = null;\n this.yylloc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [0, 0]\n };\n this.offset = 0;\n this.base_position = 0;\n // apply these bits of `this.clear()` as well:\n this.yytext = '';\n this.yyleng = 0;\n this.match = '';\n this.matches = false;\n\n this._more = false;\n this._backtrack = false;\n\n return this;\n },\n\n /**\n * edit the remaining input via user-specified callback.\n * This can be used to forward-adjust the input-to-parse,\n * e.g. inserting macro expansions and alike in the\n * input which has yet to be lexed.\n * The behaviour of this API contrasts the `unput()` et al\n * APIs as those act on the *consumed* input, while this\n * one allows one to manipulate the future, without impacting\n * the current `yyloc` cursor location or any history.\n *\n * Use this API to help implement C-preprocessor-like\n * `#include` statements, etc.\n *\n * The provided callback must be synchronous and is\n * expected to return the edited input (string).\n *\n * The `cpsArg` argument value is passed to the callback\n * as-is.\n *\n * `callback` interface:\n * `function callback(input, cpsArg)`\n *\n * - `input` will carry the remaining-input-to-lex string\n * from the lexer.\n * - `cpsArg` is `cpsArg` passed into this API.\n *\n * The `this` reference for the callback will be set to\n * reference this lexer instance so that userland code\n * in the callback can easily and quickly access any lexer\n * API.\n *\n * When the callback returns a non-string-type falsey value,\n * we assume the callback did not edit the input and we\n * will using the input as-is.\n *\n * When the callback returns a non-string-type value, it\n * is converted to a string for lexing via the `\"\" + retval`\n * operation. (See also why: http://2ality.com/2012/03/converting-to-string.html\n * -- that way any returned object's `toValue()` and `toString()`\n * methods will be invoked in a proper/desirable order.)\n *\n * @public\n * @this {RegExpLexer}\n */\n editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) {\n \"use strict\";\n\n var rv = callback.call(this, this._input, cpsArg);\n if (typeof rv !== 'string') {\n if (rv) {\n this._input = '' + rv;\n }\n // else: keep `this._input` as is.\n } else {\n this._input = rv;\n }\n return this;\n },\n\n /**\n * consumes and returns one char from the input\n *\n * @public\n * @this {RegExpLexer}\n */\n input: function lexer_input() {\n \"use strict\";\n\n if (!this._input) {\n //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*)\n return null;\n }\n if (!this._clear_state && !this._more) {\n this._clear_state = -1;\n this.clear();\n }\n var ch = this._input[0];\n this.yytext += ch;\n this.yyleng++;\n this.offset++;\n this.match += ch;\n this.matched += ch;\n // Count the linenumber up when we hit the LF (or a stand-alone CR).\n // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo\n // and we advance immediately past the LF as well, returning both together as if\n // it was all a single 'character' only.\n var slice_len = 1;\n var lines = false;\n if (ch === '\\n') {\n lines = true;\n } else if (ch === '\\r') {\n lines = true;\n var ch2 = this._input[1];\n if (ch2 === '\\n') {\n slice_len++;\n ch += ch2;\n this.yytext += ch2;\n this.yyleng++;\n this.offset++;\n this.match += ch2;\n this.matched += ch2;\n this.yylloc.range[1]++;\n }\n }\n if (lines) {\n this.yylineno++;\n this.yylloc.last_line++;\n this.yylloc.last_column = 0;\n } else {\n this.yylloc.last_column++;\n }\n this.yylloc.range[1]++;\n\n this._input = this._input.slice(slice_len);\n return ch;\n },\n\n /**\n * unshifts one char (or an entire string) into the input\n *\n * @public\n * @this {RegExpLexer}\n */\n unput: function lexer_unput(ch) {\n \"use strict\";\n\n var len = ch.length;\n var lines = ch.split(this.CRLF_Re);\n\n if (!this._clear_state && !this._more) {\n this._clear_state = -1;\n this.clear();\n }\n\n this._input = ch + this._input;\n this.yytext = this.yytext.substr(0, this.yytext.length - len);\n this.yyleng = this.yytext.length;\n this.offset -= len;\n // **WARNING:**\n // The `offset` value MAY be negative if you `unput()` more text than you have already lexed.\n // This type of behaviour is generally observed for one kind of 'lexer/parser hack'\n // where custom token-illiciting characters are pushed in front of the input stream to help\n // simulate multiple-START-points in the parser.\n // When this happens, `base_position` will be adjusted to help track the original input's\n // starting point in the `_input` buffer.\n if (-this.offset > this.base_position) {\n this.base_position = -this.offset;\n }\n this.match = this.match.substr(0, this.match.length - len);\n this.matched = this.matched.substr(0, this.matched.length - len);\n\n if (lines.length > 1) {\n this.yylineno -= lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n\n // Get last entirely matched line into the `pre_lines[]` array's\n // last index slot; we don't mind when other previously\n // matched lines end up in the array too.\n var pre = this.match;\n var pre_lines = pre.split(this.CRLF_Re);\n if (pre_lines.length === 1) {\n pre = this.matched;\n pre_lines = pre.split(this.CRLF_Re);\n }\n this.yylloc.last_column = pre_lines[pre_lines.length - 1].length;\n } else {\n this.yylloc.last_column -= len;\n }\n\n this.yylloc.range[1] = this.yylloc.range[0] + this.yyleng;\n\n this.done = false;\n return this;\n },\n\n /**\n * return the upcoming input *which has not been lexed yet*.\n * This can, for example, be used for custom look-ahead inspection code \n * in your lexer.\n * \n * The entire pending input string is returned.\n *\n * > ### NOTE ###\n * >\n * > When augmenting error reports and alike, you might want to\n * > look at the `upcomingInput()` API instead, which offers more\n * > features for limited input extraction and which includes the\n * > part of the input which has been lexed by the last token a.k.a.\n * > the *currently lexed* input.\n * > \n * \n * @public\n * @this {RegExpLexer}\n */\n lookAhead: function lexer_lookAhead() {\n \"use strict\";\n\n return this._input || '';\n },\n\n /**\n * cache matched text and append it on next action\n *\n * @public\n * @this {RegExpLexer}\n */\n more: function lexer_more() {\n \"use strict\";\n\n this._more = true;\n return this;\n },\n\n /**\n * signal the lexer that this rule fails to match the input, so the\n * next matching rule (regex) should be tested instead.\n *\n * @public\n * @this {RegExpLexer}\n */\n reject: function lexer_reject() {\n \"use strict\";\n\n if (this.options.backtrack_lexer) {\n this._backtrack = true;\n } else {\n // when the `parseError()` call returns, we MUST ensure that the error is registered.\n // We accomplish this by signaling an 'error' token to be produced for the current\n // `.lex()` run.\n var lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false);\n this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n return this;\n },\n\n /**\n * retain first n characters of the match\n *\n * @public\n * @this {RegExpLexer}\n */\n less: function lexer_less(n) {\n \"use strict\";\n\n return this.unput(this.match.slice(n));\n },\n\n /**\n * return (part of the) already matched input, i.e. for error\n * messages.\n *\n * Limit the returned string length to `maxSize` (default: 20).\n *\n * Limit the returned string to the `maxLines` number of lines of\n * input (default: 1).\n *\n * A negative `maxSize` limit value equals *unlimited*, i.e.\n * produce the entire input that has already been lexed.\n *\n * A negative `maxLines` limit value equals *unlimited*, i.e. limit the result\n * to the `maxSize` specified number of characters *only*.\n *\n * @public\n * @this {RegExpLexer}\n */\n pastInput: function lexer_pastInput(maxSize, maxLines) {\n \"use strict\";\n\n var past = this.matched.substring(0, this.matched.length - this.match.length);\n if (maxSize < 0)\n maxSize = Infinity;\n else if (!maxSize)\n maxSize = 20;\n if (maxLines < 0)\n maxLines = Infinity; // can't ever have more input lines than this!\n else if (!maxLines)\n maxLines = 1;\n // `substr` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we've transformed and limited the newLines in here:\n past = past.substr(-maxSize * 2 - 2);\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n var a = past.split(this.CRLF_Re);\n a = a.slice(-maxLines);\n past = a.join('\\n');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis prefix...\n if (past.length > maxSize) {\n past = '...' + past.substr(-maxSize);\n }\n return past;\n },\n\n /**\n * return (part of the) upcoming input *including* the input \n * matched by the last token (see also the NOTE below). \n * This can be used to augment error messages, for example.\n *\n * Limit the returned string length to `maxSize` (default: 20).\n *\n * Limit the returned string to the `maxLines` number of lines of input (default: 1).\n *\n * A negative `maxSize` limit value equals *unlimited*, i.e.\n * produce the entire input that is yet to be lexed.\n *\n * A negative `maxLines` limit value equals *unlimited*, i.e. limit the result\n * to the `maxSize` specified number of characters *only*.\n *\n * > ### NOTE ###\n * >\n * > *\"upcoming input\"* is defined as the whole of the both\n * > the *currently lexed* input, together with any remaining input\n * > following that. *\"currently lexed\"* input is the input\n * > already recognized by the lexer but not yet returned with\n * > the lexer token. This happens when you are invoking this API\n * > from inside any lexer rule action code block.\n * >\n * > When you want access to the 'upcoming input' in that you want access\n * > to the input *which has not been lexed yet* for look-ahead\n * > inspection or likewise purposes, please consider using the\n * > `lookAhead()` API instead.\n * > \n * \n * @public\n * @this {RegExpLexer}\n */\n upcomingInput: function lexer_upcomingInput(maxSize, maxLines) {\n \"use strict\";\n\n var next = this.match;\n var source = this._input || '';\n if (maxSize < 0)\n maxSize = next.length + source.length;\n else if (!maxSize)\n maxSize = 20;\n if (maxLines < 0)\n maxLines = maxSize; // can't ever have more input lines than this!\n else if (!maxLines)\n maxLines = 1;\n // `substring` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we've transformed and limited the newLines in here:\n if (next.length < maxSize * 2 + 2) {\n next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8\n }\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines.\n a = a.slice(0, maxLines);\n next = a.join('\\n');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis postfix...\n if (next.length > maxSize) {\n next = next.substring(0, maxSize) + '...';\n }\n return next;\n },\n\n /**\n * return a string which displays the character position where the\n * lexing error occurred, i.e. for error messages\n *\n * @public\n * @this {RegExpLexer}\n */\n showPosition: function lexer_showPosition(maxPrefix, maxPostfix) {\n \"use strict\";\n\n var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' ');\n var c = new Array(pre.length + 1).join('-');\n return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^';\n },\n\n /**\n * return an YYLLOC info object derived off the given context (actual, preceding, following, current).\n * Use this method when the given `actual` location is not guaranteed to exist (i.e. when\n * it MAY be NULL) and you MUST have a valid location info object anyway:\n * then we take the given context of the `preceding` and `following` locations, IFF those are available,\n * and reconstruct the `actual` location info from those.\n * If this fails, the heuristic is to take the `current` location, IFF available.\n * If this fails as well, we assume the sought location is at/around the current lexer position\n * and then produce that one as a response. DO NOTE that these heuristic/derived location info\n * values MAY be inaccurate!\n *\n * NOTE: `deriveLocationInfo()` ALWAYS produces a location info object *copy* of `actual`, not just\n * a *reference* hence all input location objects can be assumed to be 'constant' (function has no side-effects).\n *\n * @public\n * @this {RegExpLexer}\n */\n deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) {\n \"use strict\";\n\n var loc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [0, 0]\n };\n if (actual) {\n loc.first_line = actual.first_line | 0;\n loc.last_line = actual.last_line | 0;\n loc.first_column = actual.first_column | 0;\n loc.last_column = actual.last_column | 0;\n\n if (actual.range) {\n loc.range[0] = actual.range[0] | 0;\n loc.range[1] = actual.range[1] | 0;\n }\n }\n if (loc.first_line <= 0 || loc.last_line < loc.first_line) {\n // plan B: heuristic using preceding and following:\n if (loc.first_line <= 0 && preceding) {\n loc.first_line = preceding.last_line | 0;\n loc.first_column = preceding.last_column | 0;\n\n if (preceding.range) {\n loc.range[0] = actual.range[1] | 0;\n }\n }\n\n if ((loc.last_line <= 0 || loc.last_line < loc.first_line) && following) {\n loc.last_line = following.first_line | 0;\n loc.last_column = following.first_column | 0;\n\n if (following.range) {\n loc.range[1] = actual.range[0] | 0;\n }\n }\n\n // plan C?: see if the 'current' location is useful/sane too:\n if (loc.first_line <= 0 && current && (loc.last_line <= 0 || current.last_line <= loc.last_line)) {\n loc.first_line = current.first_line | 0;\n loc.first_column = current.first_column | 0;\n\n if (current.range) {\n loc.range[0] = current.range[0] | 0;\n }\n }\n\n if (loc.last_line <= 0 && current && (loc.first_line <= 0 || current.first_line >= loc.first_line)) {\n loc.last_line = current.last_line | 0;\n loc.last_column = current.last_column | 0;\n\n if (current.range) {\n loc.range[1] = current.range[1] | 0;\n }\n }\n }\n // sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter\n // or plan D heuristics to produce a 'sensible' last_line value:\n if (loc.last_line <= 0) {\n if (loc.first_line <= 0) {\n loc.first_line = this.yylloc.first_line;\n loc.last_line = this.yylloc.last_line;\n loc.first_column = this.yylloc.first_column;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[0] = this.yylloc.range[0];\n loc.range[1] = this.yylloc.range[1];\n } else {\n loc.last_line = this.yylloc.last_line;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[1] = this.yylloc.range[1];\n }\n }\n if (loc.first_line <= 0) {\n loc.first_line = loc.last_line;\n loc.first_column = 0; // loc.last_column;\n\n loc.range[1] = loc.range[0];\n }\n if (loc.first_column < 0) {\n loc.first_column = 0;\n }\n if (loc.last_column < 0) {\n loc.last_column = (loc.first_column > 0 ? loc.first_column : 80);\n }\n return loc;\n },\n\n /**\n * return a string which displays the lines & columns of input which are referenced\n * by the given location info range, plus a few lines of context.\n *\n * This function pretty-prints the indicated section of the input, with line numbers\n * and everything!\n *\n * This function is very useful to provide highly readable error reports, while\n * the location range may be specified in various flexible ways:\n *\n * - `loc` is the location info object which references the area which should be\n * displayed and 'marked up': these lines & columns of text are marked up by `^`\n * characters below each character in the entire input range.\n *\n * - `context_loc` is the *optional* location info object which instructs this\n * pretty-printer how much *leading* context should be displayed alongside\n * the area referenced by `loc`. This can help provide context for the displayed\n * error, etc.\n *\n * When this location info is not provided, a default context of 3 lines is\n * used.\n *\n * - `context_loc2` is another *optional* location info object, which serves\n * a similar purpose to `context_loc`: it specifies the amount of *trailing*\n * context lines to display in the pretty-print output.\n *\n * When this location info is not provided, a default context of 1 line only is\n * used.\n *\n * Special Notes:\n *\n * - when the `loc`-indicated range is very large (about 5 lines or more), then\n * only the first and last few lines of this block are printed while a\n * `...continued...` message will be printed between them.\n *\n * This serves the purpose of not printing a huge amount of text when the `loc`\n * range happens to be huge: this way a manageable & readable output results\n * for arbitrary large ranges.\n *\n * - this function can display lines of input which whave not yet been lexed.\n * `prettyPrintRange()` can access the entire input!\n *\n * @public\n * @this {RegExpLexer}\n */\n prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) {\n \"use strict\";\n\n loc = this.deriveLocationInfo(loc, context_loc, context_loc2);\n\n const CONTEXT = 3;\n const CONTEXT_TAIL = 1;\n const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2;\n var input = this.matched + (this._input || '');\n var lines = input.split('\\n');\n var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT));\n var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL));\n var lineno_display_width = (1 + Math.log10(l1 | 1) | 0);\n var ws_prefix = new Array(lineno_display_width).join(' ');\n var nonempty_line_indexes = [[], [], []];\n var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) {\n \"use strict\";\n\n var lno = index + l0;\n var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width);\n var rv = lno_pfx + ': ' + line;\n var errpfx = (new Array(lineno_display_width + 1)).join('^');\n var offset = 2 + 1;\n var len = 0;\n\n if (lno === loc.first_line) {\n offset += loc.first_column;\n\n len = Math.max(\n 2,\n ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1\n );\n } else if (lno === loc.last_line) {\n len = Math.max(2, loc.last_column + 1);\n } else if (lno > loc.first_line && lno < loc.last_line) {\n len = Math.max(2, line.length + 1);\n }\n\n var nli;\n if (len) {\n var lead = new Array(offset).join('.');\n var mark = new Array(len).join('^');\n rv += '\\n' + errpfx + lead + mark;\n\n nli = 1;\n } else if (lno < loc.first_line) {\n nli = 0;\n } else if (lno > loc.last_line) {\n nli = 2;\n }\n\n if (line.trim().length > 0) {\n nonempty_line_indexes[nli].push(index);\n }\n\n rv = rv.replace(/\\t/g, ' ');\n return rv;\n });\n\n // now make sure we don't print an overly large amount of lead/error/tail area: limit it\n // to the top and bottom line count:\n for (var i = 0; i <= 2; i++) {\n var line_arr = nonempty_line_indexes[i];\n if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) {\n var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1;\n var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1;\n\n var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)';\n if (i === 1) {\n intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)';\n }\n rv.splice(clip_start, clip_end - clip_start + 1, intermediate_line);\n }\n }\n\n return rv.join('\\n');\n },\n\n /**\n * helper function, used to produce a human readable description as a string, given\n * the input `yylloc` location object.\n *\n * Set `display_range_too` to TRUE to include the string character index position(s)\n * in the description if the `yylloc.range` is available.\n *\n * @public\n * @this {RegExpLexer}\n */\n describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) {\n \"use strict\";\n\n var l1 = yylloc.first_line;\n var l2 = yylloc.last_line;\n var c1 = yylloc.first_column;\n var c2 = yylloc.last_column;\n var dl = l2 - l1;\n var dc = c2 - c1;\n var rv;\n if (dl === 0) {\n rv = 'line ' + l1 + ', ';\n if (dc <= 1) {\n rv += 'column ' + c1;\n } else {\n rv += 'columns ' + c1 + ' .. ' + c2;\n }\n } else {\n rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')';\n }\n if (yylloc.range && display_range_too) {\n var r1 = yylloc.range[0];\n var r2 = yylloc.range[1] - 1;\n if (r2 <= r1) {\n rv += ' {String Offset: ' + r1 + '}';\n } else {\n rv += ' {String Offset range: ' + r1 + ' .. ' + r2 + '}';\n }\n }\n return rv;\n },\n\n /**\n * test the lexed token: return FALSE when not a match, otherwise return token.\n *\n * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]`\n * contains the actually matched text string.\n *\n * Also move the input cursor forward and update the match collectors:\n *\n * - `yytext`\n * - `yyleng`\n * - `match`\n * - `matches`\n * - `yylloc`\n * - `offset`\n *\n * @public\n * @this {RegExpLexer}\n */\n test_match: function lexer_test_match(match, indexed_rule) {\n \"use strict\";\n\n var token,\n lines,\n backup,\n match_str,\n match_str_len;\n\n if (this.options.backtrack_lexer) {\n // save context\n backup = {\n yylineno: this.yylineno,\n yylloc: {\n first_line: this.yylloc.first_line,\n last_line: this.yylloc.last_line,\n first_column: this.yylloc.first_column,\n last_column: this.yylloc.last_column,\n\n range: this.yylloc.range.slice()\n },\n yytext: this.yytext,\n match: this.match,\n matches: this.matches,\n matched: this.matched,\n yyleng: this.yyleng,\n offset: this.offset,\n _more: this._more,\n _input: this._input,\n //_signaled_error_token: this._signaled_error_token,\n yy: this.yy,\n conditionStack: this.conditionStack.slice(),\n done: this.done\n };\n }\n\n match_str = match[0];\n match_str_len = match_str.length;\n\n lines = match_str.split(this.CRLF_Re);\n if (lines.length > 1) {\n this.yylineno += lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n this.yylloc.last_column = lines[lines.length - 1].length;\n } else {\n this.yylloc.last_column += match_str_len;\n }\n\n this.yytext += match_str;\n this.match += match_str;\n this.matched += match_str;\n this.matches = match;\n this.yyleng = this.yytext.length;\n this.yylloc.range[1] += match_str_len;\n\n // previous lex rules MAY have invoked the `more()` API rather than producing a token:\n // those rules will already have moved this `offset` forward matching their match lengths,\n // hence we must only add our own match length now:\n this.offset += match_str_len;\n this._more = false;\n this._backtrack = false;\n this._input = this._input.slice(match_str_len);\n\n // calling this method:\n //\n // function lexer__performAction(yy, yyrulenumber, YY_START) {...}\n token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */);\n // otherwise, when the action codes are all simple return token statements:\n //token = this.simpleCaseActionClusters[indexed_rule];\n\n if (this.done && this._input) {\n this.done = false;\n }\n if (token) {\n return token;\n } else if (this._backtrack) {\n // recover context\n for (var k in backup) {\n this[k] = backup[k];\n }\n this.__currentRuleSet__ = null;\n return false; // rule action called reject() implying the next rule should be tested instead.\n } else if (this._signaled_error_token) {\n // produce one 'error' token as `.parseError()` in `reject()`\n // did not guarantee a failure signal by throwing an exception!\n token = this._signaled_error_token;\n this._signaled_error_token = false;\n return token;\n }\n return false;\n },\n\n /**\n * return next match in input\n *\n * @public\n * @this {RegExpLexer}\n */\n next: function lexer_next() {\n \"use strict\";\n\n if (this.done) {\n this.clear();\n return this.EOF;\n }\n if (!this._input) {\n this.done = true;\n }\n\n var token,\n match,\n tempMatch,\n index;\n if (!this._more) {\n if (!this._clear_state) {\n this._clear_state = 1;\n }\n this.clear();\n }\n var spec = this.__currentRuleSet__;\n if (!spec) {\n // Update the ruleset cache as we apparently encountered a state change or just started lexing.\n // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will\n // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps\n // speed up those activities a tiny bit.\n spec = this.__currentRuleSet__ = this._currentRules();\n // Check whether a *sane* condition has been pushed before: this makes the lexer robust against\n // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19\n if (!spec || !spec.rules) {\n var lineno_msg = '';\n if (this.yylloc) {\n lineno_msg = ' on line ' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name \"' + this.topState() + '\"; this is a fatal error and should be reported to the application programmer team!', false);\n // produce one 'error' token until this situation has been resolved, most probably by parse termination!\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n }\n\n var rule_ids = spec.rules;\n var regexes = spec.__rule_regexes;\n var len = spec.__rule_count;\n\n // Note: the arrays are 1-based, while `len` itself is a valid index,\n // hence the non-standard less-or-equal check in the next loop condition!\n for (var i = 1; i <= len; i++) {\n tempMatch = this._input.match(regexes[i]);\n if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n match = tempMatch;\n index = i;\n if (this.options.backtrack_lexer) {\n token = this.test_match(tempMatch, rule_ids[i]);\n if (token !== false) {\n return token;\n } else if (this._backtrack) {\n match = undefined;\n continue; // rule action called reject() implying a rule MISmatch.\n } else {\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n } else if (!this.options.flex) {\n break;\n }\n }\n }\n if (match) {\n token = this.test_match(match, rule_ids[index]);\n if (token !== false) {\n return token;\n }\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n if (!this._input) {\n this.done = true;\n this.clear();\n return this.EOF;\n } else {\n var lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable);\n\n var pendingInput = this._input;\n var activeCondition = this.topState();\n var conditionStackDepth = this.conditionStack.length;\n\n token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n if (token === this.ERROR) {\n // we can try to recover from a lexer error that `parseError()` did not 'recover' for us\n // by moving forward at least one character at a time IFF the (user-specified?) `parseError()`\n // has not consumed/modified any pending input or changed state in the error handler:\n if (!this.matches &&\n // and make sure the input has been modified/consumed ...\n pendingInput === this._input &&\n // ...or the lexer state has been modified significantly enough\n // to merit a non-consuming error handling action right now.\n activeCondition === this.topState() &&\n conditionStackDepth === this.conditionStack.length\n ) {\n this.input();\n }\n }\n return token;\n }\n },\n\n /**\n * return next match that has a token\n *\n * @public\n * @this {RegExpLexer}\n */\n lex: function lexer_lex() {\n \"use strict\";\n\n var r;\n\n //this._clear_state = 0;\n\n if (!this._more) {\n if (!this._clear_state) {\n this._clear_state = 1;\n }\n this.clear();\n }\n\n // allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer:\n if (typeof this.pre_lex === 'function') {\n r = this.pre_lex.call(this, 0);\n }\n if (typeof this.options.pre_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.pre_lex.call(this, r) || r;\n }\n if (this.yy && typeof this.yy.pre_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.pre_lex.call(this, r) || r;\n }\n\n while (!r) {\n r = this.next();\n }\n\n if (this.yy && typeof this.yy.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.post_lex.call(this, r) || r;\n }\n if (typeof this.options.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.post_lex.call(this, r) || r;\n }\n if (typeof this.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.post_lex.call(this, r) || r;\n }\n\n if (!this._more) {\n //\n // 1) make sure any outside interference is detected ASAP: \n // these attributes are to be treated as 'const' values\n // once the lexer has produced them with the token (return value `r`).\n // 2) make sure any subsequent `lex()` API invocation CANNOT\n // edit the `yytext`, etc. token attributes for the *current*\n // token, i.e. provide a degree of 'closure safety' so that\n // code like this:\n // \n // t1 = lexer.lex();\n // v = lexer.yytext;\n // l = lexer.yylloc;\n // t2 = lexer.lex();\n // assert(lexer.yytext !== v);\n // assert(lexer.yylloc !== l);\n // \n // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee*\n // these conditions.\n // \n this.yytext = Object.freeze(this.yytext);\n this.matches = Object.freeze(this.matches);\n this.yylloc.range = Object.freeze(this.yylloc.range);\n this.yylloc = Object.freeze(this.yylloc);\n\n this._clear_state = 0;\n }\n\n return r;\n },\n\n /**\n * return next match that has a token. Identical to the `lex()` API but does not invoke any of the\n * `pre_lex()` nor any of the `post_lex()` callbacks.\n *\n * @public\n * @this {RegExpLexer}\n */\n fastLex: function lexer_fastLex() {\n \"use strict\";\n\n var r;\n\n //this._clear_state = 0;\n\n while (!r) {\n r = this.next();\n }\n\n if (!this._more) {\n //\n // 1) make sure any outside interference is detected ASAP: \n // these attributes are to be treated as 'const' values\n // once the lexer has produced them with the token (return value `r`).\n // 2) make sure any subsequent `lex()` API invocation CANNOT\n // edit the `yytext`, etc. token attributes for the *current*\n // token, i.e. provide a degree of 'closure safety' so that\n // code like this:\n // \n // t1 = lexer.lex();\n // v = lexer.yytext;\n // l = lexer.yylloc;\n // t2 = lexer.lex();\n // assert(lexer.yytext !== v);\n // assert(lexer.yylloc !== l);\n // \n // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee*\n // these conditions.\n // \n this.yytext = Object.freeze(this.yytext);\n this.matches = Object.freeze(this.matches);\n this.yylloc.range = Object.freeze(this.yylloc.range);\n this.yylloc = Object.freeze(this.yylloc);\n\n this._clear_state = 0;\n }\n \n return r;\n },\n\n /**\n * return info about the lexer state that can help a parser or other lexer API user to use the\n * most efficient means available. This API is provided to aid run-time performance for larger\n * systems which employ this lexer.\n *\n * @public\n * @this {RegExpLexer}\n */\n canIUse: function lexer_canIUse() {\n \"use strict\";\n\n var rv = {\n fastLex: !(\n typeof this.pre_lex === 'function' ||\n typeof this.options.pre_lex === 'function' ||\n (this.yy && typeof this.yy.pre_lex === 'function') ||\n (this.yy && typeof this.yy.post_lex === 'function') ||\n typeof this.options.post_lex === 'function' ||\n typeof this.post_lex === 'function'\n ) && typeof this.fastLex === 'function',\n };\n return rv;\n },\n\n\n /**\n * backwards compatible alias for `pushState()`;\n * the latter is symmetrical with `popState()` and we advise to use\n * those APIs in any modern lexer code, rather than `begin()`.\n *\n * @public\n * @this {RegExpLexer}\n */\n begin: function lexer_begin(condition) {\n \"use strict\";\n\n return this.pushState(condition);\n },\n\n /**\n * activates a new lexer condition state (pushes the new lexer\n * condition state onto the condition stack)\n *\n * @public\n * @this {RegExpLexer}\n */\n pushState: function lexer_pushState(condition) {\n \"use strict\";\n\n this.conditionStack.push(condition);\n this.__currentRuleSet__ = null;\n return this;\n },\n\n /**\n * pop the previously active lexer condition state off the condition\n * stack\n *\n * @public\n * @this {RegExpLexer}\n */\n popState: function lexer_popState() {\n \"use strict\";\n\n var n = this.conditionStack.length - 1;\n if (n > 0) {\n this.__currentRuleSet__ = null;\n return this.conditionStack.pop();\n } else {\n return this.conditionStack[0];\n }\n },\n\n /**\n * return the currently active lexer condition state; when an index\n * argument is provided it produces the N-th previous condition state,\n * if available\n *\n * @public\n * @this {RegExpLexer}\n */\n topState: function lexer_topState(n) {\n \"use strict\";\n\n n = this.conditionStack.length - 1 - Math.abs(n || 0);\n if (n >= 0) {\n return this.conditionStack[n];\n } else {\n return 'INITIAL';\n }\n },\n\n /**\n * (internal) determine the lexer rule set which is active for the\n * currently active lexer condition state\n *\n * @public\n * @this {RegExpLexer}\n */\n _currentRules: function lexer__currentRules() {\n \"use strict\";\n\n var n = this.conditionStack.length - 1;\n var state;\n if (n >= 0) {\n state = this.conditionStack[n];\n } else {\n state = 'INITIAL';\n }\n return this.conditions[state] || this.conditions['INITIAL'];\n },\n\n /**\n * return the number of states currently on the stack\n *\n * @public\n * @this {RegExpLexer}\n */\n stateStackSize: function lexer_stateStackSize() {\n \"use strict\";\n\n return this.conditionStack.length;\n }\n}"; // --- END lexer kernel --- + return "{\n EOF: 1,\n ERROR: 2,\n\n // JisonLexerError: JisonLexerError, /// <-- injected by the code generator\n\n // options: {}, /// <-- injected by the code generator\n\n // yy: ..., /// <-- injected by setInput()\n\n __currentRuleSet__: null, /// INTERNAL USE ONLY: internal rule set cache for the current lexer state\n\n __error_infos: [], /// INTERNAL USE ONLY: the set of lexErrorInfo objects created since the last cleanup\n\n __decompressed: false, /// INTERNAL USE ONLY: mark whether the lexer instance has been 'unfolded' completely and is now ready for use\n\n done: false, /// INTERNAL USE ONLY\n _backtrack: false, /// INTERNAL USE ONLY\n _input: '', /// INTERNAL USE ONLY\n _more: false, /// INTERNAL USE ONLY\n _signaled_error_token: false, /// INTERNAL USE ONLY\n _clear_state: 0, /// INTERNAL USE ONLY; 0: clear to do, 1: clear done for lex()/next(); -1: clear done for inut()/unput()/...\n\n conditionStack: [], /// INTERNAL USE ONLY; managed via `pushState()`, `popState()`, `topState()` and `stateStackSize()`\n\n match: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction. `match` is identical to `yytext` except that this one still contains the matched input string after `lexer.performAction()` has been invoked, where userland code MAY have changed/replaced the `yytext` value entirely!\n matched: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks entire input which has been matched so far\n matches: false, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks RE match result for last (successful) match attempt\n yytext: '', /// ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction; this value is transferred to the parser as the 'token value' when the parser consumes the lexer token produced through a call to the `lex()` API.\n offset: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks the 'cursor position' in the input string, i.e. the number of characters matched so far. (**WARNING:** this value MAY be negative if you `unput()` more text than you have already lexed. This type of behaviour is generally observed for one kind of 'lexer/parser hack' where custom token-illiciting characters are pushed in front of the input stream to help simulate multiple-START-points in the parser. When this happens, `base_position` will be adjusted to help track the original input's starting point in the `_input` buffer.)\n base_position: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: index to the original starting point of the input; always ZERO(0) unless `unput()` has pushed content before the input: see the `offset` **WARNING** just above.\n yyleng: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: length of matched input for the token under construction (`yytext`)\n yylineno: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: 'line number' at which the token under construction is located\n yylloc: null, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks location info (lines + columns) for the token under construction\n CRLF_Re: /\\r\\n?|\\n/, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: regex used to split lines while tracking the lexer cursor position.\n\n /**\n * INTERNAL USE: construct a suitable error info hash object instance for `parseError`.\n *\n * @public\n * @this {RegExpLexer}\n */\n constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) {\n msg = '' + msg;\n\n // heuristic to determine if the error message already contains a (partial) source code dump\n // as produced by either `showPosition()` or `prettyPrintRange()`:\n if (show_input_position == undefined) {\n show_input_position = !(msg.indexOf('\\n') > 0 && msg.indexOf('^') > 0);\n }\n if (this.yylloc && show_input_position) {\n if (typeof this.prettyPrintRange === 'function') {\n const pretty_src = this.prettyPrintRange(this.yylloc);\n\n if (!/\\n\\s*$/.test(msg)) {\n msg += '\\n';\n }\n msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc);\n } else if (typeof this.showPosition === 'function') {\n const pos_str = this.showPosition();\n if (pos_str) {\n if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') {\n msg += '\\n' + pos_str;\n } else {\n msg += pos_str;\n }\n }\n }\n }\n /** @constructor */\n const pei = {\n errStr: msg,\n recoverable: !!recoverable,\n text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'...\n token: null,\n line: this.yylineno,\n loc: this.yylloc,\n yy: this.yy,\n lexer: this,\n\n /**\n * and make sure the error info doesn't stay due to potential\n * ref cycle via userland code manipulations.\n * These would otherwise all be memory leak opportunities!\n *\n * Note that only array and object references are nuked as those\n * constitute the set of elements which can produce a cyclic ref.\n * The rest of the members is kept intact as they are harmless.\n *\n * @public\n * @this {LexErrorInfo}\n */\n destroy: function destructLexErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // ...\n const rec = !!this.recoverable;\n for (let key in this) {\n if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n },\n\n /**\n * handler which is invoked when a lexer error occurs.\n *\n * @public\n * @this {RegExpLexer}\n */\n parseError: function lexer_parseError(str, hash, ExceptionClass) {\n if (!ExceptionClass) {\n ExceptionClass = this.JisonLexerError;\n }\n if (this.yy) {\n if (this.yy.parser && typeof this.yy.parser.parseError === 'function') {\n return this.yy.parser.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n } else if (typeof this.yy.parseError === 'function') {\n return this.yy.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n }\n }\n throw new ExceptionClass(str, hash);\n },\n\n /**\n * method which implements `yyerror(str, ...args)` functionality for use inside lexer actions.\n *\n * @public\n * @this {RegExpLexer}\n */\n yyerror: function yyError(str /*, ...args */) {\n let lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable);\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n let args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n p.extra_error_attributes = args;\n }\n\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n },\n\n /**\n * final cleanup function for when we have completed lexing the input;\n * make it an API so that external code can use this one once userland\n * code has decided it's time to destroy any lingering lexer error\n * hash object instances and the like: this function helps to clean\n * up these constructs, which *may* carry cyclic references which would\n * otherwise prevent the instances from being properly and timely\n * garbage-collected, i.e. this function helps prevent memory leaks!\n *\n * @public\n * @this {RegExpLexer}\n */\n cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) {\n // prevent lingering circular references from causing memory leaks:\n this.setInput('', {});\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (let i = this.__error_infos.length - 1; i >= 0; i--) {\n let el = this.__error_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n }\n\n return this;\n },\n\n /**\n * clear the lexer token context; intended for internal use only\n *\n * @public\n * @this {RegExpLexer}\n */\n clear: function lexer_clear() {\n this.yytext = '';\n this.yyleng = 0;\n this.match = '';\n // - DO NOT reset `this.matched`\n this.matches = false;\n\n this._more = false;\n this._backtrack = false;\n\n const col = this.yylloc.last_column;\n this.yylloc = {\n first_line: this.yylineno + 1,\n first_column: col,\n last_line: this.yylineno + 1,\n last_column: col,\n\n range: [ this.offset, this.offset ]\n };\n },\n\n /**\n * resets the lexer, sets new input\n *\n * @public\n * @this {RegExpLexer}\n */\n setInput: function lexer_setInput(input, yy) {\n this.yy = yy || this.yy || {};\n\n // also check if we've fully initialized the lexer instance,\n // including expansion work to be done to go from a loaded\n // lexer to a usable lexer:\n if (!this.__decompressed) {\n // step 1: decompress the regex list:\n let rules = this.rules;\n for (var i = 0, len = rules.length; i < len; i++) {\n var rule_re = rules[i];\n\n // compression: is the RE an xref to another RE slot in the rules[] table?\n if (typeof rule_re === 'number') {\n rules[i] = rules[rule_re];\n }\n }\n\n // step 2: unfold the conditions[] set to make these ready for use:\n let conditions = this.conditions;\n for (let k in conditions) {\n let spec = conditions[k];\n\n let rule_ids = spec.rules;\n\n var len = rule_ids.length;\n let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple!\n let rule_new_ids = new Array(len + 1);\n\n for (var i = 0; i < len; i++) {\n let idx = rule_ids[i];\n var rule_re = rules[idx];\n rule_regexes[i + 1] = rule_re;\n rule_new_ids[i + 1] = idx;\n }\n\n spec.rules = rule_new_ids;\n spec.__rule_regexes = rule_regexes;\n spec.__rule_count = len;\n }\n\n this.__decompressed = true;\n }\n\n if (input && typeof input !== 'string') {\n input = '' + input;\n }\n this._input = input || '';\n this._clear_state = -1;\n this._signaled_error_token = false;\n this.done = false;\n this.yylineno = 0;\n this.matched = '';\n this.conditionStack = [ 'INITIAL' ];\n this.__currentRuleSet__ = null;\n this.yylloc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [ 0, 0 ]\n };\n this.offset = 0;\n this.base_position = 0;\n // apply these bits of `this.clear()` as well:\n this.yytext = '';\n this.yyleng = 0;\n this.match = '';\n this.matches = false;\n\n this._more = false;\n this._backtrack = false;\n\n return this;\n },\n\n /**\n * edit the remaining input via user-specified callback.\n * This can be used to forward-adjust the input-to-parse,\n * e.g. inserting macro expansions and alike in the\n * input which has yet to be lexed.\n * The behaviour of this API contrasts the `unput()` et al\n * APIs as those act on the *consumed* input, while this\n * one allows one to manipulate the future, without impacting\n * the current `yyloc` cursor location or any history.\n *\n * Use this API to help implement C-preprocessor-like\n * `#include` statements, etc.\n *\n * The provided callback must be synchronous and is\n * expected to return the edited input (string).\n *\n * The `cpsArg` argument value is passed to the callback\n * as-is.\n *\n * `callback` interface:\n * `function callback(input, cpsArg)`\n *\n * - `input` will carry the remaining-input-to-lex string\n * from the lexer.\n * - `cpsArg` is `cpsArg` passed into this API.\n *\n * The `this` reference for the callback will be set to\n * reference this lexer instance so that userland code\n * in the callback can easily and quickly access any lexer\n * API.\n *\n * When the callback returns a non-string-type falsey value,\n * we assume the callback did not edit the input and we\n * will using the input as-is.\n *\n * When the callback returns a non-string-type value, it\n * is converted to a string for lexing via the `\"\" + retval`\n * operation. (See also why: http://2ality.com/2012/03/converting-to-string.html\n * -- that way any returned object's `toValue()` and `toString()`\n * methods will be invoked in a proper/desirable order.)\n *\n * @public\n * @this {RegExpLexer}\n */\n editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) {\n const rv = callback.call(this, this._input, cpsArg);\n if (typeof rv !== 'string') {\n if (rv) {\n this._input = '' + rv;\n }\n // else: keep `this._input` as is.\n } else {\n this._input = rv;\n }\n return this;\n },\n\n /**\n * consumes and returns one char from the input\n *\n * @public\n * @this {RegExpLexer}\n */\n input: function lexer_input() {\n if (!this._input) {\n //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*)\n return null;\n }\n if (!this._clear_state && !this._more) {\n this._clear_state = -1;\n this.clear();\n }\n let ch = this._input[0];\n this.yytext += ch;\n this.yyleng++;\n this.offset++;\n this.match += ch;\n this.matched += ch;\n // Count the linenumber up when we hit the LF (or a stand-alone CR).\n // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo\n // and we advance immediately past the LF as well, returning both together as if\n // it was all a single 'character' only.\n let slice_len = 1;\n let lines = false;\n if (ch === '\\n') {\n lines = true;\n } else if (ch === '\\r') {\n lines = true;\n const ch2 = this._input[1];\n if (ch2 === '\\n') {\n slice_len++;\n ch += ch2;\n this.yytext += ch2;\n this.yyleng++;\n this.offset++;\n this.match += ch2;\n this.matched += ch2;\n this.yylloc.range[1]++;\n }\n }\n if (lines) {\n this.yylineno++;\n this.yylloc.last_line++;\n this.yylloc.last_column = 0;\n } else {\n this.yylloc.last_column++;\n }\n this.yylloc.range[1]++;\n\n this._input = this._input.slice(slice_len);\n return ch;\n },\n\n /**\n * unshifts one char (or an entire string) into the input\n *\n * @public\n * @this {RegExpLexer}\n */\n unput: function lexer_unput(ch) {\n let len = ch.length;\n let lines = ch.split(this.CRLF_Re);\n\n if (!this._clear_state && !this._more) {\n this._clear_state = -1;\n this.clear();\n }\n\n this._input = ch + this._input;\n this.yytext = this.yytext.substr(0, this.yytext.length - len);\n this.yyleng = this.yytext.length;\n this.offset -= len;\n // **WARNING:**\n // The `offset` value MAY be negative if you `unput()` more text than you have already lexed.\n // This type of behaviour is generally observed for one kind of 'lexer/parser hack'\n // where custom token-illiciting characters are pushed in front of the input stream to help\n // simulate multiple-START-points in the parser.\n // When this happens, `base_position` will be adjusted to help track the original input's\n // starting point in the `_input` buffer.\n if (-this.offset > this.base_position) {\n this.base_position = -this.offset;\n }\n this.match = this.match.substr(0, this.match.length - len);\n this.matched = this.matched.substr(0, this.matched.length - len);\n\n if (lines.length > 1) {\n this.yylineno -= lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n\n // Get last entirely matched line into the `pre_lines[]` array's\n // last index slot; we don't mind when other previously\n // matched lines end up in the array too.\n let pre = this.match;\n let pre_lines = pre.split(this.CRLF_Re);\n if (pre_lines.length === 1) {\n pre = this.matched;\n pre_lines = pre.split(this.CRLF_Re);\n }\n this.yylloc.last_column = pre_lines[pre_lines.length - 1].length;\n } else {\n this.yylloc.last_column -= len;\n }\n\n this.yylloc.range[1] = this.yylloc.range[0] + this.yyleng;\n\n this.done = false;\n return this;\n },\n\n /**\n * return the upcoming input *which has not been lexed yet*.\n * This can, for example, be used for custom look-ahead inspection code\n * in your lexer.\n *\n * The entire pending input string is returned.\n *\n * > ### NOTE ###\n * >\n * > When augmenting error reports and alike, you might want to\n * > look at the `upcomingInput()` API instead, which offers more\n * > features for limited input extraction and which includes the\n * > part of the input which has been lexed by the last token a.k.a.\n * > the *currently lexed* input.\n * >\n *\n * @public\n * @this {RegExpLexer}\n */\n lookAhead: function lexer_lookAhead() {\n return this._input || '';\n },\n\n /**\n * cache matched text and append it on next action\n *\n * @public\n * @this {RegExpLexer}\n */\n more: function lexer_more() {\n this._more = true;\n return this;\n },\n\n /**\n * signal the lexer that this rule fails to match the input, so the\n * next matching rule (regex) should be tested instead.\n *\n * @public\n * @this {RegExpLexer}\n */\n reject: function lexer_reject() {\n if (this.options.backtrack_lexer) {\n this._backtrack = true;\n } else {\n // when the `parseError()` call returns, we MUST ensure that the error is registered.\n // We accomplish this by signaling an 'error' token to be produced for the current\n // `.lex()` run.\n let lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false);\n this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n return this;\n },\n\n /**\n * retain first n characters of the match\n *\n * @public\n * @this {RegExpLexer}\n */\n less: function lexer_less(n) {\n return this.unput(this.match.slice(n));\n },\n\n /**\n * return (part of the) already matched input, i.e. for error\n * messages.\n *\n * Limit the returned string length to `maxSize` (default: 20).\n *\n * Limit the returned string to the `maxLines` number of lines of\n * input (default: 1).\n *\n * A negative `maxSize` limit value equals *unlimited*, i.e.\n * produce the entire input that has already been lexed.\n *\n * A negative `maxLines` limit value equals *unlimited*, i.e. limit the result\n * to the `maxSize` specified number of characters *only*.\n *\n * @public\n * @this {RegExpLexer}\n */\n pastInput: function lexer_pastInput(maxSize, maxLines) {\n let past = this.matched.substring(0, this.matched.length - this.match.length);\n if (maxSize < 0) {\n maxSize = Infinity;\n } else if (!maxSize) {\n maxSize = 20;\n }\n if (maxLines < 0) {\n maxLines = Infinity; // can't ever have more input lines than this!\n } else if (!maxLines) {\n maxLines = 1;\n }\n // `substr` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we've transformed and limited the newLines in here:\n past = past.substr(-maxSize * 2 - 2);\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n let a = past.split(this.CRLF_Re);\n a = a.slice(-maxLines);\n past = a.join('\\n');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis prefix...\n if (past.length > maxSize) {\n past = '...' + past.substr(-maxSize);\n }\n return past;\n },\n\n /**\n * return (part of the) upcoming input *including* the input\n * matched by the last token (see also the NOTE below).\n * This can be used to augment error messages, for example.\n *\n * Limit the returned string length to `maxSize` (default: 20).\n *\n * Limit the returned string to the `maxLines` number of lines of input (default: 1).\n *\n * A negative `maxSize` limit value equals *unlimited*, i.e.\n * produce the entire input that is yet to be lexed.\n *\n * A negative `maxLines` limit value equals *unlimited*, i.e. limit the result\n * to the `maxSize` specified number of characters *only*.\n *\n * > ### NOTE ###\n * >\n * > *\"upcoming input\"* is defined as the whole of the both\n * > the *currently lexed* input, together with any remaining input\n * > following that. *\"currently lexed\"* input is the input\n * > already recognized by the lexer but not yet returned with\n * > the lexer token. This happens when you are invoking this API\n * > from inside any lexer rule action code block.\n * >\n * > When you want access to the 'upcoming input' in that you want access\n * > to the input *which has not been lexed yet* for look-ahead\n * > inspection or likewise purposes, please consider using the\n * > `lookAhead()` API instead.\n * >\n *\n * @public\n * @this {RegExpLexer}\n */\n upcomingInput: function lexer_upcomingInput(maxSize, maxLines) {\n let next = this.match;\n let source = this._input || '';\n if (maxSize < 0) {\n maxSize = next.length + source.length;\n } else if (!maxSize) {\n maxSize = 20;\n }\n\n if (maxLines < 0) {\n maxLines = maxSize; // can't ever have more input lines than this!\n } else if (!maxLines) {\n maxLines = 1;\n }\n // `substring` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we've transformed and limited the newLines in here:\n if (next.length < maxSize * 2 + 2) {\n next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8\n }\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines.\n a = a.slice(0, maxLines);\n next = a.join('\\n');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis postfix...\n if (next.length > maxSize) {\n next = next.substring(0, maxSize) + '...';\n }\n return next;\n },\n\n /**\n * return a string which displays the character position where the\n * lexing error occurred, i.e. for error messages\n *\n * @public\n * @this {RegExpLexer}\n */\n showPosition: function lexer_showPosition(maxPrefix, maxPostfix) {\n const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' ');\n let c = new Array(pre.length + 1).join('-');\n return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^';\n },\n\n /**\n * return an YYLLOC info object derived off the given context (actual, preceding, following, current).\n * Use this method when the given `actual` location is not guaranteed to exist (i.e. when\n * it MAY be NULL) and you MUST have a valid location info object anyway:\n * then we take the given context of the `preceding` and `following` locations, IFF those are available,\n * and reconstruct the `actual` location info from those.\n * If this fails, the heuristic is to take the `current` location, IFF available.\n * If this fails as well, we assume the sought location is at/around the current lexer position\n * and then produce that one as a response. DO NOTE that these heuristic/derived location info\n * values MAY be inaccurate!\n *\n * NOTE: `deriveLocationInfo()` ALWAYS produces a location info object *copy* of `actual`, not just\n * a *reference* hence all input location objects can be assumed to be 'constant' (function has no side-effects).\n *\n * @public\n * @this {RegExpLexer}\n */\n deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) {\n let loc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [ 0, 0 ]\n };\n if (actual) {\n loc.first_line = actual.first_line | 0;\n loc.last_line = actual.last_line | 0;\n loc.first_column = actual.first_column | 0;\n loc.last_column = actual.last_column | 0;\n\n if (actual.range) {\n loc.range[0] = actual.range[0] | 0;\n loc.range[1] = actual.range[1] | 0;\n }\n }\n if (loc.first_line <= 0 || loc.last_line < loc.first_line) {\n // plan B: heuristic using preceding and following:\n if (loc.first_line <= 0 && preceding) {\n loc.first_line = preceding.last_line | 0;\n loc.first_column = preceding.last_column | 0;\n\n if (preceding.range) {\n loc.range[0] = actual.range[1] | 0;\n }\n }\n\n if ((loc.last_line <= 0 || loc.last_line < loc.first_line) && following) {\n loc.last_line = following.first_line | 0;\n loc.last_column = following.first_column | 0;\n\n if (following.range) {\n loc.range[1] = actual.range[0] | 0;\n }\n }\n\n // plan C?: see if the 'current' location is useful/sane too:\n if (loc.first_line <= 0 && current && (loc.last_line <= 0 || current.last_line <= loc.last_line)) {\n loc.first_line = current.first_line | 0;\n loc.first_column = current.first_column | 0;\n\n if (current.range) {\n loc.range[0] = current.range[0] | 0;\n }\n }\n\n if (loc.last_line <= 0 && current && (loc.first_line <= 0 || current.first_line >= loc.first_line)) {\n loc.last_line = current.last_line | 0;\n loc.last_column = current.last_column | 0;\n\n if (current.range) {\n loc.range[1] = current.range[1] | 0;\n }\n }\n }\n // sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter\n // or plan D heuristics to produce a 'sensible' last_line value:\n if (loc.last_line <= 0) {\n if (loc.first_line <= 0) {\n loc.first_line = this.yylloc.first_line;\n loc.last_line = this.yylloc.last_line;\n loc.first_column = this.yylloc.first_column;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[0] = this.yylloc.range[0];\n loc.range[1] = this.yylloc.range[1];\n } else {\n loc.last_line = this.yylloc.last_line;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[1] = this.yylloc.range[1];\n }\n }\n if (loc.first_line <= 0) {\n loc.first_line = loc.last_line;\n loc.first_column = 0; // loc.last_column;\n\n loc.range[1] = loc.range[0];\n }\n if (loc.first_column < 0) {\n loc.first_column = 0;\n }\n if (loc.last_column < 0) {\n loc.last_column = (loc.first_column > 0 ? loc.first_column : 80);\n }\n return loc;\n },\n\n /**\n * return a string which displays the lines & columns of input which are referenced\n * by the given location info range, plus a few lines of context.\n *\n * This function pretty-prints the indicated section of the input, with line numbers\n * and everything!\n *\n * This function is very useful to provide highly readable error reports, while\n * the location range may be specified in various flexible ways:\n *\n * - `loc` is the location info object which references the area which should be\n * displayed and 'marked up': these lines & columns of text are marked up by `^`\n * characters below each character in the entire input range.\n *\n * - `context_loc` is the *optional* location info object which instructs this\n * pretty-printer how much *leading* context should be displayed alongside\n * the area referenced by `loc`. This can help provide context for the displayed\n * error, etc.\n *\n * When this location info is not provided, a default context of 3 lines is\n * used.\n *\n * - `context_loc2` is another *optional* location info object, which serves\n * a similar purpose to `context_loc`: it specifies the amount of *trailing*\n * context lines to display in the pretty-print output.\n *\n * When this location info is not provided, a default context of 1 line only is\n * used.\n *\n * Special Notes:\n *\n * - when the `loc`-indicated range is very large (about 5 lines or more), then\n * only the first and last few lines of this block are printed while a\n * `...continued...` message will be printed between them.\n *\n * This serves the purpose of not printing a huge amount of text when the `loc`\n * range happens to be huge: this way a manageable & readable output results\n * for arbitrary large ranges.\n *\n * - this function can display lines of input which whave not yet been lexed.\n * `prettyPrintRange()` can access the entire input!\n *\n * @public\n * @this {RegExpLexer}\n */\n prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) {\n loc = this.deriveLocationInfo(loc, context_loc, context_loc2);\n\n const CONTEXT = 3;\n const CONTEXT_TAIL = 1;\n const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2;\n let input = this.matched + (this._input || '');\n let lines = input.split('\\n');\n let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT));\n let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL));\n let lineno_display_width = (1 + Math.log10(l1 | 1) | 0);\n let ws_prefix = new Array(lineno_display_width).join(' ');\n let nonempty_line_indexes = [ [], [], [] ];\n let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) {\n let lno = index + l0;\n let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width);\n let rv = lno_pfx + ': ' + line;\n let errpfx = (new Array(lineno_display_width + 1)).join('^');\n let offset = 2 + 1;\n let len = 0;\n\n if (lno === loc.first_line) {\n offset += loc.first_column;\n\n len = Math.max(\n 2,\n ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1\n );\n } else if (lno === loc.last_line) {\n len = Math.max(2, loc.last_column + 1);\n } else if (lno > loc.first_line && lno < loc.last_line) {\n len = Math.max(2, line.length + 1);\n }\n\n let nli;\n if (len) {\n let lead = new Array(offset).join('.');\n let mark = new Array(len).join('^');\n rv += '\\n' + errpfx + lead + mark;\n\n nli = 1;\n } else if (lno < loc.first_line) {\n nli = 0;\n } else if (lno > loc.last_line) {\n nli = 2;\n }\n\n if (line.trim().length > 0) {\n nonempty_line_indexes[nli].push(index);\n }\n\n rv = rv.replace(/\\t/g, ' ');\n return rv;\n });\n\n // now make sure we don't print an overly large amount of lead/error/tail area: limit it\n // to the top and bottom line count:\n for (let i = 0; i <= 2; i++) {\n let line_arr = nonempty_line_indexes[i];\n if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) {\n let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1;\n let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1;\n\n let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)';\n if (i === 1) {\n intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)';\n }\n rv.splice(clip_start, clip_end - clip_start + 1, intermediate_line);\n }\n }\n\n return rv.join('\\n');\n },\n\n /**\n * helper function, used to produce a human readable description as a string, given\n * the input `yylloc` location object.\n *\n * Set `display_range_too` to TRUE to include the string character index position(s)\n * in the description if the `yylloc.range` is available.\n *\n * @public\n * @this {RegExpLexer}\n */\n describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) {\n let l1 = yylloc.first_line;\n let l2 = yylloc.last_line;\n let c1 = yylloc.first_column;\n let c2 = yylloc.last_column;\n let dl = l2 - l1;\n let dc = c2 - c1;\n let rv;\n if (dl === 0) {\n rv = 'line ' + l1 + ', ';\n if (dc <= 1) {\n rv += 'column ' + c1;\n } else {\n rv += 'columns ' + c1 + ' .. ' + c2;\n }\n } else {\n rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')';\n }\n if (yylloc.range && display_range_too) {\n let r1 = yylloc.range[0];\n let r2 = yylloc.range[1] - 1;\n if (r2 <= r1) {\n rv += ' {String Offset: ' + r1 + '}';\n } else {\n rv += ' {String Offset range: ' + r1 + ' .. ' + r2 + '}';\n }\n }\n return rv;\n },\n\n /**\n * test the lexed token: return FALSE when not a match, otherwise return token.\n *\n * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]`\n * contains the actually matched text string.\n *\n * Also move the input cursor forward and update the match collectors:\n *\n * - `yytext`\n * - `yyleng`\n * - `match`\n * - `matches`\n * - `yylloc`\n * - `offset`\n *\n * @public\n * @this {RegExpLexer}\n */\n test_match: function lexer_test_match(match, indexed_rule) {\n let backup;\n\n if (this.options.backtrack_lexer) {\n // save context\n backup = {\n yylineno: this.yylineno,\n yylloc: {\n first_line: this.yylloc.first_line,\n last_line: this.yylloc.last_line,\n first_column: this.yylloc.first_column,\n last_column: this.yylloc.last_column,\n\n range: this.yylloc.range.slice()\n },\n yytext: this.yytext,\n match: this.match,\n matches: this.matches,\n matched: this.matched,\n yyleng: this.yyleng,\n offset: this.offset,\n _more: this._more,\n _input: this._input,\n //_signaled_error_token: this._signaled_error_token,\n yy: this.yy,\n conditionStack: this.conditionStack.slice(),\n done: this.done\n };\n }\n\n let match_str = match[0];\n let match_str_len = match_str.length;\n\n let lines = match_str.split(this.CRLF_Re);\n if (lines.length > 1) {\n this.yylineno += lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n this.yylloc.last_column = lines[lines.length - 1].length;\n } else {\n this.yylloc.last_column += match_str_len;\n }\n\n this.yytext += match_str;\n this.match += match_str;\n this.matched += match_str;\n this.matches = match;\n this.yyleng = this.yytext.length;\n this.yylloc.range[1] += match_str_len;\n\n // previous lex rules MAY have invoked the `more()` API rather than producing a token:\n // those rules will already have moved this `offset` forward matching their match lengths,\n // hence we must only add our own match length now:\n this.offset += match_str_len;\n this._more = false;\n this._backtrack = false;\n this._input = this._input.slice(match_str_len);\n\n // calling this method:\n //\n // function lexer__performAction(yy, yyrulenumber, YY_START) {...}\n let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */);\n // otherwise, when the action codes are all simple return token statements:\n //token = this.simpleCaseActionClusters[indexed_rule];\n\n if (this.done && this._input) {\n this.done = false;\n }\n if (token) {\n return token;\n } else if (this._backtrack) {\n // recover context\n for (let k in backup) {\n this[k] = backup[k];\n }\n this.__currentRuleSet__ = null;\n return false; // rule action called reject() implying the next rule should be tested instead.\n } else if (this._signaled_error_token) {\n // produce one 'error' token as `.parseError()` in `reject()`\n // did not guarantee a failure signal by throwing an exception!\n token = this._signaled_error_token;\n this._signaled_error_token = false;\n return token;\n }\n return false;\n },\n\n /**\n * return next match in input\n *\n * @public\n * @this {RegExpLexer}\n */\n next: function lexer_next() {\n if (this.done) {\n this.clear();\n return this.EOF;\n }\n if (!this._input) {\n this.done = true;\n }\n\n if (!this._more) {\n if (!this._clear_state) {\n this._clear_state = 1;\n }\n this.clear();\n }\n let spec = this.__currentRuleSet__;\n if (!spec) {\n // Update the ruleset cache as we apparently encountered a state change or just started lexing.\n // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will\n // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps\n // speed up those activities a tiny bit.\n spec = this.__currentRuleSet__ = this._currentRules();\n // Check whether a *sane* condition has been pushed before: this makes the lexer robust against\n // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19\n if (!spec || !spec.rules) {\n let lineno_msg = '';\n if (this.yylloc) {\n lineno_msg = ' on line ' + (this.yylineno + 1);\n }\n const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name \"' + this.topState() + '\"; this is a fatal error and should be reported to the application programmer team!', false);\n // produce one 'error' token until this situation has been resolved, most probably by parse termination!\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n }\n\n {\n let rule_ids = spec.rules;\n let regexes = spec.__rule_regexes;\n let len = spec.__rule_count;\n let match;\n let index;\n\n // Note: the arrays are 1-based, while `len` itself is a valid index,\n // hence the non-standard less-or-equal check in the next loop condition!\n for (let i = 1; i <= len; i++) {\n let tempMatch = this._input.match(regexes[i]);\n if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n match = tempMatch;\n index = i;\n if (this.options.backtrack_lexer) {\n let token = this.test_match(tempMatch, rule_ids[i]);\n if (token !== false) {\n return token;\n } else if (this._backtrack) {\n match = undefined;\n continue; // rule action called reject() implying a rule MISmatch.\n } else {\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n } else if (!this.options.flex) {\n break;\n }\n }\n }\n\n if (match) {\n let token = this.test_match(match, rule_ids[index]);\n if (token !== false) {\n return token;\n }\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n }\n\n if (!this._input) {\n this.done = true;\n this.clear();\n return this.EOF;\n }\n\n {\n let lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable);\n\n let pendingInput = this._input;\n let activeCondition = this.topState();\n let conditionStackDepth = this.conditionStack.length;\n\n let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n if (token === this.ERROR) {\n // we can try to recover from a lexer error that `parseError()` did not 'recover' for us\n // by moving forward at least one character at a time IFF the (user-specified?) `parseError()`\n // has not consumed/modified any pending input or changed state in the error handler:\n if (!this.matches &&\n // and make sure the input has been modified/consumed ...\n pendingInput === this._input &&\n // ...or the lexer state has been modified significantly enough\n // to merit a non-consuming error handling action right now.\n activeCondition === this.topState() &&\n conditionStackDepth === this.conditionStack.length\n ) {\n this.input();\n }\n }\n return token;\n }\n },\n\n /**\n * return next match that has a token\n *\n * @public\n * @this {RegExpLexer}\n */\n lex: function lexer_lex() {\n let r;\n\n //this._clear_state = 0;\n\n if (!this._more) {\n if (!this._clear_state) {\n this._clear_state = 1;\n }\n this.clear();\n }\n\n // allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer:\n if (typeof this.pre_lex === 'function') {\n r = this.pre_lex.call(this, 0);\n }\n if (typeof this.options.pre_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.pre_lex.call(this, r) || r;\n }\n if (this.yy && typeof this.yy.pre_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.pre_lex.call(this, r) || r;\n }\n\n while (!r) {\n r = this.next();\n }\n\n if (this.yy && typeof this.yy.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.post_lex.call(this, r) || r;\n }\n if (typeof this.options.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.post_lex.call(this, r) || r;\n }\n if (typeof this.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.post_lex.call(this, r) || r;\n }\n\n if (!this._more) {\n //\n // 1) make sure any outside interference is detected ASAP:\n // these attributes are to be treated as 'const' values\n // once the lexer has produced them with the token (return value `r`).\n // 2) make sure any subsequent `lex()` API invocation CANNOT\n // edit the `yytext`, etc. token attributes for the *current*\n // token, i.e. provide a degree of 'closure safety' so that\n // code like this:\n //\n // t1 = lexer.lex();\n // v = lexer.yytext;\n // l = lexer.yylloc;\n // t2 = lexer.lex();\n // assert(lexer.yytext !== v);\n // assert(lexer.yylloc !== l);\n //\n // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee*\n // these conditions.\n //\n this.yytext = Object.freeze(this.yytext);\n this.matches = Object.freeze(this.matches);\n this.yylloc.range = Object.freeze(this.yylloc.range);\n this.yylloc = Object.freeze(this.yylloc);\n\n this._clear_state = 0;\n }\n\n return r;\n },\n\n /**\n * return next match that has a token. Identical to the `lex()` API but does not invoke any of the\n * `pre_lex()` nor any of the `post_lex()` callbacks.\n *\n * @public\n * @this {RegExpLexer}\n */\n fastLex: function lexer_fastLex() {\n let r;\n\n //this._clear_state = 0;\n\n while (!r) {\n r = this.next();\n }\n\n if (!this._more) {\n //\n // 1) make sure any outside interference is detected ASAP:\n // these attributes are to be treated as 'const' values\n // once the lexer has produced them with the token (return value `r`).\n // 2) make sure any subsequent `lex()` API invocation CANNOT\n // edit the `yytext`, etc. token attributes for the *current*\n // token, i.e. provide a degree of 'closure safety' so that\n // code like this:\n //\n // t1 = lexer.lex();\n // v = lexer.yytext;\n // l = lexer.yylloc;\n // t2 = lexer.lex();\n // assert(lexer.yytext !== v);\n // assert(lexer.yylloc !== l);\n //\n // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee*\n // these conditions.\n //\n this.yytext = Object.freeze(this.yytext);\n this.matches = Object.freeze(this.matches);\n this.yylloc.range = Object.freeze(this.yylloc.range);\n this.yylloc = Object.freeze(this.yylloc);\n\n this._clear_state = 0;\n }\n\n return r;\n },\n\n /**\n * return info about the lexer state that can help a parser or other lexer API user to use the\n * most efficient means available. This API is provided to aid run-time performance for larger\n * systems which employ this lexer.\n *\n * @public\n * @this {RegExpLexer}\n */\n canIUse: function lexer_canIUse() {\n const rv = {\n fastLex: !(\n typeof this.pre_lex === 'function' ||\n typeof this.options.pre_lex === 'function' ||\n (this.yy && typeof this.yy.pre_lex === 'function') ||\n (this.yy && typeof this.yy.post_lex === 'function') ||\n typeof this.options.post_lex === 'function' ||\n typeof this.post_lex === 'function'\n ) && typeof this.fastLex === 'function'\n };\n return rv;\n },\n\n\n /**\n * backwards compatible alias for `pushState()`;\n * the latter is symmetrical with `popState()` and we advise to use\n * those APIs in any modern lexer code, rather than `begin()`.\n *\n * @public\n * @this {RegExpLexer}\n */\n begin: function lexer_begin(condition) {\n return this.pushState(condition);\n },\n\n /**\n * activates a new lexer condition state (pushes the new lexer\n * condition state onto the condition stack)\n *\n * @public\n * @this {RegExpLexer}\n */\n pushState: function lexer_pushState(condition) {\n this.conditionStack.push(condition);\n this.__currentRuleSet__ = null;\n return this;\n },\n\n /**\n * pop the previously active lexer condition state off the condition\n * stack\n *\n * @public\n * @this {RegExpLexer}\n */\n popState: function lexer_popState() {\n const n = this.conditionStack.length - 1;\n if (n > 0) {\n this.__currentRuleSet__ = null;\n return this.conditionStack.pop();\n }\n return this.conditionStack[0];\n },\n\n /**\n * return the currently active lexer condition state; when an index\n * argument is provided it produces the N-th previous condition state,\n * if available\n *\n * @public\n * @this {RegExpLexer}\n */\n topState: function lexer_topState(n) {\n n = this.conditionStack.length - 1 - Math.abs(n || 0);\n if (n >= 0) {\n return this.conditionStack[n];\n }\n return 'INITIAL';\n },\n\n /**\n * (internal) determine the lexer rule set which is active for the\n * currently active lexer condition state\n *\n * @public\n * @this {RegExpLexer}\n */\n _currentRules: function lexer__currentRules() {\n const n = this.conditionStack.length - 1;\n let state;\n if (n >= 0) {\n state = this.conditionStack[n];\n } else {\n state = 'INITIAL';\n }\n return this.conditions[state] || this.conditions.INITIAL;\n },\n\n /**\n * return the number of states currently on the stack\n *\n * @public\n * @this {RegExpLexer}\n */\n stateStackSize: function lexer_stateStackSize() {\n return this.conditionStack.length;\n }\n}"; // --- END lexer kernel --- } chkBugger$2(getRegExpLexerPrototype()); - RegExpLexer.prototype = new Function(rmCommonWS$2(_templateObject80(), getRegExpLexerPrototype()))(); // The lexer code stripper, driven by optimization analysis settings and + RegExpLexer.prototype = new Function(rmCommonWS$2(_templateObject81(), getRegExpLexerPrototype()))(); // The lexer code stripper, driven by optimization analysis settings and // lexer options, which cannot be changed at run-time. function stripUnusedLexerCode(src, opt) { @@ -12497,15 +12707,15 @@ 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 _c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); var offendingChunk = ' ' + b.join('\n '); - console.error(rmCommonWS$2(_templateObject81(), ex, offendingChunk)); + console.error(rmCommonWS$2(_templateObject82(), ex, offendingChunk)); new_src = src; } // inject analysis report now: - new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2(_templateObject82(), opt.options.backtrack_lexer, opt.options.ranges, opt.options.trackPosition, opt.parseActionsUseYYLENG, opt.parseActionsUseYYLINENO, opt.parseActionsUseYYTEXT, opt.parseActionsUseYYLOC, opt.parseActionsUseValueTracking, opt.parseActionsUseValueAssignment, opt.parseActionsUseLocationTracking, opt.parseActionsUseLocationAssignment, opt.lexerActionsUseYYLENG, opt.lexerActionsUseYYLINENO, opt.lexerActionsUseYYTEXT, opt.lexerActionsUseYYLOC, opt.lexerActionsUseParseError, opt.lexerActionsUseYYERROR, opt.lexerActionsUseLocationTracking, opt.lexerActionsUseMore, opt.lexerActionsUseUnput, opt.lexerActionsUseReject, opt.lexerActionsUseLess, opt.lexerActionsUseDisplayAPIs, opt.lexerActionsUseDescribeYYLOC)); + new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2(_templateObject83(), opt.options.backtrack_lexer, opt.options.ranges, opt.options.trackPosition, opt.parseActionsUseYYLENG, opt.parseActionsUseYYLINENO, opt.parseActionsUseYYTEXT, opt.parseActionsUseYYLOC, opt.parseActionsUseValueTracking, opt.parseActionsUseValueAssignment, opt.parseActionsUseLocationTracking, opt.parseActionsUseLocationAssignment, opt.lexerActionsUseYYLENG, opt.lexerActionsUseYYLINENO, opt.lexerActionsUseYYTEXT, opt.lexerActionsUseYYLOC, opt.lexerActionsUseParseError, opt.lexerActionsUseYYERROR, opt.lexerActionsUseLocationTracking, opt.lexerActionsUseMore, opt.lexerActionsUseUnput, opt.lexerActionsUseReject, opt.lexerActionsUseLess, opt.lexerActionsUseDisplayAPIs, opt.lexerActionsUseDescribeYYLOC)); return new_src; } // generate lexer source from a grammar @@ -12642,9 +12852,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); return "/* ".concat(idx_str, ": */ new XRegExp(\"").concat(re_src, "\", \"").concat(re.xregexp.flags, "\")"); - } else { - return "/* ".concat(idx_str, ": */ ").concat(re); } + + return "/* ".concat(idx_str, ": */ ").concat(re); }); return b.join(',\n'); } @@ -12652,8 +12862,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function generateModuleBody(opt) { // make the JSON output look more like JavaScript: function cleanupJSON(str) { - str = str.replace(/ "rules": \[/g, ' rules: ['); - str = str.replace(/ "inclusive": /g, ' inclusive: '); + str = str.replace(/ {2}"rules": \[/g, ' rules: ['); + str = str.replace(/ {2}"inclusive": /g, ' inclusive: '); return str; } @@ -12764,7 +12974,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) { // we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. - var code = [rmCommonWS$2(_templateObject83()), '/*JISON-LEX-ANALYTICS-REPORT*/' + var code = [rmCommonWS$2(_templateObject84()), '/* JISON-LEX-ANALYTICS-REPORT */\n' /* slot #1: placeholder for analysis report further below */ ]; // get the RegExpLexer.prototype in source code form: @@ -12791,7 +13001,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var simpleCaseActionClustersCode = String(opt.caseHelperInclude); var rulesCode = generateRegexesInitTableCode(opt); var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); - code.push(rmCommonWS$2(_templateObject84(), performActionCode, simpleCaseActionClustersCode, rulesCode, conditionsCode)); + code.push(rmCommonWS$2(_templateObject85(), performActionCode, simpleCaseActionClustersCode, rulesCode, conditionsCode)); opt.is_custom_lexer = false; out = code.join(''); } else { @@ -12799,9 +13009,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // - // Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter + // Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. - out = 'var lexer;\n'; + out = '\n'; assert__default['default'](opt.regular_rule_count === 0); assert__default['default'](opt.simple_rule_count === 0); opt.is_custom_lexer = true; @@ -12812,8 +13022,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } // The output of this function is guaranteed to read something like this: // // ``` - // var lexer; - // // bla bla bla bla ... lotsa bla bla; // ``` // @@ -12824,7 +13032,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } function generateGenericHeaderComment() { - var out = rmCommonWS$2(_templateObject85(), version); + var out = rmCommonWS$2(_templateObject86(), version); return out; } @@ -12853,7 +13061,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function generateModule(opt) { opt = prepareOptions(opt); var modIncSrc = opt.moduleInclude ? opt.moduleInclude + ';' : ''; - var src = rmCommonWS$2(_templateObject86(), generateGenericHeaderComment(), opt.moduleName, jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); + var src = rmCommonWS$2(_templateObject87(), generateGenericHeaderComment(), opt.moduleName, jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); src = stripUnusedLexerCode(src, opt); opt.exportSourceCode.all = src; return src; @@ -12862,7 +13070,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function generateAMDModule(opt) { opt = prepareOptions(opt); var modIncSrc = opt.moduleInclude ? opt.moduleInclude + ';' : ''; - var src = rmCommonWS$2(_templateObject87(), generateGenericHeaderComment(), jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); + var src = rmCommonWS$2(_templateObject88(), generateGenericHeaderComment(), jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); src = stripUnusedLexerCode(src, opt); opt.exportSourceCode.all = src; return src; @@ -12871,7 +13079,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function generateESModule(opt) { opt = prepareOptions(opt); var modIncSrc = opt.moduleInclude ? opt.moduleInclude + ';' : ''; - var src = rmCommonWS$2(_templateObject88(), generateGenericHeaderComment(), jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); + var src = rmCommonWS$2(_templateObject89(), generateGenericHeaderComment(), jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); src = stripUnusedLexerCode(src, opt); opt.exportSourceCode.all = src; return src; @@ -12880,7 +13088,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function generateCommonJSModule(opt) { opt = prepareOptions(opt); var modIncSrc = opt.moduleInclude ? opt.moduleInclude + ';' : ''; - var src = rmCommonWS$2(_templateObject89(), generateGenericHeaderComment(), opt.moduleName, jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc, opt.moduleName, opt.moduleName); + var src = rmCommonWS$2(_templateObject90(), generateGenericHeaderComment(), opt.moduleName, jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc, opt.moduleName, opt.moduleName); src = stripUnusedLexerCode(src, opt); opt.exportSourceCode.all = src; return src; @@ -13252,15 +13460,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi switch (yystate) { case 0: /*! Production:: $accept : production $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-): - this.$ = yyvstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-) + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-): + this.$ = yyvstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-) break; case 1: /*! Production:: production : handle EOF */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-): - this.$ = yyvstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-) + // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-): + this.$ = yyvstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-) return yyvstack[yysp - 1]; @@ -13408,20 +13616,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + var ASSERT = typeof assert !== 'function' ? function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : assert; this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -13450,13 +13652,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + var _dst2 = {}; + shallow_copy_noclobber(_dst2, src); + return _dst2; + } } return src; @@ -13473,10 +13676,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (chk.call(src, k)) { dst[k] = src[k]; } - } else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } // copy state @@ -13622,6 +13823,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -13763,7 +13970,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi action = t[0]; // handle parse error if (!action) { - var errStr; + var errStr = void 0; var errSymbolDescr = this.describeSymbol(symbol) || symbol; var expected = this.collect_expected_token_set(state); // Report error @@ -13897,14 +14104,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -14412,6 +14621,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -14793,9 +15006,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -14805,8 +15018,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -14882,12 +15095,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi */ pastInput: function lexer_pastInput(maxSize, maxLines) { var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) maxSize = Infinity;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substr` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = Infinity; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: @@ -14904,8 +15127,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -14931,20 +15154,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { var next = this.match; var source = this._input || ''; - if (maxSize < 0) maxSize = next.length + source.length;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substring` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = next.length + source.length; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + if (next.length < maxSize * 2 + 2) { next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8 } // now that we have a significantly reduced string to process, transform the newlines @@ -15269,7 +15502,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + var backup; if (this.options.backtrack_lexer) { // save context @@ -15297,9 +15530,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + var match_str = match[0]; + var match_str_len = match_str.length; + var lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -15325,7 +15558,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] + var token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */ ); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -15371,8 +15604,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -15404,65 +15635,73 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; // 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! + { + var rule_ids = spec.rules; + var regexes = spec.__rule_regexes; + var len = spec.__rule_count; + var match; + var index; // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + for (var i = 1; i <= len; i++) { + var tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + var token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + var _token3 = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + if (_token3 !== false) { + return _token3; + } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + var _lineno_msg2 = 'Lexical error'; if (this.yylloc) { - lineno_msg += ' on line ' + (this.yylineno + 1); + _lineno_msg2 += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var _p2 = this.constructLexErrorInfo(_lineno_msg2 + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var pendingInput = this._input; var activeCondition = this.topState(); var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; - if (token === this.ERROR) { + var _token4 = this.parseError(_p2.errStr, _p2, this.JisonLexerError) || this.ERROR; + + if (_token4 === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: @@ -15474,7 +15713,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - return token; + return _token4; } }, @@ -15531,24 +15770,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15575,24 +15814,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15656,9 +15895,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -15674,9 +15913,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -15696,7 +15935,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -15899,10 +16138,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } function transformExpression(e, opts, emit) { - var type = e[0], - value = e[1], - name = false, - has_transformed = 0; + var type = e[0]; + var value = e[1]; + var name = false; + var has_transformed = 0; var list, n; if (type === 'xalias') { @@ -16023,8 +16262,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function transformProduction(id, production, grammar) { var transform_opts = optsForProduction(id, grammar); return production.map(function (handle) { - var action = null, - opts = null; + var action = null; + var opts = null; var i, len, n; if (typeof handle !== 'string') { @@ -16118,7 +16357,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } // now scan the action for all named and numeric semantic values ($nonterminal / $1 / @1, ##1, ...) // // Note that `#name` are straight **static** symbol translations, which are okay as they don't - // require access to the parse stack: `#n` references can be resolved completely + // require access to the parse stack: `#n` references can be resolved completely // at grammar compile time. // @@ -16165,9 +16404,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (ret.length === 1) { return ret[0]; - } else { - return ret; } + + return ret; }); } @@ -16711,16 +16950,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi switch (yystate) { case 0: /*! Production:: $accept : spec $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; - this._$ = yylstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break; case 1: /*! Production:: spec : declaration_list "%%" grammar optional_end_block EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4]; @@ -16734,20 +16973,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 2: /*! Production:: spec : declaration_list "%%" grammar error EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject90(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject91(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 3: /*! Production:: spec : declaration_list error EOF */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject91(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject92(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); break; case 4: @@ -16764,21 +17003,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 133: /*! Production:: optional_module_code_chunk : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject92(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject93(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); } this.$ = yyvstack[yysp]; @@ -16789,8 +17028,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 10: /*! Production:: declaration_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -16800,14 +17039,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 8: /*! Production:: optional_action_header_block : optional_action_header_block include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject93(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject94(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); } yy.addDeclaration(this.$, { @@ -16817,8 +17056,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 9: /*! Production:: declaration_list : declaration_list declaration */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -16826,18 +17065,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 11: /*! Production:: declaration_list : declaration_list error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject94(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject95(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 12: /*! Production:: declaration : START id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { start: yyvstack[yysp] @@ -16846,8 +17085,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 13: /*! Production:: declaration : LEX_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { lex: { @@ -16859,8 +17098,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 14: /*! Production:: declaration : operator */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { operator: yyvstack[yysp] @@ -16869,8 +17108,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 15: /*! Production:: declaration : TOKEN full_token_definitions */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { token_list: yyvstack[yysp] @@ -16879,13 +17118,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 16: /*! Production:: declaration : ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject95(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject96(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); } this.$ = { @@ -16895,13 +17134,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 17: /*! Production:: declaration : include_macro_code */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject96(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject97(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); } this.$ = { @@ -16911,8 +17150,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 18: /*! Production:: declaration : parse_params */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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] @@ -16921,8 +17160,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 19: /*! Production:: declaration : parser_type */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { parserType: yyvstack[yysp] @@ -16931,8 +17170,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 20: /*! Production:: declaration : options */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { options: yyvstack[yysp] @@ -16941,8 +17180,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 21: /*! Production:: declaration : DEBUG */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { options: [['debug', true]] @@ -16951,8 +17190,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 22: /*! Production:: declaration : EBNF */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) ebnf = true; this.$ = { @@ -16962,8 +17201,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 23: /*! Production:: declaration : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { unknownDecl: yyvstack[yysp] @@ -16972,8 +17211,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 24: /*! Production:: declaration : IMPORT import_name import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { imports: { @@ -16985,31 +17224,31 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 25: /*! Production:: declaration : IMPORT import_name error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject97(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject98(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 26: /*! Production:: declaration : IMPORT error import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject98(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject99(), 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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(_templateObject99(), $init_code_name, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject100(), $init_code_name, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); } this.$ = { @@ -17022,41 +17261,41 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 28: /*! Production:: declaration : INIT_CODE error action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject100(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject101(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]))); break; case 29: /*! Production:: declaration : START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject101(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject102(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 30: /*! Production:: declaration : TOKEN error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject102(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject103(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 31: /*! Production:: declaration : IMPORT error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject103(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject104(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 32: @@ -17136,8 +17375,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 132: /*! Production:: optional_module_code_chunk : module_code_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -17147,30 +17386,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 111: /*! Production:: action_ne : "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1]; break; case 40: /*! Production:: options : OPTIONS error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject104(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject105(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]))); break; case 41: /*! Production:: options : OPTIONS error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject105(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject106(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 42: @@ -17181,8 +17420,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 70: /*! Production:: id_list : id_list id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push(yyvstack[yysp]); @@ -17199,24 +17438,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 84: /*! Production:: handle_list : handle_action */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 44: /*! Production:: option : NAME */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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], true]; break; case 45: /*! Production:: option : NAME "=" OPTION_STRING_VALUE */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]]; break; @@ -17226,30 +17465,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 47: /*! Production:: option : NAME "=" NAME */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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], parseValue$1(yyvstack[yysp])]; break; case 48: /*! Production:: option : NAME "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject106(), yyvstack[yysp - 2], yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject107(), yyvstack[yysp - 2], yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 49: /*! Production:: option : NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject107(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject108(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 50: @@ -17257,36 +17496,36 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 52: /*! Production:: parser_type : PARSER_TYPE symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; break; case 51: /*! Production:: parse_params : PARSE_PARAM error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject108(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject109(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 53: /*! Production:: parser_type : PARSER_TYPE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject109(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject110(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 54: /*! Production:: operator : associativity token_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push.apply(this.$, yyvstack[yysp]); @@ -17294,42 +17533,42 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 55: /*! Production:: operator : associativity error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject110(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject111(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 56: /*! Production:: associativity : LEFT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = 'left'; break; case 57: /*! Production:: associativity : RIGHT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = 'right'; break; case 58: /*! Production:: associativity : NONASSOC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = 'nonassoc'; break; case 61: /*! Production:: full_token_definitions : optional_token_type id_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -17352,8 +17591,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 62: /*! Production:: full_token_definitions : optional_token_type one_full_token */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -17366,8 +17605,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 63: /*! Production:: one_full_token : id token_value token_description */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { id: yyvstack[yysp - 2], @@ -17378,8 +17617,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 64: /*! Production:: one_full_token : id token_description */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { id: yyvstack[yysp - 1], @@ -17389,8 +17628,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 65: /*! Production:: one_full_token : id token_value */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { id: yyvstack[yysp - 1], @@ -17400,16 +17639,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 66: /*! Production:: optional_token_type : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = false; break; case 72: /*! Production:: grammar : optional_action_header_block production_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.grammar = yyvstack[yysp]; @@ -17417,8 +17656,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 73: /*! Production:: production_list : production_list production */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -17432,8 +17671,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 74: /*! Production:: production_list : production */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = {}; this.$[yyvstack[yysp][0]] = yyvstack[yysp][1]; @@ -17441,36 +17680,36 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 75: /*! Production:: production : production_id handle_list ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1]]; break; case 76: /*! Production:: production : production_id error ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject111(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject112(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 77: /*! Production:: production : production_id error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject112(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject113(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 78: /*! Production:: production_id : id optional_production_description ":" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; // TODO: carry rule description support into the parser generator... @@ -17478,36 +17717,36 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 79: /*! Production:: production_id : id optional_production_description error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject113(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject114(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 80: /*! Production:: production_id : id optional_production_description ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject114(), $id, yyvstack[yysp - 2], yyvstack[yysp], yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject115(), $id, yyvstack[yysp - 2], yyvstack[yysp], yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 82: /*! Production:: optional_production_description : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) break; case 83: /*! Production:: handle_list : handle_list "|" handle_action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; this.$.push(yyvstack[yysp]); @@ -17515,28 +17754,28 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 85: /*! Production:: handle_list : handle_list "|" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject115(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject116(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 86: /*! Production:: handle_list : handle_list ":" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject116(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject117(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 87: /*! Production:: handle_action : handle prec action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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(' ') : '']; @@ -17544,7 +17783,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject117(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject118(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); } this.$.push(yyvstack[yysp]); @@ -17552,7 +17791,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (yyvstack[yysp - 1]) { if (yyvstack[yysp - 2].length === 0) { - yyparser.yyError(rmCommonWS$3(_templateObject118(), yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp] + 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! */ ))); } @@ -17568,8 +17807,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 88: /*! Production:: handle_action : EPSILON action */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = ['']; @@ -17577,7 +17816,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject119(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject120(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); } this.$.push(yyvstack[yysp]); @@ -17591,18 +17830,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 89: /*! Production:: handle_action : EPSILON error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject120(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject121(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 90: /*! Production:: handle : handle suffixed_expression */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push(yyvstack[yysp]); @@ -17610,16 +17849,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 91: /*! Production:: handle : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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 92: /*! Production:: handle_sublist : handle_sublist "|" handle */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; this.$.push(yyvstack[yysp].join(' ')); @@ -17627,16 +17866,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 93: /*! Production:: handle_sublist : handle */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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].join(' ')]; break; case 94: /*! Production:: suffixed_expression : expression suffix ALIAS */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + "[" + yyvstack[yysp] + "]"; break; @@ -17649,24 +17888,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 130: /*! Production:: module_code_chunk : module_code_chunk CODE */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + yyvstack[yysp]; break; case 97: /*! Production:: expression : EOF_ID */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '$end'; break; case 98: /*! Production:: expression : STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // Re-encode the string *anyway* as it will // be made part of the rule rhs a.k.a. production (type: *string*) again and we want // to be able to handle all tokens, including *significant space* @@ -17677,25 +17916,25 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 99: /*! Production:: expression : "(" handle_sublist ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1].join(' | ') + ')'; break; case 100: /*! Production:: expression : "(" handle_sublist error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject121(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject122(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 105: /*! Production:: prec : PREC symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { prec: yyvstack[yysp] @@ -17704,76 +17943,76 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 106: /*! Production:: prec : PREC error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject122(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject123(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 107: /*! Production:: prec : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = null; break; case 112: /*! Production:: action_ne : "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject123(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject124(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 116: /*! Production:: action : ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 120: /*! Production:: action_body : action_body "{" action_body "}" action_comments_body */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4] + yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; break; case 121: /*! Production:: action_body : action_body "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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 - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; break; case 122: /*! Production:: action_body : action_body "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject124(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject125(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 126: /*! Production:: extra_parser_module_code : optional_module_code_chunk include_macro_code extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + yyvstack[yysp]; break; case 127: /*! Production:: include_macro_code : INCLUDE PATH */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -17781,7 +18020,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var rv = checkActionBlock$2(fileContent); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject125(), $PATH, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject126(), $PATH, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); } // And no, we don't support nested '%include': @@ -17790,21 +18029,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 128: /*! Production:: include_macro_code : INCLUDE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject126()) + yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])); + yyparser.yyError(rmCommonWS$3(_templateObject127()) + yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])); break; case 131: /*! Production:: module_code_chunk : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject127()) + yylexer.prettyPrintRange(yylstack[yysp])); + yyparser.yyError(rmCommonWS$3(_templateObject128()) + yylexer.prettyPrintRange(yylstack[yysp])); break; } }, @@ -17881,20 +18120,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + var ASSERT = typeof assert !== 'function' ? function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : assert; this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -17927,13 +18160,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + var _dst3 = {}; + shallow_copy_noclobber(_dst3, src); + return _dst3; + } } return src; @@ -17950,10 +18184,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (chk.call(src, k)) { dst[k] = src[k]; } - } else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -18122,11 +18354,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (var _i6 = this.__error_recovery_infos.length - 1; _i6 >= 0; _i6--) { + var _el2 = this.__error_recovery_infos[_i6]; - if (el && typeof el.destroy === 'function') { - el.destroy(); + if (_el2 && typeof _el2.destroy === 'function') { + _el2.destroy(); } } @@ -18154,10 +18386,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; + var i1 = first_index | 0; + var i2 = last_index | 0; + var l1 = first_yylloc; + var l2 = last_yylloc; var rv; // rules: // - first/last yylloc entries override first/last indexes @@ -18175,8 +18407,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { - l2 = lstack[i]; + for (var _i7 = i2; _i7 >= i1; _i7--) { + l2 = lstack[_i7]; if (l2) { break; @@ -18189,8 +18421,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 i = (i1 || sp) - 1; i >= 0; i--) { - l1 = lstack[i]; + for (var _i8 = (i1 || sp) - 1; _i8 >= 0; _i8--) { + l1 = lstack[_i8]; if (l1) { break; @@ -18203,30 +18435,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; - } + return null; + } // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + + rv = this.copy_yylloc(l2); return rv; + } // shallow-copy L1, then adjust first col/row 1 column past the end. + + + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; } + + return rv; } if (!l1) { @@ -18235,7 +18467,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... @@ -18285,6 +18517,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -18367,11 +18605,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty - } + { + var i; + + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty + } - rv.base_pointer = i; - rv.info_stack_pointer = i; + rv.base_pointer = i; + rv.info_stack_pointer = i; + } rv.root_failure_pointer = rv.stack_pointer; // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_recovery_infos.push(rv); @@ -18457,9 +18699,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi while (stack_probe >= 0) { // check for error recovery rule in this state - var t = table[state] && table[state][TERROR] || NO_ACTION; + var _t2 = table[state] && table[state][TERROR] || NO_ACTION; - if (t[0]) { + if (_t2[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must // prevent the core from running forever, @@ -18622,7 +18864,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: @@ -18678,7 +18920,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errSymbolDescr: errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -18697,7 +18939,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi yyval.$ = recoveringErrorInfo; yyval._$ = undefined; yyrulelen = error_rule_depth; - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + var combineState = NO_ACTION[1]; + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -18754,9 +18997,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); var errorSymbolFromParser = true; for (;;) { @@ -18789,7 +19032,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // and take it from there! if (!action) { - ASSERT(recoveringErrorInfo, "line 1087"); // Prep state variables so that upon breaking out of + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` // statement in the outer "fast parse loop" we redo // the exact same state table lookup as the one above @@ -18824,12 +19067,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -18871,7 +19114,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; // read action for current state and first input @@ -18901,7 +19144,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; @@ -18961,15 +19204,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -19023,7 +19268,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; @@ -19065,25 +19310,25 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + var _tokenName2 = this.getSymbolName(symbol || EOF); - if (!tokenName) { - tokenName = symbol; + if (!_tokenName2) { + _tokenName2 = symbol; } Jison.parserDebugger.push({ action: 'shift', text: lexer.yytext, - terminal: tokenName, + terminal: _tokenName2, terminal_id: symbol }); } ++sp; symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc = this.copy_yylloc(lexer.yylloc); @@ -19091,9 +19336,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... @@ -19101,25 +19346,28 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; + var _prereduceValue2 = vstack.slice(sp - yyrulelen, sp); - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); - debuggableProductions.push(debuggableProduction); + var _debuggableProductions2 = []; + + for (var _debugIdx2 = yyrulelen - 1; _debugIdx2 >= 0; _debugIdx2--) { + var _debuggableProduction2 = getNonTerminalFromCode(stack[sp - _debugIdx2]); + + _debuggableProductions2.push(_debuggableProduction2); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + var _currentNonterminalCode2 = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + + var _currentNonterminal2 = getNonTerminalFromCode(_currentNonterminalCode2); - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', - nonterminal: currentNonterminal, - nonterminal_id: currentNonterminalCode, - prereduce: prereduceValue, + nonterminal: _currentNonterminal2, + nonterminal_id: _currentNonterminalCode2, + prereduce: _prereduceValue2, result: r, - productions: debuggableProductions, + productions: _debuggableProductions2, text: yyval.$ }); } @@ -19141,15 +19389,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var _ntsymbol2 = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = _ntsymbol2; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][_ntsymbol2]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -19658,6 +19908,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -20039,9 +20293,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -20051,8 +20305,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -20128,12 +20382,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi */ pastInput: function lexer_pastInput(maxSize, maxLines) { var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) maxSize = Infinity;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substr` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = Infinity; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: @@ -20150,8 +20414,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -20177,20 +20441,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { var next = this.match; var source = this._input || ''; - if (maxSize < 0) maxSize = next.length + source.length;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substring` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = next.length + source.length; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + if (next.length < maxSize * 2 + 2) { next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8 } // now that we have a significantly reduced string to process, transform the newlines @@ -20515,7 +20789,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + var backup; if (this.options.backtrack_lexer) { // save context @@ -20543,9 +20817,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + var match_str = match[0]; + var match_str_len = match_str.length; + var lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -20571,7 +20845,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] + var token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */ ); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -20617,8 +20891,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -20650,65 +20922,73 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; // 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! + { + var rule_ids = spec.rules; + var regexes = spec.__rule_regexes; + var len = spec.__rule_count; + var match; + var index; // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + for (var i = 1; i <= len; i++) { + var tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + var token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + var _token5 = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + if (_token5 !== false) { + return _token5; + } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + var _lineno_msg3 = 'Lexical error'; if (this.yylloc) { - lineno_msg += ' on line ' + (this.yylineno + 1); + _lineno_msg3 += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var _p3 = this.constructLexErrorInfo(_lineno_msg3 + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var pendingInput = this._input; var activeCondition = this.topState(); var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; - if (token === this.ERROR) { + var _token6 = this.parseError(_p3.errStr, _p3, this.JisonLexerError) || this.ERROR; + + if (_token6 === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: @@ -20720,7 +21000,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - return token; + return _token6; } }, @@ -20777,24 +21057,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -20821,24 +21101,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -20902,9 +21182,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -20920,9 +21200,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -20942,7 +21222,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -21185,7 +21465,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */ - this.warn(rmCommonWS(_templateObject128(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); + this.warn(rmCommonWS(_templateObject129(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); yy_.yytext = [// {NAME} this.matches[1], // optional value/parameters this.matches[2].trim()]; @@ -21306,42 +21586,42 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Conditions:: action */ /*! Rule:: " */ - yy_.yyerror(rmCommonWS(_templateObject129()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject130()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 82: /*! Conditions:: action */ /*! Rule:: ' */ - yy_.yyerror(rmCommonWS(_templateObject130()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject131()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 83: /*! Conditions:: action */ /*! Rule:: ` */ - yy_.yyerror(rmCommonWS(_templateObject131()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject132()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 84: /*! Conditions:: option_values */ /*! Rule:: " */ - yy_.yyerror(rmCommonWS(_templateObject132()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject133()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 85: /*! Conditions:: option_values */ /*! Rule:: ' */ - yy_.yyerror(rmCommonWS(_templateObject133()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject134()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 86: /*! Conditions:: option_values */ /*! Rule:: ` */ - yy_.yyerror(rmCommonWS(_templateObject134()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject135()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 87: @@ -21349,7 +21629,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Rule:: " */ var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject135(), rules) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject136(), rules) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 88: @@ -21357,7 +21637,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Rule:: ' */ var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject136(), rules) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject137(), rules) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 89: @@ -21365,7 +21645,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Rule:: ` */ var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject137(), rules) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject138(), rules) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 90: @@ -21374,7 +21654,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Rule:: . */ /* b0rk on bad characters */ - yy_.yyerror(rmCommonWS(_templateObject138(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject139(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); return 2; default: @@ -22111,8 +22391,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // which MAY get corrupted that way as their actual content would change then! // construct fake nesting levels to arrive at the intended start indent value: `num` var nesting_levels = num / 2; - var pre = '// **PRE**', - post = '// **POST**'; + var pre = '// **PRE**'; + var post = '// **POST**'; for (; nesting_levels > 0; nesting_levels--) { pre = 'function x() {\n' + pre; @@ -22150,8 +22430,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // Begin - var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - meta = { + var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; + var meta = { // table of character substitutions '\b': '\\b', '\t': '\\t', @@ -22219,134 +22499,140 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var lex_pre = []; var lex_rules = []; var lex_post = []; - var key, src; - src = raw.lex.macros; - delete raw.lex.macros; + { + var src = raw.lex.macros; + delete raw.lex.macros; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject139())); - var keylen = 0; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4(_templateObject140())); + var keylen = 0; - for (key in src) { - keylen = Math.max(keylen, key.length); - } + for (var key in src) { + keylen = Math.max(keylen, key.length); + } - console.log('macros keylen:', keylen); - keylen = (keylen / 4 | 0) * 4 + 4; - console.log('macros keylen B:', keylen); + console.log('macros keylen:', keylen); + keylen = (keylen / 4 | 0) * 4 + 4; + console.log('macros keylen B:', keylen); - for (key in src) { - lex_pre.push(padRight(key, keylen) + src[key]); - } + for (var _key in src) { + lex_pre.push(padRight(_key, keylen) + src[_key]); + } - lex_pre.push(rmCommonWS$4(_templateObject140())); + lex_pre.push(rmCommonWS$4(_templateObject141())); + } } + { + var _src = raw.lex.unknownDecls; + delete raw.lex.unknownDecls; - src = raw.lex.unknownDecls; - delete raw.lex.unknownDecls; + if (_src && !isEmptyObj(_src)) { + lex_pre.push(rmCommonWS$4(_templateObject142())); - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject141())); + for (var i = 0, len = _src.length; i < len; i++) { + var entry = _src[i]; + var _key2 = entry.name; + var value = entry.value; + lex_pre.push('%' + _key2 + ' ' + value); + } - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; - lex_pre.push('%' + key + ' ' + value); + lex_pre.push(rmCommonWS$4(_templateObject143())); } - - lex_pre.push(rmCommonWS$4(_templateObject142())); } + { + var _src2 = raw.lex.options; + delete raw.lex.options; - src = raw.lex.options; - delete raw.lex.options; - - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject143())); + if (_src2 && !isEmptyObj(_src2)) { + lex_pre.push(rmCommonWS$4(_templateObject144())); - for (key in src) { - var value = src[key]; + for (var _key3 in _src2) { + var _value = _src2[_key3]; - if (value) { - lex_pre.push('%options ' + key + '=' + value); - } else { - lex_pre.push('%options ' + key); + if (_value) { + lex_pre.push('%options ' + _key3 + '=' + _value); + } else { + lex_pre.push('%options ' + _key3); + } } } } + { + var _src3 = raw.lex.startConditions; + delete raw.lex.startConditions; - src = raw.lex.startConditions; - delete raw.lex.startConditions; - - if (src && !isEmptyObj(src)) { - for (key in src) { - var value = src[key]; - lex_pre.push((value ? '%x ' : '%s ') + key); + if (_src3 && !isEmptyObj(_src3)) { + for (var _key4 in _src3) { + var _value2 = _src3[_key4]; + lex_pre.push((_value2 ? '%x ' : '%s ') + _key4); + } } } + { + var _src4 = raw.lex.actionInclude; + delete raw.lex.actionInclude; - src = raw.lex.actionInclude; - delete raw.lex.actionInclude; - - if (src && src.trim()) { - lex_pre.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + if (_src4 && _src4.trim()) { + lex_pre.push('%{\n' + indentAction(_src4.trim(), 4) + '\n%}'); + } } + { + var _src5 = raw.lex.rules; + delete raw.lex.rules; - src = raw.lex.rules; - delete raw.lex.rules; - - if (src) { - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - key = entry[0]; - var action = indentAction(entry[1], 4); - var actionHasLF = /[\r\n]/.test(action); - console.log('indented action:', { - entry: entry[1], - action: action, - actionHasLF: actionHasLF - }); + if (_src5) { + for (var _i9 = 0, _len2 = _src5.length; _i9 < _len2; _i9++) { + var _entry = _src5[_i9]; + var _key5 = _entry[0]; + var action = indentAction(_entry[1], 4); + var actionHasLF = /[\r\n]/.test(action); + console.log('indented action:', { + entry: _entry[1], + action: action, + actionHasLF: actionHasLF + }); - if (key.length <= 12) { - if (!actionHasLF) { - lex_rules.push(padRight(key, 16) + indentAction(action, 16)); - } else { - lex_rules.push(padRight(key, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); - } - } else { - if (!actionHasLF) { - lex_rules.push(key, makeIndent(16) + indentAction(action, 16)); + if (_key5.length <= 12) { + if (!actionHasLF) { + lex_rules.push(padRight(_key5, 16) + indentAction(action, 16)); + } else { + lex_rules.push(padRight(_key5, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + } + } else if (!actionHasLF) { + lex_rules.push(_key5, makeIndent(16) + indentAction(action, 16)); } else { - lex_rules.push(key, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + lex_rules.push(_key5, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } } } + { + var _src6 = raw.lex.moduleInclude; + delete raw.lex.moduleInclude; - src = raw.lex.moduleInclude; - delete raw.lex.moduleInclude; - - if (src && src.trim()) { - lex_post.push(indentAction(src.trim(), 0)); + if (_src6 && _src6.trim()) { + lex_post.push(indentAction(_src6.trim(), 0)); + } } + { + var out = ''; - var out = ''; + 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, '*\\/')); + } - if (!isEmptyObj(raw.lex)) { - // dump the remainder as a comment: - var rem = JSON5__default['default'].stringify(raw.lex, null, 2); - out += rmCommonWS$4(_templateObject144(), rem.replace(/\*\//g, '*\\/')); - } + delete raw.lex; + out += lex_pre.join('\n') + '\n\n'; + out += rmCommonWS$4(_templateObject146()) + lex_rules.join('\n') + '\n\n'; - delete raw.lex; - out += lex_pre.join('\n') + '\n\n'; - out += rmCommonWS$4(_templateObject145()) + lex_rules.join('\n') + '\n\n'; + if (lex_post.length > 0) { + out += rmCommonWS$4(_templateObject147()) + lex_post.join('\n') + '\n\n'; + } - if (lex_post.length > 0) { - out += rmCommonWS$4(_templateObject146()) + lex_post.join('\n') + '\n\n'; + lex_out_str = out; } - - lex_out_str = out; } var grammar_pre = []; @@ -22354,7 +22640,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var ebnf_rules = []; var bnf_rules = []; var grammar_post = []; - var key, src; var fmtprod = function fmtprod(rule, prodset) { var backup = deepClone(prodset); @@ -22392,12 +22677,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } if (typeof prodset[1] === 'string') { - var action = prodset[1]; + var _action = prodset[1]; if (lead.length < 12 - 1) { - rule += makeIndent(12 - lead.length) + indentAction('{ ' + action + ' }', 12); + rule += makeIndent(12 - lead.length) + indentAction('{ ' + _action + ' }', 12); } else { - rule += '\n' + makeIndent(12) + indentAction('{ ' + action + ' }', 12); + rule += '\n' + makeIndent(12) + indentAction('{ ' + _action + ' }', 12); } delete prodset[1]; @@ -22413,72 +22698,71 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; var grammarfmt = function grammarfmt(src) { - var key; var dst = []; - for (key in src) { - var prodset = src[key]; - var rule; + for (var _key6 in src) { + var prodset = src[_key6]; + var rule = void 0; console.log('format one rule:', { - key: key, + key: _key6, prodset: prodset }); if (typeof prodset === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; - delete src[key]; + rule = fmtprod(_key6 + ' : ', [prodset]) + ';'; + delete src[_key6]; } else if (prodset instanceof Array) { if (prodset.length === 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; - delete src[key]; + rule = fmtprod(_key6 + ' : ', [prodset]) + ';'; + delete src[_key6]; } else if (prodset[0] instanceof Array) { - rule = fmtprod(key + ' : ', prodset[0]); + rule = fmtprod(_key6 + ' : ', prodset[0]); rule += '\n ;'; if (prodset[0].length === 0) { - delete src[key]; + delete src[_key6]; } } else { - rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; + rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } } else if (prodset.length > 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + '\n : ', [prodset[0]]); + rule = fmtprod(_key6 + '\n : ', [prodset[0]]); delete prodset[0]; } else if (prodset[0] instanceof Array) { - rule = fmtprod(key + '\n : ', prodset[0]); + rule = fmtprod(_key6 + '\n : ', prodset[0]); if (prodset[0].length === 0) { delete prodset[0]; } } else { - rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; + rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - for (var i = 1, len = prodset.length; i < len; i++) { - if (typeof prodset[i] === 'string') { - rule += fmtprod('\n | ', [prodset[i]]); - delete prodset[i]; - } else if (prodset[i] instanceof Array) { - rule += fmtprod('\n | ', prodset[i]); + 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]); - if (prodset[i].length === 0) { - delete prodset[i]; + if (prodset[_i10].length === 0) { + delete prodset[_i10]; } } else { - rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[i]; + rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[_i10]; } } rule += '\n ;'; if (isEmptyArr(prodset)) { - delete src[key]; + delete src[_key6]; } } } else { - rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; + rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; } dst.push(rule); @@ -22487,313 +22771,333 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return dst; }; - src = raw.ebnf; + { + var _src7 = raw.ebnf; - if (src) { - ebnf_rules = grammarfmt(src); + if (_src7) { + ebnf_rules = grammarfmt(_src7); - if (isEmptyObj(src)) { - delete raw.ebnf; + if (isEmptyObj(_src7)) { + delete raw.ebnf; + } } } + { + var _src8 = raw.bnf; //delete raw.bnf; - src = raw.bnf; //delete raw.bnf; - - if (src) { - bnf_rules = grammarfmt(src); + if (_src8) { + bnf_rules = grammarfmt(_src8); - if (isEmptyObj(src)) { - delete raw.bnf; + if (isEmptyObj(_src8)) { + delete raw.bnf; + } } } + { + var _src9 = raw.unknownDecls; + delete raw.unknownDecls; - src = raw.unknownDecls; - delete raw.unknownDecls; + if (_src9 && !isEmptyObj(_src9)) { + lex_pre.push(rmCommonWS$4(_templateObject148())); - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject147())); + for (var _i11 = 0, _len4 = _src9.length; _i11 < _len4; _i11++) { + var _entry2 = _src9[_i11]; + var _key7 = _entry2.name; + var _value3 = _entry2.value; + lex_pre.push('%' + _key7 + ' ' + _value3); + } - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; - lex_pre.push('%' + key + ' ' + value); + lex_pre.push(rmCommonWS$4(_templateObject149())); } - - lex_pre.push(rmCommonWS$4(_templateObject148())); - } //src = raw.lex; + } //let src = raw.lex; //delete raw.lex; //if (src) { - if (lex_out_str.trim() && options.showLexer) { - grammar_pre.push(rmCommonWS$4(_templateObject149(), lex_out_str)); + grammar_pre.push(rmCommonWS$4(_templateObject150(), lex_out_str)); } - src = raw.options; - delete raw.options; + { + var _src10 = raw.options; + delete raw.options; - if (src && !isEmptyObj(src)) { - var a = []; + if (_src10 && !isEmptyObj(_src10)) { + var a = []; - for (key in src) { - var value = src[key]; + for (var _key8 in _src10) { + var _value4 = _src10[_key8]; - switch (key) { - default: - if (value !== true) { - a.push('options', '%options ' + key + '=' + value); - } else { - a.push('options', '%options ' + key); - } + switch (_key8) { + default: + if (_value4 !== true) { + a.push('options', '%options ' + _key8 + '=' + _value4); + } else { + a.push('options', '%options ' + _key8); + } - break; + break; - case 'ebnf': - if (value) { - a.push(key, '%ebnf'); - } + case 'ebnf': + if (_value4) { + a.push(_key8, '%ebnf'); + } - break; + break; - case 'type': - if (value) { - a.push(key, '%parser-type ' + value); - } + case 'type': + if (_value4) { + a.push(_key8, '%parser-type ' + _value4); + } - break; + break; - case 'debug': - if (typeof value !== 'boolean') { - a.push(key, '%debug ' + value); - } else if (value) { - a.push(key, '%debug'); - } + case 'debug': + if (typeof _value4 !== 'boolean') { + a.push(_key8, '%debug ' + _value4); + } else if (_value4) { + a.push(_key8, '%debug'); + } - break; + break; + } } - } - var type = null; + var type = null; - for (var i = 0, len = a.length; i < len; i += 2) { - var t = a[i]; - var line = a[i + 1]; + for (var _i12 = 0, _len5 = a.length; _i12 < _len5; _i12 += 2) { + var t = a[_i12]; + var line = a[_i12 + 1]; + + if (t !== type) { + type = t; + grammar_pre.push(''); + } - if (t !== type) { - type = t; - grammar_pre.push(''); + grammar_pre.push(line); } - grammar_pre.push(line); + grammar_pre.push(''); } - - grammar_pre.push(''); } + { + var _src11 = raw.imports; - src = raw.imports; - - if (src) { - var clean = true; + if (_src11) { + var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - grammar_pre.push('%import ' + entry.name + ' ' + entry.path); - delete entry.name; - delete entry.path; + for (var _i13 = 0, _len6 = _src11.length; _i13 < _len6; _i13++) { + var _entry3 = _src11[_i13]; + grammar_pre.push('%import ' + _entry3.name + ' ' + _entry3.path); + delete _entry3.name; + delete _entry3.path; - if (isEmptyObj(entry)) { - delete src[i]; - } else { - clean = false; + if (isEmptyObj(_entry3)) { + delete _src11[_i13]; + } else { + clean = false; + } } - } - if (clean) { - delete raw.imports; + if (clean) { + delete raw.imports; + } } } + { + var _src12 = raw.moduleInit; - src = raw.moduleInit; - - if (src) { - var clean = true; + if (_src12) { + var _clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - grammar_pre.push('%code ' + entry.qualifier + ' ' + entry.include); - delete entry.qualifier; - delete entry.include; + for (var _i14 = 0, _len7 = _src12.length; _i14 < _len7; _i14++) { + var _entry4 = _src12[_i14]; + grammar_pre.push('%code ' + _entry4.qualifier + ' ' + _entry4.include); + delete _entry4.qualifier; + delete _entry4.include; - if (isEmptyObj(entry)) { - delete src[i]; - } else { - clean = false; + if (isEmptyObj(_entry4)) { + delete _src12[_i14]; + } else { + _clean = false; + } } - } - if (clean) { - delete raw.moduleInit; + if (_clean) { + delete raw.moduleInit; + } } } + { + var _src13 = raw.operators; - src = raw.operators; + if (_src13) { + var _clean2 = true; - if (src) { - var clean = true; + for (var _i15 = 0, _len8 = _src13.length; _i15 < _len8; _i15++) { + var _entry5 = _src13[_i15]; + var tokens = _entry5[1]; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var tokens = entry[1]; - var line = '%' + entry[0] + ' '; + var _line = '%' + _entry5[0] + ' '; - for (var t = 0, tlen = tokens.length; t < tlen; t++) { - line += ' ' + tokens[t]; - } + for (var _t3 = 0, tlen = tokens.length; _t3 < tlen; _t3++) { + _line += ' ' + tokens[_t3]; + } - grammar_pre.push(line); + grammar_pre.push(_line); - if (entry.length === 2) { - delete src[i]; - } else { - clean = false; + if (_entry5.length === 2) { + delete _src13[_i15]; + } else { + _clean2 = false; + } } - } - if (clean) { - delete raw.operators; + if (_clean2) { + delete raw.operators; + } } } + { + var _src14 = raw.extra_tokens; - src = raw.extra_tokens; + if (_src14) { + var _clean3 = true; - if (src) { - var clean = true; + for (var _i16 = 0, _len9 = _src14.length; _i16 < _len9; _i16++) { + var _entry6 = _src14[_i16]; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var line = '%token ' + entry.id; + var _line2 = '%token ' + _entry6.id; - if (entry.type) { - line += ' <' + entry.type + '>'; - delete entry.type; - } + if (_entry6.type) { + _line2 += ' <' + _entry6.type + '>'; + delete _entry6.type; + } - if (entry.value) { - line += ' ' + entry.value; - delete entry.value; - } + if (_entry6.value) { + _line2 += ' ' + _entry6.value; + delete _entry6.value; + } - if (entry.description) { - line += ' ' + escapeString(entry.description); - delete entry.description; - } + if (_entry6.description) { + _line2 += ' ' + escapeString(_entry6.description); + delete _entry6.description; + } - grammar_pre.push(line); - delete entry.id; + grammar_pre.push(_line2); + delete _entry6.id; - if (isEmptyObj(entry)) { - delete src[i]; - } else { - clean = false; + if (isEmptyObj(_entry6)) { + delete _src14[_i16]; + } else { + _clean3 = false; + } } - } - if (clean) { - delete raw.extra_tokens; + if (_clean3) { + delete raw.extra_tokens; + } } } + { + var _src15 = raw.parseParams; + delete raw.parseParams; - src = raw.parseParams; - delete raw.parseParams; - - if (src) { - grammar_pre.push('%parse-param ' + src.join(' ')); + if (_src15) { + grammar_pre.push('%parse-param ' + _src15.join(' ')); + } } + { + var _src16 = raw.start; + delete raw.start; - src = raw.start; - delete raw.start; - - if (src) { - grammar_pre.push('%start ' + src); + if (_src16) { + grammar_pre.push('%start ' + _src16); + } } + { + var _src17 = raw.moduleInclude; + delete raw.moduleInclude; - src = raw.moduleInclude; - delete raw.moduleInclude; + if (_src17 && _src17.trim()) { + grammar_post.push(indentAction(_src17.trim(), 0)); + } + } + { + var _src18 = raw.actionInclude; + delete raw.actionInclude; - if (src && src.trim()) { - grammar_post.push(indentAction(src.trim(), 0)); + if (_src18 && _src18.trim()) { + grammar_mid.push('%{\n' + indentAction(_src18.trim(), 4) + '\n%}'); + } } + { + var _out = ''; - src = raw.actionInclude; - delete raw.actionInclude; + if (!isEmptyObj(raw)) { + // dump the remainder as a comment: + var _rem = JSON5__default['default'].stringify(raw, null, 2); - if (src && src.trim()) { - grammar_mid.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); - } + _out += rmCommonWS$4(_templateObject151(), _rem.replace(/\*\//g, '*\\/')); // delete raw; + } - var out = ''; + if (!options.showParser) { + _out += lex_out_str; + } else { + _out += grammar_pre.join('\n') + '\n\n'; + _out += rmCommonWS$4(_templateObject152()); - if (!isEmptyObj(raw)) { - // dump the remainder as a comment: - var rem = JSON5__default['default'].stringify(raw, null, 2); - out += rmCommonWS$4(_templateObject150(), rem.replace(/\*\//g, '*\\/')); // delete raw; - } + if (grammar_mid.length > 0) { + _out += grammar_mid.join('\n') + '\n\n'; + } - if (!options.showParser) { - out += lex_out_str; - } else { - out += grammar_pre.join('\n') + '\n\n'; - out += rmCommonWS$4(_templateObject151()); + if (ebnf_rules.length > 0) { + if (bnf_rules.length > 0) { + // dump the original EBNF grammar as source and dump the BNF derivative as COMMENT: + var bnf_deriv = bnf_rules.join('\n\n'); - if (grammar_mid.length > 0) { - out += grammar_mid.join('\n') + '\n\n'; - } + var _a2 = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - if (ebnf_rules.length > 0) { - if (bnf_rules.length > 0) { - // dump the original EBNF grammar as source and dump the BNF derivative as COMMENT: - var bnf_deriv = bnf_rules.join('\n\n'); - var a = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); - out += rmCommonWS$4(_templateObject152(), a.join('\n')); + _out += rmCommonWS$4(_templateObject153(), _a2.join('\n')); + } + + _out += ebnf_rules.join('\n\n') + '\n\n'; + } else if (bnf_rules.length > 0) { + _out += bnf_rules.join('\n\n') + '\n\n'; } - out += ebnf_rules.join('\n\n') + '\n\n'; - } else if (bnf_rules.length > 0) { - out += bnf_rules.join('\n\n') + '\n\n'; + if (grammar_post.length > 0) { + _out += rmCommonWS$4(_templateObject154()) + grammar_post.join('\n') + '\n\n'; + } } - if (grammar_post.length > 0) { - out += rmCommonWS$4(_templateObject153()) + grammar_post.join('\n') + '\n\n'; - } - } + if (options.format === 'json5') { + var _a3 = _out.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - if (options.format === 'json5') { - var a = out.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); - out = rmCommonWS$4(_templateObject154(), options.showParser ? 'grammar' : 'lexer', a.join('\n')); // process the original input once again: this time via JSON5 + _out = rmCommonWS$4(_templateObject155(), options.showParser ? 'grammar' : 'lexer', _a3.join('\n')); // process the original input once again: this time via JSON5 - raw = deepClone(originalInput); + raw = deepClone(originalInput); - if (!options.showLexer) { - delete raw.lex; - out += JSON5__default['default'].stringify(raw, null, 2); - } else if (!options.showParser) { - out += JSON5__default['default'].stringify(raw.lex, null, 2); + if (!options.showLexer) { + delete raw.lex; + _out += JSON5__default['default'].stringify(raw, null, 2); + } else if (!options.showParser) { + _out += JSON5__default['default'].stringify(raw.lex, null, 2); + } } - } - return out; + return _out; + } } // Jison, an LR(0), SLR(1), LARL(1), LR(1) Parser Generator var rmCommonWS$5 = helpers.rmCommonWS; var mkIdentifier$4 = helpers.mkIdentifier; - var code_exec$2 = helpers.exec; - var version$2 = '0.6.2-220'; + var code_exec$1 = helpers.exec; + var version$2 = '0.7.0-220'; var devDebug = 0; function chkBugger$3(src) { @@ -22825,9 +23129,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // 0, 1, 2 outputDebugTables: false, noDefaultResolve: false, - defaultActionMode: ["classic", "merge"], + defaultActionMode: ['classic', 'merge'], // {classic, ast, none, skip}, {classic, ast, merge, none, skip} - testCompileActionCode: "parser:*,lexer:*", + testCompileActionCode: 'parser:*,lexer:*', noTryCatch: false, hasPartialLrUpgradeOnConflict: true, errorRecoveryTokenDiscardCount: 3, @@ -22907,14 +23211,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function mkStdOptions$1() { var h = Object.prototype.hasOwnProperty; - var opts = {}; //var args = Array.prototype.concat.apply([], args); + var opts = {}; //let args = Array.prototype.concat.apply([], args); // clone defaults, so we do not modify those constants? - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len10 = arguments.length, args = new Array(_len10), _key9 = 0; _key9 < _len10; _key9++) { + args[_key9] = arguments[_key9]; } - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(Jison$1.defaultJisonOptions); } else { args.shift(); @@ -23030,10 +23334,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } // now see if we have an overriding option here: - for (var p in o2) { - if (h.call(o2, p)) { - if (typeof o2[p] !== 'undefined') { - opts[p] = o2[p]; + for (var _p4 in o2) { + if (h.call(o2, _p4)) { + if (typeof o2[_p4] !== 'undefined') { + opts[_p4] = o2[_p4]; } } } @@ -23104,7 +23408,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // When both JSON5 and JISON input modes barf a hairball, assume the most important // error is the JISON one (show that one first!), while it MAY be a JSON5 format // error that triggered it (show that one last!). - // + // // Also check for common JISON errors which are obviously never triggered by any // odd JSON5 input format error: when we encounter such an error here, we don't // confuse matters and forget about the JSON5 fail as it's irrelevant: @@ -23221,7 +23525,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi Jison$1.Lexer = RegExpLexer; Jison$1.ebnfParser = ebnfParser; Jison$1.lexParser = lexParser; - Jison$1.codeExec = code_exec$2; + Jison$1.codeExec = code_exec$1; Jison$1.XRegExp = XRegExp__default['default']; Jison$1.recast = recast__default['default']; Jison$1.astUtils = astUtils__default['default']; //Jison.prettier = prettier; @@ -23297,7 +23601,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var Nonterminal = typal.construct({ constructor: function Nonterminal(symbol) { this.symbol = symbol; - this.productions = new Set(); + this.productions = new Set$1(); this.first = []; this.follows = []; this.nullable = false; @@ -23591,10 +23895,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; generator.processGrammar = function processGrammarDef(grammar) { - var bnf = grammar.bnf, - tokens = grammar.tokens, - nonterminals = this.nonterminals = {}, - productions = this.productions; + var bnf = grammar.bnf; + var tokens = grammar.tokens; + var nonterminals = this.nonterminals = {}; + var productions = this.productions; if (!grammar.bnf && grammar.ebnf) { bnf = grammar.bnf = ebnfParser.transform(grammar.ebnf); @@ -23650,11 +23954,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } // Make sure all predefined symbols are unique and *numeric* and do not include predefined tokens JISON already defines to a fixed ID on its own: - delete predefined_symbols['$accept']; - delete predefined_symbols['$end']; - delete predefined_symbols['error']; - delete predefined_symbols['$eof']; - delete predefined_symbols['EOF']; + delete predefined_symbols.$accept; + delete predefined_symbols.$end; + delete predefined_symbols.error; + delete predefined_symbols.$eof; + delete predefined_symbols.EOF; var symdef_uniq_check = {}; // Only these symbols are allowed to have the values 1 or 2: symdef_uniq_check[1] = 'EOF'; @@ -23666,21 +23970,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (typeof v !== 'number') { if (typeof v !== 'string' || v.length !== 1) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a non-numeric symbol ID value must be a single-character string.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a non-numeric symbol ID value must be a single-character string."); } v = v.charCodeAt(0); } - v = v | 0; + v |= 0; if (!v || v < 0) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a symbol ID value must be an integer value, 3 or greater.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a symbol ID value must be an integer value, 3 or greater."); } if (symdef_uniq_check[v]) { if (symdef_uniq_check[v] !== sym) { - throw new Error('Error: `%import symbols `: symbol table contains duplicate ID values for keys \'' + sym + '\' and \'' + symdef_uniq_check[v] + '\''); + throw new Error("Error: `%import symbols `: symbol table contains duplicate ID values for keys '" + sym + "' and '" + symdef_uniq_check[v] + "'"); } } @@ -23781,13 +24085,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi generator.signalUnusedProductions = function () { + var _this3 = this; + var mark = {}; var productions = this.productions; var nonterminals = this.nonterminals; - var i, len, nt, sym; - for (i = 0, len = nonterminals.length; i < len; i++) { - nt = nonterminals[i]; + for (var i = 0, len = nonterminals.length; i < len; i++) { + var nt = nonterminals[i]; assert__default['default'](nt.symbol); mark[nt.symbol] = false; } // scan & mark all visited productions @@ -23804,7 +24109,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi assert__default['default'](p.handle); var rhs = p.handle; - for (var j = 0, len = rhs.length; j < len; j++) { + for (var j = 0, _len11 = rhs.length; j < _len11; j++) { var sym = rhs[j]; assert__default['default'](!sym ? !nonterminals[sym] : true); @@ -23819,8 +24124,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /* this.startSymbol */ ]); // now any production which is not yet marked is *unused*: - for (sym in mark) { - nt = nonterminals[sym]; + var _loop = function _loop(sym) { + var nt = nonterminals[sym]; assert__default['default'](nt); var prods = nt.productions; assert__default['default'](prods); @@ -23837,8 +24142,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!in_use) { // and kill the unused nonterminals: - delete this.nonterminals[sym]; + delete _this3.nonterminals[sym]; } + }; + + for (var sym in mark) { + _loop(sym); } this.unused_productions = productions.filter(function (p) { @@ -23905,7 +24214,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi generator.buildProductions = function buildProductions(bnf, productions, nonterminals, symbols, operators, predefined_symbols, descriptions) { var self = this; - var prods, symbol, symId; + var prods, symId; var productions_ = []; var symbols_ = {}; var descriptions_ = {}; @@ -23921,9 +24230,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.EOF = '$end'; symbols_.$accept = 0; symbols_[this.EOF] = 1; - symbols_['$eof'] = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.$eof = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! - symbols_['EOF'] = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.EOF = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! symbols[0] = '$accept'; symbols[1] = this.EOF; @@ -23933,7 +24242,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi symbols[2] = 'error'; if (predefined_symbols) { - for (symbol in predefined_symbols) { + for (var symbol in predefined_symbols) { symId = predefined_symbols[symbol]; if (symId === true) { @@ -23957,9 +24266,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi usedSymbolIdsLowIndex = (this.options.compressTables | 0) < 2 ? 32 : 3; - for (symbol in predefined_symbols) { - symId = predefined_symbols[symbol]; - addSymbol(symbol); + for (var _symbol in predefined_symbols) { + symId = predefined_symbols[_symbol]; + addSymbol(_symbol); } // reset ID low water mark: nonterminals etc. can be assigned any number, preferably a small/low one! @@ -24018,20 +24327,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function collectLiteralTokensInProduction(handle) { - var rhs, i, sym; + var rhs; try { if (devDebug) ; var maxlen = this.maxTokenLength || Infinity; if (handle.constructor === Array) { - var rhs_i; rhs = typeof handle[0] === 'string' ? splitStringIntoSymbols(handle[0]) : handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; // check for aliased names, e.g., id[alias] and strip them + for (var i = 0; i < rhs.length; i++) { + var sym = rhs[i]; // check for aliased names, e.g., id[alias] and strip them - rhs_i = sym.match(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]$"))); + var rhs_i = sym.match(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]$"))); if (rhs_i) { sym = sym.substr(0, sym.length - rhs_i[0].length); @@ -24046,18 +24354,16 @@ 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 (i = 0; i < rhs.length; i++) { - sym = rhs[i]; + for (var _i17 = 0; _i17 < rhs.length; _i17++) { + var _sym = rhs[_i17]; - if (!bnf[sym] && sym.length <= maxlen) { - addSymbol(sym); + if (!bnf[_sym] && _sym.length <= maxlen) { + addSymbol(_sym); } } } } catch (ex) { - console.error(ex, '\ncollectLiteralTokensInProduction: ', symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { - i: i, - sym: sym, + console.error(ex, '\ncollectLiteralTokensInProduction: ', this.symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { rhs: rhs }); throw ex; @@ -24070,33 +24376,35 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var prodsLUT = {}; - for (symbol in bnf) { - if (!bnf.hasOwnProperty(symbol)) continue; + for (var _symbol2 in bnf) { + if (!bnf.hasOwnProperty(_symbol2)) continue; - if (typeof bnf[symbol] === 'string') { - prods = bnf[symbol].split(/\s*\|\s*/g); + if (typeof bnf[_symbol2] === 'string') { + prods = bnf[_symbol2].split(/\s*\|\s*/g); } else { - prods = bnf[symbol].slice(0); + prods = bnf[_symbol2].slice(0); } - prodsLUT[symbol] = prods; + prodsLUT[_symbol2] = prods; } // First we collect all single-character literal tokens: - for (symbol in prodsLUT) { - if (!prodsLUT.hasOwnProperty(symbol)) continue; - prods = prodsLUT[symbol]; + for (var _symbol3 in prodsLUT) { + if (!prodsLUT.hasOwnProperty(_symbol3)) continue; + prods = prodsLUT[_symbol3]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: 1 + maxTokenLength: 1, + symbol: _symbol3 }); } // Next we collect all other literal tokens: - for (symbol in prodsLUT) { - if (!prodsLUT.hasOwnProperty(symbol)) continue; - prods = prodsLUT[symbol]; + for (var _symbol4 in prodsLUT) { + if (!prodsLUT.hasOwnProperty(_symbol4)) continue; + prods = prodsLUT[_symbol4]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: Infinity + maxTokenLength: Infinity, + symbol: _symbol4 }); } // and now go and process the entire grammar: // first collect all nonterminals in a symbol table, then build the productions @@ -24105,22 +24413,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // referenced: - for (symbol in bnf) { - if (!bnf.hasOwnProperty(symbol)) continue; - addSymbol(symbol); - nonterminals[symbol] = new Nonterminal(symbol); + for (var _symbol5 in bnf) { + if (!bnf.hasOwnProperty(_symbol5)) continue; + addSymbol(_symbol5); + nonterminals[_symbol5] = new Nonterminal(_symbol5); } // now that we have collected all nonterminals in our symbol table, it's finally // time to process the productions: - for (symbol in prodsLUT) { - if (!prodsLUT.hasOwnProperty(symbol)) continue; - prods = prodsLUT[symbol]; - prods.forEach(buildProduction); + for (var _symbol6 in prodsLUT) { + if (!prodsLUT.hasOwnProperty(_symbol6)) continue; + prods = prodsLUT[_symbol6]; + prods.forEach(buildProduction, { + symbol: _symbol6 + }); } - var terms = [], - terms_ = {}; + var terms = []; + var terms_ = {}; each(symbols_, function (id, sym) { // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number @@ -24145,9 +24455,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi chk_er_opt('parserErrorsAreRecoverable', 'parser-errors-are-recoverable feature/option'); // Hmmmm... why would lexer errors need to be NON-recoverable when there's no ERROR rules in the GRAMMAR?! chk_er_opt('lexerErrorsAreRecoverable', 'lexer-errors-are-recoverable feature/option'); - chk_er_opt('parseActionsUseYYRECOVERING', 'YYRECOVERING macro/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYERROK', 'yyerrok() function/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYCLEARIN', 'yyclearin() function/API in grammar rules\' action code'); + chk_er_opt('parseActionsUseYYRECOVERING', "YYRECOVERING macro/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYERROK', "yyerrok() function/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYCLEARIN', "yyclearin() function/API in grammar rules' action code"); } this.terminals = terms; @@ -24239,23 +24549,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } return tokens; - } + } // options object { symbol } is `this` for this functon/callback: + function buildProduction(handle) { - var r, - rhs, - i, - precedence_override, - aliased = [], - action = null; + var rhs; + var precedence_override = null; + var aliased = []; + var action = null; if (handle.constructor === Array) { - var rhs_i; rhs = typeof handle[0] === 'string' ? splitStringIntoSymbols(handle[0]) : handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { + for (var i = 0; i < rhs.length; i++) { // check for aliased names, e.g., id[alias] and strip them - rhs_i = rhs[i].match(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]$"))); + var rhs_i = rhs[i].match(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]$"))); if (rhs_i) { rhs[i] = rhs[i].substr(0, rhs[i].length - rhs_i[0].length); @@ -24299,17 +24607,17 @@ 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 (i = 0; i < rhs.length; i++) { - if (rhs[i] === 'error') { + for (var _i18 = 0; _i18 < rhs.length; _i18++) { + if (rhs[_i18] === 'error') { hasErrorRecovery = true; } - assert__default['default'](bnf[rhs[i]] ? symbols_[rhs[i]] : true, 'all nonterminals must already exist in the symbol table'); - assert__default['default'](rhs[i] ? symbols_[rhs[i]] : true, 'all symbols (terminals and nonterminals) must already exist in the symbol table'); //addSymbol(rhs[i]); + 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]); } } - r = new Production(symbol, rhs, productions.length + 1, aliased, action); // set precedence + var r = new Production(this.symbol, rhs, productions.length + 1, aliased, action); // set precedence assert__default['default'](r.precedence === 0); @@ -24319,23 +24627,23 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var prec_symbols = []; var winning_symbol; - for (i = r.handle.length - 1; i >= 0; i--) { - if (!(r.handle[i] in nonterminals) && r.handle[i] in operators) { + for (var _i19 = r.handle.length - 1; _i19 >= 0; _i19--) { + if (!(r.handle[_i19] in nonterminals) && r.handle[_i19] in operators) { var old_prec = r.precedence; - var new_prec = operators[r.handle[i]].precedence; + var new_prec = operators[r.handle[_i19]].precedence; if (old_prec !== 0 && old_prec !== new_prec) { - prec_symbols.push(r.handle[i]); // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], symbol, handle[0]); + prec_symbols.push(r.handle[_i19]); // 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[i]; + winning_symbol = r.handle[_i19]; } else { // keep previously set precedence: new_prec = old_prec; } } else if (old_prec === 0) { - prec_symbols.push(r.handle[i]); - winning_symbol = r.handle[i]; // Jison.print('precedence set first time: ', old_prec, r.handle[i], symbol, handle[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]); } r.precedence = new_prec; @@ -24344,14 +24652,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (prec_symbols.length > 1) { if (self.DEBUG || 1) { - self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); + self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + this.symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); } } } productions.push(r); productions_.push([symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length]); - nonterminals[symbol].productions.push(r); + nonterminals[this.symbol].productions.push(r); } }; // Preprocess the action code block before we perform any `$n`, `@n` ,`##n` or `#n` expansions: // Any comment blocks in there should be kept intact (and not cause trouble either as those comments MAY @@ -24423,13 +24731,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // with our pants down in constructs like // `'"' + $$ + '"'` vs. `"'" + $$ + "'"` - var dqpos, - sqpos, - ccmtpos, - cppcmtpos, - first = -1; + var dqpos, sqpos, ccmtpos, cppcmtpos; + var first = -1; - for (var c = 0;; c++) { + for (var _c2 = 0;; _c2++) { first++; dqpos = s.indexOf('"', first); sqpos = s.indexOf("'", first); // also look for remaining comments which contain quotes of any kind, @@ -24463,7 +24768,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi s = s // multiline comment start markers: .replace(/\x01\x84/g, '/*').replace(/\x01\x85/g, '/*').replace(/\x01\x86/g, '//') // revert markers: .replace(/\x01\x81/g, '#').replace(/\x01\x82/g, '$').replace(/\x01\x83/g, '@') // and revert the string and regex markers: - .replace(/\x01\x87/g, '\'').replace(/\x01\x88/g, '\"').replace(/\x01\x89/g, '##').replace(/\x01\x90/g, '\\\\').replace(/\x01\x91/g, '\\\'').replace(/\x01\x92/g, '\\\"').replace(/\x01\x93/g, '\\\/').replace(/\x01\x94/g, 'YYABORT').replace(/\x01\x95/g, 'YYACCEPT').replace(/\x01\x96/g, 'yyvstack').replace(/\x01\x97/g, 'yylstack').replace(/\x01\x98/g, 'yyerror').replace(/\x01\x99/g, 'YYRECOVERING').replace(/\x01\x9A/g, 'yyerrok').replace(/\x01\x9B/g, 'yyclearin').replace(/\x01\x9C/g, 'yysp').replace(/\x01\x9D__/g, 'yy'); // And a final, minimal, fixup for the semicolon-lovers -- like me! ;-) + .replace(/\x01\x87/g, "'").replace(/\x01\x88/g, '\"').replace(/\x01\x89/g, '##').replace(/\x01\x90/g, '\\\\').replace(/\x01\x91/g, "\\'").replace(/\x01\x92/g, '\\\"').replace(/\x01\x93/g, '\\\/').replace(/\x01\x94/g, 'YYABORT').replace(/\x01\x95/g, 'YYACCEPT').replace(/\x01\x96/g, 'yyvstack').replace(/\x01\x97/g, 'yylstack').replace(/\x01\x98/g, 'yyerror').replace(/\x01\x99/g, 'YYRECOVERING').replace(/\x01\x9A/g, 'yyerrok').replace(/\x01\x9B/g, 'yyclearin').replace(/\x01\x9C/g, 'yysp').replace(/\x01\x9D__/g, 'yy'); // And a final, minimal, fixup for the semicolon-lovers -- like me! ;-) // // Make sure the last statement is properly semicolon-terminated 99.9% of the time: @@ -24502,11 +24807,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.productions_ = productions_; assert(this.productions === productions); */ - var productions = this.productions, - nonterminals = this.nonterminals, - symbols = this.symbols, - operators = this.operators, - self = this; // As a SIDE EFFECT of this call, we also fixup + var productions = this.productions; + var nonterminals = this.nonterminals; + var symbols = this.symbols; + var operators = this.operators; + var self = this; // As a SIDE EFFECT of this call, we also fixup // the other code chunks specified in the grammar file: // // Replace direct symbol references, e.g. #NUMBER# when there's a `%token NUMBER` for your grammar. @@ -24537,16 +24842,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi while (gen_hash !== prev_gen_hash) { var preludeCode = preprocessActionCode(this.actionInclude || ''); - var actions = ["\n /* this == yyval */\n\n // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code!\n var yy = this.yy;\n var yyparser = yy.parser;\n var yylexer = yy.lexer;\n\n ".concat(preludeCode, "\n\n switch (yystate) {")]; + var actions = ["\n /* this == yyval */\n\n // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code!\n let yy = this.yy;\n let yyparser = yy.parser;\n let yylexer = yy.lexer;\n\n ".concat(preludeCode, "\n\n switch (yystate) {")]; var actionGroups = {}; // used to combine identical actions into single instances: no use duplicating action code needlessly var actionGroupValue = {}; // stores the unaltered, expanded, user-defined action code for each action group. var stateHasAction = []; // marks which state IDs have an action, either user-specified or default. + // and now go and process the entire grammar: - var symbol; // and now go and process the entire grammar: - - productions.forEach(buildProductionAction); + productions.forEach(buildProductionAction, { + actionGroups: actionGroups, + actionGroupValue: actionGroupValue, + stateHasAction: stateHasAction + }); for (var hash in actionGroups) { actions.push([].concat.apply([], actionGroups[hash]).join('\n') + '\n\n' + actionGroupValue[hash] + '\n break;\n'); @@ -24571,10 +24879,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (missingActions.length) { if (this.DEBUG) { - this.warn("WARNING: missing actions for states: ", missingActions); + this.warn('WARNING: missing actions for states: ', missingActions); } - actions.push("default:\n // default action for all unlisted resolve states: ".concat(missingActions.join(', '), "\n\n // When we hit this entry, it's always a non-recoverable issue as this is a severe internal parser state failure:\n function __b0rk_on_internal_failure(str) {\n var hash = yyparser.constructParseErrorInfo(str, null, null, false);\n\n return yyparser.parseError(str, hash, yyparser.JisonParserError);\n }\n\n return __b0rk_on_internal_failure(\"internal parser failure: resolving unlisted state: \" + yystate);")); + actions.push("default:\n // default action for all unlisted resolve states: ".concat(missingActions.join(', '), "\n\n // When we hit this entry, it's always a non-recoverable issue as this is a severe internal parser state failure:\n function __b0rk_on_internal_failure(str) {\n let hash = yyparser.constructParseErrorInfo(str, null, null, false);\n\n return yyparser.parseError(str, hash, yyparser.JisonParserError);\n }\n\n return __b0rk_on_internal_failure(\"internal parser failure: resolving unlisted state: \" + yystate);")); } actions.push('}'); @@ -24744,9 +25052,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.actionsUseValueAssignment = true; break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": + case 'skip': // <-- this one injects *nothing* break; } @@ -24757,9 +25065,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi default: break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": + case 'skip': // <-- this one injects *nothing* break; } @@ -24831,7 +25139,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi moduleInit.getInitCodeSection = function getInitCodeSection(section) { var rv = []; - for (var i = 0, len = this.length; i < len; i++) { + for (var i = 0, _len12 = this.length; i < _len12; i++) { var m = this[i]; if (m.qualifier === section) { @@ -24849,11 +25157,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi moduleInit.getRemainingInitCodeSections = function getRemainingInitCodeSections() { var rv = []; - for (var i = 0, len = this.length; i < len; i++) { + for (var i = 0, _len13 = this.length; i < _len13; i++) { var m = this[i]; if (!this.__consumedInitCodeSlots__[i]) { - rv.push(rmCommonWS$5(_templateObject155(), m.qualifier, m.include, m.qualifier)); + rv.push(rmCommonWS$5(_templateObject156(), m.qualifier, m.include, m.qualifier)); this.__consumedInitCodeSlots__[i] = true; } } @@ -24930,12 +25238,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return ''; - } + } // options object { actionGroups, actionGroupValue, stateHasAction } is `this` for this function/callback: + function buildProductionAction(handle) { - var i; - var aliased = handle.aliases, - rhs_i; + var aliased = handle.aliases; var rhs = handle.handle; var named_token_re = new XRegExp__default['default']("^".concat(ID_REGEX_BASE$3, "$")); // semantic action specified @@ -24953,7 +25260,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var rule4msg = handle.symbol + ': ' + rhs.join(' '); assert__default['default'](typeof handle.id === 'number'); assert__default['default'](handle.id >= 0); - stateHasAction[handle.id] = true; // before anything else, replace direct symbol references, e.g. #NUMBER# when there's a %token NUMBER for your grammar. + this.stateHasAction[handle.id] = true; // before anything else, replace direct symbol references, e.g. #NUMBER# when there's a %token NUMBER for your grammar. // This is done to prevent incorrect expansions where tokens are used in rules as RHS elements: we allow these to // be referenced as both #TOKEN# and #TOKEN where the first is a literal token/symbol reference (unrelated to its use // in the rule) and the latter is a reference to the token/symbol being used in the rule. @@ -24965,9 +25272,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }); // replace named semantic values ($nonterminal) if (action.match(new XRegExp__default['default']("(?:[$@#]|##)".concat(ID_REGEX_BASE$3)))) { - var count = {}, - names = {}, - donotalias = {}; // When the rule is fitted with aliases it doesn't mean that the action code MUST use those: + var count = {}; + var names = {}; + var donotalias = {}; // When the rule is fitted with aliases it doesn't mean that the action code MUST use those: // we therefor allow access to both the original (non)terminal and the alias. // // Also note that each (non)terminal can also be uniquely addressed by [$@] @@ -24997,7 +25304,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // while `e2` would be ambiguous from the human perspective as he *might* then // expect `e2` and `e3`. - var addName = function addName(s) { + var addName = function addName(s, i) { var base = s.replace(/[0-9]+$/, ''); var dna = donotalias[base]; @@ -25029,9 +25336,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } }; - for (i = 0; i < rhs.length; i++) { + for (var i = 0; i < rhs.length; i++) { // mark both regular and aliased names, e.g., `id[alias1]` and `id1` - rhs_i = aliased[i]; + var rhs_i = aliased[i]; markBasename(rhs_i); if (rhs_i !== rhs[i]) { @@ -25039,13 +25346,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - for (i = 0; i < rhs.length; i++) { + for (var _i20 = 0; _i20 < rhs.length; _i20++) { // check for aliased names, e.g., id[alias] - rhs_i = aliased[i]; - addName(rhs_i); + var _rhs_i = aliased[_i20]; + addName(_rhs_i, _i20); - if (rhs_i !== rhs[i]) { - addName(rhs[i]); + if (_rhs_i !== rhs[_i20]) { + addName(rhs[_i20], _i20); } } @@ -25060,7 +25367,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi action = action // replace references to `$$` with `this.$`, `@$` with `this._$` and `#$` with the token ID of the current rule .replace(/\$\$/g, 'this.$').replace(/@\$/g, 'this._$').replace(/#\$/g, function (_) { - return provideSymbolAsSourcecode(symbol); + return provideSymbolAsSourcecode(handle.symbol); }) // replace semantic value references ($n) with stack value (stack[n]) .replace(/\$(-?\d+)\b/g, function (_, n) { return 'yyvstack[yysp' + indexToJsExpr(n, rhs.length, rule4msg) + ']'; @@ -25184,24 +25491,26 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // $@ = undefined; // - var vmode = !inject_default_value_action ? "skip" : self.options.defaultActionMode[0]; - var lmode = !inject_default_loc_action ? "skip" : self.options.defaultActionMode[1]; // check if there's no user action specified. Insert default action if it isn't. + var vmode = !inject_default_value_action ? 'skip' : self.options.defaultActionMode[0]; + var lmode = !inject_default_loc_action ? 'skip' : self.options.defaultActionMode[1]; // check if there's no user action specified. Insert default action if it isn't. // first determine the actual number of terms in the production: - var rhs = handle.handle.slice(0); + var rhs_reduced_length = rhs.length; var real_rhs_length = rhs.length; // strip away EOF terms at the end of the rule, ditto for epsilon terms: - if (rhs.length) { - switch (rhs[rhs.length - 1]) { + while (rhs_reduced_length) { + switch (rhs[rhs_reduced_length - 1]) { case '$end': - rhs.length--; - break; + rhs_reduced_length--; + continue; case '': // %epsilon - rhs.length--; - break; + rhs_reduced_length--; + continue; } + + break; } // then we can choose what to do, depending on the number of terms in the production. // // There are a few reasons *why* one would choose to inject the default action: @@ -25218,18 +25527,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // - switch (rhs.length) { + switch (rhs_reduced_length) { case 0: switch (vmode) { - case "classic": // $$ = $1; <-- but that would cause nondeterministic behaviour, so + case 'classic': // $$ = $1; <-- but that would cause nondeterministic behaviour, so // we fall back to the default here! - case "ast": - case "none": - default_action.push("this.$ = undefined;"); + case 'ast': + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25238,22 +25547,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // an empty production has no location as there are no terms parsed. // ergo: we produce a zero-width location which points at the tail // end of the previous content: // @$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);"); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25265,19 +25574,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 1: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; // // WARNING: be careful with the ACCEPT rule as that one's production has - // rhs.length === 1 **BUT** has real_rhs_length === 2 as we have discarded + // rhs_reduced_length === 1 **BUT** has real_rhs_length === 2 as we have discarded // the `$end` term at the end! // Here we need to account for that magick though! - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // As we're looking at a production which has one(1) useful term, we can simply // reference-copy that one intom a fresh array, instead of `slice()`-ing it out // of the vstack. @@ -25286,14 +25595,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // WARNING/NOTE: as above, and ditto BTW for rule productions which end with // `EOF` as a last term: as we now construct an entire AST, we DO NOT include // those 'values' here! - default_action.push("this.$ = [yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "]];"); + default_action.push('this.$ = [yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ']];'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25302,23 +25611,23 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: // as we have a production length of 1 only, we can simply ref-copy @1: // @$ = @1; // // WARNING: same as above for the value copying: we may have discarded an `EOF` or `$end` term! - default_action.push("this._$ = yylstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this._$ = yylstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25330,31 +25639,31 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi default: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // - // WARNING: as with the situation further above where rhs.length === 1 after we + // WARNING: as with the situation further above where rhs_reduced_length === 1 after we // have got rid of a possible `EOF` or `$end` at the end of the production, // we again have to account for our trickery earlier and compensate the // action above: again we DO NOT include the value of the EOF/$end token in the // resulting array 'AST', hence our `slice()` end index may vary by one(1): - var end_offset = 1 - real_rhs_length + rhs.length; - default_action.push("this.$ = yyvstack.slice(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp" + ( - /* CANNOT USE indexToJsExpr(rhs.length + 1, real_rhs_length, rule4msg) HERE! */ - end_offset === 0 ? "" : " + " + end_offset) + ");"); + var end_offset = 1 - real_rhs_length + rhs_reduced_length; + default_action.push('this.$ = yyvstack.slice(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp' + ( + /* CANNOT USE indexToJsExpr(rhs_reduced_length + 1, real_rhs_length, rule4msg) HERE! */ + end_offset === 0 ? '' : ' + ' + end_offset) + ');'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25363,20 +25672,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: - // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs.length - 1}, yysp); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp);"); + // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs_reduced_length - 1}, yysp); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25390,7 +25699,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (default_action.length > 0) { - var flags = [rhs.length, self.actionsUseValueTracking ? "VT" : "-", self.actionsUseValueAssignment ? "VA" : "-", uses_$$ ? "VU" : "-", uses_$$_before_assignment ? "VUbA" : "-", self.actionsUseLocationTracking ? "LT" : "-", self.actionsUseLocationAssignment ? "LA" : "-", uses_$loc ? "LU" : "-", uses_$loc_before_assignment ? "LUbA" : "-"].join(','); + var flags = [rhs_reduced_length + '/' + real_rhs_length, self.actionsUseValueTracking ? 'VT' : '-', self.actionsUseValueAssignment ? 'VA' : '-', uses_$$ ? 'VU' : '-', uses_$$_before_assignment ? 'VUbA' : '-', self.actionsUseLocationTracking ? 'LT' : '-', self.actionsUseLocationAssignment ? 'LA' : '-', uses_$loc ? 'LU' : '-', uses_$loc_before_assignment ? 'LUbA' : '-'].join(','); default_action.unshift("// default action (generated by JISON mode ".concat(self.options.defaultActionMode[0], "/").concat(self.options.defaultActionMode[1], " :: ").concat(flags, "):")); default_action.push("// END of default action (generated by JISON mode ".concat(self.options.defaultActionMode[0], "/").concat(self.options.defaultActionMode[1], " :: ").concat(flags, ")")); @@ -25405,11 +25714,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var actionHash = mkHashIndex(action); // Delay running the postprocess (restore) process until we've done ALL macro expansions: //action = postprocessActionCode(action); - if (actionHash in actionGroups) { - actionGroups[actionHash].push(label); + if (actionHash in this.actionGroups) { + this.actionGroups[actionHash].push(label); } else { - actionGroups[actionHash] = [label]; - actionGroupValue[actionHash] = action; + this.actionGroups[actionHash] = [label]; + this.actionGroupValue[actionHash] = action; } } }; @@ -25515,7 +25824,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; // --- START of debugTraceSrc chunk --- - var debugTraceSrc = "\nfunction debug_trace() {\n \"use strict\";\n\n if (typeof Jison !== 'undefined' && Jison.print) {\n Jison.print.apply(null, arguments);\n } else if (typeof print !== 'undefined') {\n print.apply(null, arguments);\n } else if (typeof console !== 'undefined' && console.log) {\n var args = Array.prototype.slice.call(arguments, 0);\n args.unshift(''); // prevent `%.` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args\n console.log.apply(null, args);\n }\n}\n"; // --- END of debugTraceSrc chunk --- + var debugTraceSrc = "\nfunction debug_trace() {\n if (typeof Jison !== 'undefined' && Jison.print) {\n Jison.print.apply(null, arguments);\n } else if (typeof print !== 'undefined') {\n print.apply(null, arguments);\n } else if (typeof console !== 'undefined' && console.log) {\n let args = Array.prototype.slice.call(arguments, 0);\n args.unshift(''); // prevent `%.` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args\n console.log.apply(null, args);\n }\n}\n"; // --- END of debugTraceSrc chunk --- // Generator debug mixin var generatorDebug = { @@ -25582,10 +25891,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi lookaheadMixin.followSets = function followSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true; // loop until no further changes have been made + var productions = this.productions; + var nonterminals = this.nonterminals; + var self = this; + var cont = true; // loop until no further changes have been made while (cont) { cont = false; @@ -25602,7 +25911,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } var bool = !ctx || q === self.nterms_[t]; - var set; + var set = void 0; if (i === production.handle.length - 1 && bool) { set = nonterminals[production.symbol].follows; @@ -25651,25 +25960,25 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi firsts = union(firsts, this.nonterminals[t].first); } - if (!this.nullable(t)) break; + if (!this.nullable(t)) { + break; + } } return firsts; // terminal } else if (!this.nonterminals[symbol]) { return [symbol]; // nonterminal - } else { - return this.nonterminals[symbol].first; } + + return this.nonterminals[symbol].first; }; // fixed-point calculation of FIRST sets lookaheadMixin.firstSets = function firstSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true, - symbol, - firsts; // loop until no further changes have been made + var productions = this.productions; + var nonterminals = this.nonterminals; + var self = this; + var cont = true; // loop until no further changes have been made while (cont) { cont = false; @@ -25682,8 +25991,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } }); - for (symbol in nonterminals) { - firsts = []; + var _loop2 = function _loop2(symbol) { + var firsts = []; nonterminals[symbol].productions.forEach(function FirstSets_forEachNonTerm(production) { firsts = union(firsts, production.first); }); @@ -25692,22 +26001,29 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi nonterminals[symbol].first = firsts; cont = true; } + }; + + for (var symbol in nonterminals) { + _loop2(symbol); } } }; // fixed-point calculation of NULLABLE lookaheadMixin.nullableSets = function nullableSets() { - var nonterminals = this.nonterminals, - self = this, - cont = true; // loop until no further changes have been made + var nonterminals = this.nonterminals; + var self = this; + var cont = true; // loop until no further changes have been made while (cont) { cont = false; // check if each production is nullable this.productions.forEach(function isEachProductionNullable(production, k) { if (!production.nullable) { - for (var i = 0, n = 0, t; t = production.handle[i]; ++i) { + var i = 0; + var n = 0; + + for (var t; t = production.handle[i]; ++i) { if (self.nullable(t)) n++; } @@ -25745,9 +26061,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return true; // terminal } else if (!this.nonterminals[symbol]) { return false; // nonterminal - } else { - return this.nonterminals[symbol].nullable; } + + return this.nonterminals[symbol].nullable; }; // lookahead debug mixin @@ -25849,7 +26165,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return s; } }); - lrGeneratorMixin.ItemSet = Set.prototype.construct({ + lrGeneratorMixin.ItemSet = Set$1.prototype.construct({ afterconstructor: function afterconstructor() { this.reductions = []; this.goes = {}; @@ -25896,12 +26212,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi lrGeneratorMixin.closureOperation = function closureOperation(itemSet) { var closureSet = new this.ItemSet(); var self = this; - var set = itemSet, - itemQueue, - syms = {}; + var set = itemSet; + var itemQueue; + var syms = {}; do { - itemQueue = new Set(); + itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function CO_set_forEach(item) { var symbol = item.markedSymbol; // if token is a non-terminal, recursively add closures @@ -25934,8 +26250,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) { - var gotoSet = new this.ItemSet(), - self = this; + var gotoSet = new this.ItemSet(); + var self = this; itemSet.forEach(function goto_forEach(item, n) { if (item.markedSymbol === symbol) { gotoSet.push(new self.Item(item.production, item.dotPosition + 1, item.follows, n)); @@ -25950,13 +26266,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi lrGeneratorMixin.canonicalCollection = function canonicalCollection() { var item1 = new this.Item(this.productions[0], 0, [this.EOF]); - var firstStateNoClosure = new this.ItemSet(item1), - firstState = this.closureOperation(firstStateNoClosure), - states = new Set(firstState), - marked = 0, - self = this, - itemSet, - markedSymbols; + var firstStateNoClosure = new this.ItemSet(item1); + var firstState = this.closureOperation(firstStateNoClosure); + var states = new Set$1(firstState); + var marked = 0; + var self = this; + var itemSet; + var markedSymbols; states.has = {}; states.has[firstStateNoClosure.valueOf()] = 0; @@ -25977,8 +26293,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert(symbol, itemSet, states, stateNum) { - var g = this.gotoOperation(itemSet, symbol), - state = states.has[g.valueOf()]; + var g = this.gotoOperation(itemSet, symbol); + var state = states.has[g.valueOf()]; if (typeof state !== 'undefined') { itemSet.edges[symbol] = state; // store goto transition for table @@ -26003,12 +26319,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { - var states = [], - nonterminals = this.nonterminals, - operators = this.operators, - conflictedStates = {}, - // set of [state, token] tuples - self = this; // for each item set + var states = []; + var nonterminals = this.nonterminals; + var operators = this.operators; + var conflictedStates = {}; // set of [state, token] tuples + + var self = this; // for each item set itemSets.forEach(function parseTableItem(itemSet, k) { k = +k; @@ -26153,11 +26469,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function findDefaults(states, hasErrorRecovery) { var defaults = {}; states.forEach(function (state, k) { - var act, sym, st; + var act; var i = 0; var gotos = {}; - for (sym in state) { + for (var sym in state) { assert__default['default']({}.hasOwnProperty.call(state, sym)); // it this isn't true, the last part of this function won't work! // keep state rows where there's an error recovery state: @@ -26167,7 +26483,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return; } - st = state[sym]; + var st = state[sym]; if (typeof st !== 'number') { if (st[0] !== REDUCE) { @@ -26203,11 +26519,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // when there's no error recovery code included in the generated parser: if (!hasErrorRecovery) { - for (sym in state) { - st = state[sym]; + for (var _sym2 in state) { + var _st = state[_sym2]; - if (typeof st !== 'number') { - delete state[sym]; + if (typeof _st !== 'number') { + delete state[_sym2]; } } } @@ -26219,9 +26535,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function cleanupTable(table) { table.forEach(function (state, k) { - var symbol; - - for (symbol in state) { + for (var symbol in state) { if (state[symbol] === NONASSOC) { delete state[symbol]; } @@ -26307,7 +26621,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComment() { - var out = "\n/* parser generated by jison ".concat(version$2, " */\n\n/*\n * Returns a Parser object of the following structure:\n *\n * Parser: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" `yy` passed around to\n * the rule actions, etc. is a derivative/copy of this one,\n * not a direct reference!\n * }\n *\n * Parser.prototype: {\n * yy: {},\n * EOF: 1,\n * TERROR: 2,\n *\n * trace: function(errorMessage, ...),\n *\n * JisonParserError: function(msg, hash),\n *\n * quoteName: function(name),\n * Helper function which can be overridden by user code later on: put suitable\n * quotes around literal IDs in a description string.\n *\n * originalQuoteName: function(name),\n * The basic quoteName handler provided by JISON.\n * `cleanupAfterParse()` will clean up and reset `quoteName()` to reference this function\n * at the end of the `parse()`.\n *\n * describeSymbol: function(symbol),\n * Return a more-or-less human-readable description of the given symbol, when\n * available, or the symbol itself, serving as its own 'description' for lack\n * of something better to serve up.\n *\n * Return NULL when the symbol is unknown to the parser.\n *\n * symbols_: {associative list: name ==> number},\n * terminals_: {associative list: number ==> name},\n * nonterminals: {associative list: rule-name ==> {associative list: number ==> rule-alt}},\n * terminal_descriptions_: (if there are any) {associative list: number ==> description},\n * productions_: [...],\n *\n * performAction: function parser__performAction(yytext, yyleng, yylineno, yyloc, yystate, yysp, yyvstack, yylstack, yystack, yysstack),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `yyval` internal object, which has members (`$` and `_$`)\n * to store/reference the rule value `$$` and location info `@$`.\n *\n * One important thing to note about `this` a.k.a. `yyval`: every *reduce* action gets\n * to see the same object via the `this` reference, i.e. if you wish to carry custom\n * data from one reduce action through to the next within a single parse run, then you\n * may get nasty and use `yyval` a.k.a. `this` for storing you own semi-permanent data.\n *\n * `this.yy` is a direct reference to the `yy` shared state object.\n *\n * `%parse-param`-specified additional `parse()` arguments have been added to this `yy`\n * object at `parse()` start and are therefore available to the action code via the\n * same named `yy.xxxx` attributes (where `xxxx` represents a identifier name from\n * the %parse-param` list.\n *\n * - `yytext` : reference to the lexer value which belongs to the last lexer token used\n * to match this rule. This is *not* the look-ahead token, but the last token\n * that's actually part of this rule.\n *\n * Formulated another way, `yytext` is the value of the token immediately preceeding\n * the current look-ahead token.\n * Caveats apply for rules which don't require look-ahead, such as epsilon rules.\n *\n * - `yyleng` : ditto as `yytext`, only now for the lexer.yyleng value.\n *\n * - `yylineno`: ditto as `yytext`, only now for the lexer.yylineno value.\n *\n * - `yyloc` : ditto as `yytext`, only now for the lexer.yylloc lexer token location info.\n *\n * WARNING: since jison 0.4.18-186 this entry may be NULL/UNDEFINED instead\n * of an empty object when no suitable location info can be provided.\n *\n * - `yystate` : the current parser state number, used internally for dispatching and\n * executing the action code chunk matching the rule currently being reduced.\n *\n * - `yysp` : the current state stack position (a.k.a. 'stack pointer')\n *\n * This one comes in handy when you are going to do advanced things to the parser\n * stacks, all of which are accessible from your action code (see the next entries below).\n *\n * Also note that you can access this and other stack index values using the new double-hash\n * syntax, i.e. `##$ === ##0 === yysp`, while `##1` is the stack index for all things\n * related to the first rule term, just like you have `$1`, `@1` and `#1`.\n * This is made available to write very advanced grammar action rules, e.g. when you want\n * to investigate the parse state stack in your action code, which would, for example,\n * be relevant when you wish to implement error diagnostics and reporting schemes similar\n * to the work described here:\n *\n * + Pottier, F., 2016. Reachability and error diagnosis in LR(1) automata.\n * In Journ\xE9es Francophones des Languages Applicatifs.\n *\n * + Jeffery, C.L., 2003. Generating LR syntax error messages from examples.\n * ACM Transactions on Programming Languages and Systems (TOPLAS), 25(5), pp.631\u2013640.\n *\n * - `yyrulelength`: the current rule's term count, i.e. the number of entries occupied on the stack.\n *\n * This one comes in handy when you are going to do advanced things to the parser\n * stacks, all of which are accessible from your action code (see the next entries below).\n *\n * - `yyvstack`: reference to the parser value stack. Also accessed via the `$1` etc.\n * constructs.\n *\n * - `yylstack`: reference to the parser token location stack. Also accessed via\n * the `@1` etc. constructs.\n *\n * WARNING: since jison 0.4.18-186 this array MAY contain slots which are\n * UNDEFINED rather than an empty (location) object, when the lexer/parser\n * action code did not provide a suitable location info object when such a\n * slot was filled!\n *\n * - `yystack` : reference to the parser token id stack. Also accessed via the\n * `#1` etc. constructs.\n *\n * Note: this is a bit of a **white lie** as we can statically decode any `#n` reference to\n * its numeric token id value, hence that code wouldn't need the `yystack` but *you* might\n * want access this array for your own purposes, such as error analysis as mentioned above!\n *\n * Note that this stack stores the current stack of *tokens*, that is the sequence of\n * already parsed=reduced *nonterminals* (tokens representing rules) and *terminals*\n * (lexer tokens *shifted* onto the stack until the rule they belong to is found and\n * *reduced*.\n *\n * - `yysstack`: reference to the parser state stack. This one carries the internal parser\n * *states* such as the one in `yystate`, which are used to represent\n * the parser state machine in the *parse table*. *Very* *internal* stuff,\n * what can I say? If you access this one, you're clearly doing wicked things\n *\n * - `...` : the extra arguments you specified in the `%parse-param` statement in your\n * grammar definition file.\n *\n * table: [...],\n * State transition table\n * ----------------------\n *\n * index levels are:\n * - `state` --> hash table\n * - `symbol` --> action (number or array)\n *\n * If the `action` is an array, these are the elements' meaning:\n * - index [0]: 1 = shift, 2 = reduce, 3 = accept\n * - index [1]: GOTO `state`\n *\n * If the `action` is a number, it is the GOTO `state`\n *\n * defaultActions: {...},\n *\n * parseError: function(str, hash, ExceptionClass),\n * yyError: function(str, ...),\n * yyRecovering: function(),\n * yyErrOk: function(),\n * yyClearIn: function(),\n *\n * constructParseErrorInfo: function(error_message, exception_object, expected_token_set, is_recoverable),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.\n * See it's use in this parser kernel in many places; example usage:\n *\n * var infoObj = parser.constructParseErrorInfo('fail!', null,\n * parser.collect_expected_token_set(state), true);\n * var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError);\n *\n * originalParseError: function(str, hash, ExceptionClass),\n * The basic `parseError` handler provided by JISON.\n * `cleanupAfterParse()` will clean up and reset `parseError()` to reference this function\n * at the end of the `parse()`.\n *\n * options: { ... parser %options ... },\n *\n * parse: function(input[, args...]),\n * Parse the given `input` and return the parsed value (or `true` when none was provided by\n * the root action, in which case the parser is acting as a *matcher*).\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of this grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Parser's additional `args...` parameters (via `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * The lexer MAY add its own set of additional parameters (via the `%parse-param` line in\n * the lexer section of the grammar spec): these will be inserted in the `yy` shared state\n * object and any collision with those will be reported by the lexer via a thrown exception.\n *\n * cleanupAfterParse: function(resultValue, invoke_post_methods, do_not_nuke_errorinfos),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * This helper API is invoked at the end of the `parse()` call, unless an exception was thrown\n * and `%options no-try-catch` has been defined for this grammar: in that case this helper MAY\n * be invoked by calling user code to ensure the `post_parse` callbacks are invoked and\n * the internal parser gets properly garbage collected under these particular circumstances.\n *\n * yyMergeLocationInfo: function(first_index, last_index, first_yylloc, last_yylloc, dont_look_back),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * This helper API can be invoked to calculate a spanning `yylloc` location info object.\n *\n * Note: %epsilon rules MAY specify no `first_index` and `first_yylloc`, in which case\n * this function will attempt to obtain a suitable location marker by inspecting the location stack\n * backwards.\n *\n * For more info see the documentation comment further below, immediately above this function's\n * implementation.\n *\n * lexer: {\n * yy: {...}, A reference to the so-called \"shared state\" `yy` once\n * received via a call to the `.setInput(input, yy)` lexer API.\n * EOF: 1,\n * ERROR: 2,\n * JisonLexerError: function(msg, hash),\n * parseError: function(str, hash, ExceptionClass),\n * setInput: function(input, [yy]),\n * input: function(),\n * unput: function(str),\n * more: function(),\n * reject: function(),\n * less: function(n),\n * pastInput: function(n),\n * upcomingInput: function(n),\n * showPosition: function(),\n * test_match: function(regex_match_array, rule_index, ...),\n * next: function(...),\n * lex: function(...),\n * begin: function(condition),\n * pushState: function(condition),\n * popState: function(),\n * topState: function(),\n * _currentRules: function(),\n * stateStackSize: function(),\n * cleanupAfterLex: function()\n *\n * options: { ... lexer %options ... },\n *\n * performAction: function(yy, yy_, $avoiding_name_collisions, YY_START, ...),\n * rules: [...],\n * conditions: {associative list: name ==> set},\n * }\n * }\n *\n *\n * token location info (@$, _$, etc.): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a 'hash' object with these members for lexer and\n * parser errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * }\n *\n * parser (grammar) errors will also provide these additional members:\n *\n * {\n * expected: (array describing the set of expected tokens;\n * may be UNDEFINED when we cannot easily produce such a set)\n * state: (integer (or array when the table includes grammar collisions);\n * represents the current internal state of the parser kernel.\n * can, for example, be used to pass to the `collect_expected_token_set()`\n * API to obtain the expected token set)\n * action: (integer; represents the current internal action which will be executed)\n * new_state: (integer; represents the next/planned internal state, once the current\n * action has executed)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * state_stack: (array: the current parser LALR/LR internal state stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * value_stack: (array: the current parser LALR/LR internal `$$` value stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * location_stack: (array: the current parser LALR/LR internal location stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * yy: (object: the current parser internal \"shared state\" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * parser: (reference to the current parser instance)\n * }\n *\n * while `this` will reference the current parser instance.\n *\n * When `parseError` is invoked by the lexer, `this` will still reference the related *parser*\n * instance, while these additional `hash` fields will also be provided:\n *\n * {\n * lexer: (reference to the current lexer instance which reported the error)\n * }\n *\n * When `parseError` is invoked by the parser due to a **JavaScript exception** being fired\n * from either the parser or lexer, `this` will still reference the related *parser*\n * instance, while these additional `hash` fields will also be provided:\n *\n * {\n * exception: (reference to the exception thrown)\n * }\n *\n * Please do note that in the latter situation, the `expected` field will be omitted as\n * this type of failure is assumed not to be due to *parse errors* but rather due to user\n * action code in either parser or lexer failing unexpectedly.\n *\n * ---\n *\n * You can specify parser options by setting / modifying the `.yy` object of your Parser instance.\n * These options are available:\n *\n * ### options which are global for all parser instances\n *\n * Parser.pre_parse: function(yy)\n * optional: you can specify a pre_parse() function in the chunk following\n * the grammar, i.e. after the last `%%`.\n * Parser.post_parse: function(yy, retval, parseInfo) { return retval; }\n * optional: you can specify a post_parse() function in the chunk following\n * the grammar, i.e. after the last `%%`. When it does not return any value,\n * the parser will return the original `retval`.\n *\n * ### options which can be set up per parser instance\n *\n * yy: {\n * pre_parse: function(yy)\n * optional: is invoked before the parse cycle starts (and before the first\n * invocation of `lex()`) but immediately after the invocation of\n * `parser.pre_parse()`).\n * post_parse: function(yy, retval, parseInfo) { return retval; }\n * optional: is invoked when the parse terminates due to success ('accept')\n * or failure (even when exceptions are thrown).\n * `retval` contains the return value to be produced by `Parser.parse()`;\n * this function can override the return value by returning another.\n * When it does not return any value, the parser will return the original\n * `retval`.\n * This function is invoked immediately before `parser.post_parse()`.\n *\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * quoteName: function(name),\n * optional: overrides the default `quoteName` function.\n * }\n *\n * parser.lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean (\u214F \uC13C \u214A \u2056 \u2058 \u2059 \u205A \u205B \u205C \u205D \u205E \u2020 \u2021 \n a\u2BC8b\n \u2200 \u2201 \u2202 \u2203 \u2204 \u2205 \u2206 \u2207 \u2208 \u2209 \u220A \u220B \u220C \u220D \u220E \u220F\nU+221x \u2210 \u2211 \u2212 \u2213 \u2214 \u2215 \u2216 \u2217 \u2218 \u2219 \u221A \u221B \u221C \u221D \u221E \u221F\nU+222x \u2220 \u2221 \u2222 \u2223 \u2224 \u2225 \u2226 \u2227 \u2228 \u2229 \u222A \u222B \u222C \u222D \u222E \u222F\nU+223x \u2230 \u2231 \u2232 \u2233 \u2234 \u2235 \u2236 \u2237 \u2238 \u2239 \u223A \u223B \u223C \u223D \u223E \u223F\nU+224x \u2240 \u2241 \u2242 \u2243 \u2244 \u2245 \u2246 \u2247 \u2248 \u2249 \u224A \u224B \u224C \u224D \u224E \u224F\nU+225x \u2250 \u2251 \u2252 \u2253 \u2254 \u2255 \u2256 \u2257 \u2258 \u2259 \u225A \u225B \u225C \u225D \u225E \u225F\nU+226x \u2260 \u2261 \u2262 \u2263 \u2264 \u2265 \u2266 \u2267 \u2268 \u2269 \u226A \u226B \u226C \u226D \u226E \u226F\nU+227x \u2270 \u2271 \u2272 \u2273 \u2274 \u2275 \u2276 \u2277 \u2278 \u2279 \u227A \u227B \u227C \u227D \u227E \u227F\nU+228x \u2280 \u2281 \u2282 \u2283 \u2284 \u2285 \u2286 \u2287 \u2288 \u2289 \u228A \u228B \u228C \u228D \u228E \u228F\nU+229x \u2290 \u2291 \u2292 \u2293 \u2294 \u2295 \u2296 \u2297 \u2298 \u2299 \u229A \u229B \u229C \u229D \u229E \u229F\nU+22Ax \u22A0 \u22A1 \u22A2 \u22A3 \u22A4 \u22A5 \u22A6 \u22A7 \u22A8 \u22A9 \u22AA \u22AB \u22AC \u22AD \u22AE \u22AF\nU+22Bx \u22B0 \u22B1 \u22B2 \u22B3 \u22B4 \u22B5 \u22B6 \u22B7 \u22B8 \u22B9 \u22BA \u22BB \u22BC \u22BD \u22BE \u22BF\nU+22Cx \u22C0 \u22C1 \u22C2 \u22C3 \u22C4 \u22C5 \u22C6 \u22C7 \u22C8 \u22C9 \u22CA \u22CB \u22CC \u22CD \u22CE \u22CF\nU+22Dx \u22D0 \u22D1 \u22D2 \u22D3 \u22D4 \u22D5 \u22D6 \u22D7 \u22D8 \u22D9 \u22DA \u22DB \u22DC \u22DD \u22DE \u22DF\nU+22Ex \u22E0 \u22E1 \u22E2 \u22E3 \u22E4 \u22E5 \u22E6 \u22E7 \u22E8 \u22E9 \u22EA \u22EB \u22EC \u22ED \u22EE \u22EF\nU+22Fx \u22F0 \u22F1 \u22F2 \u22F3 \u22F4 \u22F5 \u22F6 \u22F7 \u22F8 \u22F9 \u22FA \u22FB \u22FC \u22FD \u22FE \u22FF)\nU+230x \u2300 \u2301 \u2302 \u2303 \u2304 \u2305 \u2306 \u2307 \u2308 \u2309 \u230A \u230B \u230C \u230D \u230E \u230F\nU+231x \u2310 \u2311 \u2312 \u2313 \u2314 \u2315 \u2316 \u2317 \u2318 \u2319 \u231A \u231B \u231C \u231D \u231E \u231F\nU+232x \u2320 \u2321 \u2322 \u2323 \u2324 \u2325 \u2326 \u2327 \u2328 \u2329 \u232A \u232B \u232C \u232D \u232E \u232F\nU+233x \u2330 \u2331 \u2332 \u2333 \u2334 \u2335 \u2336 \u2337 \u2338 \u2339 \u233A \u233B \u233C \u233D \u233E \u233F\nU+234x \u2340 \u2341 \u2342 \u2343 \u2344 \u2345 \u2346 \u2347 \u2348 \u2349 \u234A \u234B \u234C \u234D \u234E \u234F\nU+235x \u2350 \u2351 \u2352 \u2353 \u2354 \u2355 \u2356 \u2357 \u2358 \u2359 \u235A \u235B \u235C \u235D \u235E \u235F\nU+236x \u2360 \u2361 \u2362 \u2363 \u2364 \u2365 \u2366 \u2367 \u2368 \u2369 \u236A \u236B \u236C \u236D \u236E \u236F\nU+237x \u2370 \u2371 \u2372 \u2373 \u2374 \u2375 \u2376 \u2377 \u2378 \u2379 \u237A \u237B \u237C \u237D \u237E \u237F\nU+238x \u2380 \u2381 \u2382 \u2383 \u2384 \u2385 \u2386 \u2387 \u2388 \u2389 \u238A \u238B \u238C \u238D \u238E \u238F\nU+239x \u2390 \u2391 \u2392 \u2393 \u2394 \u2395 \u2396 \u2397 \u2398 \u2399 \u239A \u239B \u239C \u239D \u239E \u239F\nU+23Ax \u23A0 \u23A1 \u23A2 \u23A3 \u23A4 \u23A5 \u23A6 \u23A7 \u23A8 \u23A9 \u23AA \u23AB \u23AC \u23AD \u23AE \u23AF\nU+23Bx \u23B0 \u23B1 \u23B2 \u23B3 \u23B4 \u23B5 \u23B6 \u23B7 \u23B8 \u23B9 \u23BA \u23BB \u23BC \u23BD \u23BE \u23BF\nU+23Cx \u23C0 \u23C1 \u23C2 \u23C3 \u23C4 \u23C5 \u23C6 \u23C7 \u23C8 \u23C9 \u23CA \u23CB \u23CC \u23CD \u23CE \u23CF\nU+23Dx \u23D0 \u23D1 \u23D2 \u23D3 \u23D4 \u23D5 \u23D6 \u23D7 \u23D8 \u23D9 \u23DA \u23DB \u23DC \u23DD \u23DE \u23DF\nU+23Ex \u23E0 \u23E1 \u23E2 \u23E3 \u23E4 \u23E5 \u23E6 \u23E7 \u23E8 \u23E9 \u23EA \u23EB \u23EC \u23ED \u23EE \u23EF\nU+23Fx \u23F0 \u23F1 \u23F2 \u23F3 \u23F4 \u23F5 \u23F6 \u23F7 \u23F8 \u23F9 \u23FA \u23FB \u23FC \u23FD \u23FE \u23FF\n\nU+260x \u2600 \u2601 \u2602 \u2603 \u2604 \u2605 \u2606 \u2607 \u2608 \u2609 \u260A \u260B \u260C \u260D \u260E \u260F\nU+261x \u2610 \u2611 \u2612 \u2613 \u2614 \u2615 \u2616 \u2617 \u2618 \u2619 \u261A \u261B \u261C \u261D \u261E \u261F\nU+262x \u2620 \u2621 \u2622 \u2623 \u2624 \u2625 \u2626 \u2627 \u2628 \u2629 \u262A \u262B \u262C \u262D \u262E \u262F\nU+263x \u2630 \u2631 \u2632 \u2633 \u2634 \u2635 \u2636 \u2637 \u2638 \u2639 \u263A \u263B \u263C \u263D \u263E \u263F\nU+264x \u2640 \u2641 \u2642 \u2643 \u2644 \u2645 \u2646 \u2647 \u2648 \u2649 \u264A \u264B \u264C \u264D \u264E \u264F\nU+265x \u2650 \u2651 \u2652 \u2653 \u2654 \u2655 \u2656 \u2657 \u2658 \u2659 \u265A \u265B \u265C \u265D \u265E \u265F\nU+266x \u2660 \u2661 \u2662 \u2663 \u2664 \u2665 \u2666 \u2667 \u2668 \u2669 \u266A \u266B \u266C \u266D \u266E \u266F\nU+267x \u2670 \u2671 \u2672 \u2673 \u2674 \u2675 \u2676 \u2677 \u2678 \u2679 \u267A \u267B \u267C \u267D \u267E \u267F\nU+268x \u2680 \u2681 \u2682 \u2683 \u2684 \u2685 \u2686 \u2687 \u2688 \u2689 \u268A \u268B \u268C \u268D \u268E \u268F\nU+269x \u2690 \u2691 \u2692 \u2693 \u2694 \u2695 \u2696 \u2697 \u2698 \u2699 \u269A \u269B \u269C \u269D \u269E \u269F\nU+26Ax \u26A0 \u26A1 \u26A2 \u26A3 \u26A4 \u26A5 \u26A6 \u26A7 \u26A8 \u26A9 \u26AA \u26AB \u26AC \u26AD \u26AE \u26AF\nU+26Bx \u26B0 \u26B1 \u26B2 \u26B3 \u26B4 \u26B5 \u26B6 \u26B7 \u26B8 \u26B9 \u26BA \u26BB \u26BC \u26BD \u26BE \u26BF\nU+26Cx \u26C0 \u26C1 \u26C2 \u26C3 \u26C4 \u26C5 \u26C6 \u26C7 \u26C8 \u26C9 \u26CA \u26CB \u26CC \u26CD \u26CE \u26CF\nU+26Dx \u26D0 \u26D1 \u26D2 \u26D3 \u26D4 \u26D5 \u26D6 \u26D7 \u26D8 \u26D9 \u26DA \u26DB \u26DC \u26DD \u26DE \u26DF\nU+26Ex \u26E0 \u26E1 \u26E2 \u26E3 \u26E4 \u26E5 \u26E6 \u26E7 \u26E8 \u26E9 \u26EA \u26EB \u26EC \u26ED \u26EE \u26EF\nU+26Fx \u26F0 \u26F1 \u26F2 \u26F3 \u26F4 \u26F5 \u26F6 \u26F7 \u26F8 \u26F9 \u26FA \u26FB \u26FC \u26FD \u26FE \u26FF\n\n \u2701 \u2702 \u2703 \u2704 \u2705 \u2706 \u2707 \u2708 \u2709 \u261B \u261E \u270C \u270D \u270E \u270F\n\u2710 \u2711 \u2712 \u2713 \u2714 \u2715 \u2716 \u2717 \u2718 \u2719 \u271A \u271B \u271C \u271D \u271E \u271F\n\u2720 \u2721 \u2722 \u2723 \u2724 \u2725 \u2726 \u2727 \u2605 \u2729 \u272A \u272B \u272C \u272D \u272E \u272F\n\u2730 \u2731 \u2732 \u2733 \u2734 \u2735 \u2736 \u2737 \u2738 \u2739 \u273A \u273B \u273C \u273D \u273E \u273F\n\u2740 \u2741 \u2742 \u2743 \u2744 \u2745 \u2746 \u2747 \u2748 \u2749 \u274A \u274B \u25CF \u274D \u25A0 \u274F\n\u263A \u263B \u2665 \u2666 \u2663 \u2660 \u2022 \u25D8 \u25CB \u2750 \u2751 \u2752 \u25B2 \u25BC \u25C6 \u2756\n\u25D7 \u2758 \u2759 \u275A \u275B \u275C \u275D \u275E \n\nU+270x \u2700 \u2701 \u2702 \u2703 \u2704 \u2705 \u2706 \u2707 \u2708 \u2709 \u270A \u270B \u270C \u270D \u270E \u270F\nU+271x \u2710 \u2711 \u2712 \u2713 \u2714 \u2715 \u2716 \u2717 \u2718 \u2719 \u271A \u271B \u271C \u271D \u271E \u271F\nU+272x \u2720 \u2721 \u2722 \u2723 a\u2724b a\u2725b a\u2726b a\u2727b \u2728 \u2729 \u272A \u272B \u272C \u272D \u272E \u272F\nU+273x \u2730 \u2731 \u2732 \u2733 \u2734 \u2735 \u2736 \u2737 \u2738 \u2739 \u273A \u273B \u273C \u273D \u273E \u273F\nU+274x \u2740 \u2741 \u2742 \u2743 \u2744 \u2745 \u2746 \u2747 \u2748 \u2749 \u274A \u274B \u274C \u274D \u274E \u274F\nU+275x \u2750 \u2751 \u2752 \u2753 \u2754 \u2755 \u2756 \u2757 \u2758 \u2759 \u275A \u275B \u275C \u275D \u275E \u275F\nU+276x \u2760 \u2761 \u2762 \u2763 \u2764 \u2765 \u2766 \u2767 \u2768 \u2769 \u276A \u276B \u276C \u276D \u276E a\u276Fb\nU+277x \u2770 \u2771 \u2772 \u2773 \u2774 \u2775 \u2776 \u2777 \u2778 \u2779 \u277A \u277B \u277C \u277D \u277E \u277F\nU+278x \u2780 \u2781 \u2782 \u2783 \u2784 \u2785 \u2786 \u2787 \u2788 \u2789 \u278A \u278B \u278C \u278D \u278E \u278F\nU+279x \u2790 \u2791 \u2792 \u2793 \u2794 \u2795 \u2796 \u2797 \u2798 \u2799 \u279A \u279B \u279C \u279D \u279E \u279F\nU+27Ax \u27A0 \u27A1 \u27A2 \u27A3 \u27A4 \u27A5 \u27A6 \u27A7 a\u27A8b \u27A9 \u27AA \u27AB \u27AC \u27AD \u27AE \u27AF\nU+27Bx \u27B0 a\u27B1b \u27B2 \u27B3 \u27B4 \u27B5 \u27B6 \u27B7 \u27B8 \u27B9 \u27BA \u27BB \u27BC \u27BD \u27BE \u27BF\n\nU+2580 \u2580 Upper half block\nU+2581 \u2581 Lower one eighth block\nU+2582 \u2582 Lower one quarter block\nU+2583 \u2583 Lower three eighths block\nU+2584 \u2584 Lower half block\nU+2585 \u2585 Lower five eighths block\nU+2586 \u2586 Lower three quarters block\nU+2587 \u2587 Lower seven eighths block\nU+2588 \u2588 Full block\nU+2589 \u2589 Left seven eighths block\nU+258A \u258A Left three quarters block\nU+258B \u258B Left five eighths block\nU+258C \u258C Left half block\nU+258D \u258D Left three eighths block\nU+258E \u258E Left one quarter block\nU+258F \u258F Left one eighth block\nU+2590 \u2590 Right half block\nU+2591 \u2591 Light shade\nU+2592 \u2592 Medium shade\nU+2593 \u2593 Dark shade\nU+2594 \u2594 Upper one eighth block\nU+2595 \u2595 Right one eighth block\nU+2596 \u2596 Quadrant lower left\nU+2597 \u2597 Quadrant lower right\nU+2598 \u2598 Quadrant upper left\nU+2599 \u2599 Quadrant upper left and lower left and lower right\nU+259A \u259A Quadrant upper left and lower right\nU+259B \u259B Quadrant upper left and upper right and lower left\nU+259C \u259C Quadrant upper left and upper right and lower right\nU+259D \u259D Quadrant upper right\nU+259E \u259E Quadrant upper right and lower left\nU+259F \u259F Quadrant upper right and lower left and lower right\nGeometric Shapes\nMain articles: Geometric Shapes (Unicode block) and Geometric Shapes Extended (Unicode block)\n[hide]Code Glyph Description\nU+25A0 \u25A0 Black square\nU+25A1 \u25A1 White square\nU+25A2 \u25A2 White square with rounded corners\nU+25A3 \u25A3 White square containing small black square\nU+25A4 \u25A4 Square with horizontal fill\nU+25A5 \u25A5 Square with vertical fill\nU+25A6 \u25A6 Square with orthogonal crosshatch fill\nU+25A7 \u25A7 Square with upper left to lower right fill\nU+25A8 \u25A8 Square with upper right to lower left fill\nU+25A9 \u25A9 Square with diagonal crosshatch fill\nU+25AA \u25AA Black small square\nU+25AB \u25AB White small square\nU+25AC \u25AC Black rectangle\nU+25AD \u25AD White rectangle\nU+25AE \u25AE Black vertical rectangle\nU+25AF \u25AF White vertical rectangle\nU+25B0 \u25B0 Black parallelogram\nU+25B1 \u25B1 White parallelogram\nU+25B2 \u25B2 Black up-pointing triangle\nU+25B3 \u25B3 White up-pointing triangle\nU+25B4 \u25B4 Black up-pointing small triangle\nU+25B5 \u25B5 White up-pointing small triangle\nU+25B6 \u25B6 Black right-pointing triangle\nU+25B7 \u25B7 White right-pointing triangle\nU+25B8 \u25B8 Black right-pointing small triangle\nU+25B9 \u25B9 White right-pointing small triangle\nU+25BA \u25BA Black right-pointing pointer\nU+25BB \u25BB White right-pointing pointer\nU+25BC \u25BC Black down-pointing triangle\nU+25BD \u25BD White down-pointing triangle\nU+25BE \u25BE Black down-pointing small triangle\nU+25BF \u25BF White down-pointing small triangle\nU+25C0 \u25C0 Black left-pointing triangle\nU+25C1 \u25C1 White left-pointing triangle\nU+25C2 \u25C2 Black left-pointing small triangle\nU+25C3 \u25C3 White left-pointing small triangle\nU+25C4 \u25C4 Black left-pointing pointer\nU+25C5 \u25C5 White left-pointing pointer\nU+25C6 \u25C6 Black diamond\nU+25C7 \u25C7 White diamond\nU+25C8 \u25C8 White diamond containing small black diamond\nU+25C9 \u25C9 Fisheye\nU+25CA \u25CA Lozenge\nU+25CB \u25CB White circle\nU+25CC \u25CC Dotted circle\nU+25CD \u25CD Circle with vertical fill\nU+25CE \u25CE Bullseye\nU+25CF \u25CF Black circle\nU+25D0 \u25D0 Circle with left half black\nU+25D1 \u25D1 Circle with right half black\nU+25D2 \u25D2 Circle with lower half black\nU+25D3 \u25D3 Circle with upper half black\nU+25D4 \u25D4 Circle with upper right quadrant black\nU+25D5 \u25D5 Circle with all but upper left quadrant black\nU+25D6 \u25D6 Left half circle black\nU+25D7 \u25D7 Right half black circle\nU+25D8 \u25D8 Inverse bullet\nU+25D9 \u25D9 Inverse white circle\nU+25DA \u25DA Upper half inverse white circle\nU+25DB \u25DB Lower half inverse white circle\nU+25DC \u25DC Upper left quadrant circular arc\nU+25DD \u25DD Upper right quadrant circular arc\nU+25DE \u25DE Lower right quadrant circular arc\nU+25DF \u25DF Lower left quadrant circular arc\nU+25E0 \u25E0 Upper half circle\nU+25E1 \u25E1 Lower half circle\nU+25E2 \u25E2 Black lower right triangle\nU+25E3 \u25E3 Black lower left triangle\nU+25E4 \u25E4 Black upper left triangle\nU+25E5 \u25E5 Black upper right triangle\nU+25E6 \u25E6 White bullet\nU+25E7 \u25E7 Square with left half black\nU+25E8 \u25E8 Square with right half black\nU+25E9 \u25E9 Square with upper left diagonal half black\nU+25EA \u25EA Square with lower right diagonal half black\nU+25EB \u25EB White square with vertical bisecting line\nU+25EC \u25EC White up-pointing triangle with dot\nU+25ED \u25ED Up-pointing triangle with left half black\nU+25EE \u25EE Up-pointing triangle with right half black\nU+25EF \u25EF Large circle\nU+25F0 \u25F0 White square with upper left quadrant\nU+25F1 \u25F1 White square with lower left quadrant\nU+25F2 \u25F2 White square with lower right quadrant\nU+25F3 \u25F3 White square with upper right quadrant\nU+25F4 \u25F4 White circle with upper left quadrant\nU+25F5 \u25F5 White circle with lower left quadrant\nU+25F6 \u25F6 White circle with lower right quadrant\nU+25F7 \u25F7 White circle with upper right quadrant\nU+25F8 \u25F8 Upper left triangle\nU+25F9 \u25F9 Upper right triangle\nU+25FA \u25FA Lower-left triangle\nU+25FB \u25FB White medium square\nU+25FC \u25FC Black medium square\nU+25FD \u25FD White medium small square\nU+25FE \u25FE Black medium small square\nU+25FF \u25FF Lower right triangle\n\n\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are \"extended regex format\" requiring the\n * `XRegExp` library. When this `%option` has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n"); + var out = "\n/* parser generated by jison ".concat(version$2, " */\n\n/*\n * Returns a Parser object of the following structure:\n *\n * Parser: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" `yy` passed around to\n * the rule actions, etc. is a derivative/copy of this one,\n * not a direct reference!\n * }\n *\n * Parser.prototype: {\n * yy: {},\n * EOF: 1,\n * TERROR: 2,\n *\n * trace: function(errorMessage, ...),\n *\n * JisonParserError: function(msg, hash),\n *\n * quoteName: function(name),\n * Helper function which can be overridden by user code later on: put suitable\n * quotes around literal IDs in a description string.\n *\n * originalQuoteName: function(name),\n * The basic quoteName handler provided by JISON.\n * `cleanupAfterParse()` will clean up and reset `quoteName()` to reference this function\n * at the end of the `parse()`.\n *\n * describeSymbol: function(symbol),\n * Return a more-or-less human-readable description of the given symbol, when\n * available, or the symbol itself, serving as its own 'description' for lack\n * of something better to serve up.\n *\n * Return NULL when the symbol is unknown to the parser.\n *\n * symbols_: {associative list: name ==> number},\n * terminals_: {associative list: number ==> name},\n * nonterminals: {associative list: rule-name ==> {associative list: number ==> rule-alt}},\n * terminal_descriptions_: (if there are any) {associative list: number ==> description},\n * productions_: [...],\n *\n * performAction: function parser__performAction(yytext, yyleng, yylineno, yyloc, yystate, yysp, yyvstack, yylstack, yystack, yysstack),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `yyval` internal object, which has members (`$` and `_$`)\n * to store/reference the rule value `$$` and location info `@$`.\n *\n * One important thing to note about `this` a.k.a. `yyval`: every *reduce* action gets\n * to see the same object via the `this` reference, i.e. if you wish to carry custom\n * data from one reduce action through to the next within a single parse run, then you\n * may get nasty and use `yyval` a.k.a. `this` for storing you own semi-permanent data.\n *\n * `this.yy` is a direct reference to the `yy` shared state object.\n *\n * `%parse-param`-specified additional `parse()` arguments have been added to this `yy`\n * object at `parse()` start and are therefore available to the action code via the\n * same named `yy.xxxx` attributes (where `xxxx` represents a identifier name from\n * the %parse-param` list.\n *\n * - `yytext` : reference to the lexer value which belongs to the last lexer token used\n * to match this rule. This is *not* the look-ahead token, but the last token\n * that's actually part of this rule.\n *\n * Formulated another way, `yytext` is the value of the token immediately preceeding\n * the current look-ahead token.\n * Caveats apply for rules which don't require look-ahead, such as epsilon rules.\n *\n * - `yyleng` : ditto as `yytext`, only now for the lexer.yyleng value.\n *\n * - `yylineno`: ditto as `yytext`, only now for the lexer.yylineno value.\n *\n * - `yyloc` : ditto as `yytext`, only now for the lexer.yylloc lexer token location info.\n *\n * WARNING: since jison 0.4.18-186 this entry may be NULL/UNDEFINED instead\n * of an empty object when no suitable location info can be provided.\n *\n * - `yystate` : the current parser state number, used internally for dispatching and\n * executing the action code chunk matching the rule currently being reduced.\n *\n * - `yysp` : the current state stack position (a.k.a. 'stack pointer')\n *\n * This one comes in handy when you are going to do advanced things to the parser\n * stacks, all of which are accessible from your action code (see the next entries below).\n *\n * Also note that you can access this and other stack index values using the new double-hash\n * syntax, i.e. `##$ === ##0 === yysp`, while `##1` is the stack index for all things\n * related to the first rule term, just like you have `$1`, `@1` and `#1`.\n * This is made available to write very advanced grammar action rules, e.g. when you want\n * to investigate the parse state stack in your action code, which would, for example,\n * be relevant when you wish to implement error diagnostics and reporting schemes similar\n * to the work described here:\n *\n * + Pottier, F., 2016. Reachability and error diagnosis in LR(1) automata.\n * In Journ\xE9es Francophones des Languages Applicatifs.\n *\n * + Jeffery, C.L., 2003. Generating LR syntax error messages from examples.\n * ACM Transactions on Programming Languages and Systems (TOPLAS), 25(5), pp.631\u2013640.\n *\n * - `yyrulelength`: the current rule's term count, i.e. the number of entries occupied on the stack.\n *\n * This one comes in handy when you are going to do advanced things to the parser\n * stacks, all of which are accessible from your action code (see the next entries below).\n *\n * - `yyvstack`: reference to the parser value stack. Also accessed via the `$1` etc.\n * constructs.\n *\n * - `yylstack`: reference to the parser token location stack. Also accessed via\n * the `@1` etc. constructs.\n *\n * WARNING: since jison 0.4.18-186 this array MAY contain slots which are\n * UNDEFINED rather than an empty (location) object, when the lexer/parser\n * action code did not provide a suitable location info object when such a\n * slot was filled!\n *\n * - `yystack` : reference to the parser token id stack. Also accessed via the\n * `#1` etc. constructs.\n *\n * Note: this is a bit of a **white lie** as we can statically decode any `#n` reference to\n * its numeric token id value, hence that code wouldn't need the `yystack` but *you* might\n * want access this array for your own purposes, such as error analysis as mentioned above!\n *\n * Note that this stack stores the current stack of *tokens*, that is the sequence of\n * already parsed=reduced *nonterminals* (tokens representing rules) and *terminals*\n * (lexer tokens *shifted* onto the stack until the rule they belong to is found and\n * *reduced*.\n *\n * - `yysstack`: reference to the parser state stack. This one carries the internal parser\n * *states* such as the one in `yystate`, which are used to represent\n * the parser state machine in the *parse table*. *Very* *internal* stuff,\n * what can I say? If you access this one, you're clearly doing wicked things\n *\n * - `...` : the extra arguments you specified in the `%parse-param` statement in your\n * grammar definition file.\n *\n * table: [...],\n * State transition table\n * ----------------------\n *\n * index levels are:\n * - `state` --> hash table\n * - `symbol` --> action (number or array)\n *\n * If the `action` is an array, these are the elements' meaning:\n * - index [0]: 1 = shift, 2 = reduce, 3 = accept\n * - index [1]: GOTO `state`\n *\n * If the `action` is a number, it is the GOTO `state`\n *\n * defaultActions: {...},\n *\n * parseError: function(str, hash, ExceptionClass),\n * yyError: function(str, ...),\n * yyRecovering: function(),\n * yyErrOk: function(),\n * yyClearIn: function(),\n *\n * constructParseErrorInfo: function(error_message, exception_object, expected_token_set, is_recoverable),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.\n * See it's use in this parser kernel in many places; example usage:\n *\n * let infoObj = parser.constructParseErrorInfo('fail!', null,\n * parser.collect_expected_token_set(state), true);\n * let retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError);\n *\n * originalParseError: function(str, hash, ExceptionClass),\n * The basic `parseError` handler provided by JISON.\n * `cleanupAfterParse()` will clean up and reset `parseError()` to reference this function\n * at the end of the `parse()`.\n *\n * options: { ... parser %options ... },\n *\n * parse: function(input[, args...]),\n * Parse the given `input` and return the parsed value (or `true` when none was provided by\n * the root action, in which case the parser is acting as a *matcher*).\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of this grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Parser's additional `args...` parameters (via `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * The lexer MAY add its own set of additional parameters (via the `%parse-param` line in\n * the lexer section of the grammar spec): these will be inserted in the `yy` shared state\n * object and any collision with those will be reported by the lexer via a thrown exception.\n *\n * cleanupAfterParse: function(resultValue, invoke_post_methods, do_not_nuke_errorinfos),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * This helper API is invoked at the end of the `parse()` call, unless an exception was thrown\n * and `%options no-try-catch` has been defined for this grammar: in that case this helper MAY\n * be invoked by calling user code to ensure the `post_parse` callbacks are invoked and\n * the internal parser gets properly garbage collected under these particular circumstances.\n *\n * yyMergeLocationInfo: function(first_index, last_index, first_yylloc, last_yylloc, dont_look_back),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * This helper API can be invoked to calculate a spanning `yylloc` location info object.\n *\n * Note: %epsilon rules MAY specify no `first_index` and `first_yylloc`, in which case\n * this function will attempt to obtain a suitable location marker by inspecting the location stack\n * backwards.\n *\n * For more info see the documentation comment further below, immediately above this function's\n * implementation.\n *\n * lexer: {\n * yy: {...}, A reference to the so-called \"shared state\" `yy` once\n * received via a call to the `.setInput(input, yy)` lexer API.\n * EOF: 1,\n * ERROR: 2,\n * JisonLexerError: function(msg, hash),\n * parseError: function(str, hash, ExceptionClass),\n * setInput: function(input, [yy]),\n * input: function(),\n * unput: function(str),\n * more: function(),\n * reject: function(),\n * less: function(n),\n * pastInput: function(n),\n * upcomingInput: function(n),\n * showPosition: function(),\n * test_match: function(regex_match_array, rule_index, ...),\n * next: function(...),\n * lex: function(...),\n * begin: function(condition),\n * pushState: function(condition),\n * popState: function(),\n * topState: function(),\n * _currentRules: function(),\n * stateStackSize: function(),\n * cleanupAfterLex: function()\n *\n * options: { ... lexer %options ... },\n *\n * performAction: function(yy, yy_, $avoiding_name_collisions, YY_START, ...),\n * rules: [...],\n * conditions: {associative list: name ==> set},\n * }\n * }\n *\n *\n * token location info (@$, _$, etc.): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a 'hash' object with these members for lexer and\n * parser errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * }\n *\n * parser (grammar) errors will also provide these additional members:\n *\n * {\n * expected: (array describing the set of expected tokens;\n * may be UNDEFINED when we cannot easily produce such a set)\n * state: (integer (or array when the table includes grammar collisions);\n * represents the current internal state of the parser kernel.\n * can, for example, be used to pass to the `collect_expected_token_set()`\n * API to obtain the expected token set)\n * action: (integer; represents the current internal action which will be executed)\n * new_state: (integer; represents the next/planned internal state, once the current\n * action has executed)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * state_stack: (array: the current parser LALR/LR internal state stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * value_stack: (array: the current parser LALR/LR internal `$$` value stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * location_stack: (array: the current parser LALR/LR internal location stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * yy: (object: the current parser internal \"shared state\" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * parser: (reference to the current parser instance)\n * }\n *\n * while `this` will reference the current parser instance.\n *\n * When `parseError` is invoked by the lexer, `this` will still reference the related *parser*\n * instance, while these additional `hash` fields will also be provided:\n *\n * {\n * lexer: (reference to the current lexer instance which reported the error)\n * }\n *\n * When `parseError` is invoked by the parser due to a **JavaScript exception** being fired\n * from either the parser or lexer, `this` will still reference the related *parser*\n * instance, while these additional `hash` fields will also be provided:\n *\n * {\n * exception: (reference to the exception thrown)\n * }\n *\n * Please do note that in the latter situation, the `expected` field will be omitted as\n * this type of failure is assumed not to be due to *parse errors* but rather due to user\n * action code in either parser or lexer failing unexpectedly.\n *\n * ---\n *\n * You can specify parser options by setting / modifying the `.yy` object of your Parser instance.\n * These options are available:\n *\n * ### options which are global for all parser instances\n *\n * Parser.pre_parse: function(yy)\n * optional: you can specify a pre_parse() function in the chunk following\n * the grammar, i.e. after the last `%%`.\n * Parser.post_parse: function(yy, retval, parseInfo) { return retval; }\n * optional: you can specify a post_parse() function in the chunk following\n * the grammar, i.e. after the last `%%`. When it does not return any value,\n * the parser will return the original `retval`.\n *\n * ### options which can be set up per parser instance\n *\n * yy: {\n * pre_parse: function(yy)\n * optional: is invoked before the parse cycle starts (and before the first\n * invocation of `lex()`) but immediately after the invocation of\n * `parser.pre_parse()`).\n * post_parse: function(yy, retval, parseInfo) { return retval; }\n * optional: is invoked when the parse terminates due to success ('accept')\n * or failure (even when exceptions are thrown).\n * `retval` contains the return value to be produced by `Parser.parse()`;\n * this function can override the return value by returning another.\n * When it does not return any value, the parser will return the original\n * `retval`.\n * This function is invoked immediately before `parser.post_parse()`.\n *\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * quoteName: function(name),\n * optional: overrides the default `quoteName` function.\n * }\n *\n * parser.lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are \"extended regex format\" requiring the\n * `XRegExp` library. When this `%option` has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n"); return out; }; @@ -26342,7 +26656,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi generatorMixin.generateAMDModule = function generateAMDModule(opt) { opt = this.__prepareOptions(opt); var module = this.generateModule_(); - var out = [this.generateGenericHeaderComment(), '', 'define(function (require) {', module.initCode, module.commonCode, '', 'var parser = ' + module.moduleCode, module.modulePostlude]; + var out = [this.generateGenericHeaderComment(), '', 'define(function (require) {', module.initCode, module.commonCode, '', 'let parser = ' + module.moduleCode, module.modulePostlude]; if (this.lexer && this.lexer.generateModule) { var lexSrc = this.lexer.generateModule(); @@ -26361,7 +26675,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi lrGeneratorMixin.generateESModule = function generateESModule(opt) { opt = this.__prepareOptions(opt); var module = this.generateModule_(); - var out = [this.generateGenericHeaderComment(), '', module.initCode, module.commonCode, '', 'var parser = ' + module.moduleCode, module.modulePostlude]; + var out = [this.generateGenericHeaderComment(), '', module.initCode, module.commonCode, '', 'let parser = ' + module.moduleCode, module.modulePostlude]; if (this.lexer && this.lexer.generateModule) { var lexSrc = this.lexer.generateModule(); @@ -26377,12 +26691,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(_templateObject156(), moduleImportsAsCode, moduleNameAsCode.trim())); + out.push(rmCommonWS$5(_templateObject157(), moduleImportsAsCode, moduleNameAsCode.trim())); exportMain = 'main: yyExecMain,'; - invokeMain = rmCommonWS$5(_templateObject157()); + invokeMain = rmCommonWS$5(_templateObject158()); } - out.push(rmCommonWS$5(_templateObject158(), invokeMain, exportMain)); + out.push(rmCommonWS$5(_templateObject159(), invokeMain, exportMain)); var src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; @@ -26396,10 +26710,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(_templateObject159(), moduleImportsAsCode, moduleNameAsCode.trim()); + main = rmCommonWS$5(_templateObject160(), moduleImportsAsCode, moduleNameAsCode.trim()); } - var out = this.generateModule(opt) + rmCommonWS$5(_templateObject160(), moduleName, moduleName, moduleName, moduleName, main); + var out = this.generateModule(opt) + rmCommonWS$5(_templateObject161(), moduleName, moduleName, moduleName, moduleName, main); opt.exportSourceCode.all = out; return out; }; @@ -26414,13 +26728,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var subModuleName = namespaces.shift(); if (subModuleName != null) { - var moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; + var _moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; if (namespaces.length > 0) { - return 'var ' + subModuleName + ';\n' + '(function (' + subModuleName + ') {\n' + _generateNamespace(namespaces, subModuleName, callback) + '\n})(' + subModuleName + (previousNamespace == null ? '' : ' = ' + moduleName) + ' || (' + moduleName + ' = {}));\n'; + return '(function (' + subModuleName + ') {\n' + _generateNamespace(namespaces, subModuleName, callback) + '\n})(' + subModuleName + (previousNamespace == null ? '' : ' = ' + _moduleName) + ' || (' + _moduleName + ' = {}));\n'; } - return callback(moduleName); + return callback(_moduleName); } return ''; @@ -26429,7 +26743,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var sourceCodeDef = self.generateModuleExpr(); out += "\n ".concat(sourceCodeDef.init, "\n "); out += _generateNamespace(moduleName.split('.'), null, function _generateNamespace_cb(moduleName) { - var name = moduleName.match(/\./) ? moduleName : 'var ' + moduleName; + var name = moduleName.match(/\./) ? moduleName : 'let ' + moduleName; return "\n ".concat(name, " = ").concat(sourceCodeDef.src, "\n "); }); opt.exportSourceCode.all = out; @@ -26437,12 +26751,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; generatorMixin.generateModuleExpr = function generateModuleExpr() { - var out; - var opt = this.__prepareOptions(); var module = this.generateModule_(); - out = ['(function () {', module.commonCode, '', 'var parser = ' + module.moduleCode, module.modulePostlude]; + var out = ['(function () {', module.commonCode, '', 'let parser = ' + module.moduleCode, module.modulePostlude]; if (this.lexer && this.lexer.generateModule) { var lexSrc = this.lexer.generateModule(); @@ -26491,7 +26803,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // if (typeof lexer.yyleng === 'undefined') { // lexer.yyleng = 0; // } - // var yyleng; + // let yyleng; // ... parseFn = parseFn.replace(/, yyleng\b/g, '').replace(/^.*?\bvar yyleng\b.*?$/gm, '').replace(/\s+if\b.*?\.yyleng\b.*?\{[^}]+\}/g, '\n').replace(/^.*?\byyleng = .+$/gm, '').replace(/^.*?\byyleng\b.*?=.*?\byyleng\b.*?$/gm, ''); @@ -26502,7 +26814,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // so we can kill the local var and its usage at least: actionFn = actionFn.replace(/, yylineno\b/g, ''); // remove: // - // var yylineno; + // let yylineno; // ... parseFn = parseFn.replace(/\bvar yylineno\b.*?$/gm, '').replace(/, yylineno\b/g, '').replace(/^.*?\byylineno\b.*?=.*?\byylineno\b.*?$/gm, ''); @@ -26537,7 +26849,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!info.actionsUseLocationTracking) { actionFn = actionFn.replace(/\byyloc, (.*?), yylstack\b/g, '$1'); // remove: // - // var yyloc = lexer.yylloc; + // let yyloc = lexer.yylloc; // lstack[sp] = yyloc; // ... // lstack[sp] = copy_yylloc(lexer.yylloc); @@ -26562,11 +26874,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // } // // and - // + // // if (sp >= 0 && typeof vstack[sp] !== 'undefined') { // retval = vstack[sp]; // } - // + // // but keep the yyval declaration as either location tracking MAY // still be employed by the grammar OR the grammar uses advanced // code which uses `yyval` as a run-time store which carries data @@ -26605,12 +26917,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (info.actionsAreAllDefault) { // remove // - // var yyval = { + // let yyval = { // $: true, // _$: undefined, // yy: sharedState_yy // }; - parseFn = parseFn.replace(/\s+var yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); + parseFn = parseFn.replace(/\s+let yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); } } @@ -26624,10 +26936,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // option set or by invoking JISON with the debug flag `-t`. // remove: // - // var yydebug = false; + // let yydebug = false; // ... and delete yydebug function definition ... // ... // if (yydebug) yydebug(...); + // ... + // if (yydebug) { + // yydebug(...); + // } // // and // @@ -26635,9 +26951,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // if (sharedState_yy.yydebug === false) { // yydebug = undefined; // } - parseFn = parseFn.replace(/\s+var yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') // strip multi-line `if (debug) yydebug(..., {...});` statements + parseFn = parseFn.replace(/\s+let yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') // strip multi-line `if (debug) { yydebug(..., {...}); }` statements // also strip simple yet possibly multi-line `if (debug) yydebug('...');` statements - .replace(/\n\s+if\s+\(yydebug\)\s+yydebug\([^]+?['}]\);[^\r\n]*?/g, '\n\n\n\n\n\n\n\n\n') // strip single-line `yydebug(...);` statements + .replace(/\n\s+if\s+\(yydebug\)\s+\{[\r\n]+\s+yydebug\([^]+?}\);[\s\r\n]+}\s*/g, '\n\n\n\n\n\n\n\n\n').replace(/\n\s+if\s+\(yydebug\)\s+yydebug\([^]+?['}]\);[^\r\n]*?/g, '\n\n\n\n\n\n\n\n\n') // strip single-line `yydebug(...);` statements .replace(/^.*?\byydebug\b[^;]+?\);[^\r\n]*?$/gm, '') // strip `if (sharedState_yy.yydebug) {...}` chunk .replace(/\n\s+\/\/\s*disable\s*debugging.*?[\r\n]+\s+if\s+\(sharedState_yy\.yydebug[^]+?\}/g, '\n\n\n\n'); } @@ -26713,8 +27029,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * ... __reentrant_call_depth ... */ parseFn = parseFn.replace(/\s+try \{([\s\r\n]+this\.__reentrant_call_depth[\s\S]+?)\} catch \(ex\) \{[\s\S]+?\} finally \{([^]+?)\}\s+\/\/\s+\/finally/, function replace_noTryCatch(m, p1, p2) { - p1 = p1.replace(/^ /mg, ' '); - p2 = p2.replace(/^ /mg, ' '); + p1 = p1.replace(/^ {8}/mg, ' '); + p2 = p2.replace(/^ {8}/mg, ' '); return '\n' + p1 + '\n // ... AND FINALLY ...\n' + p2; }).replace(/^[^\n]+\b__reentrant_call_depth\b[^\n]+$/gm, '\n'); } @@ -26771,11 +27087,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!arglist || arglist.length === 0) { parseFn = parseFn.replace(/, parseParams\b/g, ''); parseFn = parseFn.replace(/\bparseParams\b/g, ''); - parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers:\s+parseParamsAsMembers\b/g, ''); + parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers\b/g, ''); } else { parseFn = parseFn.replace(/, parseParams\b/g, ', ' + arglist.join(', ')); parseFn = parseFn.replace(/\bparseParams\b/g, arglist.join(', ')); - parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers:\s+parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { + parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { var s = ','; // determine longest name of the bunch (for formatting the generated code) var max_k_len = 0; @@ -26787,9 +27103,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 i = 0, len = arglist.length; i < len; i++) { - var k = arglist[i]; - s += '\n' + ws + k + ': ' + k + (i < len - 1 ? ',' + wsi2.substr(0, max_k_len - k.length - 1) : wsi2.substr(0, max_k_len - k.length)) + ' // parseParams::' + k; + 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; } return s; @@ -26826,11 +27142,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // // if (wantTokenStack) { // try { - // var ast = esprima.parse(parseFn); - // var stackAst = esprima.parse(String(tokenStackLex)).body[0]; + // let ast = esprima.parse(parseFn); + // let stackAst = esprima.parse(String(tokenStackLex)).body[0]; // stackAst.id.name = 'lex'; // - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); // // labeled[0].body = stackAst; // @@ -26840,7 +27156,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // } // } else { // // remove the line: - // // var tstack = []; // token stack + // // let tstack = []; // token stack // parseFn = parseFn.replace(/tstack = .*$/m, ''); // return parseFn; // } @@ -26850,11 +27166,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (wantTokenStack) { // And rename the `tokenStackLex` function to become the new `lex`: return parseFn.replace(/\btokenStackLex\b/g, 'lex'); - } else { - // Also nuke the support declaration statement: - // var tstack = []; - return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); - } + } // Also nuke the support declaration statement: + // let tstack = []; + + + return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); } // returns parse function with/without error recovery code @@ -26862,8 +27178,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var parseFn = fn; // We don't use the Esprima+Escodegen toolchain as those loose the code comments easily; // instead we just chop the code using labels as sentinels for our chopping-it-up regexes: // try { - // var ast = esprima.parse(parseFn); - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("' + + // let ast = esprima.parse(parseFn); + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("' + // (!hasErrorRecovery ? '_handle_error_with_recovery' : '_handle_error_no_recovery') + // '"))', ast); // Jison.print('labeled: ', labeled); @@ -26879,7 +27195,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!hasErrorRecovery) { // Also nuke the support declaration statement: - // var recovering = 0; + // let recovering = 0; // and the recovery support statements: // if (recovering > 0) { // recovering--; @@ -26887,15 +27203,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // and these yydebug particles: // , recovering: recovering // ASSERT(recovering === 0); - parseFn = parseFn.replace(/^\s*var recovering.*$/gm, '').replace(/, recovering: recovering/g, '').replace(/^.*?recovering =.*$/gm, '').replace(/^\s+recovering[,]?\s*$/gm, '').replace(/[ \t]*if \(recovering[^\)]+\) \{[^\0]+?\}\n/g, '\n\n\n\n\n') // And nuke the preErrorSymbol code as it is unused when there's no error recovery + parseFn = parseFn.replace(/^\s*let recovering.*$/gm, '').replace(/, recovering: recovering/g, '').replace(/^.*?recovering =.*$/gm, '').replace(/^\s+recovering[,]?\s*$/gm, '').replace(/[ \t]*if \(recovering[^\)]+\) \{[^\0]+?\}\n/g, '\n\n\n\n\n') // And nuke the preErrorSymbol code as it is unused when there's no error recovery // if (!preErrorSymbol) { // ... keep this chunk ... // } else { // ... KILL this chunk ... // } - .replace(/\s+if[^a-z]+preErrorSymbol.*?\{\s*\/\/[^\n]+([\s\S]+?)\} else \{[\s\S]+?\}\n\s+\}\n/g, '\n$1\n\n\n\n').replace(/^\s+(?:var )?preErrorSymbol = .*$/gm, '').replace(/^.*?\bpreErrorSymbol =.*$/gm, '') // And nuke the support declaration statement: - // var lastEofErrorStateDepth = 0; - .replace(/^\s*var lastEofErrorStateDepth.*$/gm, ''); + .replace(/\s+if[^a-z]+preErrorSymbol.*?\{\s*\/\/[^\n]+([\s\S]+?)\} else \{[\s\S]+?\}\n\s+\}\n/g, '\n$1\n\n\n\n').replace(/^\s+(?:let )?preErrorSymbol = .*$/gm, '').replace(/^.*?\bpreErrorSymbol =.*$/gm, '') // And nuke the support declaration statement: + // let lastEofErrorStateDepth = 0; + .replace(/^\s*let lastEofErrorStateDepth.*$/gm, ''); } return parseFn; @@ -26917,8 +27233,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi exportDest.parseTable = this.table; exportDest.defaultParseActions = this.defaultActions; exportDest.parseProductions = this.productions_; - var exportSourceCode = this.options.exportSourceCode; - assert__default['default'](exportSourceCode); var tableCode; switch (this.options.compressTables | 0) { @@ -26953,10 +27267,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var a = Object.keys(tbl); a.sort(); var nt = {}; - var k; for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); + var k = a[i]; // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number // and we do not want `$eof`/`EOF` to show up in the symbol tables of generated parsers // as we use `$end` for that one! @@ -26973,11 +27286,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function produceTerminalTable(tbl) { var a = Object.keys(tbl); var nt = {}; - var k, v; for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; - v = tbl[k]; + var k = a[i]; + var v = tbl[k]; nt[v] = +k; // convert numeric key back to number type; all terminals have numeric keys } @@ -27120,11 +27432,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi reachable: production.reachable }; // Determine state for given production, if it's not a production that's listed as part of a state: - var chk, idx; var lst = prods.rules[nonterm]; - chk = rv.symbol + ' : ' + rv.handle; + var chk = rv.symbol + ' : ' + rv.handle; - for (idx in lst) { + for (var idx in lst) { idx = +idx; var p = lst[idx]; @@ -27143,8 +27454,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (base && base.rules) { var pr = base.rules[rv.base_symbol]; - for (idx in pr) { - var bprod = pr[idx]; + for (var _idx in pr) { + var bprod = pr[_idx]; if (bprod.symbol + ' : ' + bprod.handle === chk) { assert__default['default'](rv.base_state === -1); @@ -27226,9 +27537,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } var nt = tbl; - var sbn; - for (sbn in nt) { + for (var sbn in nt) { var orig_symbol = get_orig_symbol(sbn); var item = nt[sbn]; var firsts = item.first; @@ -27251,12 +27561,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - for (sbn in prods.first) { - prods.first[sbn] = get_orig_symbol_set(prods.first[sbn]); + for (var _sbn in prods.first) { + prods.first[_sbn] = get_orig_symbol_set(prods.first[_sbn]); } - for (sbn in prods.follows) { - prods.follows[sbn] = get_orig_symbol_set(prods.follows[sbn]); + for (var _sbn2 in prods.follows) { + prods.follows[_sbn2] = get_orig_symbol_set(prods.follows[_sbn2]); } if (this.newg) { @@ -27412,7 +27722,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi lrGeneratorMixin.generateErrorClass = function () { // --- START parser error class --- - var prelude = "\n// See also:\n// http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n// but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n// with userland code which might access the derived class in a 'classic' way.\nfunction JisonParserError(msg, hash) {\n \"use strict\";\n\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'JisonParserError'\n });\n\n if (msg == null) msg = '???';\n\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n var stacktrace;\n if (hash && hash.exception instanceof Error) {\n var ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty('captureStackTrace')) { // V8/Chrome engine\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(JisonParserError.prototype, Error.prototype);\n} else {\n JisonParserError.prototype = Object.create(Error.prototype);\n}\nJisonParserError.prototype.constructor = JisonParserError;\nJisonParserError.prototype.name = 'JisonParserError';\n"; // --- END parser error class --- + var prelude = "\n// See also:\n// http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n// but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n// with userland code which might access the derived class in a 'classic' way.\nfunction JisonParserError(msg, hash) {\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'JisonParserError'\n });\n\n if (msg == null) msg = '???';\n\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n let stacktrace;\n if (hash && hash.exception instanceof Error) {\n let ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty('captureStackTrace')) { // V8/Chrome engine\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(JisonParserError.prototype, Error.prototype);\n} else {\n JisonParserError.prototype = Object.create(Error.prototype);\n}\nJisonParserError.prototype.constructor = JisonParserError;\nJisonParserError.prototype.name = 'JisonParserError';\n"; // --- END parser error class --- return { commonCode: '', @@ -27439,7 +27749,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // e.g., x([1, 3, 4], [6, 7], { x: 1, y: 2 }) = { 1: [6, 7]; 3: [6, 7], 4: [6, 7], x: 1, y: 2 } - var compressor1ObjectCode = "\nfunction x(k, v, o) {\n o = o || {};\n for (var l = k.length; l--; ) {\n o[k[l]] = v;\n }\n return o;\n}\n"; // Generate code that represents the specified parser table + var compressor1ObjectCode = "\nfunction x(k, v, o) {\n o = o || {};\n for (let l = k.length; l--; ) {\n o[k[l]] = v;\n }\n return o;\n}\n"; // Generate code that represents the specified parser table lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productions) { var tableCode = JSON.stringify(table, null, 2); @@ -27452,21 +27762,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi tableCode = tableCode.replace(/\{[\s\r\n]*\d+:[^\}]+,[\s\r\n]*\d+:[^\}]+\}/g, function (object) { // Find the value that occurs with the highest number of keys - var value, - frequentValue, - key, - keys = {}, - keyCount, - maxKeyCount = 0, - keyValue, - keyValues = [], - keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; + var frequentValue; + var keys = {}; + var maxKeyCount = 0; + var keyValue; + var keyValues = []; + var keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; while (keyValue = keyValueMatcher.exec(object)) { // For each value, store the keys where that value occurs - key = keyValue[1]; - value = keyValue[2].trim(); - keyCount = 1; + var key = keyValue[1]; + var value = keyValue[2].trim(); + var keyCount = 1; if (!(value in keys)) { keys[value] = [key]; @@ -27484,10 +27791,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (maxKeyCount > 1) { // Collect all non-frequent values into a remainder object - for (value in keys) { - if (value !== frequentValue) { - for (var k = keys[value], i = 0, l = k.length; i < l; i++) { - keyValues.push(k[i] + ':' + value); + for (var _value5 in keys) { + if (_value5 !== frequentValue) { + for (var k = keys[_value5], i = 0, l = k.length; i < l; i++) { + keyValues.push(k[i] + ':' + _value5); } } } @@ -27536,7 +27843,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } if (frequentLists.length > 0) { - prelude.push('var u = [\n ' + frequentLists.join(',\n ') + '\n];'); + prelude.push('let u = [\n ' + frequentLists.join(',\n ') + '\n];'); prelude.push(''); } // Return the variable initialization code and the table code @@ -27583,11 +27890,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); function reportColumnsForCompression(def_arr) { - var i, key, len; var report = []; - len = 0; + var len = 0; - for (key in def_arr) { + for (var key in def_arr) { len = Math.max(len, def_arr[key].length); } @@ -27601,48 +27907,52 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } var track_prev4delta = {}; - var c, delta, val, delta_val; var line = []; line.push('║'); - for (c in def_arr) { - key = clip(c, col_width); - delta = clip('∆', col_delta_width); - line.push(key); + for (var _c3 in def_arr) { + var _key10 = clip(_c3, col_width); + + var delta = clip('∆', col_delta_width); + line.push(_key10); line.push('┊'); line.push(delta); line.push('║'); - track_prev4delta[c] = 10000000; + track_prev4delta[_c3] = 10000000; } report.push(line.join('')); - for (i = 0; i < len; i++) { + for (var i = 0; i < len; i++) { line = []; line.push('║'); - for (c in def_arr) { - var tbl = def_arr[c]; + for (var _c4 in def_arr) { + var val = void 0, + delta_val = void 0; + var tbl = def_arr[_c4]; if (tbl.length > i) { val = tbl[i] || 0; - delta_val = val - track_prev4delta[c]; // negative deltas are jumps: don't treat those as delta but as absolute value, sign-flipped: + delta_val = val - track_prev4delta[_c4]; // 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[c] = val; + track_prev4delta[_c4] = val; } else { val = '.'; delta_val = '.'; } - key = clip(val, col_width); - delta = clip(delta_val, col_delta_width); - line.push(key); + var _key11 = clip(val, col_width); + + var _delta = clip(delta_val, col_delta_width); + + line.push(_key11); line.push('┊'); - line.push(delta); + line.push(_delta); line.push('║'); } @@ -27675,9 +27985,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } var def_arr = { - 'len': len_col, - 'pop': pop_col, - 'rule': rule_col + len: len_col, + pop: pop_col, + rule: rule_col }; return def_arr; } // table is hash of 1/2-len arrays: @@ -27700,8 +28010,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } var def_arr = { - 'idx': idx_col, - 'goto': goto_col + idx: idx_col, + goto: goto_col }; return def_arr; } @@ -27719,16 +28029,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var mode_col = []; // column: symbol hash entry goto state value if array slot type: var goto_col = []; // // column: merged: state_col + goto_col: - // var next_col = []; + // let next_col = []; var row_count = table.length; for (var state = 0; state < row_count; state++) { var hashtable = table[state]; var count = 0; - var symbol; - for (symbol in hashtable) { + for (var symbol in hashtable) { symbol = +symbol; symbol_col.push(symbol); var slot = hashtable[symbol]; @@ -27762,12 +28071,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } var def_arr = { - 'len': len_col, - 'symbol': symbol_col, - 'type': type_col, - 'state': state_col, - 'mode': mode_col, - 'goto': goto_col //'next': next_col, + len: len_col, + symbol: symbol_col, + type: type_col, + state: state_col, + mode: mode_col, + goto: goto_col //'next': next_col, }; return def_arr; @@ -27777,11 +28086,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function generateColumn(name, col) { var rv = []; - var i, j, len, l; - for (i = 0, len = col.length; i < len; i++) { + for (var i = 0, len = col.length; i < len; i++) { // try basic run-length encoding first: var v = col[i]; + var j = void 0; for (j = i + 1; j < len; j++) { if (col[j] !== v) { @@ -27811,6 +28120,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var upper_bound = i - 2; for (j = 0; j < upper_bound; j++) { + var l = void 0; + for (l = 0; col[j + l] === col[i + l]; l++) {// No need to check for: // if (j + l === i) break; // because we know how the c() helper function will regenerate @@ -27879,10 +28190,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var tableDef = analyzeGotoTableForCompression(table); var defaultActionsDef = analyzeSetForCompression(defaultActions); var productionsDef = analyzeTableForCompression(productions); - var bp_code_container = "\n // helper: reconstruct the productions[] table\n function bp(s) {\n var rv = [];\n var p = s.pop;\n var r = s.rule;\n for (var i = 0, l = p.length; i < l; i++) {\n rv.push([\n p[i],\n r[i]\n ]);\n }\n return rv;\n }\n "; - var bda_code_container = "\n // helper: reconstruct the defaultActions[] table\n function bda(s) {\n var rv = {};\n var d = s.idx;\n var g = s.goto;\n for (var i = 0, l = d.length; i < l; i++) {\n var j = d[i];\n rv[j] = g[i];\n }\n return rv;\n }\n "; - var bt_code_container = "\n // helper: reconstruct the 'goto' table\n function bt(s) {\n var rv = [];\n var d = s.len;\n var y = s.symbol;\n var t = s.type;\n var a = s.state;\n var m = s.mode;\n var g = s.goto;\n for (var i = 0, l = d.length; i < l; i++) {\n var n = d[i];\n var q = {};\n for (var j = 0; j < n; j++) {\n var z = y.shift();\n switch (t.shift()) {\n case 2:\n q[z] = [\n m.shift(),\n g.shift()\n ];\n break;\n\n case 0:\n q[z] = a.shift();\n break;\n\n default:\n // type === 1: accept\n q[z] = [\n 3\n ];\n }\n }\n rv.push(q);\n }\n return rv;\n }\n "; - var c_s_u_code_container = "\n // helper: runlength encoding with increment step: code, length: step (default step = 0)\n // `this` references an array\n function s(c, l, a) {\n a = a || 0;\n for (var i = 0; i < l; i++) {\n this.push(c);\n c += a;\n }\n }\n\n // helper: duplicate sequence from *relative* offset and length.\n // `this` references an array\n function c(i, l) {\n i = this.length - i;\n for (l += i; i < l; i++) {\n this.push(this[i]);\n }\n }\n\n // helper: unpack an array using helpers and data, all passed in an array argument 'a'.\n function u(a) {\n var rv = [];\n for (var i = 0, l = a.length; i < l; i++) {\n var e = a[i];\n // Is this entry a helper function?\n if (typeof e === 'function') {\n i++;\n e.apply(rv, a[i]);\n } else {\n rv.push(e);\n }\n }\n return rv;\n }\n "; + var bp_code_container = "\n // helper: reconstruct the productions[] table\n function bp(s) {\n let rv = [];\n let p = s.pop;\n let r = s.rule;\n for (let i = 0, l = p.length; i < l; i++) {\n rv.push([\n p[i],\n r[i]\n ]);\n }\n return rv;\n }\n "; + var bda_code_container = "\n // helper: reconstruct the defaultActions[] table\n function bda(s) {\n let rv = {};\n let d = s.idx;\n let g = s.goto;\n for (let i = 0, l = d.length; i < l; i++) {\n let j = d[i];\n rv[j] = g[i];\n }\n return rv;\n }\n "; + var bt_code_container = "\n // helper: reconstruct the 'goto' table\n function bt(s) {\n let rv = [];\n let d = s.len;\n let y = s.symbol;\n let t = s.type;\n let a = s.state;\n let m = s.mode;\n let g = s.goto;\n for (let i = 0, l = d.length; i < l; i++) {\n let n = d[i];\n let q = {};\n for (let j = 0; j < n; j++) {\n let z = y.shift();\n switch (t.shift()) {\n case 2:\n q[z] = [\n m.shift(),\n g.shift()\n ];\n break;\n\n case 0:\n q[z] = a.shift();\n break;\n\n default:\n // type === 1: accept\n q[z] = [\n 3\n ];\n }\n }\n rv.push(q);\n }\n return rv;\n }\n "; + var c_s_u_code_container = "\n // helper: runlength encoding with increment step: code, length: step (default step = 0)\n // `this` references an array\n function s(c, l, a) {\n a = a || 0;\n for (let i = 0; i < l; i++) {\n this.push(c);\n c += a;\n }\n }\n\n // helper: duplicate sequence from *relative* offset and length.\n // `this` references an array\n function c(i, l) {\n i = this.length - i;\n for (l += i; i < l; i++) {\n this.push(this[i]);\n }\n }\n\n // helper: unpack an array using helpers and data, all passed in an array argument 'a'.\n function u(a) {\n let rv = [];\n for (let i = 0, l = a.length; i < l; i++) {\n let e = a[i];\n // Is this entry a helper function?\n if (typeof e === 'function') {\n i++;\n e.apply(rv, a[i]);\n } else {\n rv.push(e);\n }\n }\n return rv;\n }\n "; has_compressed_a_table = false; var tc = generateCompressedGotoTable(tableDef); var compressGotoTable = has_compressed_a_table; @@ -27910,13 +28221,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi productionsCode: productionsCode }; }; // --- START of commonJsMain chunk --- - // + // // default main method for generated commonjs modules - var commonJsMain = "\nfunction (args) {\n \"use strict\";\n\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 var source = fs.readFileSync(path.normalize(args[1]), 'utf8');\n var 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 var 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 = "\nvar fs = require('fs');\nvar path = require('path');\n"; // debug mixin for LR parser generators + var commonJsMainImports = "\nconst fs = require('fs');\nconst path = require('path');\n"; // debug mixin for LR parser generators function printAction(a, gen) { var s = a[0] === SHIFT ? 'shift token (then go to state ' + a[1] + ')' : a[0] === REDUCE ? 'reduce by rule: ' + gen.productions[a[1]] : a[0] === ACCEPT ? 'accept' : 'UNDEFINED ACTION: ' + a[0]; @@ -27962,8 +28273,8 @@ 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(_templateObject161(), sourceCodeDef.init, sourceCodeDef.src); - var p = code_exec$2(sourcecode, function generated_code_exec_wrapper_jison(sourcecode) { + var sourcecode = rmCommonWS$5(_templateObject162(), 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); var rv = eval(sourcecode); @@ -27971,7 +28282,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }, mkStdOptions$1(this.options, { dumpSourceCodeOnFailure: this.DEBUG, throwErrorOnCompileFailure: true - }), "parser"); + }), 'parser'); assert__default['default'](_typeof(p) === 'object'); assert__default['default'](typeof p.parse === 'function'); assert__default['default'](typeof p.parser === 'undefined'); @@ -28038,7 +28349,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi parser$4.warn = generator.warn; parser$4.error = generator.error; // --- START parser Error class chunk --- - var parseErrorSourceCode = "\nfunction parseError(str, hash, ExceptionClass) {\n \"use strict\";\n\n if (hash.recoverable) {\n if (typeof this.trace === 'function') {\n this.trace(str);\n }\n hash.destroy(); // destroy... well, *almost*!\n } else {\n if (typeof this.trace === 'function') {\n this.trace(str);\n }\n if (!ExceptionClass) {\n ExceptionClass = this.JisonParserError;\n }\n throw new ExceptionClass(str, hash);\n }\n}\n"; // --- END of parseErrorSourceCode chunk --- + var parseErrorSourceCode = "\nfunction parseError(str, hash, ExceptionClass) {\n if (hash.recoverable) {\n if (typeof this.trace === 'function') {\n this.trace(str);\n }\n hash.destroy(); // destroy... well, *almost*!\n } else {\n if (typeof this.trace === 'function') {\n this.trace(str);\n }\n if (!ExceptionClass) {\n ExceptionClass = this.JisonParserError;\n }\n throw new ExceptionClass(str, hash);\n }\n}\n"; // --- END of parseErrorSourceCode chunk --- chkBugger$3(parseErrorSourceCode); parser$4.parseError = lrGeneratorMixin.parseError = eval(parseErrorSourceCode + '\n\nparseError;'); @@ -28054,7 +28365,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // in the generated code: - var define_parser_APIs_1 = "\n TERROR: 2,\n EOF: 1,\n\n // internals: defined here so the object *structure* doesn't get modified by parse() et al,\n // thus helping JIT compilers like Chrome V8.\n originalQuoteName: null,\n originalParseError: null,\n cleanupAfterParse: null,\n constructParseErrorInfo: null,\n yyMergeLocationInfo: null,\n copy_yytext: null,\n copy_yylloc: null,\n\n __reentrant_call_depth: 0, // INTERNAL USE ONLY\n __error_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup\n __error_recovery_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup\n\n // APIs which will be set up depending on user action code analysis:\n //yyRecovering: 0,\n //yyErrOk: 0,\n //yyClearIn: 0,\n\n // Helper APIs\n // -----------\n\n // Helper function which can be overridden by user code later on: put suitable quotes around\n // literal IDs in a description string.\n quoteName: function parser_quoteName(id_str) {\n \"use strict\";\n\n return '\"' + id_str + '\"';\n },\n\n // Return the name of the given symbol (terminal or non-terminal) as a string, when available.\n //\n // Return NULL when the symbol is unknown to the parser.\n getSymbolName: function parser_getSymbolName(symbol) {\n \"use strict\";\n\n if (this.terminals_[symbol]) {\n return this.terminals_[symbol];\n }\n\n // Otherwise... this might refer to a RULE token i.e. a non-terminal: see if we can dig that one up.\n //\n // An example of this may be where a rule's action code contains a call like this:\n //\n // parser.getSymbolName(#$)\n //\n // to obtain a human-readable name of the current grammar rule.\n var s = this.symbols_;\n for (var key in s) {\n if (s[key] === symbol) {\n return key;\n }\n }\n return null;\n },\n\n // Return a more-or-less human-readable description of the given symbol, when available,\n // or the symbol itself, serving as its own 'description' for lack of something better to serve up.\n //\n // Return NULL when the symbol is unknown to the parser.\n describeSymbol: function parser_describeSymbol(symbol) {\n \"use strict\";\n\n if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) {\n return this.terminal_descriptions_[symbol];\n }\n else if (symbol === this.EOF) {\n return 'end of input';\n }\n var id = this.getSymbolName(symbol);\n if (id) {\n return this.quoteName(id);\n }\n return null;\n },\n\n // Produce a (more or less) human-readable list of expected tokens at the point of failure.\n //\n // The produced list may contain token or token set descriptions instead of the tokens\n // themselves to help turning this output into something that easier to read by humans\n // unless `do_not_describe` parameter is set, in which case a list of the raw, *numeric*,\n // expected terminals and nonterminals is produced.\n //\n // The returned list (array) will not contain any duplicate entries.\n collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) {\n \"use strict\";\n\n var TERROR = this.TERROR;\n var tokenset = [];\n var check = {};\n // Has this (error?) state been outfitted with a custom expectations description text for human consumption?\n // If so, use that one instead of the less palatable token set.\n if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) {\n return [\n this.state_descriptions_[state]\n ];\n }\n for (var p in this.table[state]) {\n p = +p;\n if (p !== TERROR) {\n var d = do_not_describe ? p : this.describeSymbol(p);\n if (d && !check[d]) {\n tokenset.push(d);\n check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries.\n }\n }\n }\n return tokenset;\n }\n"; // --- END of define_parser_APIs_1 chunk --- + var define_parser_APIs_1 = "\n TERROR: 2,\n EOF: 1,\n\n // internals: defined here so the object *structure* doesn't get modified by parse() et al,\n // thus helping JIT compilers like Chrome V8.\n originalQuoteName: null,\n originalParseError: null,\n cleanupAfterParse: null,\n constructParseErrorInfo: null,\n yyMergeLocationInfo: null,\n copy_yytext: null,\n copy_yylloc: null,\n\n __reentrant_call_depth: 0, // INTERNAL USE ONLY\n __error_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup\n __error_recovery_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup\n\n // APIs which will be set up depending on user action code analysis:\n //yyRecovering: 0,\n //yyErrOk: 0,\n //yyClearIn: 0,\n\n // Helper APIs\n // -----------\n\n // Helper function which can be overridden by user code later on: put suitable quotes around\n // literal IDs in a description string.\n quoteName: function parser_quoteName(id_str) {\n return '\"' + id_str + '\"';\n },\n\n // Return the name of the given symbol (terminal or non-terminal) as a string, when available.\n //\n // Return NULL when the symbol is unknown to the parser.\n getSymbolName: function parser_getSymbolName(symbol) {\n if (this.terminals_[symbol]) {\n return this.terminals_[symbol];\n }\n\n // Otherwise... this might refer to a RULE token i.e. a non-terminal: see if we can dig that one up.\n //\n // An example of this may be where a rule's action code contains a call like this:\n //\n // parser.getSymbolName(#$)\n //\n // to obtain a human-readable name of the current grammar rule.\n const s = this.symbols_;\n for (let key in s) {\n if (s[key] === symbol) {\n return key;\n }\n }\n return null;\n },\n\n // Return a more-or-less human-readable description of the given symbol, when available,\n // or the symbol itself, serving as its own 'description' for lack of something better to serve up.\n //\n // Return NULL when the symbol is unknown to the parser.\n describeSymbol: function parser_describeSymbol(symbol) {\n if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) {\n return this.terminal_descriptions_[symbol];\n } else if (symbol === this.EOF) {\n return 'end of input';\n }\n\n let id = this.getSymbolName(symbol);\n if (id) {\n return this.quoteName(id);\n }\n return null;\n },\n\n // Produce a (more or less) human-readable list of expected tokens at the point of failure.\n //\n // The produced list may contain token or token set descriptions instead of the tokens\n // themselves to help turning this output into something that easier to read by humans\n // unless `do_not_describe` parameter is set, in which case a list of the raw, *numeric*,\n // expected terminals and nonterminals is produced.\n //\n // The returned list (array) will not contain any duplicate entries.\n collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) {\n const TERROR = this.TERROR;\n let tokenset = [];\n let check = {};\n\n // Has this (error?) state been outfitted with a custom expectations description text for human consumption?\n // If so, use that one instead of the less palatable token set.\n if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) {\n return [\n this.state_descriptions_[state]\n ];\n }\n for (let p in this.table[state]) {\n p = +p;\n if (p !== TERROR) {\n let d = do_not_describe ? p : this.describeSymbol(p);\n if (d && !check[d]) {\n tokenset.push(d);\n check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries.\n }\n }\n }\n return tokenset;\n }\n"; // --- END of define_parser_APIs_1 chunk --- var api_set = new Function('', 'return { ' + define_parser_APIs_1 + ' };')(); @@ -28063,7 +28374,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } // --- START parser kernel --- - parser$4.parse = "\nfunction parse(input, parseParams) {\n \"use strict\";\n\n var self = this;\n var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage)\n var sstack = new Array(128); // state stack: stores states (column storage)\n var tstack = []; // token stack (only used when `%options token_stack` support has been enabled)\n var vstack = new Array(128); // semantic value stack\n var lstack = new Array(128); // location stack\n var table = this.table;\n var sp = 0; // 'stack pointer': index into the stacks\n var yyloc;\n var yytext;\n var yylineno;\n var yyleng;\n\n var symbol = 0;\n var preErrorSymbol = 0;\n var lastEofErrorStateDepth = Infinity;\n var recoveringErrorInfo = null;\n var recovering = 0; // (only used when the grammar contains error recovery rules)\n var TERROR = this.TERROR;\n var EOF = this.EOF;\n var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3;\n var NO_ACTION = [0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */];\n\n var lexer;\n if (this.__lexer__) {\n lexer = this.__lexer__;\n } else {\n lexer = this.__lexer__ = Object.create(this.lexer);\n }\n\n var sharedState_yy = {\n parseError: undefined,\n quoteName: undefined,\n lexer: undefined,\n parser: undefined,\n pre_parse: undefined,\n post_parse: undefined,\n pre_lex: undefined,\n post_lex: undefined,\n parseParamsAsMembers: parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes!\n };\n\n var ASSERT;\n if (typeof assert !== 'function') {\n ASSERT = function JisonAssert(cond, msg) {\n \"use strict\";\n\n if (!cond) {\n throw new Error('assertion failed: ' + (msg || '***'));\n }\n };\n } else {\n ASSERT = assert;\n }\n\n this.yyGetSharedState = function yyGetSharedState() {\n return sharedState_yy;\n };\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n this.yyGetErrorInfoTrack = function yyGetErrorInfoTrack() {\n return recoveringErrorInfo;\n };\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // shallow clone objects & arrays, straight copy of simple `src` values\n // e.g. `lexer.yytext` MAY be a complex value object,\n // rather than a simple string/value.\n //\n // https://jsperf.com/new-array-vs-splice-vs-slice/72\n // https://jsperf.com/instanceof-vs-typeof/20\n // benchmark:: http://127.0.0.1:8080/example/jsperf/#testfile=test0020-typeof-instanceof-isArray.json5\n // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5\n //\n function shallow_copy(src) {\n \"use strict\";\n\n if (src && typeof src === 'object') {\n // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned\n // using their constructor:\n if (src.constructor !== Object) {\n if (Array.isArray(src)) {\n return src.slice();\n }\n var dst = new src.constructor(src);\n\n // and make sure all custom attributes are added to the clone:\n shallow_copy_noclobber(dst, src);\n return dst;\n }\n // native objects must be cloned a different way:\n //\n //return Object.assign({}, src);\n var dst = {};\n shallow_copy_noclobber(dst, src);\n return dst;\n }\n return src;\n }\n // add elements from `src` to `dst` when:\n // - either the element does not yet exist in `src`\n // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst`\n function shallow_copy_noclobber(dst, src) {\n \"use strict\";\n\n const chk = Object.prototype.hasOwnProperty;\n for (var k in src) {\n if (!(k in dst)) {\n if (chk.call(src, k)) {\n dst[k] = src[k];\n }\n }\n else {\n if (src[k] != null && dst[k] == null && chk.call(src, k)) {\n dst[k] = src[k];\n }\n }\n }\n }\n function copy_yylloc_native(loc) {\n \"use strict\";\n\n var rv = shallow_copy(loc);\n // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries:\n if (rv) {\n rv.range = rv.range.slice();\n }\n return rv;\n }\n\n // copy state\n shallow_copy_noclobber(sharedState_yy, this.yy);\n\n sharedState_yy.lexer = lexer;\n sharedState_yy.parser = this;\n\n // allow userland code to override the yytext and yylloc copy/clone functions:\n this.copy_yytext = this.options.copy_yytext || sharedState_yy.copy_yytext || shallow_copy;\n this.copy_yylloc = this.options.copy_yylloc || sharedState_yy.copy_yylloc || copy_yylloc_native;\n\n var yydebug = false;\n if (this.options.debug) {\n yydebug = function yydebug_impl(msg, obj) {\n \"use strict\";\n\n var ref_list;\n var ref_names;\n\n function deepClone(from, sub) {\n \"use strict\";\n\n if (sub == null) {\n ref_list = [];\n ref_names = [];\n sub = 'root';\n }\n if (typeof from === 'function') return '[Function]';\n if (from == null || typeof from !== 'object') return from;\n if (from.constructor !== Object && from.constructor !== Array) {\n return from;\n }\n\n var i = ref_list.indexOf(from);\n if (i >= 0) {\n return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference\n }\n ref_list.push(from);\n ref_names.push(sub);\n\n var to = new from.constructor();\n for (var name in from) {\n if (name === 'parser') continue;\n if (name === 'lexer') continue;\n to[name] = deepClone(from[name], name);\n }\n return to;\n }\n\n obj = obj || {};\n if (obj.symbol) {\n obj.local_yytext = yytext;\n obj.lexer_yytext = lexer.yytext;\n obj.lexer_yylloc = lexer.yylloc;\n obj.lexer_yyllineno = lexer.yyllineno;\n }\n\n // warning: here we fetch from closure (stack et al)\n obj.symbol_stack = stack;\n obj.state_stack = sstack;\n obj.value_stack = vstack;\n obj.location_stack = lstack;\n obj.stack_pointer = sp;\n\n // ready the object for printing:\n obj = deepClone(obj);\n\n // wrap try/catch in a function to help the V8 JIT compiler...\n function yydebug_cvt(obj) {\n \"use strict\";\n\n var js;\n try {\n var re1;\n if (typeof XRegExp === 'undefined') {\n re1 = / \\\"([a-z_][a-z_0-9. ]*)\\\": /ig;\n } else {\n re1 = new XRegExp(' \\\"([\\\\p{Alphabetic}_][\\\\p{Alphabetic}\\\\p{Number}_. ]*)\\\": ', 'g');\n }\n js = JSON.stringify(obj, null, 2)\n .replace(re1, ' $1: ')\n .replace(/[\\n\\s]+/g, ' ')\n // shorten yylloc object dumps too:\n .replace(/\\{ first_line: (\\d+), first_column: (\\d+), last_line: (\\d+), last_column: (\\d+)/g, '{L/C: ($1,$2)..($3,$4)');\n } catch (ex) {\n js = String(obj);\n }\n return js;\n }\n\n self.trace(msg, yydebug_cvt(obj), '\\n');\n };\n }\n\n // disable debugging at run-time ANYWAY when you've *explicitly* set \"yy.yydebug = false\":\n if (sharedState_yy.yydebug === false) {\n yydebug = undefined;\n }\n\n // *Always* setup `yyError`, `YYRECOVERING`, `yyErrOk` and `yyClearIn` functions as it is paramount\n // to have *their* closure match ours -- if we only set them up once,\n // any subsequent `parse()` runs will fail in very obscure ways when\n // these functions are invoked in the user action code block(s) as\n // their closure will still refer to the `parse()` instance which set\n // them up. Hence we MUST set them up at the start of every `parse()` run!\n if (this.yyError) {\n this.yyError = function yyError(str /*, ...args */) {\n \"use strict\";\n\n if (yydebug) yydebug('yyerror: ', { message: str, args: arguments, symbol: symbol, state: state, newState: newState, recovering: recovering, action: action });\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1);\n var expected = this.collect_expected_token_set(state);\n var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0));\n // append to the old one?\n if (recoveringErrorInfo) {\n var esp = recoveringErrorInfo.info_stack_pointer;\n\n recoveringErrorInfo.symbol_stack[esp] = symbol;\n var v = this.shallowCopyErrorInfo(hash);\n v.yyError = true;\n v.errorRuleDepth = error_rule_depth;\n v.recovering = recovering;\n // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH;\n\n recoveringErrorInfo.value_stack[esp] = v;\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc);\n recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n } else {\n recoveringErrorInfo = this.shallowCopyErrorInfo(hash);\n recoveringErrorInfo.yyError = true;\n recoveringErrorInfo.errorRuleDepth = error_rule_depth;\n recoveringErrorInfo.recovering = recovering;\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n\n var expected = this.collect_expected_token_set(state);\n var hash = this.constructParseErrorInfo(str, null, expected, false);\n\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n var args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n hash.extra_error_attributes = args;\n }\n\n return this.parseError(str, hash, this.JisonParserError);\n };\n }\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n if (this.yyRecovering) {\n this.yyRecovering = function yyRecovering() {\n \"use strict\";\n\n if (yydebug) yydebug('yyrecovering: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action });\n return recovering;\n };\n }\n\n if (this.yyErrOk) {\n this.yyErrOk = function yyErrOk() {\n \"use strict\";\n\n if (yydebug) yydebug('yyerrok: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action });\n recovering = 0;\n\n // DO NOT reset/cleanup `recoveringErrorInfo` yet: userland code\n // MAY invoke this API before the error is actually fully\n // recovered, in which case the parser recovery code won't be able\n // to append the skipped tokens to this info object.\n //\n // The rest of the kernel code is safe enough that it won't inadvertedly\n // re-use an old `recoveringErrorInfo` chunk so we'ld better wait\n // with destruction/cleanup until the end of the parse or until another\n // fresh parse error rears its ugly head...\n //\n // if (recoveringErrorInfo && typeof recoveringErrorInfo.destroy === 'function') {\n // recoveringErrorInfo.destroy();\n // recoveringErrorInfo = undefined;\n // }\n };\n }\n\n if (this.yyClearIn) {\n this.yyClearIn = function yyClearIn() {\n \"use strict\";\n\n if (yydebug) yydebug('yyclearin: ', { symbol: symbol, newState: newState, recovering: recovering, action: action, preErrorSymbol: preErrorSymbol });\n if (symbol === TERROR) {\n symbol = 0;\n yytext = null;\n yyleng = 0;\n yyloc = undefined;\n }\n preErrorSymbol = 0;\n };\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // Does the shared state override the default `parseError` that already comes with this instance?\n if (typeof sharedState_yy.parseError === 'function') {\n this.parseError = function parseErrorAlt(str, hash, ExceptionClass) {\n \"use strict\";\n\n if (!ExceptionClass) {\n ExceptionClass = this.JisonParserError;\n }\n return sharedState_yy.parseError.call(this, str, hash, ExceptionClass);\n };\n } else {\n this.parseError = this.originalParseError;\n }\n\n // Does the shared state override the default `quoteName` that already comes with this instance?\n if (typeof sharedState_yy.quoteName === 'function') {\n this.quoteName = function quoteNameAlt(id_str) {\n \"use strict\";\n\n return sharedState_yy.quoteName.call(this, id_str);\n };\n } else {\n this.quoteName = this.originalQuoteName;\n }\n\n // set up the cleanup function; make it an API so that external code can re-use this one in case of\n // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which\n // case this parse() API method doesn't come with a `finally { ... }` block any more!\n //\n // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,\n // or else your `sharedState`, etc. references will be *wrong*!\n this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) {\n \"use strict\";\n\n var rv;\n\n if (invoke_post_methods) {\n var hash;\n\n if (sharedState_yy.post_parse || this.post_parse) {\n // create an error hash info instance: we re-use this API in a **non-error situation**\n // as this one delivers all parser internals ready for access by userland code.\n hash = this.constructParseErrorInfo(null /* no error! */, null /* no exception! */, null, false);\n }\n\n if (sharedState_yy.post_parse) {\n rv = sharedState_yy.post_parse.call(this, sharedState_yy, resultValue, hash);\n if (typeof rv !== 'undefined') resultValue = rv;\n }\n if (this.post_parse) {\n rv = this.post_parse.call(this, sharedState_yy, resultValue, hash);\n if (typeof rv !== 'undefined') resultValue = rv;\n }\n\n // cleanup:\n if (hash && hash.destroy) {\n hash.destroy();\n }\n }\n\n if (this.__reentrant_call_depth > 1) return resultValue; // do not (yet) kill the sharedState when this is a reentrant run.\n\n // clean up the lingering lexer structures as well:\n if (lexer.cleanupAfterLex) {\n lexer.cleanupAfterLex(do_not_nuke_errorinfos);\n }\n\n // prevent lingering circular references from causing memory leaks:\n if (sharedState_yy) {\n sharedState_yy.lexer = undefined;\n sharedState_yy.parser = undefined;\n if (lexer.yy === sharedState_yy) {\n lexer.yy = undefined;\n }\n }\n sharedState_yy = undefined;\n this.parseError = this.originalParseError;\n this.quoteName = this.originalQuoteName;\n\n // nuke the vstack[] array at least as that one will still reference obsoleted user values.\n // To be safe, we nuke the other internal stack columns as well...\n stack.length = 0; // fastest way to nuke an array without overly bothering the GC\n sstack.length = 0;\n lstack.length = 0;\n vstack.length = 0;\n sp = 0;\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (var i = this.__error_infos.length - 1; i >= 0; i--) {\n var el = this.__error_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) {\n var el = this.__error_recovery_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_recovery_infos.length = 0;\n\n // `recoveringErrorInfo` is also part of the `__error_recovery_infos` array,\n // hence has been destroyed already: no need to do that *twice*.\n if (recoveringErrorInfo) {\n recoveringErrorInfo = undefined;\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n }\n\n return resultValue;\n };\n\n // merge yylloc info into a new yylloc instance.\n //\n // `first_index` and `last_index` MAY be UNDEFINED/NULL or these are indexes into the `lstack[]` location stack array.\n //\n // `first_yylloc` and `last_yylloc` MAY be UNDEFINED/NULL or explicit (custom or regular) `yylloc` instances, in which\n // case these override the corresponding first/last indexes.\n //\n // `dont_look_back` is an optional flag (default: FALSE), which instructs this merge operation NOT to search\n // through the parse location stack for a location, which would otherwise be used to construct the new (epsilon!)\n // yylloc info.\n //\n // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL.\n this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) {\n \"use strict\";\n\n var i1 = first_index | 0,\n i2 = last_index | 0;\n var l1 = first_yylloc,\n l2 = last_yylloc;\n var rv;\n\n // rules:\n // - first/last yylloc entries override first/last indexes\n\n if (!l1) {\n if (first_index != null) {\n for (var i = i1; i <= i2; i++) {\n l1 = lstack[i];\n if (l1) {\n break;\n }\n }\n }\n }\n\n if (!l2) {\n if (last_index != null) {\n for (var i = i2; i >= i1; i--) {\n l2 = lstack[i];\n if (l2) {\n break;\n }\n }\n }\n }\n\n // - detect if an epsilon rule is being processed and act accordingly:\n if (!l1 && first_index == null) {\n // epsilon rule span merger. With optional look-ahead in l2.\n if (!dont_look_back) {\n for (var i = (i1 || sp) - 1; i >= 0; i--) {\n l1 = lstack[i];\n if (l1) {\n break;\n }\n }\n }\n if (!l1) {\n if (!l2) {\n // when we still don't have any valid yylloc info, we're looking at an epsilon rule\n // without look-ahead and no preceding terms and/or `dont_look_back` set:\n // in that case we ca do nothing but return NULL/UNDEFINED:\n return undefined;\n } else {\n // shallow-copy L2: after all, we MAY be looking\n // at unconventional yylloc info objects...\n rv = this.copy_yylloc(l2);\n return rv;\n }\n } else {\n // shallow-copy L1, then adjust first col/row 1 column past the end.\n rv = this.copy_yylloc(l1);\n rv.first_line = rv.last_line;\n rv.first_column = rv.last_column;\n rv.range[0] = rv.range[1];\n\n if (l2) {\n // shallow-mixin L2, then adjust last col/row accordingly.\n shallow_copy_noclobber(rv, l2);\n rv.last_line = l2.last_line;\n rv.last_column = l2.last_column;\n rv.range[1] = l2.range[1];\n }\n return rv;\n }\n }\n\n if (!l1) {\n l1 = l2;\n l2 = null;\n }\n if (!l1) {\n return undefined;\n }\n\n // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking\n // at unconventional yylloc info objects...\n rv = this.copy_yylloc(l1);\n\n if (l2) {\n shallow_copy_noclobber(rv, l2);\n rv.last_line = l2.last_line;\n rv.last_column = l2.last_column;\n rv.range[1] = l2.range[1];\n }\n\n return rv;\n };\n\n // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,\n // or else your `lexer`, `sharedState`, etc. references will be *wrong*!\n this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) {\n \"use strict\";\n\n var pei = {\n errStr: msg,\n exception: ex,\n text: lexer.match,\n value: this.copy_yytext(lexer.yytext),\n token: this.describeSymbol(symbol) || symbol,\n token_id: symbol,\n line: lexer.yylineno,\n loc: this.copy_yylloc(lexer.yylloc),\n expected: expected,\n recoverable: recoverable,\n state: state,\n action: action,\n new_state: newState,\n symbol_stack: stack,\n state_stack: sstack,\n value_stack: vstack,\n location_stack: lstack,\n stack_pointer: sp,\n yy: sharedState_yy,\n lexer: lexer,\n parser: this,\n\n // and make sure the error info doesn't stay due to potential\n // ref cycle via userland code manipulations.\n // These would otherwise all be memory leak opportunities!\n //\n // Note that only array and object references are nuked as those\n // constitute the set of elements which can produce a cyclic ref.\n // The rest of the members is kept intact as they are harmless.\n destroy: function destructParseErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // info.value = null;\n // info.value_stack = null;\n // ...\n \"use strict\";\n\n var rec = !!this.recoverable;\n for (var key in this) {\n if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n };\n\n // clone some parts of the (possibly enhanced!) errorInfo object\n // to give them some persistence.\n this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) {\n \"use strict\";\n\n var rv = shallow_copy(p);\n\n // remove the large parts which can only cause cyclic references\n // and are otherwise available from the parser kernel anyway.\n delete rv.sharedState_yy;\n delete rv.parser;\n delete rv.lexer;\n\n // lexer.yytext MAY be a complex value object, rather than a simple string/value:\n rv.value = this.copy_yytext(rv.value);\n\n // yylloc info:\n rv.loc = this.copy_yylloc(rv.loc);\n\n // the 'expected' set won't be modified, so no need to clone it:\n //rv.expected = rv.expected.slice();\n\n // symbol stack is a simple array:\n rv.symbol_stack = rv.symbol_stack.slice();\n // ditto for state stack:\n rv.state_stack = rv.state_stack.slice();\n // clone the yylloc's in the location stack?:\n rv.location_stack = rv.location_stack.map(this.copy_yylloc);\n // and the value stack may carry both simple and complex values:\n // shallow-copy the latter.\n rv.value_stack = rv.value_stack.map(this.copy_yytext);\n\n // and we don't bother with the sharedState_yy reference:\n //delete rv.yy;\n\n // now we prepare for tracking the COMBINE actions\n // in the error recovery code path:\n //\n // as we want to keep the maximum error info context, we\n // *scan* the state stack to find the first *empty* slot.\n // This position will surely be AT OR ABOVE the current\n // stack pointer, but we want to keep the 'used but discarded'\n // part of the parse stacks *intact* as those slots carry\n // error context that may be useful when you want to produce\n // very detailed error diagnostic reports.\n //\n // ### Purpose of each stack pointer:\n //\n // - stack_pointer: points at the top of the parse stack\n // **as it existed at the time of the error\n // occurrence, i.e. at the time the stack\n // snapshot was taken and copied into the\n // errorInfo object.**\n // - base_pointer: the bottom of the **empty part** of the\n // stack, i.e. **the start of the rest of\n // the stack space /above/ the existing\n // parse stack. This section will be filled\n // by the error recovery process as it\n // travels the parse state machine to\n // arrive at the resolving error recovery rule.**\n // - info_stack_pointer:\n // this stack pointer points to the **top of\n // the error recovery tracking stack space**, i.e.\n // this stack pointer takes up the role of\n // the `stack_pointer` for the error recovery\n // process. Any mutations in the **parse stack**\n // are **copy-appended** to this part of the\n // stack space, keeping the bottom part of the\n // stack (the 'snapshot' part where the parse\n // state at the time of error occurrence was kept)\n // intact.\n // - root_failure_pointer:\n // copy of the `stack_pointer`...\n //\n for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) {\n // empty\n }\n rv.base_pointer = i;\n rv.info_stack_pointer = i;\n\n rv.root_failure_pointer = rv.stack_pointer;\n\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_recovery_infos.push(rv);\n\n return rv;\n };\n\n function getNonTerminalFromCode(symbol) {\n \"use strict\";\n\n var tokenName = self.getSymbolName(symbol);\n if (!tokenName) {\n tokenName = symbol;\n }\n return tokenName;\n }\n\n//_lexer_without_token_stack:\n\n function stdLex() {\n \"use strict\";\n\n var token = lexer.lex();\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n var tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName: tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n function fastLex() {\n \"use strict\";\n\n var token = lexer.fastLex();\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n var tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName: tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n var lex = stdLex;\n\n//_lexer_with_token_stack:\n\n // lex function that supports token stacks\n function tokenStackLex() {\n \"use strict\";\n\n var token;\n token = tstack.pop() || lexer.lex() || EOF;\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n if (token instanceof Array) {\n // tokenstack CANNOT be nested, i.e. an 'array'-type token\n // now means the `tstack` is empty as this array of tokens\n // could only have originated from the `lexer.lex()`\n // call:\n tstack = token;\n token = tstack.pop();\n }\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n var tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName: tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n//_lexer_with_token_stack_end:\n\n var state, action, r, t;\n var yyval = {\n $: true,\n _$: undefined,\n yy: sharedState_yy\n };\n var p;\n var yyrulelen;\n var this_production;\n var newState;\n var retval = false;\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n // Return the rule stack depth where the nearest error rule can be found.\n // Return -1 when no error recovery rule was found.\n function locateNearestErrorRecoveryRule(state) {\n \"use strict\";\n\n var stack_probe = sp - 1;\n var depth = 0;\n\n // try to recover from error\n while (stack_probe >= 0) {\n // check for error recovery rule in this state\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #test#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n var t = (table[state] && table[state][TERROR]) || NO_ACTION;\n if (t[0]) {\n // We need to make sure we're not cycling forever:\n // once we hit EOF, even when we `yyerrok()` an error, we must\n // prevent the core from running forever,\n // e.g. when parent rules are still expecting certain input to\n // follow after this, for example when you handle an error inside a set\n // of braces which are matched by a parent rule in your grammar.\n //\n // Hence we require that every error handling/recovery attempt\n // *after we've hit EOF* has a diminishing state stack: this means\n // we will ultimately have unwound the state stack entirely and thus\n // terminate the parse in a controlled fashion even when we have\n // very complex error/recovery code interplay in the core + user\n // action code blocks:\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #found#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n if (symbol === EOF) {\n if (lastEofErrorStateDepth > sp - 1 - depth) {\n lastEofErrorStateDepth = sp - 1 - depth;\n } else {\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #skip#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n --stack_probe; // popStack(1): [symbol, action]\n state = sstack[stack_probe];\n ++depth;\n continue;\n }\n }\n return depth;\n }\n if (state === 0 /* $accept rule */ || stack_probe < 1) {\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n return -1; // No suitable error recovery rule available.\n }\n --stack_probe; // popStack(1): [symbol, action]\n state = sstack[stack_probe];\n ++depth;\n }\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n return -1; // No suitable error recovery rule available.\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n try {\n this.__reentrant_call_depth++;\n\n lexer.setInput(input, sharedState_yy);\n\n // NOTE: we *assume* no lexer pre/post handlers are set up *after*\n // this initial `setInput()` call: hence we can now check and decide\n // whether we'll go with the standard, slower, lex() API or the\n // `fast_lex()` one:\n if (typeof lexer.canIUse === 'function') {\n var lexerInfo = lexer.canIUse();\n if (lexerInfo.fastLex && typeof fastLex === 'function') {\n lex = fastLex;\n }\n }\n\n yyloc = this.copy_yylloc(lexer.yylloc);\n lstack[sp] = yyloc;\n vstack[sp] = null;\n sstack[sp] = 0;\n stack[sp] = 0;\n ++sp;\n\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyleng = lexer.yyleng;\n\n if (this.pre_parse) {\n this.pre_parse.call(this, sharedState_yy);\n }\n if (sharedState_yy.pre_parse) {\n sharedState_yy.pre_parse.call(this, sharedState_yy);\n }\n\n newState = sstack[sp - 1];\n for (;;) {\n // retrieve state number from top of stack\n state = newState; // sstack[sp - 1];\n\n // use default actions if available\n if (this.defaultActions[state]) {\n action = 2;\n newState = this.defaultActions[state];\n } else {\n // The single `==` condition below covers both these `===` comparisons in a single\n // operation:\n //\n // if (symbol === null || typeof symbol === 'undefined') ...\n if (!symbol) {\n symbol = lex();\n }\n // read action for current state and first input\n t = (table[state] && table[state][symbol]) || NO_ACTION;\n newState = t[1];\n action = t[0];\n\n if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action });\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n // handle parse error\n if (!action) {\n // first see if there's any chance at hitting an error recovery rule:\n var error_rule_depth = locateNearestErrorRecoveryRule(state);\n var errStr = null;\n var errSymbolDescr = (this.describeSymbol(symbol) || symbol);\n var expected = this.collect_expected_token_set(state);\n\n if (!recovering) {\n // Report error\n errStr = 'Parse error';\n if (typeof lexer.yylineno === 'number') {\n errStr += ' on line ' + (lexer.yylineno + 1);\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += ':\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n } else {\n errStr += ': ';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n\n p = this.constructParseErrorInfo(errStr, null, expected, (error_rule_depth >= 0));\n\n // DO NOT cleanup the old one before we start the new error info track:\n // the old one will *linger* on the error stack and stay alive until we\n // invoke the parser's cleanup API!\n recoveringErrorInfo = this.shallowCopyErrorInfo(p);\n\n if (yydebug) yydebug('error recovery rule detected: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p });\n\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n break;\n }\n\n // Protect against overly blunt userland `parseError` code which *sets*\n // the `recoverable` flag without properly checking first:\n // we always terminate the parse when there's no recovery rule available anyhow!\n if (!p.recoverable || error_rule_depth < 0) {\n break;\n } else {\n // TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process...\n }\n }\n\n if (yydebug) yydebug('after ERROR DETECT: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p });\n\n var esp = recoveringErrorInfo.info_stack_pointer;\n\n // just recovered from another error\n if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) {\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = this.copy_yytext(lexer.yytext);\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n\n // SHIFT current lookahead and grab another\n recoveringErrorInfo.symbol_stack[esp] = symbol;\n recoveringErrorInfo.value_stack[esp] = yytext;\n recoveringErrorInfo.location_stack[esp] = yyloc;\n recoveringErrorInfo.state_stack[esp] = newState; // push state\n ++esp;\n\n preErrorSymbol = 0;\n symbol = lex();\n\n if (yydebug) yydebug('after ERROR RECOVERY-3: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol] });\n }\n\n // try to recover from error\n if (error_rule_depth < 0) {\n ASSERT(recovering > 0, \"line 897\");\n recoveringErrorInfo.info_stack_pointer = esp;\n\n // barf a fatal hairball when we're out of look-ahead symbols and none hit a match\n // while we are still busy recovering from another error:\n var po = this.__error_infos[this.__error_infos.length - 1];\n\n // Report error\n if (typeof lexer.yylineno === 'number') {\n errStr = 'Parsing halted on line ' + (lexer.yylineno + 1) + ' while starting to recover from another error';\n } else {\n errStr = 'Parsing halted while starting to recover from another error';\n }\n\n if (po) {\n errStr += ' -- previous error which resulted in this fatal result: ' + po.errStr;\n } else {\n errStr += ': ';\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += '\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n\n p = this.constructParseErrorInfo(errStr, null, expected, false);\n if (po) {\n p.extra_error_attributes = po;\n }\n\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n\n preErrorSymbol = (symbol === TERROR ? 0 : symbol); // save the lookahead token\n symbol = TERROR; // insert generic error symbol as new lookahead\n\n const EXTRA_STACK_SAMPLE_DEPTH = 3;\n\n // REDUCE/COMBINE the pushed terms/tokens to a new ERROR token:\n recoveringErrorInfo.symbol_stack[esp] = preErrorSymbol;\n if (errStr) {\n recoveringErrorInfo.value_stack[esp] = {\n yytext: this.copy_yytext(lexer.yytext),\n errorRuleDepth: error_rule_depth,\n errStr: errStr,\n errorSymbolDescr: errSymbolDescr,\n expectedStr: expected,\n stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH\n };\n if (yydebug) yydebug('Error recovery process: pushed error info item on the info stack: ', {\n item: vstack[sp],\n sp,\n esp,\n vstack,\n stack,\n sstack,\n combineState: NO_ACTION[1]\n });\n } else {\n recoveringErrorInfo.value_stack[esp] = {\n yytext: this.copy_yytext(lexer.yytext),\n errorRuleDepth: error_rule_depth,\n stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH\n };\n }\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc);\n recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n\n yyval.$ = recoveringErrorInfo;\n yyval._$ = undefined;\n\n yyrulelen = error_rule_depth;\n\n if (yydebug) yydebug('Error recovery process: performAction: COMBINE: ', {\n yyval, yytext, sp, pop_size: yyrulelen, vstack, stack, sstack,\n combineState: NO_ACTION[1]\n });\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, NO_ACTION[1], sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof r !== 'undefined') {\n retval = r;\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // and move the top entries + discarded part of the parse stacks onto the error info stack:\n for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) {\n recoveringErrorInfo.symbol_stack[esp] = stack[idx];\n recoveringErrorInfo.value_stack[esp] = vstack[idx];\n recoveringErrorInfo.location_stack[esp] = lstack[idx];\n recoveringErrorInfo.state_stack[esp] = sstack[idx];\n }\n\n recoveringErrorInfo.symbol_stack[esp] = TERROR;\n recoveringErrorInfo.value_stack[esp] = this.copy_yytext(yyval.$);\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(yyval._$);\n\n // goto new state = table[STATE][NONTERMINAL]\n newState = sstack[sp - 1];\n\n if (this.defaultActions[newState]) {\n recoveringErrorInfo.state_stack[esp] = this.defaultActions[newState];\n } else {\n t = (table[newState] && table[newState][symbol]) || NO_ACTION;\n recoveringErrorInfo.state_stack[esp] = t[1];\n }\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n\n // allow N (default: 3) real symbols to be shifted before reporting a new error\n recovering = ERROR_RECOVERY_TOKEN_DISCARD_COUNT;\n\n if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth: error_rule_depth, symbol: symbol, preErrorSymbol: preErrorSymbol });\n\n // Now duplicate the standard parse machine here, at least its initial\n // couple of rounds until the TERROR symbol is **pushed onto the parse stack**,\n // as we wish to push something special then!\n //\n // Run the state machine in this copy of the parser state machine\n // until we *either* consume the error symbol (and its related information)\n // *or* we run into another error while recovering from this one\n // *or* we execute a `reduce` action which outputs a final parse\n // result (yes, that MAY happen!).\n //\n // We stay in this secondary parse loop until we have completed\n // the *error recovery phase* as the main parse loop (further below)\n // is optimized for regular parse operation and DOES NOT cope with\n // error recovery *at all*.\n //\n // We call the secondary parse loop just below the \"slow parse loop\",\n // while the main parse loop, which is an almost-duplicate of this one,\n // yet optimized for regular parse operation, is called the \"fast\n // parse loop\".\n //\n // Compare this to `bison` & (vanilla) `jison`, both of which have\n // only a single parse loop, which handles everything. Our goal is\n // to eke out every drop of performance in the main parse loop...\n\n ASSERT(recoveringErrorInfo, \"line 1049\");\n ASSERT(symbol === TERROR, \"line 1050\");\n ASSERT(!action, \"line 1051\");\n var errorSymbolFromParser = true;\n for (;;) {\n // retrieve state number from top of stack\n state = newState; // sstack[sp - 1];\n\n // use default actions if available\n if (this.defaultActions[state]) {\n action = 2;\n newState = this.defaultActions[state];\n } else {\n // The single `==` condition below covers both these `===` comparisons in a single\n // operation:\n //\n // if (symbol === null || typeof symbol === 'undefined') ...\n if (!symbol) {\n symbol = lex();\n // **Warning: Edge Case**: the *lexer* may produce\n // TERROR tokens of its own volition: *those* TERROR\n // tokens should be treated like *regular tokens*\n // i.e. tokens which have a lexer-provided `yyvalue`\n // and `yylloc`:\n errorSymbolFromParser = false;\n }\n // read action for current state and first input\n t = (table[state] && table[state][symbol]) || NO_ACTION;\n newState = t[1];\n action = t[0];\n\n if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action });\n\n // encountered another parse error? If so, break out to main loop\n // and take it from there!\n if (!action) {\n if (yydebug) yydebug('**NESTED ERROR DETECTED** while still recovering from previous error');\n\n ASSERT(recoveringErrorInfo, \"line 1087\");\n\n // Prep state variables so that upon breaking out of\n // this \"slow parse loop\" and hitting the `continue;`\n // statement in the outer \"fast parse loop\" we redo\n // the exact same state table lookup as the one above\n // so that the outer=main loop will also correctly\n // detect the 'parse error' state (`!action`) we have\n // just encountered above.\n newState = state;\n break;\n }\n }\n\n if (yydebug) yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) {\n \"use strict\";\n\n if (!nt || !nt.states || !nt.rules)\n return '';\n var rulename = nt.states[state];\n var rulespec = nt.rules[rulename][state];\n return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')';\n })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol });\n\n switch (action) {\n // catch misc. parse failures:\n default:\n // this shouldn't happen, unless resolve defaults are off\n //\n // SILENTLY SIGNAL that the outer \"fast parse loop\" should\n // take care of this internal error condition:\n // prevent useless code duplication now/here.\n break;\n\n // shift:\n case 1:\n stack[sp] = symbol;\n // ### Note/Warning ###\n //\n // The *lexer* may also produce TERROR tokens on its own,\n // so we specifically test for the TERROR we did set up\n // in the error recovery logic further above!\n if (symbol === TERROR && errorSymbolFromParser) {\n // Push a special value onto the stack when we're\n // shifting the `error` symbol that is related to the\n // error we're recovering from.\n ASSERT(recoveringErrorInfo, \"line 1131\");\n vstack[sp] = recoveringErrorInfo;\n lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true);\n } else {\n ASSERT(symbol !== 0, \"line 1135\");\n ASSERT(preErrorSymbol === 0, \"line 1136\");\n vstack[sp] = lexer.yytext;\n lstack[sp] = this.copy_yylloc(lexer.yylloc);\n }\n sstack[sp] = newState; // push state\n\n ++sp;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n var tokenName = this.getSymbolName(symbol || EOF);\n if (!tokenName) {\n tokenName = symbol;\n }\n\n Jison.parserDebugger.push({\n action: 'shift',\n text: lexer.yytext,\n terminal: tokenName,\n terminal_id: symbol\n });\n }\n\n symbol = 0;\n // **Warning: Edge Case**: the *lexer* may have produced\n // TERROR tokens of its own volition: *those* TERROR\n // tokens should be treated like *regular tokens*\n // i.e. tokens which have a lexer-provided `yyvalue`\n // and `yylloc`:\n errorSymbolFromParser = false;\n if (!preErrorSymbol) { // normal execution / no error\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n\n if (recovering > 0) {\n recovering--;\n if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering: recovering, symbol: symbol });\n }\n } else {\n // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode:\n ASSERT(recovering > 0, \"line 1163\");\n symbol = preErrorSymbol;\n preErrorSymbol = 0;\n if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering: recovering, symbol: symbol });\n // read action for current state and first input\n t = (table[newState] && table[newState][symbol]) || NO_ACTION;\n if (!t[0] || symbol === TERROR) {\n // forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where\n // (simple) stuff might have been missing before the token which caused the error we're\n // recovering from now...\n //\n // Also check if the LookAhead symbol isn't the ERROR token we set as part of the error\n // recovery, for then this we would we idling (cycling) on the error forever.\n // Yes, this does not take into account the possibility that the *lexer* may have\n // produced a *new* TERROR token all by itself, but that would be a very peculiar grammar!\n if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering: recovering, symbol: symbol });\n symbol = 0;\n }\n }\n\n // once we have pushed the special ERROR token value,\n // we REMAIN in this inner, \"slow parse loop\" until\n // the entire error recovery phase has completed.\n //\n // ### Note About Edge Case ###\n //\n // Userland action code MAY already have 'reset' the\n // error recovery phase marker `recovering` to ZERO(0)\n // while the error symbol hasn't been shifted onto\n // the stack yet. Hence we only exit this \"slow parse loop\"\n // when *both* conditions are met!\n ASSERT(preErrorSymbol === 0, \"line 1194\");\n if (recovering === 0) {\n break;\n }\n continue;\n\n // reduce:\n case 2:\n this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...\n yyrulelen = this_production[1];\n\n if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol });\n\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n var prereduceValue = vstack.slice(sp - yyrulelen, sp);\n var debuggableProductions = [];\n for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) {\n var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]);\n debuggableProductions.push(debuggableProduction);\n }\n\n // find the current nonterminal name (- nolan)\n var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0];\n var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode);\n\n Jison.parserDebugger.push({\n action: 'reduce',\n nonterminal: currentNonterminal,\n nonterminal_id: currentNonterminalCode,\n prereduce: prereduceValue,\n result: r,\n productions: debuggableProductions,\n text: yyval.$\n });\n }\n\n if (typeof r !== 'undefined') {\n // signal end of error recovery loop AND end of outer parse loop\n action = 3;\n retval = r;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n sp = -2; // magic number: signal outer \"fast parse loop\" ACCEPT state that we already have a properly set up `retval` parser return value.\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // don't overwrite the `symbol` variable: use a local var to speed things up:\n var ntsymbol = this_production[0]; // push nonterminal (reduce)\n stack[sp] = ntsymbol;\n vstack[sp] = yyval.$;\n lstack[sp] = yyval._$;\n // goto new state = table[STATE][NONTERMINAL]\n newState = table[sstack[sp - 1]][ntsymbol];\n sstack[sp] = newState;\n ++sp;\n if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol });\n continue;\n\n // accept:\n case 3:\n retval = true;\n // Return the `$accept` rule's `$$` result, if available.\n //\n // Also note that JISON always adds this top-most `$accept` rule (with implicit,\n // default, action):\n //\n // $accept: $end\n // %{ $$ = $1; @$ = @1; %}\n //\n // which, combined with the parse kernel's `$accept` state behaviour coded below,\n // will produce the `$$` value output of the rule as the parse result,\n // IFF that result is *not* `undefined`. (See also the parser kernel code.)\n //\n // In code:\n //\n // %{\n // @$ = @1; // if location tracking support is included\n // if (typeof $1 !== 'undefined')\n // return $1;\n // else\n // return true; // the default parse result if the rule actions don't produce anything\n // %}\n sp--;\n if (sp >= 0 && typeof vstack[sp] !== 'undefined') {\n retval = vstack[sp];\n }\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n sp = -2; // magic number: signal outer \"fast parse loop\" ACCEPT state that we already have a properly set up `retval` parser return value.\n break;\n }\n\n // break out of loop: we accept or fail with error\n break;\n }\n\n // should we also break out of the regular/outer parse loop,\n // i.e. did the parser already produce a parse result in here?!\n // *or* did we hit an unsupported parse state, to be handled\n // in the `switch/default` code further below?\n ASSERT(action !== 2, \"line 1272\");\n if (!action || action === 1) {\n continue;\n }\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n\n // handle parse error\n if (!action) {\n var errStr;\n var errSymbolDescr = (this.describeSymbol(symbol) || symbol);\n var expected = this.collect_expected_token_set(state);\n\n // Report error\n errStr = 'Parse error';\n if (typeof lexer.yylineno === 'number') {\n errStr += ' on line ' + (lexer.yylineno + 1);\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += ':\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n } else {\n errStr += ': ';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n // we cannot recover from the error!\n p = this.constructParseErrorInfo(errStr, null, expected, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n }\n\n if (yydebug) yydebug('::: MAIN CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) {\n \"use strict\";\n\n if (!nt || !nt.states || !nt.rules)\n return '';\n var rulename = nt.states[state];\n var rulespec = nt.rules[rulename][state];\n return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')';\n })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol });\n\n switch (action) {\n // catch misc. parse failures:\n default:\n // this shouldn't happen, unless resolve defaults are off\n if (action instanceof Array) {\n p = this.constructParseErrorInfo('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol, null, null, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n // Another case of better safe than sorry: in case state transitions come out of another error recovery process\n // or a buggy LUT (LookUp Table):\n p = this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.', null, null, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n\n // shift:\n case 1:\n stack[sp] = symbol;\n vstack[sp] = lexer.yytext;\n lstack[sp] = this.copy_yylloc(lexer.yylloc);\n sstack[sp] = newState; // push state\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n var tokenName = this.getSymbolName(symbol || EOF);\n if (!tokenName) {\n tokenName = symbol;\n }\n\n Jison.parserDebugger.push({\n action: 'shift',\n text: lexer.yytext,\n terminal: tokenName,\n terminal_id: symbol\n });\n }\n\n ++sp;\n\n symbol = 0;\n\n ASSERT(preErrorSymbol === 0, \"line 1352\"); // normal execution / no error\n ASSERT(recovering === 0, \"line 1353\"); // normal execution / no error\n\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n continue;\n\n // reduce:\n case 2:\n ASSERT(preErrorSymbol === 0, \"line 1364\"); // normal execution / no error\n ASSERT(recovering === 0, \"line 1365\"); // normal execution / no error\n\n this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...\n yyrulelen = this_production[1];\n\n if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol });\n\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n var prereduceValue = vstack.slice(sp - yyrulelen, sp);\n var debuggableProductions = [];\n for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) {\n var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]);\n debuggableProductions.push(debuggableProduction);\n }\n\n // find the current nonterminal name (- nolan)\n var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0];\n var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode);\n\n Jison.parserDebugger.push({\n action: 'reduce',\n nonterminal: currentNonterminal,\n nonterminal_id: currentNonterminalCode,\n prereduce: prereduceValue,\n result: r,\n productions: debuggableProductions,\n text: yyval.$\n });\n }\n\n if (typeof r !== 'undefined') {\n retval = r;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // don't overwrite the `symbol` variable: use a local var to speed things up:\n var ntsymbol = this_production[0]; // push nonterminal (reduce)\n stack[sp] = ntsymbol;\n vstack[sp] = yyval.$;\n lstack[sp] = yyval._$;\n // goto new state = table[STATE][NONTERMINAL]\n newState = table[sstack[sp - 1]][ntsymbol];\n sstack[sp] = newState;\n ++sp;\n if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol });\n continue;\n\n // accept:\n case 3:\n if (sp !== -2) {\n retval = true;\n // Return the `$accept` rule's `$$` result, if available.\n //\n // Also note that JISON always adds this top-most `$accept` rule (with implicit,\n // default, action):\n //\n // $accept: $end\n // %{ $$ = $1; @$ = @1; %}\n //\n // which, combined with the parse kernel's `$accept` state behaviour coded below,\n // will produce the `$$` value output of the rule as the parse result,\n // IFF that result is *not* `undefined`. (See also the parser kernel code.)\n //\n // In code:\n //\n // %{\n // @$ = @1; // if location tracking support is included\n // if (typeof $1 !== 'undefined')\n // return $1;\n // else\n // return true; // the default parse result if the rule actions don't produce anything\n // %}\n sp--;\n if (typeof vstack[sp] !== 'undefined') {\n retval = vstack[sp];\n }\n }\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n break;\n }\n\n // break out of loop: we accept or fail with error\n break;\n }\n } catch (ex) {\n // report exceptions through the parseError callback too, but keep the exception intact\n // if it is a known parser or lexer error which has been thrown by parseError() already:\n if (ex instanceof this.JisonParserError) {\n throw ex;\n }\n else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) {\n throw ex;\n }\n\n p = this.constructParseErrorInfo('Parsing aborted due to exception.', ex, null, false);\n retval = false;\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n } finally {\n retval = this.cleanupAfterParse(retval, true, true);\n this.__reentrant_call_depth--;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'return',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n } // /finally\n\n return retval;\n}\n"; // --- END parser kernel --- + parser$4.parse = "\nfunction parse(input, parseParams) {\n let self = this;\n let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage)\n let sstack = new Array(128); // state stack: stores states (column storage)\n let tstack = []; // token stack (only used when `%options token_stack` support has been enabled)\n let vstack = new Array(128); // semantic value stack\n let lstack = new Array(128); // location stack\n let table = this.table;\n let sp = 0; // 'stack pointer': index into the stacks\n let yyloc;\n let yytext;\n let yylineno;\n let yyleng;\n\n let symbol = 0;\n let preErrorSymbol = 0;\n let lastEofErrorStateDepth = Infinity;\n let recoveringErrorInfo = null;\n let recovering = 0; // (only used when the grammar contains error recovery rules)\n const TERROR = this.TERROR;\n const EOF = this.EOF;\n const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3;\n const NO_ACTION = [ 0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */];\n\n let lexer;\n if (this.__lexer__) {\n lexer = this.__lexer__;\n } else {\n lexer = this.__lexer__ = Object.create(this.lexer);\n }\n\n let sharedState_yy = {\n parseError: undefined,\n quoteName: undefined,\n lexer: undefined,\n parser: undefined,\n pre_parse: undefined,\n post_parse: undefined,\n pre_lex: undefined,\n post_lex: undefined,\n parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly!\n };\n\n const ASSERT = (\n typeof assert !== 'function' ?\n function JisonAssert(cond, msg) {\n if (!cond) {\n throw new Error('assertion failed: ' + (msg || '***'));\n }\n } :\n assert\n );\n\n this.yyGetSharedState = function yyGetSharedState() {\n return sharedState_yy;\n };\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n this.yyGetErrorInfoTrack = function yyGetErrorInfoTrack() {\n return recoveringErrorInfo;\n };\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // shallow clone objects & arrays, straight copy of simple `src` values\n // e.g. `lexer.yytext` MAY be a complex value object,\n // rather than a simple string/value.\n //\n // https://jsperf.com/new-array-vs-splice-vs-slice/72\n // https://jsperf.com/instanceof-vs-typeof/20\n // benchmark:: http://127.0.0.1:8080/example/jsperf/#testfile=test0020-typeof-instanceof-isArray.json5\n // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5\n //\n function shallow_copy(src) {\n if (src && typeof src === 'object') {\n // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned\n // using their constructor:\n if (src.constructor !== Object) {\n if (Array.isArray(src)) {\n return src.slice();\n }\n let dst = new src.constructor(src);\n\n // and make sure all custom attributes are added to the clone:\n shallow_copy_noclobber(dst, src);\n return dst;\n }\n // native objects must be cloned a different way:\n {\n //return Object.assign({}, src);\n let dst = {};\n shallow_copy_noclobber(dst, src);\n return dst;\n }\n }\n return src;\n }\n // add elements from `src` to `dst` when:\n // - either the element does not yet exist in `src`\n // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst`\n function shallow_copy_noclobber(dst, src) {\n const chk = Object.prototype.hasOwnProperty;\n for (let k in src) {\n if (!(k in dst)) {\n if (chk.call(src, k)) {\n dst[k] = src[k];\n }\n } else if (src[k] != null && dst[k] == null && chk.call(src, k)) {\n dst[k] = src[k];\n }\n }\n }\n function copy_yylloc_native(loc) {\n let rv = shallow_copy(loc);\n // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries:\n if (rv) {\n rv.range = rv.range.slice();\n }\n return rv;\n }\n\n // copy state\n shallow_copy_noclobber(sharedState_yy, this.yy);\n\n sharedState_yy.lexer = lexer;\n sharedState_yy.parser = this;\n\n // allow userland code to override the yytext and yylloc copy/clone functions:\n this.copy_yytext = this.options.copy_yytext || sharedState_yy.copy_yytext || shallow_copy;\n this.copy_yylloc = this.options.copy_yylloc || sharedState_yy.copy_yylloc || copy_yylloc_native;\n\n let yydebug = false;\n if (this.options.debug) {\n yydebug = function yydebug_impl(msg, obj) {\n let ref_list;\n let ref_names;\n\n function deepClone(from, sub) {\n if (sub == null) {\n ref_list = [];\n ref_names = [];\n sub = 'root';\n }\n if (typeof from === 'function') return '[Function]';\n if (from == null || typeof from !== 'object') return from;\n if (from.constructor !== Object && from.constructor !== Array) {\n return from;\n }\n\n let i = ref_list.indexOf(from);\n if (i >= 0) {\n return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference\n }\n ref_list.push(from);\n ref_names.push(sub);\n\n let to = new from.constructor();\n for (let name in from) {\n if (name === 'parser') continue;\n if (name === 'lexer') continue;\n to[name] = deepClone(from[name], name);\n }\n return to;\n }\n\n obj = obj || {};\n if (obj.symbol) {\n obj.local_yytext = yytext;\n obj.lexer_yytext = lexer.yytext;\n obj.lexer_yylloc = lexer.yylloc;\n obj.lexer_yyllineno = lexer.yyllineno;\n }\n\n // warning: here we fetch from closure (stack et al)\n obj.symbol_stack = stack;\n obj.state_stack = sstack;\n obj.value_stack = vstack;\n obj.location_stack = lstack;\n obj.stack_pointer = sp;\n\n // ready the object for printing:\n obj = deepClone(obj);\n\n // wrap try/catch in a function to help the V8 JIT compiler...\n function yydebug_cvt(obj) {\n let js;\n try {\n let re1;\n if (typeof XRegExp === 'undefined') {\n re1 = / {2}\\\"([a-z_][a-z_0-9. ]*)\\\": /ig;\n } else {\n re1 = new XRegExp(' \\\"([\\\\p{Alphabetic}_][\\\\p{Alphabetic}\\\\p{Number}_. ]*)\\\": ', 'g');\n }\n js = JSON.stringify(obj, null, 2)\n .replace(re1, ' $1: ')\n .replace(/[\\n\\s]+/g, ' ')\n // shorten yylloc object dumps too:\n .replace(/\\{ first_line: (\\d+), first_column: (\\d+), last_line: (\\d+), last_column: (\\d+)/g, '{L/C: ($1,$2)..($3,$4)');\n } catch (ex) {\n js = String(obj);\n }\n return js;\n }\n\n self.trace(msg, yydebug_cvt(obj), '\\n');\n };\n }\n\n // disable debugging at run-time ANYWAY when you've *explicitly* set \"yy.yydebug = false\":\n if (sharedState_yy.yydebug === false) {\n yydebug = undefined;\n }\n\n // *Always* setup `yyError`, `YYRECOVERING`, `yyErrOk` and `yyClearIn` functions as it is paramount\n // to have *their* closure match ours -- if we only set them up once,\n // any subsequent `parse()` runs will fail in very obscure ways when\n // these functions are invoked in the user action code block(s) as\n // their closure will still refer to the `parse()` instance which set\n // them up. Hence we MUST set them up at the start of every `parse()` run!\n if (this.yyError) {\n this.yyError = function yyError(str /*, ...args */) {\n if (yydebug) {\n yydebug('yyerror: ', {\n message: str,\n args: arguments,\n symbol, state, newState, recovering, action\n });\n }\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1);\n let expected = this.collect_expected_token_set(state);\n let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0));\n // append to the old one?\n if (recoveringErrorInfo) {\n let esp = recoveringErrorInfo.info_stack_pointer;\n\n recoveringErrorInfo.symbol_stack[esp] = symbol;\n let v = this.shallowCopyErrorInfo(hash);\n v.yyError = true;\n v.errorRuleDepth = error_rule_depth;\n v.recovering = recovering;\n // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH;\n\n recoveringErrorInfo.value_stack[esp] = v;\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc);\n recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n } else {\n recoveringErrorInfo = this.shallowCopyErrorInfo(hash);\n recoveringErrorInfo.yyError = true;\n recoveringErrorInfo.errorRuleDepth = error_rule_depth;\n recoveringErrorInfo.recovering = recovering;\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n\n let expected = this.collect_expected_token_set(state);\n let hash = this.constructParseErrorInfo(str, null, expected, false);\n\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n let args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n hash.extra_error_attributes = args;\n }\n\n return this.parseError(str, hash, this.JisonParserError);\n };\n }\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n if (this.yyRecovering) {\n this.yyRecovering = function yyRecovering() {\n if (yydebug) yydebug('yyrecovering: ', { symbol, state, newState, recovering, action });\n return recovering;\n };\n }\n\n if (this.yyErrOk) {\n this.yyErrOk = function yyErrOk() {\n if (yydebug) yydebug('yyerrok: ', { symbol, state, newState, recovering, action });\n recovering = 0;\n\n // DO NOT reset/cleanup `recoveringErrorInfo` yet: userland code\n // MAY invoke this API before the error is actually fully\n // recovered, in which case the parser recovery code won't be able\n // to append the skipped tokens to this info object.\n //\n // The rest of the kernel code is safe enough that it won't inadvertedly\n // re-use an old `recoveringErrorInfo` chunk so we'ld better wait\n // with destruction/cleanup until the end of the parse or until another\n // fresh parse error rears its ugly head...\n //\n // if (recoveringErrorInfo && typeof recoveringErrorInfo.destroy === 'function') {\n // recoveringErrorInfo.destroy();\n // recoveringErrorInfo = undefined;\n // }\n };\n }\n\n if (this.yyClearIn) {\n this.yyClearIn = function yyClearIn() {\n if (yydebug) yydebug('yyclearin: ', { symbol, newState, recovering, action, preErrorSymbol });\n if (symbol === TERROR) {\n symbol = 0;\n yytext = null;\n yyleng = 0;\n yyloc = undefined;\n }\n preErrorSymbol = 0;\n };\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // Does the shared state override the default `parseError` that already comes with this instance?\n if (typeof sharedState_yy.parseError === 'function') {\n this.parseError = function parseErrorAlt(str, hash, ExceptionClass) {\n if (!ExceptionClass) {\n ExceptionClass = this.JisonParserError;\n }\n return sharedState_yy.parseError.call(this, str, hash, ExceptionClass);\n };\n } else {\n this.parseError = this.originalParseError;\n }\n\n // Does the shared state override the default `quoteName` that already comes with this instance?\n if (typeof sharedState_yy.quoteName === 'function') {\n this.quoteName = function quoteNameAlt(id_str) {\n return sharedState_yy.quoteName.call(this, id_str);\n };\n } else {\n this.quoteName = this.originalQuoteName;\n }\n\n // set up the cleanup function; make it an API so that external code can re-use this one in case of\n // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which\n // case this parse() API method doesn't come with a `finally { ... }` block any more!\n //\n // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,\n // or else your `sharedState`, etc. references will be *wrong*!\n this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) {\n let rv;\n\n if (invoke_post_methods) {\n let hash;\n\n if (sharedState_yy.post_parse || this.post_parse) {\n // create an error hash info instance: we re-use this API in a **non-error situation**\n // as this one delivers all parser internals ready for access by userland code.\n hash = this.constructParseErrorInfo(null /* no error! */, null /* no exception! */, null, false);\n }\n\n if (sharedState_yy.post_parse) {\n rv = sharedState_yy.post_parse.call(this, sharedState_yy, resultValue, hash);\n if (typeof rv !== 'undefined') resultValue = rv;\n }\n if (this.post_parse) {\n rv = this.post_parse.call(this, sharedState_yy, resultValue, hash);\n if (typeof rv !== 'undefined') resultValue = rv;\n }\n\n // cleanup:\n if (hash && hash.destroy) {\n hash.destroy();\n }\n }\n\n if (this.__reentrant_call_depth > 1) return resultValue; // do not (yet) kill the sharedState when this is a reentrant run.\n\n // clean up the lingering lexer structures as well:\n if (lexer.cleanupAfterLex) {\n lexer.cleanupAfterLex(do_not_nuke_errorinfos);\n }\n\n // prevent lingering circular references from causing memory leaks:\n if (sharedState_yy) {\n sharedState_yy.lexer = undefined;\n sharedState_yy.parser = undefined;\n if (lexer.yy === sharedState_yy) {\n lexer.yy = undefined;\n }\n }\n sharedState_yy = undefined;\n this.parseError = this.originalParseError;\n this.quoteName = this.originalQuoteName;\n\n // nuke the vstack[] array at least as that one will still reference obsoleted user values.\n // To be safe, we nuke the other internal stack columns as well...\n stack.length = 0; // fastest way to nuke an array without overly bothering the GC\n sstack.length = 0;\n lstack.length = 0;\n vstack.length = 0;\n sp = 0;\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (let i = this.__error_infos.length - 1; i >= 0; i--) {\n let el = this.__error_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) {\n let el = this.__error_recovery_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_recovery_infos.length = 0;\n\n // `recoveringErrorInfo` is also part of the `__error_recovery_infos` array,\n // hence has been destroyed already: no need to do that *twice*.\n if (recoveringErrorInfo) {\n recoveringErrorInfo = undefined;\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n }\n\n return resultValue;\n };\n\n // merge yylloc info into a new yylloc instance.\n //\n // `first_index` and `last_index` MAY be UNDEFINED/NULL or these are indexes into the `lstack[]` location stack array.\n //\n // `first_yylloc` and `last_yylloc` MAY be UNDEFINED/NULL or explicit (custom or regular) `yylloc` instances, in which\n // case these override the corresponding first/last indexes.\n //\n // `dont_look_back` is an optional flag (default: FALSE), which instructs this merge operation NOT to search\n // through the parse location stack for a location, which would otherwise be used to construct the new (epsilon!)\n // yylloc info.\n //\n // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL.\n this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) {\n let i1 = first_index | 0;\n let i2 = last_index | 0;\n let l1 = first_yylloc;\n let l2 = last_yylloc;\n let rv;\n\n // rules:\n // - first/last yylloc entries override first/last indexes\n\n if (!l1) {\n if (first_index != null) {\n for (let i = i1; i <= i2; i++) {\n l1 = lstack[i];\n if (l1) {\n break;\n }\n }\n }\n }\n\n if (!l2) {\n if (last_index != null) {\n for (let i = i2; i >= i1; i--) {\n l2 = lstack[i];\n if (l2) {\n break;\n }\n }\n }\n }\n\n // - detect if an epsilon rule is being processed and act accordingly:\n if (!l1 && first_index == null) {\n // epsilon rule span merger. With optional look-ahead in l2.\n if (!dont_look_back) {\n for (let i = (i1 || sp) - 1; i >= 0; i--) {\n l1 = lstack[i];\n if (l1) {\n break;\n }\n }\n }\n if (!l1) {\n if (!l2) {\n // when we still don't have any valid yylloc info, we're looking at an epsilon rule\n // without look-ahead and no preceding terms and/or `dont_look_back` set:\n // in that case we ca do nothing but return NULL/UNDEFINED:\n return null;\n }\n // shallow-copy L2: after all, we MAY be looking\n // at unconventional yylloc info objects...\n rv = this.copy_yylloc(l2);\n return rv;\n }\n // shallow-copy L1, then adjust first col/row 1 column past the end.\n rv = this.copy_yylloc(l1);\n rv.first_line = rv.last_line;\n rv.first_column = rv.last_column;\n rv.range[0] = rv.range[1];\n\n if (l2) {\n // shallow-mixin L2, then adjust last col/row accordingly.\n shallow_copy_noclobber(rv, l2);\n rv.last_line = l2.last_line;\n rv.last_column = l2.last_column;\n rv.range[1] = l2.range[1];\n }\n return rv;\n }\n\n if (!l1) {\n l1 = l2;\n l2 = null;\n }\n if (!l1) {\n return null;\n }\n\n // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking\n // at unconventional yylloc info objects...\n rv = this.copy_yylloc(l1);\n\n if (l2) {\n shallow_copy_noclobber(rv, l2);\n rv.last_line = l2.last_line;\n rv.last_column = l2.last_column;\n rv.range[1] = l2.range[1];\n }\n\n return rv;\n };\n\n // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,\n // or else your `lexer`, `sharedState`, etc. references will be *wrong*!\n this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) {\n const pei = {\n errStr: msg,\n exception: ex,\n text: lexer.match,\n value: this.copy_yytext(lexer.yytext),\n token: this.describeSymbol(symbol) || symbol,\n token_id: symbol,\n line: lexer.yylineno,\n loc: this.copy_yylloc(lexer.yylloc),\n expected,\n recoverable,\n state,\n action,\n new_state: newState,\n symbol_stack: stack,\n state_stack: sstack,\n value_stack: vstack,\n location_stack: lstack,\n stack_pointer: sp,\n yy: sharedState_yy,\n lexer,\n parser: this,\n\n // and make sure the error info doesn't stay due to potential\n // ref cycle via userland code manipulations.\n // These would otherwise all be memory leak opportunities!\n //\n // Note that only array and object references are nuked as those\n // constitute the set of elements which can produce a cyclic ref.\n // The rest of the members is kept intact as they are harmless.\n destroy: function destructParseErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // info.value = null;\n // info.value_stack = null;\n // ...\n const rec = !!this.recoverable;\n for (let key in this) {\n if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n };\n\n // clone some parts of the (possibly enhanced!) errorInfo object\n // to give them some persistence.\n this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) {\n let rv = shallow_copy(p);\n\n // remove the large parts which can only cause cyclic references\n // and are otherwise available from the parser kernel anyway.\n delete rv.sharedState_yy;\n delete rv.parser;\n delete rv.lexer;\n\n // lexer.yytext MAY be a complex value object, rather than a simple string/value:\n rv.value = this.copy_yytext(rv.value);\n\n // yylloc info:\n rv.loc = this.copy_yylloc(rv.loc);\n\n // the 'expected' set won't be modified, so no need to clone it:\n //rv.expected = rv.expected.slice();\n\n // symbol stack is a simple array:\n rv.symbol_stack = rv.symbol_stack.slice();\n // ditto for state stack:\n rv.state_stack = rv.state_stack.slice();\n // clone the yylloc's in the location stack?:\n rv.location_stack = rv.location_stack.map(this.copy_yylloc);\n // and the value stack may carry both simple and complex values:\n // shallow-copy the latter.\n rv.value_stack = rv.value_stack.map(this.copy_yytext);\n\n // and we don't bother with the sharedState_yy reference:\n //delete rv.yy;\n\n // now we prepare for tracking the COMBINE actions\n // in the error recovery code path:\n //\n // as we want to keep the maximum error info context, we\n // *scan* the state stack to find the first *empty* slot.\n // This position will surely be AT OR ABOVE the current\n // stack pointer, but we want to keep the 'used but discarded'\n // part of the parse stacks *intact* as those slots carry\n // error context that may be useful when you want to produce\n // very detailed error diagnostic reports.\n //\n // ### Purpose of each stack pointer:\n //\n // - stack_pointer: points at the top of the parse stack\n // **as it existed at the time of the error\n // occurrence, i.e. at the time the stack\n // snapshot was taken and copied into the\n // errorInfo object.**\n // - base_pointer: the bottom of the **empty part** of the\n // stack, i.e. **the start of the rest of\n // the stack space /above/ the existing\n // parse stack. This section will be filled\n // by the error recovery process as it\n // travels the parse state machine to\n // arrive at the resolving error recovery rule.**\n // - info_stack_pointer:\n // this stack pointer points to the **top of\n // the error recovery tracking stack space**, i.e.\n // this stack pointer takes up the role of\n // the `stack_pointer` for the error recovery\n // process. Any mutations in the **parse stack**\n // are **copy-appended** to this part of the\n // stack space, keeping the bottom part of the\n // stack (the 'snapshot' part where the parse\n // state at the time of error occurrence was kept)\n // intact.\n // - root_failure_pointer:\n // copy of the `stack_pointer`...\n //\n {\n let i;\n for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) {\n // empty\n }\n rv.base_pointer = i;\n rv.info_stack_pointer = i;\n }\n\n rv.root_failure_pointer = rv.stack_pointer;\n\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_recovery_infos.push(rv);\n\n return rv;\n };\n\n function getNonTerminalFromCode(symbol) {\n let tokenName = self.getSymbolName(symbol);\n if (!tokenName) {\n tokenName = symbol;\n }\n return tokenName;\n }\n\n//_lexer_without_token_stack:\n\n function stdLex() {\n let token = lexer.lex();\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n let tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n function fastLex() {\n let token = lexer.fastLex();\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n let tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n let lex = stdLex;\n\n//_lexer_with_token_stack:\n\n // lex function that supports token stacks\n function tokenStackLex() {\n let token;\n token = tstack.pop() || lexer.lex() || EOF;\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n if (token instanceof Array) {\n // tokenstack CANNOT be nested, i.e. an 'array'-type token\n // now means the `tstack` is empty as this array of tokens\n // could only have originated from the `lexer.lex()`\n // call:\n tstack = token;\n token = tstack.pop();\n }\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n let tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n//_lexer_with_token_stack_end:\n\n let state, action, r, t;\n let yyval = {\n $: true,\n _$: undefined,\n yy: sharedState_yy\n };\n let p;\n let yyrulelen;\n let this_production;\n let newState;\n let retval = false;\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n // Return the rule stack depth where the nearest error rule can be found.\n // Return -1 when no error recovery rule was found.\n function locateNearestErrorRecoveryRule(state) {\n let stack_probe = sp - 1;\n let depth = 0;\n\n // try to recover from error\n while (stack_probe >= 0) {\n // check for error recovery rule in this state\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #test#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n const t = (table[state] && table[state][TERROR]) || NO_ACTION;\n if (t[0]) {\n // We need to make sure we're not cycling forever:\n // once we hit EOF, even when we `yyerrok()` an error, we must\n // prevent the core from running forever,\n // e.g. when parent rules are still expecting certain input to\n // follow after this, for example when you handle an error inside a set\n // of braces which are matched by a parent rule in your grammar.\n //\n // Hence we require that every error handling/recovery attempt\n // *after we've hit EOF* has a diminishing state stack: this means\n // we will ultimately have unwound the state stack entirely and thus\n // terminate the parse in a controlled fashion even when we have\n // very complex error/recovery code interplay in the core + user\n // action code blocks:\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #found#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n if (symbol === EOF) {\n if (lastEofErrorStateDepth > sp - 1 - depth) {\n lastEofErrorStateDepth = sp - 1 - depth;\n } else {\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #skip#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n --stack_probe; // popStack(1): [symbol, action]\n state = sstack[stack_probe];\n ++depth;\n continue;\n }\n }\n return depth;\n }\n if (state === 0 /* $accept rule */ || stack_probe < 1) {\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n return -1; // No suitable error recovery rule available.\n }\n --stack_probe; // popStack(1): [symbol, action]\n state = sstack[stack_probe];\n ++depth;\n }\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n return -1; // No suitable error recovery rule available.\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n try {\n this.__reentrant_call_depth++;\n\n lexer.setInput(input, sharedState_yy);\n\n // NOTE: we *assume* no lexer pre/post handlers are set up *after*\n // this initial `setInput()` call: hence we can now check and decide\n // whether we'll go with the standard, slower, lex() API or the\n // `fast_lex()` one:\n if (typeof lexer.canIUse === 'function') {\n let lexerInfo = lexer.canIUse();\n if (lexerInfo.fastLex && typeof fastLex === 'function') {\n lex = fastLex;\n }\n }\n\n yyloc = this.copy_yylloc(lexer.yylloc);\n lstack[sp] = yyloc;\n vstack[sp] = null;\n sstack[sp] = 0;\n stack[sp] = 0;\n ++sp;\n\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyleng = lexer.yyleng;\n\n if (this.pre_parse) {\n this.pre_parse.call(this, sharedState_yy);\n }\n if (sharedState_yy.pre_parse) {\n sharedState_yy.pre_parse.call(this, sharedState_yy);\n }\n\n newState = sstack[sp - 1];\n for (;;) {\n // retrieve state number from top of stack\n state = newState; // sstack[sp - 1];\n\n // use default actions if available\n if (this.defaultActions[state]) {\n action = 2;\n newState = this.defaultActions[state];\n } else {\n // The single `==` condition below covers both these `===` comparisons in a single\n // operation:\n //\n // if (symbol === null || typeof symbol === 'undefined') ...\n if (!symbol) {\n symbol = lex();\n }\n // read action for current state and first input\n t = (table[state] && table[state][symbol]) || NO_ACTION;\n newState = t[1];\n action = t[0];\n\n if (yydebug) {\n yydebug('after FETCH/LEX: ', {\n symbol,\n symbolID: this.terminals_ && this.terminals_[symbol],\n state, newState, recovering, action\n });\n }\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n // handle parse error\n if (!action) {\n // first see if there's any chance at hitting an error recovery rule:\n let error_rule_depth = locateNearestErrorRecoveryRule(state);\n let errStr = null;\n let errSymbolDescr = (this.describeSymbol(symbol) || symbol);\n let expected = this.collect_expected_token_set(state);\n\n if (!recovering) {\n // Report error\n errStr = 'Parse error';\n if (typeof lexer.yylineno === 'number') {\n errStr += ' on line ' + (lexer.yylineno + 1);\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += ':\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n } else {\n errStr += ': ';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n\n p = this.constructParseErrorInfo(errStr, null, expected, (error_rule_depth >= 0));\n\n // DO NOT cleanup the old one before we start the new error info track:\n // the old one will *linger* on the error stack and stay alive until we\n // invoke the parser's cleanup API!\n recoveringErrorInfo = this.shallowCopyErrorInfo(p);\n\n if (yydebug) {\n yydebug('error recovery rule detected: ', {\n error_rule_depth,\n error: p.errStr,\n error_hash: p\n });\n }\n\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n break;\n }\n\n // Protect against overly blunt userland `parseError` code which *sets*\n // the `recoverable` flag without properly checking first:\n // we always terminate the parse when there's no recovery rule available anyhow!\n if (!p.recoverable || error_rule_depth < 0) {\n break;\n } else {\n // TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process...\n }\n }\n\n if (yydebug) {\n yydebug('after ERROR DETECT: ', {\n error_rule_depth,\n error: p.errStr,\n error_hash: p\n });\n }\n\n let esp = recoveringErrorInfo.info_stack_pointer;\n\n // just recovered from another error\n if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) {\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = this.copy_yytext(lexer.yytext);\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n\n // SHIFT current lookahead and grab another\n recoveringErrorInfo.symbol_stack[esp] = symbol;\n recoveringErrorInfo.value_stack[esp] = yytext;\n recoveringErrorInfo.location_stack[esp] = yyloc;\n recoveringErrorInfo.state_stack[esp] = newState; // push state\n ++esp;\n\n preErrorSymbol = 0;\n symbol = lex();\n\n if (yydebug) {\n yydebug('after ERROR RECOVERY-3: ', {\n symbol,\n symbolID: this.terminals_ && this.terminals_[symbol]\n });\n }\n }\n\n // try to recover from error\n if (error_rule_depth < 0) {\n ASSERT(recovering > 0, 'Line 1048');\n recoveringErrorInfo.info_stack_pointer = esp;\n\n // barf a fatal hairball when we're out of look-ahead symbols and none hit a match\n // while we are still busy recovering from another error:\n let po = this.__error_infos[this.__error_infos.length - 1];\n\n // Report error\n if (typeof lexer.yylineno === 'number') {\n errStr = 'Parsing halted on line ' + (lexer.yylineno + 1) + ' while starting to recover from another error';\n } else {\n errStr = 'Parsing halted while starting to recover from another error';\n }\n\n if (po) {\n errStr += ' -- previous error which resulted in this fatal result: ' + po.errStr;\n } else {\n errStr += ': ';\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += '\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n\n p = this.constructParseErrorInfo(errStr, null, expected, false);\n if (po) {\n p.extra_error_attributes = po;\n }\n\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n\n preErrorSymbol = (symbol === TERROR ? 0 : symbol); // save the lookahead token\n symbol = TERROR; // insert generic error symbol as new lookahead\n\n const EXTRA_STACK_SAMPLE_DEPTH = 3;\n\n // REDUCE/COMBINE the pushed terms/tokens to a new ERROR token:\n recoveringErrorInfo.symbol_stack[esp] = preErrorSymbol;\n if (errStr) {\n recoveringErrorInfo.value_stack[esp] = {\n yytext: this.copy_yytext(lexer.yytext),\n errorRuleDepth: error_rule_depth,\n errStr,\n errSymbolDescr,\n expectedStr: expected,\n stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH\n };\n if (yydebug) {\n yydebug('Error recovery process: pushed error info item on the info stack: ', {\n item: vstack[sp],\n sp, esp, vstack, stack, sstack,\n combineState: NO_ACTION[1]\n });\n }\n } else {\n recoveringErrorInfo.value_stack[esp] = {\n yytext: this.copy_yytext(lexer.yytext),\n errorRuleDepth: error_rule_depth,\n stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH\n };\n }\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc);\n recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n\n yyval.$ = recoveringErrorInfo;\n yyval._$ = undefined;\n\n yyrulelen = error_rule_depth;\n\n let combineState = NO_ACTION[1];\n\n if (yydebug) {\n yydebug('Error recovery process: performAction: COMBINE: ', {\n yyval, yytext, sp,\n pop_size: yyrulelen,\n vstack, stack, sstack,\n combineState\n });\n }\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, combineState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof r !== 'undefined') {\n retval = r;\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // and move the top entries + discarded part of the parse stacks onto the error info stack:\n for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) {\n recoveringErrorInfo.symbol_stack[esp] = stack[idx];\n recoveringErrorInfo.value_stack[esp] = vstack[idx];\n recoveringErrorInfo.location_stack[esp] = lstack[idx];\n recoveringErrorInfo.state_stack[esp] = sstack[idx];\n }\n\n recoveringErrorInfo.symbol_stack[esp] = TERROR;\n recoveringErrorInfo.value_stack[esp] = this.copy_yytext(yyval.$);\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(yyval._$);\n\n // goto new state = table[STATE][NONTERMINAL]\n newState = sstack[sp - 1];\n\n if (this.defaultActions[newState]) {\n recoveringErrorInfo.state_stack[esp] = this.defaultActions[newState];\n } else {\n t = (table[newState] && table[newState][symbol]) || NO_ACTION;\n recoveringErrorInfo.state_stack[esp] = t[1];\n }\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n\n // allow N (default: 3) real symbols to be shifted before reporting a new error\n recovering = ERROR_RECOVERY_TOKEN_DISCARD_COUNT;\n\n if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth, symbol, preErrorSymbol });\n\n // Now duplicate the standard parse machine here, at least its initial\n // couple of rounds until the TERROR symbol is **pushed onto the parse stack**,\n // as we wish to push something special then!\n //\n // Run the state machine in this copy of the parser state machine\n // until we *either* consume the error symbol (and its related information)\n // *or* we run into another error while recovering from this one\n // *or* we execute a `reduce` action which outputs a final parse\n // result (yes, that MAY happen!).\n //\n // We stay in this secondary parse loop until we have completed\n // the *error recovery phase* as the main parse loop (further below)\n // is optimized for regular parse operation and DOES NOT cope with\n // error recovery *at all*.\n //\n // We call the secondary parse loop just below the \"slow parse loop\",\n // while the main parse loop, which is an almost-duplicate of this one,\n // yet optimized for regular parse operation, is called the \"fast\n // parse loop\".\n //\n // Compare this to `bison` & (vanilla) `jison`, both of which have\n // only a single parse loop, which handles everything. Our goal is\n // to eke out every drop of performance in the main parse loop...\n\n ASSERT(recoveringErrorInfo, 'Line 1204');\n ASSERT(symbol === TERROR, 'Line 1205');\n ASSERT(!action, 'Line 1206');\n let errorSymbolFromParser = true;\n for (;;) {\n // retrieve state number from top of stack\n state = newState; // sstack[sp - 1];\n\n // use default actions if available\n if (this.defaultActions[state]) {\n action = 2;\n newState = this.defaultActions[state];\n } else {\n // The single `==` condition below covers both these `===` comparisons in a single\n // operation:\n //\n // if (symbol === null || typeof symbol === 'undefined') ...\n if (!symbol) {\n symbol = lex();\n // **Warning: Edge Case**: the *lexer* may produce\n // TERROR tokens of its own volition: *those* TERROR\n // tokens should be treated like *regular tokens*\n // i.e. tokens which have a lexer-provided `yyvalue`\n // and `yylloc`:\n errorSymbolFromParser = false;\n }\n // read action for current state and first input\n t = (table[state] && table[state][symbol]) || NO_ACTION;\n newState = t[1];\n action = t[0];\n\n if (yydebug) {\n yydebug('after FETCH/LEX: ', {\n symbol,\n symbolID: this.terminals_ && this.terminals_[symbol],\n state, newState, recovering, action\n });\n }\n\n // encountered another parse error? If so, break out to main loop\n // and take it from there!\n if (!action) {\n if (yydebug) yydebug('**NESTED ERROR DETECTED** while still recovering from previous error');\n\n ASSERT(recoveringErrorInfo, 'Line 1248');\n\n // Prep state variables so that upon breaking out of\n // this \"slow parse loop\" and hitting the `continue;`\n // statement in the outer \"fast parse loop\" we redo\n // the exact same state table lookup as the one above\n // so that the outer=main loop will also correctly\n // detect the 'parse error' state (`!action`) we have\n // just encountered above.\n newState = state;\n break;\n }\n }\n\n if (yydebug) {\n yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' +\n (action === 1 ?\n 'shift token ' + symbol + ' (then go to state ' + newState + ')' :\n action === 2 ?\n 'reduce by rule: ' + newState + (function __print_rule(nt, state) {\n if (!nt || !nt.states || !nt.rules) {\n return '';\n }\n let rulename = nt.states[state];\n let rulespec = nt.rules[rulename][state];\n return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')';\n })(this.nonterminals_, newState) :\n action === 3 ?\n 'accept' :\n '???unexpected???'\n ), {\n action, newState, recovering, symbol\n });\n }\n\n switch (action) {\n // catch misc. parse failures:\n default:\n // this shouldn't happen, unless resolve defaults are off\n //\n // SILENTLY SIGNAL that the outer \"fast parse loop\" should\n // take care of this internal error condition:\n // prevent useless code duplication now/here.\n break;\n\n // shift:\n case 1:\n stack[sp] = symbol;\n // ### Note/Warning ###\n //\n // The *lexer* may also produce TERROR tokens on its own,\n // so we specifically test for the TERROR we did set up\n // in the error recovery logic further above!\n if (symbol === TERROR && errorSymbolFromParser) {\n // Push a special value onto the stack when we're\n // shifting the `error` symbol that is related to the\n // error we're recovering from.\n ASSERT(recoveringErrorInfo, 'Line 1305');\n vstack[sp] = recoveringErrorInfo;\n lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true);\n } else {\n ASSERT(symbol !== 0, 'Line 1309');\n ASSERT(preErrorSymbol === 0, 'Line 1310');\n vstack[sp] = lexer.yytext;\n lstack[sp] = this.copy_yylloc(lexer.yylloc);\n }\n sstack[sp] = newState; // push state\n\n ++sp;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n let tokenName = this.getSymbolName(symbol || EOF);\n if (!tokenName) {\n tokenName = symbol;\n }\n\n Jison.parserDebugger.push({\n action: 'shift',\n text: lexer.yytext,\n terminal: tokenName,\n terminal_id: symbol\n });\n }\n\n symbol = 0;\n // **Warning: Edge Case**: the *lexer* may have produced\n // TERROR tokens of its own volition: *those* TERROR\n // tokens should be treated like *regular tokens*\n // i.e. tokens which have a lexer-provided `yyvalue`\n // and `yylloc`:\n errorSymbolFromParser = false;\n if (!preErrorSymbol) { // normal execution / no error\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n\n if (recovering > 0) {\n recovering--;\n if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering, symbol });\n }\n } else {\n // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode:\n ASSERT(recovering > 0, 'Line 1352');\n symbol = preErrorSymbol;\n preErrorSymbol = 0;\n if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering, symbol });\n // read action for current state and first input\n t = (table[newState] && table[newState][symbol]) || NO_ACTION;\n if (!t[0] || symbol === TERROR) {\n // forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where\n // (simple) stuff might have been missing before the token which caused the error we're\n // recovering from now...\n //\n // Also check if the LookAhead symbol isn't the ERROR token we set as part of the error\n // recovery, for then this we would we idling (cycling) on the error forever.\n // Yes, this does not take into account the possibility that the *lexer* may have\n // produced a *new* TERROR token all by itself, but that would be a very peculiar grammar!\n if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering, symbol });\n symbol = 0;\n }\n }\n\n // once we have pushed the special ERROR token value,\n // we REMAIN in this inner, \"slow parse loop\" until\n // the entire error recovery phase has completed.\n //\n // ### Note About Edge Case ###\n //\n // Userland action code MAY already have 'reset' the\n // error recovery phase marker `recovering` to ZERO(0)\n // while the error symbol hasn't been shifted onto\n // the stack yet. Hence we only exit this \"slow parse loop\"\n // when *both* conditions are met!\n ASSERT(preErrorSymbol === 0, 'Line 1383');\n if (recovering === 0) {\n break;\n }\n continue;\n\n // reduce:\n case 2:\n this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...\n yyrulelen = this_production[1];\n\n if (yydebug) {\n yydebug('~~~ REDUCE: ', {\n pop_size: yyrulelen,\n newState, recovering, symbol\n });\n }\n\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n let prereduceValue = vstack.slice(sp - yyrulelen, sp);\n let debuggableProductions = [];\n for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) {\n let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]);\n debuggableProductions.push(debuggableProduction);\n }\n\n // find the current nonterminal name (- nolan)\n let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0];\n let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode);\n\n Jison.parserDebugger.push({\n action: 'reduce',\n nonterminal: currentNonterminal,\n nonterminal_id: currentNonterminalCode,\n prereduce: prereduceValue,\n result: r,\n productions: debuggableProductions,\n text: yyval.$\n });\n }\n\n if (typeof r !== 'undefined') {\n // signal end of error recovery loop AND end of outer parse loop\n action = 3;\n retval = r;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n sp = -2; // magic number: signal outer \"fast parse loop\" ACCEPT state that we already have a properly set up `retval` parser return value.\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // don't overwrite the `symbol` variable: use a local var to speed things up:\n {\n let ntsymbol = this_production[0]; // push nonterminal (reduce)\n stack[sp] = ntsymbol;\n vstack[sp] = yyval.$;\n lstack[sp] = yyval._$;\n // goto new state = table[STATE][NONTERMINAL]\n newState = table[sstack[sp - 1]][ntsymbol];\n sstack[sp] = newState;\n ++sp;\n if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol });\n }\n continue;\n\n // accept:\n case 3:\n retval = true;\n // Return the `$accept` rule's `$$` result, if available.\n //\n // Also note that JISON always adds this top-most `$accept` rule (with implicit,\n // default, action):\n //\n // $accept: $end\n // %{ $$ = $1; @$ = @1; %}\n //\n // which, combined with the parse kernel's `$accept` state behaviour coded below,\n // will produce the `$$` value output of the rule as the parse result,\n // IFF that result is *not* `undefined`. (See also the parser kernel code.)\n //\n // In code:\n //\n // %{\n // @$ = @1; // if location tracking support is included\n // if (typeof $1 !== 'undefined')\n // return $1;\n // else\n // return true; // the default parse result if the rule actions don't produce anything\n // %}\n sp--;\n if (sp >= 0 && typeof vstack[sp] !== 'undefined') {\n retval = vstack[sp];\n }\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n sp = -2; // magic number: signal outer \"fast parse loop\" ACCEPT state that we already have a properly set up `retval` parser return value.\n break;\n }\n\n // break out of loop: we accept or fail with error\n break;\n }\n\n // should we also break out of the regular/outer parse loop,\n // i.e. did the parser already produce a parse result in here?!\n // *or* did we hit an unsupported parse state, to be handled\n // in the `switch/default` code further below?\n ASSERT(action !== 2, 'Line 1509');\n if (!action || action === 1) {\n continue;\n }\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n\n // handle parse error\n if (!action) {\n let errStr;\n let errSymbolDescr = (this.describeSymbol(symbol) || symbol);\n let expected = this.collect_expected_token_set(state);\n\n // Report error\n errStr = 'Parse error';\n if (typeof lexer.yylineno === 'number') {\n errStr += ' on line ' + (lexer.yylineno + 1);\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += ':\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n } else {\n errStr += ': ';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n // we cannot recover from the error!\n p = this.constructParseErrorInfo(errStr, null, expected, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n }\n\n if (yydebug) {\n yydebug('::: MAIN CYCLE action: ' +\n (action === 1 ?\n 'shift token ' + symbol + ' (then go to state ' + newState + ')' :\n action === 2 ?\n 'reduce by rule: ' + newState + (function __print_rule(nt, state) {\n if (!nt || !nt.states || !nt.rules) {\n return '';\n }\n let rulename = nt.states[state];\n let rulespec = nt.rules[rulename][state];\n return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')';\n })(this.nonterminals_, newState) :\n action === 3 ?\n 'accept' :\n '???unexpected???'\n ), {\n action, newState, recovering, symbol\n });\n }\n\n switch (action) {\n // catch misc. parse failures:\n default:\n // this shouldn't happen, unless resolve defaults are off\n if (action instanceof Array) {\n p = this.constructParseErrorInfo('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol, null, null, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n // Another case of better safe than sorry: in case state transitions come out of another error recovery process\n // or a buggy LUT (LookUp Table):\n p = this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.', null, null, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n\n // shift:\n case 1:\n stack[sp] = symbol;\n vstack[sp] = lexer.yytext;\n lstack[sp] = this.copy_yylloc(lexer.yylloc);\n sstack[sp] = newState; // push state\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n let tokenName = this.getSymbolName(symbol || EOF);\n if (!tokenName) {\n tokenName = symbol;\n }\n\n Jison.parserDebugger.push({\n action: 'shift',\n text: lexer.yytext,\n terminal: tokenName,\n terminal_id: symbol\n });\n }\n\n ++sp;\n\n symbol = 0;\n\n ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error\n ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error\n\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n continue;\n\n // reduce:\n case 2:\n ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error\n ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error\n\n this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...\n yyrulelen = this_production[1];\n\n if (yydebug) {\n yydebug('~~~ REDUCE: ', {\n pop_size: yyrulelen,\n newState, recovering, symbol\n });\n }\n\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n let prereduceValue = vstack.slice(sp - yyrulelen, sp);\n let debuggableProductions = [];\n for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) {\n let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]);\n debuggableProductions.push(debuggableProduction);\n }\n\n // find the current nonterminal name (- nolan)\n let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0];\n let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode);\n\n Jison.parserDebugger.push({\n action: 'reduce',\n nonterminal: currentNonterminal,\n nonterminal_id: currentNonterminalCode,\n prereduce: prereduceValue,\n result: r,\n productions: debuggableProductions,\n text: yyval.$\n });\n }\n\n if (typeof r !== 'undefined') {\n retval = r;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // don't overwrite the `symbol` variable: use a local var to speed things up:\n {\n let ntsymbol = this_production[0]; // push nonterminal (reduce)\n stack[sp] = ntsymbol;\n vstack[sp] = yyval.$;\n lstack[sp] = yyval._$;\n // goto new state = table[STATE][NONTERMINAL]\n newState = table[sstack[sp - 1]][ntsymbol];\n sstack[sp] = newState;\n ++sp;\n if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol });\n }\n continue;\n\n // accept:\n case 3:\n if (sp !== -2) {\n retval = true;\n // Return the `$accept` rule's `$$` result, if available.\n //\n // Also note that JISON always adds this top-most `$accept` rule (with implicit,\n // default, action):\n //\n // $accept: $end\n // %{ $$ = $1; @$ = @1; %}\n //\n // which, combined with the parse kernel's `$accept` state behaviour coded below,\n // will produce the `$$` value output of the rule as the parse result,\n // IFF that result is *not* `undefined`. (See also the parser kernel code.)\n //\n // In code:\n //\n // %{\n // @$ = @1; // if location tracking support is included\n // if (typeof $1 !== 'undefined')\n // return $1;\n // else\n // return true; // the default parse result if the rule actions don't produce anything\n // %}\n sp--;\n if (typeof vstack[sp] !== 'undefined') {\n retval = vstack[sp];\n }\n }\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n break;\n }\n\n // break out of loop: we accept or fail with error\n break;\n }\n } catch (ex) {\n // report exceptions through the parseError callback too, but keep the exception intact\n // if it is a known parser or lexer error which has been thrown by parseError() already:\n if (ex instanceof this.JisonParserError) {\n throw ex;\n } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) {\n throw ex;\n }\n\n p = this.constructParseErrorInfo('Parsing aborted due to exception.', ex, null, false);\n retval = false;\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n } finally {\n retval = this.cleanupAfterParse(retval, true, true);\n this.__reentrant_call_depth--;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'return',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n } // /finally\n\n return retval;\n}\n"; // --- END parser kernel --- /* * LR(0) Parser @@ -28288,7 +28599,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }, unionLookaheads: function LALR_unionLookaheads() { var self = this, - newg = this.newg; // var states = !!this.onDemandLookahead ? this.inadequateStates : this.states; + newg = this.newg; // let states = !!this.onDemandLookahead ? this.inadequateStates : this.states; var these_states = this.states; these_states.forEach(function union_states_forEach(state, i) { @@ -28404,19 +28715,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi closureOperation: function LR_ClosureOperation(itemSet) { var closureSet = new this.ItemSet(); var self = this; - var set = itemSet, - itemQueue; + var set = itemSet; - do { - itemQueue = new Set(); + var _loop3 = function _loop3() { + var itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function LR_AddItemToClosureSets(item) { - var symbol = item.markedSymbol; - var b, r; // if token is a nonterminal, recursively add closures + var symbol = item.markedSymbol; // if token is a nonterminal, recursively add closures if (symbol && self.nonterminals[symbol]) { - r = item.remainingHandle(); - b = self.first(r); + var r = item.remainingHandle(); + var b = self.first(r); if (b.length === 0 || item.production.nullable || self.nullable(r)) { b = b.concat(item.follows); @@ -28435,7 +28744,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } }); set = itemQueue; - } while (!itemQueue.isEmpty()); + }; + + do { + _loop3(); + } while (!set.isEmpty()); return closureSet; } @@ -28466,9 +28779,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi //cleanupTable(this.table); }, parseTable: function ll_ParseTable(productions) { - var table = {}, - symbols_ = this.symbols_, - self = this; + var table = {}; + var symbols_ = this.symbols_; + var self = this; productions.forEach(function (production, i) { var row = table[production.symbol] || {}; var tokens = production.first; @@ -28521,7 +28834,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // Anyway, API/CLI options **override** options coming in from the grammar spec. // - options = mkStdOptions$1("NODEFAULT", grammar.options, options); + options = mkStdOptions$1('NODEFAULT', grammar.options, options); switch (options.type || Jison$1.defaultJisonOptions.type) { case 'lr0': @@ -28561,7 +28874,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return gen.createParser(); } - Jison$1.Parser = Parser$3; + Jison$1.Parser = Parser$3; // exports for unit/system testing purposes: + + Jison$1.TestExports = { + lookaheadMixin: lookaheadMixin, + generatorMixin: generatorMixin, + lrGeneratorMixin: lrGeneratorMixin, + lalr: lalr, + lr0: lr0, + lr1: lr1, + ll: ll, + parser: parser$4, + pickErrorHandlingChunk: pickErrorHandlingChunk, + addOrRemoveTokenStack: addOrRemoveTokenStack, + removeUnusedKernelFeatures: removeUnusedKernelFeatures, + expandParseArguments: expandParseArguments + }; var rmCommonWS$6 = helpers.rmCommonWS; var mkIdentifier$5 = helpers.mkIdentifier; assert__default['default'](Jison$1); @@ -28569,7 +28897,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi assert__default['default'](Jison$1.defaultJisonOptions); assert__default['default'](typeof Jison$1.mkStdOptions === 'function'); assert__default['default'](typeof Jison$1.Generator === 'function'); - var version$3 = '0.6.2-220'; // require('./package.json').version; + var version$3 = '0.7.0-220'; // require('./package.json').version; function getCommandlineOptions() { var defaults = Jison$1.defaultJisonOptions; @@ -28679,7 +29007,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // FAIL when found: return this.help; }, - help: 'OBSOLETED. Use \'--default-action=[for-value,for-location]\' instead. (See below in \'--help\' output.)' + help: "OBSOLETED. Use '--default-action=[for-value,for-location]' instead. (See below in '--help' output.)" }, defaultActionMode: { full: 'default-action', @@ -28703,7 +29031,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi switch (mode) { case 'false': case '0': - return "none"; + return 'none'; case 'true': case '1': @@ -28721,7 +29049,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return v; }, - help: rmCommonWS$6(_templateObject162(), defaults.defaultActionMode.join(",")) + help: rmCommonWS$6(_templateObject163(), defaults.defaultActionMode.join(',')) }, hasTryCatch: { full: 'try-catch', @@ -28736,13 +29064,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi default: defaults.errorRecoveryTokenDiscardCount, callback: function callback(count) { if (count != parseInt(count)) { - return "count must be an integer"; + return 'count must be an integer'; } count = parseInt(count); if (count < 2) { - return "count must be >= 2"; + return 'count must be >= 2'; } }, transform: function transform(val) { @@ -28755,7 +29083,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi abbr: 'E', flag: true, default: defaults.exportAllTables, - help: 'Next to producing a grammar source file, also export the symbols, terminals, grammar and parse tables to separate JSON files for further use by other tools. The files\' names will be derived from the outputFile name by appending a suffix.' + help: "Next to producing a grammar source file, also export the symbols, terminals, grammar and parse tables to separate JSON files for further use by other tools. The files' names will be derived from the outputFile name by appending a suffix." }, exportAST: { full: 'export-ast', @@ -28783,7 +29111,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi flag: true, metavar: 'false|true|CFGFILE', default: defaults.prettyCfg, - help: 'Output the generated code pretty-formatted; turning this option OFF will output the generated code as-is a.k.a. \'raw\'.' + help: "Output the generated code pretty-formatted; turning this option OFF will output the generated code as-is a.k.a. 'raw'." }, main: { full: 'main', @@ -28810,7 +29138,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }).parse(); if (opts.debug) { - console.log("JISON CLI options:\n", opts); + console.log('JISON CLI options:\n', opts); } return opts; diff --git a/dist/cli-umd.js b/dist/cli-umd.js index 9d6f5092a..665cf0f80 100644 --- a/dist/cli-umd.js +++ b/dist/cli-umd.js @@ -2,16 +2,17 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('fs'), require('path'), require('@gerhobbelt/json5'), require('@gerhobbelt/xregexp'), require('recast'), require('@babel/core'), require('assert'), require('ast-util'), require('process'), require('@gerhobbelt/nomnom')) : - typeof define === 'function' && define.amd ? define(['fs', 'path', '@gerhobbelt/json5', '@gerhobbelt/xregexp', 'recast', '@babel/core', 'assert', 'ast-util', 'process', '@gerhobbelt/nomnom'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['jison-cli'] = factory(global.fs, global.path$1, global.JSON5, global.XRegExp, global.recast, global.babel, global.assert$1, global.astUtils, global.process$1, global.nomnom)); -}(this, (function (fs, path$1, JSON5, XRegExp, recast, babel, assert$1, astUtils, process$1, nomnom) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('fs'), require('path'), require('@gerhobbelt/json5'), require('mkdirp'), require('@gerhobbelt/xregexp'), require('recast'), require('@babel/core'), require('assert'), require('ast-util'), require('process'), require('@gerhobbelt/nomnom')) : + typeof define === 'function' && define.amd ? define(['fs', 'path', '@gerhobbelt/json5', 'mkdirp', '@gerhobbelt/xregexp', 'recast', '@babel/core', 'assert', 'ast-util', 'process', '@gerhobbelt/nomnom'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['jison-cli'] = factory(global.fs, global.path$1, global.JSON5, global.mkdirp, global.XRegExp, global.recast, global.babel, global.assert$1, global.astUtils, global.process$1, global.nomnom)); +}(this, (function (fs, path$1, JSON5, mkdirp, XRegExp, recast, babel, assert$1, astUtils, process$1, nomnom) { 'use strict'; function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); + var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); @@ -19,7 +20,7 @@ var process__default = /*#__PURE__*/_interopDefaultLegacy(process$1); var nomnom__default = /*#__PURE__*/_interopDefaultLegacy(nomnom); - // Return TRUE if `src` starts with `searchString`. + // Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -42,19 +43,19 @@ // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -73,19 +74,21 @@ // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -94,16 +97,19 @@ } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -114,27 +120,79 @@ return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } + // https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words + const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; + })([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' + ]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -152,6 +210,11 @@ .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -160,13 +223,13 @@ function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -177,23 +240,17 @@ break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -216,34 +273,33 @@ /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote$1(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -266,28 +322,76 @@ // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } + function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; + } + + + function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); + } + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -298,27 +402,37 @@ dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -328,7 +442,7 @@ } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -336,7 +450,7 @@ ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -362,27 +476,43 @@ // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -395,9 +525,10 @@ - var code_exec = { + var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -419,22 +550,22 @@ // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; - // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries + // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; - // Determine which Unicode NonAsciiIdentifierStart characters + // Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. - // + // // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action - // code chunks. - // + // code chunks. + // // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -442,40 +573,40 @@ function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -483,30 +614,30 @@ // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -517,59 +648,59 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -611,38 +742,38 @@ return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -654,18 +785,18 @@ // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -676,56 +807,56 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -733,97 +864,97 @@ typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -831,7 +962,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -844,7 +975,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -857,7 +988,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -870,7 +1001,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -889,37 +1020,37 @@ let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -951,7 +1082,7 @@ // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -968,37 +1099,37 @@ .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return babel.transformSync(src, options); // => { code, map, ast } @@ -1006,8 +1137,8 @@ function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1016,7 +1147,7 @@ // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1039,25 +1170,25 @@ // validate the given JISON+JavaScript snippet: does it compile? - // - // Return either the parsed AST (object) or an error message (string). + // + // Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1068,9 +1199,9 @@ // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. - // + // // Returns the trimmed sourcecode which was provided via `src`. - // + // // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1078,7 +1209,7 @@ // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: - // + // // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1087,14 +1218,14 @@ // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} - // + // // Of course the example would be 'ludicrous' action code but the - // key point here is that users will certainly be able to come up with + // key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! - // + // function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1148,7 +1279,7 @@ trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1162,7 +1293,7 @@ /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1174,24 +1305,24 @@ /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. - /// + /// /// Also supports ES6's Arrow Functions: - /// + /// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' - /// + /// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1208,8 +1339,8 @@ if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1220,14 +1351,14 @@ action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1238,17 +1369,17 @@ var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; - // - // - // + // + // + // function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1274,7 +1405,7 @@ // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1322,7 +1453,7 @@ // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1385,13 +1516,13 @@ getRegExpInfo: getRegExpInfo }; - var cycleref = []; - var cyclerefpath = []; + let cycleref = []; + let cyclerefpath = []; - var linkref = []; - var linkrefpath = []; + let linkref = []; + let linkrefpath = []; - var path = []; + let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1399,14 +1530,14 @@ return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1419,11 +1550,11 @@ function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1436,9 +1567,9 @@ dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1453,16 +1584,52 @@ } + // strip developer machine specific parts off any paths in a given stacktrace (string) + // to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } + // strip off the line/position info from any stacktrace as a assert.deepEqual() on these + // will otherwise FAIL due to us running this stuff through both regular `node` and + // the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing + // exceptions and stacktraces which point completely somewhere else and this would b0rk + // our test rigs for the jison subpackages. + function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; + } + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1477,7 +1644,7 @@ function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1503,10 +1670,10 @@ } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1604,7 +1771,7 @@ function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1621,7 +1788,7 @@ path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1649,7 +1816,7 @@ function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1665,7 +1832,7 @@ linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1677,14 +1844,14 @@ // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. - // + // // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1694,7 +1861,7 @@ cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1708,12 +1875,14 @@ dquote: dquote$1, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1728,7 +1897,7 @@ printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; /* @@ -1738,23 +1907,23 @@ * By Zachary Carter * MIT Licensed */ - var mkIdentifier$1 = helpers.mkIdentifier; + let mkIdentifier$1 = helpers.mkIdentifier; - var create = Object.create || function (o) { - function F(){} - F.prototype = o; - return new F(); + let create = Object.create || function (o) { + function F() {} + F.prototype = o; + return new F(); }; - var position = /^(before|after)/; + let position = /^(before|after)/; // basic method layering // always returns original method's return value function layerMethod(pos, key, prop, fun) { if (pos === 'after') { return function () { - var ret = prop.apply(this, arguments); - var args = [].slice.call(arguments); + let ret = prop.apply(this, arguments); + let args = [].slice.call(arguments); args.splice(0, 0, ret); fun.apply(this, args); return ret; @@ -1762,7 +1931,7 @@ } else if (pos === 'before') { return function () { fun.apply(this, arguments); - var ret = prop.apply(this, arguments); + let ret = prop.apply(this, arguments); return ret; }; } @@ -1773,7 +1942,7 @@ // overwriting them or layering them. i.e. an object method 'meth' is // layered by mixin methods 'beforemeth' or 'aftermeth' function typal_mix() { - var i, o, k; + let i, o, k; for (i = 0; i < arguments.length; i++) { o = arguments[i]; if (!o) continue; @@ -1785,8 +1954,8 @@ } for (k in o) { if (Object.prototype.hasOwnProperty.call(o, k)) { - var match = k.match(position); - var key = k.replace(position, ''); + let match = k.match(position); + let key = k.replace(position, ''); if (match && typeof this[key] === 'function') { this[key] = layerMethod(match[0], key, this[key], o[k]); } else { @@ -1800,15 +1969,15 @@ // Same as typal_mix but also camelCases every object member and 'standardizes' the key set of every input // argument through a caLLback function. - // + // // This is useful for processing options with dashes in their key, e.g. `token-stack` --> tokenStack. function typal_camel_mix(cb) { - var i, o, k; + let i, o, k; // Convert first character to lowercase function lcase0(s) { - return s.replace(/^\w/, function (match) { - return match.toLowerCase(); + return s.replace(/^\w/, function (match) { + return match.toLowerCase(); }); } @@ -1826,16 +1995,15 @@ } for (k in o) { if (Object.prototype.hasOwnProperty.call(o, k)) { - var nk = mkIdentifier$1(k); - var match = k.match(position); - var key = k.replace(position, ''); + let nk = mkIdentifier$1(k); + let match = k.match(position); + let key = k.replace(position, ''); // This anticipates before/after members to be camelcased already, e.g. - // 'afterParse()' for layering 'parse()': - var alt_key = lcase0(key); + // 'afterParse()' for layering 'parse()': + let alt_key = lcase0(key); if (match && typeof this[key] === 'function') { this[key] = layerMethod(match[0], key, this[key], o[k]); - } - else if (match && typeof this[alt_key] === 'function') { + } else if (match && typeof this[alt_key] === 'function') { this[alt_key] = layerMethod(match[0], alt_key, this[alt_key], o[k]); } else { this[nk] = o[k]; @@ -1846,7 +2014,7 @@ return this; } - var typal = { + let typal = { // extend object with own properties of each argument mix: typal_mix, @@ -1861,9 +2029,9 @@ // Creates a new Class function based on an object with a constructor method construct: function typal_construct() { - var o = typal_mix.apply(create(this), arguments); - var constructor = o.constructor; - var Klass = o.constructor = function () { return constructor.apply(this, arguments); }; + let o = typal_mix.apply(create(this), arguments); + let constructor = o.constructor; + let Klass = o.constructor = function () { return constructor.apply(this, arguments); }; Klass.prototype = o; Klass.mix = typal_mix; // allow for easy singleton property extension return Klass; @@ -1875,13 +2043,12 @@ // Set class to wrap arrays - var setMixin = { + let setMixin = { constructor: function Set_constructor(set, raw) { this._items = []; if (set && set.constructor === Array) { - this._items = raw ? set: set.slice(0); - } - else if (arguments.length) { + this._items = raw ? set : set.slice(0); + } else if (arguments.length) { this._items = [].slice.call(arguments, 0); } }, @@ -1894,7 +2061,7 @@ }, indexOf: function indexOf(item) { if (item && item.eq) { - for (var k = 0; k < this._items.length; k++) { + for (let k = 0; k < this._items.length; k++) { if (item.eq(this._items[k])) { return k; } @@ -1909,14 +2076,14 @@ }); }, complement: function complement(set) { - var that = this; + let that = this; return set.filter(function sub_complement(elm) { return !that.contains(elm); }); }, subset: function subset(set) { - var cont = true; - for (var i = 0; i < this._items.length && cont; i++) { + let cont = true; + for (let i = 0; i < this._items.length && cont; i++) { cont = cont && set.contains(this._items[i]); } return cont; @@ -1927,60 +2094,59 @@ joinSet: function joinSet(set) { return this.concat(this.complement(set)); }, - contains: function contains(item) { - return this.indexOf(item) !== -1; + contains: function contains(item) { + return this.indexOf(item) !== -1; }, - item: function item(v) { - return this._items[v]; + item: function item(v) { + return this._items[v]; }, - i: function i(v) { - return this._items[v]; + i: function i(v) { + return this._items[v]; }, - assign: function assign(index, value) { + assign: function assign(index, value) { this._items[index] = value; - return this; + return this; }, - first: function first() { - return this._items[0]; + first: function first() { + return this._items[0]; }, - last: function last() { - return this._items[this._items.length - 1]; + last: function last() { + return this._items[this._items.length - 1]; }, - size: function size() { - return this._items.length; + size: function size() { + return this._items.length; }, - isEmpty: function isEmpty() { - return this._items.length === 0; + isEmpty: function isEmpty() { + return this._items.length === 0; }, - copy: function copy() { - return new Set(this._items); + copy: function copy() { + return new Set$1(this._items); }, - toString: function toString() { - return this._items.toString(); + toString: function toString() { + return this._items.toString(); } }; 'push shift unshift forEach some every join sort'.split(' ').forEach(function (e, i) { - setMixin[e] = function () { - return Array.prototype[e].apply(this._items, arguments); + setMixin[e] = function () { + return Array.prototype[e].apply(this._items, arguments); }; //setMixin[e].name = e; }); 'filter slice map'.split(' ').forEach(function (e, i) { - setMixin[e] = function () { - return new Set(Array.prototype[e].apply(this._items, arguments), true); + setMixin[e] = function () { + return new Set$1(Array.prototype[e].apply(this._items, arguments), true); }; //setMixin[e].name = e; }); - var Set = typal.construct(setMixin); + var Set$1 = typal.construct(setMixin); // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1997,9 +2163,9 @@ this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -2032,10 +2198,10 @@ // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -2048,11 +2214,11 @@ // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -2062,18 +2228,18 @@ // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -2104,7 +2270,7 @@ // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -2121,9 +2287,9 @@ // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -2136,7 +2302,7 @@ } - var parser = { + let parser = { // Code Generator Information Report // --------------------------------- // @@ -2386,7 +2552,6 @@ // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2394,7 +2559,6 @@ // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2406,8 +2570,8 @@ // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2420,14 +2584,13 @@ // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2443,10 +2606,10 @@ // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2454,10 +2617,10 @@ this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2612,9 +2775,9 @@ /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -2626,18 +2789,18 @@ case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2667,9 +2830,9 @@ case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -2682,10 +2845,10 @@ case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2712,9 +2875,9 @@ case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -2723,10 +2886,10 @@ case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2754,9 +2917,9 @@ case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -2765,10 +2928,10 @@ case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -2807,9 +2970,9 @@ case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2874,9 +3037,9 @@ case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2891,9 +3054,9 @@ case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -2928,10 +3091,10 @@ case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2948,9 +3111,9 @@ case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2967,10 +3130,10 @@ case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2987,9 +3150,9 @@ case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -3006,10 +3169,10 @@ case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3026,9 +3189,9 @@ case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3052,9 +3215,9 @@ case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3065,9 +3228,9 @@ case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3087,9 +3250,9 @@ case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3113,9 +3276,9 @@ case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -3128,10 +3291,10 @@ case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3148,9 +3311,9 @@ case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -3162,9 +3325,9 @@ case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -3204,10 +3367,10 @@ case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3227,9 +3390,9 @@ case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3279,10 +3442,10 @@ case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -3306,10 +3469,10 @@ case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3329,10 +3492,10 @@ case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3356,10 +3519,10 @@ case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3380,10 +3543,10 @@ case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3395,10 +3558,10 @@ case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3408,10 +3571,10 @@ case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3421,10 +3584,10 @@ case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3434,10 +3597,10 @@ case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3447,10 +3610,10 @@ case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -3460,10 +3623,10 @@ case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3473,10 +3636,10 @@ case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3486,9 +3649,9 @@ case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -3497,9 +3660,9 @@ case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -3508,9 +3671,9 @@ case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3532,9 +3695,9 @@ case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3545,9 +3708,9 @@ case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3567,9 +3730,9 @@ case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3623,9 +3786,9 @@ case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3645,9 +3808,9 @@ case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -3656,9 +3819,9 @@ case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -3670,9 +3833,9 @@ case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -3686,10 +3849,10 @@ case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3709,10 +3872,10 @@ case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3732,10 +3895,10 @@ case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3755,9 +3918,9 @@ case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3768,9 +3931,9 @@ case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3789,9 +3952,9 @@ case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -3832,9 +3995,9 @@ case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3858,9 +4021,9 @@ case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3886,9 +4049,9 @@ case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3933,9 +4096,9 @@ case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -3961,9 +4124,9 @@ case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -3972,9 +4135,9 @@ case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -3983,10 +4146,10 @@ case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4000,10 +4163,10 @@ case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4017,10 +4180,10 @@ case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4034,10 +4197,10 @@ case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4056,9 +4219,9 @@ case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4067,9 +4230,9 @@ case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -4107,10 +4270,10 @@ case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -4134,9 +4297,9 @@ case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -4215,9 +4378,9 @@ case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -4226,9 +4389,9 @@ case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -4237,9 +4400,9 @@ case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -4248,9 +4411,9 @@ case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -4259,9 +4422,9 @@ case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -4270,9 +4433,9 @@ case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -4281,9 +4444,9 @@ case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -4294,10 +4457,10 @@ case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4314,9 +4477,9 @@ case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -4325,9 +4488,9 @@ case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -4336,9 +4499,9 @@ case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -4347,9 +4510,9 @@ case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -4358,9 +4521,9 @@ case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -4379,18 +4542,18 @@ case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -4399,9 +4562,9 @@ case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -4410,9 +4573,9 @@ case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -4421,9 +4584,9 @@ case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -4432,9 +4595,9 @@ case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -4443,10 +4606,10 @@ case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4463,9 +4626,9 @@ case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -4482,9 +4645,9 @@ case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -4496,9 +4659,9 @@ case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -4508,9 +4671,9 @@ case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4545,9 +4708,9 @@ case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4566,9 +4729,9 @@ case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -4577,9 +4740,9 @@ case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -4588,9 +4751,9 @@ case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4608,10 +4771,10 @@ case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -4629,10 +4792,10 @@ case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -4653,9 +4816,9 @@ case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4688,9 +4851,9 @@ case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4716,9 +4879,9 @@ case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5__default['default'].parse(yyvstack[yysp]); @@ -4727,9 +4890,9 @@ case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue(yyvstack[yysp]); @@ -4738,9 +4901,9 @@ case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4749,9 +4912,9 @@ case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -4772,10 +4935,10 @@ case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4792,9 +4955,9 @@ case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -4813,9 +4976,9 @@ case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4839,9 +5002,9 @@ case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -4861,9 +5024,9 @@ case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4874,9 +5037,9 @@ case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -4932,10 +5095,10 @@ case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6538,7 +6701,6 @@ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -6555,38 +6717,34 @@ } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -6594,20 +6752,18 @@ pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -6629,7 +6785,6 @@ // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -6637,18 +6792,19 @@ if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -6656,24 +6812,19 @@ // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -6711,18 +6862,15 @@ - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); + let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -6743,7 +6891,7 @@ // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -6761,7 +6909,6 @@ // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -6774,7 +6921,6 @@ // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -6788,11 +6934,10 @@ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -6846,8 +6991,8 @@ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6855,8 +7000,8 @@ this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6888,19 +7033,18 @@ // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -6911,7 +7055,7 @@ if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -6924,7 +7068,7 @@ if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -6936,29 +7080,27 @@ // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -6966,7 +7108,7 @@ l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -6986,8 +7128,7 @@ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -6996,10 +7137,10 @@ token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -7007,7 +7148,7 @@ location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -7018,9 +7159,14 @@ // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -7036,8 +7182,7 @@ // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -7106,11 +7251,14 @@ // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -7121,8 +7269,7 @@ }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -7131,21 +7278,20 @@ function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -7155,21 +7301,20 @@ } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -7178,28 +7323,27 @@ return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -7212,8 +7356,7 @@ - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; + const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -7236,8 +7379,7 @@ - - if (symbol === EOF) { + if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -7249,8 +7391,7 @@ - - --stack_probe; // popStack(1): [symbol, action] + --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -7267,8 +7408,7 @@ - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -7282,8 +7422,7 @@ - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } @@ -7297,7 +7436,7 @@ // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -7350,16 +7489,13 @@ - - - - // handle parse error + // handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -7393,9 +7529,7 @@ - - - r = this.parseError(p.errStr, p, this.JisonParserError); + r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -7418,9 +7552,7 @@ - - - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -7447,17 +7579,16 @@ - - } + } // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -7504,8 +7635,8 @@ recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -7517,8 +7648,7 @@ - - } else { + } else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -7536,6 +7666,7 @@ yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -7544,7 +7675,7 @@ - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -7555,7 +7686,7 @@ sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -7615,10 +7746,10 @@ // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -7653,9 +7784,7 @@ - - - // encountered another parse error? If so, break out to main loop + // encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -7668,7 +7797,7 @@ - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -7689,9 +7818,7 @@ - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7713,12 +7840,12 @@ // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -7727,7 +7854,7 @@ ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7768,7 +7895,7 @@ } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -7815,7 +7942,7 @@ // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -7833,21 +7960,19 @@ - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7881,14 +8006,15 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7898,6 +8024,7 @@ + } continue; // accept: @@ -7949,7 +8076,7 @@ // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -7965,9 +8092,7 @@ - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7996,7 +8121,7 @@ sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -8013,8 +8138,8 @@ symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -8025,8 +8150,8 @@ // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -8038,21 +8163,19 @@ - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -8083,14 +8206,15 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -8100,6 +8224,7 @@ + } continue; // accept: @@ -8152,8 +8277,7 @@ // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -8414,7 +8538,6 @@ * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -8431,10 +8554,10 @@ }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -8466,7 +8589,7 @@ JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -8508,7 +8631,9 @@ // // --------- END OF REPORT ----------- - EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -8594,7 +8719,7 @@ if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -8602,7 +8727,7 @@ msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -8615,7 +8740,7 @@ } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -8641,10 +8766,13 @@ * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -8667,7 +8795,6 @@ * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -8690,16 +8817,16 @@ * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -8721,7 +8848,6 @@ * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -8729,8 +8855,8 @@ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -8759,7 +8885,7 @@ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -8784,7 +8910,7 @@ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -8796,17 +8922,17 @@ } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -8900,7 +9026,7 @@ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -8921,7 +9047,6 @@ * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -8932,7 +9057,7 @@ this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -8943,15 +9068,15 @@ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -8985,8 +9110,8 @@ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -9019,9 +9144,9 @@ // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -9040,9 +9165,9 @@ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -9052,8 +9177,8 @@ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -9080,20 +9205,19 @@ * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -9133,17 +9257,19 @@ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -9152,7 +9278,7 @@ // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -9167,8 +9293,8 @@ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -9194,24 +9320,26 @@ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -9222,7 +9350,7 @@ // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -9244,8 +9372,8 @@ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -9267,8 +9395,7 @@ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -9412,21 +9539,21 @@ const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -9441,11 +9568,11 @@ len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -9464,13 +9591,13 @@ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -9494,13 +9621,13 @@ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -9515,8 +9642,8 @@ } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -9547,7 +9674,7 @@ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -9579,9 +9706,9 @@ }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -9610,7 +9737,7 @@ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -9628,7 +9755,7 @@ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -9653,7 +9780,6 @@ * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -9663,8 +9789,6 @@ this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -9673,7 +9797,7 @@ this.clear(); } - 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. @@ -9685,13 +9809,13 @@ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -9701,68 +9825,74 @@ } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -9787,7 +9917,7 @@ * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -9835,24 +9965,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9872,7 +10002,7 @@ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -9882,24 +10012,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9920,8 +10050,7 @@ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -9961,14 +10090,14 @@ * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -9984,9 +10113,9 @@ if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -9997,8 +10126,8 @@ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -10006,7 +10135,7 @@ state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -11696,7 +11825,7 @@ // The expanded regex sets which are equivalent to the given `\\{c}` escapes: // // `/\s/`: - const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; + const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; // `/\d/`: const DIGIT_SETSTR = '0-9'; // `/\w/`: @@ -11708,7 +11837,7 @@ // Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex function i2c(i) { - var c, x; + let c, x; switch (i) { case 10: @@ -11748,7 +11877,7 @@ || i > 0xFFF0 /* Unicode Specials, also in UTF16 */ || (i >= 0xD800 && i <= 0xDFFF) /* Unicode Supplementary Planes; we're TOAST in JavaScript as we're NOT UTF-16 but UCS-2! */ || String.fromCharCode(i).match(/[\u2028\u2029]/) /* Code compilation via `new Function()` does not like to see these, or rather: treats them as just another form of CRLF, which breaks your generated regex code! */ - ) { + ) { // Detail about a detail: // U+2028 and U+2029 are part of the `\s` regex escape code (`\s` and `[\s]` match either of these) and when placed in a JavaScript // source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report @@ -11756,11 +11885,10 @@ // Hence we MUST escape these buggers everywhere we go... x = i.toString(16); if (x.length >= 1 && i <= 0xFFFF) { - c = '0000' + x; - return '\\u' + c.substr(c.length - 4); - } else { - return '\\u{' + x + '}'; + c = '0000' + x; + return '\\u' + c.substr(c.length - 4); } + return '\\u{' + x + '}'; } return String.fromCharCode(i); } @@ -11769,18 +11897,18 @@ // Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating // this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a // `\\p{NAME}` shorthand to represent [part of] the bitarray: - var Pcodes_bitarray_cache = {}; - var Pcodes_bitarray_cache_test_order = []; + let Pcodes_bitarray_cache = {}; + let Pcodes_bitarray_cache_test_order = []; - // Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by + // Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. - var EscCode_bitarray_output_refs; + let EscCode_bitarray_output_refs; // now initialize the EscCodes_... table above: init_EscCode_lookup_table(); function init_EscCode_lookup_table() { - var s, bitarr, set2esc = {}, esc2bitarr = {}; + let s, bitarr, set2esc = {}, esc2bitarr = {}; // patch global lookup tables for the time being, while we calculate their *real* content in this function: EscCode_bitarray_output_refs = { @@ -11849,13 +11977,13 @@ }; updatePcodesBitarrayCacheTestOrder(); - } + } function updatePcodesBitarrayCacheTestOrder(opts) { - var t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var l = {}; - var user_has_xregexp = opts && opts.options && opts.options.xregexp; - var i, j, k, ba; + let t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let l = {}; + let user_has_xregexp = opts && opts.options && opts.options.xregexp; + let i, j, k, ba; // mark every character with which regex pcodes they are part of: for (k in Pcodes_bitarray_cache) { @@ -11865,12 +11993,12 @@ continue; } - var cnt = 0; + let cnt = 0; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { cnt++; if (!t[i]) { - t[i] = [k]; + t[i] = [ k ]; } else { t[i].push(k); } @@ -11880,27 +12008,27 @@ } // now dig out the unique ones: only need one per pcode. - // + // // We ASSUME every \\p{NAME} 'pcode' has at least ONE character - // in it that is ONLY matched by that particular pcode. + // in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode - // won't be tested during optimization. - // + // won't be tested during optimization. + // // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to // look for markers which match multiple escapes/pcodes for those // ones where a unique item isn't available... - var lut = []; - var done = {}; - var keys = Object.keys(Pcodes_bitarray_cache); + let lut = []; + let done = {}; + let keys = Object.keys(Pcodes_bitarray_cache); for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { k = t[i][0]; if (t[i].length === 1 && !done[k]) { assert__default['default'](l[k] > 0); - lut.push([i, k]); + lut.push([ i, k ]); done[k] = true; } } @@ -11911,19 +12039,19 @@ if (!user_has_xregexp && k.indexOf('\\p{') >= 0) { continue; } - + if (!done[k]) { assert__default['default'](l[k] > 0); // find a minimum span character to mark this one: - var w = Infinity; + let w = Infinity; var rv; ba = Pcodes_bitarray_cache[k]; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { - var tl = t[i].length; + let tl = t[i].length; if (tl > 1 && tl < w) { assert__default['default'](l[k] > 0); - rv = [i, k]; + rv = [ i, k ]; w = tl; } } @@ -11937,16 +12065,16 @@ // order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. - // + // // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more - // optimal minification of the regex set expression. - // + // optimal minification of the regex set expression. + // // This is a guestimate/heuristic only! lut.sort(function (a, b) { - var k1 = a[1]; - var k2 = b[1]; - var ld = l[k2] - l[k1]; + let k1 = a[1]; + let k2 = b[1]; + let ld = l[k2] - l[k1]; if (ld) { return ld; } @@ -11964,19 +12092,19 @@ // 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set. function set2bitarray(bitarr, s, opts) { - var orig = s; - var set_is_inverted = false; - var bitarr_orig; + let orig = s; + let set_is_inverted = false; + let bitarr_orig; function mark(d1, d2) { if (d2 == null) d2 = d1; - for (var i = d1; i <= d2; i++) { + for (let i = d1; i <= d2; i++) { bitarr[i] = true; } } function add2bitarray(dst, src) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (src[i]) { dst[i] = true; } @@ -11984,10 +12112,10 @@ } function eval_escaped_code(s) { - var c; + let c; // decode escaped code? If none, just take the character as-is if (s.indexOf('\\') === 0) { - var l = s.substr(0, 2); + let l = s.substr(0, 2); switch (l) { case '\\c': c = s.charCodeAt(2) - 'A'.charCodeAt(0) + 1; @@ -12005,7 +12133,7 @@ } c = parseInt(s, 16); if (c >= 0x10000) { - return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); + return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); } return String.fromCharCode(c); @@ -12049,7 +12177,7 @@ } if (s && s.length) { - var c1, c2; + let c1, c2; // inverted set? if (s[0] === '^') { @@ -12080,13 +12208,13 @@ c2 = c2[0]; s = s.substr(c2.length); // do we have this one cached already? - var pex = c1 + c2; - var ba4p = Pcodes_bitarray_cache[pex]; + let pex = c1 + c2; + let ba4p = Pcodes_bitarray_cache[pex]; if (!ba4p) { // expand escape: - var xr = new XRegExp__default['default']('[' + pex + ']'); // TODO: case-insensitive grammar??? + let xr = new XRegExp__default['default']('[' + pex + ']'); // TODO: case-insensitive grammar??? // rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`: - var xs = '' + xr; + let xs = '' + xr; // remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: xs = xs.substr(1, xs.length - 2); @@ -12121,7 +12249,7 @@ break; } } - var v1 = eval_escaped_code(c1); + let v1 = eval_escaped_code(c1); // propagate deferred exceptions = error reports. if (v1 instanceof Error) { return v1; @@ -12139,7 +12267,7 @@ } else { c2 = c2[0]; } - var v2 = eval_escaped_code(c2); + let v2 = eval_escaped_code(c2); // propagate deferred exceptions = error reports. if (v2 instanceof Error) { return v1; @@ -12162,12 +12290,12 @@ } // When we have marked all slots, '^' NEGATES the set, hence we flip all slots. - // + // // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. if (set_is_inverted) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (!bitarr[i]) { bitarr_orig[i] = true; } @@ -12186,10 +12314,10 @@ // below can be simple and fast: l[UNICODE_BASE_PLANE_MAX_CP + 1] = 1; // now reconstruct the regex set: - var rv = []; - var i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; - var bitarr_is_cloned = false; - var l_orig = l; + let rv = []; + let i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; + let bitarr_is_cloned = false; + let l_orig = l; if (output_inverted_variant) { // generate the inverted set, hence all unmarked slots are part of the output range: @@ -12203,8 +12331,7 @@ // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. // BUT... since we output the INVERTED set, we output the match-all set instead: return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` // BUT... since we output the INVERTED set, we output the match-nothing set instead: @@ -12236,9 +12363,9 @@ } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12265,7 +12392,7 @@ } } } - + i = 0; while (i <= UNICODE_BASE_PLANE_MAX_CP) { // find first character not in original set: @@ -12296,8 +12423,7 @@ // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. return '^\\S\\s'; } @@ -12327,9 +12453,9 @@ } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12381,11 +12507,11 @@ } assert__default['default'](rv.length); - var s = rv.join(''); + let s = rv.join(''); assert__default['default'](s); // Check if the set is better represented by one of the regex escapes: - var esc4s = EscCode_bitarray_output_refs.set2esc[s]; + let esc4s = EscCode_bitarray_output_refs.set2esc[s]; if (esc4s) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return '\\' + esc4s; @@ -12400,25 +12526,24 @@ // Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there; // ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`. function reduceRegexToSetBitArray(s, name, opts) { - var orig = s; + let orig = s; // propagate deferred exceptions = error reports. if (s instanceof Error) { return s; } - var l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var internal_state = 0; - var derr; + let l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let internal_state = 0; + let derr; while (s.length) { - var c1 = s.match(CHR_RE); + let c1 = s.match(CHR_RE); if (!c1) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"'); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12426,15 +12551,14 @@ // this is starting a set within the regex: scan until end of set! var set_content = []; while (s.length) { - var inner = s.match(SET_PART_RE); + let inner = s.match(SET_PART_RE); if (!inner) { inner = s.match(CHR_RE); if (!inner) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"'); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12448,9 +12572,8 @@ if (!c2) { // cope with illegal escape sequences too! return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error('regex set expression is broken in regex: ' + orig); } @@ -12534,10 +12657,9 @@ // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; assert__default['default'](s); assert__default['default'](!(s instanceof Error)); - re = new XRegExp__default['default']('[' + s + ']'); + let re = new XRegExp__default['default']('[' + s + ']'); re.test(s[0]); // One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` @@ -12562,25 +12684,24 @@ - // Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` + // Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! function produceOptimizedRegex4Set(bitarr) { // First try to produce a minimum regex from the bitarray directly: - var s1 = bitarray2set(bitarr, false, true); + let s1 = bitarray2set(bitarr, false, true); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s1.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s1; - } else { - s1 = '[' + s1 + ']'; } + s1 = '[' + s1 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s2 = bitarray2set(bitarr, true, true); + let s2 = bitarray2set(bitarr, true, true); if (s2[0] === '^') { s2 = s2.substr(1); @@ -12595,23 +12716,22 @@ // Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: - // + // // First try to produce a minimum regex from the bitarray directly: - var s3 = bitarray2set(bitarr, false, false); + let s3 = bitarray2set(bitarr, false, false); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s3.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s3; - } else { - s3 = '[' + s3 + ']'; } + s3 = '[' + s3 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s4 = bitarray2set(bitarr, true, false); + let s4 = bitarray2set(bitarr, true, false); if (s4[0] === '^') { s4 = s4.substr(1); @@ -12643,30 +12763,30 @@ var setmgmt = { - XREGEXP_UNICODE_ESCAPE_RE, - CHR_RE, - SET_PART_RE, - NOTHING_SPECIAL_RE, - SET_IS_SINGLE_PCODE_RE, - - UNICODE_BASE_PLANE_MAX_CP, - - WHITESPACE_SETSTR, - DIGIT_SETSTR, - WORDCHAR_SETSTR, - - set2bitarray, - bitarray2set, - produceOptimizedRegex4Set, - reduceRegexToSetBitArray, + XREGEXP_UNICODE_ESCAPE_RE, + CHR_RE, + SET_PART_RE, + NOTHING_SPECIAL_RE, + SET_IS_SINGLE_PCODE_RE, + + UNICODE_BASE_PLANE_MAX_CP, + + WHITESPACE_SETSTR, + DIGIT_SETSTR, + WORDCHAR_SETSTR, + + set2bitarray, + bitarray2set, + produceOptimizedRegex4Set, + reduceRegexToSetBitArray }; // Basic Lexer implemented using JavaScript regular expressions - var rmCommonWS$2 = helpers.rmCommonWS; - var mkIdentifier$3 = helpers.mkIdentifier; - var code_exec$1 = helpers.exec; + const rmCommonWS$2 = helpers.rmCommonWS; + const mkIdentifier$3 = helpers.mkIdentifier; + const code_exec = helpers.exec; - var version = '0.6.2-220'; // require('./package.json').version; + const version = '0.6.2-220'; // require('./package.json').version; @@ -12727,7 +12847,7 @@ exportAST: false, prettyCfg: true, pre_lex: undefined, - post_lex: undefined, + post_lex: undefined }; @@ -12745,23 +12865,23 @@ // Return a fresh set of options. /** @public */ function mkStdOptions(/*...args*/) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - var args = [].concat.apply([], arguments); + let opts = {}; + let args = [].concat.apply([], arguments); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(defaultJisonLexOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; for (var p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { @@ -12799,7 +12919,7 @@ function prepExportStructures(options) { // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -12820,8 +12940,8 @@ // Otherwise return the *parsed* lexer spec as it has // been processed through LexParser. function autodetectAndConvertToJSONformat(lexerSpec, options) { - var chk_l = null; - var ex1, err; + let chk_l = null; + let ex1, err; if (typeof lexerSpec === 'string') { if (options.json) { @@ -12873,9 +12993,9 @@ /should be separated/, /an error in one or more of your lexer regex rules/, /an error in your lexer epilogue/, - /unsupported definition type/, + /unsupported definition type/ ]; - var cmnerr = commonErrors.filter(function check(re) { + let cmnerr = commonErrors.filter(function check(re) { return e.message.match(re); }); if (cmnerr.length > 0) { @@ -12904,14 +13024,14 @@ // expand macros and convert matchers to RegExp's function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) { - var m, i, k, rule, action, conditions; - var active_conditions; + let m, i, k, rule, action, conditions; + let active_conditions; assert__default['default'](Array.isArray(dict.rules)); - var rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! - var newRules = []; - var macros = {}; - var regular_rule_count = 0; - var simple_rule_count = 0; + let rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! + let newRules = []; + let macros = {}; + let regular_rule_count = 0; + let simple_rule_count = 0; // Assure all options are camelCased: assert__default['default'](typeof opts.options['case-insensitive'] === 'undefined'); @@ -12921,7 +13041,7 @@ } if (opts.options.flex && rules.length > 0) { - rules.push(['.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']); + rules.push([ '.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */' ]); } // Depending on the location within the regex we need different expansions of the macros: @@ -12945,7 +13065,7 @@ return str; } - var routingCode = ['switch(yyrulenumber) {']; + let routingCode = [ 'switch(yyrulenumber) {' ]; for (i = 0; i < rules.length; i++) { rule = rules[i].slice(0); // shallow copy: do not modify input rules @@ -12999,7 +13119,7 @@ action = action.replace(/return\s*\(?'((?:\\'|[^']+)+)'\)?/g, tokenNumberReplacement); action = action.replace(/return\s*\(?"((?:\\"|[^"]+)+)"\)?/g, tokenNumberReplacement); - var code = ['\n/*! Conditions::']; + let code = [ '\n/*! Conditions::' ]; code.push(postprocessComment(active_conditions)); code.push('*/', '\n/*! Rule:: '); code.push(postprocessComment(rule[0])); @@ -13020,7 +13140,7 @@ // 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'. - var match_nr = /^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim()); + 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 ')); @@ -13047,7 +13167,7 @@ macros: macros, regular_rule_count: regular_rule_count, - simple_rule_count: simple_rule_count, + simple_rule_count: simple_rule_count }; } @@ -13060,14 +13180,13 @@ // 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. function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElsewhere_cb) { - var orig = s; + let orig = s; function errinfo() { if (name) { return 'macro [[' + name + ']]'; - } else { - return 'regex [[' + orig + ']]'; } + return 'regex [[' + orig + ']]'; } // propagate deferred exceptions = error reports. @@ -13075,19 +13194,18 @@ return s; } - var c1, c2; - var rv = []; - var derr; - var se; + let c1, c2; + let rv = []; + let derr; + let se; while (s.length) { c1 = s.match(CHR_RE$1); if (!c1) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -13097,15 +13215,14 @@ var l = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1); while (s.length) { - var inner = s.match(SET_PART_RE$1); + let inner = s.match(SET_PART_RE$1); if (!inner) { inner = s.match(CHR_RE$1); if (!inner) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -13119,9 +13236,8 @@ if (!c2) { // cope with illegal escape sequences too! return new Error(errinfo() + ': regex set expression is broken: "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error(errinfo() + ': regex set expression is broken: apparently unterminated'); } @@ -13182,7 +13298,7 @@ c2 = c2[0]; s = s.substr(c2.length); - var c3 = s[0]; + let c3 = s[0]; s = s.substr(c3.length); if (c3 === '}') { // possibly a macro name in there... Expand if possible: @@ -13235,7 +13351,7 @@ // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; + let re; re = new XRegExp__default['default'](s); re.test(s[0]); } catch (ex) { @@ -13251,11 +13367,11 @@ // expand macros within macros and cache the result function prepareMacros(dict_macros, opts) { - var macros = {}; + let macros = {}; // expand a `{NAME}` macro which exists inside a `[...]` set: function expandMacroInSet(i) { - var k, a, m; + let k, a, m; if (!macros[i]) { m = dict_macros[i]; @@ -13289,7 +13405,7 @@ a = m.split('{' + k + '}'); if (a.length > 1) { - var x = expandMacroInSet(k); + let x = expandMacroInSet(k); assert__default['default'](x); if (x instanceof Error) { m = x; @@ -13301,9 +13417,9 @@ } } - var mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); + let mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); - var s1; + let s1; // propagate deferred exceptions = error reports. if (mba instanceof Error) { @@ -13337,7 +13453,7 @@ } function expandMacroElsewhere(i) { - var m; + let m; if (macros[i].elsewhere == null) { m = dict_macros[i]; @@ -13372,13 +13488,13 @@ } function expandAllMacrosInSet(s) { - var i, x; + let i, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { for (i in macros) { if (macros.hasOwnProperty(i)) { - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroInSet(i); assert__default['default'](x); @@ -13400,7 +13516,7 @@ } function expandAllMacrosElsewhere(s) { - var i, x; + let i, x; // When we process the remaining macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13415,7 +13531,7 @@ for (i in macros) { if (macros.hasOwnProperty(i)) { // These are all submacro expansions, hence non-capturing grouping is applied: - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroElsewhere(i); assert__default['default'](x); @@ -13437,7 +13553,7 @@ } - var i; + let i; if (opts.debug) console.log('\n############## RAW macros: ', dict_macros); @@ -13468,13 +13584,13 @@ // expand macros in a regex; expands them recursively function expandMacros(src, macros, opts) { - var expansion_count = 0; + let expansion_count = 0; // By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! // Hence things should be easy in there: function expandAllMacrosInSet(s) { - var i, m, x; + let i, m, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { @@ -13482,7 +13598,7 @@ if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = m.in_set; @@ -13513,7 +13629,7 @@ } function expandAllMacrosElsewhere(s) { - var i, m, x; + let i, m, x; // When we process the main macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13529,7 +13645,7 @@ if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { // These are all main macro expansions, hence CAPTURING grouping is applied: x = m.elsewhere; @@ -13565,7 +13681,7 @@ // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! - var s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); + let s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); // propagate deferred exceptions = error reports. if (s2 instanceof Error) { throw s2; @@ -13590,8 +13706,8 @@ } function prepareStartConditions(conditions) { - var sc; - var hash = {}; + let sc; + let hash = {}; for (sc in conditions) { if (conditions.hasOwnProperty(sc)) { @@ -13605,22 +13721,22 @@ } function buildActions(dict, tokens, opts) { - var actions = [dict.actionInclude || '', 'var YYSTATE = YY_START;']; - var tok; - var toks = {}; - var caseHelper = []; + let actions = [ dict.actionInclude || '', 'var YYSTATE = YY_START;' ]; + let tok; + let toks = {}; + let caseHelper = []; // tokens: map/array of token numbers to token names for (tok in tokens) { - var idx = parseInt(tok); + let idx = parseInt(tok); if (idx && idx > 0) { toks[tokens[tok]] = idx; } } - var gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); + let gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); - var code = actions.join('\n'); + let code = actions.join('\n'); 'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function (yy) { code = code.replace(new RegExp('\\b(' + yy + ')\\b', 'g'), 'yy_.$1'); }); @@ -13638,7 +13754,7 @@ macros: gen.macros, // propagate these for debugging/diagnostic purposes regular_rule_count: gen.regular_rule_count, - simple_rule_count: gen.simple_rule_count, + simple_rule_count: gen.simple_rule_count }; } @@ -13649,7 +13765,7 @@ function generateErrorClass() { // --- START lexer error class --- - var prelude = `/** + const prelude = `/** * 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 @@ -13660,8 +13776,6 @@ * @nocollapse */ function JisonLexerError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -13678,9 +13792,9 @@ function JisonLexerError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -13741,8 +13855,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /** @constructor */ function RegExpLexer(dict, input, tokens, build_options) { - var opts; - var dump = false; + let opts; + let dump = false; function test_me(tweak_cb, description, src_exception, ex_callback) { opts = processGrammar(dict, tokens, build_options); @@ -13752,7 +13866,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (tweak_cb) { tweak_cb(); } - var source = generateModuleBody(opts); + let source = generateModuleBody(opts); try { // The generated code will always have the `lexer` variable declared at local scope // as `eval()` will use the local scope. @@ -13760,16 +13874,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // The compiled code will look something like this: // // ``` - // var lexer; + // let lexer; // bla bla... // ``` // // or // // ``` - // var lexer = { bla... }; + // const lexer = { bla... }; // ``` - var testcode = [ + let testcode = [ '// provide a local version for test purposes:', jisonLexerErrorDefinition, '', @@ -13777,14 +13891,33 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; '', source, '', + rmCommonWS$2` + // JISON INJECTED VALIDATION CODE + // which attempts to ascertain you have defined a minimal viable lexer at least: + if (typeof lexer === "undefined") { + throw new SyntaxError("user-defined lexer does not define the required 'lexer' instance."); + } + if (!lexer) { + throw new SyntaxError("user-defined lexer does not define a non-NULL 'lexer' instance."); + } + if (typeof lexer.setInput !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.setInput()' API function."); + } + if (typeof lexer.lex !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.lex()' API function."); + } + // END OF JISON INJECTED VALIDATION CODE + `, 'return lexer;' ].join('\n'); - var lexer = code_exec$1(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { + let lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { //console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$2(sourcecode); - var lexer_f = new Function('', sourcecode); + let lexer_f = new Function('', sourcecode); return lexer_f(); - }, opts.options, "lexer"); + }, Object.assign({}, opts.options, { + throwErrorOnCompileFailure: true + }), 'lexer'); if (!lexer) { throw new Error('no lexer defined *at all*?!'); @@ -13801,7 +13934,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // When we do NOT crash, we found/killed the problem area just before this call! if (src_exception && description) { - var msg = description; + let msg = description; if (typeof description === 'function') { msg = description(); } @@ -13810,8 +13943,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // patch the pre and post handlers in there, now that we have some live code to work with: if (opts.options) { - var pre = opts.options.pre_lex; - var post = opts.options.post_lex; + let pre = opts.options.pre_lex; + let post = opts.options.post_lex; // since JSON cannot encode functions, we'll have to do it manually now: if (typeof pre === 'function') { lexer.options.pre_lex = pre; @@ -13825,7 +13958,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (typeof opts.options.showSource === 'function') { opts.options.showSource(lexer, source, opts, RegExpLexer); } else { - console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n"); + console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n', source, '\n----------------------------------------\n'); } } return lexer; @@ -13844,13 +13977,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } /** @constructor */ - var lexer = test_me(null, null, null, function (ex) { + let lexer = test_me(null, null, null, function (ex) { // When we get an exception here, it means some part of the user-specified lexer is botched. // // Now we go and try to narrow down the problem area/category: assert__default['default'](opts.options); assert__default['default'](opts.options.xregexp !== undefined); - var orig_xregexp_opt = !!opts.options.xregexp; + let orig_xregexp_opt = !!opts.options.xregexp; if (!test_me(function () { assert__default['default'](opts.options.xregexp !== undefined); opts.options.xregexp = false; @@ -13869,7 +14002,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; 'Your custom lexer is somehow botched.' ); }, ex, null)) { - var rulesSpecSize; + let rulesSpecSize; if (!test_me(function () { // store the parsed rule set size so we can use that info in case // this attempt also fails: @@ -13882,7 +14015,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; opts.__in_rules_failure_analysis_mode__ = true; }, 'One or more of your lexer rules are possibly botched?', ex, null)) { // kill each rule action block, one at a time and test again after each 'edit': - var rv = false; + let rv = false; for (var i = 0, len = rulesSpecSize; i < len; i++) { var lastEditedRuleSpec; rv = test_me(function () { @@ -13894,10 +14027,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // opts.__in_rules_failure_analysis_mode__ = true; // nuke all rules' actions up to and including rule numero `i`: - for (var j = 0; j <= i; j++) { + for (let j = 0; j <= i; j++) { // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; // now we want to edit the *action* part: - var rule = opts.rules[j]; + let rule = opts.rules[j]; assert__default['default'](Array.isArray(rule)); assert__default['default'](rule.length === 2 || rule.length === 3); rule.pop(); @@ -14031,8 +14164,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -14042,14 +14173,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\\n\\s*$/.test(msg)) { msg += '\\n'; } msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') { msg += '\\n' + pos_str; @@ -14060,14 +14191,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the \`upcomingInput\` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -14087,9 +14218,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -14109,8 +14239,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -14131,16 +14259,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -14161,8 +14287,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -14170,8 +14294,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -14189,8 +14313,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -14200,14 +14322,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -14218,8 +14340,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -14227,40 +14347,40 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -14272,7 +14392,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -14280,7 +14400,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -14341,9 +14461,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -14362,8 +14480,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set \`done\` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -14372,7 +14488,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -14382,13 +14498,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\\n') { lines = true; } else if (ch === '\\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\\n') { slice_len++; ch += ch2; @@ -14420,10 +14536,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -14455,8 +14569,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Get last entirely matched line into the \`pre_lines[]\` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -14474,9 +14588,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -14486,14 +14600,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -14504,8 +14616,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -14518,19 +14628,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the \`parseError()\` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // \`.lex()\` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -14543,8 +14651,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -14567,24 +14673,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substr\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14596,8 +14702,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to \`maxSize\` (default: 20). @@ -14623,24 +14729,25 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > \`lookAhead()\` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substring\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -14649,7 +14756,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14668,10 +14775,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^'; }, @@ -14693,15 +14798,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -14832,58 +14935,54 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\\t/g, ' '); @@ -14892,13 +14991,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -14920,15 +15019,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -14940,8 +15037,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -14970,13 +15067,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -15005,10 +15096,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -15036,7 +15127,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -15047,7 +15138,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -15069,8 +15160,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -15079,17 +15168,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -15099,67 +15184,75 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that \`parseError()\` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) \`parseError()\` @@ -15186,9 +15279,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15231,24 +15322,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15268,9 +15359,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15280,24 +15369,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15305,7 +15394,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this._clear_state = 0; } - + return r; }, @@ -15318,9 +15407,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -15328,7 +15415,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -15343,8 +15430,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -15356,8 +15441,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -15371,15 +15454,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -15391,14 +15471,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -15409,16 +15486,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -15428,8 +15503,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; } }`; @@ -15461,18 +15534,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // ............................. ${opt.lexerActionsUseDisplayAPIs} // uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC} - var new_src; + let new_src; try { - var ast = helpers.parseCodeChunkToAST(src, opt); + let ast = helpers.parseCodeChunkToAST(src, opt); new_src = helpers.prettyPrintAST(ast, opt); - } - catch (ex) { + } catch (ex) { let line = ex.lineNumber || 0; let a = src.split(/\r?\n/g); let len = a.length; let minl = Math.max(0, line - 10); let b = a.slice(minl, line + 10); - let c = b.splice(line - minl, 0, "", "^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", ""); + let c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); let offendingChunk = ' ' + b.join('\n '); console.error(rmCommonWS$2` stripUnusedLexerCode WARNING: @@ -15488,17 +15560,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; ${offendingChunk} `); - + new_src = src; } - - - - - - // inject analysis report now: new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2` // Code Generator Information Report @@ -15553,7 +15619,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // generate lexer source from a grammar /** @public */ function generate(dict, tokens, build_options) { - var opt = processGrammar(dict, tokens, build_options); + let opt = processGrammar(dict, tokens, build_options); return generateFromOpts(opt); } @@ -15562,7 +15628,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /** @public */ function processGrammar(dict, tokens, build_options) { build_options = build_options || {}; - var opts = { + let opts = { // include the knowledge passed through `build_options` about which lexer // features will actually be *used* by the environment (which in 99.9% // of cases is a jison *parser*): @@ -15602,7 +15668,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; lexerActionsUseReject: '???', lexerActionsUseLess: '???', lexerActionsUseDisplayAPIs: '???', - lexerActionsUseDescribeYYLOC: '???', + lexerActionsUseDescribeYYLOC: '???' }; dict = autodetectAndConvertToJSONformat(dict, build_options) || {}; @@ -15627,7 +15693,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // only produce rule action code blocks when there are any rules at all; // a "custom lexer" has ZERO rules and must be defined entirely in // other code blocks: - var code = (dict.rules ? buildActions(dict, tokens, opts) : {}); + let code = (dict.rules ? buildActions(dict, tokens, opts) : {}); opts.performAction = code.actions; opts.caseHelperInclude = code.caseHelperInclude; opts.rules = code.rules || []; @@ -15636,7 +15702,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; opts.regular_rule_count = code.regular_rule_count; opts.simple_rule_count = code.simple_rule_count; - opts.conditionStack = ['INITIAL']; + opts.conditionStack = [ 'INITIAL' ]; opts.actionInclude = (dict.actionInclude || ''); opts.moduleInclude = (opts.moduleInclude || '') + (dict.moduleInclude || '').trim(); @@ -15647,7 +15713,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Assemble the final source from the processed grammar /** @public */ function generateFromOpts(opt) { - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -15670,12 +15736,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function generateRegexesInitTableCode(opt) { - var a = opt.rules; - var print_xregexp = opt.options && opt.options.xregexp; - var id_display_width = (1 + Math.log10(a.length | 1) | 0); - var ws_prefix = new Array(id_display_width).join(' '); - var b = a.map(function generateXRegExpInitCode(re, idx) { - var idx_str = (ws_prefix + idx).substr(-id_display_width); + let a = opt.rules; + let print_xregexp = opt.options && opt.options.xregexp; + let id_display_width = (1 + Math.log10(a.length | 1) | 0); + let ws_prefix = new Array(id_display_width).join(' '); + let b = a.map(function generateXRegExpInitCode(re, idx) { + let idx_str = (ws_prefix + idx).substr(-id_display_width); if (re instanceof XRegExp__default['default']) { // When we don't need the special XRegExp sauce at run-time, we do with the original @@ -15685,11 +15751,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // And make sure to escape the regex to make it suitable for placement inside a *string* // as it is passed as a string argument to the XRegExp constructor here. - var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); + let re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); return `/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`; - } else { - return `/* ${idx_str}: */ ${re}`; } + return `/* ${idx_str}: */ ${re}`; + }); return b.join(',\n'); } @@ -15697,77 +15763,77 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateModuleBody(opt) { // make the JSON output look more like JavaScript: function cleanupJSON(str) { - str = str.replace(/ "rules": \[/g, ' rules: ['); - str = str.replace(/ "inclusive": /g, ' inclusive: '); + str = str.replace(/ {2}"rules": \[/g, ' rules: ['); + str = str.replace(/ {2}"inclusive": /g, ' inclusive: '); return str; } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - json: 1, - _: 1, - noMain: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - lexerErrorsAreRecoverable: 0, - flex: 0, - backtrack_lexer: 0, - caseInsensitive: 0, - showSource: 1, - exportAST: 1, - exportAllTables: 1, - exportSourceCode: 1, - prettyCfg: 1, - parseActionsUseYYLENG: 1, - parseActionsUseYYLINENO: 1, - parseActionsUseYYTEXT: 1, - parseActionsUseYYLOC: 1, - parseActionsUseParseError: 1, - parseActionsUseYYERROR: 1, - parseActionsUseYYRECOVERING: 1, - parseActionsUseYYERROK: 1, - parseActionsUseYYCLEARIN: 1, - parseActionsUseValueTracking: 1, - parseActionsUseValueAssignment: 1, - parseActionsUseLocationTracking: 1, - parseActionsUseLocationAssignment: 1, - parseActionsUseYYSTACK: 1, - parseActionsUseYYSSTACK: 1, - parseActionsUseYYSTACKPOINTER: 1, - parseActionsUseYYRULELENGTH: 1, - parseActionsUseYYMERGELOCATIONINFO: 1, - parserHasErrorRecovery: 1, - parserHasErrorReporting: 1, - lexerActionsUseYYLENG: 1, - lexerActionsUseYYLINENO: 1, - lexerActionsUseYYTEXT: 1, - lexerActionsUseYYLOC: 1, - lexerActionsUseParseError: 1, - lexerActionsUseYYERROR: 1, - lexerActionsUseLocationTracking: 1, - lexerActionsUseMore: 1, - lexerActionsUseUnput: 1, - lexerActionsUseReject: 1, - lexerActionsUseLess: 1, - lexerActionsUseDisplayAPIs: 1, - lexerActionsUseDescribeYYLOC: 1, + let obj = {}; + const do_not_pass = { + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + json: 1, + _: 1, + noMain: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + lexerErrorsAreRecoverable: 0, + flex: 0, + backtrack_lexer: 0, + caseInsensitive: 0, + showSource: 1, + exportAST: 1, + exportAllTables: 1, + exportSourceCode: 1, + prettyCfg: 1, + parseActionsUseYYLENG: 1, + parseActionsUseYYLINENO: 1, + parseActionsUseYYTEXT: 1, + parseActionsUseYYLOC: 1, + parseActionsUseParseError: 1, + parseActionsUseYYERROR: 1, + parseActionsUseYYRECOVERING: 1, + parseActionsUseYYERROK: 1, + parseActionsUseYYCLEARIN: 1, + parseActionsUseValueTracking: 1, + parseActionsUseValueAssignment: 1, + parseActionsUseLocationTracking: 1, + parseActionsUseLocationAssignment: 1, + parseActionsUseYYSTACK: 1, + parseActionsUseYYSSTACK: 1, + parseActionsUseYYSTACKPOINTER: 1, + parseActionsUseYYRULELENGTH: 1, + parseActionsUseYYMERGELOCATIONINFO: 1, + parserHasErrorRecovery: 1, + parserHasErrorReporting: 1, + lexerActionsUseYYLENG: 1, + lexerActionsUseYYLINENO: 1, + lexerActionsUseYYTEXT: 1, + lexerActionsUseYYLOC: 1, + lexerActionsUseParseError: 1, + lexerActionsUseYYERROR: 1, + lexerActionsUseLocationTracking: 1, + lexerActionsUseMore: 1, + lexerActionsUseUnput: 1, + lexerActionsUseReject: 1, + lexerActionsUseLess: 1, + lexerActionsUseDisplayAPIs: 1, + lexerActionsUseDescribeYYLOC: 1 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -15778,8 +15844,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // And now some options which should receive some special processing: - var pre = obj.pre_lex; - var post = obj.post_lex; + let pre = obj.pre_lex; + let post = obj.post_lex; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_lex = true; @@ -15788,7 +15854,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; obj.post_lex = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$1})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_lex: true(,)?$/gm, function (m, ls, tc) { @@ -15801,17 +15867,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } - var out; + let out; if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) { // we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. - var code = [rmCommonWS$2` - var lexer = { - `, '/*JISON-LEX-ANALYTICS-REPORT*/' /* slot #1: placeholder for analysis report further below */ + let code = [ rmCommonWS$2` + const lexer = { + `, '/* JISON-LEX-ANALYTICS-REPORT */\n' /* slot #1: placeholder for analysis report further below */ ]; // get the RegExpLexer.prototype in source code form: - var protosrc = getRegExpLexerPrototype(); + let protosrc = getRegExpLexerPrototype(); // and strip off the surrounding bits we don't want: protosrc = protosrc .replace(/^[\s\r\n]*\{/, '') @@ -15838,10 +15904,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } */ - var performActionCode = String(opt.performAction); - var simpleCaseActionClustersCode = String(opt.caseHelperInclude); - var rulesCode = generateRegexesInitTableCode(opt); - var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); + let performActionCode = String(opt.performAction); + let simpleCaseActionClustersCode = String(opt.caseHelperInclude); + let rulesCode = generateRegexesInitTableCode(opt); + let conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); code.push(rmCommonWS$2`, JisonLexerError: JisonLexerError, performAction: ${performActionCode}, @@ -15861,9 +15927,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // - // Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter + // Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. - out = 'var lexer;\n'; + out = '\n'; assert__default['default'](opt.regular_rule_count === 0); assert__default['default'](opt.simple_rule_count === 0); @@ -15877,8 +15943,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // The output of this function is guaranteed to read something like this: // // ``` - // var lexer; - // // bla bla bla bla ... lotsa bla bla; // ``` // @@ -15887,7 +15951,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function generateGenericHeaderComment() { - var out = rmCommonWS$2` + let out = rmCommonWS$2` /* lexer generated by jison-lex ${version} */ /* @@ -16116,7 +16180,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else { @@ -16134,9 +16198,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -16159,9 +16223,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateAMDModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} define([], function () { @@ -16184,12 +16248,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateESModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} - var lexer = (function () { + const lexer = (function () { "use strict"; ${jisonLexerErrorDefinition} @@ -16218,9 +16282,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateCommonJSModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -16262,7 +16326,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // 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. function JisonParserError$1(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -16279,9 +16342,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -16314,10 +16377,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // helper: reconstruct the productions[] table function bp$1(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -16332,18 +16395,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // helper: reconstruct the 'goto' table function bt$1(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -16374,7 +16437,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // `this` references an array function s$1(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -16391,9 +16454,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$1(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -16406,7 +16469,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } - var parser$1 = { + let parser$1 = { // Code Generator Information Report // --------------------------------- // @@ -16532,7 +16595,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -16540,7 +16602,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -16552,8 +16613,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -16566,14 +16627,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -16589,10 +16649,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -16600,10 +16660,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -16647,9 +16707,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; @@ -16657,17 +16717,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 0: /*! Production:: $accept : production $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-) break; case 1: /*! Production:: production : handle EOF */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-) return yyvstack[yysp - 1]; @@ -16903,7 +16963,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; 19: 3 }, parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -16920,37 +16979,32 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } }, parse: function parse(input) { + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks + let vstack = new Array(128); // semantic value stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks - - + let symbol = 0; - var symbol = 0; + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -16958,20 +17012,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -16988,7 +17040,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -16996,18 +17047,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -17015,18 +17067,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -17048,7 +17096,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -17061,7 +17108,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -17075,11 +17121,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -17133,8 +17178,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -17283,8 +17328,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -17293,10 +17337,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; token_id: symbol, line: lexer.yylineno, - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -17304,7 +17348,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -17315,9 +17359,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -17343,8 +17392,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -17353,21 +17401,20 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -17377,21 +17424,20 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -17400,20 +17446,20 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; try { @@ -17426,7 +17472,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -17479,14 +17525,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - - // handle parse error + // handle parse error if (!action) { - var errStr; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let errStr; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); // Report error errStr = 'Parse error'; @@ -17523,9 +17566,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -17554,7 +17595,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -17596,21 +17637,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - r = this.performAction.call(yyval, newState, sp - 1, vstack); + r = this.performAction.call(yyval, newState, sp - 1, vstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -17641,14 +17680,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -17658,6 +17698,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; + } continue; // accept: @@ -17710,8 +17751,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -17971,7 +18011,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -17988,10 +18027,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -18023,7 +18062,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -18065,7 +18104,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // --------- END OF REPORT ----------- - EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -18151,7 +18192,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -18159,7 +18200,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -18172,7 +18213,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -18198,10 +18239,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -18224,7 +18268,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -18247,16 +18290,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -18278,7 +18321,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -18286,8 +18328,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -18316,7 +18358,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -18341,7 +18383,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -18353,17 +18395,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -18457,7 +18499,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -18478,7 +18520,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -18489,7 +18530,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -18500,15 +18541,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -18542,8 +18583,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -18576,9 +18617,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -18597,9 +18638,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -18609,8 +18650,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -18637,20 +18678,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -18690,17 +18730,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -18709,7 +18751,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -18724,8 +18766,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -18751,24 +18793,26 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -18779,7 +18823,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -18801,8 +18845,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -18824,8 +18868,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -18969,21 +19012,21 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -18998,11 +19041,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -19021,13 +19064,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -19051,13 +19094,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -19072,8 +19115,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -19104,7 +19147,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -19136,9 +19179,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -19167,7 +19210,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -19185,7 +19228,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -19210,7 +19253,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -19220,8 +19262,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -19230,7 +19270,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.clear(); } - 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. @@ -19242,13 +19282,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -19258,68 +19298,74 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -19344,7 +19390,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -19392,24 +19438,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -19429,7 +19475,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -19439,24 +19485,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -19477,8 +19523,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -19518,14 +19563,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -19541,9 +19586,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -19554,8 +19599,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -19563,7 +19608,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -19716,9 +19761,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // guaranteed not to collide with previously generated / already existing // rules (~ symbols). function generateUniqueSymbol(id, postfix, opts) { - var sym = id + postfix; + let sym = id + postfix; if (opts.grammar[sym]) { - var i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. + let i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. do { sym = id + postfix + i; i++; @@ -19728,8 +19773,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function generatePushAction(handle, offset) { - var terms = handle.terms; - var rv = []; + const terms = handle.terms; + let rv = []; for (var i = 0, len = terms.length; i < len; i++) { rv.push('$' + (i + offset)); @@ -19745,11 +19790,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function transformExpression(e, opts, emit) { - var type = e[0], - value = e[1], - name = false, - has_transformed = 0; - var list, n; + let type = e[0]; + let value = e[1]; + let name = false; + let has_transformed = 0; + let list, n; if (type === 'xalias') { type = e[1]; @@ -19776,7 +19821,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ list.fragment, @@ -19796,7 +19841,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ '', @@ -19816,7 +19861,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); // you want to be able to check if 0 or 1 occurrences were recognized: since jison // by default *copies* the lexer token value, i.e. `$$ = $1` is the (optional) default action, // we will need to set the action up explicitly in case of the 0-count match: @@ -19852,7 +19897,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; opts = optsForProduction(name, opts.grammar); opts.grammar[name] = value.map(function (handle) { - var list = transformExpressionList(handle, opts); + let list = transformExpressionList(handle, opts); return [ list.fragment, '$$ = ' + generatePushAction(list, 1) + ';' @@ -19865,11 +19910,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function transformExpressionList(list, opts) { - var first_transformed_term_index = false; - var terms = list.reduce(function (tot, e) { - var ci = tot.length; + let first_transformed_term_index = false; + let terms = list.reduce(function (tot, e) { + let ci = tot.length; - var has_transformed = transformExpression(e, opts, function (name) { + let has_transformed = transformExpression(e, opts, function (name) { if (name.terms) { tot.push.apply(tot, name.terms); } else { @@ -19898,42 +19943,42 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function transformProduction(id, production, grammar) { - var transform_opts = optsForProduction(id, grammar); + let transform_opts = optsForProduction(id, grammar); return production.map(function (handle) { - var action = null, - opts = null; - var i, len, n; + let action = null; + let opts = null; + let i, len, n; if (typeof handle !== 'string') { action = handle[1]; opts = handle[2]; handle = handle[0]; } - var expressions = handle; + let expressions = handle; if (typeof expressions === 'string') { expressions = parser$2.parse(handle); } - var list = transformExpressionList(expressions, transform_opts); + let list = transformExpressionList(expressions, transform_opts); - var ret = [list.fragment]; + let ret = [ list.fragment ]; if (action) { // make sure the action doesn't address any inner items. if (list.first_transformed_term_index) { // seek out all names and aliases; strip out literal tokens first as those cannot serve as $names: - var alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); + let alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); - var alias_re = new XRegExp__default['default'](`\\[${ID_REGEX_BASE$2}\\]`); - var term_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$2}$`); + let alias_re = new XRegExp__default['default'](`\\[${ID_REGEX_BASE$2}\\]`); + let term_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$2}$`); // and collect the PERMITTED aliases: the names of the terms and all the remaining aliases - var good_aliases = {}; - var alias_cnt = {}; - var donotalias = {}; + let good_aliases = {}; + let alias_cnt = {}; + let donotalias = {}; // WARNING: this replicates the knowledge/code of jison.js::addName() - var addName = function addNameEBNF(s, i) { - var base = s.replace(/[0-9]+$/, ''); - var dna = donotalias[base]; + let addName = function addNameEBNF(s, i) { + let base = s.replace(/[0-9]+$/, ''); + let dna = donotalias[base]; if (good_aliases[s]) { alias_cnt[s]++; @@ -19952,7 +19997,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; // WARNING: this replicates the knowledge/code of jison.js::markBasename() - var markBasename = function markBasenameEBNF(s) { + let markBasename = function markBasenameEBNF(s) { if (/[0-9]$/.test(s)) { s = s.replace(/[0-9]+$/, ''); donotalias[s] = true; @@ -19989,13 +20034,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now scan the action for all named and numeric semantic values ($nonterminal / $1 / @1, ##1, ...) // // Note that `#name` are straight **static** symbol translations, which are okay as they don't - // require access to the parse stack: `#n` references can be resolved completely + // require access to the parse stack: `#n` references can be resolved completely // at grammar compile time. // - var nameref_re = new XRegExp__default['default'](`(?:[$@]|##)${ID_REGEX_BASE$2}`, 'g'); - var named_spots = nameref_re.exec(action); - var numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); - var max_term_index = list.terms.length; + let nameref_re = new XRegExp__default['default'](`(?:[$@]|##)${ID_REGEX_BASE$2}`, 'g'); + let named_spots = nameref_re.exec(action); + let numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); + let max_term_index = list.terms.length; // loop through the XRegExp alias regex matches in `action` while (named_spots) { @@ -20025,7 +20070,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; for (i = 0, len = numbered_spots.length; i < len; i++) { n = parseInt(numbered_spots[i].replace(/^(?:[$@]|##)/, '')); if (n > max_term_index) { - /* @const */ var n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; + /* @const */ let n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; throw new Error('The action block references the ' + n + n_suffixes[Math.max(0, Math.min(3, n - 1))] + ' term, ' + 'which is not available in production "' + handle + '"; ' + 'Be reminded that you cannot reference sub-elements within EBNF */+/? groups, ' + @@ -20043,13 +20088,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (ret.length === 1) { return ret[0]; - } else { - return ret; } + return ret; + }); } - var ref_list; - var ref_names; + + let ref_list; + let ref_names; // create a deep copy of the input, so we will keep the input constant. function deepClone(from, sub) { @@ -20064,7 +20110,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return from; } - var idx = ref_list.indexOf(from); + let idx = ref_list.indexOf(from); if (idx >= 0) { throw new Error('[Circular/Xref:' + ref_names[i] + ']'); // circular or cross reference } @@ -20080,7 +20126,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; sub += '.'; var to = new from.constructor(); - for (var name in from) { + for (let name in from) { to[name] = deepClone(from[name], sub + name); } } @@ -20096,8 +20142,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return grammar; } + function transform(ebnf) { - var rv = transformGrammar(ebnf); + let rv = transformGrammar(ebnf); return rv; } @@ -20107,7 +20154,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // 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. function JisonParserError$2(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -20124,9 +20170,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -20159,10 +20205,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // helper: reconstruct the productions[] table function bp$2(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -20175,11 +20221,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // helper: reconstruct the defaultActions[] table function bda$1(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -20189,18 +20235,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // helper: reconstruct the 'goto' table function bt$2(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -20231,7 +20277,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // `this` references an array function s$2(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -20248,9 +20294,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$2(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -20263,7 +20309,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } - var parser$3 = { + let parser$3 = { // Code Generator Information Report // --------------------------------- // @@ -20499,7 +20545,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -20507,7 +20552,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -20519,8 +20563,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -20533,14 +20577,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -20556,10 +20599,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -20567,10 +20610,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -20751,26 +20794,26 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; switch (yystate) { case 0: /*! Production:: $accept : spec $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break; case 1: /*! Production:: spec : declaration_list "%%" grammar optional_end_block EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4]; @@ -20782,10 +20825,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 2: /*! Production:: spec : declaration_list "%%" grammar error EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -20804,10 +20847,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 3: /*! Production:: spec : declaration_list error EOF */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -20829,9 +20872,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 133: /*! Production:: optional_module_code_chunk : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -20840,9 +20883,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 5: /*! Production:: optional_end_block : "%%" extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20862,9 +20905,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 10: /*! Production:: declaration_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; @@ -20875,9 +20918,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 8: /*! Production:: optional_action_header_block : optional_action_header_block include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -20896,9 +20939,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 9: /*! Production:: declaration_list : declaration_list declaration */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20907,10 +20950,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 11: /*! Production:: declaration_list : declaration_list error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -20925,9 +20968,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 12: /*! Production:: declaration : START id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {start: yyvstack[yysp]}; @@ -20936,9 +20979,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 13: /*! Production:: declaration : LEX_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {lex: {text: yyvstack[yysp], position: yylstack[yysp]}}; @@ -20947,9 +20990,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 14: /*! Production:: declaration : operator */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {operator: yyvstack[yysp]}; @@ -20958,9 +21001,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 15: /*! Production:: declaration : TOKEN full_token_definitions */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {token_list: yyvstack[yysp]}; @@ -20969,9 +21012,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 16: /*! Production:: declaration : ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20989,9 +21032,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 17: /*! Production:: declaration : include_macro_code */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21009,9 +21052,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 18: /*! Production:: declaration : parse_params */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parseParams: yyvstack[yysp]}; @@ -21020,9 +21063,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 19: /*! Production:: declaration : parser_type */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parserType: yyvstack[yysp]}; @@ -21031,9 +21074,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 20: /*! Production:: declaration : options */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: yyvstack[yysp]}; @@ -21042,9 +21085,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 21: /*! Production:: declaration : DEBUG */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: [['debug', true]]}; @@ -21053,9 +21096,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 22: /*! Production:: declaration : EBNF */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) ebnf = true; @@ -21065,9 +21108,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 23: /*! Production:: declaration : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {unknownDecl: yyvstack[yysp]}; @@ -21076,9 +21119,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 24: /*! Production:: declaration : IMPORT import_name import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = {imports: {name: yyvstack[yysp - 1], path: yyvstack[yysp]}}; @@ -21087,10 +21130,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 25: /*! Production:: declaration : IMPORT import_name error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21106,10 +21149,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 26: /*! Production:: declaration : IMPORT error import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21125,9 +21168,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 27: /*! Production:: declaration : INIT_CODE init_code_name action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21150,10 +21193,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 28: /*! Production:: declaration : INIT_CODE error action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21169,10 +21212,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 29: /*! Production:: declaration : START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21187,10 +21230,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 30: /*! Production:: declaration : TOKEN error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21205,10 +21248,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 31: /*! Production:: declaration : IMPORT error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21273,9 +21316,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 132: /*! Production:: optional_module_code_chunk : module_code_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -21286,9 +21329,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 111: /*! Production:: action_ne : "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21297,10 +21340,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 40: /*! Production:: options : OPTIONS error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21315,10 +21358,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 41: /*! Production:: options : OPTIONS error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21337,9 +21380,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 70: /*! Production:: id_list : id_list id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21354,9 +21397,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 84: /*! Production:: handle_list : handle_action */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -21365,9 +21408,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 44: /*! Production:: option : NAME */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -21376,9 +21419,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 45: /*! Production:: option : NAME "=" OPTION_STRING_VALUE */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -21389,9 +21432,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 47: /*! Production:: option : NAME "=" NAME */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], parseValue$1(yyvstack[yysp])]; @@ -21400,10 +21443,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 48: /*! Production:: option : NAME "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21418,10 +21461,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 49: /*! Production:: option : NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21438,9 +21481,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 52: /*! Production:: parser_type : PARSER_TYPE symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -21449,10 +21492,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 51: /*! Production:: parse_params : PARSE_PARAM error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21470,10 +21513,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 53: /*! Production:: parser_type : PARSER_TYPE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21491,9 +21534,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 54: /*! Production:: operator : associativity token_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1]]; this.$.push.apply(this.$, yyvstack[yysp]); @@ -21502,10 +21545,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 55: /*! Production:: operator : associativity error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21523,9 +21566,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 56: /*! Production:: associativity : LEFT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'left'; @@ -21534,9 +21577,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 57: /*! Production:: associativity : RIGHT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'right'; @@ -21545,9 +21588,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 58: /*! Production:: associativity : NONASSOC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'nonassoc'; @@ -21556,9 +21599,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 61: /*! Production:: full_token_definitions : optional_token_type id_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var rv = []; @@ -21577,9 +21620,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 62: /*! Production:: full_token_definitions : optional_token_type one_full_token */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var m = yyvstack[yysp]; @@ -21592,9 +21635,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 63: /*! Production:: one_full_token : id token_value token_description */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21607,9 +21650,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 64: /*! Production:: one_full_token : id token_description */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21621,9 +21664,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 65: /*! Production:: one_full_token : id token_value */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21635,9 +21678,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 66: /*! Production:: optional_token_type : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = false; @@ -21646,9 +21689,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 72: /*! Production:: grammar : optional_action_header_block production_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21658,9 +21701,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 73: /*! Production:: production_list : production_list production */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21674,9 +21717,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 74: /*! Production:: production_list : production */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; this.$[yyvstack[yysp][0]] = yyvstack[yysp][1]; @@ -21685,9 +21728,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 75: /*! Production:: production : production_id handle_list ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp - 1]]; @@ -21696,10 +21739,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 76: /*! Production:: production : production_id error ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21717,10 +21760,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 77: /*! Production:: production : production_id error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21738,9 +21781,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 78: /*! Production:: production_id : id optional_production_description ":" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21751,10 +21794,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 79: /*! Production:: production_id : id optional_production_description error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21772,10 +21815,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 80: /*! Production:: production_id : id optional_production_description ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21799,18 +21842,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 82: /*! Production:: optional_production_description : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) break; case 83: /*! Production:: handle_list : handle_list "|" handle_action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21820,10 +21863,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 85: /*! Production:: handle_list : handle_list "|" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21841,10 +21884,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 86: /*! Production:: handle_list : handle_list ":" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21859,9 +21902,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 87: /*! Production:: handle_action : handle prec action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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(' ') : '')]; @@ -21896,9 +21939,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 88: /*! Production:: handle_action : EPSILON action */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = ['']; @@ -21922,10 +21965,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 89: /*! Production:: handle_action : EPSILON error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21940,9 +21983,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 90: /*! Production:: handle : handle suffixed_expression */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21952,9 +21995,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 91: /*! Production:: handle : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -21963,9 +22006,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 92: /*! Production:: handle_sublist : handle_sublist "|" handle */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21975,9 +22018,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 93: /*! Production:: handle_sublist : handle */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp].join(' ')]; @@ -21986,9 +22029,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 94: /*! Production:: suffixed_expression : expression suffix ALIAS */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + "[" + yyvstack[yysp] + "]"; @@ -22001,9 +22044,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 130: /*! Production:: module_code_chunk : module_code_chunk CODE */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22012,9 +22055,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 97: /*! Production:: expression : EOF_ID */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$end'; @@ -22023,9 +22066,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 98: /*! Production:: expression : STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // Re-encode the string *anyway* as it will @@ -22038,9 +22081,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 99: /*! Production:: expression : "(" handle_sublist ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1].join(' | ') + ')'; @@ -22049,10 +22092,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 100: /*! Production:: expression : "(" handle_sublist error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22066,9 +22109,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 105: /*! Production:: prec : PREC symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { prec: yyvstack[yysp] }; @@ -22077,10 +22120,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 106: /*! Production:: prec : PREC error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -22098,9 +22141,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 107: /*! Production:: prec : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = null; @@ -22109,10 +22152,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 112: /*! Production:: action_ne : "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22126,9 +22169,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 116: /*! Production:: action : ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$$ = (' + yyvstack[yysp] + ');'; @@ -22137,9 +22180,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 120: /*! Production:: action_body : action_body "{" action_body "}" action_comments_body */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4] + yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22148,9 +22191,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 121: /*! Production:: action_body : action_body "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22159,10 +22202,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 122: /*! Production:: action_body : action_body "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22176,9 +22219,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 126: /*! Production:: extra_parser_module_code : optional_module_code_chunk include_macro_code extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22187,9 +22230,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 127: /*! Production:: include_macro_code : INCLUDE PATH */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' }); @@ -22209,10 +22252,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 128: /*! Production:: include_macro_code : INCLUDE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22225,10 +22268,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 131: /*! Production:: module_code_chunk : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -23621,7 +23664,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -23638,38 +23680,34 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -23677,20 +23715,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -23712,7 +23748,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -23720,18 +23755,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -23739,24 +23775,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -23794,18 +23825,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); + let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -23826,7 +23854,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -23844,7 +23872,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -23857,7 +23884,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -23871,11 +23897,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -23929,8 +23954,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -23938,8 +23963,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -23971,19 +23996,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -23994,7 +24018,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -24007,7 +24031,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -24019,29 +24043,27 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -24049,7 +24071,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -24069,8 +24091,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -24079,10 +24100,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -24090,7 +24111,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -24101,9 +24122,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -24119,8 +24145,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -24189,11 +24214,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -24204,8 +24232,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -24214,21 +24241,20 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -24238,21 +24264,20 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -24261,28 +24286,27 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -24295,8 +24319,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; + const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -24319,8 +24342,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - if (symbol === EOF) { + if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -24332,8 +24354,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - --stack_probe; // popStack(1): [symbol, action] + --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -24350,8 +24371,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -24365,8 +24385,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } @@ -24380,7 +24399,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -24433,16 +24452,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - - // handle parse error + // handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -24476,9 +24492,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - r = this.parseError(p.errStr, p, this.JisonParserError); + r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -24501,9 +24515,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -24530,17 +24542,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - } + } // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -24587,8 +24598,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -24600,8 +24611,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - } else { + } else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -24619,6 +24629,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -24627,7 +24638,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -24638,7 +24649,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -24698,10 +24709,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -24736,9 +24747,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - // encountered another parse error? If so, break out to main loop + // encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -24751,7 +24760,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -24772,9 +24781,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -24796,12 +24803,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -24810,7 +24817,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -24851,7 +24858,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -24898,7 +24905,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -24916,21 +24923,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -24964,14 +24969,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -24981,6 +24987,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; + } continue; // accept: @@ -25032,7 +25039,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -25048,9 +25055,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -25079,7 +25084,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -25096,8 +25101,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -25108,8 +25113,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -25121,21 +25126,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -25166,14 +25169,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -25183,6 +25187,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; + } continue; // accept: @@ -25235,8 +25240,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -25497,7 +25501,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -25514,10 +25517,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -25549,7 +25552,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -25591,7 +25594,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // --------- END OF REPORT ----------- - EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -25677,7 +25682,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -25685,7 +25690,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -25698,7 +25703,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -25724,10 +25729,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -25750,7 +25758,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -25773,16 +25780,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -25804,7 +25811,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -25812,8 +25818,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -25842,7 +25848,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -25867,7 +25873,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -25879,17 +25885,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -25983,7 +25989,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -26004,7 +26010,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -26015,7 +26020,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -26026,15 +26031,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -26068,8 +26073,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -26102,9 +26107,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -26123,9 +26128,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -26135,8 +26140,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -26163,20 +26168,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -26216,17 +26220,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -26235,7 +26241,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -26250,8 +26256,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -26277,24 +26283,26 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -26305,7 +26313,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -26327,8 +26335,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -26350,8 +26358,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -26495,21 +26502,21 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -26524,11 +26531,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -26547,13 +26554,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -26577,13 +26584,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -26598,8 +26605,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -26630,7 +26637,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -26662,9 +26669,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -26693,7 +26700,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -26711,7 +26718,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -26736,7 +26743,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -26746,8 +26752,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -26756,7 +26760,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.clear(); } - 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. @@ -26768,13 +26772,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -26784,68 +26788,74 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -26870,7 +26880,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -26918,24 +26928,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -26955,7 +26965,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -26965,24 +26975,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -27003,8 +27013,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -27044,14 +27053,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -27067,9 +27076,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -27080,8 +27089,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -27089,7 +27098,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -28134,7 +28143,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; - var version$1 = '0.6.2-220'; // require('./package.json').version; + const version$1 = '0.6.2-220'; // require('./package.json').version; function parse(grammar) { return bnf.parser.parse(grammar); @@ -28200,7 +28209,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (decl.options) { if (!grammar.options) grammar.options = {}; // last occurrence of `%options` wins: - for (var i = 0; i < decl.options.length; i++) { + for (let i = 0; i < decl.options.length; i++) { grammar.options[decl.options[i][0]] = decl.options[i][1]; } } @@ -28240,9 +28249,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // which matches the original input file: position = position || {}; position.range = position.range || []; - var l = position.first_line | 0; - var c = position.range[0] | 0; - var prelude = ''; + let l = position.first_line | 0; + let c = position.range[0] | 0; + let prelude = ''; if (l > 1) { prelude += (new Array(l)).join('\n'); c -= prelude.length; @@ -28267,10 +28276,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; ebnf_parser, bnf_lexer: lexParser, - version: version$1, + version: version$1 }; - var rmCommonWS$4 = helpers.rmCommonWS; + const rmCommonWS$4 = helpers.rmCommonWS; /** @@ -28296,14 +28305,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 'json5': options.format = 'json5'; break; - + case '.y': case '.yacc': options.format = 'jison'; options.showLexer = false; options.showParser = true; break; - + case '.l': case '.lex': options.format = 'jison'; @@ -28325,20 +28334,20 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // which MAY get corrupted that way as their actual content would change then! // construct fake nesting levels to arrive at the intended start indent value: `num` - var nesting_levels = num / 2; - var pre = '// **PRE**', - post = '// **POST**'; - for ( ; nesting_levels > 0; nesting_levels--) { + let nesting_levels = num / 2; + let pre = '// **PRE**'; + let post = '// **POST**'; + for (; nesting_levels > 0; nesting_levels--) { pre = 'function x() {\n' + pre; post += '\n}'; } - src = '\n' + pre + '\n' + src + '\n' + post + '\n'; + src = '\n' + pre + '\n' + src + '\n' + post + '\n'; - var ast = helpers.parseCodeChunkToAST(src, options); - var new_src = helpers.prettyPrintAST(ast, options); + let ast = helpers.parseCodeChunkToAST(src, options); + let new_src = helpers.prettyPrintAST(ast, options); - var start = new_src.indexOf('// **PRE**'); - var end = new_src.lastIndexOf('// **POST**'); + let start = new_src.indexOf('// **PRE**'); + let end = new_src.lastIndexOf('// **POST**'); new_src = new_src .substring(start + 10, end) .trim(); @@ -28347,13 +28356,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function isEmptyObj(obj) { - var keys = obj && typeof obj === 'object' && Object.keys(obj); + let keys = obj && typeof obj === 'object' && Object.keys(obj); return keys && keys.length === 0; } function isEmptyArr(arr) { if (arr && arr instanceof Array) { - for (var i = 0, len = arr.length; i < len; i++) { + for (let i = 0, len = arr.length; i < len; i++) { if (arr[i] !== undefined) { return false; } @@ -28366,8 +28375,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Copied from Crokford's implementation of JSON // See https://github.com/douglascrockford/JSON-js/blob/e39db4b7e6249f04a195e7dd0840e610cc9e941e/json2.js#L195 // Begin - var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - meta = { // table of character substitutions + let escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; + let meta = { // table of character substitutions '\b': '\\b', '\t': '\\t', '\n': '\\n', @@ -28384,15 +28393,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // sequences. escapable.lastIndex = 0; return escapable.test(string) ? '"' + string.replace(escapable, function (a) { - var c = meta[a]; + let c = meta[a]; return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }) + '"' : '"' + string + '"'; } - var ref_list; - var ref_names; + let ref_list; + let ref_names; // create a deep copy of the input, so we can delete the parts we converted and dump the remainder // so that we always output the entire thing, even when we don't know all the details about the @@ -28409,7 +28418,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return from; } - for (var i = 0, len = ref_list.length; i < len; i++) { + for (let i = 0, len = ref_list.length; i < len; i++) { if (ref_list[i] === from) { return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference } @@ -28418,204 +28427,211 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; ref_names.push(sub); sub += '.'; - var to = new from.constructor(); - for (var name in from) { + let to = new from.constructor(); + for (let name in from) { to[name] = deepClone(from[name], sub + name); } return to; } - var originalInput = raw; + let originalInput = raw; raw = deepClone(raw); - var lex_out_str = ''; + let lex_out_str = ''; if (raw.lex) { var lex_pre = []; - var lex_rules = []; - var lex_post = []; - var key, src; + let lex_rules = []; + let lex_post = []; + + { + let src = raw.lex.macros; + delete raw.lex.macros; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // macros: + `); - src = raw.lex.macros; - delete raw.lex.macros; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // macros: - `); + let keylen = 0; + for (let key in src) { + keylen = Math.max(keylen, key.length); + } + console.log('macros keylen:', keylen); + keylen = ((keylen / 4) | 0) * 4 + 4; + console.log('macros keylen B:', keylen); + for (let key in src) { + lex_pre.push(padRight(key, keylen) + src[key]); + } - var keylen = 0; - for (key in src) { - keylen = Math.max(keylen, key.length); - } - console.log('macros keylen:', keylen); - keylen = ((keylen / 4) | 0) * 4 + 4; - console.log('macros keylen B:', keylen); - for (key in src) { - lex_pre.push(padRight(key, keylen) + src[key]); + lex_pre.push(rmCommonWS$4` + // END of the lexer macros. + `); } - - lex_pre.push(rmCommonWS$4` - // END of the lexer macros. - `); } - src = raw.lex.unknownDecls; - delete raw.lex.unknownDecls; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // unknown declarations: - `); + { + let src = raw.lex.unknownDecls; + delete raw.lex.unknownDecls; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // unknown declarations: + `); - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry.name; + let value = entry.value; - lex_pre.push('%' + key + ' ' + value); - } + lex_pre.push('%' + key + ' ' + value); + } - lex_pre.push(rmCommonWS$4` - // END of unknown declarations. - `); + lex_pre.push(rmCommonWS$4` + // END of unknown declarations. + `); + } } - src = raw.lex.options; - delete raw.lex.options; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // options: - `); + { + let src = raw.lex.options; + delete raw.lex.options; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // options: + `); - for (key in src) { - var value = src[key]; - if (value) { - lex_pre.push('%options ' + key + '=' + value); - } - else { - lex_pre.push('%options ' + key); + for (let key in src) { + let value = src[key]; + if (value) { + lex_pre.push('%options ' + key + '=' + value); + } else { + lex_pre.push('%options ' + key); + } } } } - src = raw.lex.startConditions; - delete raw.lex.startConditions; - if (src && !isEmptyObj(src)) { - for (key in src) { - var value = src[key]; + { + let src = raw.lex.startConditions; + delete raw.lex.startConditions; + if (src && !isEmptyObj(src)) { + for (let key in src) { + let value = src[key]; - lex_pre.push((value ? '%x ' : '%s ') + key); + lex_pre.push((value ? '%x ' : '%s ') + key); + } } } - src = raw.lex.actionInclude; - delete raw.lex.actionInclude; - if (src && src.trim()) { - lex_pre.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + { + let src = raw.lex.actionInclude; + delete raw.lex.actionInclude; + if (src && src.trim()) { + lex_pre.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + } } - src = raw.lex.rules; - delete raw.lex.rules; - if (src) { - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - key = entry[0]; - var action = indentAction(entry[1], 4); - - var actionHasLF = /[\r\n]/.test(action); - console.log('indented action:', { - entry: entry[1], - action, - actionHasLF - }); - if (key.length <= 12) { - if (!actionHasLF) { - lex_rules.push(padRight(key, 16) + indentAction(action, 16)); - } - else { - lex_rules.push(padRight(key, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); - } - } - else { - if (!actionHasLF) { + { + let src = raw.lex.rules; + delete raw.lex.rules; + if (src) { + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry[0]; + let action = indentAction(entry[1], 4); + + let actionHasLF = /[\r\n]/.test(action); + console.log('indented action:', { + entry: entry[1], + action, + actionHasLF + }); + if (key.length <= 12) { + if (!actionHasLF) { + lex_rules.push(padRight(key, 16) + indentAction(action, 16)); + } else { + lex_rules.push(padRight(key, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + } + } else if (!actionHasLF) { lex_rules.push(key, makeIndent(16) + indentAction(action, 16)); - } - else { + } else { lex_rules.push(key, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } } } - src = raw.lex.moduleInclude; - delete raw.lex.moduleInclude; - if (src && src.trim()) { - lex_post.push(indentAction(src.trim(), 0)); + { + let src = raw.lex.moduleInclude; + delete raw.lex.moduleInclude; + if (src && src.trim()) { + lex_post.push(indentAction(src.trim(), 0)); + } } - var out = ''; + { + let out = ''; - if (!isEmptyObj(raw.lex)) { - // dump the remainder as a comment: - var rem = JSON5__default['default'].stringify(raw.lex, null, 2); - out += rmCommonWS$4` - /* - * Lexer stuff that's unknown to the JISON prettyPrint service: - * - * ${rem.replace(/\*\//g, '*\\/')} - */ + if (!isEmptyObj(raw.lex)) { + // dump the remainder as a comment: + let rem = JSON5__default['default'].stringify(raw.lex, null, 2); + out += rmCommonWS$4` + /* + * Lexer stuff that's unknown to the JISON prettyPrint service: + * + * ${rem.replace(/\*\//g, '*\\/')} + */ - `; - } - delete raw.lex; - - out += lex_pre.join('\n') + '\n\n'; - out += rmCommonWS$4` - - %% + `; + } + delete raw.lex; - ` + lex_rules.join('\n') + '\n\n'; - if (lex_post.length > 0) { + out += lex_pre.join('\n') + '\n\n'; out += rmCommonWS$4` %% - ` + lex_post.join('\n') + '\n\n'; + ` + lex_rules.join('\n') + '\n\n'; + if (lex_post.length > 0) { + out += rmCommonWS$4` + + %% + + ` + lex_post.join('\n') + '\n\n'; + } + lex_out_str = out; } - lex_out_str = out; } - var grammar_pre = []; - var grammar_mid = []; - var ebnf_rules = []; - var bnf_rules = []; - var grammar_post = []; - var key, src; + let grammar_pre = []; + let grammar_mid = []; + let ebnf_rules = []; + let bnf_rules = []; + let grammar_post = []; - var fmtprod = function fmtprod(rule, prodset) { - var backup = deepClone(prodset); + let fmtprod = function fmtprod(rule, prodset) { + let backup = deepClone(prodset); rule += prodset[0] ? prodset[0] : '%epsilon'; - var prec = null; - var lead = rule.split(/\r\n\|\n|\r/).pop(); + let prec = null; + let lead = rule.split(/\r\n\|\n|\r/).pop(); delete prodset[0]; if (prodset.length === 3 && typeof prodset[2] === 'object') { prec = '%prec ' + prodset[2].prec; if (lead.length < 12) { rule += makeIndent(12 - lead.length); - } + } rule += ' ' + prec; delete prodset[2].prec; if (isEmptyObj(prodset[2])) { delete prodset[2]; } - } - else if (prodset.length === 2 && typeof prodset[1] === 'object') { + } else if (prodset.length === 2 && typeof prodset[1] === 'object') { prec = '%prec ' + prodset[1].prec; if (lead.length < 12) { rule += makeIndent(12 - lead.length); - } + } rule += ' ' + prec; delete prodset[1].prec; @@ -28624,84 +28640,73 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } if (typeof prodset[1] === 'string') { - var action = prodset[1]; + let action = prodset[1]; if (lead.length < 12 - 1) { - rule += makeIndent(12 - lead.length) + indentAction('{ ' + action + ' }', 12); - } - else { - rule += '\n' + makeIndent(12) + indentAction('{ ' + action + ' }', 12); + rule += makeIndent(12 - lead.length) + indentAction('{ ' + action + ' }', 12); + } else { + rule += '\n' + makeIndent(12) + indentAction('{ ' + action + ' }', 12); } delete prodset[1]; } if (isEmptyArr(prodset)) { prodset.length = 0; - } - else { + } else { prodset = backup; } return rule; }; - var grammarfmt = function grammarfmt(src) { - var key; - var dst = []; + let grammarfmt = function grammarfmt(src) { + let dst = []; - for (key in src) { - var prodset = src[key]; - var rule; + for (let key in src) { + let prodset = src[key]; + let rule; console.log('format one rule:', { - key, + key, prodset }); if (typeof prodset === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; + rule = fmtprod(key + ' : ', [ prodset ]) + ';'; delete src[key]; - } - else if (prodset instanceof Array) { + } else if (prodset instanceof Array) { if (prodset.length === 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; + rule = fmtprod(key + ' : ', [ prodset ]) + ';'; delete src[key]; - } - else if (prodset[0] instanceof Array) { + } else if (prodset[0] instanceof Array) { rule = fmtprod(key + ' : ', prodset[0]); rule += '\n ;'; if (prodset[0].length === 0) { delete src[key]; } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - } - else if (prodset.length > 1) { + } else if (prodset.length > 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + '\n : ', [prodset[0]]); + rule = fmtprod(key + '\n : ', [ prodset[0] ]); delete prodset[0]; - } - else if (prodset[0] instanceof Array) { + } else if (prodset[0] instanceof Array) { rule = fmtprod(key + '\n : ', prodset[0]); if (prodset[0].length === 0) { delete prodset[0]; } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - for (var i = 1, len = prodset.length; i < len; i++) { + for (let i = 1, len = prodset.length; i < len; i++) { if (typeof prodset[i] === 'string') { - rule += fmtprod('\n | ', [prodset[i]]); + rule += fmtprod('\n | ', [ prodset[i] ]); delete prodset[i]; - } - else if (prodset[i] instanceof Array) { + } else if (prodset[i] instanceof Array) { rule += fmtprod('\n | ', prodset[i]); if (prodset[i].length === 0) { delete prodset[i]; } - } - else { + } else { rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[i]; } } @@ -28711,8 +28716,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; delete src[key]; } } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; } dst.push(rule); @@ -28721,46 +28725,52 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return dst; }; - src = raw.ebnf; - if (src) { - ebnf_rules = grammarfmt(src); + { + let src = raw.ebnf; + if (src) { + ebnf_rules = grammarfmt(src); - if (isEmptyObj(src)) { - delete raw.ebnf; + if (isEmptyObj(src)) { + delete raw.ebnf; + } } } - src = raw.bnf; - //delete raw.bnf; - if (src) { - bnf_rules = grammarfmt(src); + { + let src = raw.bnf; + //delete raw.bnf; + if (src) { + bnf_rules = grammarfmt(src); - if (isEmptyObj(src)) { - delete raw.bnf; + if (isEmptyObj(src)) { + delete raw.bnf; + } } } - src = raw.unknownDecls; - delete raw.unknownDecls; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // unknown declarations: - `); + { + let src = raw.unknownDecls; + delete raw.unknownDecls; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // unknown declarations: + `); - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry.name; + let value = entry.value; - lex_pre.push('%' + key + ' ' + value); - } + lex_pre.push('%' + key + ' ' + value); + } - lex_pre.push(rmCommonWS$4` - // END of unknown declarations. - `); + lex_pre.push(rmCommonWS$4` + // END of unknown declarations. + `); + } } - //src = raw.lex; + //let src = raw.lex; //delete raw.lex; //if (src) { if (lex_out_str.trim() && options.showLexer) { @@ -28778,294 +28788,305 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; `); } - src = raw.options; - delete raw.options; - if (src && !isEmptyObj(src)) { - var a = []; - for (key in src) { - var value = src[key]; - switch (key) { - default: - if (value !== true) { - a.push('options', '%options ' + key + '=' + value); - } - else { - a.push('options', '%options ' + key); - } - break; + { + let src = raw.options; + delete raw.options; + if (src && !isEmptyObj(src)) { + let a = []; + for (let key in src) { + let value = src[key]; + switch (key) { + default: + if (value !== true) { + a.push('options', '%options ' + key + '=' + value); + } else { + a.push('options', '%options ' + key); + } + break; - case 'ebnf': - if (value) { - a.push(key, '%ebnf'); - } - break; + case 'ebnf': + if (value) { + a.push(key, '%ebnf'); + } + break; - case 'type': - if (value) { - a.push(key, '%parser-type ' + value); - } - break; + case 'type': + if (value) { + a.push(key, '%parser-type ' + value); + } + break; - case 'debug': - if (typeof value !== 'boolean') { - a.push(key, '%debug ' + value); - } - else if (value) { - a.push(key, '%debug'); + case 'debug': + if (typeof value !== 'boolean') { + a.push(key, '%debug ' + value); + } else if (value) { + a.push(key, '%debug'); + } + break; } - break; } - } - var type = null; - for (var i = 0, len = a.length; i < len; i += 2) { - var t = a[i]; - var line = a[i + 1]; - if (t !== type) { - type = t; - grammar_pre.push(''); + let type = null; + for (let i = 0, len = a.length; i < len; i += 2) { + let t = a[i]; + let line = a[i + 1]; + if (t !== type) { + type = t; + grammar_pre.push(''); + } + grammar_pre.push(line); } - grammar_pre.push(line); + grammar_pre.push(''); } - grammar_pre.push(''); } - src = raw.imports; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - - grammar_pre.push('%import ' + entry.name + ' ' + entry.path); - delete entry.name; - delete entry.path; - if (isEmptyObj(entry)) { - delete src[i]; + { + let src = raw.imports; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + + grammar_pre.push('%import ' + entry.name + ' ' + entry.path); + delete entry.name; + delete entry.path; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } + } + if (clean) { + delete raw.imports; } - else { - clean = false; - } - } - if (clean) { - delete raw.imports; } } - src = raw.moduleInit; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - - grammar_pre.push('%code ' + entry.qualifier + ' ' + entry.include); - delete entry.qualifier; - delete entry.include; - if (isEmptyObj(entry)) { - delete src[i]; + { + let src = raw.moduleInit; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + + grammar_pre.push('%code ' + entry.qualifier + ' ' + entry.include); + delete entry.qualifier; + delete entry.include; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } + } + if (clean) { + delete raw.moduleInit; } - else { - clean = false; - } - } - if (clean) { - delete raw.moduleInit; } } - src = raw.operators; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var tokens = entry[1]; - var line = '%' + entry[0] + ' '; - - for (var t = 0, tlen = tokens.length; t < tlen; t++) { - line += ' ' + tokens[t]; - } + { + let src = raw.operators; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let tokens = entry[1]; + let line = '%' + entry[0] + ' '; + + for (let t = 0, tlen = tokens.length; t < tlen; t++) { + line += ' ' + tokens[t]; + } - grammar_pre.push(line); + grammar_pre.push(line); - if (entry.length === 2) { - delete src[i]; + if (entry.length === 2) { + delete src[i]; + } else { + clean = false; + } } - else { - clean = false; + if (clean) { + delete raw.operators; } } - if (clean) { - delete raw.operators; - } } - src = raw.extra_tokens; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var line = '%token ' + entry.id; - - if (entry.type) { - line += ' <' + entry.type + '>'; - delete entry.type; - } - if (entry.value) { - line += ' ' + entry.value; - delete entry.value; - } - if (entry.description) { - line += ' ' + escapeString(entry.description); - delete entry.description; - } + { + let src = raw.extra_tokens; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let line = '%token ' + entry.id; + + if (entry.type) { + line += ' <' + entry.type + '>'; + delete entry.type; + } + if (entry.value) { + line += ' ' + entry.value; + delete entry.value; + } + if (entry.description) { + line += ' ' + escapeString(entry.description); + delete entry.description; + } - grammar_pre.push(line); + grammar_pre.push(line); - delete entry.id; - if (isEmptyObj(entry)) { - delete src[i]; + delete entry.id; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } } - else { - clean = false; + if (clean) { + delete raw.extra_tokens; } } - if (clean) { - delete raw.extra_tokens; - } } - src = raw.parseParams; - delete raw.parseParams; - if (src) { - grammar_pre.push('%parse-param ' + src.join(' ')); + { + let src = raw.parseParams; + delete raw.parseParams; + if (src) { + grammar_pre.push('%parse-param ' + src.join(' ')); + } } - src = raw.start; - delete raw.start; - if (src) { - grammar_pre.push('%start ' + src); + { + let src = raw.start; + delete raw.start; + if (src) { + grammar_pre.push('%start ' + src); + } } - src = raw.moduleInclude; - delete raw.moduleInclude; - if (src && src.trim()) { - grammar_post.push(indentAction(src.trim(), 0)); + { + let src = raw.moduleInclude; + delete raw.moduleInclude; + if (src && src.trim()) { + grammar_post.push(indentAction(src.trim(), 0)); + } } - src = raw.actionInclude; - delete raw.actionInclude; - if (src && src.trim()) { - grammar_mid.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + { + let src = raw.actionInclude; + delete raw.actionInclude; + if (src && src.trim()) { + grammar_mid.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + } } - var out = ''; + { + let out = ''; - if (!isEmptyObj(raw)) { - // dump the remainder as a comment: - var rem = JSON5__default['default'].stringify(raw, null, 2); - out += rmCommonWS$4` - /* - * Parser stuff that's unknown to the JISON prettyPrint service: - * - * ${rem.replace(/\*\//g, '*\\/')} - */ + if (!isEmptyObj(raw)) { + // dump the remainder as a comment: + let rem = JSON5__default['default'].stringify(raw, null, 2); + out += rmCommonWS$4` + /* + * Parser stuff that's unknown to the JISON prettyPrint service: + * + * ${rem.replace(/\*\//g, '*\\/')} + */ - `; - // delete raw; - } + `; + // delete raw; + } - if (!options.showParser) { - out += lex_out_str; - } - else { - out += grammar_pre.join('\n') + '\n\n'; - out += rmCommonWS$4` + if (!options.showParser) { + out += lex_out_str; + } else { + out += grammar_pre.join('\n') + '\n\n'; + out += rmCommonWS$4` - %% + %% - `; - if (grammar_mid.length > 0) { - out += grammar_mid.join('\n') + '\n\n'; - } - if (ebnf_rules.length > 0) { - if (bnf_rules.length > 0) { + `; + if (grammar_mid.length > 0) { + out += grammar_mid.join('\n') + '\n\n'; + } + if (ebnf_rules.length > 0) { + if (bnf_rules.length > 0) { // dump the original EBNF grammar as source and dump the BNF derivative as COMMENT: - var bnf_deriv = bnf_rules.join('\n\n'); - var a = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); + let bnf_deriv = bnf_rules.join('\n\n'); + let a = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - out += rmCommonWS$4` - // - // JISON says: - // - // This is a EBNF grammar. The resulting **BNF** grammar has been - // reproduced here for your convenience: - // - // ---------------------------- START --------------------------- - ${a.join('\n')} - // ---------------------------- END OF BNF grammar -------------- - // + out += rmCommonWS$4` + // + // JISON says: + // + // This is a EBNF grammar. The resulting **BNF** grammar has been + // reproduced here for your convenience: + // + // ---------------------------- START --------------------------- + ${a.join('\n')} + // ---------------------------- END OF BNF grammar -------------- + // - `; + `; + } + out += ebnf_rules.join('\n\n') + '\n\n'; + } else if (bnf_rules.length > 0) { + out += bnf_rules.join('\n\n') + '\n\n'; } - out += ebnf_rules.join('\n\n') + '\n\n'; - } - else if (bnf_rules.length > 0) { - out += bnf_rules.join('\n\n') + '\n\n'; - } - if (grammar_post.length > 0) { - out += rmCommonWS$4` + if (grammar_post.length > 0) { + out += rmCommonWS$4` - %% + %% - ` + grammar_post.join('\n') + '\n\n'; + ` + grammar_post.join('\n') + '\n\n'; + } } - } - if (options.format === 'json5') { - var a = out.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); + if (options.format === 'json5') { + let a = out.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - out = rmCommonWS$4` - // - // JISON says: - // - // The JISON ${options.showParser ? 'grammar' : 'lexer'} has been - // reproduced here for your convenience: - // - // ---------------------------- START --------------------------- - ${a.join('\n')} - // ---------------------------- END ----------------------------- - // + out = rmCommonWS$4` + // + // JISON says: + // + // The JISON ${options.showParser ? 'grammar' : 'lexer'} has been + // reproduced here for your convenience: + // + // ---------------------------- START --------------------------- + ${a.join('\n')} + // ---------------------------- END ----------------------------- + // - `; + `; - // process the original input once again: this time via JSON5 - raw = deepClone(originalInput); + // process the original input once again: this time via JSON5 + raw = deepClone(originalInput); - if (!options.showLexer) { - delete raw.lex; - out += JSON5__default['default'].stringify(raw, null, 2); - } - else if (!options.showParser) { - out += JSON5__default['default'].stringify(raw.lex, null, 2); + if (!options.showLexer) { + delete raw.lex; + out += JSON5__default['default'].stringify(raw, null, 2); + } else if (!options.showParser) { + out += JSON5__default['default'].stringify(raw.lex, null, 2); + } } - } - return out; + return out; + } } // Jison, an LR(0), SLR(1), LARL(1), LR(1) Parser Generator - var rmCommonWS$5 = helpers.rmCommonWS; - var mkIdentifier$4 = helpers.mkIdentifier; - var code_exec$2 = helpers.exec; + const rmCommonWS$5 = helpers.rmCommonWS; + const mkIdentifier$4 = helpers.mkIdentifier; + const code_exec$1 = helpers.exec; - var version$2 = '0.6.2-220'; + const version$2 = '0.7.0-220'; - var devDebug = 0; + let devDebug = 0; function chkBugger$3(src) { src = '' + src; @@ -29081,7 +29102,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE$3 = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; - var Jison$1 = { + let Jison$1 = { version: version$2 }; @@ -29096,8 +29117,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; compressTables: 2, // 0, 1, 2 outputDebugTables: false, noDefaultResolve: false, - defaultActionMode: ["classic", "merge"], // {classic, ast, none, skip}, {classic, ast, merge, none, skip} - testCompileActionCode: "parser:*,lexer:*", + defaultActionMode: [ 'classic', 'merge' ], // {classic, ast, none, skip}, {classic, ast, merge, none, skip} + testCompileActionCode: 'parser:*,lexer:*', noTryCatch: false, hasPartialLrUpgradeOnConflict: true, errorRecoveryTokenDiscardCount: 3, @@ -29155,7 +29176,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; actionsUseYYSTACKPOINTER: false, actionsUseYYTEXT: false, hasErrorRecovery: false, - hasErrorReporting: false, + hasErrorReporting: false }; Jison$1.defaultJisonOptions = defaultJisonOptions; @@ -29176,25 +29197,25 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Return a fresh set of options. /** @public */ function mkStdOptions$1(...args) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - //var args = Array.prototype.concat.apply([], args); + let opts = {}; + //let args = Array.prototype.concat.apply([], args); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(Jison$1.defaultJisonOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; - for (var p in o) { + for (let p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { o2[mkIdentifier$4(p)] = o[p]; } @@ -29226,7 +29247,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // fall through case 'string': - var a = String(o2.defaultActionMode).split(',').map(function (m) { + let a = String(o2.defaultActionMode).split(',').map(function (m) { return m.trim(); }); if (a.length === 1) { @@ -29290,7 +29311,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // now see if we have an overriding option here: - for (var p in o2) { + for (let p in o2) { if (h.call(o2, p)) { if (typeof o2[p] !== 'undefined') { opts[p] = o2[p]; @@ -29306,7 +29327,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function prepExportStructures$1(options) { // set up the 'option' `exportAllTables` as a hash object for returning // all generated tables to the caller - var exportDest = options.exportAllTables; + let exportDest = options.exportAllTables; if (!exportDest || typeof exportDest !== 'object') { exportDest = { enabled: !!exportDest @@ -29318,7 +29339,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -29339,128 +29360,128 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Otherwise return the *parsed* grammar and optional lexer specs as they have // been processed through EBNFParser and LEXParser respectively. function autodetectAndConvertToJSONformat$1(grammar, optionalLexerSection, options) { - var chk_g = null; - var chk_l = null; - var ex1, err; + let chk_g = null; + let chk_l = null; + let ex1, err; if (typeof grammar === 'string') { - if (options.json) { - try { - chk_g = JSON5__default['default'].parse(grammar); + if (options.json) { + try { + chk_g = JSON5__default['default'].parse(grammar); - // When JSON5-based parsing of the grammar succeeds, this implies the grammar is specified in `JSON mode` - // *OR* there's a JSON/JSON5 format error in the input: - } catch (e) { - ex1 = e; + // When JSON5-based parsing of the grammar succeeds, this implies the grammar is specified in `JSON mode` + // *OR* there's a JSON/JSON5 format error in the input: + } catch (e) { + ex1 = e; + } } - } - if (!chk_g) { - try { - chk_g = ebnfParser.parse(grammar); - } catch (e) { - if (options.json) { - // When both JSON5 and JISON input modes barf a hairball, assume the most important - // error is the JISON one (show that one first!), while it MAY be a JSON5 format - // error that triggered it (show that one last!). - // - // Also check for common JISON errors which are obviously never triggered by any - // odd JSON5 input format error: when we encounter such an error here, we don't - // confuse matters and forget about the JSON5 fail as it's irrelevant: - const commonErrors = [ - /does not compile/, - /you did not correctly separate trailing code/, - /You did not specify/, - /You cannot specify/, - /must be qualified/, - /%start/, - /%token/, - /%import/, - /%include/, - /%options/, - /%parse-params/, - /%parser-type/, - /%epsilon/, - /definition list error/, - /token list error/, - /declaration error/, - /should be followed/, - /should be separated/, - /an error in one or more of your lexer regex rules/, - /an error in your lexer epilogue/, - /unsupported definition type/, - ]; - var cmnerr = commonErrors.filter(function check(re) { - return e.message.match(re); - }); - if (cmnerr.length > 0) { - err = e; + if (!chk_g) { + try { + chk_g = ebnfParser.parse(grammar); + } catch (e) { + if (options.json) { + // When both JSON5 and JISON input modes barf a hairball, assume the most important + // error is the JISON one (show that one first!), while it MAY be a JSON5 format + // error that triggered it (show that one last!). + // + // Also check for common JISON errors which are obviously never triggered by any + // odd JSON5 input format error: when we encounter such an error here, we don't + // confuse matters and forget about the JSON5 fail as it's irrelevant: + const commonErrors = [ + /does not compile/, + /you did not correctly separate trailing code/, + /You did not specify/, + /You cannot specify/, + /must be qualified/, + /%start/, + /%token/, + /%import/, + /%include/, + /%options/, + /%parse-params/, + /%parser-type/, + /%epsilon/, + /definition list error/, + /token list error/, + /declaration error/, + /should be followed/, + /should be separated/, + /an error in one or more of your lexer regex rules/, + /an error in your lexer epilogue/, + /unsupported definition type/ + ]; + let cmnerr = commonErrors.filter(function check(re) { + return e.message.match(re); + }); + if (cmnerr.length > 0) { + err = e; + } else { + err = new Error('Could not parse jison grammar in JSON AUTODETECT mode:\nin JISON Mode we get Error: ' + e.message + '\nwhile JSON5 Mode produces Error: ' + ex1.message); + err.secondary_exception = e; + err.stack = ex1.stack; + } } else { - err = new Error('Could not parse jison grammar in JSON AUTODETECT mode:\nin JISON Mode we get Error: ' + e.message + '\nwhile JSON5 Mode produces Error: ' + ex1.message); - err.secondary_exception = e; - err.stack = ex1.stack; + err = new Error('Could not parse jison grammar\nError: ' + e.message); + err.stack = e.stack; } - } else { - err = new Error('Could not parse jison grammar\nError: ' + e.message); - err.stack = e.stack; + throw err; } - throw err; } - } - // Save time! Don't reparse the entire grammar *again* inside the code generators when that's not necessary: - // if (chk_g) { - // grammar = chk_g; - // } + // Save time! Don't reparse the entire grammar *again* inside the code generators when that's not necessary: + // if (chk_g) { + // grammar = chk_g; + // } } else { chk_g = grammar; } // Now the same treatment for the lexer: if (chk_g && optionalLexerSection) { - if (chk_g.lex) { - throw new Error('Cannot invoke with both a lexer section in the grammar input and a separate lexer input at the same time!'); - } + if (chk_g.lex) { + throw new Error('Cannot invoke with both a lexer section in the grammar input and a separate lexer input at the same time!'); + } - if (typeof optionalLexerSection === 'string') { - if (options.json) { - try { - chk_l = JSON5__default['default'].parse(optionalLexerSection); + if (typeof optionalLexerSection === 'string') { + if (options.json) { + try { + chk_l = JSON5__default['default'].parse(optionalLexerSection); - // When JSON5-based parsing of the lexer spec succeeds, this implies the lexer spec is specified in `JSON mode` - // *OR* there's a JSON/JSON5 format error in the input: - } catch (e) { - ex1 = e; - } - } - if (!chk_l) { - // // WARNING: the lexer may receive options specified in the **grammar spec file**, - // // hence we should mix the options to ensure the lexParser always - // // receives the full set! - // // - // // make sure all options are 'standardized' before we go and mix them together: - // options = mkStdOptions(grammar.options, options); - try { - chk_l = lexParser.parse(optionalLexerSection); - } catch (e) { - if (options.json) { - err = new Error('Could not parse lexer spec in JSON AUTODETECT mode\nError: ' + ex1.message + ' (' + e.message + ')'); - err.secondary_exception = e; - err.stack = ex1.stack; - } else { - err = new Error('Could not parse lexer spec\nError: ' + e.message); - err.stack = e.stack; - } - throw err; - } + // When JSON5-based parsing of the lexer spec succeeds, this implies the lexer spec is specified in `JSON mode` + // *OR* there's a JSON/JSON5 format error in the input: + } catch (e) { + ex1 = e; + } + } + if (!chk_l) { + // // WARNING: the lexer may receive options specified in the **grammar spec file**, + // // hence we should mix the options to ensure the lexParser always + // // receives the full set! + // // + // // make sure all options are 'standardized' before we go and mix them together: + // options = mkStdOptions(grammar.options, options); + try { + chk_l = lexParser.parse(optionalLexerSection); + } catch (e) { + if (options.json) { + err = new Error('Could not parse lexer spec in JSON AUTODETECT mode\nError: ' + ex1.message + ' (' + e.message + ')'); + err.secondary_exception = e; + err.stack = ex1.stack; + } else { + err = new Error('Could not parse lexer spec\nError: ' + e.message); + err.stack = e.stack; + } + throw err; + } + } + } else { + chk_l = optionalLexerSection; } - } else { - chk_l = optionalLexerSection; - } - // Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: - if (chk_l) { - chk_g.lex = chk_l; - } + // Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: + if (chk_l) { + chk_g.lex = chk_l; + } } return chk_g; @@ -29477,7 +29498,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // wrap console.log to prevent 'Illegal Invocation' exceptions when Jison.print() is used, e.g. // in the web tryout pages where this code is employed. Jison$1.print = function console_log(/* ... */) { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); args.unshift(''); // prevent `%.` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args console.log.apply(console, args); }; @@ -29498,7 +29519,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; Jison$1.Lexer = RegExpLexer; Jison$1.ebnfParser = ebnfParser; Jison$1.lexParser = lexParser; - Jison$1.codeExec = code_exec$2; + Jison$1.codeExec = code_exec$1; Jison$1.XRegExp = XRegExp__default['default']; Jison$1.recast = recast__default['default']; Jison$1.astUtils = astUtils__default['default']; @@ -29513,7 +29534,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (typeof obj.forEach === 'function') { obj.forEach(func); } else { - var p; + let p; for (p in obj) { if (obj.hasOwnProperty(p)) { func.call(obj, obj[p], p, obj); @@ -29543,10 +29564,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // site for this jscore grammar as the naive scan consistently // outperformed the old smarter hash-object code for smaller // thresholds (10, 20, 32, 42!) - var k, len; + let k, len; if (a.length > 52) { - var ar = {}; + let ar = {}; for (k = 0, len = a.length; k < len; k++) { ar[a[k]] = true; } @@ -29556,7 +29577,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } } else { - var bn = []; + let bn = []; for (k = 0, len = b.length; k < len; k++) { if (a.indexOf(b[k]) < 0) { bn.push(b[k]); @@ -29567,17 +29588,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return a; } - var Nonterminal = typal.construct({ + let Nonterminal = typal.construct({ constructor: function Nonterminal(symbol) { this.symbol = symbol; - this.productions = new Set(); + this.productions = new Set$1(); this.first = []; this.follows = []; this.nullable = false; }, toString: function Nonterminal_toString() { - var str = this.symbol; - var attr_str = []; + let str = this.symbol; + let attr_str = []; if (this.nullable) { attr_str.push('nullable'); @@ -29594,7 +29615,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } }); - var Production = typal.construct({ + let Production = typal.construct({ constructor: function Production(symbol, handle, id, handle_aliases, handle_action) { this.symbol = symbol; this.handle = handle; @@ -29608,9 +29629,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.reachable = false; }, toString: function Production_toString() { - var str = this.symbol; + let str = this.symbol; - var attr_str = []; + let attr_str = []; if (this.nullable) { attr_str.push('~'); @@ -29630,9 +29651,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return str; }, describe: function Production_describe() { - var str = this.symbol; + let str = this.symbol; - var attr_str = []; + let attr_str = []; if (this.nullable) { attr_str.push('nullable'); @@ -29653,7 +29674,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - var generator = typal.beget(); + let generator = typal.beget(); // `optionalLexerSection` is an optional {String} argument, specifying the lexer rules. // May only be specified when the specified `grammar` also is a yet-unparsed @@ -29728,11 +29749,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; generator.constructor = function Jison_Generator(grammar, optionalLexerSection, options) { // pick the correct argument for the `options` for this call: if (!options && optionalLexerSection && typeof optionalLexerSection !== 'string') { - options = optionalLexerSection; - optionalLexerSection = null; + options = optionalLexerSection; + optionalLexerSection = null; } // and standardize it: - var preliminary_options = mkStdOptions$1(options); + let preliminary_options = mkStdOptions$1(options); grammar = autodetectAndConvertToJSONformat$1(grammar, optionalLexerSection, preliminary_options); @@ -29780,7 +29801,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // } // calculate the input path; if none is specified, it's the present working directory - var inpath = options.file || options.outfile || './dummy'; + let inpath = options.file || options.outfile || './dummy'; inpath = path__default['default'].normalize(inpath); options.inputPath = path__default['default'].dirname(inpath); options.inputFilename = path__default['default'].basename(inpath); @@ -29811,7 +29832,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.processGrammar(grammar); if (grammar.lex) { - var lexer_options = { + let lexer_options = { // include the knowledge about which parser/lexer // features will actually be *used* by the environment: // @@ -29866,7 +29887,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; exportAST: this.options.exportAST, prettyCfg: this.options.prettyCfg, pre_lex: this.options.pre_lex, - post_lex: this.options.post_lex, + post_lex: this.options.post_lex }; this.lexer = new RegExpLexer(grammar.lex, null, this.terminals_, lexer_options); @@ -29874,10 +29895,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; generator.processGrammar = function processGrammarDef(grammar) { - var bnf = grammar.bnf, - tokens = grammar.tokens, - nonterminals = this.nonterminals = {}, - productions = this.productions; + let bnf = grammar.bnf; + let tokens = grammar.tokens; + let nonterminals = this.nonterminals = {}; + let productions = this.productions; if (!grammar.bnf && grammar.ebnf) { bnf = grammar.bnf = ebnfParser.transform(grammar.ebnf); @@ -29893,18 +29914,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // did the grammar user also provide a predefined set of symbols to be (re)used with this grammar? // (This is used when you want to generate multiple lexers and parsers which share a common symbol set // so as to make the parsers and lexers mutually interchangeable.) - var predefined_symbols = null; + let predefined_symbols = null; if (grammar.imports) { - var symbols_import = grammar.imports.find(function (el, idx) { + let symbols_import = grammar.imports.find(function (el, idx) { if (el.name === 'symbols') { return el; } return false; }); if (symbols_import) { - var filepath = path__default['default'].resolve(symbols_import.path); + let filepath = path__default['default'].resolve(symbols_import.path); - var source = fs__default['default'].readFileSync(filepath, 'utf8'); + let source = fs__default['default'].readFileSync(filepath, 'utf8'); // It's either a JSON file or a JISON generated output file: // // symbols_: { @@ -29914,7 +29935,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; predefined_symbols = JSON5__default['default'].parse(source); } catch (ex) { try { - var m = /[\r\n]\s*symbols_:\s*(\{[\s\S]*?\}),\s*[\r\n]/.exec(source); + let m = /[\r\n]\s*symbols_:\s*(\{[\s\S]*?\}),\s*[\r\n]/.exec(source); if (m && m[1]) { source = m[1]; predefined_symbols = JSON5__default['default'].parse(source); @@ -29929,18 +29950,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // Make sure all predefined symbols are unique and *numeric* and do not include predefined tokens JISON already defines to a fixed ID on its own: - delete predefined_symbols['$accept']; - delete predefined_symbols['$end']; - delete predefined_symbols['error']; - delete predefined_symbols['$eof']; - delete predefined_symbols['EOF']; + delete predefined_symbols.$accept; + delete predefined_symbols.$end; + delete predefined_symbols.error; + delete predefined_symbols.$eof; + delete predefined_symbols.EOF; - var symdef_uniq_check = {}; + let symdef_uniq_check = {}; // Only these symbols are allowed to have the values 1 or 2: symdef_uniq_check[1] = 'EOF'; symdef_uniq_check[2] = 'error'; Object.keys(predefined_symbols).forEach(function cvt_symbol_id_to_numeric(sym) { - var v = predefined_symbols[sym]; + let v = predefined_symbols[sym]; // Symbol value may be defined as boolean TRUE, in which case we let JISON pick the value for us: if (v === true) return; @@ -29948,17 +29969,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Symbol value may be defined as a one-character string: if (typeof v !== 'number') { if (typeof v !== 'string' || v.length !== 1) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a non-numeric symbol ID value must be a single-character string.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a non-numeric symbol ID value must be a single-character string."); } v = v.charCodeAt(0); } - v = v | 0; + v |= 0; if (!v || v < 0) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a symbol ID value must be an integer value, 3 or greater.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a symbol ID value must be an integer value, 3 or greater."); } if (symdef_uniq_check[v]) { if (symdef_uniq_check[v] !== sym) { - throw new Error('Error: `%import symbols `: symbol table contains duplicate ID values for keys \'' + sym + '\' and \'' + symdef_uniq_check[v] + '\''); + throw new Error("Error: `%import symbols `: symbol table contains duplicate ID values for keys '" + sym + "' and '" + symdef_uniq_check[v] + "'"); } } symdef_uniq_check[v] = sym; @@ -29967,15 +29988,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } - var symbols = this.symbols = []; + let symbols = this.symbols = []; // calculate precedence of operators - var operators = this.operators = processOperators(grammar.operators); + let operators = this.operators = processOperators(grammar.operators); // build productions from CFG and calculate the symbol sets (terminals and nonterminals) and their name-to-ID mappings this.buildProductions(bnf, productions, nonterminals, symbols, operators, predefined_symbols, grammar.extra_tokens); if (tokens) { - var termset = this.terminals.filter(function (t) { + let termset = this.terminals.filter(function (t) { switch (t) { case 'EOF': case 'error': @@ -29987,7 +30008,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return true; } }); - var diffset = termset.filter(function (t) { + let diffset = termset.filter(function (t) { return tokens.indexOf(t) === -1; }); diffset = diffset.concat(tokens.filter(function (t) { @@ -30044,7 +30065,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // return true; // the default parse result if the rule actions don't produce anything // %} // - var acceptProduction = new Production('$accept', [this.startSymbol, '$end'], 0); + let acceptProduction = new Production('$accept', [ this.startSymbol, '$end' ], 0); this.productions.unshift(acceptProduction); // prepend parser tokens // moved to generator.buildProductions() @@ -30063,14 +30084,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Mark unused productions generator.signalUnusedProductions = function () { - var mark = {}; + let mark = {}; - var productions = this.productions; - var nonterminals = this.nonterminals; - var i, len, nt, sym; + let productions = this.productions; + let nonterminals = this.nonterminals; - for (i = 0, len = nonterminals.length; i < len; i++) { - nt = nonterminals[i]; + for (let i = 0, len = nonterminals.length; i < len; i++) { + let nt = nonterminals[i]; assert__default['default'](nt.symbol); mark[nt.symbol] = false; } @@ -30081,15 +30101,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; assert__default['default'](nt.symbol); mark[nt.symbol] = true; - var prods = nt.productions; + let prods = nt.productions; assert__default['default'](prods); prods.forEach(function (p) { assert__default['default'](p.symbol === nt.symbol); assert__default['default'](p.handle); - var rhs = p.handle; + let rhs = p.handle; - for (var j = 0, len = rhs.length; j < len; j++) { - var sym = rhs[j]; + for (let j = 0, len = rhs.length; j < len; j++) { + let sym = rhs[j]; assert__default['default'](!sym ? !nonterminals[sym] : true); if (nonterminals[sym] && !mark[sym]) { traverseGrammar(nonterminals[sym]); @@ -30098,15 +30118,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }); } - traverseGrammar(nonterminals['$accept' /* this.startSymbol */ ]); + traverseGrammar(nonterminals['$accept' /* this.startSymbol */]); // now any production which is not yet marked is *unused*: - for (sym in mark) { - nt = nonterminals[sym]; + for (let sym in mark) { + let nt = nonterminals[sym]; assert__default['default'](nt); - var prods = nt.productions; + let prods = nt.productions; assert__default['default'](prods); - var in_use = mark[sym]; + let in_use = mark[sym]; prods.forEach(function (p) { assert__default['default'](p); if (in_use) { @@ -30135,8 +30155,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // set precedence and associativity of operators function processOperators(ops) { if (!ops) return {}; - var operators = {}; - for (var i = 0, k, prec; (prec = ops[i]); i++) { + let operators = {}; + for (let i = 0, k, prec; (prec = ops[i]); i++) { for (k = 1; k < prec.length; k++) { operators[prec[k]] = { precedence: i + 1, @@ -30151,8 +30171,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // Note that the first line doesn't count as the chunk is very probably trimmed! function reindentCodeBlock(action, indent_level) { - var width = 0; - var lines = action + let width = 0; + let lines = action .trim() .split('\n') // measure the indent: @@ -30169,7 +30189,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return s.replace(/\t/g, ' '); }); - var m = /^[ ]+/.exec(line); + let m = /^[ ]+/.exec(line); if (m) { width = Math.min(m[0].length, width); } @@ -30180,8 +30200,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; .map(function checkIndentation(line, idx) { line = line .replace(/^[ ]*/, function adjustIndent(s) { - var l = Math.max(s.length - width, 0) + indent_level; - var shift = (new Array(l + 1)).join(' '); + let l = Math.max(s.length - width, 0) + indent_level; + let shift = (new Array(l + 1)).join(' '); return shift; }); return line; @@ -30192,21 +30212,21 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; generator.buildProductions = function buildProductions(bnf, productions, nonterminals, symbols, operators, predefined_symbols, descriptions) { - var self = this; - var prods, symbol, symId; - var productions_ = []; - var symbols_ = {}; - var descriptions_ = {}; - var usedSymbolIds = [/* $accept = 0 */ true, /* $end = 1 */ true, /* error = 2 */ true]; - var usedSymbolIdsLowIndex = 3; + let self = this; + let prods, symId; + let productions_ = []; + let symbols_ = {}; + let descriptions_ = {}; + let usedSymbolIds = [/* $accept = 0 */ true, /* $end = 1 */ true, /* error = 2 */ true ]; + let usedSymbolIdsLowIndex = 3; // set up the required symbols `$accept` and `$end` (a.k.a. EOF) and make sure they occupy the expected slots: this.EOF = '$end'; symbols_.$accept = 0; symbols_[this.EOF] = 1; - symbols_['$eof'] = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! - symbols_['EOF'] = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.$eof = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.EOF = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! symbols[0] = '$accept'; symbols[1] = this.EOF; @@ -30217,7 +30237,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; symbols[2] = 'error'; if (predefined_symbols) { - for (symbol in predefined_symbols) { + for (let symbol in predefined_symbols) { symId = predefined_symbols[symbol]; if (symId === true) { // add symbol to queue which must be assigned a value by JISON; after all the other predefined symbols have been processed. @@ -30240,7 +30260,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // preferably assign readable ASCII-range token IDs to tokens added from the predefined list // but only when maximum table compression isn't demanded: usedSymbolIdsLowIndex = ((this.options.compressTables | 0) < 2 ? 32 : 3); - for (symbol in predefined_symbols) { + for (let symbol in predefined_symbols) { symId = predefined_symbols[symbol]; addSymbol(symbol); } @@ -30260,11 +30280,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } - var hasErrorRecovery = false; // has error recovery + let hasErrorRecovery = false; // has error recovery // Produce the next available unique symbolID: function getNextSymbolId() { - for (var i = usedSymbolIdsLowIndex; ; i++) { + for (let i = usedSymbolIdsLowIndex; ; i++) { if (!usedSymbolIds[i]) { usedSymbolIds[i] = true; usedSymbolIdsLowIndex = i + 1; @@ -30275,7 +30295,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function addSymbol(s) { if (s && !symbols_[s]) { - var i; + let i; // assign the Unicode codepoint index to single-character symbols, // but only when maximum table compression isn't demanded: @@ -30299,46 +30319,45 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // `this` is options object with `maxTokenLength` option to guide us which literal tokens we want to process: function collectLiteralTokensInProduction(handle) { - var rhs, i, sym; + let rhs; - try{ - if (devDebug) ; + try { + if (devDebug) ; - var maxlen = this.maxTokenLength || Infinity; + let maxlen = this.maxTokenLength || Infinity; - if (handle.constructor === Array) { - var rhs_i; - rhs = (typeof handle[0] === 'string') ? - splitStringIntoSymbols(handle[0]) : - handle[0].slice(0); + if (handle.constructor === Array) { + rhs = (typeof handle[0] === 'string') ? + splitStringIntoSymbols(handle[0]) : + handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; - // check for aliased names, e.g., id[alias] and strip them - rhs_i = sym.match(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]$`)); - if (rhs_i) { - sym = sym.substr(0, sym.length - rhs_i[0].length); - } + for (let i = 0; i < rhs.length; i++) { + let sym = rhs[i]; + // check for aliased names, e.g., id[alias] and strip them + let rhs_i = sym.match(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]$`)); + if (rhs_i) { + sym = sym.substr(0, sym.length - rhs_i[0].length); + } - if (!bnf[sym] && sym.length <= maxlen) { - addSymbol(sym); + if (!bnf[sym] && sym.length <= maxlen) { + addSymbol(sym); + } } - } - } else { - // no action -> don't care about aliases; strip them. - handle = handle.replace(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); - rhs = splitStringIntoSymbols(handle); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; - if (!bnf[sym] && sym.length <= maxlen) { - addSymbol(sym); + } else { + // no action -> don't care about aliases; strip them. + handle = handle.replace(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); + rhs = splitStringIntoSymbols(handle); + for (let i = 0; i < rhs.length; i++) { + let sym = rhs[i]; + if (!bnf[sym] && sym.length <= maxlen) { + addSymbol(sym); + } } } + } catch (ex) { + console.error(ex, '\ncollectLiteralTokensInProduction: ', this.symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { rhs }); + throw ex; } - }catch (ex) { - console.error(ex, '\ncollectLiteralTokensInProduction: ', symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { i, sym, rhs }); - throw ex; - } } // Before we go process the grammar for real, we collect the 'literal' non-terminals and add them to the symbol table @@ -30346,8 +30365,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // which helps debugging/diagnosis of generated grammars. // (This is why previously we had set `usedSymbolIdsLowIndex` to 127 instead of 3!) - var prodsLUT = {}; - for (symbol in bnf) { + let prodsLUT = {}; + for (let symbol in bnf) { if (!bnf.hasOwnProperty(symbol)) continue; if (typeof bnf[symbol] === 'string') { @@ -30360,21 +30379,23 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // First we collect all single-character literal tokens: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: 1 + maxTokenLength: 1, + symbol }); } // Next we collect all other literal tokens: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: Infinity + maxTokenLength: Infinity, + symbol }); } @@ -30383,7 +30404,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // for each of those: nonterminals should all have IDs assigned before they // should be processed as part of a *production* rule, where these MAY be // referenced: - for (symbol in bnf) { + for (let symbol in bnf) { if (!bnf.hasOwnProperty(symbol)) continue; addSymbol(symbol); @@ -30392,15 +30413,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now that we have collected all nonterminals in our symbol table, it's finally // time to process the productions: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; - prods.forEach(buildProduction); + prods.forEach(buildProduction, { symbol }); } - var terms = [], - terms_ = {}; + let terms = []; + let terms_ = {}; each(symbols_, function (id, sym) { // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number @@ -30416,7 +30437,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // fix error recovery related options now that we know whether we actually have any recovery // rules at all: if (!this.hasErrorRecovery) { - var chk_er_opt = function check_error_recovery_option(opt, label) { + let chk_er_opt = function check_error_recovery_option(opt, label) { if (self.options[opt]) { self.options[opt] = false; self.warn('The grammar does not have any error recovery rules, so using the ' + label + ' is rather useless.'); @@ -30428,9 +30449,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Hmmmm... why would lexer errors need to be NON-recoverable when there's no ERROR rules in the GRAMMAR?! chk_er_opt('lexerErrorsAreRecoverable', 'lexer-errors-are-recoverable feature/option'); - chk_er_opt('parseActionsUseYYRECOVERING', 'YYRECOVERING macro/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYERROK', 'yyerrok() function/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYCLEARIN', 'yyclearin() function/API in grammar rules\' action code'); + chk_er_opt('parseActionsUseYYRECOVERING', "YYRECOVERING macro/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYERROK', "yyerrok() function/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYCLEARIN', "yyclearin() function/API in grammar rules' action code"); } this.terminals = terms; @@ -30449,8 +30470,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function splitStringIntoSymbols(rhs) { // when there's no literal tokens in there, we can fast-track this baby: rhs = rhs.trim(); - var pos1 = rhs.indexOf("'"); - var pos2 = rhs.indexOf('"'); + let pos1 = rhs.indexOf("'"); + let pos2 = rhs.indexOf('"'); if (pos1 < 0 && pos2 < 0) { return rhs.split(' '); } @@ -30458,10 +30479,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // rhs has at least one literal: we will need to parse the rhs into tokens // with a little more effort now. - var tokens = []; + let tokens = []; while (pos1 >= 0 || pos2 >= 0) { - var pos = pos1; - var marker = "'"; + let pos = pos1; + let marker = "'"; if (pos < 0) { assert__default['default'](pos2 >= 0); pos = pos2; @@ -30470,7 +30491,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; pos = pos2; marker = '"'; } - var ls = rhs.substr(0, pos).trim(); + let ls = rhs.substr(0, pos).trim(); if (ls.length > 0) { tokens.push.apply(tokens, ls.split(' ')); } @@ -30479,7 +30500,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // Edge case: token MAY include the ESCAPED MARKER... or other escapes! // Hence we need to skip over ALL escapes inside the token! - var pos3 = rhs.indexOf('\\'); + let pos3 = rhs.indexOf('\\'); pos = rhs.indexOf(marker); ls = ''; while (pos3 >= 0 && pos3 < pos) { @@ -30494,7 +30515,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; ls += rhs.substr(0, pos); // check for aliased literals, e.g., `'>'[gt]` and keep it and the alias together rhs = rhs.substr(pos + 1); - var alias = rhs.match(new XRegExp__default['default'](`^\\[${ID_REGEX_BASE$3}\\]`)); + let alias = rhs.match(new XRegExp__default['default'](`^\\[${ID_REGEX_BASE$3}\\]`)); if (alias) { ls += alias[0]; rhs = rhs.substr(alias[0].length); @@ -30514,22 +30535,21 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return tokens; } + // options object { symbol } is `this` for this functon/callback: function buildProduction(handle) { - var r, rhs, i, - precedence_override, - aliased = [], - action = null; + let rhs; + let precedence_override = null; + let aliased = []; + let action = null; if (handle.constructor === Array) { - var rhs_i; - rhs = (typeof handle[0] === 'string') ? - splitStringIntoSymbols(handle[0]) : - handle[0].slice(0); + splitStringIntoSymbols(handle[0]) : + handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // check for aliased names, e.g., id[alias] and strip them - rhs_i = rhs[i].match(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]$`)); + let rhs_i = rhs[i].match(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]$`)); if (rhs_i) { rhs[i] = rhs[i].substr(0, rhs[i].length - rhs_i[0].length); rhs_i = rhs_i[0].substr(1, rhs_i[0].length - 2); @@ -30571,7 +30591,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // no action -> don't care about aliases; strip them. handle = handle.replace(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { if (rhs[i] === 'error') { hasErrorRecovery = true; } @@ -30581,35 +30601,33 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } - r = new Production(symbol, rhs, productions.length + 1, aliased, action); + let r = new Production(this.symbol, rhs, productions.length + 1, aliased, action); // set precedence assert__default['default'](r.precedence === 0); if (precedence_override) { r.precedence = precedence_override.spec.precedence; - } - else { - var prec_symbols = []; - var winning_symbol; + } else { + let prec_symbols = []; + let winning_symbol; - for (i = r.handle.length - 1; i >= 0; i--) { + for (let i = r.handle.length - 1; i >= 0; i--) { if (!(r.handle[i] in nonterminals) && r.handle[i] in operators) { - var old_prec = r.precedence; - var new_prec = operators[r.handle[i]].precedence; + let old_prec = r.precedence; + let new_prec = operators[r.handle[i]].precedence; if (old_prec !== 0 && old_prec !== new_prec) { prec_symbols.push(r.handle[i]); - // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], symbol, handle[0]); + // 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[i]; - } - else { + } else { // keep previously set precedence: new_prec = old_prec; } } else if (old_prec === 0) { prec_symbols.push(r.handle[i]); winning_symbol = r.handle[i]; - // Jison.print('precedence set first time: ', old_prec, r.handle[i], symbol, handle[0]); + // Jison.print('precedence set first time: ', old_prec, r.handle[i], this.symbol, handle[0]); } r.precedence = new_prec; } @@ -30617,14 +30635,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (prec_symbols.length > 1) { if (self.DEBUG || 1) { - self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); + self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + this.symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); } } } productions.push(r); - productions_.push([symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length]); - nonterminals[symbol].productions.push(r); + productions_.push([ symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length ]); + nonterminals[this.symbol].productions.push(r); } }; @@ -30729,8 +30747,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // with our pants down in constructs like // `'"' + $$ + '"'` vs. `"'" + $$ + "'"` - var dqpos, sqpos, ccmtpos, cppcmtpos, first = -1; - for (var c = 0;; c++) { + let dqpos, sqpos, ccmtpos, cppcmtpos; + let first = -1; + for (let c = 0; ; c++) { first++; dqpos = s.indexOf('"', first); sqpos = s.indexOf("'", first); @@ -30774,11 +30793,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; .replace(/\x01\x82/g, '$') .replace(/\x01\x83/g, '@') // and revert the string and regex markers: - .replace(/\x01\x87/g, '\'') + .replace(/\x01\x87/g, "'") .replace(/\x01\x88/g, '\"') .replace(/\x01\x89/g, '##') .replace(/\x01\x90/g, '\\\\') - .replace(/\x01\x91/g, '\\\'') + .replace(/\x01\x91/g, "\\'") .replace(/\x01\x92/g, '\\\"') .replace(/\x01\x93/g, '\\\/') .replace(/\x01\x94/g, 'YYABORT') @@ -30811,7 +30830,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function analyzeFeatureUsage(sourcecode, feature, threshold) { - var found = sourcecode.match(feature); + let found = sourcecode.match(feature); return !!(found && found.length > threshold); } @@ -30819,7 +30838,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function mkParserFeatureHash(self) { assert__default['default'](self.options.exportAllTables); // check that this function isn't called too early in the process or the hash will be bogus assert__default['default'](self.options.exportSourceCode); - var h = [ + let h = [ self.actionsAreAllDefault, self.actionsUseLocationAssignment, self.actionsUseLocationTracking, @@ -30868,7 +30887,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; self.options.prettyCfg, '======================================', self.performAction, - '======================================', + '======================================' ]; return JSON.stringify(h); } @@ -30883,23 +30902,23 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.productions_ = productions_; assert(this.productions === productions); */ - var productions = this.productions, - nonterminals = this.nonterminals, - symbols = this.symbols, - operators = this.operators, - self = this; + let productions = this.productions; + let nonterminals = this.nonterminals; + let symbols = this.symbols; + let operators = this.operators; + let self = this; // As a SIDE EFFECT of this call, we also fixup // the other code chunks specified in the grammar file: // // Replace direct symbol references, e.g. #NUMBER# when there's a `%token NUMBER` for your grammar. // We allow these tokens to be referenced anywhere in your code as #TOKEN#. - var moduleInclude = preprocessActionCode(this.moduleInclude) + let moduleInclude = preprocessActionCode(this.moduleInclude) .replace(new XRegExp__default['default'](`#(${ID_REGEX_BASE$3})#`, 'g'), function (_, sym) { return provideSymbolAsSourcecode(sym); }); // and COPY the `moduleInit` array, after preprocessing the individual COPIES: - var moduleInit = this.moduleInit.map(function (chunk) { + let moduleInit = this.moduleInit.map(function (chunk) { assert__default['default'](chunk.qualifier); assert__default['default'](typeof chunk.include === 'string'); return { @@ -30915,39 +30934,38 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // We potentially need multiple (2+) rounds to produce the correct actions // as userland action code determines whether the default actions should // include location tracking or not: - var gen_level = 0; - var prev_gen_hash = 'n'; - var gen_hash = 'y'; + let gen_level = 0; + let prev_gen_hash = 'n'; + let gen_hash = 'y'; this.performAction = null; while (gen_hash !== prev_gen_hash) { - var preludeCode = preprocessActionCode(this.actionInclude || ''); - var actions = [` + let preludeCode = preprocessActionCode(this.actionInclude || ''); + let actions = [ ` /* this == yyval */ // the JS engine itself can go and remove these statements when \`yy\` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; ${preludeCode} switch (yystate) {` ]; - var actionGroups = {}; // used to combine identical actions into single instances: no use duplicating action code needlessly - var actionGroupValue = {}; // stores the unaltered, expanded, user-defined action code for each action group. - var stateHasAction = []; // marks which state IDs have an action, either user-specified or default. - var symbol; + let actionGroups = {}; // used to combine identical actions into single instances: no use duplicating action code needlessly + let actionGroupValue = {}; // stores the unaltered, expanded, user-defined action code for each action group. + let stateHasAction = []; // marks which state IDs have an action, either user-specified or default. // and now go and process the entire grammar: - productions.forEach(buildProductionAction); + productions.forEach(buildProductionAction, { actionGroups, actionGroupValue, stateHasAction }); - for (var hash in actionGroups) { + for (let hash in actionGroups) { actions.push([].concat.apply([], actionGroups[hash]).join('\n') + '\n\n' + actionGroupValue[hash] + '\n break;\n'); } // add the special error recovery reduction action: if (this.hasErrorRecovery) { - var userland_err_recov_redux_code = ''; + let userland_err_recov_redux_code = ''; actions.push(`case YY_ERROR_RECOVERY_COMBINE_ID: // === NO_ACTION[1] :: ensures that anyone (but us) using this new state will fail dramatically! // error recovery reduction action (action generated by jison, @@ -30960,16 +30978,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // check if all IDs have an action now: - var missingActions = []; - for (var idx = 0, len = stateHasAction.length; idx < len; idx++) { + let missingActions = []; + for (let idx = 0, len = stateHasAction.length; idx < len; idx++) { if (!stateHasAction[idx]) { missingActions.push(idx); } } - this.missingActions = missingActions; + this.missingActions = missingActions; if (missingActions.length) { if ( this.DEBUG) { - this.warn("WARNING: missing actions for states: ", missingActions); + this.warn('WARNING: missing actions for states: ', missingActions); } actions.push(`default: @@ -30977,7 +30995,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // When we hit this entry, it's always a non-recoverable issue as this is a severe internal parser state failure: function __b0rk_on_internal_failure(str) { - var hash = yyparser.constructParseErrorInfo(str, null, null, false); + let hash = yyparser.constructParseErrorInfo(str, null, null, false); return yyparser.parseError(str, hash, yyparser.JisonParserError); } @@ -30987,7 +31005,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } actions.push('}'); - var parameters = 'yytext, yyleng, yylineno, yyloc, yystate /* action[1] */, yysp, yyrulelength, yyvstack, yylstack, yystack, yysstack'; + let parameters = 'yytext, yyleng, yylineno, yyloc, yystate /* action[1] */, yysp, yyrulelength, yyvstack, yylstack, yystack, yysstack'; this.performAction = [].concat( 'function parser__PerformAction(' + parameters + ') {', @@ -31106,7 +31124,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; moduleInit.forEach(function (chunk) { assert__default['default'](chunk.qualifier); assert__default['default'](typeof chunk.include === 'string'); - var moduleInclude = chunk.include; + let moduleInclude = chunk.include; //self.actionsUseYYLENG = self.actionsUseYYLENG || analyzeFeatureUsage(moduleInclude, /\byyleng\b/g, 0); //self.actionsUseYYLINENO = self.actionsUseYYLINENO || analyzeFeatureUsage(moduleInclude, /\byylineno\b/g, 0); @@ -31174,8 +31192,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.actionsUseValueAssignment = true; break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": // <-- this one injects *nothing* + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'skip': // <-- this one injects *nothing* break; } this.actionsUseValueTracking = this.actionsUseValueTracking || this.actionsUseYYLENG || this.actionsUseYYTEXT || this.actionsUseValueAssignment; @@ -31184,8 +31202,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; default: break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": // <-- this one injects *nothing* + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'skip': // <-- this one injects *nothing* break; } this.actionsUseLocationTracking = this.actionsUseLocationTracking || this.actionsUseYYLINENO || this.actionsUseYYLOC || this.actionsUseLocationAssignment || this.actionsUseYYMERGELOCATIONINFO; @@ -31206,7 +31224,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; gen_hash = null; // create check hash of the new generated code: - var new_hash = mkParserFeatureHash(this); + let new_hash = mkParserFeatureHash(this); if ( this.DEBUG) { Jison$1.print('Optimization analysis:\n', { @@ -31235,7 +31253,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; hasErrorReporting: this.hasErrorReporting, defaultActionMode: this.options.defaultActionMode, testCompileActionCode: this.options.testCompileActionCode, - noTryCatch: this.options.noTryCatch, + noTryCatch: this.options.noTryCatch }); } @@ -31258,9 +31276,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; moduleInit.__consumedInitCodeSlots__ = []; moduleInit.getInitCodeSection = function getInitCodeSection(section) { - var rv = []; - for (var i = 0, len = this.length; i < len; i++) { - var m = this[i]; + let rv = []; + for (let i = 0, len = this.length; i < len; i++) { + let m = this[i]; if (m.qualifier === section) { if (m.include.trim()) { rv.push(m.include); @@ -31272,9 +31290,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; moduleInit.getRemainingInitCodeSections = function getRemainingInitCodeSections() { - var rv = []; - for (var i = 0, len = this.length; i < len; i++) { - var m = this[i]; + let rv = []; + for (let i = 0, len = this.length; i < len; i++) { + let m = this[i]; if (!this.__consumedInitCodeSlots__[i]) { rv.push(rmCommonWS$5` @@ -31290,8 +31308,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; - - // make sure a comment does not contain any embedded '*/' end-of-comment marker // as that would break the generated code function postprocessComment(str) { @@ -31315,13 +31331,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function provideSymbolAsSourcecode(sym) { - var ss = String(sym); + let ss = String(sym); return ' /* ' + postprocessComment(ss) + ' */ ' + getSymbolId(sym); } // helper: convert index string/number to proper JS add/subtract expression function indexToJsExpr(n, len, rule4msg) { - var v = parseInt(n, 10); + let v = parseInt(n, 10); // the usual situation: `$3`; MUST reference an rhs[] element or it will be considered an ERROR: if (v > 0) { if (v > len) { @@ -31351,35 +31367,33 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return ''; } + // options object { actionGroups, actionGroupValue, stateHasAction } is `this` for this function/callback: function buildProductionAction(handle) { - var i; - var aliased = handle.aliases, - rhs_i; + let aliased = handle.aliases; - var rhs = handle.handle; - var named_token_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$3}$`); + let rhs = handle.handle; + let named_token_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$3}$`); // semantic action specified - var label = [ + let label = [ 'case ', handle.id, ':', '\n /*! Production:: ', postprocessComment(handle.symbol), ' : ' ].concat(postprocessComment(rhs.map(function (sym) { // check if the symbol is a literal terminal, and if it is, quote it: if (sym && !self.nonterminals[sym] && !named_token_re.test(sym) && sym !== self.EOF) { return '"' + sym.replace(/["]/g, '\\"') + '"'; - } - else if (!sym) { + } else if (!sym) { sym = '%epsilon'; } return sym; })), ' */').join(''); - var action = preprocessActionCode(handle.action || ''); - var rule4msg = handle.symbol + ': ' + rhs.join(' '); + let action = preprocessActionCode(handle.action || ''); + let rule4msg = handle.symbol + ': ' + rhs.join(' '); assert__default['default'](typeof handle.id === 'number'); assert__default['default'](handle.id >= 0); - stateHasAction[handle.id] = true; + this.stateHasAction[handle.id] = true; // before anything else, replace direct symbol references, e.g. #NUMBER# when there's a %token NUMBER for your grammar. // This is done to prevent incorrect expansions where tokens are used in rules as RHS elements: we allow these to @@ -31394,9 +31408,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // replace named semantic values ($nonterminal) if (action.match(new XRegExp__default['default'](`(?:[$@#]|##)${ID_REGEX_BASE$3}`))) { - var count = {}, - names = {}, - donotalias = {}; + let count = {}; + let names = {}; + let donotalias = {}; // When the rule is fitted with aliases it doesn't mean that the action code MUST use those: // we therefor allow access to both the original (non)terminal and the alias. @@ -31427,9 +31441,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // as an explicit alias: adding auto-alias `e1` would then break the system, // while `e2` would be ambiguous from the human perspective as he *might* then // expect `e2` and `e3`. - var addName = function addName(s) { - var base = s.replace(/[0-9]+$/, ''); - var dna = donotalias[base]; + let addName = function addName(s, i) { + let base = s.replace(/[0-9]+$/, ''); + let dna = donotalias[base]; if (names[s]) { count[s]++; @@ -31450,28 +31464,28 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // register the alias/rule name when the real one ends with a number, e.g. `rule5` as // *blocking* the auto-aliasing process for the term of the same base, e.g. `rule`. // This will catch the `WORD[e1]` example above too, via `e1` --> `donotalias['e']` - var markBasename = function markBasename(s) { + let markBasename = function markBasename(s) { if (/[0-9]$/.test(s)) { s = s.replace(/[0-9]+$/, ''); donotalias[s] = true; } }; - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // mark both regular and aliased names, e.g., `id[alias1]` and `id1` - rhs_i = aliased[i]; + let rhs_i = aliased[i]; markBasename(rhs_i); if (rhs_i !== rhs[i]) { markBasename(rhs[i]); } } - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // check for aliased names, e.g., id[alias] - rhs_i = aliased[i]; - addName(rhs_i); + let rhs_i = aliased[i]; + addName(rhs_i, i); if (rhs_i !== rhs[i]) { - addName(rhs[i]); + addName(rhs[i], i); } } action = action.replace( @@ -31488,7 +31502,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; .replace(/\$\$/g, 'this.$') .replace(/@\$/g, 'this._$') .replace(/#\$/g, function (_) { - return provideSymbolAsSourcecode(symbol); + return provideSymbolAsSourcecode(handle.symbol); }) // replace semantic value references ($n) with stack value (stack[n]) .replace(/\$(-?\d+)\b/g, function (_, n) { @@ -31507,7 +31521,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }) // same as above for token ID references (#n) .replace(/#(-?\d+)\b/g, function (_, n) { - var i = parseInt(n, 10) - 1; + let i = parseInt(n, 10) - 1; if (!rhs[i]) { throw new Error(`invalid token location reference in action code for rule: "${rule4msg}" - location reference: "${_}"`); } @@ -31551,7 +31565,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // the action code: if some Smart Alec decides to code `this.$` instead of // `$$` it SHOULD NOT confuse the code analysis here! - var uses_$$ = analyzeFeatureUsage(action, /\bthis\.\$[^\w]/g, 0); // use includes assignment, not just read accesses! + let uses_$$ = analyzeFeatureUsage(action, /\bthis\.\$[^\w]/g, 0); // use includes assignment, not just read accesses! // the next check is very rough; we need the AST of the code to do better than this. function analyzeFeatureAssignmentBeforeUse(source, assignment_re, access_re) { @@ -31560,8 +31574,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // If no assignment can be found at all, we're probably looking at access-only // OR weird constructs we don't yet understand, in which case we play it safe. - var prelude = source; - var m = source.match(assignment_re); + let prelude = source; + let m = source.match(assignment_re); if (m) { // check the closure exists in the regex: m[1] is filled with its content: assert__default['default'](m[1] != null); @@ -31591,21 +31605,21 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return false; // assignment before access (or no usage and assignments at all!) } - var uses_$$_before_assignment = uses_$$ && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\.\$\s*=[^=>]/, /\bthis\.\$[^\w]/g); + let uses_$$_before_assignment = uses_$$ && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\.\$\s*=[^=>]/, /\bthis\.\$[^\w]/g); // ditto for location tracking, but only iff we use it at all: - var uses_$loc = false; - var uses_$loc_before_assignment = false; + let uses_$loc = false; + let uses_$loc_before_assignment = false; if (self.actionsUseLocationTracking) { uses_$loc = analyzeFeatureUsage(action, /\bthis\._\$[^\w]/g, 0); uses_$loc_before_assignment = uses_$loc && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\._\$\s*=[^=>]/, /\bthis\._\$[^\w]/g); } - var inject_default_value_action = (uses_$$_before_assignment || (self.actionsUseValueTracking && !uses_$$)); - var inject_default_loc_action = (uses_$loc_before_assignment || (self.actionsUseLocationTracking && !uses_$loc)); + let inject_default_value_action = (uses_$$_before_assignment || (self.actionsUseValueTracking && !uses_$$)); + let inject_default_loc_action = (uses_$loc_before_assignment || (self.actionsUseLocationTracking && !uses_$loc)); - var default_action = []; + let default_action = []; // Note: // @@ -31616,26 +31630,27 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // $$ = undefined; // $@ = undefined; // - var vmode = !inject_default_value_action ? "skip" : self.options.defaultActionMode[0]; - var lmode = !inject_default_loc_action ? "skip" : self.options.defaultActionMode[1]; + let vmode = !inject_default_value_action ? 'skip' : self.options.defaultActionMode[0]; + let lmode = !inject_default_loc_action ? 'skip' : self.options.defaultActionMode[1]; // check if there's no user action specified. Insert default action if it isn't. // first determine the actual number of terms in the production: - var rhs = handle.handle.slice(0); - var real_rhs_length = rhs.length; + let rhs_reduced_length = rhs.length; + let real_rhs_length = rhs.length; // strip away EOF terms at the end of the rule, ditto for epsilon terms: - if (rhs.length) { - switch (rhs[rhs.length - 1]) { + while (rhs_reduced_length) { + switch (rhs[rhs_reduced_length - 1]) { case '$end': - rhs.length--; - break; + rhs_reduced_length--; + continue; case '': // %epsilon - rhs.length--; - break; + rhs_reduced_length--; + continue; } + break; } // then we can choose what to do, depending on the number of terms in the production. @@ -31652,18 +31667,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // Ditto for location tracking default actions... // - switch (rhs.length) { + switch (rhs_reduced_length) { case 0: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; <-- but that would cause nondeterministic behaviour, so // we fall back to the default here! - case "ast": - case "none": - default_action.push("this.$ = undefined;"); + case 'ast': + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31672,22 +31687,22 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // an empty production has no location as there are no terms parsed. // ergo: we produce a zero-width location which points at the tail // end of the previous content: // @$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);"); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31698,19 +31713,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 1: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; // // WARNING: be careful with the ACCEPT rule as that one's production has - // rhs.length === 1 **BUT** has real_rhs_length === 2 as we have discarded + // rhs_reduced_length === 1 **BUT** has real_rhs_length === 2 as we have discarded // the `$end` term at the end! // Here we need to account for that magick though! - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // As we're looking at a production which has one(1) useful term, we can simply // reference-copy that one intom a fresh array, instead of `slice()`-ing it out // of the vstack. @@ -31719,14 +31734,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // WARNING/NOTE: as above, and ditto BTW for rule productions which end with // `EOF` as a last term: as we now construct an entire AST, we DO NOT include // those 'values' here! - default_action.push("this.$ = [yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "]];"); + default_action.push('this.$ = [yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ']];'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31735,23 +31750,23 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: // as we have a production length of 1 only, we can simply ref-copy @1: // @$ = @1; // // WARNING: same as above for the value copying: we may have discarded an `EOF` or `$end` term! - default_action.push("this._$ = yylstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this._$ = yylstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31762,29 +31777,29 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; default: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // - // WARNING: as with the situation further above where rhs.length === 1 after we + // WARNING: as with the situation further above where rhs_reduced_length === 1 after we // have got rid of a possible `EOF` or `$end` at the end of the production, // we again have to account for our trickery earlier and compensate the // action above: again we DO NOT include the value of the EOF/$end token in the // resulting array 'AST', hence our `slice()` end index may vary by one(1): - var end_offset = 1 - real_rhs_length + rhs.length; - default_action.push("this.$ = yyvstack.slice(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp" + /* CANNOT USE indexToJsExpr(rhs.length + 1, real_rhs_length, rule4msg) HERE! */ (end_offset === 0 ? "" : " + " + end_offset) + ");"); + let end_offset = 1 - real_rhs_length + rhs_reduced_length; + default_action.push('this.$ = yyvstack.slice(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp' + /* CANNOT USE indexToJsExpr(rhs_reduced_length + 1, real_rhs_length, rule4msg) HERE! */ (end_offset === 0 ? '' : ' + ' + end_offset) + ');'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31793,20 +31808,20 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: - // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs.length - 1}, yysp); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp);"); + // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs_reduced_length - 1}, yysp); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31819,16 +31834,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // comment/mark the default action chunk, if any, so we can simply observe // what is user code and what is generated by us in the final product: if (default_action.length > 0) { - var flags = [ - rhs.length, - self.actionsUseValueTracking ? "VT" : "-", - self.actionsUseValueAssignment ? "VA" : "-", - uses_$$ ? "VU" : "-", - uses_$$_before_assignment ? "VUbA" : "-", - self.actionsUseLocationTracking ? "LT" : "-", - self.actionsUseLocationAssignment ? "LA" : "-", - uses_$loc ? "LU" : "-", - uses_$loc_before_assignment ? "LUbA" : "-", + let flags = [ + rhs_reduced_length + '/' + real_rhs_length, + self.actionsUseValueTracking ? 'VT' : '-', + self.actionsUseValueAssignment ? 'VA' : '-', + uses_$$ ? 'VU' : '-', + uses_$$_before_assignment ? 'VUbA' : '-', + self.actionsUseLocationTracking ? 'LT' : '-', + self.actionsUseLocationAssignment ? 'LA' : '-', + uses_$loc ? 'LU' : '-', + uses_$loc_before_assignment ? 'LUbA' : '-' ].join(','); default_action.unshift(`// default action (generated by JISON mode ${self.options.defaultActionMode[0]}/${self.options.defaultActionMode[1]} :: ${flags}):`); @@ -31842,16 +31857,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; action = reindentCodeBlock(action, 4); - var actionHash = mkHashIndex(action); + let actionHash = mkHashIndex(action); // Delay running the postprocess (restore) process until we've done ALL macro expansions: //action = postprocessActionCode(action); - if (actionHash in actionGroups) { - actionGroups[actionHash].push(label); + if (actionHash in this.actionGroups) { + this.actionGroups[actionHash].push(label); } else { - actionGroups[actionHash] = [label]; - actionGroupValue[actionHash] = action; + this.actionGroups[actionHash] = [ label ]; + this.actionGroupValue[actionHash] = action; } } }; @@ -31871,7 +31886,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; //generator.trace.name = 'no_op_trace'; generator.warn = function warn() { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); Jison$1.print.call(null, args.join('')); }; @@ -31918,9 +31933,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // LR specific mixin class later on, so that we can have another // implementation/report for LL and PEG type grammars. - var rows = 0, cols = 0; - var colmarks = {}; - var i, j, len; + let rows = 0, cols = 0; + let colmarks = {}; + let i, j, len; for (i = 0, len = this.table.length; i < len; i++) { rows++; @@ -31931,8 +31946,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } } - var defrows = 0; - var rowmarks = {}; + let defrows = 0; + let rowmarks = {}; for (j in this.defaultActions) { if (!rowmarks[j]) { rowmarks[j] = true; @@ -31940,8 +31955,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } - var ntc = 0; - for (var nt in this.nonterminals) { + let ntc = 0; + for (let nt in this.nonterminals) { ntc++; } @@ -31960,14 +31975,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // --- START of debugTraceSrc chunk --- const debugTraceSrc = ` function debug_trace() { - "use strict"; - if (typeof Jison !== 'undefined' && Jison.print) { Jison.print.apply(null, arguments); } else if (typeof print !== 'undefined') { print.apply(null, arguments); } else if (typeof console !== 'undefined' && console.log) { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); args.unshift(''); // prevent \`%.\` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args console.log.apply(null, args); } @@ -31977,14 +31990,14 @@ function debug_trace() { // Generator debug mixin - var generatorDebug = { + const generatorDebug = { trace: (new Function('', debugTraceSrc + ` return debug_trace;`))(), beforeprocessGrammar: function () { this.trace('Processing grammar.'); }, afteraugmentGrammar: function () { - var trace = this.trace; + let trace = this.trace; trace('\nSymbols:\n'); each(this.symbols, function (sym, i) { trace(sym + '(' + i + ')'); @@ -31998,7 +32011,7 @@ function debug_trace() { /* * Mixin for common behaviors of lookahead parsers */ - var lookaheadMixin = {}; + let lookaheadMixin = {}; lookaheadMixin.computeLookaheads = function computeLookaheads() { if (this.DEBUG) { @@ -32012,11 +32025,11 @@ function debug_trace() { }; lookaheadMixin.displayFollowSets = function displayFollowSets() { - var self = this; - var symfollowdbg = {}; + let self = this; + let symfollowdbg = {}; this.productions.forEach(function Follow_prod_forEach_debugOut(production, k) { - var key = ['prod-', k, ': ', production.symbol, ' := ', production.handle.join(' ')].join(''); - var flw = '[' + self.nonterminals[production.symbol].follows.join('] [') + ']'; + let key = [ 'prod-', k, ': ', production.symbol, ' := ', production.handle.join(' ') ].join(''); + let flw = '[' + self.nonterminals[production.symbol].follows.join('] [') + ']'; if (!symfollowdbg[flw]) { symfollowdbg[flw] = {}; } @@ -32027,9 +32040,9 @@ function debug_trace() { symfollowdbg[flw][key]++; } }); - for (var l in symfollowdbg) { - var lst = []; - for (var k in symfollowdbg[l]) { + for (let l in symfollowdbg) { + let lst = []; + for (let k in symfollowdbg[l]) { lst.push(k); } self.trace('Symbol/Follows:\n ', lst.join('\n '), ' -->\n ', l); @@ -32038,10 +32051,10 @@ function debug_trace() { // calculate follow sets based on first and nullable lookaheadMixin.followSets = function followSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true; + let productions = this.productions; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { @@ -32050,23 +32063,23 @@ function debug_trace() { productions.forEach(function Follow_prod_forEach(production, k) { // q is used in Simple LALR algorithm determine follows in context - var q; - var ctx = !!self.go_; + let q; + let ctx = !!self.go_; - for (var i = 0, t; (t = production.handle[i]); ++i) { + for (let i = 0, t; (t = production.handle[i]); ++i) { if (!nonterminals[t]) continue; // for Simple LALR algorithm, self.go_ checks if if (ctx) { q = self.go_(production.symbol, production.handle.slice(0, i)); } - var bool = (!ctx || q === self.nterms_[t]); - var set; + let bool = (!ctx || q === self.nterms_[t]); + let set; if (i === production.handle.length - 1 && bool) { set = nonterminals[production.symbol].follows; } else { - var part = production.handle.slice(i + 1); + let part = production.handle.slice(i + 1); set = self.first(part); if (self.nullable(part) && bool) { @@ -32074,8 +32087,8 @@ function debug_trace() { set.push.apply(set, nonterminals[production.symbol].follows); } } - var follows = nonterminals[t].follows; - var oldcount = follows.length; + let follows = nonterminals[t].follows; + let oldcount = follows.length; follows = union(follows, set); if (oldcount !== follows.length) { cont = true; @@ -32097,8 +32110,8 @@ function debug_trace() { return []; // RHS } else if (symbol instanceof Array) { - var firsts = []; - for (var i = 0, t; (t = symbol[i]); ++i) { + let firsts = []; + for (let i = 0, t; (t = symbol[i]); ++i) { if (!this.nonterminals[t]) { if (firsts.indexOf(t) === -1) { firsts.push(t); @@ -32106,41 +32119,39 @@ function debug_trace() { } else { firsts = union(firsts, this.nonterminals[t].first); } - if (!this.nullable(t)) - break; + if (!this.nullable(t)) { break; } } return firsts; // terminal } else if (!this.nonterminals[symbol]) { - return [symbol]; + return [ symbol ]; // nonterminal - } else { - return this.nonterminals[symbol].first; } + return this.nonterminals[symbol].first; + }; // fixed-point calculation of FIRST sets lookaheadMixin.firstSets = function firstSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true, - symbol, firsts; + let productions = this.productions; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { cont = false; productions.forEach(function FirstSets_forEach(production, k) { - var firsts = self.first(production.handle); + let firsts = self.first(production.handle); if (firsts.length !== production.first.length) { production.first = firsts; cont = true; } }); - for (symbol in nonterminals) { - firsts = []; + for (let symbol in nonterminals) { + let firsts = []; nonterminals[symbol].productions.forEach(function FirstSets_forEachNonTerm(production) { firsts = union(firsts, production.first); }); @@ -32154,9 +32165,9 @@ function debug_trace() { // fixed-point calculation of NULLABLE lookaheadMixin.nullableSets = function nullableSets() { - var nonterminals = this.nonterminals, - self = this, - cont = true; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { @@ -32165,7 +32176,9 @@ function debug_trace() { // check if each production is nullable this.productions.forEach(function isEachProductionNullable(production, k) { if (!production.nullable) { - for (var i = 0, n = 0, t; (t = production.handle[i]); ++i) { + let i = 0; + let n = 0; + for (let t; (t = production.handle[i]); ++i) { if (self.nullable(t)) n++; } if (n === i) { // production is nullable if all tokens are nullable @@ -32175,9 +32188,9 @@ function debug_trace() { }); // check if each symbol is nullable - for (var symbol in nonterminals) { + for (let symbol in nonterminals) { if (!this.nullable(symbol)) { - for (var i = 0, production; (production = nonterminals[symbol].productions.item(i)); i++) { + for (let i = 0, production; (production = nonterminals[symbol].productions.item(i)); i++) { if (production.nullable) { nonterminals[symbol].nullable = cont = true; } @@ -32194,7 +32207,7 @@ function debug_trace() { return true; // RHS } else if (symbol instanceof Array) { - for (var i = 0, t; (t = symbol[i]); ++i) { + for (let i = 0, t; (t = symbol[i]); ++i) { if (!this.nullable(t)) { return false; } @@ -32204,14 +32217,14 @@ function debug_trace() { } else if (!this.nonterminals[symbol]) { return false; // nonterminal - } else { - return this.nonterminals[symbol].nullable; } + return this.nonterminals[symbol].nullable; + }; // lookahead debug mixin - var lookaheadDebug = { + const lookaheadDebug = { beforenullableSets: function () { this.trace('Computing Nullable sets.'); }, @@ -32222,7 +32235,7 @@ function debug_trace() { this.trace('Computing Follow sets.'); }, afterfollowSets: function () { - var trace = this.trace; + let trace = this.trace; trace('\nNonterminals:\n'); each(this.nonterminals, function (nt, t) { trace(nt.toString(), '\n'); @@ -32234,7 +32247,7 @@ function debug_trace() { /* * Mixin for common LR parser behavior */ - var lrGeneratorMixin = {}; + let lrGeneratorMixin = {}; // LR state machine actions: @@ -32287,16 +32300,16 @@ function debug_trace() { return e.id === this.id; }, handleToString: function () { - var handle = this.production.handle.slice(0); + let handle = this.production.handle.slice(0); handle[this.dotPosition] = '.' + (handle[this.dotPosition] || ''); return handle.join(' '); }, toString: function () { - var temp = this.production.handle.slice(0); + let temp = this.production.handle.slice(0); temp[this.dotPosition] = '.' + (temp[this.dotPosition] || ''); - var s = this.production.symbol + ' -> ' + temp.join(' '); - var padlen = Math.max(4, 40 - s.length); - var pad = new Array(padlen); + let s = this.production.symbol + ' -> ' + temp.join(' '); + let padlen = Math.max(4, 40 - s.length); + let pad = new Array(padlen); if (this.follows.length) { s += pad.join(' ') + '#lookaheads= [' + this.follows.join('] [') + ']'; pad = new Array(2); @@ -32309,7 +32322,7 @@ function debug_trace() { } }); - lrGeneratorMixin.ItemSet = Set.prototype.construct({ + lrGeneratorMixin.ItemSet = Set$1.prototype.construct({ afterconstructor: function () { this.reductions = []; this.goes = {}; @@ -32317,13 +32330,13 @@ function debug_trace() { this.shifts = false; this.inadequate = false; this.hash_ = {}; - for (var i = this._items.length - 1; i >= 0; i--) { + for (let i = this._items.length - 1; i >= 0; i--) { this.hash_[this._items[i].id] = true; //i; } }, concat: function concat(set) { - var a = set._items || set; - for (var i = a.length - 1; i >= 0; i--) { + let a = set._items || set; + for (let i = a.length - 1; i >= 0; i--) { this.hash_[a[i].id] = true; } this._items.push.apply(this._items, a); @@ -32337,31 +32350,31 @@ function debug_trace() { return this.hash_[item.id]; }, valueOf: function toValue() { - var v = this._items.map(function (a) { return a.id; }).sort().join('|'); + let v = this._items.map(function (a) { return a.id; }).sort().join('|'); this.valueOf = function valueOf_inner() { return v; }; return v; } }); lrGeneratorMixin.closureOperation = function closureOperation(itemSet) { - var closureSet = new this.ItemSet(); - var self = this; + let closureSet = new this.ItemSet(); + let self = this; - var set = itemSet, - itemQueue, - syms = {}; + let set = itemSet; + let itemQueue; + let syms = {}; do { - itemQueue = new Set(); + itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function CO_set_forEach(item) { - var symbol = item.markedSymbol; + let symbol = item.markedSymbol; // if token is a non-terminal, recursively add closures if (symbol && self.nonterminals[symbol]) { if (!syms[symbol]) { self.nonterminals[symbol].productions.forEach(function CO_nt_forEach(production) { - var newItem = new self.Item(production, 0); + let newItem = new self.Item(production, 0); if (!closureSet.contains(newItem)) { itemQueue.push(newItem); } @@ -32386,8 +32399,8 @@ function debug_trace() { }; lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) { - var gotoSet = new this.ItemSet(), - self = this; + let gotoSet = new this.ItemSet(); + let self = this; itemSet.forEach(function goto_forEach(item, n) { if (item.markedSymbol === symbol) { @@ -32402,14 +32415,14 @@ function debug_trace() { * Create unique set of item sets */ lrGeneratorMixin.canonicalCollection = function canonicalCollection() { - var item1 = new this.Item(this.productions[0], 0, [this.EOF]); - var firstStateNoClosure = new this.ItemSet(item1), - firstState = this.closureOperation(firstStateNoClosure), - states = new Set(firstState), - marked = 0, - self = this, - itemSet, - markedSymbols; + let item1 = new this.Item(this.productions[0], 0, [ this.EOF ]); + let firstStateNoClosure = new this.ItemSet(item1); + let firstState = this.closureOperation(firstStateNoClosure); + let states = new Set$1(firstState); + let marked = 0; + let self = this; + let itemSet; + let markedSymbols; states.has = {}; states.has[firstStateNoClosure.valueOf()] = 0; @@ -32431,8 +32444,8 @@ function debug_trace() { // Pushes a unique state into the queue. Some parsing algorithms may perform additional operations lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert(symbol, itemSet, states, stateNum) { - var g = this.gotoOperation(itemSet, symbol), - state = states.has[g.valueOf()]; + let g = this.gotoOperation(itemSet, symbol); + let state = states.has[g.valueOf()]; if (typeof state !== 'undefined') { itemSet.edges[symbol] = state; // store goto transition for table @@ -32447,36 +32460,36 @@ function debug_trace() { } itemSet.edges[symbol] = states.size(); // store goto transition for table states.push(g); - g.predecessors[symbol] = [stateNum]; + g.predecessors[symbol] = [ stateNum ]; } } }; lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { - var states = [], - nonterminals = this.nonterminals, - operators = this.operators, - conflictedStates = {}, // set of [state, token] tuples - self = this; + let states = []; + let nonterminals = this.nonterminals; + let operators = this.operators; + let conflictedStates = {}; // set of [state, token] tuples + let self = this; // for each item set itemSets.forEach(function parseTableItem(itemSet, k) { k = +k; - var state = states[k] = {}; - var action, stackSymbol; + let state = states[k] = {}; + let action, stackSymbol; // set shift and goto actions for (stackSymbol in itemSet.edges) { itemSet.forEach(function findShiftAndGotoActions(item, j) { // find shift and goto actions if (item.markedSymbol === stackSymbol) { - var gotoState = itemSet.edges[stackSymbol]; + let gotoState = itemSet.edges[stackSymbol]; assert__default['default'](gotoState); if (nonterminals[stackSymbol]) { // store state to go to after a reduce state[self.symbols_[stackSymbol]] = gotoState; } else { - state[self.symbols_[stackSymbol]] = [SHIFT, gotoState]; + state[self.symbols_[stackSymbol]] = [ SHIFT, gotoState ]; } } }); @@ -32486,25 +32499,25 @@ function debug_trace() { itemSet.forEach(function setAcceptAction(item, j) { if (item.markedSymbol === self.EOF) { // accept - state[self.symbols_[self.EOF]] = [ACCEPT]; + state[self.symbols_[self.EOF]] = [ ACCEPT ]; } }); - var allterms = self.lookAheads ? false : self.terminals; + let allterms = self.lookAheads ? false : self.terminals; // set reductions and resolve potential conflicts itemSet.reductions.forEach(function calcReduction(item, j) { // if parser uses lookahead, only enumerate those terminals - var terminals = allterms || self.lookAheads(itemSet, item); + let terminals = allterms || self.lookAheads(itemSet, item); terminals.forEach(function (stackSymbol) { action = state[self.symbols_[stackSymbol]]; - var op = operators[stackSymbol]; + let op = operators[stackSymbol]; // Reading a terminal and current position is at the end of a production, try to reduce if (action) { - var sol = resolveConflict(item.production, op, [REDUCE, item.production.id], action[0] instanceof Array ? action[0] : action); - self.resolutions.push([k, stackSymbol, sol]); + let sol = resolveConflict(item.production, op, [ REDUCE, item.production.id ], action[0] instanceof Array ? action[0] : action); + self.resolutions.push([ k, stackSymbol, sol ]); if (sol.bydefault) { self.conflicts++; @@ -32542,7 +32555,7 @@ function debug_trace() { if (self.options.noDefaultResolve) { if (!(action[0] instanceof Array)) { - action = [action]; + action = [ action ]; } action.push(sol.r); } @@ -32550,7 +32563,7 @@ function debug_trace() { action = sol.action; } } else { - action = [REDUCE, item.production.id]; + action = [ REDUCE, item.production.id ]; } if (action && action.length) { state[self.symbols_[stackSymbol]] = action; @@ -32601,25 +32614,25 @@ function debug_trace() { // only this time we are careful about the TERROR symbol as a state carrying that one // is an explicitly encoded error recovery rule and should remain as-is. function findDefaults(states, hasErrorRecovery) { - var defaults = {}; + let defaults = {}; states.forEach(function (state, k) { - var act, sym, st; - var i = 0; - var gotos = {}; + let act; + let i = 0; + let gotos = {}; - for (sym in state) { + for (let sym in state) { assert__default['default']({}.hasOwnProperty.call(state, sym)); // it this isn't true, the last part of this function won't work! // keep state rows where there's an error recovery state: if (sym === 2 /* TERROR */) { return; } - st = state[sym]; + let st = state[sym]; if (typeof st !== 'number') { if (st[0] !== REDUCE) { // not a reduce action: forget about this row! return; } - var go = st[1]; + let go = st[1]; if (!gotos[go]) { gotos[go] = true; i++; @@ -32647,8 +32660,8 @@ function debug_trace() { // ... hence we only nuke these table entries (as that makes for a smaller table --> smaller parser file) // when there's no error recovery code included in the generated parser: if (!hasErrorRecovery) { - for (sym in state) { - st = state[sym]; + for (let sym in state) { + let st = state[sym]; if (typeof st !== 'number') { delete state[sym]; } @@ -32663,9 +32676,7 @@ function debug_trace() { // Remove all NONASSOC state transitions from the generated table now that we don't need them any longer function cleanupTable(table) { table.forEach(function (state, k) { - var symbol; - - for (symbol in state) { + for (let symbol in state) { if (state[symbol] === NONASSOC) { delete state[symbol]; } @@ -32675,16 +32686,16 @@ function debug_trace() { // resolves shift-reduce and reduce-reduce conflicts function resolveConflict(production, op, reduce, shift) { - var sln = { - production: production, - operator: op, - r: reduce, - s: shift, - - msg: null, - action: null, - bydefault: false - }; + let sln = { + production: production, + operator: op, + r: reduce, + s: shift, + + msg: null, + action: null, + bydefault: false + }; if (shift[0] === REDUCE) { sln.msg = 'Resolved R/R conflict: use first production declared in grammar.'; @@ -32722,7 +32733,7 @@ function debug_trace() { /* * Mixin for common LR/LL/*any* parser behavior */ - var generatorMixin = {}; + let generatorMixin = {}; // internal helper function: generatorMixin.__prepareOptions = function parser___prepare_Options(opt) { @@ -32736,7 +32747,7 @@ function debug_trace() { // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*?[a-zA-Z0-9_$]$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "parser" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "parser" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else if (opt.warn_cb) { @@ -32752,7 +32763,7 @@ function debug_trace() { }; generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComment() { - var out = ` + let out = ` /* parser generated by jison ${version$2} */ /* @@ -32916,9 +32927,9 @@ function debug_trace() { * Produces a new errorInfo 'hash object' which can be passed into \`parseError()\`. * See it's use in this parser kernel in many places; example usage: * - * var infoObj = parser.constructParseErrorInfo('fail!', null, + * let infoObj = parser.constructParseErrorInfo('fail!', null, * parser.collect_expected_token_set(state), true); - * var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); + * let retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); * * originalParseError: function(str, hash, ExceptionClass), * The basic \`parseError\` handler provided by JISON. @@ -33120,212 +33131,7 @@ function debug_trace() { * flex: boolean * optional: \`true\` ==> flex-like lexing behaviour where the rules are tested * exhaustively to find the longest match. - * backtrack_lexer: boolean (⅏ 센 ⅊ ⁖ ⁘ ⁙ ⁚ ⁛ ⁜ ⁝ ⁞ † ‡ - a⯈b - ∀ ∁ ∂ ∃ ∄ ∅ ∆ ∇ ∈ ∉ ∊ ∋ ∌ ∍ ∎ ∏ -U+221x ∐ ∑ − ∓ ∔ ∕ ∖ ∗ ∘ ∙ √ ∛ ∜ ∝ ∞ ∟ -U+222x ∠ ∡ ∢ ∣ ∤ ∥ ∦ ∧ ∨ ∩ ∪ ∫ ∬ ∭ ∮ ∯ -U+223x ∰ ∱ ∲ ∳ ∴ ∵ ∶ ∷ ∸ ∹ ∺ ∻ ∼ ∽ ∾ ∿ -U+224x ≀ ≁ ≂ ≃ ≄ ≅ ≆ ≇ ≈ ≉ ≊ ≋ ≌ ≍ ≎ ≏ -U+225x ≐ ≑ ≒ ≓ ≔ ≕ ≖ ≗ ≘ ≙ ≚ ≛ ≜ ≝ ≞ ≟ -U+226x ≠ ≡ ≢ ≣ ≤ ≥ ≦ ≧ ≨ ≩ ≪ ≫ ≬ ≭ ≮ ≯ -U+227x ≰ ≱ ≲ ≳ ≴ ≵ ≶ ≷ ≸ ≹ ≺ ≻ ≼ ≽ ≾ ≿ -U+228x ⊀ ⊁ ⊂ ⊃ ⊄ ⊅ ⊆ ⊇ ⊈ ⊉ ⊊ ⊋ ⊌ ⊍ ⊎ ⊏ -U+229x ⊐ ⊑ ⊒ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊜ ⊝ ⊞ ⊟ -U+22Ax ⊠ ⊡ ⊢ ⊣ ⊤ ⊥ ⊦ ⊧ ⊨ ⊩ ⊪ ⊫ ⊬ ⊭ ⊮ ⊯ -U+22Bx ⊰ ⊱ ⊲ ⊳ ⊴ ⊵ ⊶ ⊷ ⊸ ⊹ ⊺ ⊻ ⊼ ⊽ ⊾ ⊿ -U+22Cx ⋀ ⋁ ⋂ ⋃ ⋄ ⋅ ⋆ ⋇ ⋈ ⋉ ⋊ ⋋ ⋌ ⋍ ⋎ ⋏ -U+22Dx ⋐ ⋑ ⋒ ⋓ ⋔ ⋕ ⋖ ⋗ ⋘ ⋙ ⋚ ⋛ ⋜ ⋝ ⋞ ⋟ -U+22Ex ⋠ ⋡ ⋢ ⋣ ⋤ ⋥ ⋦ ⋧ ⋨ ⋩ ⋪ ⋫ ⋬ ⋭ ⋮ ⋯ -U+22Fx ⋰ ⋱ ⋲ ⋳ ⋴ ⋵ ⋶ ⋷ ⋸ ⋹ ⋺ ⋻ ⋼ ⋽ ⋾ ⋿) -U+230x ⌀ ⌁ ⌂ ⌃ ⌄ ⌅ ⌆ ⌇ ⌈ ⌉ ⌊ ⌋ ⌌ ⌍ ⌎ ⌏ -U+231x ⌐ ⌑ ⌒ ⌓ ⌔ ⌕ ⌖ ⌗ ⌘ ⌙ ⌚ ⌛ ⌜ ⌝ ⌞ ⌟ -U+232x ⌠ ⌡ ⌢ ⌣ ⌤ ⌥ ⌦ ⌧ ⌨ 〈 〉 ⌫ ⌬ ⌭ ⌮ ⌯ -U+233x ⌰ ⌱ ⌲ ⌳ ⌴ ⌵ ⌶ ⌷ ⌸ ⌹ ⌺ ⌻ ⌼ ⌽ ⌾ ⌿ -U+234x ⍀ ⍁ ⍂ ⍃ ⍄ ⍅ ⍆ ⍇ ⍈ ⍉ ⍊ ⍋ ⍌ ⍍ ⍎ ⍏ -U+235x ⍐ ⍑ ⍒ ⍓ ⍔ ⍕ ⍖ ⍗ ⍘ ⍙ ⍚ ⍛ ⍜ ⍝ ⍞ ⍟ -U+236x ⍠ ⍡ ⍢ ⍣ ⍤ ⍥ ⍦ ⍧ ⍨ ⍩ ⍪ ⍫ ⍬ ⍭ ⍮ ⍯ -U+237x ⍰ ⍱ ⍲ ⍳ ⍴ ⍵ ⍶ ⍷ ⍸ ⍹ ⍺ ⍻ ⍼ ⍽ ⍾ ⍿ -U+238x ⎀ ⎁ ⎂ ⎃ ⎄ ⎅ ⎆ ⎇ ⎈ ⎉ ⎊ ⎋ ⎌ ⎍ ⎎ ⎏ -U+239x ⎐ ⎑ ⎒ ⎓ ⎔ ⎕ ⎖ ⎗ ⎘ ⎙ ⎚ ⎛ ⎜ ⎝ ⎞ ⎟ -U+23Ax ⎠ ⎡ ⎢ ⎣ ⎤ ⎥ ⎦ ⎧ ⎨ ⎩ ⎪ ⎫ ⎬ ⎭ ⎮ ⎯ -U+23Bx ⎰ ⎱ ⎲ ⎳ ⎴ ⎵ ⎶ ⎷ ⎸ ⎹ ⎺ ⎻ ⎼ ⎽ ⎾ ⎿ -U+23Cx ⏀ ⏁ ⏂ ⏃ ⏄ ⏅ ⏆ ⏇ ⏈ ⏉ ⏊ ⏋ ⏌ ⏍ ⏎ ⏏ -U+23Dx ⏐ ⏑ ⏒ ⏓ ⏔ ⏕ ⏖ ⏗ ⏘ ⏙ ⏚ ⏛ ⏜ ⏝ ⏞ ⏟ -U+23Ex ⏠ ⏡ ⏢ ⏣ ⏤ ⏥ ⏦ ⏧ ⏨ ⏩ ⏪ ⏫ ⏬ ⏭ ⏮ ⏯ -U+23Fx ⏰ ⏱ ⏲ ⏳ ⏴ ⏵ ⏶ ⏷ ⏸ ⏹ ⏺ ⏻ ⏼ ⏽ ⏾ ⏿ - -U+260x ☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☎ ☏ -U+261x ☐ ☑ ☒ ☓ ☔ ☕ ☖ ☗ ☘ ☙ ☚ ☛ ☜ ☝ ☞ ☟ -U+262x ☠ ☡ ☢ ☣ ☤ ☥ ☦ ☧ ☨ ☩ ☪ ☫ ☬ ☭ ☮ ☯ -U+263x ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷ ☸ ☹ ☺ ☻ ☼ ☽ ☾ ☿ -U+264x ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇ ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ -U+265x ♐ ♑ ♒ ♓ ♔ ♕ ♖ ♗ ♘ ♙ ♚ ♛ ♜ ♝ ♞ ♟ -U+266x ♠ ♡ ♢ ♣ ♤ ♥ ♦ ♧ ♨ ♩ ♪ ♫ ♬ ♭ ♮ ♯ -U+267x ♰ ♱ ♲ ♳ ♴ ♵ ♶ ♷ ♸ ♹ ♺ ♻ ♼ ♽ ♾ ♿ -U+268x ⚀ ⚁ ⚂ ⚃ ⚄ ⚅ ⚆ ⚇ ⚈ ⚉ ⚊ ⚋ ⚌ ⚍ ⚎ ⚏ -U+269x ⚐ ⚑ ⚒ ⚓ ⚔ ⚕ ⚖ ⚗ ⚘ ⚙ ⚚ ⚛ ⚜ ⚝ ⚞ ⚟ -U+26Ax ⚠ ⚡ ⚢ ⚣ ⚤ ⚥ ⚦ ⚧ ⚨ ⚩ ⚪ ⚫ ⚬ ⚭ ⚮ ⚯ -U+26Bx ⚰ ⚱ ⚲ ⚳ ⚴ ⚵ ⚶ ⚷ ⚸ ⚹ ⚺ ⚻ ⚼ ⚽ ⚾ ⚿ -U+26Cx ⛀ ⛁ ⛂ ⛃ ⛄ ⛅ ⛆ ⛇ ⛈ ⛉ ⛊ ⛋ ⛌ ⛍ ⛎ ⛏ -U+26Dx ⛐ ⛑ ⛒ ⛓ ⛔ ⛕ ⛖ ⛗ ⛘ ⛙ ⛚ ⛛ ⛜ ⛝ ⛞ ⛟ -U+26Ex ⛠ ⛡ ⛢ ⛣ ⛤ ⛥ ⛦ ⛧ ⛨ ⛩ ⛪ ⛫ ⛬ ⛭ ⛮ ⛯ -U+26Fx ⛰ ⛱ ⛲ ⛳ ⛴ ⛵ ⛶ ⛷ ⛸ ⛹ ⛺ ⛻ ⛼ ⛽ ⛾ ⛿ - - ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ☛ ☞ ✌ ✍ ✎ ✏ -✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -✠ ✡ ✢ ✣ ✤ ✥ ✦ ✧ ★ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ● ❍ ■ ❏ -☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ❐ ❑ ❒ ▲ ▼ ◆ ❖ -◗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ - -U+270x ✀ ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ✊ ✋ ✌ ✍ ✎ ✏ -U+271x ✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -U+272x ✠ ✡ ✢ ✣ a✤b a✥b a✦b a✧b ✨ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -U+273x ✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -U+274x ❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ❌ ❍ ❎ ❏ -U+275x ❐ ❑ ❒ ❓ ❔ ❕ ❖ ❗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ ❟ -U+276x ❠ ❡ ❢ ❣ ❤ ❥ ❦ ❧ ❨ ❩ ❪ ❫ ❬ ❭ ❮ a❯b -U+277x ❰ ❱ ❲ ❳ ❴ ❵ ❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ ❾ ❿ -U+278x ➀ ➁ ➂ ➃ ➄ ➅ ➆ ➇ ➈ ➉ ➊ ➋ ➌ ➍ ➎ ➏ -U+279x ➐ ➑ ➒ ➓ ➔ ➕ ➖ ➗ ➘ ➙ ➚ ➛ ➜ ➝ ➞ ➟ -U+27Ax ➠ ➡ ➢ ➣ ➤ ➥ ➦ ➧ a➨b ➩ ➪ ➫ ➬ ➭ ➮ ➯ -U+27Bx ➰ a➱b ➲ ➳ ➴ ➵ ➶ ➷ ➸ ➹ ➺ ➻ ➼ ➽ ➾ ➿ - -U+2580 ▀ Upper half block -U+2581 ▁ Lower one eighth block -U+2582 ▂ Lower one quarter block -U+2583 ▃ Lower three eighths block -U+2584 ▄ Lower half block -U+2585 ▅ Lower five eighths block -U+2586 ▆ Lower three quarters block -U+2587 ▇ Lower seven eighths block -U+2588 █ Full block -U+2589 ▉ Left seven eighths block -U+258A ▊ Left three quarters block -U+258B ▋ Left five eighths block -U+258C ▌ Left half block -U+258D ▍ Left three eighths block -U+258E ▎ Left one quarter block -U+258F ▏ Left one eighth block -U+2590 ▐ Right half block -U+2591 ░ Light shade -U+2592 ▒ Medium shade -U+2593 ▓ Dark shade -U+2594 ▔ Upper one eighth block -U+2595 ▕ Right one eighth block -U+2596 ▖ Quadrant lower left -U+2597 ▗ Quadrant lower right -U+2598 ▘ Quadrant upper left -U+2599 ▙ Quadrant upper left and lower left and lower right -U+259A ▚ Quadrant upper left and lower right -U+259B ▛ Quadrant upper left and upper right and lower left -U+259C ▜ Quadrant upper left and upper right and lower right -U+259D ▝ Quadrant upper right -U+259E ▞ Quadrant upper right and lower left -U+259F ▟ Quadrant upper right and lower left and lower right -Geometric Shapes -Main articles: Geometric Shapes (Unicode block) and Geometric Shapes Extended (Unicode block) -[hide]Code Glyph Description -U+25A0 ■ Black square -U+25A1 □ White square -U+25A2 ▢ White square with rounded corners -U+25A3 ▣ White square containing small black square -U+25A4 ▤ Square with horizontal fill -U+25A5 ▥ Square with vertical fill -U+25A6 ▦ Square with orthogonal crosshatch fill -U+25A7 ▧ Square with upper left to lower right fill -U+25A8 ▨ Square with upper right to lower left fill -U+25A9 ▩ Square with diagonal crosshatch fill -U+25AA ▪ Black small square -U+25AB ▫ White small square -U+25AC ▬ Black rectangle -U+25AD ▭ White rectangle -U+25AE ▮ Black vertical rectangle -U+25AF ▯ White vertical rectangle -U+25B0 ▰ Black parallelogram -U+25B1 ▱ White parallelogram -U+25B2 ▲ Black up-pointing triangle -U+25B3 △ White up-pointing triangle -U+25B4 ▴ Black up-pointing small triangle -U+25B5 ▵ White up-pointing small triangle -U+25B6 ▶ Black right-pointing triangle -U+25B7 ▷ White right-pointing triangle -U+25B8 ▸ Black right-pointing small triangle -U+25B9 ▹ White right-pointing small triangle -U+25BA ► Black right-pointing pointer -U+25BB ▻ White right-pointing pointer -U+25BC ▼ Black down-pointing triangle -U+25BD ▽ White down-pointing triangle -U+25BE ▾ Black down-pointing small triangle -U+25BF ▿ White down-pointing small triangle -U+25C0 ◀ Black left-pointing triangle -U+25C1 ◁ White left-pointing triangle -U+25C2 ◂ Black left-pointing small triangle -U+25C3 ◃ White left-pointing small triangle -U+25C4 ◄ Black left-pointing pointer -U+25C5 ◅ White left-pointing pointer -U+25C6 ◆ Black diamond -U+25C7 ◇ White diamond -U+25C8 ◈ White diamond containing small black diamond -U+25C9 ◉ Fisheye -U+25CA ◊ Lozenge -U+25CB ○ White circle -U+25CC ◌ Dotted circle -U+25CD ◍ Circle with vertical fill -U+25CE ◎ Bullseye -U+25CF ● Black circle -U+25D0 ◐ Circle with left half black -U+25D1 ◑ Circle with right half black -U+25D2 ◒ Circle with lower half black -U+25D3 ◓ Circle with upper half black -U+25D4 ◔ Circle with upper right quadrant black -U+25D5 ◕ Circle with all but upper left quadrant black -U+25D6 ◖ Left half circle black -U+25D7 ◗ Right half black circle -U+25D8 ◘ Inverse bullet -U+25D9 ◙ Inverse white circle -U+25DA ◚ Upper half inverse white circle -U+25DB ◛ Lower half inverse white circle -U+25DC ◜ Upper left quadrant circular arc -U+25DD ◝ Upper right quadrant circular arc -U+25DE ◞ Lower right quadrant circular arc -U+25DF ◟ Lower left quadrant circular arc -U+25E0 ◠ Upper half circle -U+25E1 ◡ Lower half circle -U+25E2 ◢ Black lower right triangle -U+25E3 ◣ Black lower left triangle -U+25E4 ◤ Black upper left triangle -U+25E5 ◥ Black upper right triangle -U+25E6 ◦ White bullet -U+25E7 ◧ Square with left half black -U+25E8 ◨ Square with right half black -U+25E9 ◩ Square with upper left diagonal half black -U+25EA ◪ Square with lower right diagonal half black -U+25EB ◫ White square with vertical bisecting line -U+25EC ◬ White up-pointing triangle with dot -U+25ED ◭ Up-pointing triangle with left half black -U+25EE ◮ Up-pointing triangle with right half black -U+25EF ◯ Large circle -U+25F0 ◰ White square with upper left quadrant -U+25F1 ◱ White square with lower left quadrant -U+25F2 ◲ White square with lower right quadrant -U+25F3 ◳ White square with upper right quadrant -U+25F4 ◴ White circle with upper left quadrant -U+25F5 ◵ White circle with lower left quadrant -U+25F6 ◶ White circle with lower right quadrant -U+25F7 ◷ White circle with upper right quadrant -U+25F8 ◸ Upper left triangle -U+25F9 ◹ Upper right triangle -U+25FA ◺ Lower-left triangle -U+25FB ◻ White medium square -U+25FC ◼ Black medium square -U+25FD ◽ White medium small square -U+25FE ◾ Black medium small square -U+25FF ◿ Lower right triangle - - + * backtrack_lexer: boolean * optional: \`true\` ==> lexer regexes are tested in order and for invoked; * the lexer terminates the scan when a token is returned by the action code. * xregexp: boolean @@ -33342,7 +33148,7 @@ U+25FF ◿ Lower right triangle generatorMixin.generate = function parser_generate(opt) { opt = this.__prepareOptions(opt); - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -33368,19 +33174,19 @@ U+25FF ◿ Lower right triangle generatorMixin.generateAMDModule = function generateAMDModule(opt) { opt = this.__prepareOptions(opt); - var module = this.generateModule_(); - var out = [ + let module = this.generateModule_(); + let out = [ this.generateGenericHeaderComment(), '', 'define(function (require) {', module.initCode, module.commonCode, '', - 'var parser = ' + module.moduleCode, + 'let parser = ' + module.moduleCode, module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(lexSrc); out.push('parser.lexer = lexer;'); @@ -33388,7 +33194,7 @@ U+25FF ◿ Lower right triangle out.push('', module.moduleInclude, '', 'return parser;'); out.push('});'); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; }; @@ -33396,35 +33202,35 @@ U+25FF ◿ Lower right triangle lrGeneratorMixin.generateESModule = function generateESModule(opt) { opt = this.__prepareOptions(opt); - var module = this.generateModule_(); - var out = [ + let module = this.generateModule_(); + let out = [ this.generateGenericHeaderComment(), '', module.initCode, module.commonCode, '', - 'var parser = ' + module.moduleCode, - module.modulePostlude, + 'let parser = ' + module.moduleCode, + module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(this.lexer.generateModule()); out.push('parser.lexer = lexer;'); } out.push('', module.moduleInclude, ''); - var exportMain = ''; - var invokeMain = ''; + let exportMain = ''; + let invokeMain = ''; if (!opt.noMain) { - var moduleNameAsCode = String(opt.moduleMain || commonJsMain); - var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); + let moduleNameAsCode = String(opt.moduleMain || commonJsMain); + let moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); out.push(rmCommonWS$5` ${moduleImportsAsCode} - var yymain = ${moduleNameAsCode.trim()}; + let yymain = ${moduleNameAsCode.trim()}; function yyExecMain() { yymain(process.argv.slice(1)); @@ -33460,7 +33266,7 @@ U+25FF ◿ Lower right triangle }; `); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; }; @@ -33468,11 +33274,11 @@ U+25FF ◿ Lower right triangle generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { opt = this.__prepareOptions(opt); - var moduleName = opt.moduleName; - var main = ''; + let moduleName = opt.moduleName; + let main = ''; if (!opt.noMain) { - var moduleNameAsCode = String(opt.moduleMain || commonJsMain); - var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); + let moduleNameAsCode = String(opt.moduleMain || commonJsMain); + let moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); main = rmCommonWS$5` @@ -33487,7 +33293,7 @@ U+25FF ◿ Lower right triangle } `; } - var out = this.generateModule(opt) + + let out = this.generateModule(opt) + rmCommonWS$5` @@ -33508,17 +33314,16 @@ U+25FF ◿ Lower right triangle generatorMixin.generateModule = function generateModule(opt) { opt = this.__prepareOptions(opt); - var moduleName = opt.moduleName; - var out = this.generateGenericHeaderComment(); + let moduleName = opt.moduleName; + let out = this.generateGenericHeaderComment(); - var self = this; + let self = this; function _generateNamespace(namespaces, previousNamespace, callback) { - var subModuleName = namespaces.shift(); + let subModuleName = namespaces.shift(); if (subModuleName != null) { - var moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; + let moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; if (namespaces.length > 0) { - return 'var ' + subModuleName + ';\n' - + '(function (' + subModuleName + ') {\n' + return '(function (' + subModuleName + ') {\n' + _generateNamespace(namespaces, subModuleName, callback) + '\n})(' + subModuleName + (previousNamespace == null ? '' : ' = ' + moduleName) + ' || (' + moduleName + ' = {}));\n'; } @@ -33527,14 +33332,14 @@ U+25FF ◿ Lower right triangle return ''; } - var sourceCodeDef = self.generateModuleExpr(); + let sourceCodeDef = self.generateModuleExpr(); out += ` ${sourceCodeDef.init} `; out += _generateNamespace(moduleName.split('.'), null, function _generateNamespace_cb(moduleName) { - var name = (moduleName.match(/\./) ? moduleName : 'var ' + moduleName); + let name = (moduleName.match(/\./) ? moduleName : 'let ' + moduleName); return ` ${name} = ${sourceCodeDef.src} `; @@ -33546,24 +33351,23 @@ U+25FF ◿ Lower right triangle generatorMixin.generateModuleExpr = function generateModuleExpr() { - var out; - var opt = this.__prepareOptions(); - var module = this.generateModule_(); + let opt = this.__prepareOptions(); + let module = this.generateModule_(); - out = [ + let out = [ '(function () {', module.commonCode, '', - 'var parser = ' + module.moduleCode, - module.modulePostlude, + 'let parser = ' + module.moduleCode, + module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(lexSrc); out.push('parser.lexer = lexer;'); } - out = out.concat(['', + out = out.concat([ '', module.moduleInclude, '', 'function Parser() {', @@ -33576,7 +33380,7 @@ U+25FF ◿ Lower right triangle '})();' ]); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return { @@ -33586,7 +33390,7 @@ U+25FF ◿ Lower right triangle }; function removeUnusedKernelFeatures(parseFn, info) { - var actionFn = info.performAction; + let actionFn = info.performAction; if (info.actionsAreAllDefault) { // in this case, there's no need to call the parseAction function at all: @@ -33628,7 +33432,7 @@ U+25FF ◿ Lower right triangle // if (typeof lexer.yyleng === 'undefined') { // lexer.yyleng = 0; // } - // var yyleng; + // let yyleng; // ... parseFn = parseFn @@ -33647,7 +33451,7 @@ U+25FF ◿ Lower right triangle // remove: // - // var yylineno; + // let yylineno; // ... parseFn = parseFn @@ -33702,7 +33506,7 @@ U+25FF ◿ Lower right triangle // remove: // - // var yyloc = lexer.yylloc; + // let yyloc = lexer.yylloc; // lstack[sp] = yyloc; // ... // lstack[sp] = copy_yylloc(lexer.yylloc); @@ -33742,11 +33546,11 @@ U+25FF ◿ Lower right triangle // } // // and - // + // // if (sp >= 0 && typeof vstack[sp] !== 'undefined') { // retval = vstack[sp]; // } - // + // // but keep the yyval declaration as either location tracking MAY // still be employed by the grammar OR the grammar uses advanced // code which uses `yyval` as a run-time store which carries data @@ -33792,13 +33596,13 @@ U+25FF ◿ Lower right triangle if (info.actionsAreAllDefault) { // remove // - // var yyval = { + // let yyval = { // $: true, // _$: undefined, // yy: sharedState_yy // }; parseFn = parseFn - .replace(/\s+var yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); + .replace(/\s+let yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); } } @@ -33813,10 +33617,14 @@ U+25FF ◿ Lower right triangle // remove: // - // var yydebug = false; + // let yydebug = false; // ... and delete yydebug function definition ... // ... // if (yydebug) yydebug(...); + // ... + // if (yydebug) { + // yydebug(...); + // } // // and // @@ -33827,9 +33635,10 @@ U+25FF ◿ Lower right triangle parseFn = parseFn - .replace(/\s+var yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') - // strip multi-line `if (debug) yydebug(..., {...});` statements + .replace(/\s+let yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') + // strip multi-line `if (debug) { yydebug(..., {...}); }` statements // also strip simple yet possibly multi-line `if (debug) yydebug('...');` statements + .replace(/\n\s+if\s+\(yydebug\)\s+\{[\r\n]+\s+yydebug\([^]+?}\);[\s\r\n]+}\s*/g, '\n\n\n\n\n\n\n\n\n') .replace(/\n\s+if\s+\(yydebug\)\s+yydebug\([^]+?['}]\);[^\r\n]*?/g, '\n\n\n\n\n\n\n\n\n') // strip single-line `yydebug(...);` statements .replace(/^.*?\byydebug\b[^;]+?\);[^\r\n]*?$/gm, '') @@ -33914,8 +33723,8 @@ U+25FF ◿ Lower right triangle */ parseFn = parseFn .replace(/\s+try \{([\s\r\n]+this\.__reentrant_call_depth[\s\S]+?)\} catch \(ex\) \{[\s\S]+?\} finally \{([^]+?)\}\s+\/\/\s+\/finally/, function replace_noTryCatch(m, p1, p2) { - p1 = p1.replace(/^ /mg, ' '); - p2 = p2.replace(/^ /mg, ' '); + p1 = p1.replace(/^ {8}/mg, ' '); + p2 = p2.replace(/^ {8}/mg, ' '); return '\n' + p1 + '\n // ... AND FINALLY ...\n' + p2; }) .replace(/^[^\n]+\b__reentrant_call_depth\b[^\n]+$/gm, '\n'); @@ -33973,29 +33782,29 @@ U+25FF ◿ Lower right triangle // // https://github.com/zaach/jison/pull/332 function expandParseArguments(parseFn, self) { - var arglist = self.parseParams; + let arglist = self.parseParams; if (!arglist || arglist.length === 0) { parseFn = parseFn.replace(/, parseParams\b/g, ''); parseFn = parseFn.replace(/\bparseParams\b/g, ''); - parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers:\s+parseParamsAsMembers\b/g, ''); + parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers\b/g, ''); } else { parseFn = parseFn.replace(/, parseParams\b/g, ', ' + arglist.join(', ')); parseFn = parseFn.replace(/\bparseParams\b/g, arglist.join(', ')); - parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers:\s+parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { - var s = ','; + parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { + let s = ','; // determine longest name of the bunch (for formatting the generated code) - var max_k_len = 0; - for (var i = 0, len = arglist.length; i < len; i++) { - var k = arglist[i]; + let max_k_len = 0; + for (let i = 0, len = arglist.length; i < len; i++) { + let k = arglist[i]; max_k_len = Math.max(max_k_len, k.length); } - var wsi2 = (new Array(max_k_len + 1)).join(' '); + let 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 i = 0, len = arglist.length; i < len; i++) { - var k = arglist[i]; + for (let i = 0, len = arglist.length; i < len; i++) { + let k = arglist[i]; s += '\n' + ws + k + ': ' + k + (i < len - 1 ? ',' + wsi2.substr(0, max_k_len - k.length - 1) : wsi2.substr(0, max_k_len - k.length)) + ' // parseParams::' + k; } return s; @@ -34030,17 +33839,17 @@ U+25FF ◿ Lower right triangle } function addOrRemoveTokenStack(fn, wantTokenStack) { - var parseFn = fn; + let parseFn = fn; // We don't use the Esprima+Escodegen toolchain as those loose the code comments easily; // instead we just chop the code using labels as sentinels for our chopping-it-up regexes: // // if (wantTokenStack) { // try { - // var ast = esprima.parse(parseFn); - // var stackAst = esprima.parse(String(tokenStackLex)).body[0]; + // let ast = esprima.parse(parseFn); + // let stackAst = esprima.parse(String(tokenStackLex)).body[0]; // stackAst.id.name = 'lex'; // - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); // // labeled[0].body = stackAst; // @@ -34050,7 +33859,7 @@ U+25FF ◿ Lower right triangle // } // } else { // // remove the line: - // // var tstack = []; // token stack + // // let tstack = []; // token stack // parseFn = parseFn.replace(/tstack = .*$/m, ''); // return parseFn; // } @@ -34059,23 +33868,23 @@ U+25FF ◿ Lower right triangle if (wantTokenStack) { // And rename the `tokenStackLex` function to become the new `lex`: return parseFn.replace(/\btokenStackLex\b/g, 'lex'); - } else { - // Also nuke the support declaration statement: - // var tstack = []; - return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); } + // Also nuke the support declaration statement: + // let tstack = []; + return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); + } // returns parse function with/without error recovery code function pickErrorHandlingChunk(fn, hasErrorRecovery) { - var parseFn = fn; + let parseFn = fn; // We don't use the Esprima+Escodegen toolchain as those loose the code comments easily; // instead we just chop the code using labels as sentinels for our chopping-it-up regexes: // try { - // var ast = esprima.parse(parseFn); + // let ast = esprima.parse(parseFn); - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("' + + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("' + // (!hasErrorRecovery ? '_handle_error_with_recovery' : '_handle_error_no_recovery') + // '"))', ast); // Jison.print('labeled: ', labeled); @@ -34091,7 +33900,7 @@ U+25FF ◿ Lower right triangle // and some post-coital touch-ups: if (!hasErrorRecovery) { // Also nuke the support declaration statement: - // var recovering = 0; + // let recovering = 0; // and the recovery support statements: // if (recovering > 0) { // recovering--; @@ -34100,7 +33909,7 @@ U+25FF ◿ Lower right triangle // , recovering: recovering // ASSERT(recovering === 0); parseFn = parseFn - .replace(/^\s*var recovering.*$/gm, '') + .replace(/^\s*let recovering.*$/gm, '') .replace(/, recovering: recovering/g, '') .replace(/^.*?recovering =.*$/gm, '') .replace(/^\s+recovering[,]?\s*$/gm, '') @@ -34112,11 +33921,11 @@ U+25FF ◿ Lower right triangle // ... KILL this chunk ... // } .replace(/\s+if[^a-z]+preErrorSymbol.*?\{\s*\/\/[^\n]+([\s\S]+?)\} else \{[\s\S]+?\}\n\s+\}\n/g, '\n$1\n\n\n\n') - .replace(/^\s+(?:var )?preErrorSymbol = .*$/gm, '') + .replace(/^\s+(?:let )?preErrorSymbol = .*$/gm, '') .replace(/^.*?\bpreErrorSymbol =.*$/gm, '') // And nuke the support declaration statement: - // var lastEofErrorStateDepth = 0; - .replace(/^\s*var lastEofErrorStateDepth.*$/gm, ''); + // let lastEofErrorStateDepth = 0; + .replace(/^\s*let lastEofErrorStateDepth.*$/gm, ''); } return parseFn; } @@ -34125,7 +33934,7 @@ U+25FF ◿ Lower right triangle // - module.commonCode: initialization code that should be placed before the module // - module.moduleCode: code that creates the module object lrGeneratorMixin.generateModule_ = function generateModule_() { - var parseFn = String(parser$4.parse); + let parseFn = String(parser$4.parse); parseFn = pickErrorHandlingChunk(parseFn, this.hasErrorRecovery); parseFn = addOrRemoveTokenStack(parseFn, this.options.tokenStack); @@ -34134,9 +33943,9 @@ U+25FF ◿ Lower right triangle parseFn = expandParseArguments(parseFn, this); - var errorClassCode = this.generateErrorClass(); + let errorClassCode = this.generateErrorClass(); - var exportDest = this.options.exportAllTables; + let exportDest = this.options.exportAllTables; assert__default['default'](exportDest); // store the parse tables: @@ -34144,10 +33953,7 @@ U+25FF ◿ Lower right triangle exportDest.defaultParseActions = this.defaultActions; exportDest.parseProductions = this.productions_; - var exportSourceCode = this.options.exportSourceCode; - assert__default['default'](exportSourceCode); - - var tableCode; + let tableCode; switch (this.options.compressTables | 0) { case 0: // no compression tableCode = this.generateTableCode0(this.table, this.defaultActions, this.productions_); @@ -34170,29 +33976,27 @@ U+25FF ◿ Lower right triangle // Generate the initialization code - var initCode = [].concat( + let initCode = [].concat( this.moduleInit.getInitCodeSection('imports'), this.moduleInit.getInitCodeSection('init') ); - var commonCode = [].concat( + let commonCode = [].concat( this.moduleInit.getInitCodeSection('required'), errorClassCode.commonCode, errorClassCode.moduleCode, - ['\nYY_REMAINING_INIT_CODE_SECTIONS_GO_HERE\n'], + [ '\nYY_REMAINING_INIT_CODE_SECTIONS_GO_HERE\n' ], tableCode.commonCode ); - // sort hash table by key to produce a nicer output: function produceSymbolTable(tbl) { - var a = Object.keys(tbl); + let a = Object.keys(tbl); a.sort(); - var nt = {}; - var k; - for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; + let nt = {}; + for (let i = 0, len = a.length; i < len; i++) { + let k = a[i]; // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number // and we do not want `$eof`/`EOF` to show up in the symbol tables of generated parsers @@ -34206,12 +34010,11 @@ U+25FF ◿ Lower right triangle // swap key and value and then sort hash table by key to produce a nicer output: function produceTerminalTable(tbl) { - var a = Object.keys(tbl); - var nt = {}; - var k, v; - for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; - v = tbl[k]; + let a = Object.keys(tbl); + let nt = {}; + for (let i = 0, len = a.length; i < len; i++) { + let k = a[i]; + let v = tbl[k]; nt[v] = +k; // convert numeric key back to number type; all terminals have numeric keys } return produceSymbolTable(nt); @@ -34219,71 +34022,71 @@ U+25FF ◿ Lower right triangle function produceProductionsForDebugging(options, symbols, base) { function get_orig_symbol(s) { - var a = s.split(':'); + let a = s.split(':'); if (a.length === 1 || a[0] === '') { return { state: -1, symbol: s }; } - var state = a[0]; + let state = a[0]; a.shift(); return { state: +state, - symbol: a.join(':'), + symbol: a.join(':') }; } function get_orig_symbol_set(arr) { - var rv = {}; - for (var i = 0, len = arr.length; i < len; i++) { - var item = arr[i]; - var symbol = get_orig_symbol(item); + let rv = {}; + for (let i = 0, len = arr.length; i < len; i++) { + let item = arr[i]; + let symbol = get_orig_symbol(item); rv[symbol.symbol] = symbol.state; } return Object.keys(rv); } - var tbl = this.nonterminals; - var sym = this.symbols_ || symbols; + let tbl = this.nonterminals; + let sym = this.symbols_ || symbols; if (!options.outputDebugTables && !options.exportAllTables.enabled) { return undefined; } - var prods = { + let prods = { ids: {}, states: {}, rules: {}, nonterminals: {}, symbols: {}, first: {}, - follows: {}, + follows: {} }; - var self = this; + let self = this; this.productions.forEach(function Follow_prod_forEach_genDebugTable(production, k) { - var nonterm = production.symbol; + let nonterm = production.symbol; prods.states[k] = nonterm; prods.ids[nonterm] = sym[nonterm]; - var lst = prods.rules[nonterm] || {}; + let lst = prods.rules[nonterm] || {}; lst[k] = gen_lalr_states_production(production, k, false, k, true); prods.rules[nonterm] = lst; }); function gen_nonterminal(nt) { - var l = nt.productions._items; - var lst = l.map(function (p, i) { + let l = nt.productions._items; + let lst = l.map(function (p, i) { return gen_lalr_states_production(p, i, false, false, false); }); - var rv = { + let rv = { symbol: nt.symbol, productions: lst, first: nt.first, base_first: get_orig_symbol_set(nt.first), follows: nt.follows, base_follows: get_orig_symbol_set(nt.follows), - nullable: nt.nullable, + nullable: nt.nullable }; // clean up structure: ditch superfluous elements: @@ -34297,7 +34100,7 @@ U+25FF ◿ Lower right triangle return rv; } - for (var key in tbl) { + for (let key in tbl) { prods.nonterminals[key] = gen_nonterminal(tbl[key]); } @@ -34306,9 +34109,9 @@ U+25FF ◿ Lower right triangle } function gen_lalr_states_production(production, index, dotPosition, state, patch_base) { - var nonterm = production.symbol; - var hlen = production.handle.length; - var rulestr = production.handle.map(function (t, idx) { + let nonterm = production.symbol; + let hlen = production.handle.length; + let rulestr = production.handle.map(function (t, idx) { if (!t) { t = '%epsilon'; } @@ -34322,7 +34125,7 @@ U+25FF ◿ Lower right triangle rulestr += ' ⬤'; } - var base_rulestr = production.handle.map(function (t) { + let base_rulestr = production.handle.map(function (t) { if (!t) { t = '%epsilon'; } @@ -34330,7 +34133,7 @@ U+25FF ◿ Lower right triangle return t; }).join(' '); - var rv = { + let rv = { symbol: nonterm, base_symbol: get_orig_symbol(nonterm).symbol, handle: rulestr, @@ -34349,12 +34152,11 @@ U+25FF ◿ Lower right triangle }; // Determine state for given production, if it's not a production that's listed as part of a state: - var chk, idx; - var lst = prods.rules[nonterm]; - chk = rv.symbol + ' : ' + rv.handle; - for (idx in lst) { + let lst = prods.rules[nonterm]; + let chk = rv.symbol + ' : ' + rv.handle; + for (let idx in lst) { idx = +idx; - var p = lst[idx]; + let p = lst[idx]; if (p) { if (p.symbol + ' : ' + p.handle === chk) { assert__default['default'](rv.state === -1); @@ -34367,9 +34169,9 @@ U+25FF ◿ Lower right triangle // Try to reference base productions from newg child productions and vice versa: chk = rv.base_symbol + ' : ' + rv.base_handle; if (base && base.rules) { - var pr = base.rules[rv.base_symbol]; - for (idx in pr) { - var bprod = pr[idx]; + let pr = base.rules[rv.base_symbol]; + for (let idx in pr) { + let bprod = pr[idx]; if (bprod.symbol + ' : ' + bprod.handle === chk) { assert__default['default'](rv.base_state === -1); rv.base_state = bprod.state; @@ -34403,13 +34205,13 @@ U+25FF ◿ Lower right triangle if (this.states) { prods.lalr_states = []; - var these_states = this.states; + let these_states = this.states; these_states.forEach(function traverse_states(state, i) { //assert(state.inadequate ? these_states.inadequate : true); state.forEach(function traverse_state(item, j) { // is this a REDUCE state? - var nterm_first = self.nonterminals[item.production.symbol].first; - var rv = { + let nterm_first = self.nonterminals[item.production.symbol].first; + let rv = { state: i, item_index: j, is_reduce_state: (item.dotPosition === item.production.handle.length), @@ -34422,7 +34224,7 @@ U+25FF ◿ Lower right triangle nterm_first: nterm_first, base_nterm_first: get_orig_symbol_set(nterm_first), prod_first: item.production.first, - base_prod_first: get_orig_symbol_set(item.production.first), + base_prod_first: get_orig_symbol_set(item.production.first) }; // clean up structure: ditch superfluous elements: @@ -34441,13 +34243,12 @@ U+25FF ◿ Lower right triangle }); } - var nt = tbl; - var sbn; - for (sbn in nt) { - var orig_symbol = get_orig_symbol(sbn); - var item = nt[sbn]; - var firsts = item.first; - var follows = item.follows; + let nt = tbl; + for (let sbn in nt) { + let orig_symbol = get_orig_symbol(sbn); + let item = nt[sbn]; + let firsts = item.first; + let follows = item.follows; if (!prods.symbols[orig_symbol.symbol]) { prods.symbols[orig_symbol.symbol] = orig_symbol.state; } @@ -34462,10 +34263,10 @@ U+25FF ◿ Lower right triangle prods.follows[orig_symbol.symbol] = prods.follows[orig_symbol.symbol].concat(follows); } } - for (sbn in prods.first) { + for (let sbn in prods.first) { prods.first[sbn] = get_orig_symbol_set(prods.first[sbn]); } - for (sbn in prods.follows) { + for (let sbn in prods.follows) { prods.follows[sbn] = get_orig_symbol_set(prods.follows[sbn]); } @@ -34476,11 +34277,11 @@ U+25FF ◿ Lower right triangle } function produceTerminalDescriptions(tbl, sym) { - var rv = {}; - var count = 0; - for (var k in tbl) { - var descr = tbl[k]; - var id = sym[k]; + let rv = {}; + let count = 0; + for (let k in tbl) { + let descr = tbl[k]; + let id = sym[k]; if (id && descr && descr !== id) { rv[id] = descr; count++; @@ -34490,56 +34291,56 @@ U+25FF ◿ Lower right triangle } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - type: 0, // CLI: --parserType option - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - numExpectedConflictStates: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - json: 1, - _: 1, - noMain: 1, - moduleMain: 1, - moduleMainImports: 1, - noDefaultResolve: 1, - defaultActionMode: 1, - testCompileActionCode: 1, - noTryCatch: 1, - hasPartialLrUpgradeOnConflict: 0, - compressTables: 1, - outputDebugTables: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - lexfile: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - exportAllTables: 1, - exportSourceCode: 1, - tokenStack: 0, - parserErrorsAreRecoverable: 0, - lexerErrorsAreRecoverable: 1, - showSource: 1, - exportAST: 1, - prettyCfg: 1, - - errorRecoveryTokenDiscardCount: 0, - - warn_cb: 0, // function(msg) | true (= use Jison.Print) | false (= throw Exception) - - parseParams: 1, - ranges: 0, + let obj = {}; + let do_not_pass = { + type: 0, // CLI: --parserType option + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + numExpectedConflictStates: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + json: 1, + _: 1, + noMain: 1, + moduleMain: 1, + moduleMainImports: 1, + noDefaultResolve: 1, + defaultActionMode: 1, + testCompileActionCode: 1, + noTryCatch: 1, + hasPartialLrUpgradeOnConflict: 0, + compressTables: 1, + outputDebugTables: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + lexfile: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + exportAllTables: 1, + exportSourceCode: 1, + tokenStack: 0, + parserErrorsAreRecoverable: 0, + lexerErrorsAreRecoverable: 1, + showSource: 1, + exportAST: 1, + prettyCfg: 1, + + errorRecoveryTokenDiscardCount: 0, + + warn_cb: 0, // function(msg) | true (= use Jison.Print) | false (= throw Exception) + + parseParams: 1, + ranges: 0 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -34551,12 +34352,12 @@ U+25FF ◿ Lower right triangle // And now some options which should receive some special processing: if (!obj.hasPartialLrUpgradeOnConflict) { - // only list this option when it's actually TRUE: - delete obj.hasPartialLrUpgradeOnConflict; + // only list this option when it's actually TRUE: + delete obj.hasPartialLrUpgradeOnConflict; } - var pre = obj.pre_parse; - var post = obj.post_parse; + let pre = obj.pre_parse; + let post = obj.post_parse; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_parse = true; @@ -34565,7 +34366,7 @@ U+25FF ◿ Lower right triangle obj.post_parse = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$3})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_parse: true(,)?$/gm, function (m, ls, tc) { @@ -34579,27 +34380,27 @@ U+25FF ◿ Lower right triangle // Generate the module creation code - var termDescrs = produceTerminalDescriptions(this.descriptions_, this.symbols_); + let termDescrs = produceTerminalDescriptions(this.descriptions_, this.symbols_); exportDest.terminalDescriptions = termDescrs; - var descrLst = JSON.stringify(termDescrs, null, 2); + let descrLst = JSON.stringify(termDescrs, null, 2); if (descrLst) { descrLst = descrLst.replace(/"([0-9]+)":/g, '$1:'); } - var rules4Dbg = produceProductionsForDebugging.call(this, this.options); + let rules4Dbg = produceProductionsForDebugging.call(this, this.options); exportDest.parseRules = rules4Dbg; - var rulesLst = ((this.options.outputDebugTables || this.options.exportAllTables.enabled) ? JSON.stringify(rules4Dbg, null, 2) : undefined); + let rulesLst = ((this.options.outputDebugTables || this.options.exportAllTables.enabled) ? JSON.stringify(rules4Dbg, null, 2) : undefined); if (rulesLst) { rulesLst = rulesLst.replace(/"([0-9]+)":/g, '$1:').replace(/^(\s+)"([a-z_][a-z_0-9]*)":/gmi, '$1$2:'); } - var symbolTable = produceSymbolTable(this.symbols_); + let symbolTable = produceSymbolTable(this.symbols_); exportDest.symbolTable = symbolTable; // produce a hash lookup table from the terminal set exportDest.terminalTable = produceTerminalTable(this.terminals_); - var moduleCode = `{ + let moduleCode = `{ // Code Generator Information Report // --------------------------------- // @@ -34663,22 +34464,22 @@ U+25FF ◿ Lower right triangle 'yy: {}', 'options: ' + produceOptions(this.options), 'symbols_: ' + JSON.stringify(symbolTable, null, 2), - 'terminals_: ' + JSON.stringify(this.terminals_, null, 2).replace(/"([0-9]+)":/g, '$1:'), + 'terminals_: ' + JSON.stringify(this.terminals_, null, 2).replace(/"([0-9]+)":/g, '$1:') ].concat( rulesLst ? - 'nonterminals_: ' + rulesLst : - [] + 'nonterminals_: ' + rulesLst : + [] ).concat( descrLst ? - 'terminal_descriptions_: ' + descrLst : - [] + 'terminal_descriptions_: ' + descrLst : + [] ).concat([ define_parser_APIs_1.trim(), 'productions_: ' + tableCode.productionsCode ]).concat( String(this.performAction).trim() !== '' ? - 'performAction: ' + String(this.performAction) : - [] + 'performAction: ' + String(this.performAction) : + [] ).concat([ 'table: ' + tableCode.tableCode, 'defaultActions: ' + tableCode.defaultActionsCode, @@ -34686,24 +34487,24 @@ U+25FF ◿ Lower right triangle 'parse: ' + parseFn.trim() ]).concat( this.actionsUseYYERROR ? - 'yyError: 1' : - [] + 'yyError: 1' : + [] ).concat( this.actionsUseYYRECOVERING ? - 'yyRecovering: 1' : - [] + 'yyRecovering: 1' : + [] ).concat( this.actionsUseYYERROK ? - 'yyErrOk: 1' : - [] + 'yyErrOk: 1' : + [] ).concat( this.actionsUseYYCLEARIN ? - 'yyClearIn: 1' : - [] + 'yyClearIn: 1' : + [] ).join(',\n'); moduleCode += '\n};'; - var exportSourceCode = this.options.exportSourceCode; + const exportSourceCode = this.options.exportSourceCode; assert__default['default'](exportSourceCode); exportSourceCode.parserChunks = { initCode: expandConstantsInGeneratedCode(initCode.join('\n'), this), @@ -34711,8 +34512,8 @@ U+25FF ◿ Lower right triangle moduleCode: expandConstantsInGeneratedCode(moduleCode, this), modulePostlude: [ 'parser.originalParseError = parser.parseError;', - 'parser.originalQuoteName = parser.quoteName;', - ].join('\n'), + 'parser.originalQuoteName = parser.quoteName;' + ].join('\n'), moduleInclude: expandConstantsInGeneratedCode(this.moduleInclude, this) }; return exportSourceCode.parserChunks; @@ -34726,8 +34527,6 @@ U+25FF ◿ Lower right triangle // 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. function JisonParserError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -34744,9 +34543,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -34784,14 +34583,14 @@ JisonParserError.prototype.name = 'JisonParserError'; // Generate code that represents the specified parser table lrGeneratorMixin.generateTableCode0 = function (table, defaultActions, productions) { - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); // Don't surround numerical property name numbers in quotes tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); - var prelude = []; + let prelude = []; // Return the variable initialization code and the table code return { @@ -34804,10 +34603,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // Function that extends an object with the given value for all given keys // e.g., x([1, 3, 4], [6, 7], { x: 1, y: 2 }) = { 1: [6, 7]; 3: [6, 7], 4: [6, 7], x: 1, y: 2 } - var compressor1ObjectCode = ` + let compressor1ObjectCode = ` function x(k, v, o) { o = o || {}; - for (var l = k.length; l--; ) { + for (let l = k.length; l--; ) { o[k[l]] = v; } return o; @@ -34816,10 +34615,10 @@ function x(k, v, o) { // Generate code that represents the specified parser table lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productions) { - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); - var usesCompressor = false; + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); + let usesCompressor = false; // Don't surround numerical property name numbers in quotes tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); @@ -34828,22 +34627,21 @@ function x(k, v, o) { // e.g., { 1: [6, 7]; 3: [6, 7], 4: [6, 7], 5: 8 } = x([1, 3, 4], [6, 7], { 5: 8 }) tableCode = tableCode.replace(/\{[\s\r\n]*\d+:[^\}]+,[\s\r\n]*\d+:[^\}]+\}/g, function (object) { // Find the value that occurs with the highest number of keys - var value, frequentValue, key, - keys = {}, - keyCount, - maxKeyCount = 0, - keyValue, - keyValues = [], - keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; + let frequentValue; + let keys = {}; + let maxKeyCount = 0; + let keyValue; + let keyValues = []; + let keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; while ((keyValue = keyValueMatcher.exec(object))) { // For each value, store the keys where that value occurs - key = keyValue[1]; - value = keyValue[2].trim(); - keyCount = 1; + let key = keyValue[1]; + let value = keyValue[2].trim(); + let keyCount = 1; if (!(value in keys)) { - keys[value] = [key]; + keys[value] = [ key ]; } else { keyCount = keys[value].push(key); } @@ -34856,9 +34654,9 @@ function x(k, v, o) { // Construct the object with a function call if the most frequent value occurs multiple times if (maxKeyCount > 1) { // Collect all non-frequent values into a remainder object - for (value in keys) { + for (let value in keys) { if (value !== frequentValue) { - for (var k = keys[value], i = 0, l = k.length; i < l; i++) { + for (let k = keys[value], i = 0, l = k.length; i < l; i++) { keyValues.push(k[i] + ':' + value); } } @@ -34872,10 +34670,10 @@ function x(k, v, o) { }); // Count occurrences of number lists - var list; - var lists = {}; - var listMatcher = /\[[0-9,]+\]/g; - var frequentLists = []; + let list; + let lists = {}; + let listMatcher = /\[[0-9,]+\]/g; + let frequentLists = []; while ((list = listMatcher.exec(tableCode))) { lists[list] = (lists[list] || 0) + 1; @@ -34883,7 +34681,7 @@ function x(k, v, o) { // Replace frequently occurring number lists with variables tableCode = tableCode.replace(listMatcher, function (list) { - var listId = lists[list]; + let listId = lists[list]; // If listId is a number, it represents the list's occurrence frequency if (typeof listId === 'number') { // If the list does not occur frequently, represent it by the list @@ -34898,7 +34696,7 @@ function x(k, v, o) { return listId; }); - var prelude = []; + let prelude = []; // Only include the expander function when it's actually used // (tiny grammars don't have much state duplication, so this shaves off @@ -34909,7 +34707,7 @@ function x(k, v, o) { } if (frequentLists.length > 0) { - prelude.push('var u = [\n ' + frequentLists.join(',\n ') + '\n];'); + prelude.push('let u = [\n ' + frequentLists.join(',\n ') + '\n];'); prelude.push(''); } @@ -34928,9 +34726,9 @@ function x(k, v, o) { throw new Error("Table Compression mode 2 corrupts the table when the 'noDefaultResolve' option is turned on and one or more conflicts occur. Please use a different compression mode and/or disable this option."); } - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); // We know a couple of things about the parse table: // @@ -34958,33 +34756,29 @@ function x(k, v, o) { tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); - - function reportColumnsForCompression(def_arr) { - var i, key, len; - var report = []; + let report = []; - len = 0; - for (key in def_arr) { + let len = 0; + for (let key in def_arr) { len = Math.max(len, def_arr[key].length); } - var col_width = 6; - var col_delta_width = 4; + let col_width = 6; + let col_delta_width = 4; function clip(val, width) { - var s = ' ' + val; + let s = ' ' + val; s = s.substr(s.length - width); return s; } - var track_prev4delta = {}; - var c, delta, val, delta_val; - var line = []; + let track_prev4delta = {}; + let line = []; line.push('║'); - for (c in def_arr) { - key = clip(c, col_width); - delta = clip('∆', col_delta_width); + for (let c in def_arr) { + let key = clip(c, col_width); + let delta = clip('∆', col_delta_width); line.push(key); line.push('┊'); line.push(delta); @@ -34994,12 +34788,13 @@ function x(k, v, o) { } report.push(line.join('')); - for (i = 0; i < len; i++) { + for (let i = 0; i < len; i++) { line = []; line.push('║'); - for (c in def_arr) { - var tbl = def_arr[c]; + for (let c in def_arr) { + let val, delta_val; + let tbl = def_arr[c]; if (tbl.length > i) { val = tbl[i] || 0; @@ -35014,8 +34809,8 @@ function x(k, v, o) { delta_val = '.'; } - key = clip(val, col_width); - delta = clip(delta_val, col_delta_width); + let key = clip(val, col_width); + let delta = clip(delta_val, col_delta_width); line.push(key); line.push('┊'); line.push(delta); @@ -35031,16 +34826,16 @@ function x(k, v, o) { // table is array of 1/2-len arrays: function analyzeTableForCompression(table) { // column: productions' row length - var len_col = []; + let len_col = []; // column: productions' shift size / action column - var pop_col = []; + let pop_col = []; // column: rule number for each slot ('rule'): - var rule_col = []; + let rule_col = []; - var i; - var row_count = table.length; + let i; + let row_count = table.length; for (i = 0; i < row_count; i++) { - var prod = table[i]; + let prod = table[i]; len_col.push(prod.length); assert__default['default'](prod.length <= 2); @@ -35051,10 +34846,10 @@ function x(k, v, o) { rule_col.push(prod[1]); } - var def_arr = { - 'len': len_col, - 'pop': pop_col, - 'rule': rule_col, + let def_arr = { + len: len_col, + pop: pop_col, + rule: rule_col }; return def_arr; } @@ -35065,14 +34860,14 @@ function x(k, v, o) { // table is hash of 1/2-len arrays: function analyzeSetForCompression(table) { // column: row index - var idx_col = []; + let idx_col = []; // column: REDUCE productions' goto column - var goto_col = []; + let goto_col = []; - var i; + let i; for (i in table) { i = +i; - var prod = table[i]; + let prod = table[i]; idx_col.push(i); // and the special knowledge about the defaultActions[] table: @@ -35080,9 +34875,9 @@ function x(k, v, o) { goto_col.push(prod); } - var def_arr = { - 'idx': idx_col, - 'goto': goto_col, + let def_arr = { + idx: idx_col, + goto: goto_col }; return def_arr; } @@ -35091,30 +34886,29 @@ function x(k, v, o) { function analyzeGotoTableForCompression(table) { // column: number of symbol hash entries per state slot ('length'): - var len_col = []; + let len_col = []; // column: symbol hash entry key for each slot ('symbol'): - var symbol_col = []; + let symbol_col = []; // column: symbol hash entry value type: number (0) or array (array.length) ('type'): - var type_col = []; + let type_col = []; // column: symbol hash entry value if single GOTO state number ('state'): - var state_col = []; + let state_col = []; // column: symbol hash entry mode value if array slot type (reduce/shift/accept): - var mode_col = []; + let mode_col = []; // column: symbol hash entry goto state value if array slot type: - var goto_col = []; + let goto_col = []; // // column: merged: state_col + goto_col: - // var next_col = []; - - var row_count = table.length; - for (var state = 0; state < row_count; state++) { - var hashtable = table[state]; - var count = 0; - var symbol; - for (symbol in hashtable) { + // let next_col = []; + + let row_count = table.length; + for (let state = 0; state < row_count; state++) { + let hashtable = table[state]; + let count = 0; + for (let symbol in hashtable) { symbol = +symbol; symbol_col.push(symbol); - var slot = hashtable[symbol]; + let slot = hashtable[symbol]; if (slot && slot.length) { // array type slot: assert__default['default'](slot.length === 2 || slot.length === 1); @@ -35141,40 +34935,40 @@ function x(k, v, o) { len_col.push(count); } - var def_arr = { - 'len': len_col, - 'symbol': symbol_col, - 'type': type_col, - 'state': state_col, - 'mode': mode_col, - 'goto': goto_col, + let def_arr = { + len: len_col, + symbol: symbol_col, + type: type_col, + state: state_col, + mode: mode_col, + goto: goto_col //'next': next_col, }; return def_arr; } - var has_compressed_a_table = false; + let has_compressed_a_table = false; function generateColumn(name, col) { - var rv = []; - var i, j, len, l; + let rv = []; - for (i = 0, len = col.length; i < len; i++) { + for (let i = 0, len = col.length; i < len; i++) { // try basic run-length encoding first: - var v = col[i]; + let v = col[i]; + let j; for (j = i + 1; j < len; j++) { if (col[j] !== v) { break; } } - var runlength = j - i; + let runlength = j - i; // try stepped run-length encoding next: - var delta = col[i + 1] - v; - var steplength = 0; + let delta = col[i + 1] - v; + let steplength = 0; // we don't want to replicate the runlength result, so only look for a match // when delta !== 0: @@ -35188,10 +34982,11 @@ function x(k, v, o) { } // try to match the pattern in history: - var best_pos = 0; - var best_len = 0; - var upper_bound = i - 2; + let best_pos = 0; + let best_len = 0; + let upper_bound = i - 2; for (j = 0; j < upper_bound; j++) { + let l; for (l = 0; col[j + l] === col[i + l]; l++) { // No need to check for: // if (j + l === i) break; @@ -35215,28 +35010,24 @@ function x(k, v, o) { } // weight our options now: - var gain = [ + let gain = [ runlength - 2, steplength - 3, best_len - 2 ]; - var optimum_gain = Math.max.apply(null, gain); + let optimum_gain = Math.max.apply(null, gain); if (optimum_gain <= 0) { rv.push(v); - } - else if (optimum_gain === gain[0]) { + } else if (optimum_gain === gain[0]) { rv.push('s', '[' + v + ', ' + runlength + ']'); i += runlength - 1; - } - else if (optimum_gain === gain[1]) { + } else if (optimum_gain === gain[1]) { rv.push('s', '[' + v + ', ' + steplength + ', ' + delta + ']'); i += steplength - 1; - } - else if (optimum_gain === gain[2]) { + } else if (optimum_gain === gain[2]) { rv.push('c', '[' + best_pos + ', ' + best_len + ']'); i += best_len - 1; - } - else { + } else { rv.push(v); //assert(0); // should never get here! } @@ -35246,11 +35037,11 @@ function x(k, v, o) { } } - var code = [ + let code = [ ' ', name, ': ', 'u([', '\n ', - rv.join(',\n '), // JSON.stringify(col, null, 2), + rv.join(',\n '), // JSON.stringify(col, null, 2), '\n', '])' ].join(''); @@ -35259,7 +35050,7 @@ function x(k, v, o) { function generateCompressedTable(def_arr) { - var code = [ + let code = [ 'bp({', generateColumn('pop', def_arr.pop) + ',', generateColumn('rule', def_arr.rule), @@ -35270,7 +35061,7 @@ function x(k, v, o) { function generateCompressedSet(def_arr) { - var code = [ + let code = [ 'bda({', generateColumn('idx', def_arr.idx) + ',', generateColumn('goto', def_arr.goto), @@ -35281,7 +35072,7 @@ function x(k, v, o) { function generateCompressedGotoTable(def_arr) { - var code = [ + let code = [ 'bt({', generateColumn('len', def_arr.len) + ',', generateColumn('symbol', def_arr.symbol) + ',', @@ -35295,18 +35086,18 @@ function x(k, v, o) { } - var tableDef = analyzeGotoTableForCompression(table); - var defaultActionsDef = analyzeSetForCompression(defaultActions); - var productionsDef = analyzeTableForCompression(productions); + let tableDef = analyzeGotoTableForCompression(table); + let defaultActionsDef = analyzeSetForCompression(defaultActions); + let productionsDef = analyzeTableForCompression(productions); const bp_code_container = ` // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -35319,11 +35110,11 @@ function x(k, v, o) { const bda_code_container = ` // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -35333,18 +35124,18 @@ function x(k, v, o) { const bt_code_container = ` // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -35375,7 +35166,7 @@ function x(k, v, o) { // \`this\` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -35392,9 +35183,9 @@ function x(k, v, o) { // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -35408,25 +35199,25 @@ function x(k, v, o) { `; has_compressed_a_table = false; - var tc = generateCompressedGotoTable(tableDef); - var compressGotoTable = has_compressed_a_table; + let tc = generateCompressedGotoTable(tableDef); + let compressGotoTable = has_compressed_a_table; has_compressed_a_table = false; - var dac = generateCompressedSet(defaultActionsDef); - var compressDefaultActions = has_compressed_a_table; + let dac = generateCompressedSet(defaultActionsDef); + let compressDefaultActions = has_compressed_a_table; has_compressed_a_table = false; - var pc = generateCompressedTable(productionsDef); - var compressProductions = has_compressed_a_table; + let pc = generateCompressedTable(productionsDef); + let compressProductions = has_compressed_a_table; - var compressAnything = (compressProductions || compressDefaultActions || compressGotoTable); + let compressAnything = (compressProductions || compressDefaultActions || compressGotoTable); tableCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(tableDef) : '') + (compressGotoTable ? tc : tableCode); defaultActionsCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(defaultActionsDef) : '') + (compressDefaultActions ? dac : defaultActionsCode); productionsCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(productionsDef) : '') + (compressProductions ? pc : productionsCode); - var prelude = [ + let prelude = [ '', compressProductions ? bp_code_container : '', '', @@ -35434,7 +35225,7 @@ function x(k, v, o) { '', compressGotoTable ? bt_code_container : '', '', - c_s_u_code_container, + c_s_u_code_container ]; if (!compressAnything) { prelude = []; @@ -35450,31 +35241,29 @@ function x(k, v, o) { }; // --- START of commonJsMain chunk --- - // + // // default main method for generated commonjs modules const commonJsMain = ` -function (args) { - "use strict"; - +function __jison_default_main__(args) { // When the parser comes with its own \`main\` function, then use that one: if (typeof exports.parser.main === 'function') { - return exports.parser.main(args); + return exports.parser.main(args); } if (!args[1]) { console.log('Usage:', path.basename(args[0]) + ' FILE'); process.exit(1); } - var source = fs.readFileSync(path.normalize(args[1]), 'utf8'); - var dst = exports.parser.parse(source); + const source = fs.readFileSync(path.normalize(args[1]), 'utf8'); + const dst = exports.parser.parse(source); console.log('parser output:\\n\\n', { type: typeof dst, value: dst }); try { - console.log("\\n\\nor as JSON:\\n", JSON.stringify(dst, null, 2)); + 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... */ } - var rv = 0; + let rv = 0; if (typeof dst === 'number' || typeof dst === 'boolean') { rv = dst; } @@ -35484,16 +35273,16 @@ function (args) { // --- END of commonJsMain chunk --- const commonJsMainImports = ` -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); `; // debug mixin for LR parser generators function printAction(a, gen) { - var s = a[0] === SHIFT ? 'shift token (then go to state ' + a[1] + ')' : + let s = a[0] === SHIFT ? 'shift token (then go to state ' + a[1] + ')' : a[0] === REDUCE ? 'reduce by rule: ' + gen.productions[a[1]] : - a[0] === ACCEPT ? 'accept' : 'UNDEFINED ACTION: ' + a[0]; + a[0] === ACCEPT ? 'accept' : 'UNDEFINED ACTION: ' + a[0]; return s; } @@ -35507,13 +35296,13 @@ var path = require('path'); trace('\n'); } - var lrGeneratorDebug = { + const lrGeneratorDebug = { beforeparseTable: function () { this.trace('Building parse table.'); }, afterparseTable: function () { - var trace = this.trace; - var self = this; + let trace = this.trace; + let self = this; if (this.conflicts > 0) { trace('\nConflicts:\n'); this.resolutions.forEach(function (r, i) { @@ -35525,21 +35314,21 @@ var path = require('path'); } trace('Done.\n'); }, - aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */ ) { + aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */) { traceStates(this.trace, states, 'as produced by LR::canonicalCollection()'); } }; - var parser$4 = typal.beget(); + const parser$4 = typal.beget(); generatorMixin.createParser = function createParser() { - var sourceCodeDef = this.generateModuleExpr(); + let sourceCodeDef = this.generateModuleExpr(); // produce a chunk of sourcecode that's suitable for evaluation through `eval()`: - var sourcecode = rmCommonWS$5` + let sourcecode = rmCommonWS$5` ${sourceCodeDef.init} - var yy__parser = ${sourceCodeDef.src}; + let yy__parser = ${sourceCodeDef.src}; // produce the generated parser function/class as the last value // in this chunk of code so that we can be sure to produce *that* @@ -35550,15 +35339,15 @@ var path = require('path'); yy__parser; `; - var p = code_exec$2(sourcecode, function generated_code_exec_wrapper_jison(sourcecode) { + let 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); - var rv = eval(sourcecode); + let rv = eval(sourcecode); return rv; }, mkStdOptions$1(this.options, { dumpSourceCodeOnFailure: this.DEBUG, throwErrorOnCompileFailure: true - }), "parser"); + }), 'parser'); assert__default['default'](typeof p === 'object'); assert__default['default'](typeof p.parse === 'function'); assert__default['default'](typeof p.parser === 'undefined'); @@ -35602,7 +35391,7 @@ var path = require('path'); } p.sourceCode = sourceCodeDef; - var self = this; + let self = this; function bind(method) { return function () { self.lexer = p.lexer; @@ -35629,8 +35418,6 @@ var path = require('path'); // --- START parser Error class chunk --- const parseErrorSourceCode = ` function parseError(str, hash, ExceptionClass) { - "use strict"; - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -35655,7 +35442,7 @@ function parseError(str, hash, ExceptionClass) { generatorMixin.createLexer = function createLexer(lexerSpec, input, tokens, options) { // TODO: construct options from generator options: // lexer_options = ... - var lexer = new RegExpLexer(lexerSpec, input, tokens, options); + let lexer = new RegExpLexer(lexerSpec, input, tokens, options); return lexer; }; @@ -35694,8 +35481,6 @@ function parseError(str, hash, ExceptionClass) { // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - "use strict"; - return '"' + id_str + '"'; }, @@ -35703,8 +35488,6 @@ function parseError(str, hash, ExceptionClass) { // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - "use strict"; - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -35716,8 +35499,8 @@ function parseError(str, hash, ExceptionClass) { // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -35730,15 +35513,13 @@ function parseError(str, hash, ExceptionClass) { // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - "use strict"; - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -35754,11 +35535,10 @@ function parseError(str, hash, ExceptionClass) { // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { - "use strict"; + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -35766,10 +35546,10 @@ function parseError(str, hash, ExceptionClass) { this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -35781,8 +35561,8 @@ function parseError(str, hash, ExceptionClass) { `; // --- END of define_parser_APIs_1 chunk --- - var api_set = (new Function('', 'return { ' + define_parser_APIs_1 + ' };'))(); - for (var api in api_set) { + const api_set = (new Function('', 'return { ' + define_parser_APIs_1 + ' };'))(); + for (let api in api_set) { parser$4[api] = api_set[api]; } @@ -35790,39 +35570,37 @@ function parseError(str, hash, ExceptionClass) { // --- START parser kernel --- parser$4.parse = ` function parse(input, parseParams) { - "use strict"; - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - var tstack = []; // token stack (only used when \`%options token_stack\` support has been enabled) - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - var yytext; - var yylineno; - var yyleng; - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + let tstack = []; // token stack (only used when \`%options token_stack\` support has been enabled) + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + let yytext; + let yylineno; + let yyleng; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -35831,21 +35609,18 @@ function parse(input, parseParams) { post_parse: undefined, pre_lex: undefined, post_lex: undefined, - parseParamsAsMembers: parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - "use strict"; - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -35870,8 +35645,6 @@ function parse(input, parseParams) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - "use strict"; - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -35879,18 +35652,19 @@ function parse(input, parseParams) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -35898,26 +35672,19 @@ function parse(input, parseParams) { // - either the element does not yet exist in \`src\` // - or exists in \`src\` but is NULL or UNDEFINED there, while its value is non-NULL in \`dst\` function shallow_copy_noclobber(dst, src) { - "use strict"; - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - "use strict"; - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -35935,17 +35702,13 @@ function parse(input, parseParams) { this.copy_yytext = this.options.copy_yytext || sharedState_yy.copy_yytext || shallow_copy; this.copy_yylloc = this.options.copy_yylloc || sharedState_yy.copy_yylloc || copy_yylloc_native; - var yydebug = false; + let yydebug = false; if (this.options.debug) { yydebug = function yydebug_impl(msg, obj) { - "use strict"; - - var ref_list; - var ref_names; + let ref_list; + let ref_names; function deepClone(from, sub) { - "use strict"; - if (sub == null) { ref_list = []; ref_names = []; @@ -35957,15 +35720,15 @@ function parse(input, parseParams) { return from; } - var i = ref_list.indexOf(from); + let i = ref_list.indexOf(from); if (i >= 0) { return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference } ref_list.push(from); ref_names.push(sub); - var to = new from.constructor(); - for (var name in from) { + let to = new from.constructor(); + for (let name in from) { if (name === 'parser') continue; if (name === 'lexer') continue; to[name] = deepClone(from[name], name); @@ -35993,13 +35756,11 @@ function parse(input, parseParams) { // wrap try/catch in a function to help the V8 JIT compiler... function yydebug_cvt(obj) { - "use strict"; - - var js; + let js; try { - var re1; + let re1; if (typeof XRegExp === 'undefined') { - re1 = / \\"([a-z_][a-z_0-9. ]*)\\": /ig; + re1 = / {2}\\"([a-z_][a-z_0-9. ]*)\\": /ig; } else { re1 = new XRegExp(' \\"([\\\\p{Alphabetic}_][\\\\p{Alphabetic}\\\\p{Number}_. ]*)\\": ', 'g'); } @@ -36031,21 +35792,25 @@ function parse(input, parseParams) { // them up. Hence we MUST set them up at the start of every \`parse()\` run! if (this.yyError) { this.yyError = function yyError(str /*, ...args */) { - "use strict"; - - if (yydebug) yydebug('yyerror: ', { message: str, args: arguments, symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('yyerror: ', { + message: str, + args: arguments, + symbol, state, newState, recovering, action + }); + } //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); + let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -36066,13 +35831,13 @@ function parse(input, parseParams) { //_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, false); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, false); //_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -36085,18 +35850,14 @@ function parse(input, parseParams) { if (this.yyRecovering) { this.yyRecovering = function yyRecovering() { - "use strict"; - - if (yydebug) yydebug('yyrecovering: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) yydebug('yyrecovering: ', { symbol, state, newState, recovering, action }); return recovering; }; } if (this.yyErrOk) { this.yyErrOk = function yyErrOk() { - "use strict"; - - if (yydebug) yydebug('yyerrok: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) yydebug('yyerrok: ', { symbol, state, newState, recovering, action }); recovering = 0; // DO NOT reset/cleanup \`recoveringErrorInfo\` yet: userland code @@ -36118,9 +35879,7 @@ function parse(input, parseParams) { if (this.yyClearIn) { this.yyClearIn = function yyClearIn() { - "use strict"; - - if (yydebug) yydebug('yyclearin: ', { symbol: symbol, newState: newState, recovering: recovering, action: action, preErrorSymbol: preErrorSymbol }); + if (yydebug) yydebug('yyclearin: ', { symbol, newState, recovering, action, preErrorSymbol }); if (symbol === TERROR) { symbol = 0; yytext = null; @@ -36137,8 +35896,6 @@ function parse(input, parseParams) { // Does the shared state override the default \`parseError\` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -36151,8 +35908,6 @@ function parse(input, parseParams) { // Does the shared state override the default \`quoteName\` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - "use strict"; - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -36166,12 +35921,10 @@ function parse(input, parseParams) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your \`sharedState\`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - "use strict"; - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -36225,8 +35978,8 @@ function parse(input, parseParams) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -36235,8 +35988,8 @@ function parse(input, parseParams) { //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -36270,20 +36023,18 @@ function parse(input, parseParams) { // // Note: epsilon rule's yylloc situation is detected by passing both \`first_index\` and \`first_yylloc\` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - "use strict"; - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -36294,7 +36045,7 @@ function parse(input, parseParams) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -36307,7 +36058,7 @@ function parse(input, parseParams) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -36319,29 +36070,27 @@ function parse(input, parseParams) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or \`dont_look_back\` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -36349,7 +36098,7 @@ function parse(input, parseParams) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -36369,9 +36118,7 @@ function parse(input, parseParams) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your \`lexer\`, \`sharedState\`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - "use strict"; - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -36380,10 +36127,10 @@ function parse(input, parseParams) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -36391,7 +36138,7 @@ function parse(input, parseParams) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -36408,10 +36155,8 @@ function parse(input, parseParams) { // info.value = null; // info.value_stack = null; // ... - "use strict"; - - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -36427,9 +36172,7 @@ function parse(input, parseParams) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - "use strict"; - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -36498,11 +36241,14 @@ function parse(input, parseParams) { // - root_failure_pointer: // copy of the \`stack_pointer\`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -36513,9 +36259,7 @@ function parse(input, parseParams) { }; function getNonTerminalFromCode(symbol) { - "use strict"; - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -36525,22 +36269,20 @@ function parse(input, parseParams) { //_lexer_without_token_stack: function stdLex() { - "use strict"; - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36550,22 +36292,20 @@ function parse(input, parseParams) { } function fastLex() { - "use strict"; - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36574,15 +36314,13 @@ function parse(input, parseParams) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; //_lexer_with_token_stack: // lex function that supports token stacks function tokenStackLex() { - "use strict"; - - var token; + let token; token = tstack.pop() || lexer.lex() || EOF; // if token isn't its numeric value, convert if (typeof token !== 'number') { @@ -36601,13 +36339,13 @@ function parse(input, parseParams) { } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36618,33 +36356,37 @@ function parse(input, parseParams) { //_lexer_with_token_stack_end: - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - "use strict"; - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { // check for error recovery rule in this state - if (yydebug) yydebug('locateNearestErrorRecoveryRule #test#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); - var t = (table[state] && table[state][TERROR]) || NO_ACTION; + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #test#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } + const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we \`yyerrok()\` an error, we must @@ -36659,12 +36401,24 @@ function parse(input, parseParams) { // terminate the parse in a controlled fashion even when we have // very complex error/recovery code interplay in the core + user // action code blocks: - if (yydebug) yydebug('locateNearestErrorRecoveryRule #found#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #found#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { - if (yydebug) yydebug('locateNearestErrorRecoveryRule #skip#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #skip#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; @@ -36674,14 +36428,26 @@ function parse(input, parseParams) { return depth; } if (state === 0 /* $accept rule */ || stack_probe < 1) { - if (yydebug) yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; } - if (yydebug) yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } return -1; // No suitable error recovery rule available. } @@ -36698,7 +36464,7 @@ function parse(input, parseParams) { // whether we'll go with the standard, slower, lex() API or the // \`fast_lex()\` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -36744,17 +36510,23 @@ function parse(input, parseParams) { newState = t[1]; action = t[0]; - if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('after FETCH/LEX: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol], + state, newState, recovering, action + }); + } //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules // handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -36781,7 +36553,13 @@ function parse(input, parseParams) { // invoke the parser's cleanup API! recoveringErrorInfo = this.shallowCopyErrorInfo(p); - if (yydebug) yydebug('error recovery rule detected: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p }); + if (yydebug) { + yydebug('error recovery rule detected: ', { + error_rule_depth, + error: p.errStr, + error_hash: p + }); + } r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { @@ -36799,9 +36577,15 @@ function parse(input, parseParams) { } } - if (yydebug) yydebug('after ERROR DETECT: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p }); + if (yydebug) { + yydebug('after ERROR DETECT: ', { + error_rule_depth, + error: p.errStr, + error_hash: p + }); + } - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -36821,17 +36605,22 @@ function parse(input, parseParams) { preErrorSymbol = 0; symbol = lex(); - if (yydebug) yydebug('after ERROR RECOVERY-3: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol] }); + if (yydebug) { + yydebug('after ERROR RECOVERY-3: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol] + }); + } } // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -36878,20 +36667,18 @@ function parse(input, parseParams) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; - if (yydebug) yydebug('Error recovery process: pushed error info item on the info stack: ', { - item: vstack[sp], - sp, - esp, - vstack, - stack, - sstack, - combineState: NO_ACTION[1] - }); + if (yydebug) { + yydebug('Error recovery process: pushed error info item on the info stack: ', { + item: vstack[sp], + sp, esp, vstack, stack, sstack, + combineState: NO_ACTION[1] + }); + } } else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), @@ -36910,11 +36697,17 @@ function parse(input, parseParams) { yyrulelen = error_rule_depth; - if (yydebug) yydebug('Error recovery process: performAction: COMBINE: ', { - yyval, yytext, sp, pop_size: yyrulelen, vstack, stack, sstack, - combineState: NO_ACTION[1] - }); - r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, NO_ACTION[1], sp - 1, yyrulelen, vstack, lstack, stack, sstack); + let combineState = NO_ACTION[1]; + + if (yydebug) { + yydebug('Error recovery process: performAction: COMBINE: ', { + yyval, yytext, sp, + pop_size: yyrulelen, + vstack, stack, sstack, + combineState + }); + } + r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, combineState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof r !== 'undefined') { retval = r; @@ -36925,7 +36718,7 @@ function parse(input, parseParams) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -36952,7 +36745,7 @@ function parse(input, parseParams) { // allow N (default: 3) real symbols to be shifted before reporting a new error recovering = ERROR_RECOVERY_TOKEN_DISCARD_COUNT; - if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth: error_rule_depth, symbol: symbol, preErrorSymbol: preErrorSymbol }); + if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth, symbol, preErrorSymbol }); // Now duplicate the standard parse machine here, at least its initial // couple of rounds until the TERROR symbol is **pushed onto the parse stack**, @@ -36978,10 +36771,10 @@ function parse(input, parseParams) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -37009,14 +36802,20 @@ function parse(input, parseParams) { newState = t[1]; action = t[0]; - if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('after FETCH/LEX: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol], + state, newState, recovering, action + }); + } // encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { if (yydebug) yydebug('**NESTED ERROR DETECTED** while still recovering from previous error'); - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the \`continue;\` @@ -37030,15 +36829,26 @@ function parse(input, parseParams) { } } - if (yydebug) yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) { - "use strict"; - - if (!nt || !nt.states || !nt.rules) - return ''; - var rulename = nt.states[state]; - var rulespec = nt.rules[rulename][state]; - return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; - })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' + + (action === 1 ? + 'shift token ' + symbol + ' (then go to state ' + newState + ')' : + action === 2 ? + 'reduce by rule: ' + newState + (function __print_rule(nt, state) { + if (!nt || !nt.states || !nt.rules) { + return ''; + } + let rulename = nt.states[state]; + let rulespec = nt.rules[rulename][state]; + return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; + })(this.nonterminals_, newState) : + action === 3 ? + 'accept' : + '???unexpected???' + ), { + action, newState, recovering, symbol + }); + } switch (action) { // catch misc. parse failures: @@ -37062,12 +36872,12 @@ function parse(input, parseParams) { // Push a special value onto the stack when we're // shifting the \`error\` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -37076,7 +36886,7 @@ function parse(input, parseParams) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -37105,14 +36915,14 @@ function parse(input, parseParams) { if (recovering > 0) { recovering--; - if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering, symbol }); } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; - if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering, symbol }); // read action for current state and first input t = (table[newState] && table[newState][symbol]) || NO_ACTION; if (!t[0] || symbol === TERROR) { @@ -37124,7 +36934,7 @@ function parse(input, parseParams) { // recovery, for then this we would we idling (cycling) on the error forever. // Yes, this does not take into account the possibility that the *lexer* may have // produced a *new* TERROR token all by itself, but that would be a very peculiar grammar! - if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering, symbol }); symbol = 0; } } @@ -37140,7 +36950,7 @@ function parse(input, parseParams) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -37151,21 +36961,26 @@ function parse(input, parseParams) { this_production = this.productions_[newState - 1]; // \`this.productions_[]\` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; - if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('~~~ REDUCE: ', { + pop_size: yyrulelen, + newState, recovering, symbol + }); + } r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -37199,15 +37014,17 @@ function parse(input, parseParams) { sp -= yyrulelen; // don't overwrite the \`symbol\` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; - if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol }); + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol }); + } continue; // accept: @@ -37259,7 +37076,7 @@ function parse(input, parseParams) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the \`switch/default\` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -37269,9 +37086,9 @@ function parse(input, parseParams) { // handle parse error if (!action) { - var errStr; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let errStr; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); // Report error errStr = 'Parse error'; @@ -37302,15 +37119,26 @@ function parse(input, parseParams) { } - if (yydebug) yydebug('::: MAIN CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) { - "use strict"; - - if (!nt || !nt.states || !nt.rules) - return ''; - var rulename = nt.states[state]; - var rulespec = nt.rules[rulename][state]; - return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; - })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('::: MAIN CYCLE action: ' + + (action === 1 ? + 'shift token ' + symbol + ' (then go to state ' + newState + ')' : + action === 2 ? + 'reduce by rule: ' + newState + (function __print_rule(nt, state) { + if (!nt || !nt.states || !nt.rules) { + return ''; + } + let rulename = nt.states[state]; + let rulespec = nt.rules[rulename][state]; + return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; + })(this.nonterminals_, newState) : + action === 3 ? + 'accept' : + '???unexpected???' + ), { + action, newState, recovering, symbol + }); + } switch (action) { // catch misc. parse failures: @@ -37341,7 +37169,7 @@ function parse(input, parseParams) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -37358,8 +37186,8 @@ function parse(input, parseParams) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyleng = lexer.yyleng; @@ -37370,27 +37198,32 @@ function parse(input, parseParams) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // \`this.productions_[]\` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; - if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('~~~ REDUCE: ', { + pop_size: yyrulelen, + newState, recovering, symbol + }); + } r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -37421,15 +37254,17 @@ function parse(input, parseParams) { sp -= yyrulelen; // don't overwrite the \`symbol\` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; - if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol }); + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol }); + } continue; // accept: @@ -37482,8 +37317,7 @@ function parse(input, parseParams) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -37516,30 +37350,30 @@ function parse(input, parseParams) { * LR(0) Parser */ - var lr0 = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { + const lr0 = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LR(0)', afterconstructor: function lr0_afterconstructor() { this.buildTable(); } }); - var LR0Generator = Jison$1.LR0Generator = lr0.construct(); + const LR0Generator = Jison$1.LR0Generator = lr0.construct(); /* * Simple LALR(1) */ - var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { + const lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LALR(1)', afterconstructor: function lalr_afterconstructor() { - var self = this; + let self = this; if (this.DEBUG) { this.mix(lrGeneratorDebug, lalrGeneratorDebug); // mixin debug methods } - for (var round = 1; /* infinite loop if it weren't for the `break`s at the end */ ; round++) { + for (let round = 1; /* infinite loop if it weren't for the `break`s at the end */ ; round++) { this.states = this.canonicalCollection(); if (this.DEBUG || devDebug) { @@ -37550,13 +37384,13 @@ function parse(input, parseParams) { this.terms_ = {}; - var newg = this.newg = typal.beget(lookaheadMixin, { + let newg = this.newg = typal.beget(lookaheadMixin, { oldg: this, trace: this.trace, nterms_: {}, DEBUG: false, go_: function (productionSymbol, productionHandle) { - var stateNum = productionSymbol.split(':')[0]; // grab state # + let stateNum = productionSymbol.split(':')[0]; // grab state # assert__default['default'](stateNum == +stateNum); stateNum = +stateNum; productionHandle = productionHandle.map(function (rhsElem) { @@ -37593,8 +37427,8 @@ function parse(input, parseParams) { // backprop `nullable` value for each nonterminal and production back to original grammar: each(newg.nonterminals, function (newg_nt, t) { // extract original symbol: - var sym; - var a = newg_nt.symbol.split(':'); + let sym; + let a = newg_nt.symbol.split(':'); if (a.length === 1 || a[0] === '') { sym = newg_nt.symbol; } else { @@ -37669,8 +37503,8 @@ function parse(input, parseParams) { go: function LALR_go(stateNum, productionHandle, productionSymbol) { assert__default['default'](typeof stateNum === 'number'); - var endStateNum = stateNum; - for (var i = 0; i < productionHandle.length; i++) { + let endStateNum = stateNum; + for (let i = 0; i < productionHandle.length; i++) { endStateNum = this.states.item(endStateNum).edges[productionHandle[i]] || endStateNum; } return endStateNum; @@ -37678,10 +37512,10 @@ function parse(input, parseParams) { goPath: function LALR_goPath(stateNum, productionHandle, productionSymbol) { assert__default['default'](typeof stateNum === 'number'); - var endStateNum = stateNum, - t, - path = []; - for (var i = 0; i < productionHandle.length; i++) { + let endStateNum = stateNum, + t, + path = []; + for (let i = 0; i < productionHandle.length; i++) { t = productionHandle[i] ? endStateNum + ':' + productionHandle[i] /* + ':' + productionSymbol */ : ''; if (t) { this.newg.nterms_[t] = endStateNum; @@ -37699,34 +37533,34 @@ function parse(input, parseParams) { // every disjoint reduction of a nonterminal becomes a production in G' buildNewGrammar: function LALR_buildNewGrammar() { - var self = this, - newg = this.newg; + let self = this, + newg = this.newg; this.states.forEach(function (state, i) { i = +i; state.forEach(function LALR_buildNewHandle(item) { if (item.dotPosition === 0) { // new symbols are a combination of state and transition symbol - var symbol = i + ':' + item.production.symbol; + let symbol = i + ':' + item.production.symbol; assert__default['default'](typeof self.terms_[symbol] === 'undefined' || self.terms_[symbol] === item.production.symbol); self.terms_[symbol] = item.production.symbol; newg.nterms_[symbol] = i; if (!newg.nonterminals[symbol]) { newg.nonterminals[symbol] = new Nonterminal(symbol); } - var pathInfo = self.goPath(i, item.production.handle, item.production.symbol); - var p = new Production(symbol, pathInfo.path, newg.productions.length); + let pathInfo = self.goPath(i, item.production.handle, item.production.symbol); + let p = new Production(symbol, pathInfo.path, newg.productions.length); newg.productions.push(p); newg.nonterminals[symbol].productions.push(p); // store the transition that gets 'backed up to' after reduction on path - var handle = item.production.handle.join(' '); + let handle = item.production.handle.join(' '); if (self.conflict_fixing_round && self.conflict_states_LU[i]) ; if (self.conflict_fixing_round && self.conflict_productions_LU[item.production.id]) { handle += ':P' + item.production.id; } - var goes = self.states.item(pathInfo.endState).goes; + let goes = self.states.item(pathInfo.endState).goes; if (!goes[handle]) { goes[handle] = []; } @@ -37740,22 +37574,22 @@ function parse(input, parseParams) { }, unionLookaheads: function LALR_unionLookaheads() { - var self = this, - newg = this.newg; - // var states = !!this.onDemandLookahead ? this.inadequateStates : this.states; + let self = this, + newg = this.newg; + // let states = !!this.onDemandLookahead ? this.inadequateStates : this.states; - var these_states = this.states; + let these_states = this.states; these_states.forEach(function union_states_forEach(state, i) { i = +i; //assert(state.inadequate ? these_states.inadequate : true); - var treat_me = (self.onDemandLookahead ? these_states.inadequate || state.inadequate : true); + let treat_me = (self.onDemandLookahead ? these_states.inadequate || state.inadequate : true); if (state.reductions.length && treat_me) { state.reductions.forEach(function union_reduction_forEach(item) { - var follows = {}; - for (var k = 0; k < item.follows.length; k++) { + let follows = {}; + for (let k = 0; k < item.follows.length; k++) { follows[item.follows[k]] = true; } - var handle = item.production.handle.join(' '); + let handle = item.production.handle.join(' '); if (self.conflict_fixing_round && self.conflict_states_LU[i]) ; if (self.conflict_fixing_round && self.conflict_productions_LU[item.production.id]) { handle += ':P' + item.production.id; @@ -37766,7 +37600,7 @@ function parse(input, parseParams) { state.goes[handle].forEach(function reduction_goes_forEach(symbol) { newg.nonterminals[symbol].follows.forEach(function goes_follows_forEach(symbol) { - var terminal = self.terms_[symbol]; + let terminal = self.terms_[symbol]; if (!follows[terminal]) { follows[terminal] = true; @@ -37780,11 +37614,11 @@ function parse(input, parseParams) { } }); - var LALRGenerator = Jison$1.LALRGenerator = lalr.construct(); + const LALRGenerator = Jison$1.LALRGenerator = lalr.construct(); // LALR generator debug mixin - var lalrGeneratorDebug = { + const lalrGeneratorDebug = { beforebuildNewGrammar: function () { this.trace(this.states.size() + ' states.'); this.trace('Building lookahead grammar.'); @@ -37801,7 +37635,7 @@ function parse(input, parseParams) { aftercomputeLookaheads: function () { traceStates(this.trace, this.states, 'after LALR::computeLookaheads()'); }, - aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */ ) { + aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */) { traceStates(this.trace, states, 'as produced by LALR::canonicalCollection()'); } }; @@ -37811,7 +37645,7 @@ function parse(input, parseParams) { * * Define base type */ - var lrLookaheadGenerator = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { + const lrLookaheadGenerator = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { afterconstructor: function lr_aftercontructor() { this.computeLookaheads(); @@ -37828,7 +37662,7 @@ function parse(input, parseParams) { /* * SLR Parser */ - var SLRGenerator = Jison$1.SLRGenerator = lrLookaheadGenerator.construct({ + const SLRGenerator = Jison$1.SLRGenerator = lrLookaheadGenerator.construct({ type: 'SLR(1)', lookAheads: function SLR_lookAhead(state, item) { @@ -37840,7 +37674,7 @@ function parse(input, parseParams) { /* * LR(1) Parser */ - var lr1 = lrLookaheadGenerator.beget({ + const lr1 = lrLookaheadGenerator.beget({ type: 'Canonical LR(1)', lookAheads: function LR_lookAheads(state, item) { @@ -37857,28 +37691,26 @@ function parse(input, parseParams) { }), closureOperation: function LR_ClosureOperation(itemSet) { - var closureSet = new this.ItemSet(); - var self = this; + let closureSet = new this.ItemSet(); + let self = this; - var set = itemSet, - itemQueue; + let set = itemSet; do { - itemQueue = new Set(); + let itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function LR_AddItemToClosureSets(item) { - var symbol = item.markedSymbol; - var b, r; + let symbol = item.markedSymbol; // if token is a nonterminal, recursively add closures if (symbol && self.nonterminals[symbol]) { - r = item.remainingHandle(); - b = self.first(r); + let r = item.remainingHandle(); + let b = self.first(r); if (b.length === 0 || item.production.nullable || self.nullable(r)) { b = b.concat(item.follows); } self.nonterminals[symbol].productions.forEach(function (production) { - var newItem = new self.Item(production, 0, b); + let newItem = new self.Item(production, 0, b); if (!closureSet.contains(newItem) && !itemQueue.contains(newItem)) { itemQueue.push(newItem); } @@ -37890,18 +37722,18 @@ function parse(input, parseParams) { }); set = itemQueue; - } while (!itemQueue.isEmpty()); + } while (!set.isEmpty()); return closureSet; } }); - var LR1Generator = Jison$1.LR1Generator = lr1.construct(); + const LR1Generator = Jison$1.LR1Generator = lr1.construct(); /* * LL Parser */ - var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { + const ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LL(1)', afterconstructor: function ll_aftercontructor() { @@ -37924,13 +37756,13 @@ function parse(input, parseParams) { }, parseTable: function ll_ParseTable(productions) { - var table = {}, - symbols_ = this.symbols_, - self = this; + let table = {}; + let symbols_ = this.symbols_; + let self = this; productions.forEach(function (production, i) { - var row = table[production.symbol] || {}; - var tokens = production.first; + let row = table[production.symbol] || {}; + let tokens = production.first; if (self.nullable(production.handle)) { tokens = union(tokens, self.nonterminals[production.symbol].follows); } @@ -37939,7 +37771,7 @@ function parse(input, parseParams) { row[token].push(i); self.conflicts++; } else { - row[token] = [i]; + row[token] = [ i ]; } }); table[production.symbol] = row; @@ -37950,16 +37782,16 @@ function parse(input, parseParams) { } }); - var LLGenerator = Jison$1.LLGenerator = ll.construct(); + const LLGenerator = Jison$1.LLGenerator = ll.construct(); Jison$1.Generator = function Jison_Generator(grammar, optionalLexerSection, options) { // pick the correct argument for the `options` for this call: if (!options && optionalLexerSection && typeof optionalLexerSection !== 'string') { - options = optionalLexerSection; - optionalLexerSection = null; + options = optionalLexerSection; + optionalLexerSection = null; } // and standardize it: - var preliminary_options = mkStdOptions$1(options); + let preliminary_options = mkStdOptions$1(options); // Provisionally parse the grammar, really only to obtain the *options.type* // specified within the grammar, if specified (via `%parser-type`). @@ -37981,7 +37813,7 @@ function parse(input, parseParams) { // // Anyway, API/CLI options **override** options coming in from the grammar spec. // - options = mkStdOptions$1("NODEFAULT", grammar.options, options); + options = mkStdOptions$1('NODEFAULT', grammar.options, options); switch (options.type || Jison$1.defaultJisonOptions.type) { case 'lr0': options.hasPartialLrUpgradeOnConflict = false; // kill this unsupported option @@ -38007,14 +37839,28 @@ function parse(input, parseParams) { }; function Parser$3(g, l, options) { - var gen = Jison$1.Generator(g, l, options); + let gen = Jison$1.Generator(g, l, options); return gen.createParser(); } Jison$1.Parser = Parser$3; - var rmCommonWS$6 = helpers.rmCommonWS; - var mkIdentifier$5 = helpers.mkIdentifier; + // exports for unit/system testing purposes: + Jison$1.TestExports = { + lookaheadMixin, generatorMixin, lrGeneratorMixin, + lalr, + lr0, + lr1, + ll, + parser: parser$4, + pickErrorHandlingChunk, + addOrRemoveTokenStack, + removeUnusedKernelFeatures, + expandParseArguments + }; + + const rmCommonWS$6 = helpers.rmCommonWS; + const mkIdentifier$5 = helpers.mkIdentifier; assert__default['default'](Jison$1); @@ -38024,13 +37870,12 @@ function parse(input, parseParams) { assert__default['default'](typeof Jison$1.Generator === 'function'); - var version$3 = '0.6.2-220'; // require('./package.json').version; + const version$3 = '0.7.0-220'; // require('./package.json').version; function getCommandlineOptions() { - - var defaults = Jison$1.defaultJisonOptions; - var opts = nomnom__default['default'] + const defaults = Jison$1.defaultJisonOptions; + let opts = nomnom__default['default'] .script('jison') .unknownOptionTreatment(false) // do not accept unknown options! .produceExplicitOptionsOnly(true) @@ -38086,7 +37931,7 @@ function parse(input, parseParams) { abbr: 'm', default: defaults.moduleType, metavar: 'TYPE', - choices: ['commonjs', 'cjs', 'amd', 'umd', 'js', 'iife', 'es'], + choices: [ 'commonjs', 'cjs', 'amd', 'umd', 'js', 'iife', 'es' ], help: 'The type of module to generate.' }, moduleName: { @@ -38108,7 +37953,7 @@ function parse(input, parseParams) { abbr: 'c', flag: false, default: defaults.compressTables, // 0, 1, 2 - choices: [0, 1, 2], + choices: [ 0, 1, 2 ], help: 'Output compressed parser tables in generated modules. (0 = no compression, 1 = default compression, 2 = deep compression)' }, outputDebugTables: { @@ -38138,7 +37983,7 @@ function parse(input, parseParams) { // FAIL when found: return this.help; }, - help: 'OBSOLETED. Use \'--default-action=[for-value,for-location]\' instead. (See below in \'--help\' output.)' + help: "OBSOLETED. Use '--default-action=[for-value,for-location]' instead. (See below in '--help' output.)" }, defaultActionMode: { full: 'default-action', @@ -38146,21 +37991,21 @@ function parse(input, parseParams) { default: defaults.defaultActionMode, callback: function (val) { // split value at comma, expect zero, one or two values: - var v = ('' + val).split(','); + let v = ('' + val).split(','); if (v.length > 2) { return 'default-action=yyval,yylloc expects at most 2 modes! You specified ' + v.length; } }, transform: function (val) { // split value at comma, expect zero, one or two values: - var option = this; - var def = option.default; - var v = ('' + val).split(',').map(function cvt_modes(mode, idx) { + let option = this; + let def = option.default; + let v = ('' + val).split(',').map(function cvt_modes(mode, idx) { mode = mode.trim(); switch (mode) { case 'false': case '0': - return "none"; + return 'none'; case 'true': case '1': @@ -38186,7 +38031,7 @@ function parse(input, parseParams) { - classic : generate a parser which includes the default $$ = $1; action for every rule. - - 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 dentical to "classic" mode. + - 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. - 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;" - 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! @@ -38202,7 +38047,7 @@ function parse(input, parseParams) { --default-action=ast equals: --default-action=ast,ast - - when you do not specify an explicit default mode or only a "true"/"1" value, the default is assumed: "${defaults.defaultActionMode.join(",")}". + - when you do not specify an explicit default mode or only a "true"/"1" value, the default is assumed: "${defaults.defaultActionMode.join(',')}". - when you specify "false"/"0" as an explicit default mode, "none,none" is assumed. This produces the fastest deterministic parser. ` }, @@ -38219,11 +38064,11 @@ function parse(input, parseParams) { default: defaults.errorRecoveryTokenDiscardCount, callback: function (count) { if (count != parseInt(count)) { - return "count must be an integer"; + return 'count must be an integer'; } count = parseInt(count); if (count < 2) { - return "count must be >= 2"; + return 'count must be >= 2'; } }, transform: function (val) { @@ -38236,7 +38081,7 @@ function parse(input, parseParams) { abbr: 'E', flag: true, default: defaults.exportAllTables, - help: 'Next to producing a grammar source file, also export the symbols, terminals, grammar and parse tables to separate JSON files for further use by other tools. The files\' names will be derived from the outputFile name by appending a suffix.' + help: "Next to producing a grammar source file, also export the symbols, terminals, grammar and parse tables to separate JSON files for further use by other tools. The files' names will be derived from the outputFile name by appending a suffix." }, exportAST: { full: 'export-ast', @@ -38264,7 +38109,7 @@ function parse(input, parseParams) { flag: true, metavar: 'false|true|CFGFILE', default: defaults.prettyCfg, - help: 'Output the generated code pretty-formatted; turning this option OFF will output the generated code as-is a.k.a. \'raw\'.', + help: "Output the generated code pretty-formatted; turning this option OFF will output the generated code as-is a.k.a. 'raw'." }, main: { full: 'main', @@ -38291,7 +38136,7 @@ function parse(input, parseParams) { }).parse(); if (opts.debug) { - console.log("JISON CLI options:\n", opts); + console.log('JISON CLI options:\n', opts); } return opts; @@ -38318,7 +38163,7 @@ function parse(input, parseParams) { return true; } catch (e) { if (e.code === 'ENOENT') { - var parent = path__default['default'].dirname(fp); + let parent = path__default['default'].dirname(fp); // Did we hit the root directory by now? If so, abort! // Else, create the parent; iff that fails, we fail too... if (parent !== fp && mkdirp(parent)) { @@ -38337,20 +38182,20 @@ function parse(input, parseParams) { function processInputFile() { // getting raw files - var lex; - var original_cwd = process__default['default'].cwd(); + let lex; + const original_cwd = process__default['default'].cwd(); if (opts.lexfile) { lex = fs__default['default'].readFileSync(path__default['default'].normalize(opts.lexfile), 'utf8'); } - var raw = fs__default['default'].readFileSync(path__default['default'].normalize(opts.file), 'utf8'); + let raw = fs__default['default'].readFileSync(path__default['default'].normalize(opts.file), 'utf8'); // making best guess at json mode opts.json = path__default['default'].extname(opts.file) === '.json' || opts.json; // When only the directory part of the output path was specified, then we // do NOT have the target module name in there as well! - var outpath = opts.outfile; + let outpath = opts.outfile; if (typeof outpath === 'string') { if (/[\\\/]$/.test(outpath) || isDirectory(outpath)) { opts.outfile = null; @@ -38369,7 +38214,7 @@ function parse(input, parseParams) { // setting output file name and module name based on input file name // if they aren't specified. - var name = path__default['default'].basename(opts.outfile || opts.file); + let name = path__default['default'].basename(opts.outfile || opts.file); // get the base name (i.e. the file name without extension) // i.e. strip off only the extension and keep any other dots in the filename @@ -38426,10 +38271,10 @@ function parse(input, parseParams) { // Change CWD to the directory where the source grammar resides: this helps us properly // %include any files mentioned in the grammar with relative paths: - var new_cwd = path__default['default'].dirname(path__default['default'].normalize(opts.file)); + let new_cwd = path__default['default'].dirname(path__default['default'].normalize(opts.file)); process__default['default'].chdir(new_cwd); - var parser = cli.generateParserString(raw, lex, opts); + let parser = cli.generateParserString(raw, lex, opts); // and change back to the CWD we started out with: process__default['default'].chdir(original_cwd); @@ -38442,11 +38287,11 @@ function parse(input, parseParams) { if (opts.exportAllTables.enabled) { // Determine the output file path 'template' for use by the exportAllTables // functionality: - var out_base_fname = path__default['default'].join(path__default['default'].dirname(opts.outfile), path__default['default'].basename(opts.outfile, path__default['default'].extname(opts.outfile))); + let out_base_fname = path__default['default'].join(path__default['default'].dirname(opts.outfile), path__default['default'].basename(opts.outfile, path__default['default'].extname(opts.outfile))); - var t = opts.exportAllTables; + let t = opts.exportAllTables; - for (var id in t) { + for (let id in t) { if (t.hasOwnProperty(id) && id !== 'enabled') { var content = t[id]; if (content) { @@ -38487,8 +38332,8 @@ function parse(input, parseParams) { } function readin(cb) { - var stdin = process__default['default'].openStdin(), - data = ''; + let stdin = process__default['default'].openStdin(), + data = ''; stdin.setEncoding('utf8'); stdin.addListener('data', function (chunk) { @@ -38516,10 +38361,11 @@ function parse(input, parseParams) { function generateParserString(grammar, optionalLexSection, opts) { + // var settings = Jison.mkStdOptions(opts); - var generator = new Jison$1.Generator(grammar, optionalLexSection, opts); - var srcCode = generator.generate(opts); + let generator = new Jison$1.Generator(grammar, optionalLexSection, opts); + let srcCode = generator.generate(opts); generator.reportGrammarInformation(); // as `opts` is cloned inside `generator.generate()`, we need to fetch @@ -38538,7 +38384,7 @@ function parse(input, parseParams) { if (require.main === module) { - var opts = getCommandlineOptions(); + let opts = getCommandlineOptions(); cli.main(opts); } diff --git a/dist/jison-cjs-es5.js b/dist/jison-cjs-es5.js index 52a6ec68f..5faa29db2 100644 --- a/dist/jison-cjs-es5.js +++ b/dist/jison-cjs-es5.js @@ -1,7 +1,17 @@ 'use strict'; +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 "]); + + _templateObject162 = function _templateObject162() { + return data; + }; + + return data; +} + function _templateObject161() { - var data = _taggedTemplateLiteral(["\n ", "\n\n var 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 var 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 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 "]); _templateObject161 = function _templateObject161() { return data; @@ -11,7 +21,7 @@ function _templateObject161() { } function _templateObject160() { - 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\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 "]); _templateObject160 = function _templateObject160() { return data; @@ -21,7 +31,7 @@ function _templateObject160() { } function _templateObject159() { - 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 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 "]); _templateObject159 = function _templateObject159() { return data; @@ -31,7 +41,7 @@ function _templateObject159() { } function _templateObject158() { - 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 // 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 "]); _templateObject158 = function _templateObject158() { return data; @@ -41,7 +51,7 @@ function _templateObject158() { } function _templateObject157() { - 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 ", "\n\n let yymain = ", ";\n\n function yyExecMain() {\n yymain(process.argv.slice(1));\n }\n "]); _templateObject157 = function _templateObject157() { return data; @@ -51,7 +61,7 @@ function _templateObject157() { } function _templateObject156() { - var data = _taggedTemplateLiteral(["\n\n ", "\n\n var yymain = ", ";\n\n function yyExecMain() {\n yymain(process.argv.slice(1));\n }\n "]); + var data = _taggedTemplateLiteral(["\n\n // START code section \"", "\"\n ", "\n // END code section \"", "\"\n\n "]); _templateObject156 = function _templateObject156() { return data; @@ -61,7 +71,7 @@ function _templateObject156() { } function _templateObject155() { - var data = _taggedTemplateLiteral(["\n\n // START code section \"", "\"\n ", "\n // END code section \"", "\"\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 "]); _templateObject155 = function _templateObject155() { return data; @@ -71,7 +81,7 @@ function _templateObject155() { } function _templateObject154() { - 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 %%\n\n "]); _templateObject154 = function _templateObject154() { return data; @@ -81,7 +91,7 @@ function _templateObject154() { } function _templateObject153() { - var data = _taggedTemplateLiteral(["\n\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 "]); _templateObject153 = function _templateObject153() { return data; @@ -91,7 +101,7 @@ function _templateObject153() { } function _templateObject152() { - 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 %%\n\n "]); _templateObject152 = function _templateObject152() { return data; @@ -101,7 +111,7 @@ function _templateObject152() { } function _templateObject151() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n /*\n * Parser stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); _templateObject151 = function _templateObject151() { return data; @@ -111,7 +121,7 @@ function _templateObject151() { } function _templateObject150() { - var data = _taggedTemplateLiteral(["\n /*\n * Parser stuff that's unknown to the JISON prettyPrint service:\n *\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 "]); _templateObject150 = function _templateObject150() { return data; @@ -121,7 +131,7 @@ function _templateObject150() { } function _templateObject149() { - 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 // END of unknown declarations.\n "]); _templateObject149 = function _templateObject149() { return data; @@ -131,7 +141,7 @@ function _templateObject149() { } function _templateObject148() { - var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); + var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); _templateObject148 = function _templateObject148() { return data; @@ -141,7 +151,7 @@ function _templateObject148() { } function _templateObject147() { - var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject147 = function _templateObject147() { return data; @@ -161,7 +171,7 @@ function _templateObject146() { } function _templateObject145() { - 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 "]); _templateObject145 = function _templateObject145() { return data; @@ -171,7 +181,7 @@ function _templateObject145() { } function _templateObject144() { - var data = _taggedTemplateLiteral(["\n /*\n * Lexer stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); + var data = _taggedTemplateLiteral(["\n // options:\n "]); _templateObject144 = function _templateObject144() { return data; @@ -181,7 +191,7 @@ function _templateObject144() { } function _templateObject143() { - var data = _taggedTemplateLiteral(["\n // options:\n "]); + var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); _templateObject143 = function _templateObject143() { return data; @@ -191,7 +201,7 @@ function _templateObject143() { } function _templateObject142() { - var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); + var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); _templateObject142 = function _templateObject142() { return data; @@ -201,7 +211,7 @@ function _templateObject142() { } function _templateObject141() { - var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); + var data = _taggedTemplateLiteral(["\n // END of the lexer macros.\n "]); _templateObject141 = function _templateObject141() { return data; @@ -211,7 +221,7 @@ function _templateObject141() { } function _templateObject140() { - var data = _taggedTemplateLiteral(["\n // END of the lexer macros.\n "]); + var data = _taggedTemplateLiteral(["\n // macros:\n "]); _templateObject140 = function _templateObject140() { return data; @@ -221,7 +231,7 @@ function _templateObject140() { } function _templateObject139() { - var data = _taggedTemplateLiteral(["\n // macros:\n "]); + var data = _taggedTemplateLiteral(["\n unsupported parser input: ", "\n while lexing in ", " state.\n \n Erroneous area:\n "]); _templateObject139 = function _templateObject139() { return data; @@ -231,7 +241,7 @@ function _templateObject139() { } function _templateObject138() { - 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 "]); _templateObject138 = function _templateObject138() { return data; @@ -261,7 +271,7 @@ function _templateObject136() { } function _templateObject135() { - 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 "]); _templateObject135 = function _templateObject135() { return data; @@ -291,7 +301,7 @@ function _templateObject133() { } function _templateObject132() { - 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 "]); _templateObject132 = function _templateObject132() { return data; @@ -321,7 +331,7 @@ function _templateObject130() { } function _templateObject129() { - 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 "]); _templateObject129 = function _templateObject129() { return data; @@ -331,7 +341,7 @@ function _templateObject129() { } function _templateObject128() { - var data = _taggedTemplateLiteral(["\n EBNF: ignoring unsupported parser option ", "\n while lexing in ", " state.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n module code declaration error?\n \n Erroneous area:\n "]); _templateObject128 = function _templateObject128() { return data; @@ -341,7 +351,7 @@ function _templateObject128() { } function _templateObject127() { - var data = _taggedTemplateLiteral(["\n module code declaration error?\n \n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n "]); _templateObject127 = function _templateObject127() { return data; @@ -351,7 +361,7 @@ function _templateObject127() { } function _templateObject126() { - var data = _taggedTemplateLiteral(["\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n "]); + var data = _taggedTemplateLiteral(["\n included action code file \"", "\" does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject126 = function _templateObject126() { return data; @@ -361,7 +371,7 @@ function _templateObject126() { } function _templateObject125() { - 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 match curly braces '{ ... }' in a parser rule action block.\n \n Erroneous area:\n ", "\n "]); _templateObject125 = function _templateObject125() { return data; @@ -371,7 +381,7 @@ function _templateObject125() { } function _templateObject124() { - 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 Seems you did not correctly bracket a parser rule action block in curly braces: '{ ... }'.\n \n Erroneous area:\n ", "\n "]); _templateObject124 = function _templateObject124() { return data; @@ -381,7 +391,7 @@ function _templateObject124() { } function _templateObject123() { - 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 %prec precedence override declaration error?\n \n Erroneous precedence declaration:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject123 = function _templateObject123() { return data; @@ -391,7 +401,7 @@ function _templateObject123() { } function _templateObject122() { - 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 Seems you did not correctly bracket a grammar rule sublist in '( ... )' brackets.\n \n Erroneous area:\n ", "\n "]); _templateObject122 = function _templateObject122() { return data; @@ -401,7 +411,7 @@ function _templateObject122() { } function _templateObject121() { - 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 rule action declaration error?\n \n Erroneous area:\n ", "\n "]); _templateObject121 = function _templateObject121() { return data; @@ -411,7 +421,7 @@ function _templateObject121() { } function _templateObject120() { - 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 "]); _templateObject120 = function _templateObject120() { return data; @@ -421,7 +431,7 @@ function _templateObject120() { } function _templateObject119() { - 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 "]); _templateObject119 = function _templateObject119() { return data; @@ -431,7 +441,7 @@ function _templateObject119() { } function _templateObject118() { - 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 action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject118 = function _templateObject118() { return data; @@ -441,7 +451,7 @@ function _templateObject118() { } function _templateObject117() { - var data = _taggedTemplateLiteral(["\n production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n multiple alternative rule productions should be separated by a '|' pipe character, not a ':' colon!\n \n Erroneous area:\n ", "\n "]); _templateObject117 = function _templateObject117() { return data; @@ -451,7 +461,7 @@ function _templateObject117() { } function _templateObject116() { - var data = _taggedTemplateLiteral(["\n multiple alternative rule productions should be separated by a '|' pipe character, not a ':' colon!\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n rule alternative production declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject116 = function _templateObject116() { return data; @@ -461,7 +471,7 @@ function _templateObject116() { } function _templateObject115() { - var data = _taggedTemplateLiteral(["\n rule alternative production declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Production for rule '", "' is missing: arrows introduce action code in Jison.\n \n Jison does not support rule production definition using arrows (->, =>, \u2192) but expects\n colons (:) instead, so maybe you intended this:\n \n ", " : ", "\n \n while the user-defined action code block MAY be an arrow function, e.g.\n \n rule: math_production -> Math.min($math_production, 42);\n \n Erroneous area:\n ", "\n "]); _templateObject115 = function _templateObject115() { return data; @@ -471,7 +481,7 @@ function _templateObject115() { } function _templateObject114() { - var data = _taggedTemplateLiteral(["\n Production for rule '", "' is missing: arrows introduce action code in Jison.\n \n Jison does not support rule production definition using arrows (->, =>, \u2192) but expects\n colons (:) instead, so maybe you intended this:\n \n ", " : ", "\n \n while the user-defined action code block MAY be an arrow function, e.g.\n \n rule: math_production -> Math.min($math_production, 42);\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n rule id should be followed by a colon, but that one seems missing?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject114 = function _templateObject114() { return data; @@ -481,7 +491,7 @@ function _templateObject114() { } function _templateObject113() { - var data = _taggedTemplateLiteral(["\n rule id should be followed by a colon, but that one seems missing?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n rule production declaration error: did you terminate the rule production set with a semicolon?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject113 = function _templateObject113() { return data; @@ -491,7 +501,7 @@ function _templateObject113() { } function _templateObject112() { - var data = _taggedTemplateLiteral(["\n rule production declaration error: did you terminate the rule production set with a semicolon?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n rule production declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject112 = function _templateObject112() { return data; @@ -501,7 +511,7 @@ function _templateObject112() { } function _templateObject111() { - var data = _taggedTemplateLiteral(["\n rule production declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n operator token list error in an associativity statement?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject111 = function _templateObject111() { return data; @@ -511,7 +521,7 @@ function _templateObject111() { } function _templateObject110() { - var data = _taggedTemplateLiteral(["\n operator token list error in an associativity statement?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %parser-type declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject110 = function _templateObject110() { return data; @@ -521,7 +531,7 @@ function _templateObject110() { } function _templateObject109() { - var data = _taggedTemplateLiteral(["\n %parser-type declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %parse-params declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject109 = function _templateObject109() { return data; @@ -531,7 +541,7 @@ function _templateObject109() { } function _templateObject108() { - var data = _taggedTemplateLiteral(["\n %parse-params declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n named %option value assignment error?\n \n Erroneous area:\n ", "\n "]); _templateObject108 = function _templateObject108() { return data; @@ -541,7 +551,7 @@ function _templateObject108() { } function _templateObject107() { - var data = _taggedTemplateLiteral(["\n named %option value assignment error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n named %option value error for ", "?\n \n Erroneous area:\n ", "\n "]); _templateObject107 = function _templateObject107() { return data; @@ -551,7 +561,7 @@ function _templateObject107() { } function _templateObject106() { - var data = _taggedTemplateLiteral(["\n named %option value error for ", "?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %options don't seem terminated?\n \n Erroneous area:\n ", "\n "]); _templateObject106 = function _templateObject106() { return data; @@ -561,7 +571,7 @@ function _templateObject106() { } function _templateObject105() { - var data = _taggedTemplateLiteral(["\n %options don't seem terminated?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %options ill defined / error?\n \n Erroneous area:\n ", "\n "]); _templateObject105 = function _templateObject105() { return data; @@ -571,7 +581,7 @@ function _templateObject105() { } function _templateObject104() { - var data = _taggedTemplateLiteral(["\n %options ill defined / error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %import name or source filename missing maybe?\n \n Erroneous area:\n ", "\n "]); _templateObject104 = function _templateObject104() { return data; @@ -581,7 +591,7 @@ function _templateObject104() { } function _templateObject103() { - var data = _taggedTemplateLiteral(["\n %import name or source filename missing maybe?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %token definition list error?\n \n Erroneous area:\n ", "\n "]); _templateObject103 = function _templateObject103() { return data; @@ -591,7 +601,7 @@ function _templateObject103() { } function _templateObject102() { - var data = _taggedTemplateLiteral(["\n %token definition list error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %start token error?\n \n Erroneous area:\n ", "\n "]); _templateObject102 = function _templateObject102() { return data; @@ -601,7 +611,7 @@ function _templateObject102() { } function _templateObject101() { - var data = _taggedTemplateLiteral(["\n %start token error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Each '%code' initialization code section must be qualified by a name, e.g. 'required' before the action code itself:\n \n %code qualifier_name {action code}\n \n Erroneous area:\n ", "\n "]); _templateObject101 = function _templateObject101() { return data; @@ -611,7 +621,7 @@ function _templateObject101() { } function _templateObject100() { - var data = _taggedTemplateLiteral(["\n Each '%code' initialization code section must be qualified by a name, e.g. 'required' before the action code itself:\n \n %code qualifier_name {action code}\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %code \"", "\" initialization section action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject100 = function _templateObject100() { return data; @@ -621,7 +631,7 @@ function _templateObject100() { } function _templateObject99() { - var data = _taggedTemplateLiteral(["\n %code \"", "\" initialization section action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Each '%import'-ed initialization code section must be qualified by a name, e.g. 'required' before the import path itself:\n \n %import qualifier_name file_path\n \n Erroneous area:\n ", "\n "]); _templateObject99 = function _templateObject99() { return data; @@ -631,7 +641,7 @@ function _templateObject99() { } function _templateObject98() { - var data = _taggedTemplateLiteral(["\n Each '%import'-ed initialization code section must be qualified by a name, e.g. 'required' before the import path itself:\n \n %import qualifier_name file_path\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n You did not specify a legal file path for the '%import' initialization code statement, which must have the format:\n \n %import qualifier_name file_path\n \n Erroneous area:\n ", "\n "]); _templateObject98 = function _templateObject98() { return data; @@ -641,7 +651,7 @@ function _templateObject98() { } function _templateObject97() { - var data = _taggedTemplateLiteral(["\n You did not specify a legal file path for the '%import' initialization code statement, which must have the format:\n \n %import qualifier_name file_path\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n action header code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject97 = function _templateObject97() { return data; @@ -651,7 +661,7 @@ function _templateObject97() { } function _templateObject96() { - var data = _taggedTemplateLiteral(["\n action header code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject96 = function _templateObject96() { return data; @@ -661,7 +671,7 @@ function _templateObject96() { } function _templateObject95() { - var data = _taggedTemplateLiteral(["\n action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n declaration list error?\n \n Erroneous area:\n ", "\n "]); _templateObject95 = function _templateObject95() { return data; @@ -671,7 +681,7 @@ function _templateObject95() { } function _templateObject94() { - var data = _taggedTemplateLiteral(["\n declaration list error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n action header code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject94 = function _templateObject94() { return data; @@ -681,7 +691,7 @@ function _templateObject94() { } function _templateObject93() { - var data = _taggedTemplateLiteral(["\n action header code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n The extra parser module code section (a.k.a. 'epilogue') does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject93 = function _templateObject93() { return data; @@ -691,7 +701,7 @@ function _templateObject93() { } function _templateObject92() { - var data = _taggedTemplateLiteral(["\n The extra parser module code section (a.k.a. 'epilogue') does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Maybe you did not correctly separate the parse 'header section' (token definitions, options, lexer spec, etc.) from the grammar rule set with a '%%' on an otherwise empty line?\n \n Erroneous area:\n ", "\n "]); _templateObject92 = function _templateObject92() { return data; @@ -701,7 +711,7 @@ function _templateObject92() { } function _templateObject91() { - var data = _taggedTemplateLiteral(["\n Maybe you did not correctly separate the parse 'header section' (token definitions, options, lexer spec, etc.) from the grammar rule set with a '%%' on an otherwise empty line?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n illegal input in the parser grammar productions definition section.\n \n Maybe you did not correctly separate trailing code from the grammar rule set with a '%%' marker on an otherwise empty line?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject91 = function _templateObject91() { return data; @@ -711,7 +721,7 @@ function _templateObject91() { } function _templateObject90() { - var data = _taggedTemplateLiteral(["\n illegal input in the parser grammar productions definition section.\n \n Maybe you did not correctly separate trailing code from the grammar rule set with a '%%' marker on an otherwise empty line?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n ", "\n\n var ", " = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n\n if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\n exports.lexer = ", ";\n exports.lex = function () {\n return ", ".lex.apply(lexer, arguments);\n };\n }\n "]); _templateObject90 = function _templateObject90() { return data; @@ -721,7 +731,7 @@ function _templateObject90() { } function _templateObject89() { - var data = _taggedTemplateLiteral(["\n ", "\n\n var ", " = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n\n if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\n exports.lexer = ", ";\n exports.lex = function () {\n return ", ".lex.apply(lexer, arguments);\n };\n }\n "]); + var data = _taggedTemplateLiteral(["\n ", "\n\n const lexer = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n\n function yylex() {\n return lexer.lex.apply(lexer, arguments);\n }\n\n export {\n lexer,\n yylex as lex\n };\n "]); _templateObject89 = function _templateObject89() { return data; @@ -731,7 +741,7 @@ function _templateObject89() { } function _templateObject88() { - var data = _taggedTemplateLiteral(["\n ", "\n\n var lexer = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n\n function yylex() {\n return lexer.lex.apply(lexer, arguments);\n }\n\n export {\n lexer,\n yylex as lex\n };\n "]); + var data = _taggedTemplateLiteral(["\n ", "\n\n define([], function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n });\n "]); _templateObject88 = function _templateObject88() { return data; @@ -741,7 +751,7 @@ function _templateObject88() { } function _templateObject87() { - var data = _taggedTemplateLiteral(["\n ", "\n\n define([], function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n });\n "]); + var data = _taggedTemplateLiteral(["\n ", "\n\n var ", " = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n "]); _templateObject87 = function _templateObject87() { return data; @@ -751,7 +761,7 @@ function _templateObject87() { } function _templateObject86() { - var data = _taggedTemplateLiteral(["\n ", "\n\n var ", " = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n "]); + var data = _taggedTemplateLiteral(["\n /* lexer generated by jison-lex ", " */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" `yy` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This \"shared context\" object was passed to the lexer by way of\n * the `lexer.setInput(str, yy)` API before you may use it.\n *\n * This \"shared context\" object is passed to the lexer action code in `performAction()`\n * so userland code in the lexer actions may communicate with the outside world\n * and/or other lexer rules' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall \"shared context\" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `lexer` instance.\n * `yy_` is an alias for `this` lexer instance reference used internally.\n *\n * - `yy` : a reference to the `yy` \"shared state\" object which was passed to the lexer\n * by way of the `lexer.setInput(str, yy)` API before.\n *\n * Note:\n * The extra arguments you specified in the `%parse-param` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - `yyrulenumber` : index of the matched lexer rule (regex), used internally.\n *\n * - `YY_START`: the current lexer \"start condition\" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.\n * See it's use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo('fail!', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the `lexer.setInput()` API.\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of the **lexer** grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Lexer's additional `args...` parameters (via lexer's `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the **parser** or the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.\n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (`yylloc`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a 'hash' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal \"shared state\" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while `this` will reference the current lexer instance.\n *\n * When `parseError` is invoked by the lexer, the default implementation will\n * attempt to invoke `yy.parser.parseError()`; when this callback is not provided\n * it will try to invoke `yy.parseError()` instead. When that callback is also not\n * provided, a `JisonLexerError` exception will be thrown containing the error\n * message and `hash`, as constructed by the `constructLexErrorInfo()` API.\n *\n * Note that the lexer's `JisonLexerError` error class is passed via the\n * `ExceptionClass` argument, which is invoked to construct the exception\n * instance to be thrown, so technically `parseError` will throw the object\n * produced by the `new ExceptionClass(str, hash)` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the `.options` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n *\n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are \"extended regex format\" requiring the\n * `XRegExp` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n "], ["\n /* lexer generated by jison-lex ", " */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" \\`yy\\` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This \"shared context\" object was passed to the lexer by way of\n * the \\`lexer.setInput(str, yy)\\` API before you may use it.\n *\n * This \"shared context\" object is passed to the lexer action code in \\`performAction()\\`\n * so userland code in the lexer actions may communicate with the outside world\n * and/or other lexer rules' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall \"shared context\" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and \\`this\\` have the following value/meaning:\n * - \\`this\\` : reference to the \\`lexer\\` instance.\n * \\`yy_\\` is an alias for \\`this\\` lexer instance reference used internally.\n *\n * - \\`yy\\` : a reference to the \\`yy\\` \"shared state\" object which was passed to the lexer\n * by way of the \\`lexer.setInput(str, yy)\\` API before.\n *\n * Note:\n * The extra arguments you specified in the \\`%parse-param\\` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - \\`yyrulenumber\\` : index of the matched lexer rule (regex), used internally.\n *\n * - \\`YY_START\\`: the current lexer \"start condition\" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo \\'hash object\\' which can be passed into \\`parseError()\\`.\n * See it\\'s use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo(\\'fail!\\', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the \\`lexer.setInput()\\` API.\n * You MAY use the additional \\`args...\\` parameters as per \\`%parse-param\\` spec of the **lexer** grammar:\n * these extra \\`args...\\` are added verbatim to the \\`yy\\` object reference as member variables.\n *\n * WARNING:\n * Lexer's additional \\`args...\\` parameters (via lexer's \\`%parse-param\\`) MAY conflict with\n * any attributes already added to \\`yy\\` by the **parser** or the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.\n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (\\`yylloc\\`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The \\`parseError\\` function receives a \\'hash\\' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal \"shared state\" \\`yy\\`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while \\`this\\` will reference the current lexer instance.\n *\n * When \\`parseError\\` is invoked by the lexer, the default implementation will\n * attempt to invoke \\`yy.parser.parseError()\\`; when this callback is not provided\n * it will try to invoke \\`yy.parseError()\\` instead. When that callback is also not\n * provided, a \\`JisonLexerError\\` exception will be thrown containing the error\n * message and \\`hash\\`, as constructed by the \\`constructLexErrorInfo()\\` API.\n *\n * Note that the lexer\\'s \\`JisonLexerError\\` error class is passed via the\n * \\`ExceptionClass\\` argument, which is invoked to construct the exception\n * instance to be thrown, so technically \\`parseError\\` will throw the object\n * produced by the \\`new ExceptionClass(str, hash)\\` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the \\`.options\\` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n *\n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default \\`parseError\\` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * \\`this\\` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token \\`token\\`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original \\`token\\`.\n * \\`this\\` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: \\`true\\` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: \\`true\\` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: \\`true\\` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: \\`true\\` ==> lexer rule regexes are \"extended regex format\" requiring the\n * \\`XRegExp\\` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n "]); _templateObject86 = function _templateObject86() { return data; @@ -761,7 +771,7 @@ function _templateObject86() { } function _templateObject85() { - var data = _taggedTemplateLiteral(["\n /* lexer generated by jison-lex ", " */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" `yy` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This \"shared context\" object was passed to the lexer by way of\n * the `lexer.setInput(str, yy)` API before you may use it.\n *\n * This \"shared context\" object is passed to the lexer action code in `performAction()`\n * so userland code in the lexer actions may communicate with the outside world\n * and/or other lexer rules' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall \"shared context\" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `lexer` instance.\n * `yy_` is an alias for `this` lexer instance reference used internally.\n *\n * - `yy` : a reference to the `yy` \"shared state\" object which was passed to the lexer\n * by way of the `lexer.setInput(str, yy)` API before.\n *\n * Note:\n * The extra arguments you specified in the `%parse-param` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - `yyrulenumber` : index of the matched lexer rule (regex), used internally.\n *\n * - `YY_START`: the current lexer \"start condition\" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.\n * See it's use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo('fail!', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the `lexer.setInput()` API.\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of the **lexer** grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Lexer's additional `args...` parameters (via lexer's `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the **parser** or the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.\n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (`yylloc`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a 'hash' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal \"shared state\" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while `this` will reference the current lexer instance.\n *\n * When `parseError` is invoked by the lexer, the default implementation will\n * attempt to invoke `yy.parser.parseError()`; when this callback is not provided\n * it will try to invoke `yy.parseError()` instead. When that callback is also not\n * provided, a `JisonLexerError` exception will be thrown containing the error\n * message and `hash`, as constructed by the `constructLexErrorInfo()` API.\n *\n * Note that the lexer's `JisonLexerError` error class is passed via the\n * `ExceptionClass` argument, which is invoked to construct the exception\n * instance to be thrown, so technically `parseError` will throw the object\n * produced by the `new ExceptionClass(str, hash)` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the `.options` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n *\n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are \"extended regex format\" requiring the\n * `XRegExp` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n "], ["\n /* lexer generated by jison-lex ", " */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" \\`yy\\` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This \"shared context\" object was passed to the lexer by way of\n * the \\`lexer.setInput(str, yy)\\` API before you may use it.\n *\n * This \"shared context\" object is passed to the lexer action code in \\`performAction()\\`\n * so userland code in the lexer actions may communicate with the outside world\n * and/or other lexer rules' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall \"shared context\" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and \\`this\\` have the following value/meaning:\n * - \\`this\\` : reference to the \\`lexer\\` instance.\n * \\`yy_\\` is an alias for \\`this\\` lexer instance reference used internally.\n *\n * - \\`yy\\` : a reference to the \\`yy\\` \"shared state\" object which was passed to the lexer\n * by way of the \\`lexer.setInput(str, yy)\\` API before.\n *\n * Note:\n * The extra arguments you specified in the \\`%parse-param\\` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - \\`yyrulenumber\\` : index of the matched lexer rule (regex), used internally.\n *\n * - \\`YY_START\\`: the current lexer \"start condition\" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo \\'hash object\\' which can be passed into \\`parseError()\\`.\n * See it\\'s use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo(\\'fail!\\', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the \\`lexer.setInput()\\` API.\n * You MAY use the additional \\`args...\\` parameters as per \\`%parse-param\\` spec of the **lexer** grammar:\n * these extra \\`args...\\` are added verbatim to the \\`yy\\` object reference as member variables.\n *\n * WARNING:\n * Lexer's additional \\`args...\\` parameters (via lexer's \\`%parse-param\\`) MAY conflict with\n * any attributes already added to \\`yy\\` by the **parser** or the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.\n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (\\`yylloc\\`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The \\`parseError\\` function receives a \\'hash\\' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal \"shared state\" \\`yy\\`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while \\`this\\` will reference the current lexer instance.\n *\n * When \\`parseError\\` is invoked by the lexer, the default implementation will\n * attempt to invoke \\`yy.parser.parseError()\\`; when this callback is not provided\n * it will try to invoke \\`yy.parseError()\\` instead. When that callback is also not\n * provided, a \\`JisonLexerError\\` exception will be thrown containing the error\n * message and \\`hash\\`, as constructed by the \\`constructLexErrorInfo()\\` API.\n *\n * Note that the lexer\\'s \\`JisonLexerError\\` error class is passed via the\n * \\`ExceptionClass\\` argument, which is invoked to construct the exception\n * instance to be thrown, so technically \\`parseError\\` will throw the object\n * produced by the \\`new ExceptionClass(str, hash)\\` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the \\`.options\\` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n *\n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default \\`parseError\\` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * \\`this\\` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token \\`token\\`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original \\`token\\`.\n * \\`this\\` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: \\`true\\` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: \\`true\\` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: \\`true\\` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: \\`true\\` ==> lexer rule regexes are \"extended regex format\" requiring the\n * \\`XRegExp\\` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n "]); + var data = _taggedTemplateLiteral([",\n JisonLexerError: JisonLexerError,\n performAction: ", ",\n simpleCaseActionClusters: ", ",\n rules: [\n ", "\n ],\n conditions: ", "\n };\n "]); _templateObject85 = function _templateObject85() { return data; @@ -771,7 +781,7 @@ function _templateObject85() { } function _templateObject84() { - var data = _taggedTemplateLiteral([",\n JisonLexerError: JisonLexerError,\n performAction: ", ",\n simpleCaseActionClusters: ", ",\n rules: [\n ", "\n ],\n conditions: ", "\n };\n "]); + var data = _taggedTemplateLiteral(["\n const lexer = {\n "]); _templateObject84 = function _templateObject84() { return data; @@ -781,7 +791,7 @@ function _templateObject84() { } function _templateObject83() { - var data = _taggedTemplateLiteral(["\n var lexer = {\n "]); + var data = _taggedTemplateLiteral(["\n // Code Generator Information Report\n // ---------------------------------\n //\n // Options:\n //\n // backtracking: .................... ", "\n // location.ranges: ................. ", "\n // location line+column tracking: ... ", "\n //\n //\n // Forwarded Parser Analysis flags:\n //\n // uses yyleng: ..................... ", "\n // uses yylineno: ................... ", "\n // uses yytext: ..................... ", "\n // uses yylloc: ..................... ", "\n // uses lexer values: ............... ", " / ", "\n // location tracking: ............... ", "\n // location assignment: ............. ", "\n //\n //\n // Lexer Analysis flags:\n //\n // uses yyleng: ..................... ", "\n // uses yylineno: ................... ", "\n // uses yytext: ..................... ", "\n // uses yylloc: ..................... ", "\n // uses ParseError API: ............. ", "\n // uses yyerror: .................... ", "\n // uses location tracking & editing: ", "\n // uses more() API: ................. ", "\n // uses unput() API: ................ ", "\n // uses reject() API: ............... ", "\n // uses less() API: ................. ", "\n // uses display APIs pastInput(), upcomingInput(), showPosition():\n // ............................. ", "\n // uses describeYYLLOC() API: ....... ", "\n //\n // --------- END OF REPORT -----------\n\n "]); _templateObject83 = function _templateObject83() { return data; @@ -791,7 +801,7 @@ function _templateObject83() { } function _templateObject82() { - var data = _taggedTemplateLiteral(["\n // Code Generator Information Report\n // ---------------------------------\n //\n // Options:\n //\n // backtracking: .................... ", "\n // location.ranges: ................. ", "\n // location line+column tracking: ... ", "\n //\n //\n // Forwarded Parser Analysis flags:\n //\n // uses yyleng: ..................... ", "\n // uses yylineno: ................... ", "\n // uses yytext: ..................... ", "\n // uses yylloc: ..................... ", "\n // uses lexer values: ............... ", " / ", "\n // location tracking: ............... ", "\n // location assignment: ............. ", "\n //\n //\n // Lexer Analysis flags:\n //\n // uses yyleng: ..................... ", "\n // uses yylineno: ................... ", "\n // uses yytext: ..................... ", "\n // uses yylloc: ..................... ", "\n // uses ParseError API: ............. ", "\n // uses yyerror: .................... ", "\n // uses location tracking & editing: ", "\n // uses more() API: ................. ", "\n // uses unput() API: ................ ", "\n // uses reject() API: ............... ", "\n // uses less() API: ................. ", "\n // uses display APIs pastInput(), upcomingInput(), showPosition():\n // ............................. ", "\n // uses describeYYLLOC() API: ....... ", "\n //\n // --------- END OF REPORT -----------\n\n "]); + var data = _taggedTemplateLiteral(["\n stripUnusedLexerCode WARNING: \n\n JISON failed to reformat the generated lexer.\n Using the generated code as-is instead and pray it works in your final output!\n\n Internal error report:\n\n ", "\n\n The offending action code chunk as reported above:\n\n ", "\n "]); _templateObject82 = function _templateObject82() { return data; @@ -801,7 +811,7 @@ function _templateObject82() { } function _templateObject81() { - var data = _taggedTemplateLiteral(["\n stripUnusedLexerCode WARNING: \n\n JISON failed to reformat the generated lexer.\n Using the generated code as-is instead and pray it works in your final output!\n\n Internal error report:\n\n ", "\n\n The offending action code chunk as reported above:\n\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n \"use strict\";\n\n return ", ";\n"]); _templateObject81 = function _templateObject81() { return data; @@ -811,7 +821,7 @@ function _templateObject81() { } function _templateObject80() { - var data = _taggedTemplateLiteral(["\n \"use strict\";\n\n return ", ";\n"]); + var data = _taggedTemplateLiteral(["\n // JISON INJECTED VALIDATION CODE\n // which attempts to ascertain you have defined a minimal viable lexer at least:\n if (typeof lexer === \"undefined\") {\n throw new SyntaxError(\"user-defined lexer does not define the required 'lexer' instance.\");\n }\n if (!lexer) {\n throw new SyntaxError(\"user-defined lexer does not define a non-NULL 'lexer' instance.\");\n }\n if (typeof lexer.setInput !== 'function') {\n throw new SyntaxError(\"user-defined lexer does not provide the mandatory 'lexer.setInput()' API function.\");\n }\n if (typeof lexer.lex !== 'function') {\n throw new SyntaxError(\"user-defined lexer does not provide the mandatory 'lexer.lex()' API function.\");\n }\n // END OF JISON INJECTED VALIDATION CODE\n "]); _templateObject80 = function _templateObject80() { return data; @@ -1614,6 +1624,12 @@ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice( function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } var fs = require('fs'); @@ -1622,6 +1638,8 @@ var path$1 = require('path'); var JSON5 = require('@gerhobbelt/json5'); +var mkdirp = require('mkdirp'); + var XRegExp = require('@gerhobbelt/xregexp'); var recast = require('recast'); @@ -1644,13 +1662,15 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); +var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); + var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); -var astUtils__default = /*#__PURE__*/_interopDefaultLegacy(astUtils); // Return TRUE if `src` starts with `searchString`. +var astUtils__default = /*#__PURE__*/_interopDefaultLegacy(astUtils); // Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { @@ -1673,7 +1693,7 @@ function rmCommonWS(strings) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look @@ -1702,37 +1722,42 @@ function rmCommonWS(strings) { // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); // Done removing common indentation. - // + { + var a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; // only correct indentation at start of line, i.e. only check for + var _a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { - if (startsWith(a[j], indent_str)) { - a[j] = a[j].substr(indent_str.length); + for (var j = 1, linecnt = _a.length; j < linecnt; j++) { + if (startsWith(_a[j], indent_str)) { + _a[j] = _a[j].substr(indent_str.length); } } } } // now merge everything to construct the template result: - var rv = []; + { + var rv = []; + var _i = 0; - for (var i = 0, len = arguments.length <= 1 ? 0 : arguments.length - 1; i < len; i++) { - rv.push(src[i].join('\n')); - rv.push(i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1]); - } // the last value is always followed by a last template string partial: + for (var _len = arguments.length <= 1 ? 0 : arguments.length - 1; _i < _len; _i++) { + rv.push(src[_i].join('\n')); + rv.push(_i + 1 < 1 || arguments.length <= _i + 1 ? undefined : arguments[_i + 1]); + } // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + rv.push(src[_i].join('\n')); + var sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` /** @public */ @@ -1752,14 +1777,36 @@ function camelCase(s) { return rv; }); -} // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers +} // https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words + + +var reservedWords = function (list) { + var rv = new Set(); + + var _iterator = _createForOfIteratorHelper(list), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var w = _step.value; + //console.error('reserved word:', w); + rv.add(w); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + return rv; +}(['await', 'break', 'case', 'catch', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'enum', 'export', 'extends', 'finally', 'for', 'function', 'if', 'implements', 'import', 'in', 'instanceof', 'interface', 'new', 'package', 'private', 'protected', 'public', 'return', 'super', 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'yield']); // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + var rv = s // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { var c = match.charAt(1); @@ -1775,6 +1822,12 @@ function mkIdentifier(s) { .replace(/^[^\w_]/, '_') // do not accept numerics at the leading position, despite those matching regex `\w`: .replace(/^\d/, '_').replace(/[^\w\d_]/g, '_') // and only accept multiple (double, not triple) underscores at start or end of identifier name: .replace(/^__+/, '#').replace(/__+$/, '#').replace(/_+/g, '_').replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + + return rv; } // Check if the start of the given input matches a regex expression. // Return the length of the regex expression or -1 if none was found. @@ -1810,13 +1863,11 @@ function scanRegExp(s) { if (ch === ']') { classMarker = false; } - } else { - if (ch === '/') { - terminated = true; - break; - } else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } @@ -1840,7 +1891,7 @@ function isLineTerminator(cp) { function isLegalIdentifierInput(s) { - s = '' + s; // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + s = '' + s; // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` var ref = s.replace(/-\w/g, function (match) { @@ -1890,6 +1941,55 @@ function pad(n, p) { p = p || 2; var rv = '0000' + n; return rv.slice(-p); +} + +function convertExceptionToObject(ex) { + if (!ex) return ex; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + + var rv = Object.assign({}, ex); // - Set up the default fields which should ALWAYS be present: + + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + + if (Array.isArray(ex.errors)) { + rv.errors = []; + + var _iterator2 = _createForOfIteratorHelper(ex.errors), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var se = _step2.value; + rv.errors.push(convertExceptionToObject(se)); + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + } + + return rv; +} + +function find_suitable_app_dump_path() { + return process.cwd().replace(/\\/g, '/').replace(/\/node_modules\/.*$/, function (m) { + return '/___nm___/'; + }).replace(/(\/jison\/)(.*)$/, function (m, p1, p2) { + return p1 + '___' + p2.split('/').map(function (d) { + return d.charAt(0).toUpperCase(); + }).join('_'); + }); } // attempt to dump in one of several locations: first winner is *it*! @@ -1898,15 +1998,27 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { options = options || {}; try { - var dumpPaths = [options.outfile ? path__default['default'].dirname(options.outfile) : null, options.inputPath, process.cwd()]; + var dumpPaths = [options.outfile ? path__default['default'].dirname(options.outfile) : null, options.inputPath, find_suitable_app_dump_path()]; var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname).replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; + } // generate a stacktrace for the dump no matter what: + + + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } } err_id = err_id || 'XXX'; + err_id = err_id.replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); var ts = new Date(); var tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + '' + pad(ts.getUTCMinutes()) + '' + pad(ts.getUTCSeconds()) + '.' + pad(ts.getUTCMilliseconds(), 3) + 'Z'; dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; @@ -1917,21 +2029,34 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); var dump = { errname: errname, err_id: err_id, options: options, - ex: ex + ex: convertExceptionToObject(ex) }; - var d = JSON5__default['default'].stringify(dump, null, 2); // make sure each line is a comment line: + var d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + + return value; + }, + space: 2, + circularRefHandler: function circularRefHandler(value, circusPos, stack, keyStack, key, err) { + return '[!circular ref!]'; + } + }); // make sure each line is a comment line: d = d.split('\n').map(function (l) { return '// ' + l; }); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -1941,7 +2066,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -1972,25 +2097,36 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + var errname = '' + (title || 'exec_test'); + var err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + + var debug = options.debug || 0; + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + + if (debug > 1) { + console.warn("\n ######################## source code ##########################\n ".concat(sourcecode, "\n ######################## source code ##########################\n ")); } - var debug = 0; var p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + if (debug > 1) console.log('exec-and-diagnose options:', options); + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } @@ -2003,9 +2139,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t return p; } -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject: convertExceptionToObject }; // assert__default['default'](recast__default['default']); //var types = recast.types; @@ -2019,18 +2156,18 @@ assert__default['default'](recast__default['default']); //var types = recast.typ // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! -var ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +var ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: -var IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; // Determine which Unicode NonAsciiIdentifierStart characters +var IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; // Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -2042,37 +2179,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -2080,30 +2217,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -2114,58 +2251,58 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -2210,27 +2347,27 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - var escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: + var escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: - var typeIdCharSets = ["ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", + var typeIdCharSets = ['ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ"]; //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ']; //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - var reStr = escCharSet + typeIdCharSets.join(""); + var reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); var re = new RegExp("[".concat(reStr, "]"), 'g'); var hash = new Array(0xD800); @@ -2241,18 +2378,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { hash[i] = (hash[i] || 0) + 1; } // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -2263,64 +2400,64 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // var escChar = pickChar(escCharSet); var typeIdChar = []; - for (var _i = 0, l = typeIdCharSets.length; _i < l; _i++) { - typeIdChar[_i] = pickChar(typeIdCharSets[_i]); - } // produce a function set for encoding and decoding content, + for (var _i2 = 0, l = typeIdCharSets.length; _i2 < l; _i2++) { + typeIdChar[_i2] = pickChar(typeIdCharSets[_i2]); + } // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: @@ -2328,47 +2465,47 @@ function generateMapper4JisonGrammarIdentifiers(input) { return _ref = { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default']("#(".concat(ID_REGEX_BASE, ")#"), 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default']("$(".concat(ID_REGEX_BASE, ")|$([0-9]+)"), 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default']("@(".concat(ID_REGEX_BASE, ")|@([0-9]+)"), 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default']("#(".concat(ID_REGEX_BASE, ")|#([0-9]+)"), 'g'), // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default']("##(".concat(ID_REGEX_BASE, ")|##([0-9]+)"), 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4] - }, _defineProperty(_ref, "tokenValueReferenceRe", new XRegExp__default['default']("$-([0-9]+)", 'g')), _defineProperty(_ref, "tokenNegativeLocationStart", escChar + typeIdChar[5]), _defineProperty(_ref, "tokenNegativeLocationRe", new XRegExp__default['default']("@-([0-9]+)", 'g')), _defineProperty(_ref, "tokenNegativeStackIndexStart", escChar + typeIdChar[6]), _defineProperty(_ref, "tokenNegativeStackIndexRe", new XRegExp__default['default']("#-([0-9]+)", 'g')), _defineProperty(_ref, "tokenDetect4EncodeRe", new XRegExp__default['default']("([^$@#".concat(IN_ID_CHARSET, "])([$@#]|##)(").concat(ID_REGEX_BASE, "|[$]|-?[0-9]+)(#?)(?![$@#").concat(IN_ID_CHARSET, "])"), 'g')), _defineProperty(_ref, "tokenDetect4DecodeRe", new XRegExp__default['default']("([^$".concat(IN_ID_CHARSET, "])(").concat(escChar, "[").concat(typeIdChar.slice(0, 7).join(''), "])(").concat(ID_REGEX_BASE, "|[$]|[0-9]+)(?![$@#").concat(IN_ID_CHARSET, "])"), 'g')), _defineProperty(_ref, "encode", function encodeJisonTokens(src, locationOffsetSpec) { + }, _defineProperty(_ref, "tokenValueReferenceRe", new XRegExp__default['default']('$-([0-9]+)', 'g')), _defineProperty(_ref, "tokenNegativeLocationStart", escChar + typeIdChar[5]), _defineProperty(_ref, "tokenNegativeLocationRe", new XRegExp__default['default']('@-([0-9]+)', 'g')), _defineProperty(_ref, "tokenNegativeStackIndexStart", escChar + typeIdChar[6]), _defineProperty(_ref, "tokenNegativeStackIndexRe", new XRegExp__default['default']('#-([0-9]+)', 'g')), _defineProperty(_ref, "tokenDetect4EncodeRe", new XRegExp__default['default']("([^$@#".concat(IN_ID_CHARSET, "])([$@#]|##)(").concat(ID_REGEX_BASE, "|[$]|-?[0-9]+)(#?)(?![$@#").concat(IN_ID_CHARSET, "])"), 'g')), _defineProperty(_ref, "tokenDetect4DecodeRe", new XRegExp__default['default']("([^$".concat(IN_ID_CHARSET, "])(").concat(escChar, "[").concat(typeIdChar.slice(0, 7).join(''), "])(").concat(ID_REGEX_BASE, "|[$]|[0-9]+)(?![$@#").concat(IN_ID_CHARSET, "])"), 'g')), _defineProperty(_ref, "encode", function encodeJisonTokens(src, locationOffsetSpec) { var _this = this; var re = this.tokenDetect4EncodeRe; // reset regex @@ -2376,10 +2513,10 @@ function generateMapper4JisonGrammarIdentifiers(input) { re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -2463,10 +2600,10 @@ function generateMapper4JisonGrammarIdentifiers(input) { re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -2475,19 +2612,19 @@ function generateMapper4JisonGrammarIdentifiers(input) { // p1 is only serving as lookbehind emulation switch (p2) { case _this2.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case _this2.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case _this2.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case _this2.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case _this2.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case _this2.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -2543,13 +2680,13 @@ function compileCodeToES5(src, options) { sourceRoot: '.', sourceType: 'module', babelrc: false, - ignore: ["node_modules/**/*.js"], + ignore: ['node_modules/**/*.js'], compact: false, retainLines: false, - presets: [["@babel/preset-env", { + presets: [['@babel/preset-env', { targets: { - browsers: ["last 2 versions"], - node: "8.0" + browsers: ['last 2 versions'], + node: '8.0' } }]] }, options); @@ -2557,7 +2694,7 @@ function compileCodeToES5(src, options) { } function prettyPrintAST(ast, options) { - var options = options || {}; + options = options || {}; var defaultOptions = { tabWidth: 2, quote: 'single', @@ -2580,8 +2717,8 @@ function prettyPrintAST(ast, options) { .replace(/\uFFDA/g, '@').replace(/\uFFDB/g, '#'); return new_src; } // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { @@ -2601,16 +2738,16 @@ function checkActionBlock(src, yylloc, options) { var rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } // The rough-and-ready preprocessor for any action code block: // this one trims off any surplus whitespace and removes any // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -2618,7 +2755,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -2627,12 +2764,12 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { @@ -2709,16 +2846,16 @@ function printFunctionSourceCode(f) { var funcRe = /^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/; var arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/; /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ @@ -2747,8 +2884,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -2774,12 +2911,12 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { printFunctionSourceCode: printFunctionSourceCode, printFunctionSourceCodeContainer: printFunctionSourceCodeContainer -}; // -// -// +}; // +// +// function detectIstanbulGlobal() { - var gcv = "__coverage__"; + var gcv = '__coverage__'; var globalvar = new Function('return this')(); var coverage = globalvar[gcv]; return coverage || false; @@ -2966,12 +3103,44 @@ function shallow_copy_and_strip_depth(src, parentKey) { } return src; -} +} // strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. + function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: - msg = msg.replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)').replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + msg = msg.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; +} // strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. + + +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + var msg = obj.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + + var keys = Object.keys(obj); + + for (var i in keys) { + var key = keys[i]; + var el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + + return obj; } function trim_array_tail(arr) { @@ -3019,33 +3188,33 @@ function treat_error_infos_array(arr) { trim_array_tail(inf); for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + var _err = inf[key]; - if (err) { + if (_err) { path.push('[' + key + ']'); - err = treat_object(err); + _err = treat_object(_err); - if (_typeof(err) === 'object') { - if (err.lexer) { - err.lexer = '[lexer]'; + if (_typeof(_err) === 'object') { + if (_err.lexer) { + _err.lexer = '[lexer]'; } - if (err.parser) { - err.parser = '[parser]'; + if (_err.parser) { + _err.parser = '[parser]'; } - trim_array_tail(err.symbol_stack); - trim_array_tail(err.state_stack); - trim_array_tail(err.location_stack); + trim_array_tail(_err.symbol_stack); + trim_array_tail(_err.state_stack); + trim_array_tail(_err.location_stack); - if (err.value_stack) { + if (_err.value_stack) { path.push('value_stack'); - err.value_stack = treat_value_stack(err.value_stack); + _err.value_stack = treat_value_stack(_err.value_stack); path.pop(); } } - inf[key] = err; + inf[key] = _err; path.pop(); } } @@ -3192,7 +3361,7 @@ function treat_object(e) { return e; } // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. @@ -3224,10 +3393,12 @@ var helpers = { dquote: dquote$1, trimErrorForTestReporting: trimErrorForTestReporting, stripErrorStackPaths: stripErrorStackPaths, + cleanStackTrace4Comparison: cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, compileCodeToES5: parse2AST.compileCodeToES5, @@ -3315,7 +3486,7 @@ function typal_mix() { return this; } // Same as typal_mix but also camelCases every object member and 'standardizes' the key set of every input // argument through a caLLback function. -// +// // This is useful for processing options with dashes in their key, e.g. `token-stack` --> tokenStack. @@ -3349,7 +3520,7 @@ function typal_camel_mix(cb) { var nk = mkIdentifier$1(k); var match = k.match(position); var key = k.replace(position, ''); // This anticipates before/after members to be camelcased already, e.g. - // 'afterParse()' for layering 'parse()': + // 'afterParse()' for layering 'parse()': var alt_key = lcase0(key); @@ -3480,7 +3651,7 @@ var setMixin = { return this._items.length === 0; }, copy: function copy() { - return new Set(this._items); + return new Set$1(this._items); }, toString: function toString() { return this._items.toString(); @@ -3494,11 +3665,11 @@ var setMixin = { }); 'filter slice map'.split(' ').forEach(function (e, i) { setMixin[e] = function () { - return new Set(Array.prototype[e].apply(this._items, arguments), true); + return new Set$1(Array.prototype[e].apply(this._items, arguments), true); }; //setMixin[e].name = e; }); -var Set = typal.construct(setMixin); // See also: +var Set$1 = typal.construct(setMixin); // 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. @@ -4001,16 +4172,16 @@ var parser = { switch (yystate) { case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; - this._$ = yylstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4039,8 +4210,8 @@ var parser = { case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { @@ -4057,17 +4228,17 @@ var parser = { case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp - 1].errStr)); break; case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { rules: yyvstack[yysp] @@ -4076,17 +4247,17 @@ var parser = { case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject2(), yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr)); break; case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { rules: [] @@ -4095,9 +4266,9 @@ var parser = { case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; if (!yy.options) yy.options = {}; @@ -4136,8 +4307,8 @@ var parser = { case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4187,8 +4358,8 @@ var parser = { case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { macros: {}, @@ -4206,8 +4377,8 @@ var parser = { case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` // macros here: @@ -4230,17 +4401,17 @@ var parser = { case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject6(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4257,17 +4428,17 @@ var parser = { case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject7(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4284,17 +4455,17 @@ var parser = { case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject8(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4316,8 +4487,8 @@ var parser = { case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. @@ -4326,8 +4497,8 @@ var parser = { case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -4337,8 +4508,8 @@ var parser = { case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -4348,8 +4519,8 @@ var parser = { case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4362,17 +4533,17 @@ var parser = { case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject12(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { type: 'unknown', @@ -4382,8 +4553,8 @@ var parser = { case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4410,17 +4581,17 @@ var parser = { case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject15(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 5, yysp); // END of default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4454,9 +4625,9 @@ var parser = { case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + 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 : ''; @@ -4466,36 +4637,36 @@ var parser = { case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1(_templateObject20(), yylexer.prettyPrintRange(yylstack[yysp - 3], yylstack[yysp - 4]), yyvstack[yysp - 3].errStr)); break; case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject21(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1(_templateObject22(), yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = yyvstack[yysp]; @@ -4506,9 +4677,9 @@ var parser = { case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; yy.__options_category_description__ = yyvstack[yysp]; @@ -4516,9 +4687,9 @@ var parser = { case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; yy.__options_category_description__ = yyvstack[yysp]; @@ -4526,9 +4697,9 @@ var parser = { case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = 'the inclusive lexer start conditions set (%s)'; @@ -4536,9 +4707,9 @@ var parser = { case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = 'the exclusive lexer start conditions set (%x)'; @@ -4546,9 +4717,9 @@ var parser = { case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; yy.__options_category_description__ = 'the <...> delimited set of lexer start conditions'; @@ -4556,9 +4727,9 @@ var parser = { case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; yy.__options_category_description__ = 'the lexer rules definition section'; @@ -4566,9 +4737,9 @@ var parser = { case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; yy.__options_category_description__ = 'the lexer epilogue section'; @@ -4576,24 +4747,24 @@ var parser = { case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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].concat(yyvstack[yysp]); break; case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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].concat([yyvstack[yysp]]); break; case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4612,8 +4783,8 @@ var parser = { case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. @@ -4622,8 +4793,8 @@ var parser = { case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -4633,8 +4804,8 @@ var parser = { case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4669,8 +4840,8 @@ var parser = { case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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(_templateObject27(), yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp]))); this.$ = yyvstack[yysp - 1]; @@ -4681,16 +4852,16 @@ var parser = { case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (yyvstack[yysp - 1]) { yyvstack[yysp].unshift(yyvstack[yysp - 1]); @@ -4701,8 +4872,8 @@ var parser = { case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (yyvstack[yysp - 3]) { yyvstack[yysp - 1].forEach(function (d) { @@ -4715,35 +4886,35 @@ var parser = { case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + 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$1(_templateObject28(), yyvstack[yysp - 3].join(','), yylexer.prettyPrintRange(yyparser.mergeLocationInfo(yysp - 3, yysp), yylstack[yysp - 3]), yyvstack[yysp - 1].errStr)); break; case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject29(), yyvstack[yysp - 2].join(','), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject30(), yyvstack[yysp - 2].join(','), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push(yyvstack[yysp]); @@ -4754,8 +4925,8 @@ var parser = { case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -4769,8 +4940,8 @@ var parser = { case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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. @@ -4801,8 +4972,8 @@ var parser = { case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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(_templateObject33(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); @@ -4810,8 +4981,8 @@ var parser = { case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO: REWRITE this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -4820,8 +4991,8 @@ var parser = { case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO: REWRITE this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -4830,8 +5001,8 @@ var parser = { case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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], yyvstack[yysp]]; yyparser.yyError(rmCommonWS$1(_templateObject36(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); @@ -4851,52 +5022,52 @@ var parser = { case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + yyvstack[yysp]; break; case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '\n\n' + yyvstack[yysp] + '\n\n'; break; case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject37(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]))); break; case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject38(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]))); break; case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject39(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]))); break; case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject40(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]))); break; @@ -4906,16 +5077,16 @@ var parser = { case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -4934,9 +5105,9 @@ var parser = { case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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) { @@ -4947,8 +5118,8 @@ var parser = { case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -5028,56 +5199,56 @@ var parser = { case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; break; case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '|'; break; case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; break; case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '|'; break; case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + ')'; break; case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + ')'; break; @@ -5087,49 +5258,49 @@ var parser = { case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject43(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '+'; break; case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '*'; break; case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '?'; break; case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + ')'; break; case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + ')'; break; @@ -5151,65 +5322,65 @@ var parser = { case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '.'; break; case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '^'; break; case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '$'; break; case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); break; case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + yyvstack[yysp]; break; case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject44(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) && yyvstack[yysp].toUpperCase() !== yyvstack[yysp]) { // treat this as part of an XRegExp `\p{...}` Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories @@ -5223,8 +5394,8 @@ var parser = { case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -5234,8 +5405,8 @@ var parser = { case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -5243,8 +5414,8 @@ var parser = { case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -5265,8 +5436,8 @@ var parser = { case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -5279,24 +5450,24 @@ var parser = { case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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], true]; break; case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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_VALUE) { @@ -5308,9 +5479,9 @@ var parser = { case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... yyparser.yyError(rmCommonWS$1(_templateObject49(), $option, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 4]), yyvstack[yysp].errStr)); @@ -5318,9 +5489,9 @@ var parser = { case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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)'; @@ -5333,8 +5504,8 @@ var parser = { case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -5360,8 +5531,8 @@ var parser = { case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -5380,32 +5551,32 @@ var parser = { case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = parseValue(yyvstack[yysp]); break; case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = ''; break; case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -5422,17 +5593,17 @@ var parser = { case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject54(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$1(_templateObject55(), yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr)); @@ -5441,8 +5612,8 @@ var parser = { case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -5462,8 +5633,8 @@ var parser = { case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -5473,8 +5644,8 @@ var parser = { case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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. @@ -5483,8 +5654,8 @@ var parser = { case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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]; @@ -5519,9 +5690,9 @@ var parser = { case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject61(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; @@ -5600,20 +5771,14 @@ var parser = { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + var ASSERT = typeof assert !== 'function' ? function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : assert; this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -5646,13 +5811,14 @@ var parser = { shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + var _dst = {}; + shallow_copy_noclobber(_dst, src); + return _dst; + } } return src; @@ -5669,10 +5835,8 @@ var parser = { if (chk.call(src, k)) { dst[k] = src[k]; } - } else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -5841,11 +6005,11 @@ var parser = { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (var _i3 = this.__error_recovery_infos.length - 1; _i3 >= 0; _i3--) { + var _el = this.__error_recovery_infos[_i3]; - if (el && typeof el.destroy === 'function') { - el.destroy(); + if (_el && typeof _el.destroy === 'function') { + _el.destroy(); } } @@ -5873,10 +6037,10 @@ var parser = { this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; + var i1 = first_index | 0; + var i2 = last_index | 0; + var l1 = first_yylloc; + var l2 = last_yylloc; var rv; // rules: // - first/last yylloc entries override first/last indexes @@ -5894,8 +6058,8 @@ var parser = { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { - l2 = lstack[i]; + for (var _i4 = i2; _i4 >= i1; _i4--) { + l2 = lstack[_i4]; if (l2) { break; @@ -5908,8 +6072,8 @@ var parser = { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { - l1 = lstack[i]; + for (var _i5 = (i1 || sp) - 1; _i5 >= 0; _i5--) { + l1 = lstack[_i5]; if (l1) { break; @@ -5922,30 +6086,30 @@ var parser = { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; - } + return null; + } // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + + rv = this.copy_yylloc(l2); return rv; + } // shallow-copy L1, then adjust first col/row 1 column past the end. + + + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; } + + return rv; } if (!l1) { @@ -5954,7 +6118,7 @@ var parser = { } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... @@ -6004,6 +6168,12 @@ var parser = { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -6086,11 +6256,15 @@ var parser = { // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty - } + { + var i; + + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty + } - rv.base_pointer = i; - rv.info_stack_pointer = i; + rv.base_pointer = i; + rv.info_stack_pointer = i; + } rv.root_failure_pointer = rv.stack_pointer; // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_recovery_infos.push(rv); @@ -6176,9 +6350,9 @@ var parser = { while (stack_probe >= 0) { // check for error recovery rule in this state - var t = table[state] && table[state][TERROR] || NO_ACTION; + var _t = table[state] && table[state][TERROR] || NO_ACTION; - if (t[0]) { + if (_t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must // prevent the core from running forever, @@ -6341,7 +6515,7 @@ var parser = { if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: @@ -6397,7 +6571,7 @@ var parser = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errSymbolDescr: errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -6416,7 +6590,8 @@ var parser = { yyval.$ = recoveringErrorInfo; yyval._$ = undefined; yyrulelen = error_rule_depth; - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + var combineState = NO_ACTION[1]; + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -6473,9 +6648,9 @@ var parser = { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); var errorSymbolFromParser = true; for (;;) { @@ -6508,7 +6683,7 @@ var parser = { // and take it from there! if (!action) { - ASSERT(recoveringErrorInfo, "line 1087"); // Prep state variables so that upon breaking out of + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` // statement in the outer "fast parse loop" we redo // the exact same state table lookup as the one above @@ -6543,12 +6718,12 @@ var parser = { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -6590,7 +6765,7 @@ var parser = { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; // read action for current state and first input @@ -6620,7 +6795,7 @@ var parser = { // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; @@ -6680,15 +6855,17 @@ var parser = { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -6742,7 +6919,7 @@ var parser = { // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; @@ -6784,25 +6961,25 @@ var parser = { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + var _tokenName = this.getSymbolName(symbol || EOF); - if (!tokenName) { - tokenName = symbol; + if (!_tokenName) { + _tokenName = symbol; } Jison.parserDebugger.push({ action: 'shift', text: lexer.yytext, - terminal: tokenName, + terminal: _tokenName, terminal_id: symbol }); } ++sp; symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc = this.copy_yylloc(lexer.yylloc); @@ -6810,9 +6987,9 @@ var parser = { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... @@ -6820,25 +6997,28 @@ var parser = { r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; + var _prereduceValue = vstack.slice(sp - yyrulelen, sp); - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); - debuggableProductions.push(debuggableProduction); + var _debuggableProductions = []; + + for (var _debugIdx = yyrulelen - 1; _debugIdx >= 0; _debugIdx--) { + var _debuggableProduction = getNonTerminalFromCode(stack[sp - _debugIdx]); + + _debuggableProductions.push(_debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + var _currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + + var _currentNonterminal = getNonTerminalFromCode(_currentNonterminalCode); - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', - nonterminal: currentNonterminal, - nonterminal_id: currentNonterminalCode, - prereduce: prereduceValue, + nonterminal: _currentNonterminal, + nonterminal_id: _currentNonterminalCode, + prereduce: _prereduceValue, result: r, - productions: debuggableProductions, + productions: _debuggableProductions, text: yyval.$ }); } @@ -6860,15 +7040,17 @@ var parser = { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var _ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = _ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][_ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -7377,6 +7559,10 @@ var lexer = function () { * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -7758,9 +7944,9 @@ var lexer = function () { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -7770,8 +7956,8 @@ var lexer = function () { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -7847,12 +8033,22 @@ var lexer = function () { */ pastInput: function lexer_pastInput(maxSize, maxLines) { var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) maxSize = Infinity;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substr` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = Infinity; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: @@ -7869,8 +8065,8 @@ var lexer = function () { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -7896,20 +8092,30 @@ var lexer = function () { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { var next = this.match; var source = this._input || ''; - if (maxSize < 0) maxSize = next.length + source.length;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substring` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = next.length + source.length; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + if (next.length < maxSize * 2 + 2) { next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8 } // now that we have a significantly reduced string to process, transform the newlines @@ -8234,7 +8440,7 @@ var lexer = function () { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + var backup; if (this.options.backtrack_lexer) { // save context @@ -8262,9 +8468,9 @@ var lexer = function () { }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + var match_str = match[0]; + var match_str_len = match_str.length; + var lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -8290,7 +8496,7 @@ var lexer = function () { // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] + var token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */ ); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -8336,8 +8542,6 @@ var lexer = function () { this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -8369,65 +8573,73 @@ var lexer = function () { } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; // 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! + { + var rule_ids = spec.rules; + var regexes = spec.__rule_regexes; + var len = spec.__rule_count; + var match; + var index; // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + for (var i = 1; i <= len; i++) { + var tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + var token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + var _token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + if (_token !== false) { + return _token; + } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + var _lineno_msg = 'Lexical error'; if (this.yylloc) { - lineno_msg += ' on line ' + (this.yylineno + 1); + _lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var _p = this.constructLexErrorInfo(_lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var pendingInput = this._input; var activeCondition = this.topState(); var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; - if (token === this.ERROR) { + var _token2 = this.parseError(_p.errStr, _p, this.JisonLexerError) || this.ERROR; + + if (_token2 === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: @@ -8439,7 +8651,7 @@ var lexer = function () { } } - return token; + return _token2; } }, @@ -8496,24 +8708,24 @@ var lexer = function () { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -8540,24 +8752,24 @@ var lexer = function () { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -8621,9 +8833,9 @@ var lexer = function () { if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -8639,9 +8851,9 @@ var lexer = function () { if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -8661,7 +8873,7 @@ var lexer = function () { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -10288,9 +10500,9 @@ function i2c(i) { if (x.length >= 1 && i <= 0xFFFF) { c = '0000' + x; return "\\u" + c.substr(c.length - 4); - } else { - return "\\u{" + x + '}'; } + + return "\\u{" + x + '}'; } return String.fromCharCode(i); @@ -10300,7 +10512,7 @@ function i2c(i) { var Pcodes_bitarray_cache = {}; -var Pcodes_bitarray_cache_test_order = []; // Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by +var Pcodes_bitarray_cache_test_order = []; // Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. var EscCode_bitarray_output_refs; // now initialize the EscCodes_... table above: @@ -10402,13 +10614,13 @@ function updatePcodesBitarrayCacheTestOrder(opts) { l[k] = cnt; } // now dig out the unique ones: only need one per pcode. - // + // // We ASSUME every \\p{NAME} 'pcode' has at least ONE character - // in it that is ONLY matched by that particular pcode. + // in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode - // won't be tested during optimization. - // + // won't be tested during optimization. + // // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to @@ -10463,11 +10675,11 @@ function updatePcodesBitarrayCacheTestOrder(opts) { } } // order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. - // + // // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more - // optimal minification of the regex set expression. - // + // optimal minification of the regex set expression. + // // This is a guestimate/heuristic only! @@ -10704,7 +10916,7 @@ function set2bitarray(bitarr, s, opts) { mark(v1); } // When we have marked all slots, '^' NEGATES the set, hence we flip all slots. - // + // // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. @@ -10781,9 +10993,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { break; } } - } // We're only interested in matches which actually cover some + } // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: @@ -10884,9 +11096,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { break; } } - } // We're only interested in matches which actually cover some + } // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: @@ -10982,10 +11194,9 @@ function reduceRegexToSetBitArray(s, name, opts) { if (!c1) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"'); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -11002,10 +11213,9 @@ function reduceRegexToSetBitArray(s, name, opts) { if (!inner) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"'); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -11021,10 +11231,10 @@ function reduceRegexToSetBitArray(s, name, opts) { if (!c2) { // cope with illegal escape sequences too! return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; + if (c2 !== ']') { return new Error('regex set expression is broken in regex: ' + orig); } @@ -11112,10 +11322,9 @@ function reduceRegexToSetBitArray(s, name, opts) { // inside a regex set: try { - var re; assert__default['default'](s); assert__default['default'](!(s instanceof Error)); - re = new XRegExp__default['default']('[' + s + ']'); + var re = new XRegExp__default['default']('[' + s + ']'); re.test(s[0]); // One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` // so we check for lingering UNESCAPED brackets in here as those cannot be: @@ -11135,7 +11344,7 @@ function reduceRegexToSetBitArray(s, name, opts) { } return l; -} // Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` +} // Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! @@ -11147,13 +11356,12 @@ function produceOptimizedRegex4Set(bitarr) { if (s1.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s1; - } else { - s1 = '[' + s1 + ']'; - } // Now try to produce a minimum regex from the *inverted* bitarray via negation: + } + + s1 = '[' + s1 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s2 = bitarray2set(bitarr, true, true); if (s2[0] === '^') { @@ -11169,7 +11377,7 @@ function produceOptimizedRegex4Set(bitarr) { s2 = '[' + s2 + ']'; // Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: - // + // // First try to produce a minimum regex from the bitarray directly: var s3 = bitarray2set(bitarr, false, false); // and when the regex set turns out to match a single pcode/escape, then @@ -11178,13 +11386,12 @@ function produceOptimizedRegex4Set(bitarr) { if (s3.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s3; - } else { - s3 = '[' + s3 + ']'; - } // Now try to produce a minimum regex from the *inverted* bitarray via negation: + } + + s3 = '[' + s3 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s4 = bitarray2set(bitarr, true, false); if (s4[0] === '^') { @@ -11233,7 +11440,7 @@ var setmgmt = { var rmCommonWS$2 = helpers.rmCommonWS; var mkIdentifier$3 = helpers.mkIdentifier; -var code_exec$1 = helpers.exec; +var code_exec = helpers.exec; var version = '0.6.2-220'; // require('./package.json').version; function chkBugger$2(src) { @@ -11314,7 +11521,7 @@ function mkStdOptions() var opts = {}; var args = [].concat.apply([], arguments); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(defaultJisonLexOptions); } else { args.shift(); @@ -11610,9 +11817,9 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse function errinfo() { if (name) { return 'macro [[' + name + ']]'; - } else { - return 'regex [[' + orig + ']]'; } + + return 'regex [[' + orig + ']]'; } // propagate deferred exceptions = error reports. @@ -11631,10 +11838,9 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse if (!c1) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -11652,10 +11858,9 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse if (!inner) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -11671,10 +11876,10 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse if (!c2) { // cope with illegal escape sequences too! return new Error(errinfo() + ': regex set expression is broken: "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; + if (c2 !== ']') { return new Error(errinfo() + ': regex set expression is broken: apparently unterminated'); } @@ -12189,7 +12394,7 @@ function buildActions(dict, tokens, opts) { function generateErrorClass() { // --- START lexer error class --- - var prelude = "/**\n * See also:\n * http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n * but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n * with userland code which might access the derived class in a 'classic' way.\n *\n * @public\n * @constructor\n * @nocollapse\n */\nfunction JisonLexerError(msg, hash) {\n \"use strict\";\n\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'JisonLexerError'\n });\n\n if (msg == null) msg = '???';\n\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n var stacktrace;\n if (hash && hash.exception instanceof Error) {\n var ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty('captureStackTrace')) { // V8\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(JisonLexerError.prototype, Error.prototype);\n} else {\n JisonLexerError.prototype = Object.create(Error.prototype);\n}\nJisonLexerError.prototype.constructor = JisonLexerError;\nJisonLexerError.prototype.name = 'JisonLexerError';"; // --- END lexer error class --- + var prelude = "/**\n * See also:\n * http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n * but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n * with userland code which might access the derived class in a 'classic' way.\n *\n * @public\n * @constructor\n * @nocollapse\n */\nfunction JisonLexerError(msg, hash) {\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'JisonLexerError'\n });\n\n if (msg == null) msg = '???';\n\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n let stacktrace;\n if (hash && hash.exception instanceof Error) {\n const ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty('captureStackTrace')) { // V8\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(JisonLexerError.prototype, Error.prototype);\n} else {\n JisonLexerError.prototype = Object.create(Error.prototype);\n}\nJisonLexerError.prototype.constructor = JisonLexerError;\nJisonLexerError.prototype.name = 'JisonLexerError';"; // --- END lexer error class --- return prelude; } @@ -12225,36 +12430,39 @@ function RegExpLexer(dict, input, tokens, build_options) { // The compiled code will look something like this: // // ``` - // var lexer; + // let lexer; // bla bla... // ``` // // or // // ``` - // var lexer = { bla... }; + // const lexer = { bla... }; // ``` - var testcode = ['// provide a local version for test purposes:', jisonLexerErrorDefinition, '', generateFakeXRegExpClassSrcCode(), '', source, '', 'return lexer;'].join('\n'); - var lexer = code_exec$1(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { + var testcode = ['// provide a local version for test purposes:', jisonLexerErrorDefinition, '', generateFakeXRegExpClassSrcCode(), '', source, '', rmCommonWS$2(_templateObject80()), 'return lexer;'].join('\n'); + + var _lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { //console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$2(sourcecode); var lexer_f = new Function('', sourcecode); return lexer_f(); - }, opts.options, "lexer"); + }, Object.assign({}, opts.options, { + throwErrorOnCompileFailure: true + }), 'lexer'); - if (!lexer) { + if (!_lexer) { throw new Error('no lexer defined *at all*?!'); } - if (_typeof(lexer.options) !== 'object' || lexer.options == null) { + if (_typeof(_lexer.options) !== 'object' || _lexer.options == null) { throw new Error('your lexer class MUST have an .options member object or it won\'t fly!'); } - if (typeof lexer.setInput !== 'function') { + if (typeof _lexer.setInput !== 'function') { throw new Error('your lexer class MUST have a .setInput function member or it won\'t fly!'); } - if (lexer.EOF !== 1 && lexer.ERROR !== 2) { + if (_lexer.EOF !== 1 && _lexer.ERROR !== 2) { throw new Error('your lexer class MUST have these constants defined: lexer.EOF = 1 and lexer.ERROR = 2 or it won\'t fly!'); } // When we do NOT crash, we found/killed the problem area just before this call! @@ -12275,23 +12483,23 @@ function RegExpLexer(dict, input, tokens, build_options) { var post = opts.options.post_lex; // since JSON cannot encode functions, we'll have to do it manually now: if (typeof pre === 'function') { - lexer.options.pre_lex = pre; + _lexer.options.pre_lex = pre; } if (typeof post === 'function') { - lexer.options.post_lex = post; + _lexer.options.post_lex = post; } } if (opts.options.showSource) { if (typeof opts.options.showSource === 'function') { - opts.options.showSource(lexer, source, opts, RegExpLexer); + opts.options.showSource(_lexer, source, opts, RegExpLexer); } else { - console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n"); + console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n', source, '\n----------------------------------------\n'); } } - return lexer; + return _lexer; } catch (ex) { // if (src_exception) { // src_exception.message += '\n (' + description + ': ' + ex.message + ')'; @@ -12330,62 +12538,66 @@ function RegExpLexer(dict, input, tokens, build_options) { assert__default['default'](Array.isArray(opts.rules)); return opts.rules.length > 0 ? 'One or more of your lexer state names are possibly botched?' : 'Your custom lexer is somehow botched.'; }, ex, null)) { - var rulesSpecSize; - - if (!test_me(function () { - // store the parsed rule set size so we can use that info in case - // this attempt also fails: - assert__default['default'](Array.isArray(opts.rules)); - rulesSpecSize = opts.rules.length; // opts.conditions = []; - - opts.rules = []; - opts.showSource = false; - opts.__in_rules_failure_analysis_mode__ = true; - }, 'One or more of your lexer rules are possibly botched?', ex, null)) { - // kill each rule action block, one at a time and test again after each 'edit': - var rv = false; - - for (var i = 0, len = rulesSpecSize; i < len; i++) { - var lastEditedRuleSpec; - rv = test_me(function () { - assert__default['default'](Array.isArray(opts.rules)); - assert__default['default'](opts.rules.length === rulesSpecSize); // opts.conditions = []; - // opts.rules = []; - // opts.__in_rules_failure_analysis_mode__ = true; - // nuke all rules' actions up to and including rule numero `i`: - - for (var j = 0; j <= i; j++) { - // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; - // now we want to edit the *action* part: - var rule = opts.rules[j]; - assert__default['default'](Array.isArray(rule)); - assert__default['default'](rule.length === 2 || rule.length === 3); - rule.pop(); - rule.push('{ /* nada */ }'); - lastEditedRuleSpec = rule; - } - }, function () { - return 'Your lexer rule "' + lastEditedRuleSpec[0] + '" action code block is botched?'; - }, ex, null); + var i, len; + var lastEditedRuleSpec; + + (function () { + var rulesSpecSize; + + if (!test_me(function () { + // store the parsed rule set size so we can use that info in case + // this attempt also fails: + assert__default['default'](Array.isArray(opts.rules)); + rulesSpecSize = opts.rules.length; // opts.conditions = []; + + opts.rules = []; + opts.showSource = false; + opts.__in_rules_failure_analysis_mode__ = true; + }, 'One or more of your lexer rules are possibly botched?', ex, null)) { + // kill each rule action block, one at a time and test again after each 'edit': + var rv = false; + + for (i = 0, len = rulesSpecSize; i < len; i++) { + rv = test_me(function () { + assert__default['default'](Array.isArray(opts.rules)); + assert__default['default'](opts.rules.length === rulesSpecSize); // opts.conditions = []; + // opts.rules = []; + // opts.__in_rules_failure_analysis_mode__ = true; + // nuke all rules' actions up to and including rule numero `i`: + + for (var j = 0; j <= i; j++) { + // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; + // now we want to edit the *action* part: + var rule = opts.rules[j]; + assert__default['default'](Array.isArray(rule)); + assert__default['default'](rule.length === 2 || rule.length === 3); + rule.pop(); + rule.push('{ /* nada */ }'); + lastEditedRuleSpec = rule; + } + }, function () { + return 'Your lexer rule "' + lastEditedRuleSpec[0] + '" action code block is botched?'; + }, ex, null); - if (rv) { - break; + if (rv) { + break; + } } - } - if (!rv) { - test_me(function () { - opts.conditions = []; - opts.rules = []; - opts.performAction = 'null'; // opts.options = {}; - // opts.caseHelperInclude = '{}'; - - opts.showSource = false; - opts.__in_rules_failure_analysis_mode__ = true; - dump = false; - }, 'One or more of your lexer rule action code block(s) are possibly botched?', ex, null); + if (!rv) { + test_me(function () { + opts.conditions = []; + opts.rules = []; + opts.performAction = 'null'; // opts.options = {}; + // opts.caseHelperInclude = '{}'; + + opts.showSource = false; + opts.__in_rules_failure_analysis_mode__ = true; + dump = false; + }, 'One or more of your lexer rule action code block(s) are possibly botched?', ex, null); + } } - } + })(); } } @@ -12458,11 +12670,11 @@ function RegExpLexer(dict, input, tokens, build_options) { function getRegExpLexerPrototype() { // --- START lexer kernel --- - return "{\n EOF: 1,\n ERROR: 2,\n\n // JisonLexerError: JisonLexerError, /// <-- injected by the code generator\n\n // options: {}, /// <-- injected by the code generator\n\n // yy: ..., /// <-- injected by setInput()\n\n __currentRuleSet__: null, /// INTERNAL USE ONLY: internal rule set cache for the current lexer state\n\n __error_infos: [], /// INTERNAL USE ONLY: the set of lexErrorInfo objects created since the last cleanup\n\n __decompressed: false, /// INTERNAL USE ONLY: mark whether the lexer instance has been 'unfolded' completely and is now ready for use\n\n done: false, /// INTERNAL USE ONLY\n _backtrack: false, /// INTERNAL USE ONLY\n _input: '', /// INTERNAL USE ONLY\n _more: false, /// INTERNAL USE ONLY\n _signaled_error_token: false, /// INTERNAL USE ONLY\n _clear_state: 0, /// INTERNAL USE ONLY; 0: clear to do, 1: clear done for lex()/next(); -1: clear done for inut()/unput()/...\n\n conditionStack: [], /// INTERNAL USE ONLY; managed via `pushState()`, `popState()`, `topState()` and `stateStackSize()`\n\n match: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction. `match` is identical to `yytext` except that this one still contains the matched input string after `lexer.performAction()` has been invoked, where userland code MAY have changed/replaced the `yytext` value entirely!\n matched: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks entire input which has been matched so far\n matches: false, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks RE match result for last (successful) match attempt\n yytext: '', /// ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction; this value is transferred to the parser as the 'token value' when the parser consumes the lexer token produced through a call to the `lex()` API.\n offset: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks the 'cursor position' in the input string, i.e. the number of characters matched so far. (**WARNING:** this value MAY be negative if you `unput()` more text than you have already lexed. This type of behaviour is generally observed for one kind of 'lexer/parser hack' where custom token-illiciting characters are pushed in front of the input stream to help simulate multiple-START-points in the parser. When this happens, `base_position` will be adjusted to help track the original input's starting point in the `_input` buffer.)\n base_position: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: index to the original starting point of the input; always ZERO(0) unless `unput()` has pushed content before the input: see the `offset` **WARNING** just above.\n yyleng: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: length of matched input for the token under construction (`yytext`)\n yylineno: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: 'line number' at which the token under construction is located\n yylloc: null, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks location info (lines + columns) for the token under construction\n CRLF_Re: /\\r\\n?|\\n/, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: regex used to split lines while tracking the lexer cursor position.\n\n /**\n * INTERNAL USE: construct a suitable error info hash object instance for `parseError`.\n *\n * @public\n * @this {RegExpLexer}\n */\n constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) {\n \"use strict\";\n \n msg = '' + msg;\n\n // heuristic to determine if the error message already contains a (partial) source code dump\n // as produced by either `showPosition()` or `prettyPrintRange()`:\n if (show_input_position == undefined) {\n show_input_position = !(msg.indexOf('\\n') > 0 && msg.indexOf('^') > 0);\n }\n if (this.yylloc && show_input_position) {\n if (typeof this.prettyPrintRange === 'function') {\n var pretty_src = this.prettyPrintRange(this.yylloc);\n\n if (!/\\n\\s*$/.test(msg)) {\n msg += '\\n';\n }\n msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc);\n } else if (typeof this.showPosition === 'function') {\n var pos_str = this.showPosition();\n if (pos_str) {\n if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') {\n msg += '\\n' + pos_str;\n } else {\n msg += pos_str;\n }\n }\n }\n }\n /** @constructor */\n var pei = {\n errStr: msg,\n recoverable: !!recoverable,\n text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'...\n token: null,\n line: this.yylineno,\n loc: this.yylloc,\n yy: this.yy, \n lexer: this,\n\n /**\n * and make sure the error info doesn't stay due to potential\n * ref cycle via userland code manipulations.\n * These would otherwise all be memory leak opportunities!\n *\n * Note that only array and object references are nuked as those\n * constitute the set of elements which can produce a cyclic ref.\n * The rest of the members is kept intact as they are harmless.\n *\n * @public\n * @this {LexErrorInfo}\n */\n destroy: function destructLexErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // ...\n \"use strict\";\n var rec = !!this.recoverable;\n for (var key in this) {\n if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n },\n\n /**\n * handler which is invoked when a lexer error occurs.\n *\n * @public\n * @this {RegExpLexer}\n */\n parseError: function lexer_parseError(str, hash, ExceptionClass) {\n \"use strict\";\n\n if (!ExceptionClass) {\n ExceptionClass = this.JisonLexerError;\n }\n if (this.yy) {\n if (this.yy.parser && typeof this.yy.parser.parseError === 'function') {\n return this.yy.parser.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n } else if (typeof this.yy.parseError === 'function') {\n return this.yy.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n }\n }\n throw new ExceptionClass(str, hash);\n },\n\n /**\n * method which implements `yyerror(str, ...args)` functionality for use inside lexer actions.\n *\n * @public\n * @this {RegExpLexer}\n */\n yyerror: function yyError(str /*, ...args */) {\n \"use strict\";\n\n var lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable);\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n var args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n p.extra_error_attributes = args;\n }\n\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n },\n\n /**\n * final cleanup function for when we have completed lexing the input;\n * make it an API so that external code can use this one once userland\n * code has decided it's time to destroy any lingering lexer error\n * hash object instances and the like: this function helps to clean\n * up these constructs, which *may* carry cyclic references which would\n * otherwise prevent the instances from being properly and timely\n * garbage-collected, i.e. this function helps prevent memory leaks!\n *\n * @public\n * @this {RegExpLexer}\n */\n cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) {\n \"use strict\";\n\n // prevent lingering circular references from causing memory leaks:\n this.setInput('', {});\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (var i = this.__error_infos.length - 1; i >= 0; i--) {\n var el = this.__error_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n }\n\n return this;\n },\n\n /**\n * clear the lexer token context; intended for internal use only\n *\n * @public\n * @this {RegExpLexer}\n */\n clear: function lexer_clear() {\n \"use strict\";\n\n this.yytext = '';\n this.yyleng = 0;\n this.match = '';\n // - DO NOT reset `this.matched`\n this.matches = false;\n\n this._more = false;\n this._backtrack = false;\n\n var col = this.yylloc.last_column;\n this.yylloc = {\n first_line: this.yylineno + 1,\n first_column: col,\n last_line: this.yylineno + 1,\n last_column: col,\n\n range: [this.offset, this.offset]\n };\n },\n\n /**\n * resets the lexer, sets new input\n *\n * @public\n * @this {RegExpLexer}\n */\n setInput: function lexer_setInput(input, yy) {\n \"use strict\";\n\n this.yy = yy || this.yy || {};\n\n // also check if we've fully initialized the lexer instance,\n // including expansion work to be done to go from a loaded\n // lexer to a usable lexer:\n if (!this.__decompressed) {\n // step 1: decompress the regex list:\n var rules = this.rules;\n for (var i = 0, len = rules.length; i < len; i++) {\n var rule_re = rules[i];\n\n // compression: is the RE an xref to another RE slot in the rules[] table?\n if (typeof rule_re === 'number') {\n rules[i] = rules[rule_re];\n }\n }\n\n // step 2: unfold the conditions[] set to make these ready for use:\n var conditions = this.conditions;\n for (var k in conditions) {\n var spec = conditions[k];\n\n var rule_ids = spec.rules;\n\n var len = rule_ids.length;\n var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple!\n var rule_new_ids = new Array(len + 1);\n\n for (var i = 0; i < len; i++) {\n var idx = rule_ids[i];\n var rule_re = rules[idx];\n rule_regexes[i + 1] = rule_re;\n rule_new_ids[i + 1] = idx;\n }\n\n spec.rules = rule_new_ids;\n spec.__rule_regexes = rule_regexes;\n spec.__rule_count = len;\n }\n\n this.__decompressed = true;\n }\n\n if (input && typeof input !== 'string') {\n input = '' + input;\n }\n this._input = input || '';\n this._clear_state = -1;\n this._signaled_error_token = false;\n this.done = false;\n this.yylineno = 0;\n this.matched = '';\n this.conditionStack = ['INITIAL'];\n this.__currentRuleSet__ = null;\n this.yylloc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [0, 0]\n };\n this.offset = 0;\n this.base_position = 0;\n // apply these bits of `this.clear()` as well:\n this.yytext = '';\n this.yyleng = 0;\n this.match = '';\n this.matches = false;\n\n this._more = false;\n this._backtrack = false;\n\n return this;\n },\n\n /**\n * edit the remaining input via user-specified callback.\n * This can be used to forward-adjust the input-to-parse,\n * e.g. inserting macro expansions and alike in the\n * input which has yet to be lexed.\n * The behaviour of this API contrasts the `unput()` et al\n * APIs as those act on the *consumed* input, while this\n * one allows one to manipulate the future, without impacting\n * the current `yyloc` cursor location or any history.\n *\n * Use this API to help implement C-preprocessor-like\n * `#include` statements, etc.\n *\n * The provided callback must be synchronous and is\n * expected to return the edited input (string).\n *\n * The `cpsArg` argument value is passed to the callback\n * as-is.\n *\n * `callback` interface:\n * `function callback(input, cpsArg)`\n *\n * - `input` will carry the remaining-input-to-lex string\n * from the lexer.\n * - `cpsArg` is `cpsArg` passed into this API.\n *\n * The `this` reference for the callback will be set to\n * reference this lexer instance so that userland code\n * in the callback can easily and quickly access any lexer\n * API.\n *\n * When the callback returns a non-string-type falsey value,\n * we assume the callback did not edit the input and we\n * will using the input as-is.\n *\n * When the callback returns a non-string-type value, it\n * is converted to a string for lexing via the `\"\" + retval`\n * operation. (See also why: http://2ality.com/2012/03/converting-to-string.html\n * -- that way any returned object's `toValue()` and `toString()`\n * methods will be invoked in a proper/desirable order.)\n *\n * @public\n * @this {RegExpLexer}\n */\n editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) {\n \"use strict\";\n\n var rv = callback.call(this, this._input, cpsArg);\n if (typeof rv !== 'string') {\n if (rv) {\n this._input = '' + rv;\n }\n // else: keep `this._input` as is.\n } else {\n this._input = rv;\n }\n return this;\n },\n\n /**\n * consumes and returns one char from the input\n *\n * @public\n * @this {RegExpLexer}\n */\n input: function lexer_input() {\n \"use strict\";\n\n if (!this._input) {\n //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*)\n return null;\n }\n if (!this._clear_state && !this._more) {\n this._clear_state = -1;\n this.clear();\n }\n var ch = this._input[0];\n this.yytext += ch;\n this.yyleng++;\n this.offset++;\n this.match += ch;\n this.matched += ch;\n // Count the linenumber up when we hit the LF (or a stand-alone CR).\n // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo\n // and we advance immediately past the LF as well, returning both together as if\n // it was all a single 'character' only.\n var slice_len = 1;\n var lines = false;\n if (ch === '\\n') {\n lines = true;\n } else if (ch === '\\r') {\n lines = true;\n var ch2 = this._input[1];\n if (ch2 === '\\n') {\n slice_len++;\n ch += ch2;\n this.yytext += ch2;\n this.yyleng++;\n this.offset++;\n this.match += ch2;\n this.matched += ch2;\n this.yylloc.range[1]++;\n }\n }\n if (lines) {\n this.yylineno++;\n this.yylloc.last_line++;\n this.yylloc.last_column = 0;\n } else {\n this.yylloc.last_column++;\n }\n this.yylloc.range[1]++;\n\n this._input = this._input.slice(slice_len);\n return ch;\n },\n\n /**\n * unshifts one char (or an entire string) into the input\n *\n * @public\n * @this {RegExpLexer}\n */\n unput: function lexer_unput(ch) {\n \"use strict\";\n\n var len = ch.length;\n var lines = ch.split(this.CRLF_Re);\n\n if (!this._clear_state && !this._more) {\n this._clear_state = -1;\n this.clear();\n }\n\n this._input = ch + this._input;\n this.yytext = this.yytext.substr(0, this.yytext.length - len);\n this.yyleng = this.yytext.length;\n this.offset -= len;\n // **WARNING:**\n // The `offset` value MAY be negative if you `unput()` more text than you have already lexed.\n // This type of behaviour is generally observed for one kind of 'lexer/parser hack'\n // where custom token-illiciting characters are pushed in front of the input stream to help\n // simulate multiple-START-points in the parser.\n // When this happens, `base_position` will be adjusted to help track the original input's\n // starting point in the `_input` buffer.\n if (-this.offset > this.base_position) {\n this.base_position = -this.offset;\n }\n this.match = this.match.substr(0, this.match.length - len);\n this.matched = this.matched.substr(0, this.matched.length - len);\n\n if (lines.length > 1) {\n this.yylineno -= lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n\n // Get last entirely matched line into the `pre_lines[]` array's\n // last index slot; we don't mind when other previously\n // matched lines end up in the array too.\n var pre = this.match;\n var pre_lines = pre.split(this.CRLF_Re);\n if (pre_lines.length === 1) {\n pre = this.matched;\n pre_lines = pre.split(this.CRLF_Re);\n }\n this.yylloc.last_column = pre_lines[pre_lines.length - 1].length;\n } else {\n this.yylloc.last_column -= len;\n }\n\n this.yylloc.range[1] = this.yylloc.range[0] + this.yyleng;\n\n this.done = false;\n return this;\n },\n\n /**\n * return the upcoming input *which has not been lexed yet*.\n * This can, for example, be used for custom look-ahead inspection code \n * in your lexer.\n * \n * The entire pending input string is returned.\n *\n * > ### NOTE ###\n * >\n * > When augmenting error reports and alike, you might want to\n * > look at the `upcomingInput()` API instead, which offers more\n * > features for limited input extraction and which includes the\n * > part of the input which has been lexed by the last token a.k.a.\n * > the *currently lexed* input.\n * > \n * \n * @public\n * @this {RegExpLexer}\n */\n lookAhead: function lexer_lookAhead() {\n \"use strict\";\n\n return this._input || '';\n },\n\n /**\n * cache matched text and append it on next action\n *\n * @public\n * @this {RegExpLexer}\n */\n more: function lexer_more() {\n \"use strict\";\n\n this._more = true;\n return this;\n },\n\n /**\n * signal the lexer that this rule fails to match the input, so the\n * next matching rule (regex) should be tested instead.\n *\n * @public\n * @this {RegExpLexer}\n */\n reject: function lexer_reject() {\n \"use strict\";\n\n if (this.options.backtrack_lexer) {\n this._backtrack = true;\n } else {\n // when the `parseError()` call returns, we MUST ensure that the error is registered.\n // We accomplish this by signaling an 'error' token to be produced for the current\n // `.lex()` run.\n var lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false);\n this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n return this;\n },\n\n /**\n * retain first n characters of the match\n *\n * @public\n * @this {RegExpLexer}\n */\n less: function lexer_less(n) {\n \"use strict\";\n\n return this.unput(this.match.slice(n));\n },\n\n /**\n * return (part of the) already matched input, i.e. for error\n * messages.\n *\n * Limit the returned string length to `maxSize` (default: 20).\n *\n * Limit the returned string to the `maxLines` number of lines of\n * input (default: 1).\n *\n * A negative `maxSize` limit value equals *unlimited*, i.e.\n * produce the entire input that has already been lexed.\n *\n * A negative `maxLines` limit value equals *unlimited*, i.e. limit the result\n * to the `maxSize` specified number of characters *only*.\n *\n * @public\n * @this {RegExpLexer}\n */\n pastInput: function lexer_pastInput(maxSize, maxLines) {\n \"use strict\";\n\n var past = this.matched.substring(0, this.matched.length - this.match.length);\n if (maxSize < 0)\n maxSize = Infinity;\n else if (!maxSize)\n maxSize = 20;\n if (maxLines < 0)\n maxLines = Infinity; // can't ever have more input lines than this!\n else if (!maxLines)\n maxLines = 1;\n // `substr` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we've transformed and limited the newLines in here:\n past = past.substr(-maxSize * 2 - 2);\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n var a = past.split(this.CRLF_Re);\n a = a.slice(-maxLines);\n past = a.join('\\n');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis prefix...\n if (past.length > maxSize) {\n past = '...' + past.substr(-maxSize);\n }\n return past;\n },\n\n /**\n * return (part of the) upcoming input *including* the input \n * matched by the last token (see also the NOTE below). \n * This can be used to augment error messages, for example.\n *\n * Limit the returned string length to `maxSize` (default: 20).\n *\n * Limit the returned string to the `maxLines` number of lines of input (default: 1).\n *\n * A negative `maxSize` limit value equals *unlimited*, i.e.\n * produce the entire input that is yet to be lexed.\n *\n * A negative `maxLines` limit value equals *unlimited*, i.e. limit the result\n * to the `maxSize` specified number of characters *only*.\n *\n * > ### NOTE ###\n * >\n * > *\"upcoming input\"* is defined as the whole of the both\n * > the *currently lexed* input, together with any remaining input\n * > following that. *\"currently lexed\"* input is the input\n * > already recognized by the lexer but not yet returned with\n * > the lexer token. This happens when you are invoking this API\n * > from inside any lexer rule action code block.\n * >\n * > When you want access to the 'upcoming input' in that you want access\n * > to the input *which has not been lexed yet* for look-ahead\n * > inspection or likewise purposes, please consider using the\n * > `lookAhead()` API instead.\n * > \n * \n * @public\n * @this {RegExpLexer}\n */\n upcomingInput: function lexer_upcomingInput(maxSize, maxLines) {\n \"use strict\";\n\n var next = this.match;\n var source = this._input || '';\n if (maxSize < 0)\n maxSize = next.length + source.length;\n else if (!maxSize)\n maxSize = 20;\n if (maxLines < 0)\n maxLines = maxSize; // can't ever have more input lines than this!\n else if (!maxLines)\n maxLines = 1;\n // `substring` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we've transformed and limited the newLines in here:\n if (next.length < maxSize * 2 + 2) {\n next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8\n }\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines.\n a = a.slice(0, maxLines);\n next = a.join('\\n');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis postfix...\n if (next.length > maxSize) {\n next = next.substring(0, maxSize) + '...';\n }\n return next;\n },\n\n /**\n * return a string which displays the character position where the\n * lexing error occurred, i.e. for error messages\n *\n * @public\n * @this {RegExpLexer}\n */\n showPosition: function lexer_showPosition(maxPrefix, maxPostfix) {\n \"use strict\";\n\n var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' ');\n var c = new Array(pre.length + 1).join('-');\n return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^';\n },\n\n /**\n * return an YYLLOC info object derived off the given context (actual, preceding, following, current).\n * Use this method when the given `actual` location is not guaranteed to exist (i.e. when\n * it MAY be NULL) and you MUST have a valid location info object anyway:\n * then we take the given context of the `preceding` and `following` locations, IFF those are available,\n * and reconstruct the `actual` location info from those.\n * If this fails, the heuristic is to take the `current` location, IFF available.\n * If this fails as well, we assume the sought location is at/around the current lexer position\n * and then produce that one as a response. DO NOTE that these heuristic/derived location info\n * values MAY be inaccurate!\n *\n * NOTE: `deriveLocationInfo()` ALWAYS produces a location info object *copy* of `actual`, not just\n * a *reference* hence all input location objects can be assumed to be 'constant' (function has no side-effects).\n *\n * @public\n * @this {RegExpLexer}\n */\n deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) {\n \"use strict\";\n\n var loc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [0, 0]\n };\n if (actual) {\n loc.first_line = actual.first_line | 0;\n loc.last_line = actual.last_line | 0;\n loc.first_column = actual.first_column | 0;\n loc.last_column = actual.last_column | 0;\n\n if (actual.range) {\n loc.range[0] = actual.range[0] | 0;\n loc.range[1] = actual.range[1] | 0;\n }\n }\n if (loc.first_line <= 0 || loc.last_line < loc.first_line) {\n // plan B: heuristic using preceding and following:\n if (loc.first_line <= 0 && preceding) {\n loc.first_line = preceding.last_line | 0;\n loc.first_column = preceding.last_column | 0;\n\n if (preceding.range) {\n loc.range[0] = actual.range[1] | 0;\n }\n }\n\n if ((loc.last_line <= 0 || loc.last_line < loc.first_line) && following) {\n loc.last_line = following.first_line | 0;\n loc.last_column = following.first_column | 0;\n\n if (following.range) {\n loc.range[1] = actual.range[0] | 0;\n }\n }\n\n // plan C?: see if the 'current' location is useful/sane too:\n if (loc.first_line <= 0 && current && (loc.last_line <= 0 || current.last_line <= loc.last_line)) {\n loc.first_line = current.first_line | 0;\n loc.first_column = current.first_column | 0;\n\n if (current.range) {\n loc.range[0] = current.range[0] | 0;\n }\n }\n\n if (loc.last_line <= 0 && current && (loc.first_line <= 0 || current.first_line >= loc.first_line)) {\n loc.last_line = current.last_line | 0;\n loc.last_column = current.last_column | 0;\n\n if (current.range) {\n loc.range[1] = current.range[1] | 0;\n }\n }\n }\n // sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter\n // or plan D heuristics to produce a 'sensible' last_line value:\n if (loc.last_line <= 0) {\n if (loc.first_line <= 0) {\n loc.first_line = this.yylloc.first_line;\n loc.last_line = this.yylloc.last_line;\n loc.first_column = this.yylloc.first_column;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[0] = this.yylloc.range[0];\n loc.range[1] = this.yylloc.range[1];\n } else {\n loc.last_line = this.yylloc.last_line;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[1] = this.yylloc.range[1];\n }\n }\n if (loc.first_line <= 0) {\n loc.first_line = loc.last_line;\n loc.first_column = 0; // loc.last_column;\n\n loc.range[1] = loc.range[0];\n }\n if (loc.first_column < 0) {\n loc.first_column = 0;\n }\n if (loc.last_column < 0) {\n loc.last_column = (loc.first_column > 0 ? loc.first_column : 80);\n }\n return loc;\n },\n\n /**\n * return a string which displays the lines & columns of input which are referenced\n * by the given location info range, plus a few lines of context.\n *\n * This function pretty-prints the indicated section of the input, with line numbers\n * and everything!\n *\n * This function is very useful to provide highly readable error reports, while\n * the location range may be specified in various flexible ways:\n *\n * - `loc` is the location info object which references the area which should be\n * displayed and 'marked up': these lines & columns of text are marked up by `^`\n * characters below each character in the entire input range.\n *\n * - `context_loc` is the *optional* location info object which instructs this\n * pretty-printer how much *leading* context should be displayed alongside\n * the area referenced by `loc`. This can help provide context for the displayed\n * error, etc.\n *\n * When this location info is not provided, a default context of 3 lines is\n * used.\n *\n * - `context_loc2` is another *optional* location info object, which serves\n * a similar purpose to `context_loc`: it specifies the amount of *trailing*\n * context lines to display in the pretty-print output.\n *\n * When this location info is not provided, a default context of 1 line only is\n * used.\n *\n * Special Notes:\n *\n * - when the `loc`-indicated range is very large (about 5 lines or more), then\n * only the first and last few lines of this block are printed while a\n * `...continued...` message will be printed between them.\n *\n * This serves the purpose of not printing a huge amount of text when the `loc`\n * range happens to be huge: this way a manageable & readable output results\n * for arbitrary large ranges.\n *\n * - this function can display lines of input which whave not yet been lexed.\n * `prettyPrintRange()` can access the entire input!\n *\n * @public\n * @this {RegExpLexer}\n */\n prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) {\n \"use strict\";\n\n loc = this.deriveLocationInfo(loc, context_loc, context_loc2);\n\n const CONTEXT = 3;\n const CONTEXT_TAIL = 1;\n const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2;\n var input = this.matched + (this._input || '');\n var lines = input.split('\\n');\n var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT));\n var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL));\n var lineno_display_width = (1 + Math.log10(l1 | 1) | 0);\n var ws_prefix = new Array(lineno_display_width).join(' ');\n var nonempty_line_indexes = [[], [], []];\n var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) {\n \"use strict\";\n\n var lno = index + l0;\n var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width);\n var rv = lno_pfx + ': ' + line;\n var errpfx = (new Array(lineno_display_width + 1)).join('^');\n var offset = 2 + 1;\n var len = 0;\n\n if (lno === loc.first_line) {\n offset += loc.first_column;\n\n len = Math.max(\n 2,\n ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1\n );\n } else if (lno === loc.last_line) {\n len = Math.max(2, loc.last_column + 1);\n } else if (lno > loc.first_line && lno < loc.last_line) {\n len = Math.max(2, line.length + 1);\n }\n\n var nli;\n if (len) {\n var lead = new Array(offset).join('.');\n var mark = new Array(len).join('^');\n rv += '\\n' + errpfx + lead + mark;\n\n nli = 1;\n } else if (lno < loc.first_line) {\n nli = 0;\n } else if (lno > loc.last_line) {\n nli = 2;\n }\n\n if (line.trim().length > 0) {\n nonempty_line_indexes[nli].push(index);\n }\n\n rv = rv.replace(/\\t/g, ' ');\n return rv;\n });\n\n // now make sure we don't print an overly large amount of lead/error/tail area: limit it\n // to the top and bottom line count:\n for (var i = 0; i <= 2; i++) {\n var line_arr = nonempty_line_indexes[i];\n if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) {\n var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1;\n var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1;\n\n var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)';\n if (i === 1) {\n intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)';\n }\n rv.splice(clip_start, clip_end - clip_start + 1, intermediate_line);\n }\n }\n\n return rv.join('\\n');\n },\n\n /**\n * helper function, used to produce a human readable description as a string, given\n * the input `yylloc` location object.\n *\n * Set `display_range_too` to TRUE to include the string character index position(s)\n * in the description if the `yylloc.range` is available.\n *\n * @public\n * @this {RegExpLexer}\n */\n describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) {\n \"use strict\";\n\n var l1 = yylloc.first_line;\n var l2 = yylloc.last_line;\n var c1 = yylloc.first_column;\n var c2 = yylloc.last_column;\n var dl = l2 - l1;\n var dc = c2 - c1;\n var rv;\n if (dl === 0) {\n rv = 'line ' + l1 + ', ';\n if (dc <= 1) {\n rv += 'column ' + c1;\n } else {\n rv += 'columns ' + c1 + ' .. ' + c2;\n }\n } else {\n rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')';\n }\n if (yylloc.range && display_range_too) {\n var r1 = yylloc.range[0];\n var r2 = yylloc.range[1] - 1;\n if (r2 <= r1) {\n rv += ' {String Offset: ' + r1 + '}';\n } else {\n rv += ' {String Offset range: ' + r1 + ' .. ' + r2 + '}';\n }\n }\n return rv;\n },\n\n /**\n * test the lexed token: return FALSE when not a match, otherwise return token.\n *\n * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]`\n * contains the actually matched text string.\n *\n * Also move the input cursor forward and update the match collectors:\n *\n * - `yytext`\n * - `yyleng`\n * - `match`\n * - `matches`\n * - `yylloc`\n * - `offset`\n *\n * @public\n * @this {RegExpLexer}\n */\n test_match: function lexer_test_match(match, indexed_rule) {\n \"use strict\";\n\n var token,\n lines,\n backup,\n match_str,\n match_str_len;\n\n if (this.options.backtrack_lexer) {\n // save context\n backup = {\n yylineno: this.yylineno,\n yylloc: {\n first_line: this.yylloc.first_line,\n last_line: this.yylloc.last_line,\n first_column: this.yylloc.first_column,\n last_column: this.yylloc.last_column,\n\n range: this.yylloc.range.slice()\n },\n yytext: this.yytext,\n match: this.match,\n matches: this.matches,\n matched: this.matched,\n yyleng: this.yyleng,\n offset: this.offset,\n _more: this._more,\n _input: this._input,\n //_signaled_error_token: this._signaled_error_token,\n yy: this.yy,\n conditionStack: this.conditionStack.slice(),\n done: this.done\n };\n }\n\n match_str = match[0];\n match_str_len = match_str.length;\n\n lines = match_str.split(this.CRLF_Re);\n if (lines.length > 1) {\n this.yylineno += lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n this.yylloc.last_column = lines[lines.length - 1].length;\n } else {\n this.yylloc.last_column += match_str_len;\n }\n\n this.yytext += match_str;\n this.match += match_str;\n this.matched += match_str;\n this.matches = match;\n this.yyleng = this.yytext.length;\n this.yylloc.range[1] += match_str_len;\n\n // previous lex rules MAY have invoked the `more()` API rather than producing a token:\n // those rules will already have moved this `offset` forward matching their match lengths,\n // hence we must only add our own match length now:\n this.offset += match_str_len;\n this._more = false;\n this._backtrack = false;\n this._input = this._input.slice(match_str_len);\n\n // calling this method:\n //\n // function lexer__performAction(yy, yyrulenumber, YY_START) {...}\n token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */);\n // otherwise, when the action codes are all simple return token statements:\n //token = this.simpleCaseActionClusters[indexed_rule];\n\n if (this.done && this._input) {\n this.done = false;\n }\n if (token) {\n return token;\n } else if (this._backtrack) {\n // recover context\n for (var k in backup) {\n this[k] = backup[k];\n }\n this.__currentRuleSet__ = null;\n return false; // rule action called reject() implying the next rule should be tested instead.\n } else if (this._signaled_error_token) {\n // produce one 'error' token as `.parseError()` in `reject()`\n // did not guarantee a failure signal by throwing an exception!\n token = this._signaled_error_token;\n this._signaled_error_token = false;\n return token;\n }\n return false;\n },\n\n /**\n * return next match in input\n *\n * @public\n * @this {RegExpLexer}\n */\n next: function lexer_next() {\n \"use strict\";\n\n if (this.done) {\n this.clear();\n return this.EOF;\n }\n if (!this._input) {\n this.done = true;\n }\n\n var token,\n match,\n tempMatch,\n index;\n if (!this._more) {\n if (!this._clear_state) {\n this._clear_state = 1;\n }\n this.clear();\n }\n var spec = this.__currentRuleSet__;\n if (!spec) {\n // Update the ruleset cache as we apparently encountered a state change or just started lexing.\n // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will\n // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps\n // speed up those activities a tiny bit.\n spec = this.__currentRuleSet__ = this._currentRules();\n // Check whether a *sane* condition has been pushed before: this makes the lexer robust against\n // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19\n if (!spec || !spec.rules) {\n var lineno_msg = '';\n if (this.yylloc) {\n lineno_msg = ' on line ' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name \"' + this.topState() + '\"; this is a fatal error and should be reported to the application programmer team!', false);\n // produce one 'error' token until this situation has been resolved, most probably by parse termination!\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n }\n\n var rule_ids = spec.rules;\n var regexes = spec.__rule_regexes;\n var len = spec.__rule_count;\n\n // Note: the arrays are 1-based, while `len` itself is a valid index,\n // hence the non-standard less-or-equal check in the next loop condition!\n for (var i = 1; i <= len; i++) {\n tempMatch = this._input.match(regexes[i]);\n if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n match = tempMatch;\n index = i;\n if (this.options.backtrack_lexer) {\n token = this.test_match(tempMatch, rule_ids[i]);\n if (token !== false) {\n return token;\n } else if (this._backtrack) {\n match = undefined;\n continue; // rule action called reject() implying a rule MISmatch.\n } else {\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n } else if (!this.options.flex) {\n break;\n }\n }\n }\n if (match) {\n token = this.test_match(match, rule_ids[index]);\n if (token !== false) {\n return token;\n }\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n if (!this._input) {\n this.done = true;\n this.clear();\n return this.EOF;\n } else {\n var lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable);\n\n var pendingInput = this._input;\n var activeCondition = this.topState();\n var conditionStackDepth = this.conditionStack.length;\n\n token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n if (token === this.ERROR) {\n // we can try to recover from a lexer error that `parseError()` did not 'recover' for us\n // by moving forward at least one character at a time IFF the (user-specified?) `parseError()`\n // has not consumed/modified any pending input or changed state in the error handler:\n if (!this.matches &&\n // and make sure the input has been modified/consumed ...\n pendingInput === this._input &&\n // ...or the lexer state has been modified significantly enough\n // to merit a non-consuming error handling action right now.\n activeCondition === this.topState() &&\n conditionStackDepth === this.conditionStack.length\n ) {\n this.input();\n }\n }\n return token;\n }\n },\n\n /**\n * return next match that has a token\n *\n * @public\n * @this {RegExpLexer}\n */\n lex: function lexer_lex() {\n \"use strict\";\n\n var r;\n\n //this._clear_state = 0;\n\n if (!this._more) {\n if (!this._clear_state) {\n this._clear_state = 1;\n }\n this.clear();\n }\n\n // allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer:\n if (typeof this.pre_lex === 'function') {\n r = this.pre_lex.call(this, 0);\n }\n if (typeof this.options.pre_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.pre_lex.call(this, r) || r;\n }\n if (this.yy && typeof this.yy.pre_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.pre_lex.call(this, r) || r;\n }\n\n while (!r) {\n r = this.next();\n }\n\n if (this.yy && typeof this.yy.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.post_lex.call(this, r) || r;\n }\n if (typeof this.options.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.post_lex.call(this, r) || r;\n }\n if (typeof this.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.post_lex.call(this, r) || r;\n }\n\n if (!this._more) {\n //\n // 1) make sure any outside interference is detected ASAP: \n // these attributes are to be treated as 'const' values\n // once the lexer has produced them with the token (return value `r`).\n // 2) make sure any subsequent `lex()` API invocation CANNOT\n // edit the `yytext`, etc. token attributes for the *current*\n // token, i.e. provide a degree of 'closure safety' so that\n // code like this:\n // \n // t1 = lexer.lex();\n // v = lexer.yytext;\n // l = lexer.yylloc;\n // t2 = lexer.lex();\n // assert(lexer.yytext !== v);\n // assert(lexer.yylloc !== l);\n // \n // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee*\n // these conditions.\n // \n this.yytext = Object.freeze(this.yytext);\n this.matches = Object.freeze(this.matches);\n this.yylloc.range = Object.freeze(this.yylloc.range);\n this.yylloc = Object.freeze(this.yylloc);\n\n this._clear_state = 0;\n }\n\n return r;\n },\n\n /**\n * return next match that has a token. Identical to the `lex()` API but does not invoke any of the\n * `pre_lex()` nor any of the `post_lex()` callbacks.\n *\n * @public\n * @this {RegExpLexer}\n */\n fastLex: function lexer_fastLex() {\n \"use strict\";\n\n var r;\n\n //this._clear_state = 0;\n\n while (!r) {\n r = this.next();\n }\n\n if (!this._more) {\n //\n // 1) make sure any outside interference is detected ASAP: \n // these attributes are to be treated as 'const' values\n // once the lexer has produced them with the token (return value `r`).\n // 2) make sure any subsequent `lex()` API invocation CANNOT\n // edit the `yytext`, etc. token attributes for the *current*\n // token, i.e. provide a degree of 'closure safety' so that\n // code like this:\n // \n // t1 = lexer.lex();\n // v = lexer.yytext;\n // l = lexer.yylloc;\n // t2 = lexer.lex();\n // assert(lexer.yytext !== v);\n // assert(lexer.yylloc !== l);\n // \n // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee*\n // these conditions.\n // \n this.yytext = Object.freeze(this.yytext);\n this.matches = Object.freeze(this.matches);\n this.yylloc.range = Object.freeze(this.yylloc.range);\n this.yylloc = Object.freeze(this.yylloc);\n\n this._clear_state = 0;\n }\n \n return r;\n },\n\n /**\n * return info about the lexer state that can help a parser or other lexer API user to use the\n * most efficient means available. This API is provided to aid run-time performance for larger\n * systems which employ this lexer.\n *\n * @public\n * @this {RegExpLexer}\n */\n canIUse: function lexer_canIUse() {\n \"use strict\";\n\n var rv = {\n fastLex: !(\n typeof this.pre_lex === 'function' ||\n typeof this.options.pre_lex === 'function' ||\n (this.yy && typeof this.yy.pre_lex === 'function') ||\n (this.yy && typeof this.yy.post_lex === 'function') ||\n typeof this.options.post_lex === 'function' ||\n typeof this.post_lex === 'function'\n ) && typeof this.fastLex === 'function',\n };\n return rv;\n },\n\n\n /**\n * backwards compatible alias for `pushState()`;\n * the latter is symmetrical with `popState()` and we advise to use\n * those APIs in any modern lexer code, rather than `begin()`.\n *\n * @public\n * @this {RegExpLexer}\n */\n begin: function lexer_begin(condition) {\n \"use strict\";\n\n return this.pushState(condition);\n },\n\n /**\n * activates a new lexer condition state (pushes the new lexer\n * condition state onto the condition stack)\n *\n * @public\n * @this {RegExpLexer}\n */\n pushState: function lexer_pushState(condition) {\n \"use strict\";\n\n this.conditionStack.push(condition);\n this.__currentRuleSet__ = null;\n return this;\n },\n\n /**\n * pop the previously active lexer condition state off the condition\n * stack\n *\n * @public\n * @this {RegExpLexer}\n */\n popState: function lexer_popState() {\n \"use strict\";\n\n var n = this.conditionStack.length - 1;\n if (n > 0) {\n this.__currentRuleSet__ = null;\n return this.conditionStack.pop();\n } else {\n return this.conditionStack[0];\n }\n },\n\n /**\n * return the currently active lexer condition state; when an index\n * argument is provided it produces the N-th previous condition state,\n * if available\n *\n * @public\n * @this {RegExpLexer}\n */\n topState: function lexer_topState(n) {\n \"use strict\";\n\n n = this.conditionStack.length - 1 - Math.abs(n || 0);\n if (n >= 0) {\n return this.conditionStack[n];\n } else {\n return 'INITIAL';\n }\n },\n\n /**\n * (internal) determine the lexer rule set which is active for the\n * currently active lexer condition state\n *\n * @public\n * @this {RegExpLexer}\n */\n _currentRules: function lexer__currentRules() {\n \"use strict\";\n\n var n = this.conditionStack.length - 1;\n var state;\n if (n >= 0) {\n state = this.conditionStack[n];\n } else {\n state = 'INITIAL';\n }\n return this.conditions[state] || this.conditions['INITIAL'];\n },\n\n /**\n * return the number of states currently on the stack\n *\n * @public\n * @this {RegExpLexer}\n */\n stateStackSize: function lexer_stateStackSize() {\n \"use strict\";\n\n return this.conditionStack.length;\n }\n}"; // --- END lexer kernel --- + return "{\n EOF: 1,\n ERROR: 2,\n\n // JisonLexerError: JisonLexerError, /// <-- injected by the code generator\n\n // options: {}, /// <-- injected by the code generator\n\n // yy: ..., /// <-- injected by setInput()\n\n __currentRuleSet__: null, /// INTERNAL USE ONLY: internal rule set cache for the current lexer state\n\n __error_infos: [], /// INTERNAL USE ONLY: the set of lexErrorInfo objects created since the last cleanup\n\n __decompressed: false, /// INTERNAL USE ONLY: mark whether the lexer instance has been 'unfolded' completely and is now ready for use\n\n done: false, /// INTERNAL USE ONLY\n _backtrack: false, /// INTERNAL USE ONLY\n _input: '', /// INTERNAL USE ONLY\n _more: false, /// INTERNAL USE ONLY\n _signaled_error_token: false, /// INTERNAL USE ONLY\n _clear_state: 0, /// INTERNAL USE ONLY; 0: clear to do, 1: clear done for lex()/next(); -1: clear done for inut()/unput()/...\n\n conditionStack: [], /// INTERNAL USE ONLY; managed via `pushState()`, `popState()`, `topState()` and `stateStackSize()`\n\n match: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction. `match` is identical to `yytext` except that this one still contains the matched input string after `lexer.performAction()` has been invoked, where userland code MAY have changed/replaced the `yytext` value entirely!\n matched: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks entire input which has been matched so far\n matches: false, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks RE match result for last (successful) match attempt\n yytext: '', /// ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction; this value is transferred to the parser as the 'token value' when the parser consumes the lexer token produced through a call to the `lex()` API.\n offset: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks the 'cursor position' in the input string, i.e. the number of characters matched so far. (**WARNING:** this value MAY be negative if you `unput()` more text than you have already lexed. This type of behaviour is generally observed for one kind of 'lexer/parser hack' where custom token-illiciting characters are pushed in front of the input stream to help simulate multiple-START-points in the parser. When this happens, `base_position` will be adjusted to help track the original input's starting point in the `_input` buffer.)\n base_position: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: index to the original starting point of the input; always ZERO(0) unless `unput()` has pushed content before the input: see the `offset` **WARNING** just above.\n yyleng: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: length of matched input for the token under construction (`yytext`)\n yylineno: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: 'line number' at which the token under construction is located\n yylloc: null, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks location info (lines + columns) for the token under construction\n CRLF_Re: /\\r\\n?|\\n/, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: regex used to split lines while tracking the lexer cursor position.\n\n /**\n * INTERNAL USE: construct a suitable error info hash object instance for `parseError`.\n *\n * @public\n * @this {RegExpLexer}\n */\n constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) {\n msg = '' + msg;\n\n // heuristic to determine if the error message already contains a (partial) source code dump\n // as produced by either `showPosition()` or `prettyPrintRange()`:\n if (show_input_position == undefined) {\n show_input_position = !(msg.indexOf('\\n') > 0 && msg.indexOf('^') > 0);\n }\n if (this.yylloc && show_input_position) {\n if (typeof this.prettyPrintRange === 'function') {\n const pretty_src = this.prettyPrintRange(this.yylloc);\n\n if (!/\\n\\s*$/.test(msg)) {\n msg += '\\n';\n }\n msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc);\n } else if (typeof this.showPosition === 'function') {\n const pos_str = this.showPosition();\n if (pos_str) {\n if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') {\n msg += '\\n' + pos_str;\n } else {\n msg += pos_str;\n }\n }\n }\n }\n /** @constructor */\n const pei = {\n errStr: msg,\n recoverable: !!recoverable,\n text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'...\n token: null,\n line: this.yylineno,\n loc: this.yylloc,\n yy: this.yy,\n lexer: this,\n\n /**\n * and make sure the error info doesn't stay due to potential\n * ref cycle via userland code manipulations.\n * These would otherwise all be memory leak opportunities!\n *\n * Note that only array and object references are nuked as those\n * constitute the set of elements which can produce a cyclic ref.\n * The rest of the members is kept intact as they are harmless.\n *\n * @public\n * @this {LexErrorInfo}\n */\n destroy: function destructLexErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // ...\n const rec = !!this.recoverable;\n for (let key in this) {\n if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n },\n\n /**\n * handler which is invoked when a lexer error occurs.\n *\n * @public\n * @this {RegExpLexer}\n */\n parseError: function lexer_parseError(str, hash, ExceptionClass) {\n if (!ExceptionClass) {\n ExceptionClass = this.JisonLexerError;\n }\n if (this.yy) {\n if (this.yy.parser && typeof this.yy.parser.parseError === 'function') {\n return this.yy.parser.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n } else if (typeof this.yy.parseError === 'function') {\n return this.yy.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n }\n }\n throw new ExceptionClass(str, hash);\n },\n\n /**\n * method which implements `yyerror(str, ...args)` functionality for use inside lexer actions.\n *\n * @public\n * @this {RegExpLexer}\n */\n yyerror: function yyError(str /*, ...args */) {\n let lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable);\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n let args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n p.extra_error_attributes = args;\n }\n\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n },\n\n /**\n * final cleanup function for when we have completed lexing the input;\n * make it an API so that external code can use this one once userland\n * code has decided it's time to destroy any lingering lexer error\n * hash object instances and the like: this function helps to clean\n * up these constructs, which *may* carry cyclic references which would\n * otherwise prevent the instances from being properly and timely\n * garbage-collected, i.e. this function helps prevent memory leaks!\n *\n * @public\n * @this {RegExpLexer}\n */\n cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) {\n // prevent lingering circular references from causing memory leaks:\n this.setInput('', {});\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (let i = this.__error_infos.length - 1; i >= 0; i--) {\n let el = this.__error_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n }\n\n return this;\n },\n\n /**\n * clear the lexer token context; intended for internal use only\n *\n * @public\n * @this {RegExpLexer}\n */\n clear: function lexer_clear() {\n this.yytext = '';\n this.yyleng = 0;\n this.match = '';\n // - DO NOT reset `this.matched`\n this.matches = false;\n\n this._more = false;\n this._backtrack = false;\n\n const col = this.yylloc.last_column;\n this.yylloc = {\n first_line: this.yylineno + 1,\n first_column: col,\n last_line: this.yylineno + 1,\n last_column: col,\n\n range: [ this.offset, this.offset ]\n };\n },\n\n /**\n * resets the lexer, sets new input\n *\n * @public\n * @this {RegExpLexer}\n */\n setInput: function lexer_setInput(input, yy) {\n this.yy = yy || this.yy || {};\n\n // also check if we've fully initialized the lexer instance,\n // including expansion work to be done to go from a loaded\n // lexer to a usable lexer:\n if (!this.__decompressed) {\n // step 1: decompress the regex list:\n let rules = this.rules;\n for (var i = 0, len = rules.length; i < len; i++) {\n var rule_re = rules[i];\n\n // compression: is the RE an xref to another RE slot in the rules[] table?\n if (typeof rule_re === 'number') {\n rules[i] = rules[rule_re];\n }\n }\n\n // step 2: unfold the conditions[] set to make these ready for use:\n let conditions = this.conditions;\n for (let k in conditions) {\n let spec = conditions[k];\n\n let rule_ids = spec.rules;\n\n var len = rule_ids.length;\n let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple!\n let rule_new_ids = new Array(len + 1);\n\n for (var i = 0; i < len; i++) {\n let idx = rule_ids[i];\n var rule_re = rules[idx];\n rule_regexes[i + 1] = rule_re;\n rule_new_ids[i + 1] = idx;\n }\n\n spec.rules = rule_new_ids;\n spec.__rule_regexes = rule_regexes;\n spec.__rule_count = len;\n }\n\n this.__decompressed = true;\n }\n\n if (input && typeof input !== 'string') {\n input = '' + input;\n }\n this._input = input || '';\n this._clear_state = -1;\n this._signaled_error_token = false;\n this.done = false;\n this.yylineno = 0;\n this.matched = '';\n this.conditionStack = [ 'INITIAL' ];\n this.__currentRuleSet__ = null;\n this.yylloc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [ 0, 0 ]\n };\n this.offset = 0;\n this.base_position = 0;\n // apply these bits of `this.clear()` as well:\n this.yytext = '';\n this.yyleng = 0;\n this.match = '';\n this.matches = false;\n\n this._more = false;\n this._backtrack = false;\n\n return this;\n },\n\n /**\n * edit the remaining input via user-specified callback.\n * This can be used to forward-adjust the input-to-parse,\n * e.g. inserting macro expansions and alike in the\n * input which has yet to be lexed.\n * The behaviour of this API contrasts the `unput()` et al\n * APIs as those act on the *consumed* input, while this\n * one allows one to manipulate the future, without impacting\n * the current `yyloc` cursor location or any history.\n *\n * Use this API to help implement C-preprocessor-like\n * `#include` statements, etc.\n *\n * The provided callback must be synchronous and is\n * expected to return the edited input (string).\n *\n * The `cpsArg` argument value is passed to the callback\n * as-is.\n *\n * `callback` interface:\n * `function callback(input, cpsArg)`\n *\n * - `input` will carry the remaining-input-to-lex string\n * from the lexer.\n * - `cpsArg` is `cpsArg` passed into this API.\n *\n * The `this` reference for the callback will be set to\n * reference this lexer instance so that userland code\n * in the callback can easily and quickly access any lexer\n * API.\n *\n * When the callback returns a non-string-type falsey value,\n * we assume the callback did not edit the input and we\n * will using the input as-is.\n *\n * When the callback returns a non-string-type value, it\n * is converted to a string for lexing via the `\"\" + retval`\n * operation. (See also why: http://2ality.com/2012/03/converting-to-string.html\n * -- that way any returned object's `toValue()` and `toString()`\n * methods will be invoked in a proper/desirable order.)\n *\n * @public\n * @this {RegExpLexer}\n */\n editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) {\n const rv = callback.call(this, this._input, cpsArg);\n if (typeof rv !== 'string') {\n if (rv) {\n this._input = '' + rv;\n }\n // else: keep `this._input` as is.\n } else {\n this._input = rv;\n }\n return this;\n },\n\n /**\n * consumes and returns one char from the input\n *\n * @public\n * @this {RegExpLexer}\n */\n input: function lexer_input() {\n if (!this._input) {\n //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*)\n return null;\n }\n if (!this._clear_state && !this._more) {\n this._clear_state = -1;\n this.clear();\n }\n let ch = this._input[0];\n this.yytext += ch;\n this.yyleng++;\n this.offset++;\n this.match += ch;\n this.matched += ch;\n // Count the linenumber up when we hit the LF (or a stand-alone CR).\n // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo\n // and we advance immediately past the LF as well, returning both together as if\n // it was all a single 'character' only.\n let slice_len = 1;\n let lines = false;\n if (ch === '\\n') {\n lines = true;\n } else if (ch === '\\r') {\n lines = true;\n const ch2 = this._input[1];\n if (ch2 === '\\n') {\n slice_len++;\n ch += ch2;\n this.yytext += ch2;\n this.yyleng++;\n this.offset++;\n this.match += ch2;\n this.matched += ch2;\n this.yylloc.range[1]++;\n }\n }\n if (lines) {\n this.yylineno++;\n this.yylloc.last_line++;\n this.yylloc.last_column = 0;\n } else {\n this.yylloc.last_column++;\n }\n this.yylloc.range[1]++;\n\n this._input = this._input.slice(slice_len);\n return ch;\n },\n\n /**\n * unshifts one char (or an entire string) into the input\n *\n * @public\n * @this {RegExpLexer}\n */\n unput: function lexer_unput(ch) {\n let len = ch.length;\n let lines = ch.split(this.CRLF_Re);\n\n if (!this._clear_state && !this._more) {\n this._clear_state = -1;\n this.clear();\n }\n\n this._input = ch + this._input;\n this.yytext = this.yytext.substr(0, this.yytext.length - len);\n this.yyleng = this.yytext.length;\n this.offset -= len;\n // **WARNING:**\n // The `offset` value MAY be negative if you `unput()` more text than you have already lexed.\n // This type of behaviour is generally observed for one kind of 'lexer/parser hack'\n // where custom token-illiciting characters are pushed in front of the input stream to help\n // simulate multiple-START-points in the parser.\n // When this happens, `base_position` will be adjusted to help track the original input's\n // starting point in the `_input` buffer.\n if (-this.offset > this.base_position) {\n this.base_position = -this.offset;\n }\n this.match = this.match.substr(0, this.match.length - len);\n this.matched = this.matched.substr(0, this.matched.length - len);\n\n if (lines.length > 1) {\n this.yylineno -= lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n\n // Get last entirely matched line into the `pre_lines[]` array's\n // last index slot; we don't mind when other previously\n // matched lines end up in the array too.\n let pre = this.match;\n let pre_lines = pre.split(this.CRLF_Re);\n if (pre_lines.length === 1) {\n pre = this.matched;\n pre_lines = pre.split(this.CRLF_Re);\n }\n this.yylloc.last_column = pre_lines[pre_lines.length - 1].length;\n } else {\n this.yylloc.last_column -= len;\n }\n\n this.yylloc.range[1] = this.yylloc.range[0] + this.yyleng;\n\n this.done = false;\n return this;\n },\n\n /**\n * return the upcoming input *which has not been lexed yet*.\n * This can, for example, be used for custom look-ahead inspection code\n * in your lexer.\n *\n * The entire pending input string is returned.\n *\n * > ### NOTE ###\n * >\n * > When augmenting error reports and alike, you might want to\n * > look at the `upcomingInput()` API instead, which offers more\n * > features for limited input extraction and which includes the\n * > part of the input which has been lexed by the last token a.k.a.\n * > the *currently lexed* input.\n * >\n *\n * @public\n * @this {RegExpLexer}\n */\n lookAhead: function lexer_lookAhead() {\n return this._input || '';\n },\n\n /**\n * cache matched text and append it on next action\n *\n * @public\n * @this {RegExpLexer}\n */\n more: function lexer_more() {\n this._more = true;\n return this;\n },\n\n /**\n * signal the lexer that this rule fails to match the input, so the\n * next matching rule (regex) should be tested instead.\n *\n * @public\n * @this {RegExpLexer}\n */\n reject: function lexer_reject() {\n if (this.options.backtrack_lexer) {\n this._backtrack = true;\n } else {\n // when the `parseError()` call returns, we MUST ensure that the error is registered.\n // We accomplish this by signaling an 'error' token to be produced for the current\n // `.lex()` run.\n let lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false);\n this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n return this;\n },\n\n /**\n * retain first n characters of the match\n *\n * @public\n * @this {RegExpLexer}\n */\n less: function lexer_less(n) {\n return this.unput(this.match.slice(n));\n },\n\n /**\n * return (part of the) already matched input, i.e. for error\n * messages.\n *\n * Limit the returned string length to `maxSize` (default: 20).\n *\n * Limit the returned string to the `maxLines` number of lines of\n * input (default: 1).\n *\n * A negative `maxSize` limit value equals *unlimited*, i.e.\n * produce the entire input that has already been lexed.\n *\n * A negative `maxLines` limit value equals *unlimited*, i.e. limit the result\n * to the `maxSize` specified number of characters *only*.\n *\n * @public\n * @this {RegExpLexer}\n */\n pastInput: function lexer_pastInput(maxSize, maxLines) {\n let past = this.matched.substring(0, this.matched.length - this.match.length);\n if (maxSize < 0) {\n maxSize = Infinity;\n } else if (!maxSize) {\n maxSize = 20;\n }\n if (maxLines < 0) {\n maxLines = Infinity; // can't ever have more input lines than this!\n } else if (!maxLines) {\n maxLines = 1;\n }\n // `substr` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we've transformed and limited the newLines in here:\n past = past.substr(-maxSize * 2 - 2);\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n let a = past.split(this.CRLF_Re);\n a = a.slice(-maxLines);\n past = a.join('\\n');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis prefix...\n if (past.length > maxSize) {\n past = '...' + past.substr(-maxSize);\n }\n return past;\n },\n\n /**\n * return (part of the) upcoming input *including* the input\n * matched by the last token (see also the NOTE below).\n * This can be used to augment error messages, for example.\n *\n * Limit the returned string length to `maxSize` (default: 20).\n *\n * Limit the returned string to the `maxLines` number of lines of input (default: 1).\n *\n * A negative `maxSize` limit value equals *unlimited*, i.e.\n * produce the entire input that is yet to be lexed.\n *\n * A negative `maxLines` limit value equals *unlimited*, i.e. limit the result\n * to the `maxSize` specified number of characters *only*.\n *\n * > ### NOTE ###\n * >\n * > *\"upcoming input\"* is defined as the whole of the both\n * > the *currently lexed* input, together with any remaining input\n * > following that. *\"currently lexed\"* input is the input\n * > already recognized by the lexer but not yet returned with\n * > the lexer token. This happens when you are invoking this API\n * > from inside any lexer rule action code block.\n * >\n * > When you want access to the 'upcoming input' in that you want access\n * > to the input *which has not been lexed yet* for look-ahead\n * > inspection or likewise purposes, please consider using the\n * > `lookAhead()` API instead.\n * >\n *\n * @public\n * @this {RegExpLexer}\n */\n upcomingInput: function lexer_upcomingInput(maxSize, maxLines) {\n let next = this.match;\n let source = this._input || '';\n if (maxSize < 0) {\n maxSize = next.length + source.length;\n } else if (!maxSize) {\n maxSize = 20;\n }\n\n if (maxLines < 0) {\n maxLines = maxSize; // can't ever have more input lines than this!\n } else if (!maxLines) {\n maxLines = 1;\n }\n // `substring` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we've transformed and limited the newLines in here:\n if (next.length < maxSize * 2 + 2) {\n next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8\n }\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines.\n a = a.slice(0, maxLines);\n next = a.join('\\n');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis postfix...\n if (next.length > maxSize) {\n next = next.substring(0, maxSize) + '...';\n }\n return next;\n },\n\n /**\n * return a string which displays the character position where the\n * lexing error occurred, i.e. for error messages\n *\n * @public\n * @this {RegExpLexer}\n */\n showPosition: function lexer_showPosition(maxPrefix, maxPostfix) {\n const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' ');\n let c = new Array(pre.length + 1).join('-');\n return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^';\n },\n\n /**\n * return an YYLLOC info object derived off the given context (actual, preceding, following, current).\n * Use this method when the given `actual` location is not guaranteed to exist (i.e. when\n * it MAY be NULL) and you MUST have a valid location info object anyway:\n * then we take the given context of the `preceding` and `following` locations, IFF those are available,\n * and reconstruct the `actual` location info from those.\n * If this fails, the heuristic is to take the `current` location, IFF available.\n * If this fails as well, we assume the sought location is at/around the current lexer position\n * and then produce that one as a response. DO NOTE that these heuristic/derived location info\n * values MAY be inaccurate!\n *\n * NOTE: `deriveLocationInfo()` ALWAYS produces a location info object *copy* of `actual`, not just\n * a *reference* hence all input location objects can be assumed to be 'constant' (function has no side-effects).\n *\n * @public\n * @this {RegExpLexer}\n */\n deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) {\n let loc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [ 0, 0 ]\n };\n if (actual) {\n loc.first_line = actual.first_line | 0;\n loc.last_line = actual.last_line | 0;\n loc.first_column = actual.first_column | 0;\n loc.last_column = actual.last_column | 0;\n\n if (actual.range) {\n loc.range[0] = actual.range[0] | 0;\n loc.range[1] = actual.range[1] | 0;\n }\n }\n if (loc.first_line <= 0 || loc.last_line < loc.first_line) {\n // plan B: heuristic using preceding and following:\n if (loc.first_line <= 0 && preceding) {\n loc.first_line = preceding.last_line | 0;\n loc.first_column = preceding.last_column | 0;\n\n if (preceding.range) {\n loc.range[0] = actual.range[1] | 0;\n }\n }\n\n if ((loc.last_line <= 0 || loc.last_line < loc.first_line) && following) {\n loc.last_line = following.first_line | 0;\n loc.last_column = following.first_column | 0;\n\n if (following.range) {\n loc.range[1] = actual.range[0] | 0;\n }\n }\n\n // plan C?: see if the 'current' location is useful/sane too:\n if (loc.first_line <= 0 && current && (loc.last_line <= 0 || current.last_line <= loc.last_line)) {\n loc.first_line = current.first_line | 0;\n loc.first_column = current.first_column | 0;\n\n if (current.range) {\n loc.range[0] = current.range[0] | 0;\n }\n }\n\n if (loc.last_line <= 0 && current && (loc.first_line <= 0 || current.first_line >= loc.first_line)) {\n loc.last_line = current.last_line | 0;\n loc.last_column = current.last_column | 0;\n\n if (current.range) {\n loc.range[1] = current.range[1] | 0;\n }\n }\n }\n // sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter\n // or plan D heuristics to produce a 'sensible' last_line value:\n if (loc.last_line <= 0) {\n if (loc.first_line <= 0) {\n loc.first_line = this.yylloc.first_line;\n loc.last_line = this.yylloc.last_line;\n loc.first_column = this.yylloc.first_column;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[0] = this.yylloc.range[0];\n loc.range[1] = this.yylloc.range[1];\n } else {\n loc.last_line = this.yylloc.last_line;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[1] = this.yylloc.range[1];\n }\n }\n if (loc.first_line <= 0) {\n loc.first_line = loc.last_line;\n loc.first_column = 0; // loc.last_column;\n\n loc.range[1] = loc.range[0];\n }\n if (loc.first_column < 0) {\n loc.first_column = 0;\n }\n if (loc.last_column < 0) {\n loc.last_column = (loc.first_column > 0 ? loc.first_column : 80);\n }\n return loc;\n },\n\n /**\n * return a string which displays the lines & columns of input which are referenced\n * by the given location info range, plus a few lines of context.\n *\n * This function pretty-prints the indicated section of the input, with line numbers\n * and everything!\n *\n * This function is very useful to provide highly readable error reports, while\n * the location range may be specified in various flexible ways:\n *\n * - `loc` is the location info object which references the area which should be\n * displayed and 'marked up': these lines & columns of text are marked up by `^`\n * characters below each character in the entire input range.\n *\n * - `context_loc` is the *optional* location info object which instructs this\n * pretty-printer how much *leading* context should be displayed alongside\n * the area referenced by `loc`. This can help provide context for the displayed\n * error, etc.\n *\n * When this location info is not provided, a default context of 3 lines is\n * used.\n *\n * - `context_loc2` is another *optional* location info object, which serves\n * a similar purpose to `context_loc`: it specifies the amount of *trailing*\n * context lines to display in the pretty-print output.\n *\n * When this location info is not provided, a default context of 1 line only is\n * used.\n *\n * Special Notes:\n *\n * - when the `loc`-indicated range is very large (about 5 lines or more), then\n * only the first and last few lines of this block are printed while a\n * `...continued...` message will be printed between them.\n *\n * This serves the purpose of not printing a huge amount of text when the `loc`\n * range happens to be huge: this way a manageable & readable output results\n * for arbitrary large ranges.\n *\n * - this function can display lines of input which whave not yet been lexed.\n * `prettyPrintRange()` can access the entire input!\n *\n * @public\n * @this {RegExpLexer}\n */\n prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) {\n loc = this.deriveLocationInfo(loc, context_loc, context_loc2);\n\n const CONTEXT = 3;\n const CONTEXT_TAIL = 1;\n const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2;\n let input = this.matched + (this._input || '');\n let lines = input.split('\\n');\n let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT));\n let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL));\n let lineno_display_width = (1 + Math.log10(l1 | 1) | 0);\n let ws_prefix = new Array(lineno_display_width).join(' ');\n let nonempty_line_indexes = [ [], [], [] ];\n let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) {\n let lno = index + l0;\n let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width);\n let rv = lno_pfx + ': ' + line;\n let errpfx = (new Array(lineno_display_width + 1)).join('^');\n let offset = 2 + 1;\n let len = 0;\n\n if (lno === loc.first_line) {\n offset += loc.first_column;\n\n len = Math.max(\n 2,\n ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1\n );\n } else if (lno === loc.last_line) {\n len = Math.max(2, loc.last_column + 1);\n } else if (lno > loc.first_line && lno < loc.last_line) {\n len = Math.max(2, line.length + 1);\n }\n\n let nli;\n if (len) {\n let lead = new Array(offset).join('.');\n let mark = new Array(len).join('^');\n rv += '\\n' + errpfx + lead + mark;\n\n nli = 1;\n } else if (lno < loc.first_line) {\n nli = 0;\n } else if (lno > loc.last_line) {\n nli = 2;\n }\n\n if (line.trim().length > 0) {\n nonempty_line_indexes[nli].push(index);\n }\n\n rv = rv.replace(/\\t/g, ' ');\n return rv;\n });\n\n // now make sure we don't print an overly large amount of lead/error/tail area: limit it\n // to the top and bottom line count:\n for (let i = 0; i <= 2; i++) {\n let line_arr = nonempty_line_indexes[i];\n if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) {\n let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1;\n let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1;\n\n let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)';\n if (i === 1) {\n intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)';\n }\n rv.splice(clip_start, clip_end - clip_start + 1, intermediate_line);\n }\n }\n\n return rv.join('\\n');\n },\n\n /**\n * helper function, used to produce a human readable description as a string, given\n * the input `yylloc` location object.\n *\n * Set `display_range_too` to TRUE to include the string character index position(s)\n * in the description if the `yylloc.range` is available.\n *\n * @public\n * @this {RegExpLexer}\n */\n describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) {\n let l1 = yylloc.first_line;\n let l2 = yylloc.last_line;\n let c1 = yylloc.first_column;\n let c2 = yylloc.last_column;\n let dl = l2 - l1;\n let dc = c2 - c1;\n let rv;\n if (dl === 0) {\n rv = 'line ' + l1 + ', ';\n if (dc <= 1) {\n rv += 'column ' + c1;\n } else {\n rv += 'columns ' + c1 + ' .. ' + c2;\n }\n } else {\n rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')';\n }\n if (yylloc.range && display_range_too) {\n let r1 = yylloc.range[0];\n let r2 = yylloc.range[1] - 1;\n if (r2 <= r1) {\n rv += ' {String Offset: ' + r1 + '}';\n } else {\n rv += ' {String Offset range: ' + r1 + ' .. ' + r2 + '}';\n }\n }\n return rv;\n },\n\n /**\n * test the lexed token: return FALSE when not a match, otherwise return token.\n *\n * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]`\n * contains the actually matched text string.\n *\n * Also move the input cursor forward and update the match collectors:\n *\n * - `yytext`\n * - `yyleng`\n * - `match`\n * - `matches`\n * - `yylloc`\n * - `offset`\n *\n * @public\n * @this {RegExpLexer}\n */\n test_match: function lexer_test_match(match, indexed_rule) {\n let backup;\n\n if (this.options.backtrack_lexer) {\n // save context\n backup = {\n yylineno: this.yylineno,\n yylloc: {\n first_line: this.yylloc.first_line,\n last_line: this.yylloc.last_line,\n first_column: this.yylloc.first_column,\n last_column: this.yylloc.last_column,\n\n range: this.yylloc.range.slice()\n },\n yytext: this.yytext,\n match: this.match,\n matches: this.matches,\n matched: this.matched,\n yyleng: this.yyleng,\n offset: this.offset,\n _more: this._more,\n _input: this._input,\n //_signaled_error_token: this._signaled_error_token,\n yy: this.yy,\n conditionStack: this.conditionStack.slice(),\n done: this.done\n };\n }\n\n let match_str = match[0];\n let match_str_len = match_str.length;\n\n let lines = match_str.split(this.CRLF_Re);\n if (lines.length > 1) {\n this.yylineno += lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n this.yylloc.last_column = lines[lines.length - 1].length;\n } else {\n this.yylloc.last_column += match_str_len;\n }\n\n this.yytext += match_str;\n this.match += match_str;\n this.matched += match_str;\n this.matches = match;\n this.yyleng = this.yytext.length;\n this.yylloc.range[1] += match_str_len;\n\n // previous lex rules MAY have invoked the `more()` API rather than producing a token:\n // those rules will already have moved this `offset` forward matching their match lengths,\n // hence we must only add our own match length now:\n this.offset += match_str_len;\n this._more = false;\n this._backtrack = false;\n this._input = this._input.slice(match_str_len);\n\n // calling this method:\n //\n // function lexer__performAction(yy, yyrulenumber, YY_START) {...}\n let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */);\n // otherwise, when the action codes are all simple return token statements:\n //token = this.simpleCaseActionClusters[indexed_rule];\n\n if (this.done && this._input) {\n this.done = false;\n }\n if (token) {\n return token;\n } else if (this._backtrack) {\n // recover context\n for (let k in backup) {\n this[k] = backup[k];\n }\n this.__currentRuleSet__ = null;\n return false; // rule action called reject() implying the next rule should be tested instead.\n } else if (this._signaled_error_token) {\n // produce one 'error' token as `.parseError()` in `reject()`\n // did not guarantee a failure signal by throwing an exception!\n token = this._signaled_error_token;\n this._signaled_error_token = false;\n return token;\n }\n return false;\n },\n\n /**\n * return next match in input\n *\n * @public\n * @this {RegExpLexer}\n */\n next: function lexer_next() {\n if (this.done) {\n this.clear();\n return this.EOF;\n }\n if (!this._input) {\n this.done = true;\n }\n\n if (!this._more) {\n if (!this._clear_state) {\n this._clear_state = 1;\n }\n this.clear();\n }\n let spec = this.__currentRuleSet__;\n if (!spec) {\n // Update the ruleset cache as we apparently encountered a state change or just started lexing.\n // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will\n // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps\n // speed up those activities a tiny bit.\n spec = this.__currentRuleSet__ = this._currentRules();\n // Check whether a *sane* condition has been pushed before: this makes the lexer robust against\n // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19\n if (!spec || !spec.rules) {\n let lineno_msg = '';\n if (this.yylloc) {\n lineno_msg = ' on line ' + (this.yylineno + 1);\n }\n const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name \"' + this.topState() + '\"; this is a fatal error and should be reported to the application programmer team!', false);\n // produce one 'error' token until this situation has been resolved, most probably by parse termination!\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n }\n\n {\n let rule_ids = spec.rules;\n let regexes = spec.__rule_regexes;\n let len = spec.__rule_count;\n let match;\n let index;\n\n // Note: the arrays are 1-based, while `len` itself is a valid index,\n // hence the non-standard less-or-equal check in the next loop condition!\n for (let i = 1; i <= len; i++) {\n let tempMatch = this._input.match(regexes[i]);\n if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n match = tempMatch;\n index = i;\n if (this.options.backtrack_lexer) {\n let token = this.test_match(tempMatch, rule_ids[i]);\n if (token !== false) {\n return token;\n } else if (this._backtrack) {\n match = undefined;\n continue; // rule action called reject() implying a rule MISmatch.\n } else {\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n } else if (!this.options.flex) {\n break;\n }\n }\n }\n\n if (match) {\n let token = this.test_match(match, rule_ids[index]);\n if (token !== false) {\n return token;\n }\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n }\n\n if (!this._input) {\n this.done = true;\n this.clear();\n return this.EOF;\n }\n\n {\n let lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable);\n\n let pendingInput = this._input;\n let activeCondition = this.topState();\n let conditionStackDepth = this.conditionStack.length;\n\n let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n if (token === this.ERROR) {\n // we can try to recover from a lexer error that `parseError()` did not 'recover' for us\n // by moving forward at least one character at a time IFF the (user-specified?) `parseError()`\n // has not consumed/modified any pending input or changed state in the error handler:\n if (!this.matches &&\n // and make sure the input has been modified/consumed ...\n pendingInput === this._input &&\n // ...or the lexer state has been modified significantly enough\n // to merit a non-consuming error handling action right now.\n activeCondition === this.topState() &&\n conditionStackDepth === this.conditionStack.length\n ) {\n this.input();\n }\n }\n return token;\n }\n },\n\n /**\n * return next match that has a token\n *\n * @public\n * @this {RegExpLexer}\n */\n lex: function lexer_lex() {\n let r;\n\n //this._clear_state = 0;\n\n if (!this._more) {\n if (!this._clear_state) {\n this._clear_state = 1;\n }\n this.clear();\n }\n\n // allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer:\n if (typeof this.pre_lex === 'function') {\n r = this.pre_lex.call(this, 0);\n }\n if (typeof this.options.pre_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.pre_lex.call(this, r) || r;\n }\n if (this.yy && typeof this.yy.pre_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.pre_lex.call(this, r) || r;\n }\n\n while (!r) {\n r = this.next();\n }\n\n if (this.yy && typeof this.yy.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.post_lex.call(this, r) || r;\n }\n if (typeof this.options.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.post_lex.call(this, r) || r;\n }\n if (typeof this.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.post_lex.call(this, r) || r;\n }\n\n if (!this._more) {\n //\n // 1) make sure any outside interference is detected ASAP:\n // these attributes are to be treated as 'const' values\n // once the lexer has produced them with the token (return value `r`).\n // 2) make sure any subsequent `lex()` API invocation CANNOT\n // edit the `yytext`, etc. token attributes for the *current*\n // token, i.e. provide a degree of 'closure safety' so that\n // code like this:\n //\n // t1 = lexer.lex();\n // v = lexer.yytext;\n // l = lexer.yylloc;\n // t2 = lexer.lex();\n // assert(lexer.yytext !== v);\n // assert(lexer.yylloc !== l);\n //\n // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee*\n // these conditions.\n //\n this.yytext = Object.freeze(this.yytext);\n this.matches = Object.freeze(this.matches);\n this.yylloc.range = Object.freeze(this.yylloc.range);\n this.yylloc = Object.freeze(this.yylloc);\n\n this._clear_state = 0;\n }\n\n return r;\n },\n\n /**\n * return next match that has a token. Identical to the `lex()` API but does not invoke any of the\n * `pre_lex()` nor any of the `post_lex()` callbacks.\n *\n * @public\n * @this {RegExpLexer}\n */\n fastLex: function lexer_fastLex() {\n let r;\n\n //this._clear_state = 0;\n\n while (!r) {\n r = this.next();\n }\n\n if (!this._more) {\n //\n // 1) make sure any outside interference is detected ASAP:\n // these attributes are to be treated as 'const' values\n // once the lexer has produced them with the token (return value `r`).\n // 2) make sure any subsequent `lex()` API invocation CANNOT\n // edit the `yytext`, etc. token attributes for the *current*\n // token, i.e. provide a degree of 'closure safety' so that\n // code like this:\n //\n // t1 = lexer.lex();\n // v = lexer.yytext;\n // l = lexer.yylloc;\n // t2 = lexer.lex();\n // assert(lexer.yytext !== v);\n // assert(lexer.yylloc !== l);\n //\n // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee*\n // these conditions.\n //\n this.yytext = Object.freeze(this.yytext);\n this.matches = Object.freeze(this.matches);\n this.yylloc.range = Object.freeze(this.yylloc.range);\n this.yylloc = Object.freeze(this.yylloc);\n\n this._clear_state = 0;\n }\n\n return r;\n },\n\n /**\n * return info about the lexer state that can help a parser or other lexer API user to use the\n * most efficient means available. This API is provided to aid run-time performance for larger\n * systems which employ this lexer.\n *\n * @public\n * @this {RegExpLexer}\n */\n canIUse: function lexer_canIUse() {\n const rv = {\n fastLex: !(\n typeof this.pre_lex === 'function' ||\n typeof this.options.pre_lex === 'function' ||\n (this.yy && typeof this.yy.pre_lex === 'function') ||\n (this.yy && typeof this.yy.post_lex === 'function') ||\n typeof this.options.post_lex === 'function' ||\n typeof this.post_lex === 'function'\n ) && typeof this.fastLex === 'function'\n };\n return rv;\n },\n\n\n /**\n * backwards compatible alias for `pushState()`;\n * the latter is symmetrical with `popState()` and we advise to use\n * those APIs in any modern lexer code, rather than `begin()`.\n *\n * @public\n * @this {RegExpLexer}\n */\n begin: function lexer_begin(condition) {\n return this.pushState(condition);\n },\n\n /**\n * activates a new lexer condition state (pushes the new lexer\n * condition state onto the condition stack)\n *\n * @public\n * @this {RegExpLexer}\n */\n pushState: function lexer_pushState(condition) {\n this.conditionStack.push(condition);\n this.__currentRuleSet__ = null;\n return this;\n },\n\n /**\n * pop the previously active lexer condition state off the condition\n * stack\n *\n * @public\n * @this {RegExpLexer}\n */\n popState: function lexer_popState() {\n const n = this.conditionStack.length - 1;\n if (n > 0) {\n this.__currentRuleSet__ = null;\n return this.conditionStack.pop();\n }\n return this.conditionStack[0];\n },\n\n /**\n * return the currently active lexer condition state; when an index\n * argument is provided it produces the N-th previous condition state,\n * if available\n *\n * @public\n * @this {RegExpLexer}\n */\n topState: function lexer_topState(n) {\n n = this.conditionStack.length - 1 - Math.abs(n || 0);\n if (n >= 0) {\n return this.conditionStack[n];\n }\n return 'INITIAL';\n },\n\n /**\n * (internal) determine the lexer rule set which is active for the\n * currently active lexer condition state\n *\n * @public\n * @this {RegExpLexer}\n */\n _currentRules: function lexer__currentRules() {\n const n = this.conditionStack.length - 1;\n let state;\n if (n >= 0) {\n state = this.conditionStack[n];\n } else {\n state = 'INITIAL';\n }\n return this.conditions[state] || this.conditions.INITIAL;\n },\n\n /**\n * return the number of states currently on the stack\n *\n * @public\n * @this {RegExpLexer}\n */\n stateStackSize: function lexer_stateStackSize() {\n return this.conditionStack.length;\n }\n}"; // --- END lexer kernel --- } chkBugger$2(getRegExpLexerPrototype()); -RegExpLexer.prototype = new Function(rmCommonWS$2(_templateObject80(), getRegExpLexerPrototype()))(); // The lexer code stripper, driven by optimization analysis settings and +RegExpLexer.prototype = new Function(rmCommonWS$2(_templateObject81(), getRegExpLexerPrototype()))(); // The lexer code stripper, driven by optimization analysis settings and // lexer options, which cannot be changed at run-time. function stripUnusedLexerCode(src, opt) { @@ -12491,15 +12703,15 @@ 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 _c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); var offendingChunk = ' ' + b.join('\n '); - console.error(rmCommonWS$2(_templateObject81(), ex, offendingChunk)); + console.error(rmCommonWS$2(_templateObject82(), ex, offendingChunk)); new_src = src; } // inject analysis report now: - new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2(_templateObject82(), opt.options.backtrack_lexer, opt.options.ranges, opt.options.trackPosition, opt.parseActionsUseYYLENG, opt.parseActionsUseYYLINENO, opt.parseActionsUseYYTEXT, opt.parseActionsUseYYLOC, opt.parseActionsUseValueTracking, opt.parseActionsUseValueAssignment, opt.parseActionsUseLocationTracking, opt.parseActionsUseLocationAssignment, opt.lexerActionsUseYYLENG, opt.lexerActionsUseYYLINENO, opt.lexerActionsUseYYTEXT, opt.lexerActionsUseYYLOC, opt.lexerActionsUseParseError, opt.lexerActionsUseYYERROR, opt.lexerActionsUseLocationTracking, opt.lexerActionsUseMore, opt.lexerActionsUseUnput, opt.lexerActionsUseReject, opt.lexerActionsUseLess, opt.lexerActionsUseDisplayAPIs, opt.lexerActionsUseDescribeYYLOC)); + new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2(_templateObject83(), opt.options.backtrack_lexer, opt.options.ranges, opt.options.trackPosition, opt.parseActionsUseYYLENG, opt.parseActionsUseYYLINENO, opt.parseActionsUseYYTEXT, opt.parseActionsUseYYLOC, opt.parseActionsUseValueTracking, opt.parseActionsUseValueAssignment, opt.parseActionsUseLocationTracking, opt.parseActionsUseLocationAssignment, opt.lexerActionsUseYYLENG, opt.lexerActionsUseYYLINENO, opt.lexerActionsUseYYTEXT, opt.lexerActionsUseYYLOC, opt.lexerActionsUseParseError, opt.lexerActionsUseYYERROR, opt.lexerActionsUseLocationTracking, opt.lexerActionsUseMore, opt.lexerActionsUseUnput, opt.lexerActionsUseReject, opt.lexerActionsUseLess, opt.lexerActionsUseDisplayAPIs, opt.lexerActionsUseDescribeYYLOC)); return new_src; } // generate lexer source from a grammar @@ -12636,9 +12848,9 @@ function generateRegexesInitTableCode(opt) { var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); return "/* ".concat(idx_str, ": */ new XRegExp(\"").concat(re_src, "\", \"").concat(re.xregexp.flags, "\")"); - } else { - return "/* ".concat(idx_str, ": */ ").concat(re); } + + return "/* ".concat(idx_str, ": */ ").concat(re); }); return b.join(',\n'); } @@ -12646,8 +12858,8 @@ function generateRegexesInitTableCode(opt) { function generateModuleBody(opt) { // make the JSON output look more like JavaScript: function cleanupJSON(str) { - str = str.replace(/ "rules": \[/g, ' rules: ['); - str = str.replace(/ "inclusive": /g, ' inclusive: '); + str = str.replace(/ {2}"rules": \[/g, ' rules: ['); + str = str.replace(/ {2}"inclusive": /g, ' inclusive: '); return str; } @@ -12758,7 +12970,7 @@ function generateModuleBody(opt) { if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) { // we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. - var code = [rmCommonWS$2(_templateObject83()), '/*JISON-LEX-ANALYTICS-REPORT*/' + var code = [rmCommonWS$2(_templateObject84()), '/* JISON-LEX-ANALYTICS-REPORT */\n' /* slot #1: placeholder for analysis report further below */ ]; // get the RegExpLexer.prototype in source code form: @@ -12787,7 +12999,7 @@ function generateModuleBody(opt) { var simpleCaseActionClustersCode = String(opt.caseHelperInclude); var rulesCode = generateRegexesInitTableCode(opt); var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); - code.push(rmCommonWS$2(_templateObject84(), performActionCode, simpleCaseActionClustersCode, rulesCode, conditionsCode)); + code.push(rmCommonWS$2(_templateObject85(), performActionCode, simpleCaseActionClustersCode, rulesCode, conditionsCode)); opt.is_custom_lexer = false; out = code.join(''); } else { @@ -12795,9 +13007,9 @@ function generateModuleBody(opt) { // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // - // Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter + // Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. - out = 'var lexer;\n'; + out = '\n'; assert__default['default'](opt.regular_rule_count === 0); assert__default['default'](opt.simple_rule_count === 0); opt.is_custom_lexer = true; @@ -12808,8 +13020,6 @@ function generateModuleBody(opt) { } // The output of this function is guaranteed to read something like this: // // ``` - // var lexer; - // // bla bla bla bla ... lotsa bla bla; // ``` // @@ -12820,7 +13030,7 @@ function generateModuleBody(opt) { } function generateGenericHeaderComment() { - var out = rmCommonWS$2(_templateObject85(), version); + var out = rmCommonWS$2(_templateObject86(), version); return out; } @@ -12849,7 +13059,7 @@ function prepareOptions(opt) { function generateModule(opt) { opt = prepareOptions(opt); var modIncSrc = opt.moduleInclude ? opt.moduleInclude + ';' : ''; - var src = rmCommonWS$2(_templateObject86(), generateGenericHeaderComment(), opt.moduleName, jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); + var src = rmCommonWS$2(_templateObject87(), generateGenericHeaderComment(), opt.moduleName, jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); src = stripUnusedLexerCode(src, opt); opt.exportSourceCode.all = src; return src; @@ -12858,7 +13068,7 @@ function generateModule(opt) { function generateAMDModule(opt) { opt = prepareOptions(opt); var modIncSrc = opt.moduleInclude ? opt.moduleInclude + ';' : ''; - var src = rmCommonWS$2(_templateObject87(), generateGenericHeaderComment(), jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); + var src = rmCommonWS$2(_templateObject88(), generateGenericHeaderComment(), jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); src = stripUnusedLexerCode(src, opt); opt.exportSourceCode.all = src; return src; @@ -12867,7 +13077,7 @@ function generateAMDModule(opt) { function generateESModule(opt) { opt = prepareOptions(opt); var modIncSrc = opt.moduleInclude ? opt.moduleInclude + ';' : ''; - var src = rmCommonWS$2(_templateObject88(), generateGenericHeaderComment(), jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); + var src = rmCommonWS$2(_templateObject89(), generateGenericHeaderComment(), jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); src = stripUnusedLexerCode(src, opt); opt.exportSourceCode.all = src; return src; @@ -12876,7 +13086,7 @@ function generateESModule(opt) { function generateCommonJSModule(opt) { opt = prepareOptions(opt); var modIncSrc = opt.moduleInclude ? opt.moduleInclude + ';' : ''; - var src = rmCommonWS$2(_templateObject89(), generateGenericHeaderComment(), opt.moduleName, jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc, opt.moduleName, opt.moduleName); + var src = rmCommonWS$2(_templateObject90(), generateGenericHeaderComment(), opt.moduleName, jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc, opt.moduleName, opt.moduleName); src = stripUnusedLexerCode(src, opt); opt.exportSourceCode.all = src; return src; @@ -13248,15 +13458,15 @@ var parser$1 = { switch (yystate) { case 0: /*! Production:: $accept : production $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-): - this.$ = yyvstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-) + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-): + this.$ = yyvstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-) break; case 1: /*! Production:: production : handle EOF */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-): - this.$ = yyvstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-) + // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-): + this.$ = yyvstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-) return yyvstack[yysp - 1]; @@ -13404,20 +13614,14 @@ var parser$1 = { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + var ASSERT = typeof assert !== 'function' ? function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : assert; this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -13446,13 +13650,14 @@ var parser$1 = { shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + var _dst2 = {}; + shallow_copy_noclobber(_dst2, src); + return _dst2; + } } return src; @@ -13469,10 +13674,8 @@ var parser$1 = { if (chk.call(src, k)) { dst[k] = src[k]; } - } else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } // copy state @@ -13618,6 +13821,12 @@ var parser$1 = { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -13759,7 +13968,7 @@ var parser$1 = { action = t[0]; // handle parse error if (!action) { - var errStr; + var errStr = void 0; var errSymbolDescr = this.describeSymbol(symbol) || symbol; var expected = this.collect_expected_token_set(state); // Report error @@ -13893,14 +14102,16 @@ var parser$1 = { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -14408,6 +14619,10 @@ var lexer$1 = function () { * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -14789,9 +15004,9 @@ var lexer$1 = function () { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -14801,8 +15016,8 @@ var lexer$1 = function () { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -14878,12 +15093,22 @@ var lexer$1 = function () { */ pastInput: function lexer_pastInput(maxSize, maxLines) { var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) maxSize = Infinity;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substr` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = Infinity; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: @@ -14900,8 +15125,8 @@ var lexer$1 = function () { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -14927,20 +15152,30 @@ var lexer$1 = function () { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { var next = this.match; var source = this._input || ''; - if (maxSize < 0) maxSize = next.length + source.length;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substring` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = next.length + source.length; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + if (next.length < maxSize * 2 + 2) { next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8 } // now that we have a significantly reduced string to process, transform the newlines @@ -15265,7 +15500,7 @@ var lexer$1 = function () { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + var backup; if (this.options.backtrack_lexer) { // save context @@ -15293,9 +15528,9 @@ var lexer$1 = function () { }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + var match_str = match[0]; + var match_str_len = match_str.length; + var lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -15321,7 +15556,7 @@ var lexer$1 = function () { // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] + var token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */ ); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -15367,8 +15602,6 @@ var lexer$1 = function () { this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -15400,65 +15633,73 @@ var lexer$1 = function () { } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; // 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! + { + var rule_ids = spec.rules; + var regexes = spec.__rule_regexes; + var len = spec.__rule_count; + var match; + var index; // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + for (var i = 1; i <= len; i++) { + var tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + var token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + var _token3 = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + if (_token3 !== false) { + return _token3; + } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + var _lineno_msg2 = 'Lexical error'; if (this.yylloc) { - lineno_msg += ' on line ' + (this.yylineno + 1); + _lineno_msg2 += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var _p2 = this.constructLexErrorInfo(_lineno_msg2 + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var pendingInput = this._input; var activeCondition = this.topState(); var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; - if (token === this.ERROR) { + var _token4 = this.parseError(_p2.errStr, _p2, this.JisonLexerError) || this.ERROR; + + if (_token4 === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: @@ -15470,7 +15711,7 @@ var lexer$1 = function () { } } - return token; + return _token4; } }, @@ -15527,24 +15768,24 @@ var lexer$1 = function () { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15571,24 +15812,24 @@ var lexer$1 = function () { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15652,9 +15893,9 @@ var lexer$1 = function () { if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -15670,9 +15911,9 @@ var lexer$1 = function () { if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -15692,7 +15933,7 @@ var lexer$1 = function () { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -15895,10 +16136,10 @@ function generatePushAction(handle, offset) { } function transformExpression(e, opts, emit) { - var type = e[0], - value = e[1], - name = false, - has_transformed = 0; + var type = e[0]; + var value = e[1]; + var name = false; + var has_transformed = 0; var list, n; if (type === 'xalias') { @@ -16019,8 +16260,8 @@ function optsForProduction(id, grammar) { function transformProduction(id, production, grammar) { var transform_opts = optsForProduction(id, grammar); return production.map(function (handle) { - var action = null, - opts = null; + var action = null; + var opts = null; var i, len, n; if (typeof handle !== 'string') { @@ -16114,7 +16355,7 @@ function transformProduction(id, production, grammar) { } // now scan the action for all named and numeric semantic values ($nonterminal / $1 / @1, ##1, ...) // // Note that `#name` are straight **static** symbol translations, which are okay as they don't - // require access to the parse stack: `#n` references can be resolved completely + // require access to the parse stack: `#n` references can be resolved completely // at grammar compile time. // @@ -16161,9 +16402,9 @@ function transformProduction(id, production, grammar) { if (ret.length === 1) { return ret[0]; - } else { - return ret; } + + return ret; }); } @@ -16707,16 +16948,16 @@ var parser$3 = { switch (yystate) { case 0: /*! Production:: $accept : spec $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; - this._$ = yylstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break; case 1: /*! Production:: spec : declaration_list "%%" grammar optional_end_block EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4]; @@ -16730,20 +16971,20 @@ var parser$3 = { case 2: /*! Production:: spec : declaration_list "%%" grammar error EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject90(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject91(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 3: /*! Production:: spec : declaration_list error EOF */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject91(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject92(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); break; case 4: @@ -16760,21 +17001,21 @@ var parser$3 = { case 133: /*! Production:: optional_module_code_chunk : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject92(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject93(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); } this.$ = yyvstack[yysp]; @@ -16785,8 +17026,8 @@ var parser$3 = { case 10: /*! Production:: declaration_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -16796,14 +17037,14 @@ var parser$3 = { case 8: /*! Production:: optional_action_header_block : optional_action_header_block include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject93(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject94(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); } yy.addDeclaration(this.$, { @@ -16813,8 +17054,8 @@ var parser$3 = { case 9: /*! Production:: declaration_list : declaration_list declaration */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -16822,18 +17063,18 @@ var parser$3 = { case 11: /*! Production:: declaration_list : declaration_list error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject94(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject95(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 12: /*! Production:: declaration : START id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { start: yyvstack[yysp] @@ -16842,8 +17083,8 @@ var parser$3 = { case 13: /*! Production:: declaration : LEX_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { lex: { @@ -16855,8 +17096,8 @@ var parser$3 = { case 14: /*! Production:: declaration : operator */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { operator: yyvstack[yysp] @@ -16865,8 +17106,8 @@ var parser$3 = { case 15: /*! Production:: declaration : TOKEN full_token_definitions */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { token_list: yyvstack[yysp] @@ -16875,13 +17116,13 @@ var parser$3 = { case 16: /*! Production:: declaration : ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject95(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject96(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); } this.$ = { @@ -16891,13 +17132,13 @@ var parser$3 = { case 17: /*! Production:: declaration : include_macro_code */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject96(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject97(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); } this.$ = { @@ -16907,8 +17148,8 @@ var parser$3 = { case 18: /*! Production:: declaration : parse_params */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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] @@ -16917,8 +17158,8 @@ var parser$3 = { case 19: /*! Production:: declaration : parser_type */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { parserType: yyvstack[yysp] @@ -16927,8 +17168,8 @@ var parser$3 = { case 20: /*! Production:: declaration : options */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { options: yyvstack[yysp] @@ -16937,8 +17178,8 @@ var parser$3 = { case 21: /*! Production:: declaration : DEBUG */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { options: [['debug', true]] @@ -16947,8 +17188,8 @@ var parser$3 = { case 22: /*! Production:: declaration : EBNF */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) ebnf = true; this.$ = { @@ -16958,8 +17199,8 @@ var parser$3 = { case 23: /*! Production:: declaration : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { unknownDecl: yyvstack[yysp] @@ -16968,8 +17209,8 @@ var parser$3 = { case 24: /*! Production:: declaration : IMPORT import_name import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { imports: { @@ -16981,31 +17222,31 @@ var parser$3 = { case 25: /*! Production:: declaration : IMPORT import_name error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject97(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject98(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 26: /*! Production:: declaration : IMPORT error import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject98(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject99(), 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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(_templateObject99(), $init_code_name, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject100(), $init_code_name, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); } this.$ = { @@ -17018,41 +17259,41 @@ var parser$3 = { case 28: /*! Production:: declaration : INIT_CODE error action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject100(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject101(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]))); break; case 29: /*! Production:: declaration : START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject101(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject102(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 30: /*! Production:: declaration : TOKEN error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject102(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject103(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 31: /*! Production:: declaration : IMPORT error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject103(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject104(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 32: @@ -17132,8 +17373,8 @@ var parser$3 = { case 132: /*! Production:: optional_module_code_chunk : module_code_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -17143,30 +17384,30 @@ var parser$3 = { case 111: /*! Production:: action_ne : "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1]; break; case 40: /*! Production:: options : OPTIONS error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject104(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject105(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]))); break; case 41: /*! Production:: options : OPTIONS error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject105(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject106(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 42: @@ -17177,8 +17418,8 @@ var parser$3 = { case 70: /*! Production:: id_list : id_list id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push(yyvstack[yysp]); @@ -17195,24 +17436,24 @@ var parser$3 = { case 84: /*! Production:: handle_list : handle_action */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 44: /*! Production:: option : NAME */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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], true]; break; case 45: /*! Production:: option : NAME "=" OPTION_STRING_VALUE */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]]; break; @@ -17222,30 +17463,30 @@ var parser$3 = { case 47: /*! Production:: option : NAME "=" NAME */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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], parseValue$1(yyvstack[yysp])]; break; case 48: /*! Production:: option : NAME "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject106(), yyvstack[yysp - 2], yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject107(), yyvstack[yysp - 2], yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 49: /*! Production:: option : NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject107(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject108(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 50: @@ -17253,36 +17494,36 @@ var parser$3 = { case 52: /*! Production:: parser_type : PARSER_TYPE symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; break; case 51: /*! Production:: parse_params : PARSE_PARAM error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject108(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject109(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 53: /*! Production:: parser_type : PARSER_TYPE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject109(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject110(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 54: /*! Production:: operator : associativity token_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push.apply(this.$, yyvstack[yysp]); @@ -17290,42 +17531,42 @@ var parser$3 = { case 55: /*! Production:: operator : associativity error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject110(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject111(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 56: /*! Production:: associativity : LEFT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = 'left'; break; case 57: /*! Production:: associativity : RIGHT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = 'right'; break; case 58: /*! Production:: associativity : NONASSOC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = 'nonassoc'; break; case 61: /*! Production:: full_token_definitions : optional_token_type id_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -17348,8 +17589,8 @@ var parser$3 = { case 62: /*! Production:: full_token_definitions : optional_token_type one_full_token */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -17362,8 +17603,8 @@ var parser$3 = { case 63: /*! Production:: one_full_token : id token_value token_description */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { id: yyvstack[yysp - 2], @@ -17374,8 +17615,8 @@ var parser$3 = { case 64: /*! Production:: one_full_token : id token_description */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { id: yyvstack[yysp - 1], @@ -17385,8 +17626,8 @@ var parser$3 = { case 65: /*! Production:: one_full_token : id token_value */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { id: yyvstack[yysp - 1], @@ -17396,16 +17637,16 @@ var parser$3 = { case 66: /*! Production:: optional_token_type : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = false; break; case 72: /*! Production:: grammar : optional_action_header_block production_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.grammar = yyvstack[yysp]; @@ -17413,8 +17654,8 @@ var parser$3 = { case 73: /*! Production:: production_list : production_list production */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -17428,8 +17669,8 @@ var parser$3 = { case 74: /*! Production:: production_list : production */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = {}; this.$[yyvstack[yysp][0]] = yyvstack[yysp][1]; @@ -17437,36 +17678,36 @@ var parser$3 = { case 75: /*! Production:: production : production_id handle_list ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1]]; break; case 76: /*! Production:: production : production_id error ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject111(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject112(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 77: /*! Production:: production : production_id error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject112(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject113(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 78: /*! Production:: production_id : id optional_production_description ":" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; // TODO: carry rule description support into the parser generator... @@ -17474,36 +17715,36 @@ var parser$3 = { case 79: /*! Production:: production_id : id optional_production_description error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject113(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject114(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 80: /*! Production:: production_id : id optional_production_description ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject114(), $id, yyvstack[yysp - 2], yyvstack[yysp], yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject115(), $id, yyvstack[yysp - 2], yyvstack[yysp], yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 82: /*! Production:: optional_production_description : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) break; case 83: /*! Production:: handle_list : handle_list "|" handle_action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; this.$.push(yyvstack[yysp]); @@ -17511,28 +17752,28 @@ var parser$3 = { case 85: /*! Production:: handle_list : handle_list "|" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject115(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject116(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 86: /*! Production:: handle_list : handle_list ":" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject116(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject117(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 87: /*! Production:: handle_action : handle prec action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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(' ') : '']; @@ -17540,7 +17781,7 @@ var parser$3 = { var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject117(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject118(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); } this.$.push(yyvstack[yysp]); @@ -17548,7 +17789,7 @@ var parser$3 = { if (yyvstack[yysp - 1]) { if (yyvstack[yysp - 2].length === 0) { - yyparser.yyError(rmCommonWS$3(_templateObject118(), yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp] + 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! */ ))); } @@ -17564,8 +17805,8 @@ var parser$3 = { case 88: /*! Production:: handle_action : EPSILON action */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = ['']; @@ -17573,7 +17814,7 @@ var parser$3 = { var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject119(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject120(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); } this.$.push(yyvstack[yysp]); @@ -17587,18 +17828,18 @@ var parser$3 = { case 89: /*! Production:: handle_action : EPSILON error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject120(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject121(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 90: /*! Production:: handle : handle suffixed_expression */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push(yyvstack[yysp]); @@ -17606,16 +17847,16 @@ var parser$3 = { case 91: /*! Production:: handle : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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 92: /*! Production:: handle_sublist : handle_sublist "|" handle */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; this.$.push(yyvstack[yysp].join(' ')); @@ -17623,16 +17864,16 @@ var parser$3 = { case 93: /*! Production:: handle_sublist : handle */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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].join(' ')]; break; case 94: /*! Production:: suffixed_expression : expression suffix ALIAS */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + "[" + yyvstack[yysp] + "]"; break; @@ -17645,24 +17886,24 @@ var parser$3 = { case 130: /*! Production:: module_code_chunk : module_code_chunk CODE */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + yyvstack[yysp]; break; case 97: /*! Production:: expression : EOF_ID */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '$end'; break; case 98: /*! Production:: expression : STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // Re-encode the string *anyway* as it will // be made part of the rule rhs a.k.a. production (type: *string*) again and we want // to be able to handle all tokens, including *significant space* @@ -17673,25 +17914,25 @@ var parser$3 = { case 99: /*! Production:: expression : "(" handle_sublist ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1].join(' | ') + ')'; break; case 100: /*! Production:: expression : "(" handle_sublist error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject121(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject122(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 105: /*! Production:: prec : PREC symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { prec: yyvstack[yysp] @@ -17700,76 +17941,76 @@ var parser$3 = { case 106: /*! Production:: prec : PREC error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject122(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject123(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 107: /*! Production:: prec : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = null; break; case 112: /*! Production:: action_ne : "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject123(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject124(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 116: /*! Production:: action : ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 120: /*! Production:: action_body : action_body "{" action_body "}" action_comments_body */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4] + yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; break; case 121: /*! Production:: action_body : action_body "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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 - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; break; case 122: /*! Production:: action_body : action_body "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject124(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject125(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 126: /*! Production:: extra_parser_module_code : optional_module_code_chunk include_macro_code extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + yyvstack[yysp]; break; case 127: /*! Production:: include_macro_code : INCLUDE PATH */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -17777,7 +18018,7 @@ var parser$3 = { var rv = checkActionBlock$2(fileContent); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject125(), $PATH, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject126(), $PATH, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); } // And no, we don't support nested '%include': @@ -17786,21 +18027,21 @@ var parser$3 = { case 128: /*! Production:: include_macro_code : INCLUDE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject126()) + yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])); + yyparser.yyError(rmCommonWS$3(_templateObject127()) + yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])); break; case 131: /*! Production:: module_code_chunk : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject127()) + yylexer.prettyPrintRange(yylstack[yysp])); + yyparser.yyError(rmCommonWS$3(_templateObject128()) + yylexer.prettyPrintRange(yylstack[yysp])); break; } }, @@ -17877,20 +18118,14 @@ var parser$3 = { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + var ASSERT = typeof assert !== 'function' ? function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : assert; this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -17923,13 +18158,14 @@ var parser$3 = { shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + var _dst3 = {}; + shallow_copy_noclobber(_dst3, src); + return _dst3; + } } return src; @@ -17946,10 +18182,8 @@ var parser$3 = { if (chk.call(src, k)) { dst[k] = src[k]; } - } else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -18118,11 +18352,11 @@ var parser$3 = { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (var _i6 = this.__error_recovery_infos.length - 1; _i6 >= 0; _i6--) { + var _el2 = this.__error_recovery_infos[_i6]; - if (el && typeof el.destroy === 'function') { - el.destroy(); + if (_el2 && typeof _el2.destroy === 'function') { + _el2.destroy(); } } @@ -18150,10 +18384,10 @@ var parser$3 = { this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; + var i1 = first_index | 0; + var i2 = last_index | 0; + var l1 = first_yylloc; + var l2 = last_yylloc; var rv; // rules: // - first/last yylloc entries override first/last indexes @@ -18171,8 +18405,8 @@ var parser$3 = { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { - l2 = lstack[i]; + for (var _i7 = i2; _i7 >= i1; _i7--) { + l2 = lstack[_i7]; if (l2) { break; @@ -18185,8 +18419,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 i = (i1 || sp) - 1; i >= 0; i--) { - l1 = lstack[i]; + for (var _i8 = (i1 || sp) - 1; _i8 >= 0; _i8--) { + l1 = lstack[_i8]; if (l1) { break; @@ -18199,30 +18433,30 @@ var parser$3 = { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; - } + return null; + } // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + + rv = this.copy_yylloc(l2); return rv; + } // shallow-copy L1, then adjust first col/row 1 column past the end. + + + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; } + + return rv; } if (!l1) { @@ -18231,7 +18465,7 @@ var parser$3 = { } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... @@ -18281,6 +18515,12 @@ var parser$3 = { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -18363,11 +18603,15 @@ var parser$3 = { // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty - } + { + var i; + + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty + } - rv.base_pointer = i; - rv.info_stack_pointer = i; + rv.base_pointer = i; + rv.info_stack_pointer = i; + } rv.root_failure_pointer = rv.stack_pointer; // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_recovery_infos.push(rv); @@ -18453,9 +18697,9 @@ var parser$3 = { while (stack_probe >= 0) { // check for error recovery rule in this state - var t = table[state] && table[state][TERROR] || NO_ACTION; + var _t2 = table[state] && table[state][TERROR] || NO_ACTION; - if (t[0]) { + if (_t2[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must // prevent the core from running forever, @@ -18618,7 +18862,7 @@ var parser$3 = { if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: @@ -18674,7 +18918,7 @@ var parser$3 = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errSymbolDescr: errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -18693,7 +18937,8 @@ var parser$3 = { yyval.$ = recoveringErrorInfo; yyval._$ = undefined; yyrulelen = error_rule_depth; - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + var combineState = NO_ACTION[1]; + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -18750,9 +18995,9 @@ var parser$3 = { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); var errorSymbolFromParser = true; for (;;) { @@ -18785,7 +19030,7 @@ var parser$3 = { // and take it from there! if (!action) { - ASSERT(recoveringErrorInfo, "line 1087"); // Prep state variables so that upon breaking out of + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` // statement in the outer "fast parse loop" we redo // the exact same state table lookup as the one above @@ -18820,12 +19065,12 @@ var parser$3 = { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -18867,7 +19112,7 @@ var parser$3 = { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; // read action for current state and first input @@ -18897,7 +19142,7 @@ var parser$3 = { // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; @@ -18957,15 +19202,17 @@ var parser$3 = { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -19019,7 +19266,7 @@ var parser$3 = { // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; @@ -19061,25 +19308,25 @@ var parser$3 = { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + var _tokenName2 = this.getSymbolName(symbol || EOF); - if (!tokenName) { - tokenName = symbol; + if (!_tokenName2) { + _tokenName2 = symbol; } Jison.parserDebugger.push({ action: 'shift', text: lexer.yytext, - terminal: tokenName, + terminal: _tokenName2, terminal_id: symbol }); } ++sp; symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc = this.copy_yylloc(lexer.yylloc); @@ -19087,9 +19334,9 @@ var parser$3 = { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... @@ -19097,25 +19344,28 @@ var parser$3 = { r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; + var _prereduceValue2 = vstack.slice(sp - yyrulelen, sp); - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); - debuggableProductions.push(debuggableProduction); + var _debuggableProductions2 = []; + + for (var _debugIdx2 = yyrulelen - 1; _debugIdx2 >= 0; _debugIdx2--) { + var _debuggableProduction2 = getNonTerminalFromCode(stack[sp - _debugIdx2]); + + _debuggableProductions2.push(_debuggableProduction2); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + var _currentNonterminalCode2 = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + + var _currentNonterminal2 = getNonTerminalFromCode(_currentNonterminalCode2); - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', - nonterminal: currentNonterminal, - nonterminal_id: currentNonterminalCode, - prereduce: prereduceValue, + nonterminal: _currentNonterminal2, + nonterminal_id: _currentNonterminalCode2, + prereduce: _prereduceValue2, result: r, - productions: debuggableProductions, + productions: _debuggableProductions2, text: yyval.$ }); } @@ -19137,15 +19387,17 @@ var parser$3 = { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var _ntsymbol2 = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = _ntsymbol2; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][_ntsymbol2]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -19654,6 +19906,10 @@ var lexer$2 = function () { * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -20035,9 +20291,9 @@ var lexer$2 = function () { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -20047,8 +20303,8 @@ var lexer$2 = function () { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -20124,12 +20380,22 @@ var lexer$2 = function () { */ pastInput: function lexer_pastInput(maxSize, maxLines) { var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) maxSize = Infinity;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substr` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = Infinity; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: @@ -20146,8 +20412,8 @@ var lexer$2 = function () { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -20173,20 +20439,30 @@ var lexer$2 = function () { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { var next = this.match; var source = this._input || ''; - if (maxSize < 0) maxSize = next.length + source.length;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substring` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = next.length + source.length; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + if (next.length < maxSize * 2 + 2) { next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8 } // now that we have a significantly reduced string to process, transform the newlines @@ -20511,7 +20787,7 @@ var lexer$2 = function () { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + var backup; if (this.options.backtrack_lexer) { // save context @@ -20539,9 +20815,9 @@ var lexer$2 = function () { }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + var match_str = match[0]; + var match_str_len = match_str.length; + var lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -20567,7 +20843,7 @@ var lexer$2 = function () { // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] + var token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */ ); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -20613,8 +20889,6 @@ var lexer$2 = function () { this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -20646,65 +20920,73 @@ var lexer$2 = function () { } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; // 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! + { + var rule_ids = spec.rules; + var regexes = spec.__rule_regexes; + var len = spec.__rule_count; + var match; + var index; // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + for (var i = 1; i <= len; i++) { + var tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + var token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + var _token5 = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + if (_token5 !== false) { + return _token5; + } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + var _lineno_msg3 = 'Lexical error'; if (this.yylloc) { - lineno_msg += ' on line ' + (this.yylineno + 1); + _lineno_msg3 += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var _p3 = this.constructLexErrorInfo(_lineno_msg3 + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var pendingInput = this._input; var activeCondition = this.topState(); var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; - if (token === this.ERROR) { + var _token6 = this.parseError(_p3.errStr, _p3, this.JisonLexerError) || this.ERROR; + + if (_token6 === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: @@ -20716,7 +20998,7 @@ var lexer$2 = function () { } } - return token; + return _token6; } }, @@ -20773,24 +21055,24 @@ var lexer$2 = function () { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -20817,24 +21099,24 @@ var lexer$2 = function () { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -20898,9 +21180,9 @@ var lexer$2 = function () { if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -20916,9 +21198,9 @@ var lexer$2 = function () { if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -20938,7 +21220,7 @@ var lexer$2 = function () { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -21181,7 +21463,7 @@ var lexer$2 = function () { /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */ - this.warn(rmCommonWS(_templateObject128(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); + this.warn(rmCommonWS(_templateObject129(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); yy_.yytext = [// {NAME} this.matches[1], // optional value/parameters this.matches[2].trim()]; @@ -21302,42 +21584,42 @@ var lexer$2 = function () { /*! Conditions:: action */ /*! Rule:: " */ - yy_.yyerror(rmCommonWS(_templateObject129()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject130()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 82: /*! Conditions:: action */ /*! Rule:: ' */ - yy_.yyerror(rmCommonWS(_templateObject130()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject131()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 83: /*! Conditions:: action */ /*! Rule:: ` */ - yy_.yyerror(rmCommonWS(_templateObject131()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject132()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 84: /*! Conditions:: option_values */ /*! Rule:: " */ - yy_.yyerror(rmCommonWS(_templateObject132()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject133()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 85: /*! Conditions:: option_values */ /*! Rule:: ' */ - yy_.yyerror(rmCommonWS(_templateObject133()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject134()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 86: /*! Conditions:: option_values */ /*! Rule:: ` */ - yy_.yyerror(rmCommonWS(_templateObject134()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject135()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 87: @@ -21345,7 +21627,7 @@ var lexer$2 = function () { /*! Rule:: " */ var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject135(), rules) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject136(), rules) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 88: @@ -21353,7 +21635,7 @@ var lexer$2 = function () { /*! Rule:: ' */ var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject136(), rules) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject137(), rules) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 89: @@ -21361,7 +21643,7 @@ var lexer$2 = function () { /*! Rule:: ` */ var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject137(), rules) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject138(), rules) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 90: @@ -21370,7 +21652,7 @@ var lexer$2 = function () { /*! Rule:: . */ /* b0rk on bad characters */ - yy_.yyerror(rmCommonWS(_templateObject138(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject139(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); return 2; default: @@ -22107,8 +22389,8 @@ function grammarPrinter(raw, options) { // which MAY get corrupted that way as their actual content would change then! // construct fake nesting levels to arrive at the intended start indent value: `num` var nesting_levels = num / 2; - var pre = '// **PRE**', - post = '// **POST**'; + var pre = '// **PRE**'; + var post = '// **POST**'; for (; nesting_levels > 0; nesting_levels--) { pre = 'function x() {\n' + pre; @@ -22146,8 +22428,8 @@ function grammarPrinter(raw, options) { // Begin - var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - meta = { + var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; + var meta = { // table of character substitutions '\b': '\\b', '\t': '\\t', @@ -22215,134 +22497,140 @@ function grammarPrinter(raw, options) { var lex_pre = []; var lex_rules = []; var lex_post = []; - var key, src; - src = raw.lex.macros; - delete raw.lex.macros; + { + var src = raw.lex.macros; + delete raw.lex.macros; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject139())); - var keylen = 0; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4(_templateObject140())); + var keylen = 0; - for (key in src) { - keylen = Math.max(keylen, key.length); - } + for (var key in src) { + keylen = Math.max(keylen, key.length); + } - console.log('macros keylen:', keylen); - keylen = (keylen / 4 | 0) * 4 + 4; - console.log('macros keylen B:', keylen); + console.log('macros keylen:', keylen); + keylen = (keylen / 4 | 0) * 4 + 4; + console.log('macros keylen B:', keylen); - for (key in src) { - lex_pre.push(padRight(key, keylen) + src[key]); - } + for (var _key in src) { + lex_pre.push(padRight(_key, keylen) + src[_key]); + } - lex_pre.push(rmCommonWS$4(_templateObject140())); + lex_pre.push(rmCommonWS$4(_templateObject141())); + } } + { + var _src = raw.lex.unknownDecls; + delete raw.lex.unknownDecls; - src = raw.lex.unknownDecls; - delete raw.lex.unknownDecls; + if (_src && !isEmptyObj(_src)) { + lex_pre.push(rmCommonWS$4(_templateObject142())); - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject141())); + for (var i = 0, len = _src.length; i < len; i++) { + var entry = _src[i]; + var _key2 = entry.name; + var value = entry.value; + lex_pre.push('%' + _key2 + ' ' + value); + } - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; - lex_pre.push('%' + key + ' ' + value); + lex_pre.push(rmCommonWS$4(_templateObject143())); } - - lex_pre.push(rmCommonWS$4(_templateObject142())); } + { + var _src2 = raw.lex.options; + delete raw.lex.options; - src = raw.lex.options; - delete raw.lex.options; - - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject143())); + if (_src2 && !isEmptyObj(_src2)) { + lex_pre.push(rmCommonWS$4(_templateObject144())); - for (key in src) { - var value = src[key]; + for (var _key3 in _src2) { + var _value = _src2[_key3]; - if (value) { - lex_pre.push('%options ' + key + '=' + value); - } else { - lex_pre.push('%options ' + key); + if (_value) { + lex_pre.push('%options ' + _key3 + '=' + _value); + } else { + lex_pre.push('%options ' + _key3); + } } } } + { + var _src3 = raw.lex.startConditions; + delete raw.lex.startConditions; - src = raw.lex.startConditions; - delete raw.lex.startConditions; - - if (src && !isEmptyObj(src)) { - for (key in src) { - var value = src[key]; - lex_pre.push((value ? '%x ' : '%s ') + key); + if (_src3 && !isEmptyObj(_src3)) { + for (var _key4 in _src3) { + var _value2 = _src3[_key4]; + lex_pre.push((_value2 ? '%x ' : '%s ') + _key4); + } } } + { + var _src4 = raw.lex.actionInclude; + delete raw.lex.actionInclude; - src = raw.lex.actionInclude; - delete raw.lex.actionInclude; - - if (src && src.trim()) { - lex_pre.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + if (_src4 && _src4.trim()) { + lex_pre.push('%{\n' + indentAction(_src4.trim(), 4) + '\n%}'); + } } + { + var _src5 = raw.lex.rules; + delete raw.lex.rules; - src = raw.lex.rules; - delete raw.lex.rules; - - if (src) { - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - key = entry[0]; - var action = indentAction(entry[1], 4); - var actionHasLF = /[\r\n]/.test(action); - console.log('indented action:', { - entry: entry[1], - action: action, - actionHasLF: actionHasLF - }); + if (_src5) { + for (var _i9 = 0, _len2 = _src5.length; _i9 < _len2; _i9++) { + var _entry = _src5[_i9]; + var _key5 = _entry[0]; + var action = indentAction(_entry[1], 4); + var actionHasLF = /[\r\n]/.test(action); + console.log('indented action:', { + entry: _entry[1], + action: action, + actionHasLF: actionHasLF + }); - if (key.length <= 12) { - if (!actionHasLF) { - lex_rules.push(padRight(key, 16) + indentAction(action, 16)); - } else { - lex_rules.push(padRight(key, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); - } - } else { - if (!actionHasLF) { - lex_rules.push(key, makeIndent(16) + indentAction(action, 16)); + if (_key5.length <= 12) { + if (!actionHasLF) { + lex_rules.push(padRight(_key5, 16) + indentAction(action, 16)); + } else { + lex_rules.push(padRight(_key5, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + } + } else if (!actionHasLF) { + lex_rules.push(_key5, makeIndent(16) + indentAction(action, 16)); } else { - lex_rules.push(key, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + lex_rules.push(_key5, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } } } + { + var _src6 = raw.lex.moduleInclude; + delete raw.lex.moduleInclude; - src = raw.lex.moduleInclude; - delete raw.lex.moduleInclude; - - if (src && src.trim()) { - lex_post.push(indentAction(src.trim(), 0)); + if (_src6 && _src6.trim()) { + lex_post.push(indentAction(_src6.trim(), 0)); + } } + { + var out = ''; - var out = ''; + 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, '*\\/')); + } - if (!isEmptyObj(raw.lex)) { - // dump the remainder as a comment: - var rem = JSON5__default['default'].stringify(raw.lex, null, 2); - out += rmCommonWS$4(_templateObject144(), rem.replace(/\*\//g, '*\\/')); - } + delete raw.lex; + out += lex_pre.join('\n') + '\n\n'; + out += rmCommonWS$4(_templateObject146()) + lex_rules.join('\n') + '\n\n'; - delete raw.lex; - out += lex_pre.join('\n') + '\n\n'; - out += rmCommonWS$4(_templateObject145()) + lex_rules.join('\n') + '\n\n'; + if (lex_post.length > 0) { + out += rmCommonWS$4(_templateObject147()) + lex_post.join('\n') + '\n\n'; + } - if (lex_post.length > 0) { - out += rmCommonWS$4(_templateObject146()) + lex_post.join('\n') + '\n\n'; + lex_out_str = out; } - - lex_out_str = out; } var grammar_pre = []; @@ -22350,7 +22638,6 @@ function grammarPrinter(raw, options) { var ebnf_rules = []; var bnf_rules = []; var grammar_post = []; - var key, src; var fmtprod = function fmtprod(rule, prodset) { var backup = deepClone(prodset); @@ -22388,12 +22675,12 @@ function grammarPrinter(raw, options) { } if (typeof prodset[1] === 'string') { - var action = prodset[1]; + var _action = prodset[1]; if (lead.length < 12 - 1) { - rule += makeIndent(12 - lead.length) + indentAction('{ ' + action + ' }', 12); + rule += makeIndent(12 - lead.length) + indentAction('{ ' + _action + ' }', 12); } else { - rule += '\n' + makeIndent(12) + indentAction('{ ' + action + ' }', 12); + rule += '\n' + makeIndent(12) + indentAction('{ ' + _action + ' }', 12); } delete prodset[1]; @@ -22409,72 +22696,71 @@ function grammarPrinter(raw, options) { }; var grammarfmt = function grammarfmt(src) { - var key; var dst = []; - for (key in src) { - var prodset = src[key]; - var rule; + for (var _key6 in src) { + var prodset = src[_key6]; + var rule = void 0; console.log('format one rule:', { - key: key, + key: _key6, prodset: prodset }); if (typeof prodset === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; - delete src[key]; + rule = fmtprod(_key6 + ' : ', [prodset]) + ';'; + delete src[_key6]; } else if (prodset instanceof Array) { if (prodset.length === 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; - delete src[key]; + rule = fmtprod(_key6 + ' : ', [prodset]) + ';'; + delete src[_key6]; } else if (prodset[0] instanceof Array) { - rule = fmtprod(key + ' : ', prodset[0]); + rule = fmtprod(_key6 + ' : ', prodset[0]); rule += '\n ;'; if (prodset[0].length === 0) { - delete src[key]; + delete src[_key6]; } } else { - rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; + rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } } else if (prodset.length > 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + '\n : ', [prodset[0]]); + rule = fmtprod(_key6 + '\n : ', [prodset[0]]); delete prodset[0]; } else if (prodset[0] instanceof Array) { - rule = fmtprod(key + '\n : ', prodset[0]); + rule = fmtprod(_key6 + '\n : ', prodset[0]); if (prodset[0].length === 0) { delete prodset[0]; } } else { - rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; + rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - for (var i = 1, len = prodset.length; i < len; i++) { - if (typeof prodset[i] === 'string') { - rule += fmtprod('\n | ', [prodset[i]]); - delete prodset[i]; - } else if (prodset[i] instanceof Array) { - rule += fmtprod('\n | ', prodset[i]); + 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]); - if (prodset[i].length === 0) { - delete prodset[i]; + if (prodset[_i10].length === 0) { + delete prodset[_i10]; } } else { - rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[i]; + rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[_i10]; } } rule += '\n ;'; if (isEmptyArr(prodset)) { - delete src[key]; + delete src[_key6]; } } } else { - rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; + rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; } dst.push(rule); @@ -22483,313 +22769,333 @@ function grammarPrinter(raw, options) { return dst; }; - src = raw.ebnf; + { + var _src7 = raw.ebnf; - if (src) { - ebnf_rules = grammarfmt(src); + if (_src7) { + ebnf_rules = grammarfmt(_src7); - if (isEmptyObj(src)) { - delete raw.ebnf; + if (isEmptyObj(_src7)) { + delete raw.ebnf; + } } } + { + var _src8 = raw.bnf; //delete raw.bnf; - src = raw.bnf; //delete raw.bnf; - - if (src) { - bnf_rules = grammarfmt(src); + if (_src8) { + bnf_rules = grammarfmt(_src8); - if (isEmptyObj(src)) { - delete raw.bnf; + if (isEmptyObj(_src8)) { + delete raw.bnf; + } } } + { + var _src9 = raw.unknownDecls; + delete raw.unknownDecls; - src = raw.unknownDecls; - delete raw.unknownDecls; + if (_src9 && !isEmptyObj(_src9)) { + lex_pre.push(rmCommonWS$4(_templateObject148())); - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject147())); + for (var _i11 = 0, _len4 = _src9.length; _i11 < _len4; _i11++) { + var _entry2 = _src9[_i11]; + var _key7 = _entry2.name; + var _value3 = _entry2.value; + lex_pre.push('%' + _key7 + ' ' + _value3); + } - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; - lex_pre.push('%' + key + ' ' + value); + lex_pre.push(rmCommonWS$4(_templateObject149())); } - - lex_pre.push(rmCommonWS$4(_templateObject148())); - } //src = raw.lex; + } //let src = raw.lex; //delete raw.lex; //if (src) { - if (lex_out_str.trim() && options.showLexer) { - grammar_pre.push(rmCommonWS$4(_templateObject149(), lex_out_str)); + grammar_pre.push(rmCommonWS$4(_templateObject150(), lex_out_str)); } - src = raw.options; - delete raw.options; + { + var _src10 = raw.options; + delete raw.options; - if (src && !isEmptyObj(src)) { - var a = []; + if (_src10 && !isEmptyObj(_src10)) { + var a = []; - for (key in src) { - var value = src[key]; + for (var _key8 in _src10) { + var _value4 = _src10[_key8]; - switch (key) { - default: - if (value !== true) { - a.push('options', '%options ' + key + '=' + value); - } else { - a.push('options', '%options ' + key); - } + switch (_key8) { + default: + if (_value4 !== true) { + a.push('options', '%options ' + _key8 + '=' + _value4); + } else { + a.push('options', '%options ' + _key8); + } - break; + break; - case 'ebnf': - if (value) { - a.push(key, '%ebnf'); - } + case 'ebnf': + if (_value4) { + a.push(_key8, '%ebnf'); + } - break; + break; - case 'type': - if (value) { - a.push(key, '%parser-type ' + value); - } + case 'type': + if (_value4) { + a.push(_key8, '%parser-type ' + _value4); + } - break; + break; - case 'debug': - if (typeof value !== 'boolean') { - a.push(key, '%debug ' + value); - } else if (value) { - a.push(key, '%debug'); - } + case 'debug': + if (typeof _value4 !== 'boolean') { + a.push(_key8, '%debug ' + _value4); + } else if (_value4) { + a.push(_key8, '%debug'); + } - break; + break; + } } - } - var type = null; + var type = null; - for (var i = 0, len = a.length; i < len; i += 2) { - var t = a[i]; - var line = a[i + 1]; + for (var _i12 = 0, _len5 = a.length; _i12 < _len5; _i12 += 2) { + var t = a[_i12]; + var line = a[_i12 + 1]; + + if (t !== type) { + type = t; + grammar_pre.push(''); + } - if (t !== type) { - type = t; - grammar_pre.push(''); + grammar_pre.push(line); } - grammar_pre.push(line); + grammar_pre.push(''); } - - grammar_pre.push(''); } + { + var _src11 = raw.imports; - src = raw.imports; - - if (src) { - var clean = true; + if (_src11) { + var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - grammar_pre.push('%import ' + entry.name + ' ' + entry.path); - delete entry.name; - delete entry.path; + for (var _i13 = 0, _len6 = _src11.length; _i13 < _len6; _i13++) { + var _entry3 = _src11[_i13]; + grammar_pre.push('%import ' + _entry3.name + ' ' + _entry3.path); + delete _entry3.name; + delete _entry3.path; - if (isEmptyObj(entry)) { - delete src[i]; - } else { - clean = false; + if (isEmptyObj(_entry3)) { + delete _src11[_i13]; + } else { + clean = false; + } } - } - if (clean) { - delete raw.imports; + if (clean) { + delete raw.imports; + } } } + { + var _src12 = raw.moduleInit; - src = raw.moduleInit; - - if (src) { - var clean = true; + if (_src12) { + var _clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - grammar_pre.push('%code ' + entry.qualifier + ' ' + entry.include); - delete entry.qualifier; - delete entry.include; + for (var _i14 = 0, _len7 = _src12.length; _i14 < _len7; _i14++) { + var _entry4 = _src12[_i14]; + grammar_pre.push('%code ' + _entry4.qualifier + ' ' + _entry4.include); + delete _entry4.qualifier; + delete _entry4.include; - if (isEmptyObj(entry)) { - delete src[i]; - } else { - clean = false; + if (isEmptyObj(_entry4)) { + delete _src12[_i14]; + } else { + _clean = false; + } } - } - if (clean) { - delete raw.moduleInit; + if (_clean) { + delete raw.moduleInit; + } } } + { + var _src13 = raw.operators; - src = raw.operators; + if (_src13) { + var _clean2 = true; - if (src) { - var clean = true; + for (var _i15 = 0, _len8 = _src13.length; _i15 < _len8; _i15++) { + var _entry5 = _src13[_i15]; + var tokens = _entry5[1]; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var tokens = entry[1]; - var line = '%' + entry[0] + ' '; + var _line = '%' + _entry5[0] + ' '; - for (var t = 0, tlen = tokens.length; t < tlen; t++) { - line += ' ' + tokens[t]; - } + for (var _t3 = 0, tlen = tokens.length; _t3 < tlen; _t3++) { + _line += ' ' + tokens[_t3]; + } - grammar_pre.push(line); + grammar_pre.push(_line); - if (entry.length === 2) { - delete src[i]; - } else { - clean = false; + if (_entry5.length === 2) { + delete _src13[_i15]; + } else { + _clean2 = false; + } } - } - if (clean) { - delete raw.operators; + if (_clean2) { + delete raw.operators; + } } } + { + var _src14 = raw.extra_tokens; - src = raw.extra_tokens; + if (_src14) { + var _clean3 = true; - if (src) { - var clean = true; + for (var _i16 = 0, _len9 = _src14.length; _i16 < _len9; _i16++) { + var _entry6 = _src14[_i16]; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var line = '%token ' + entry.id; + var _line2 = '%token ' + _entry6.id; - if (entry.type) { - line += ' <' + entry.type + '>'; - delete entry.type; - } + if (_entry6.type) { + _line2 += ' <' + _entry6.type + '>'; + delete _entry6.type; + } - if (entry.value) { - line += ' ' + entry.value; - delete entry.value; - } + if (_entry6.value) { + _line2 += ' ' + _entry6.value; + delete _entry6.value; + } - if (entry.description) { - line += ' ' + escapeString(entry.description); - delete entry.description; - } + if (_entry6.description) { + _line2 += ' ' + escapeString(_entry6.description); + delete _entry6.description; + } - grammar_pre.push(line); - delete entry.id; + grammar_pre.push(_line2); + delete _entry6.id; - if (isEmptyObj(entry)) { - delete src[i]; - } else { - clean = false; + if (isEmptyObj(_entry6)) { + delete _src14[_i16]; + } else { + _clean3 = false; + } } - } - if (clean) { - delete raw.extra_tokens; + if (_clean3) { + delete raw.extra_tokens; + } } } + { + var _src15 = raw.parseParams; + delete raw.parseParams; - src = raw.parseParams; - delete raw.parseParams; - - if (src) { - grammar_pre.push('%parse-param ' + src.join(' ')); + if (_src15) { + grammar_pre.push('%parse-param ' + _src15.join(' ')); + } } + { + var _src16 = raw.start; + delete raw.start; - src = raw.start; - delete raw.start; - - if (src) { - grammar_pre.push('%start ' + src); + if (_src16) { + grammar_pre.push('%start ' + _src16); + } } + { + var _src17 = raw.moduleInclude; + delete raw.moduleInclude; - src = raw.moduleInclude; - delete raw.moduleInclude; + if (_src17 && _src17.trim()) { + grammar_post.push(indentAction(_src17.trim(), 0)); + } + } + { + var _src18 = raw.actionInclude; + delete raw.actionInclude; - if (src && src.trim()) { - grammar_post.push(indentAction(src.trim(), 0)); + if (_src18 && _src18.trim()) { + grammar_mid.push('%{\n' + indentAction(_src18.trim(), 4) + '\n%}'); + } } + { + var _out = ''; - src = raw.actionInclude; - delete raw.actionInclude; + if (!isEmptyObj(raw)) { + // dump the remainder as a comment: + var _rem = JSON5__default['default'].stringify(raw, null, 2); - if (src && src.trim()) { - grammar_mid.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); - } + _out += rmCommonWS$4(_templateObject151(), _rem.replace(/\*\//g, '*\\/')); // delete raw; + } - var out = ''; + if (!options.showParser) { + _out += lex_out_str; + } else { + _out += grammar_pre.join('\n') + '\n\n'; + _out += rmCommonWS$4(_templateObject152()); - if (!isEmptyObj(raw)) { - // dump the remainder as a comment: - var rem = JSON5__default['default'].stringify(raw, null, 2); - out += rmCommonWS$4(_templateObject150(), rem.replace(/\*\//g, '*\\/')); // delete raw; - } + if (grammar_mid.length > 0) { + _out += grammar_mid.join('\n') + '\n\n'; + } - if (!options.showParser) { - out += lex_out_str; - } else { - out += grammar_pre.join('\n') + '\n\n'; - out += rmCommonWS$4(_templateObject151()); + if (ebnf_rules.length > 0) { + if (bnf_rules.length > 0) { + // dump the original EBNF grammar as source and dump the BNF derivative as COMMENT: + var bnf_deriv = bnf_rules.join('\n\n'); - if (grammar_mid.length > 0) { - out += grammar_mid.join('\n') + '\n\n'; - } + var _a2 = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - if (ebnf_rules.length > 0) { - if (bnf_rules.length > 0) { - // dump the original EBNF grammar as source and dump the BNF derivative as COMMENT: - var bnf_deriv = bnf_rules.join('\n\n'); - var a = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); - out += rmCommonWS$4(_templateObject152(), a.join('\n')); + _out += rmCommonWS$4(_templateObject153(), _a2.join('\n')); + } + + _out += ebnf_rules.join('\n\n') + '\n\n'; + } else if (bnf_rules.length > 0) { + _out += bnf_rules.join('\n\n') + '\n\n'; } - out += ebnf_rules.join('\n\n') + '\n\n'; - } else if (bnf_rules.length > 0) { - out += bnf_rules.join('\n\n') + '\n\n'; + if (grammar_post.length > 0) { + _out += rmCommonWS$4(_templateObject154()) + grammar_post.join('\n') + '\n\n'; + } } - if (grammar_post.length > 0) { - out += rmCommonWS$4(_templateObject153()) + grammar_post.join('\n') + '\n\n'; - } - } + if (options.format === 'json5') { + var _a3 = _out.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - if (options.format === 'json5') { - var a = out.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); - out = rmCommonWS$4(_templateObject154(), options.showParser ? 'grammar' : 'lexer', a.join('\n')); // process the original input once again: this time via JSON5 + _out = rmCommonWS$4(_templateObject155(), options.showParser ? 'grammar' : 'lexer', _a3.join('\n')); // process the original input once again: this time via JSON5 - raw = deepClone(originalInput); + raw = deepClone(originalInput); - if (!options.showLexer) { - delete raw.lex; - out += JSON5__default['default'].stringify(raw, null, 2); - } else if (!options.showParser) { - out += JSON5__default['default'].stringify(raw.lex, null, 2); + if (!options.showLexer) { + delete raw.lex; + _out += JSON5__default['default'].stringify(raw, null, 2); + } else if (!options.showParser) { + _out += JSON5__default['default'].stringify(raw.lex, null, 2); + } } - } - return out; + return _out; + } } // Jison, an LR(0), SLR(1), LARL(1), LR(1) Parser Generator var rmCommonWS$5 = helpers.rmCommonWS; var mkIdentifier$4 = helpers.mkIdentifier; -var code_exec$2 = helpers.exec; -var version$2 = '0.6.2-220'; +var code_exec$1 = helpers.exec; +var version$2 = '0.7.0-220'; var devDebug = 0; function chkBugger$3(src) { @@ -22821,9 +23127,9 @@ var defaultJisonOptions = { // 0, 1, 2 outputDebugTables: false, noDefaultResolve: false, - defaultActionMode: ["classic", "merge"], + defaultActionMode: ['classic', 'merge'], // {classic, ast, none, skip}, {classic, ast, merge, none, skip} - testCompileActionCode: "parser:*,lexer:*", + testCompileActionCode: 'parser:*,lexer:*', noTryCatch: false, hasPartialLrUpgradeOnConflict: true, errorRecoveryTokenDiscardCount: 3, @@ -22903,14 +23209,14 @@ Jison$1.defaultJisonOptions = defaultJisonOptions; // Merge sets of options. function mkStdOptions$1() { var h = Object.prototype.hasOwnProperty; - var opts = {}; //var args = Array.prototype.concat.apply([], args); + var opts = {}; //let args = Array.prototype.concat.apply([], args); // clone defaults, so we do not modify those constants? - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len10 = arguments.length, args = new Array(_len10), _key9 = 0; _key9 < _len10; _key9++) { + args[_key9] = arguments[_key9]; } - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(Jison$1.defaultJisonOptions); } else { args.shift(); @@ -23026,10 +23332,10 @@ function mkStdOptions$1() { } // now see if we have an overriding option here: - for (var p in o2) { - if (h.call(o2, p)) { - if (typeof o2[p] !== 'undefined') { - opts[p] = o2[p]; + for (var _p4 in o2) { + if (h.call(o2, _p4)) { + if (typeof o2[_p4] !== 'undefined') { + opts[_p4] = o2[_p4]; } } } @@ -23100,7 +23406,7 @@ function autodetectAndConvertToJSONformat$1(grammar, optionalLexerSection, optio // When both JSON5 and JISON input modes barf a hairball, assume the most important // error is the JISON one (show that one first!), while it MAY be a JSON5 format // error that triggered it (show that one last!). - // + // // Also check for common JISON errors which are obviously never triggered by any // odd JSON5 input format error: when we encounter such an error here, we don't // confuse matters and forget about the JSON5 fail as it's irrelevant: @@ -23217,7 +23523,7 @@ if (typeof console !== 'undefined' && console.log) { Jison$1.Lexer = RegExpLexer; Jison$1.ebnfParser = ebnfParser; Jison$1.lexParser = lexParser; -Jison$1.codeExec = code_exec$2; +Jison$1.codeExec = code_exec$1; Jison$1.XRegExp = XRegExp__default['default']; Jison$1.recast = recast__default['default']; Jison$1.astUtils = astUtils__default['default']; //Jison.prettier = prettier; @@ -23293,7 +23599,7 @@ function union(a, b) { var Nonterminal = typal.construct({ constructor: function Nonterminal(symbol) { this.symbol = symbol; - this.productions = new Set(); + this.productions = new Set$1(); this.first = []; this.follows = []; this.nullable = false; @@ -23587,10 +23893,10 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, }; generator.processGrammar = function processGrammarDef(grammar) { - var bnf = grammar.bnf, - tokens = grammar.tokens, - nonterminals = this.nonterminals = {}, - productions = this.productions; + var bnf = grammar.bnf; + var tokens = grammar.tokens; + var nonterminals = this.nonterminals = {}; + var productions = this.productions; if (!grammar.bnf && grammar.ebnf) { bnf = grammar.bnf = ebnfParser.transform(grammar.ebnf); @@ -23646,11 +23952,11 @@ generator.processGrammar = function processGrammarDef(grammar) { } // Make sure all predefined symbols are unique and *numeric* and do not include predefined tokens JISON already defines to a fixed ID on its own: - delete predefined_symbols['$accept']; - delete predefined_symbols['$end']; - delete predefined_symbols['error']; - delete predefined_symbols['$eof']; - delete predefined_symbols['EOF']; + delete predefined_symbols.$accept; + delete predefined_symbols.$end; + delete predefined_symbols.error; + delete predefined_symbols.$eof; + delete predefined_symbols.EOF; var symdef_uniq_check = {}; // Only these symbols are allowed to have the values 1 or 2: symdef_uniq_check[1] = 'EOF'; @@ -23662,21 +23968,21 @@ generator.processGrammar = function processGrammarDef(grammar) { if (typeof v !== 'number') { if (typeof v !== 'string' || v.length !== 1) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a non-numeric symbol ID value must be a single-character string.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a non-numeric symbol ID value must be a single-character string."); } v = v.charCodeAt(0); } - v = v | 0; + v |= 0; if (!v || v < 0) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a symbol ID value must be an integer value, 3 or greater.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a symbol ID value must be an integer value, 3 or greater."); } if (symdef_uniq_check[v]) { if (symdef_uniq_check[v] !== sym) { - throw new Error('Error: `%import symbols `: symbol table contains duplicate ID values for keys \'' + sym + '\' and \'' + symdef_uniq_check[v] + '\''); + throw new Error("Error: `%import symbols `: symbol table contains duplicate ID values for keys '" + sym + "' and '" + symdef_uniq_check[v] + "'"); } } @@ -23777,13 +24083,14 @@ generator.augmentGrammar = function augmentGrammar(grammar) { generator.signalUnusedProductions = function () { + var _this3 = this; + var mark = {}; var productions = this.productions; var nonterminals = this.nonterminals; - var i, len, nt, sym; - for (i = 0, len = nonterminals.length; i < len; i++) { - nt = nonterminals[i]; + for (var i = 0, len = nonterminals.length; i < len; i++) { + var nt = nonterminals[i]; assert__default['default'](nt.symbol); mark[nt.symbol] = false; } // scan & mark all visited productions @@ -23800,7 +24107,7 @@ generator.signalUnusedProductions = function () { assert__default['default'](p.handle); var rhs = p.handle; - for (var j = 0, len = rhs.length; j < len; j++) { + for (var j = 0, _len11 = rhs.length; j < _len11; j++) { var sym = rhs[j]; assert__default['default'](!sym ? !nonterminals[sym] : true); @@ -23815,8 +24122,8 @@ generator.signalUnusedProductions = function () { /* this.startSymbol */ ]); // now any production which is not yet marked is *unused*: - for (sym in mark) { - nt = nonterminals[sym]; + var _loop = function _loop(sym) { + var nt = nonterminals[sym]; assert__default['default'](nt); var prods = nt.productions; assert__default['default'](prods); @@ -23833,8 +24140,12 @@ generator.signalUnusedProductions = function () { if (!in_use) { // and kill the unused nonterminals: - delete this.nonterminals[sym]; + delete _this3.nonterminals[sym]; } + }; + + for (var sym in mark) { + _loop(sym); } this.unused_productions = productions.filter(function (p) { @@ -23901,7 +24212,7 @@ function reindentCodeBlock(action, indent_level) { generator.buildProductions = function buildProductions(bnf, productions, nonterminals, symbols, operators, predefined_symbols, descriptions) { var self = this; - var prods, symbol, symId; + var prods, symId; var productions_ = []; var symbols_ = {}; var descriptions_ = {}; @@ -23917,9 +24228,9 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm this.EOF = '$end'; symbols_.$accept = 0; symbols_[this.EOF] = 1; - symbols_['$eof'] = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.$eof = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! - symbols_['EOF'] = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.EOF = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! symbols[0] = '$accept'; symbols[1] = this.EOF; @@ -23929,7 +24240,7 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm symbols[2] = 'error'; if (predefined_symbols) { - for (symbol in predefined_symbols) { + for (var symbol in predefined_symbols) { symId = predefined_symbols[symbol]; if (symId === true) { @@ -23953,9 +24264,9 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm usedSymbolIdsLowIndex = (this.options.compressTables | 0) < 2 ? 32 : 3; - for (symbol in predefined_symbols) { - symId = predefined_symbols[symbol]; - addSymbol(symbol); + for (var _symbol in predefined_symbols) { + symId = predefined_symbols[_symbol]; + addSymbol(_symbol); } // reset ID low water mark: nonterminals etc. can be assigned any number, preferably a small/low one! @@ -24014,20 +24325,19 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm function collectLiteralTokensInProduction(handle) { - var rhs, i, sym; + var rhs; try { if (devDebug) ; var maxlen = this.maxTokenLength || Infinity; if (handle.constructor === Array) { - var rhs_i; rhs = typeof handle[0] === 'string' ? splitStringIntoSymbols(handle[0]) : handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; // check for aliased names, e.g., id[alias] and strip them + for (var i = 0; i < rhs.length; i++) { + var sym = rhs[i]; // check for aliased names, e.g., id[alias] and strip them - rhs_i = sym.match(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]$"))); + var rhs_i = sym.match(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]$"))); if (rhs_i) { sym = sym.substr(0, sym.length - rhs_i[0].length); @@ -24042,18 +24352,16 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm handle = handle.replace(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]"), 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; + for (var _i17 = 0; _i17 < rhs.length; _i17++) { + var _sym = rhs[_i17]; - if (!bnf[sym] && sym.length <= maxlen) { - addSymbol(sym); + if (!bnf[_sym] && _sym.length <= maxlen) { + addSymbol(_sym); } } } } catch (ex) { - console.error(ex, '\ncollectLiteralTokensInProduction: ', symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { - i: i, - sym: sym, + console.error(ex, '\ncollectLiteralTokensInProduction: ', this.symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { rhs: rhs }); throw ex; @@ -24066,33 +24374,35 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm var prodsLUT = {}; - for (symbol in bnf) { - if (!bnf.hasOwnProperty(symbol)) continue; + for (var _symbol2 in bnf) { + if (!bnf.hasOwnProperty(_symbol2)) continue; - if (typeof bnf[symbol] === 'string') { - prods = bnf[symbol].split(/\s*\|\s*/g); + if (typeof bnf[_symbol2] === 'string') { + prods = bnf[_symbol2].split(/\s*\|\s*/g); } else { - prods = bnf[symbol].slice(0); + prods = bnf[_symbol2].slice(0); } - prodsLUT[symbol] = prods; + prodsLUT[_symbol2] = prods; } // First we collect all single-character literal tokens: - for (symbol in prodsLUT) { - if (!prodsLUT.hasOwnProperty(symbol)) continue; - prods = prodsLUT[symbol]; + for (var _symbol3 in prodsLUT) { + if (!prodsLUT.hasOwnProperty(_symbol3)) continue; + prods = prodsLUT[_symbol3]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: 1 + maxTokenLength: 1, + symbol: _symbol3 }); } // Next we collect all other literal tokens: - for (symbol in prodsLUT) { - if (!prodsLUT.hasOwnProperty(symbol)) continue; - prods = prodsLUT[symbol]; + for (var _symbol4 in prodsLUT) { + if (!prodsLUT.hasOwnProperty(_symbol4)) continue; + prods = prodsLUT[_symbol4]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: Infinity + maxTokenLength: Infinity, + symbol: _symbol4 }); } // and now go and process the entire grammar: // first collect all nonterminals in a symbol table, then build the productions @@ -24101,22 +24411,24 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm // referenced: - for (symbol in bnf) { - if (!bnf.hasOwnProperty(symbol)) continue; - addSymbol(symbol); - nonterminals[symbol] = new Nonterminal(symbol); + for (var _symbol5 in bnf) { + if (!bnf.hasOwnProperty(_symbol5)) continue; + addSymbol(_symbol5); + nonterminals[_symbol5] = new Nonterminal(_symbol5); } // now that we have collected all nonterminals in our symbol table, it's finally // time to process the productions: - for (symbol in prodsLUT) { - if (!prodsLUT.hasOwnProperty(symbol)) continue; - prods = prodsLUT[symbol]; - prods.forEach(buildProduction); + for (var _symbol6 in prodsLUT) { + if (!prodsLUT.hasOwnProperty(_symbol6)) continue; + prods = prodsLUT[_symbol6]; + prods.forEach(buildProduction, { + symbol: _symbol6 + }); } - var terms = [], - terms_ = {}; + var terms = []; + var terms_ = {}; each(symbols_, function (id, sym) { // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number @@ -24141,9 +24453,9 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm chk_er_opt('parserErrorsAreRecoverable', 'parser-errors-are-recoverable feature/option'); // Hmmmm... why would lexer errors need to be NON-recoverable when there's no ERROR rules in the GRAMMAR?! chk_er_opt('lexerErrorsAreRecoverable', 'lexer-errors-are-recoverable feature/option'); - chk_er_opt('parseActionsUseYYRECOVERING', 'YYRECOVERING macro/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYERROK', 'yyerrok() function/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYCLEARIN', 'yyclearin() function/API in grammar rules\' action code'); + chk_er_opt('parseActionsUseYYRECOVERING', "YYRECOVERING macro/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYERROK', "yyerrok() function/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYCLEARIN', "yyclearin() function/API in grammar rules' action code"); } this.terminals = terms; @@ -24235,23 +24547,21 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm } return tokens; - } + } // options object { symbol } is `this` for this functon/callback: + function buildProduction(handle) { - var r, - rhs, - i, - precedence_override, - aliased = [], - action = null; + var rhs; + var precedence_override = null; + var aliased = []; + var action = null; if (handle.constructor === Array) { - var rhs_i; rhs = typeof handle[0] === 'string' ? splitStringIntoSymbols(handle[0]) : handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { + for (var i = 0; i < rhs.length; i++) { // check for aliased names, e.g., id[alias] and strip them - rhs_i = rhs[i].match(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]$"))); + var rhs_i = rhs[i].match(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]$"))); if (rhs_i) { rhs[i] = rhs[i].substr(0, rhs[i].length - rhs_i[0].length); @@ -24295,17 +24605,17 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm handle = handle.replace(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]"), 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (i = 0; i < rhs.length; i++) { - if (rhs[i] === 'error') { + for (var _i18 = 0; _i18 < rhs.length; _i18++) { + if (rhs[_i18] === 'error') { hasErrorRecovery = true; } - assert__default['default'](bnf[rhs[i]] ? symbols_[rhs[i]] : true, 'all nonterminals must already exist in the symbol table'); - assert__default['default'](rhs[i] ? symbols_[rhs[i]] : true, 'all symbols (terminals and nonterminals) must already exist in the symbol table'); //addSymbol(rhs[i]); + 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]); } } - r = new Production(symbol, rhs, productions.length + 1, aliased, action); // set precedence + var r = new Production(this.symbol, rhs, productions.length + 1, aliased, action); // set precedence assert__default['default'](r.precedence === 0); @@ -24315,23 +24625,23 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm var prec_symbols = []; var winning_symbol; - for (i = r.handle.length - 1; i >= 0; i--) { - if (!(r.handle[i] in nonterminals) && r.handle[i] in operators) { + for (var _i19 = r.handle.length - 1; _i19 >= 0; _i19--) { + if (!(r.handle[_i19] in nonterminals) && r.handle[_i19] in operators) { var old_prec = r.precedence; - var new_prec = operators[r.handle[i]].precedence; + var new_prec = operators[r.handle[_i19]].precedence; if (old_prec !== 0 && old_prec !== new_prec) { - prec_symbols.push(r.handle[i]); // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], symbol, handle[0]); + prec_symbols.push(r.handle[_i19]); // 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[i]; + winning_symbol = r.handle[_i19]; } else { // keep previously set precedence: new_prec = old_prec; } } else if (old_prec === 0) { - prec_symbols.push(r.handle[i]); - winning_symbol = r.handle[i]; // Jison.print('precedence set first time: ', old_prec, r.handle[i], symbol, handle[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]); } r.precedence = new_prec; @@ -24340,14 +24650,14 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm if (prec_symbols.length > 1) { if (self.DEBUG || 1) { - self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); + self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + this.symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); } } } productions.push(r); productions_.push([symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length]); - nonterminals[symbol].productions.push(r); + nonterminals[this.symbol].productions.push(r); } }; // Preprocess the action code block before we perform any `$n`, `@n` ,`##n` or `#n` expansions: // Any comment blocks in there should be kept intact (and not cause trouble either as those comments MAY @@ -24419,13 +24729,10 @@ function preprocessActionCode(s) { // with our pants down in constructs like // `'"' + $$ + '"'` vs. `"'" + $$ + "'"` - var dqpos, - sqpos, - ccmtpos, - cppcmtpos, - first = -1; + var dqpos, sqpos, ccmtpos, cppcmtpos; + var first = -1; - for (var c = 0;; c++) { + for (var _c2 = 0;; _c2++) { first++; dqpos = s.indexOf('"', first); sqpos = s.indexOf("'", first); // also look for remaining comments which contain quotes of any kind, @@ -24459,7 +24766,7 @@ function postprocessActionCode(s) { s = s // multiline comment start markers: .replace(/\x01\x84/g, '/*').replace(/\x01\x85/g, '/*').replace(/\x01\x86/g, '//') // revert markers: .replace(/\x01\x81/g, '#').replace(/\x01\x82/g, '$').replace(/\x01\x83/g, '@') // and revert the string and regex markers: - .replace(/\x01\x87/g, '\'').replace(/\x01\x88/g, '\"').replace(/\x01\x89/g, '##').replace(/\x01\x90/g, '\\\\').replace(/\x01\x91/g, '\\\'').replace(/\x01\x92/g, '\\\"').replace(/\x01\x93/g, '\\\/').replace(/\x01\x94/g, 'YYABORT').replace(/\x01\x95/g, 'YYACCEPT').replace(/\x01\x96/g, 'yyvstack').replace(/\x01\x97/g, 'yylstack').replace(/\x01\x98/g, 'yyerror').replace(/\x01\x99/g, 'YYRECOVERING').replace(/\x01\x9A/g, 'yyerrok').replace(/\x01\x9B/g, 'yyclearin').replace(/\x01\x9C/g, 'yysp').replace(/\x01\x9D__/g, 'yy'); // And a final, minimal, fixup for the semicolon-lovers -- like me! ;-) + .replace(/\x01\x87/g, "'").replace(/\x01\x88/g, '\"').replace(/\x01\x89/g, '##').replace(/\x01\x90/g, '\\\\').replace(/\x01\x91/g, "\\'").replace(/\x01\x92/g, '\\\"').replace(/\x01\x93/g, '\\\/').replace(/\x01\x94/g, 'YYABORT').replace(/\x01\x95/g, 'YYACCEPT').replace(/\x01\x96/g, 'yyvstack').replace(/\x01\x97/g, 'yylstack').replace(/\x01\x98/g, 'yyerror').replace(/\x01\x99/g, 'YYRECOVERING').replace(/\x01\x9A/g, 'yyerrok').replace(/\x01\x9B/g, 'yyclearin').replace(/\x01\x9C/g, 'yysp').replace(/\x01\x9D__/g, 'yy'); // And a final, minimal, fixup for the semicolon-lovers -- like me! ;-) // // Make sure the last statement is properly semicolon-terminated 99.9% of the time: @@ -24498,11 +24805,11 @@ generator.buildProductionActions = function buildProductionActions() { this.productions_ = productions_; assert(this.productions === productions); */ - var productions = this.productions, - nonterminals = this.nonterminals, - symbols = this.symbols, - operators = this.operators, - self = this; // As a SIDE EFFECT of this call, we also fixup + var productions = this.productions; + var nonterminals = this.nonterminals; + var symbols = this.symbols; + var operators = this.operators; + var self = this; // As a SIDE EFFECT of this call, we also fixup // the other code chunks specified in the grammar file: // // Replace direct symbol references, e.g. #NUMBER# when there's a `%token NUMBER` for your grammar. @@ -24533,16 +24840,19 @@ generator.buildProductionActions = function buildProductionActions() { while (gen_hash !== prev_gen_hash) { var preludeCode = preprocessActionCode(this.actionInclude || ''); - var actions = ["\n /* this == yyval */\n\n // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code!\n var yy = this.yy;\n var yyparser = yy.parser;\n var yylexer = yy.lexer;\n\n ".concat(preludeCode, "\n\n switch (yystate) {")]; + var actions = ["\n /* this == yyval */\n\n // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code!\n let yy = this.yy;\n let yyparser = yy.parser;\n let yylexer = yy.lexer;\n\n ".concat(preludeCode, "\n\n switch (yystate) {")]; var actionGroups = {}; // used to combine identical actions into single instances: no use duplicating action code needlessly var actionGroupValue = {}; // stores the unaltered, expanded, user-defined action code for each action group. var stateHasAction = []; // marks which state IDs have an action, either user-specified or default. + // and now go and process the entire grammar: - var symbol; // and now go and process the entire grammar: - - productions.forEach(buildProductionAction); + productions.forEach(buildProductionAction, { + actionGroups: actionGroups, + actionGroupValue: actionGroupValue, + stateHasAction: stateHasAction + }); for (var hash in actionGroups) { actions.push([].concat.apply([], actionGroups[hash]).join('\n') + '\n\n' + actionGroupValue[hash] + '\n break;\n'); @@ -24567,10 +24877,10 @@ generator.buildProductionActions = function buildProductionActions() { if (missingActions.length) { if (this.DEBUG) { - this.warn("WARNING: missing actions for states: ", missingActions); + this.warn('WARNING: missing actions for states: ', missingActions); } - actions.push("default:\n // default action for all unlisted resolve states: ".concat(missingActions.join(', '), "\n\n // When we hit this entry, it's always a non-recoverable issue as this is a severe internal parser state failure:\n function __b0rk_on_internal_failure(str) {\n var hash = yyparser.constructParseErrorInfo(str, null, null, false);\n\n return yyparser.parseError(str, hash, yyparser.JisonParserError);\n }\n\n return __b0rk_on_internal_failure(\"internal parser failure: resolving unlisted state: \" + yystate);")); + actions.push("default:\n // default action for all unlisted resolve states: ".concat(missingActions.join(', '), "\n\n // When we hit this entry, it's always a non-recoverable issue as this is a severe internal parser state failure:\n function __b0rk_on_internal_failure(str) {\n let hash = yyparser.constructParseErrorInfo(str, null, null, false);\n\n return yyparser.parseError(str, hash, yyparser.JisonParserError);\n }\n\n return __b0rk_on_internal_failure(\"internal parser failure: resolving unlisted state: \" + yystate);")); } actions.push('}'); @@ -24740,9 +25050,9 @@ generator.buildProductionActions = function buildProductionActions() { this.actionsUseValueAssignment = true; break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": + case 'skip': // <-- this one injects *nothing* break; } @@ -24753,9 +25063,9 @@ generator.buildProductionActions = function buildProductionActions() { default: break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": + case 'skip': // <-- this one injects *nothing* break; } @@ -24827,7 +25137,7 @@ generator.buildProductionActions = function buildProductionActions() { moduleInit.getInitCodeSection = function getInitCodeSection(section) { var rv = []; - for (var i = 0, len = this.length; i < len; i++) { + for (var i = 0, _len12 = this.length; i < _len12; i++) { var m = this[i]; if (m.qualifier === section) { @@ -24845,11 +25155,11 @@ generator.buildProductionActions = function buildProductionActions() { moduleInit.getRemainingInitCodeSections = function getRemainingInitCodeSections() { var rv = []; - for (var i = 0, len = this.length; i < len; i++) { + for (var i = 0, _len13 = this.length; i < _len13; i++) { var m = this[i]; if (!this.__consumedInitCodeSlots__[i]) { - rv.push(rmCommonWS$5(_templateObject155(), m.qualifier, m.include, m.qualifier)); + rv.push(rmCommonWS$5(_templateObject156(), m.qualifier, m.include, m.qualifier)); this.__consumedInitCodeSlots__[i] = true; } } @@ -24926,12 +25236,11 @@ generator.buildProductionActions = function buildProductionActions() { return ''; - } + } // options object { actionGroups, actionGroupValue, stateHasAction } is `this` for this function/callback: + function buildProductionAction(handle) { - var i; - var aliased = handle.aliases, - rhs_i; + var aliased = handle.aliases; var rhs = handle.handle; var named_token_re = new XRegExp__default['default']("^".concat(ID_REGEX_BASE$3, "$")); // semantic action specified @@ -24949,7 +25258,7 @@ generator.buildProductionActions = function buildProductionActions() { var rule4msg = handle.symbol + ': ' + rhs.join(' '); assert__default['default'](typeof handle.id === 'number'); assert__default['default'](handle.id >= 0); - stateHasAction[handle.id] = true; // before anything else, replace direct symbol references, e.g. #NUMBER# when there's a %token NUMBER for your grammar. + this.stateHasAction[handle.id] = true; // before anything else, replace direct symbol references, e.g. #NUMBER# when there's a %token NUMBER for your grammar. // This is done to prevent incorrect expansions where tokens are used in rules as RHS elements: we allow these to // be referenced as both #TOKEN# and #TOKEN where the first is a literal token/symbol reference (unrelated to its use // in the rule) and the latter is a reference to the token/symbol being used in the rule. @@ -24961,9 +25270,9 @@ generator.buildProductionActions = function buildProductionActions() { }); // replace named semantic values ($nonterminal) if (action.match(new XRegExp__default['default']("(?:[$@#]|##)".concat(ID_REGEX_BASE$3)))) { - var count = {}, - names = {}, - donotalias = {}; // When the rule is fitted with aliases it doesn't mean that the action code MUST use those: + var count = {}; + var names = {}; + var donotalias = {}; // When the rule is fitted with aliases it doesn't mean that the action code MUST use those: // we therefor allow access to both the original (non)terminal and the alias. // // Also note that each (non)terminal can also be uniquely addressed by [$@] @@ -24993,7 +25302,7 @@ generator.buildProductionActions = function buildProductionActions() { // while `e2` would be ambiguous from the human perspective as he *might* then // expect `e2` and `e3`. - var addName = function addName(s) { + var addName = function addName(s, i) { var base = s.replace(/[0-9]+$/, ''); var dna = donotalias[base]; @@ -25025,9 +25334,9 @@ generator.buildProductionActions = function buildProductionActions() { } }; - for (i = 0; i < rhs.length; i++) { + for (var i = 0; i < rhs.length; i++) { // mark both regular and aliased names, e.g., `id[alias1]` and `id1` - rhs_i = aliased[i]; + var rhs_i = aliased[i]; markBasename(rhs_i); if (rhs_i !== rhs[i]) { @@ -25035,13 +25344,13 @@ generator.buildProductionActions = function buildProductionActions() { } } - for (i = 0; i < rhs.length; i++) { + for (var _i20 = 0; _i20 < rhs.length; _i20++) { // check for aliased names, e.g., id[alias] - rhs_i = aliased[i]; - addName(rhs_i); + var _rhs_i = aliased[_i20]; + addName(_rhs_i, _i20); - if (rhs_i !== rhs[i]) { - addName(rhs[i]); + if (_rhs_i !== rhs[_i20]) { + addName(rhs[_i20], _i20); } } @@ -25056,7 +25365,7 @@ generator.buildProductionActions = function buildProductionActions() { action = action // replace references to `$$` with `this.$`, `@$` with `this._$` and `#$` with the token ID of the current rule .replace(/\$\$/g, 'this.$').replace(/@\$/g, 'this._$').replace(/#\$/g, function (_) { - return provideSymbolAsSourcecode(symbol); + return provideSymbolAsSourcecode(handle.symbol); }) // replace semantic value references ($n) with stack value (stack[n]) .replace(/\$(-?\d+)\b/g, function (_, n) { return 'yyvstack[yysp' + indexToJsExpr(n, rhs.length, rule4msg) + ']'; @@ -25180,24 +25489,26 @@ generator.buildProductionActions = function buildProductionActions() { // $@ = undefined; // - var vmode = !inject_default_value_action ? "skip" : self.options.defaultActionMode[0]; - var lmode = !inject_default_loc_action ? "skip" : self.options.defaultActionMode[1]; // check if there's no user action specified. Insert default action if it isn't. + var vmode = !inject_default_value_action ? 'skip' : self.options.defaultActionMode[0]; + var lmode = !inject_default_loc_action ? 'skip' : self.options.defaultActionMode[1]; // check if there's no user action specified. Insert default action if it isn't. // first determine the actual number of terms in the production: - var rhs = handle.handle.slice(0); + var rhs_reduced_length = rhs.length; var real_rhs_length = rhs.length; // strip away EOF terms at the end of the rule, ditto for epsilon terms: - if (rhs.length) { - switch (rhs[rhs.length - 1]) { + while (rhs_reduced_length) { + switch (rhs[rhs_reduced_length - 1]) { case '$end': - rhs.length--; - break; + rhs_reduced_length--; + continue; case '': // %epsilon - rhs.length--; - break; + rhs_reduced_length--; + continue; } + + break; } // then we can choose what to do, depending on the number of terms in the production. // // There are a few reasons *why* one would choose to inject the default action: @@ -25214,18 +25525,18 @@ generator.buildProductionActions = function buildProductionActions() { // - switch (rhs.length) { + switch (rhs_reduced_length) { case 0: switch (vmode) { - case "classic": // $$ = $1; <-- but that would cause nondeterministic behaviour, so + case 'classic': // $$ = $1; <-- but that would cause nondeterministic behaviour, so // we fall back to the default here! - case "ast": - case "none": - default_action.push("this.$ = undefined;"); + case 'ast': + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25234,22 +25545,22 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // an empty production has no location as there are no terms parsed. // ergo: we produce a zero-width location which points at the tail // end of the previous content: // @$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);"); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25261,19 +25572,19 @@ generator.buildProductionActions = function buildProductionActions() { case 1: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; // // WARNING: be careful with the ACCEPT rule as that one's production has - // rhs.length === 1 **BUT** has real_rhs_length === 2 as we have discarded + // rhs_reduced_length === 1 **BUT** has real_rhs_length === 2 as we have discarded // the `$end` term at the end! // Here we need to account for that magick though! - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // As we're looking at a production which has one(1) useful term, we can simply // reference-copy that one intom a fresh array, instead of `slice()`-ing it out // of the vstack. @@ -25282,14 +25593,14 @@ generator.buildProductionActions = function buildProductionActions() { // WARNING/NOTE: as above, and ditto BTW for rule productions which end with // `EOF` as a last term: as we now construct an entire AST, we DO NOT include // those 'values' here! - default_action.push("this.$ = [yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "]];"); + default_action.push('this.$ = [yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ']];'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25298,23 +25609,23 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: // as we have a production length of 1 only, we can simply ref-copy @1: // @$ = @1; // // WARNING: same as above for the value copying: we may have discarded an `EOF` or `$end` term! - default_action.push("this._$ = yylstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this._$ = yylstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25326,31 +25637,31 @@ generator.buildProductionActions = function buildProductionActions() { default: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // - // WARNING: as with the situation further above where rhs.length === 1 after we + // WARNING: as with the situation further above where rhs_reduced_length === 1 after we // have got rid of a possible `EOF` or `$end` at the end of the production, // we again have to account for our trickery earlier and compensate the // action above: again we DO NOT include the value of the EOF/$end token in the // resulting array 'AST', hence our `slice()` end index may vary by one(1): - var end_offset = 1 - real_rhs_length + rhs.length; - default_action.push("this.$ = yyvstack.slice(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp" + ( - /* CANNOT USE indexToJsExpr(rhs.length + 1, real_rhs_length, rule4msg) HERE! */ - end_offset === 0 ? "" : " + " + end_offset) + ");"); + var end_offset = 1 - real_rhs_length + rhs_reduced_length; + default_action.push('this.$ = yyvstack.slice(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp' + ( + /* CANNOT USE indexToJsExpr(rhs_reduced_length + 1, real_rhs_length, rule4msg) HERE! */ + end_offset === 0 ? '' : ' + ' + end_offset) + ');'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25359,20 +25670,20 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: - // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs.length - 1}, yysp); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp);"); + // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs_reduced_length - 1}, yysp); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25386,7 +25697,7 @@ generator.buildProductionActions = function buildProductionActions() { if (default_action.length > 0) { - var flags = [rhs.length, self.actionsUseValueTracking ? "VT" : "-", self.actionsUseValueAssignment ? "VA" : "-", uses_$$ ? "VU" : "-", uses_$$_before_assignment ? "VUbA" : "-", self.actionsUseLocationTracking ? "LT" : "-", self.actionsUseLocationAssignment ? "LA" : "-", uses_$loc ? "LU" : "-", uses_$loc_before_assignment ? "LUbA" : "-"].join(','); + var flags = [rhs_reduced_length + '/' + real_rhs_length, self.actionsUseValueTracking ? 'VT' : '-', self.actionsUseValueAssignment ? 'VA' : '-', uses_$$ ? 'VU' : '-', uses_$$_before_assignment ? 'VUbA' : '-', self.actionsUseLocationTracking ? 'LT' : '-', self.actionsUseLocationAssignment ? 'LA' : '-', uses_$loc ? 'LU' : '-', uses_$loc_before_assignment ? 'LUbA' : '-'].join(','); default_action.unshift("// default action (generated by JISON mode ".concat(self.options.defaultActionMode[0], "/").concat(self.options.defaultActionMode[1], " :: ").concat(flags, "):")); default_action.push("// END of default action (generated by JISON mode ".concat(self.options.defaultActionMode[0], "/").concat(self.options.defaultActionMode[1], " :: ").concat(flags, ")")); @@ -25401,11 +25712,11 @@ generator.buildProductionActions = function buildProductionActions() { var actionHash = mkHashIndex(action); // Delay running the postprocess (restore) process until we've done ALL macro expansions: //action = postprocessActionCode(action); - if (actionHash in actionGroups) { - actionGroups[actionHash].push(label); + if (actionHash in this.actionGroups) { + this.actionGroups[actionHash].push(label); } else { - actionGroups[actionHash] = [label]; - actionGroupValue[actionHash] = action; + this.actionGroups[actionHash] = [label]; + this.actionGroupValue[actionHash] = action; } } }; @@ -25511,7 +25822,7 @@ generator.reportGrammarInformation = function reportGrammarInformation() { }; // --- START of debugTraceSrc chunk --- -var debugTraceSrc = "\nfunction debug_trace() {\n \"use strict\";\n\n if (typeof Jison !== 'undefined' && Jison.print) {\n Jison.print.apply(null, arguments);\n } else if (typeof print !== 'undefined') {\n print.apply(null, arguments);\n } else if (typeof console !== 'undefined' && console.log) {\n var args = Array.prototype.slice.call(arguments, 0);\n args.unshift(''); // prevent `%.` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args\n console.log.apply(null, args);\n }\n}\n"; // --- END of debugTraceSrc chunk --- +var debugTraceSrc = "\nfunction debug_trace() {\n if (typeof Jison !== 'undefined' && Jison.print) {\n Jison.print.apply(null, arguments);\n } else if (typeof print !== 'undefined') {\n print.apply(null, arguments);\n } else if (typeof console !== 'undefined' && console.log) {\n let args = Array.prototype.slice.call(arguments, 0);\n args.unshift(''); // prevent `%.` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args\n console.log.apply(null, args);\n }\n}\n"; // --- END of debugTraceSrc chunk --- // Generator debug mixin var generatorDebug = { @@ -25578,10 +25889,10 @@ lookaheadMixin.displayFollowSets = function displayFollowSets() { lookaheadMixin.followSets = function followSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true; // loop until no further changes have been made + var productions = this.productions; + var nonterminals = this.nonterminals; + var self = this; + var cont = true; // loop until no further changes have been made while (cont) { cont = false; @@ -25598,7 +25909,7 @@ lookaheadMixin.followSets = function followSets() { } var bool = !ctx || q === self.nterms_[t]; - var set; + var set = void 0; if (i === production.handle.length - 1 && bool) { set = nonterminals[production.symbol].follows; @@ -25647,25 +25958,25 @@ lookaheadMixin.first = function first(symbol) { firsts = union(firsts, this.nonterminals[t].first); } - if (!this.nullable(t)) break; + if (!this.nullable(t)) { + break; + } } return firsts; // terminal } else if (!this.nonterminals[symbol]) { return [symbol]; // nonterminal - } else { - return this.nonterminals[symbol].first; } + + return this.nonterminals[symbol].first; }; // fixed-point calculation of FIRST sets lookaheadMixin.firstSets = function firstSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true, - symbol, - firsts; // loop until no further changes have been made + var productions = this.productions; + var nonterminals = this.nonterminals; + var self = this; + var cont = true; // loop until no further changes have been made while (cont) { cont = false; @@ -25678,8 +25989,8 @@ lookaheadMixin.firstSets = function firstSets() { } }); - for (symbol in nonterminals) { - firsts = []; + var _loop2 = function _loop2(symbol) { + var firsts = []; nonterminals[symbol].productions.forEach(function FirstSets_forEachNonTerm(production) { firsts = union(firsts, production.first); }); @@ -25688,22 +25999,29 @@ lookaheadMixin.firstSets = function firstSets() { nonterminals[symbol].first = firsts; cont = true; } + }; + + for (var symbol in nonterminals) { + _loop2(symbol); } } }; // fixed-point calculation of NULLABLE lookaheadMixin.nullableSets = function nullableSets() { - var nonterminals = this.nonterminals, - self = this, - cont = true; // loop until no further changes have been made + var nonterminals = this.nonterminals; + var self = this; + var cont = true; // loop until no further changes have been made while (cont) { cont = false; // check if each production is nullable this.productions.forEach(function isEachProductionNullable(production, k) { if (!production.nullable) { - for (var i = 0, n = 0, t; t = production.handle[i]; ++i) { + var i = 0; + var n = 0; + + for (var t; t = production.handle[i]; ++i) { if (self.nullable(t)) n++; } @@ -25741,9 +26059,9 @@ lookaheadMixin.nullable = function nullable(symbol) { return true; // terminal } else if (!this.nonterminals[symbol]) { return false; // nonterminal - } else { - return this.nonterminals[symbol].nullable; } + + return this.nonterminals[symbol].nullable; }; // lookahead debug mixin @@ -25845,7 +26163,7 @@ lrGeneratorMixin.Item = typal.construct({ return s; } }); -lrGeneratorMixin.ItemSet = Set.prototype.construct({ +lrGeneratorMixin.ItemSet = Set$1.prototype.construct({ afterconstructor: function afterconstructor() { this.reductions = []; this.goes = {}; @@ -25892,12 +26210,12 @@ lrGeneratorMixin.ItemSet = Set.prototype.construct({ lrGeneratorMixin.closureOperation = function closureOperation(itemSet) { var closureSet = new this.ItemSet(); var self = this; - var set = itemSet, - itemQueue, - syms = {}; + var set = itemSet; + var itemQueue; + var syms = {}; do { - itemQueue = new Set(); + itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function CO_set_forEach(item) { var symbol = item.markedSymbol; // if token is a non-terminal, recursively add closures @@ -25930,8 +26248,8 @@ lrGeneratorMixin.closureOperation = function closureOperation(itemSet) { }; lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) { - var gotoSet = new this.ItemSet(), - self = this; + var gotoSet = new this.ItemSet(); + var self = this; itemSet.forEach(function goto_forEach(item, n) { if (item.markedSymbol === symbol) { gotoSet.push(new self.Item(item.production, item.dotPosition + 1, item.follows, n)); @@ -25946,13 +26264,13 @@ lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) { lrGeneratorMixin.canonicalCollection = function canonicalCollection() { var item1 = new this.Item(this.productions[0], 0, [this.EOF]); - var firstStateNoClosure = new this.ItemSet(item1), - firstState = this.closureOperation(firstStateNoClosure), - states = new Set(firstState), - marked = 0, - self = this, - itemSet, - markedSymbols; + var firstStateNoClosure = new this.ItemSet(item1); + var firstState = this.closureOperation(firstStateNoClosure); + var states = new Set$1(firstState); + var marked = 0; + var self = this; + var itemSet; + var markedSymbols; states.has = {}; states.has[firstStateNoClosure.valueOf()] = 0; @@ -25973,8 +26291,8 @@ lrGeneratorMixin.canonicalCollection = function canonicalCollection() { lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert(symbol, itemSet, states, stateNum) { - var g = this.gotoOperation(itemSet, symbol), - state = states.has[g.valueOf()]; + var g = this.gotoOperation(itemSet, symbol); + var state = states.has[g.valueOf()]; if (typeof state !== 'undefined') { itemSet.edges[symbol] = state; // store goto transition for table @@ -25999,12 +26317,12 @@ lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert( }; lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { - var states = [], - nonterminals = this.nonterminals, - operators = this.operators, - conflictedStates = {}, - // set of [state, token] tuples - self = this; // for each item set + var states = []; + var nonterminals = this.nonterminals; + var operators = this.operators; + var conflictedStates = {}; // set of [state, token] tuples + + var self = this; // for each item set itemSets.forEach(function parseTableItem(itemSet, k) { k = +k; @@ -26149,11 +26467,11 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { function findDefaults(states, hasErrorRecovery) { var defaults = {}; states.forEach(function (state, k) { - var act, sym, st; + var act; var i = 0; var gotos = {}; - for (sym in state) { + for (var sym in state) { assert__default['default']({}.hasOwnProperty.call(state, sym)); // it this isn't true, the last part of this function won't work! // keep state rows where there's an error recovery state: @@ -26163,7 +26481,7 @@ function findDefaults(states, hasErrorRecovery) { return; } - st = state[sym]; + var st = state[sym]; if (typeof st !== 'number') { if (st[0] !== REDUCE) { @@ -26199,11 +26517,11 @@ function findDefaults(states, hasErrorRecovery) { // when there's no error recovery code included in the generated parser: if (!hasErrorRecovery) { - for (sym in state) { - st = state[sym]; + for (var _sym2 in state) { + var _st = state[_sym2]; - if (typeof st !== 'number') { - delete state[sym]; + if (typeof _st !== 'number') { + delete state[_sym2]; } } } @@ -26215,9 +26533,7 @@ function findDefaults(states, hasErrorRecovery) { function cleanupTable(table) { table.forEach(function (state, k) { - var symbol; - - for (symbol in state) { + for (var symbol in state) { if (state[symbol] === NONASSOC) { delete state[symbol]; } @@ -26303,7 +26619,7 @@ generatorMixin.__prepareOptions = function parser___prepare_Options(opt) { }; generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComment() { - var out = "\n/* parser generated by jison ".concat(version$2, " */\n\n/*\n * Returns a Parser object of the following structure:\n *\n * Parser: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" `yy` passed around to\n * the rule actions, etc. is a derivative/copy of this one,\n * not a direct reference!\n * }\n *\n * Parser.prototype: {\n * yy: {},\n * EOF: 1,\n * TERROR: 2,\n *\n * trace: function(errorMessage, ...),\n *\n * JisonParserError: function(msg, hash),\n *\n * quoteName: function(name),\n * Helper function which can be overridden by user code later on: put suitable\n * quotes around literal IDs in a description string.\n *\n * originalQuoteName: function(name),\n * The basic quoteName handler provided by JISON.\n * `cleanupAfterParse()` will clean up and reset `quoteName()` to reference this function\n * at the end of the `parse()`.\n *\n * describeSymbol: function(symbol),\n * Return a more-or-less human-readable description of the given symbol, when\n * available, or the symbol itself, serving as its own 'description' for lack\n * of something better to serve up.\n *\n * Return NULL when the symbol is unknown to the parser.\n *\n * symbols_: {associative list: name ==> number},\n * terminals_: {associative list: number ==> name},\n * nonterminals: {associative list: rule-name ==> {associative list: number ==> rule-alt}},\n * terminal_descriptions_: (if there are any) {associative list: number ==> description},\n * productions_: [...],\n *\n * performAction: function parser__performAction(yytext, yyleng, yylineno, yyloc, yystate, yysp, yyvstack, yylstack, yystack, yysstack),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `yyval` internal object, which has members (`$` and `_$`)\n * to store/reference the rule value `$$` and location info `@$`.\n *\n * One important thing to note about `this` a.k.a. `yyval`: every *reduce* action gets\n * to see the same object via the `this` reference, i.e. if you wish to carry custom\n * data from one reduce action through to the next within a single parse run, then you\n * may get nasty and use `yyval` a.k.a. `this` for storing you own semi-permanent data.\n *\n * `this.yy` is a direct reference to the `yy` shared state object.\n *\n * `%parse-param`-specified additional `parse()` arguments have been added to this `yy`\n * object at `parse()` start and are therefore available to the action code via the\n * same named `yy.xxxx` attributes (where `xxxx` represents a identifier name from\n * the %parse-param` list.\n *\n * - `yytext` : reference to the lexer value which belongs to the last lexer token used\n * to match this rule. This is *not* the look-ahead token, but the last token\n * that's actually part of this rule.\n *\n * Formulated another way, `yytext` is the value of the token immediately preceeding\n * the current look-ahead token.\n * Caveats apply for rules which don't require look-ahead, such as epsilon rules.\n *\n * - `yyleng` : ditto as `yytext`, only now for the lexer.yyleng value.\n *\n * - `yylineno`: ditto as `yytext`, only now for the lexer.yylineno value.\n *\n * - `yyloc` : ditto as `yytext`, only now for the lexer.yylloc lexer token location info.\n *\n * WARNING: since jison 0.4.18-186 this entry may be NULL/UNDEFINED instead\n * of an empty object when no suitable location info can be provided.\n *\n * - `yystate` : the current parser state number, used internally for dispatching and\n * executing the action code chunk matching the rule currently being reduced.\n *\n * - `yysp` : the current state stack position (a.k.a. 'stack pointer')\n *\n * This one comes in handy when you are going to do advanced things to the parser\n * stacks, all of which are accessible from your action code (see the next entries below).\n *\n * Also note that you can access this and other stack index values using the new double-hash\n * syntax, i.e. `##$ === ##0 === yysp`, while `##1` is the stack index for all things\n * related to the first rule term, just like you have `$1`, `@1` and `#1`.\n * This is made available to write very advanced grammar action rules, e.g. when you want\n * to investigate the parse state stack in your action code, which would, for example,\n * be relevant when you wish to implement error diagnostics and reporting schemes similar\n * to the work described here:\n *\n * + Pottier, F., 2016. Reachability and error diagnosis in LR(1) automata.\n * In Journ\xE9es Francophones des Languages Applicatifs.\n *\n * + Jeffery, C.L., 2003. Generating LR syntax error messages from examples.\n * ACM Transactions on Programming Languages and Systems (TOPLAS), 25(5), pp.631\u2013640.\n *\n * - `yyrulelength`: the current rule's term count, i.e. the number of entries occupied on the stack.\n *\n * This one comes in handy when you are going to do advanced things to the parser\n * stacks, all of which are accessible from your action code (see the next entries below).\n *\n * - `yyvstack`: reference to the parser value stack. Also accessed via the `$1` etc.\n * constructs.\n *\n * - `yylstack`: reference to the parser token location stack. Also accessed via\n * the `@1` etc. constructs.\n *\n * WARNING: since jison 0.4.18-186 this array MAY contain slots which are\n * UNDEFINED rather than an empty (location) object, when the lexer/parser\n * action code did not provide a suitable location info object when such a\n * slot was filled!\n *\n * - `yystack` : reference to the parser token id stack. Also accessed via the\n * `#1` etc. constructs.\n *\n * Note: this is a bit of a **white lie** as we can statically decode any `#n` reference to\n * its numeric token id value, hence that code wouldn't need the `yystack` but *you* might\n * want access this array for your own purposes, such as error analysis as mentioned above!\n *\n * Note that this stack stores the current stack of *tokens*, that is the sequence of\n * already parsed=reduced *nonterminals* (tokens representing rules) and *terminals*\n * (lexer tokens *shifted* onto the stack until the rule they belong to is found and\n * *reduced*.\n *\n * - `yysstack`: reference to the parser state stack. This one carries the internal parser\n * *states* such as the one in `yystate`, which are used to represent\n * the parser state machine in the *parse table*. *Very* *internal* stuff,\n * what can I say? If you access this one, you're clearly doing wicked things\n *\n * - `...` : the extra arguments you specified in the `%parse-param` statement in your\n * grammar definition file.\n *\n * table: [...],\n * State transition table\n * ----------------------\n *\n * index levels are:\n * - `state` --> hash table\n * - `symbol` --> action (number or array)\n *\n * If the `action` is an array, these are the elements' meaning:\n * - index [0]: 1 = shift, 2 = reduce, 3 = accept\n * - index [1]: GOTO `state`\n *\n * If the `action` is a number, it is the GOTO `state`\n *\n * defaultActions: {...},\n *\n * parseError: function(str, hash, ExceptionClass),\n * yyError: function(str, ...),\n * yyRecovering: function(),\n * yyErrOk: function(),\n * yyClearIn: function(),\n *\n * constructParseErrorInfo: function(error_message, exception_object, expected_token_set, is_recoverable),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.\n * See it's use in this parser kernel in many places; example usage:\n *\n * var infoObj = parser.constructParseErrorInfo('fail!', null,\n * parser.collect_expected_token_set(state), true);\n * var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError);\n *\n * originalParseError: function(str, hash, ExceptionClass),\n * The basic `parseError` handler provided by JISON.\n * `cleanupAfterParse()` will clean up and reset `parseError()` to reference this function\n * at the end of the `parse()`.\n *\n * options: { ... parser %options ... },\n *\n * parse: function(input[, args...]),\n * Parse the given `input` and return the parsed value (or `true` when none was provided by\n * the root action, in which case the parser is acting as a *matcher*).\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of this grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Parser's additional `args...` parameters (via `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * The lexer MAY add its own set of additional parameters (via the `%parse-param` line in\n * the lexer section of the grammar spec): these will be inserted in the `yy` shared state\n * object and any collision with those will be reported by the lexer via a thrown exception.\n *\n * cleanupAfterParse: function(resultValue, invoke_post_methods, do_not_nuke_errorinfos),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * This helper API is invoked at the end of the `parse()` call, unless an exception was thrown\n * and `%options no-try-catch` has been defined for this grammar: in that case this helper MAY\n * be invoked by calling user code to ensure the `post_parse` callbacks are invoked and\n * the internal parser gets properly garbage collected under these particular circumstances.\n *\n * yyMergeLocationInfo: function(first_index, last_index, first_yylloc, last_yylloc, dont_look_back),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * This helper API can be invoked to calculate a spanning `yylloc` location info object.\n *\n * Note: %epsilon rules MAY specify no `first_index` and `first_yylloc`, in which case\n * this function will attempt to obtain a suitable location marker by inspecting the location stack\n * backwards.\n *\n * For more info see the documentation comment further below, immediately above this function's\n * implementation.\n *\n * lexer: {\n * yy: {...}, A reference to the so-called \"shared state\" `yy` once\n * received via a call to the `.setInput(input, yy)` lexer API.\n * EOF: 1,\n * ERROR: 2,\n * JisonLexerError: function(msg, hash),\n * parseError: function(str, hash, ExceptionClass),\n * setInput: function(input, [yy]),\n * input: function(),\n * unput: function(str),\n * more: function(),\n * reject: function(),\n * less: function(n),\n * pastInput: function(n),\n * upcomingInput: function(n),\n * showPosition: function(),\n * test_match: function(regex_match_array, rule_index, ...),\n * next: function(...),\n * lex: function(...),\n * begin: function(condition),\n * pushState: function(condition),\n * popState: function(),\n * topState: function(),\n * _currentRules: function(),\n * stateStackSize: function(),\n * cleanupAfterLex: function()\n *\n * options: { ... lexer %options ... },\n *\n * performAction: function(yy, yy_, $avoiding_name_collisions, YY_START, ...),\n * rules: [...],\n * conditions: {associative list: name ==> set},\n * }\n * }\n *\n *\n * token location info (@$, _$, etc.): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a 'hash' object with these members for lexer and\n * parser errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * }\n *\n * parser (grammar) errors will also provide these additional members:\n *\n * {\n * expected: (array describing the set of expected tokens;\n * may be UNDEFINED when we cannot easily produce such a set)\n * state: (integer (or array when the table includes grammar collisions);\n * represents the current internal state of the parser kernel.\n * can, for example, be used to pass to the `collect_expected_token_set()`\n * API to obtain the expected token set)\n * action: (integer; represents the current internal action which will be executed)\n * new_state: (integer; represents the next/planned internal state, once the current\n * action has executed)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * state_stack: (array: the current parser LALR/LR internal state stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * value_stack: (array: the current parser LALR/LR internal `$$` value stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * location_stack: (array: the current parser LALR/LR internal location stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * yy: (object: the current parser internal \"shared state\" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * parser: (reference to the current parser instance)\n * }\n *\n * while `this` will reference the current parser instance.\n *\n * When `parseError` is invoked by the lexer, `this` will still reference the related *parser*\n * instance, while these additional `hash` fields will also be provided:\n *\n * {\n * lexer: (reference to the current lexer instance which reported the error)\n * }\n *\n * When `parseError` is invoked by the parser due to a **JavaScript exception** being fired\n * from either the parser or lexer, `this` will still reference the related *parser*\n * instance, while these additional `hash` fields will also be provided:\n *\n * {\n * exception: (reference to the exception thrown)\n * }\n *\n * Please do note that in the latter situation, the `expected` field will be omitted as\n * this type of failure is assumed not to be due to *parse errors* but rather due to user\n * action code in either parser or lexer failing unexpectedly.\n *\n * ---\n *\n * You can specify parser options by setting / modifying the `.yy` object of your Parser instance.\n * These options are available:\n *\n * ### options which are global for all parser instances\n *\n * Parser.pre_parse: function(yy)\n * optional: you can specify a pre_parse() function in the chunk following\n * the grammar, i.e. after the last `%%`.\n * Parser.post_parse: function(yy, retval, parseInfo) { return retval; }\n * optional: you can specify a post_parse() function in the chunk following\n * the grammar, i.e. after the last `%%`. When it does not return any value,\n * the parser will return the original `retval`.\n *\n * ### options which can be set up per parser instance\n *\n * yy: {\n * pre_parse: function(yy)\n * optional: is invoked before the parse cycle starts (and before the first\n * invocation of `lex()`) but immediately after the invocation of\n * `parser.pre_parse()`).\n * post_parse: function(yy, retval, parseInfo) { return retval; }\n * optional: is invoked when the parse terminates due to success ('accept')\n * or failure (even when exceptions are thrown).\n * `retval` contains the return value to be produced by `Parser.parse()`;\n * this function can override the return value by returning another.\n * When it does not return any value, the parser will return the original\n * `retval`.\n * This function is invoked immediately before `parser.post_parse()`.\n *\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * quoteName: function(name),\n * optional: overrides the default `quoteName` function.\n * }\n *\n * parser.lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean (\u214F \uC13C \u214A \u2056 \u2058 \u2059 \u205A \u205B \u205C \u205D \u205E \u2020 \u2021 \n a\u2BC8b\n \u2200 \u2201 \u2202 \u2203 \u2204 \u2205 \u2206 \u2207 \u2208 \u2209 \u220A \u220B \u220C \u220D \u220E \u220F\nU+221x \u2210 \u2211 \u2212 \u2213 \u2214 \u2215 \u2216 \u2217 \u2218 \u2219 \u221A \u221B \u221C \u221D \u221E \u221F\nU+222x \u2220 \u2221 \u2222 \u2223 \u2224 \u2225 \u2226 \u2227 \u2228 \u2229 \u222A \u222B \u222C \u222D \u222E \u222F\nU+223x \u2230 \u2231 \u2232 \u2233 \u2234 \u2235 \u2236 \u2237 \u2238 \u2239 \u223A \u223B \u223C \u223D \u223E \u223F\nU+224x \u2240 \u2241 \u2242 \u2243 \u2244 \u2245 \u2246 \u2247 \u2248 \u2249 \u224A \u224B \u224C \u224D \u224E \u224F\nU+225x \u2250 \u2251 \u2252 \u2253 \u2254 \u2255 \u2256 \u2257 \u2258 \u2259 \u225A \u225B \u225C \u225D \u225E \u225F\nU+226x \u2260 \u2261 \u2262 \u2263 \u2264 \u2265 \u2266 \u2267 \u2268 \u2269 \u226A \u226B \u226C \u226D \u226E \u226F\nU+227x \u2270 \u2271 \u2272 \u2273 \u2274 \u2275 \u2276 \u2277 \u2278 \u2279 \u227A \u227B \u227C \u227D \u227E \u227F\nU+228x \u2280 \u2281 \u2282 \u2283 \u2284 \u2285 \u2286 \u2287 \u2288 \u2289 \u228A \u228B \u228C \u228D \u228E \u228F\nU+229x \u2290 \u2291 \u2292 \u2293 \u2294 \u2295 \u2296 \u2297 \u2298 \u2299 \u229A \u229B \u229C \u229D \u229E \u229F\nU+22Ax \u22A0 \u22A1 \u22A2 \u22A3 \u22A4 \u22A5 \u22A6 \u22A7 \u22A8 \u22A9 \u22AA \u22AB \u22AC \u22AD \u22AE \u22AF\nU+22Bx \u22B0 \u22B1 \u22B2 \u22B3 \u22B4 \u22B5 \u22B6 \u22B7 \u22B8 \u22B9 \u22BA \u22BB \u22BC \u22BD \u22BE \u22BF\nU+22Cx \u22C0 \u22C1 \u22C2 \u22C3 \u22C4 \u22C5 \u22C6 \u22C7 \u22C8 \u22C9 \u22CA \u22CB \u22CC \u22CD \u22CE \u22CF\nU+22Dx \u22D0 \u22D1 \u22D2 \u22D3 \u22D4 \u22D5 \u22D6 \u22D7 \u22D8 \u22D9 \u22DA \u22DB \u22DC \u22DD \u22DE \u22DF\nU+22Ex \u22E0 \u22E1 \u22E2 \u22E3 \u22E4 \u22E5 \u22E6 \u22E7 \u22E8 \u22E9 \u22EA \u22EB \u22EC \u22ED \u22EE \u22EF\nU+22Fx \u22F0 \u22F1 \u22F2 \u22F3 \u22F4 \u22F5 \u22F6 \u22F7 \u22F8 \u22F9 \u22FA \u22FB \u22FC \u22FD \u22FE \u22FF)\nU+230x \u2300 \u2301 \u2302 \u2303 \u2304 \u2305 \u2306 \u2307 \u2308 \u2309 \u230A \u230B \u230C \u230D \u230E \u230F\nU+231x \u2310 \u2311 \u2312 \u2313 \u2314 \u2315 \u2316 \u2317 \u2318 \u2319 \u231A \u231B \u231C \u231D \u231E \u231F\nU+232x \u2320 \u2321 \u2322 \u2323 \u2324 \u2325 \u2326 \u2327 \u2328 \u2329 \u232A \u232B \u232C \u232D \u232E \u232F\nU+233x \u2330 \u2331 \u2332 \u2333 \u2334 \u2335 \u2336 \u2337 \u2338 \u2339 \u233A \u233B \u233C \u233D \u233E \u233F\nU+234x \u2340 \u2341 \u2342 \u2343 \u2344 \u2345 \u2346 \u2347 \u2348 \u2349 \u234A \u234B \u234C \u234D \u234E \u234F\nU+235x \u2350 \u2351 \u2352 \u2353 \u2354 \u2355 \u2356 \u2357 \u2358 \u2359 \u235A \u235B \u235C \u235D \u235E \u235F\nU+236x \u2360 \u2361 \u2362 \u2363 \u2364 \u2365 \u2366 \u2367 \u2368 \u2369 \u236A \u236B \u236C \u236D \u236E \u236F\nU+237x \u2370 \u2371 \u2372 \u2373 \u2374 \u2375 \u2376 \u2377 \u2378 \u2379 \u237A \u237B \u237C \u237D \u237E \u237F\nU+238x \u2380 \u2381 \u2382 \u2383 \u2384 \u2385 \u2386 \u2387 \u2388 \u2389 \u238A \u238B \u238C \u238D \u238E \u238F\nU+239x \u2390 \u2391 \u2392 \u2393 \u2394 \u2395 \u2396 \u2397 \u2398 \u2399 \u239A \u239B \u239C \u239D \u239E \u239F\nU+23Ax \u23A0 \u23A1 \u23A2 \u23A3 \u23A4 \u23A5 \u23A6 \u23A7 \u23A8 \u23A9 \u23AA \u23AB \u23AC \u23AD \u23AE \u23AF\nU+23Bx \u23B0 \u23B1 \u23B2 \u23B3 \u23B4 \u23B5 \u23B6 \u23B7 \u23B8 \u23B9 \u23BA \u23BB \u23BC \u23BD \u23BE \u23BF\nU+23Cx \u23C0 \u23C1 \u23C2 \u23C3 \u23C4 \u23C5 \u23C6 \u23C7 \u23C8 \u23C9 \u23CA \u23CB \u23CC \u23CD \u23CE \u23CF\nU+23Dx \u23D0 \u23D1 \u23D2 \u23D3 \u23D4 \u23D5 \u23D6 \u23D7 \u23D8 \u23D9 \u23DA \u23DB \u23DC \u23DD \u23DE \u23DF\nU+23Ex \u23E0 \u23E1 \u23E2 \u23E3 \u23E4 \u23E5 \u23E6 \u23E7 \u23E8 \u23E9 \u23EA \u23EB \u23EC \u23ED \u23EE \u23EF\nU+23Fx \u23F0 \u23F1 \u23F2 \u23F3 \u23F4 \u23F5 \u23F6 \u23F7 \u23F8 \u23F9 \u23FA \u23FB \u23FC \u23FD \u23FE \u23FF\n\nU+260x \u2600 \u2601 \u2602 \u2603 \u2604 \u2605 \u2606 \u2607 \u2608 \u2609 \u260A \u260B \u260C \u260D \u260E \u260F\nU+261x \u2610 \u2611 \u2612 \u2613 \u2614 \u2615 \u2616 \u2617 \u2618 \u2619 \u261A \u261B \u261C \u261D \u261E \u261F\nU+262x \u2620 \u2621 \u2622 \u2623 \u2624 \u2625 \u2626 \u2627 \u2628 \u2629 \u262A \u262B \u262C \u262D \u262E \u262F\nU+263x \u2630 \u2631 \u2632 \u2633 \u2634 \u2635 \u2636 \u2637 \u2638 \u2639 \u263A \u263B \u263C \u263D \u263E \u263F\nU+264x \u2640 \u2641 \u2642 \u2643 \u2644 \u2645 \u2646 \u2647 \u2648 \u2649 \u264A \u264B \u264C \u264D \u264E \u264F\nU+265x \u2650 \u2651 \u2652 \u2653 \u2654 \u2655 \u2656 \u2657 \u2658 \u2659 \u265A \u265B \u265C \u265D \u265E \u265F\nU+266x \u2660 \u2661 \u2662 \u2663 \u2664 \u2665 \u2666 \u2667 \u2668 \u2669 \u266A \u266B \u266C \u266D \u266E \u266F\nU+267x \u2670 \u2671 \u2672 \u2673 \u2674 \u2675 \u2676 \u2677 \u2678 \u2679 \u267A \u267B \u267C \u267D \u267E \u267F\nU+268x \u2680 \u2681 \u2682 \u2683 \u2684 \u2685 \u2686 \u2687 \u2688 \u2689 \u268A \u268B \u268C \u268D \u268E \u268F\nU+269x \u2690 \u2691 \u2692 \u2693 \u2694 \u2695 \u2696 \u2697 \u2698 \u2699 \u269A \u269B \u269C \u269D \u269E \u269F\nU+26Ax \u26A0 \u26A1 \u26A2 \u26A3 \u26A4 \u26A5 \u26A6 \u26A7 \u26A8 \u26A9 \u26AA \u26AB \u26AC \u26AD \u26AE \u26AF\nU+26Bx \u26B0 \u26B1 \u26B2 \u26B3 \u26B4 \u26B5 \u26B6 \u26B7 \u26B8 \u26B9 \u26BA \u26BB \u26BC \u26BD \u26BE \u26BF\nU+26Cx \u26C0 \u26C1 \u26C2 \u26C3 \u26C4 \u26C5 \u26C6 \u26C7 \u26C8 \u26C9 \u26CA \u26CB \u26CC \u26CD \u26CE \u26CF\nU+26Dx \u26D0 \u26D1 \u26D2 \u26D3 \u26D4 \u26D5 \u26D6 \u26D7 \u26D8 \u26D9 \u26DA \u26DB \u26DC \u26DD \u26DE \u26DF\nU+26Ex \u26E0 \u26E1 \u26E2 \u26E3 \u26E4 \u26E5 \u26E6 \u26E7 \u26E8 \u26E9 \u26EA \u26EB \u26EC \u26ED \u26EE \u26EF\nU+26Fx \u26F0 \u26F1 \u26F2 \u26F3 \u26F4 \u26F5 \u26F6 \u26F7 \u26F8 \u26F9 \u26FA \u26FB \u26FC \u26FD \u26FE \u26FF\n\n \u2701 \u2702 \u2703 \u2704 \u2705 \u2706 \u2707 \u2708 \u2709 \u261B \u261E \u270C \u270D \u270E \u270F\n\u2710 \u2711 \u2712 \u2713 \u2714 \u2715 \u2716 \u2717 \u2718 \u2719 \u271A \u271B \u271C \u271D \u271E \u271F\n\u2720 \u2721 \u2722 \u2723 \u2724 \u2725 \u2726 \u2727 \u2605 \u2729 \u272A \u272B \u272C \u272D \u272E \u272F\n\u2730 \u2731 \u2732 \u2733 \u2734 \u2735 \u2736 \u2737 \u2738 \u2739 \u273A \u273B \u273C \u273D \u273E \u273F\n\u2740 \u2741 \u2742 \u2743 \u2744 \u2745 \u2746 \u2747 \u2748 \u2749 \u274A \u274B \u25CF \u274D \u25A0 \u274F\n\u263A \u263B \u2665 \u2666 \u2663 \u2660 \u2022 \u25D8 \u25CB \u2750 \u2751 \u2752 \u25B2 \u25BC \u25C6 \u2756\n\u25D7 \u2758 \u2759 \u275A \u275B \u275C \u275D \u275E \n\nU+270x \u2700 \u2701 \u2702 \u2703 \u2704 \u2705 \u2706 \u2707 \u2708 \u2709 \u270A \u270B \u270C \u270D \u270E \u270F\nU+271x \u2710 \u2711 \u2712 \u2713 \u2714 \u2715 \u2716 \u2717 \u2718 \u2719 \u271A \u271B \u271C \u271D \u271E \u271F\nU+272x \u2720 \u2721 \u2722 \u2723 a\u2724b a\u2725b a\u2726b a\u2727b \u2728 \u2729 \u272A \u272B \u272C \u272D \u272E \u272F\nU+273x \u2730 \u2731 \u2732 \u2733 \u2734 \u2735 \u2736 \u2737 \u2738 \u2739 \u273A \u273B \u273C \u273D \u273E \u273F\nU+274x \u2740 \u2741 \u2742 \u2743 \u2744 \u2745 \u2746 \u2747 \u2748 \u2749 \u274A \u274B \u274C \u274D \u274E \u274F\nU+275x \u2750 \u2751 \u2752 \u2753 \u2754 \u2755 \u2756 \u2757 \u2758 \u2759 \u275A \u275B \u275C \u275D \u275E \u275F\nU+276x \u2760 \u2761 \u2762 \u2763 \u2764 \u2765 \u2766 \u2767 \u2768 \u2769 \u276A \u276B \u276C \u276D \u276E a\u276Fb\nU+277x \u2770 \u2771 \u2772 \u2773 \u2774 \u2775 \u2776 \u2777 \u2778 \u2779 \u277A \u277B \u277C \u277D \u277E \u277F\nU+278x \u2780 \u2781 \u2782 \u2783 \u2784 \u2785 \u2786 \u2787 \u2788 \u2789 \u278A \u278B \u278C \u278D \u278E \u278F\nU+279x \u2790 \u2791 \u2792 \u2793 \u2794 \u2795 \u2796 \u2797 \u2798 \u2799 \u279A \u279B \u279C \u279D \u279E \u279F\nU+27Ax \u27A0 \u27A1 \u27A2 \u27A3 \u27A4 \u27A5 \u27A6 \u27A7 a\u27A8b \u27A9 \u27AA \u27AB \u27AC \u27AD \u27AE \u27AF\nU+27Bx \u27B0 a\u27B1b \u27B2 \u27B3 \u27B4 \u27B5 \u27B6 \u27B7 \u27B8 \u27B9 \u27BA \u27BB \u27BC \u27BD \u27BE \u27BF\n\nU+2580 \u2580 Upper half block\nU+2581 \u2581 Lower one eighth block\nU+2582 \u2582 Lower one quarter block\nU+2583 \u2583 Lower three eighths block\nU+2584 \u2584 Lower half block\nU+2585 \u2585 Lower five eighths block\nU+2586 \u2586 Lower three quarters block\nU+2587 \u2587 Lower seven eighths block\nU+2588 \u2588 Full block\nU+2589 \u2589 Left seven eighths block\nU+258A \u258A Left three quarters block\nU+258B \u258B Left five eighths block\nU+258C \u258C Left half block\nU+258D \u258D Left three eighths block\nU+258E \u258E Left one quarter block\nU+258F \u258F Left one eighth block\nU+2590 \u2590 Right half block\nU+2591 \u2591 Light shade\nU+2592 \u2592 Medium shade\nU+2593 \u2593 Dark shade\nU+2594 \u2594 Upper one eighth block\nU+2595 \u2595 Right one eighth block\nU+2596 \u2596 Quadrant lower left\nU+2597 \u2597 Quadrant lower right\nU+2598 \u2598 Quadrant upper left\nU+2599 \u2599 Quadrant upper left and lower left and lower right\nU+259A \u259A Quadrant upper left and lower right\nU+259B \u259B Quadrant upper left and upper right and lower left\nU+259C \u259C Quadrant upper left and upper right and lower right\nU+259D \u259D Quadrant upper right\nU+259E \u259E Quadrant upper right and lower left\nU+259F \u259F Quadrant upper right and lower left and lower right\nGeometric Shapes\nMain articles: Geometric Shapes (Unicode block) and Geometric Shapes Extended (Unicode block)\n[hide]Code Glyph Description\nU+25A0 \u25A0 Black square\nU+25A1 \u25A1 White square\nU+25A2 \u25A2 White square with rounded corners\nU+25A3 \u25A3 White square containing small black square\nU+25A4 \u25A4 Square with horizontal fill\nU+25A5 \u25A5 Square with vertical fill\nU+25A6 \u25A6 Square with orthogonal crosshatch fill\nU+25A7 \u25A7 Square with upper left to lower right fill\nU+25A8 \u25A8 Square with upper right to lower left fill\nU+25A9 \u25A9 Square with diagonal crosshatch fill\nU+25AA \u25AA Black small square\nU+25AB \u25AB White small square\nU+25AC \u25AC Black rectangle\nU+25AD \u25AD White rectangle\nU+25AE \u25AE Black vertical rectangle\nU+25AF \u25AF White vertical rectangle\nU+25B0 \u25B0 Black parallelogram\nU+25B1 \u25B1 White parallelogram\nU+25B2 \u25B2 Black up-pointing triangle\nU+25B3 \u25B3 White up-pointing triangle\nU+25B4 \u25B4 Black up-pointing small triangle\nU+25B5 \u25B5 White up-pointing small triangle\nU+25B6 \u25B6 Black right-pointing triangle\nU+25B7 \u25B7 White right-pointing triangle\nU+25B8 \u25B8 Black right-pointing small triangle\nU+25B9 \u25B9 White right-pointing small triangle\nU+25BA \u25BA Black right-pointing pointer\nU+25BB \u25BB White right-pointing pointer\nU+25BC \u25BC Black down-pointing triangle\nU+25BD \u25BD White down-pointing triangle\nU+25BE \u25BE Black down-pointing small triangle\nU+25BF \u25BF White down-pointing small triangle\nU+25C0 \u25C0 Black left-pointing triangle\nU+25C1 \u25C1 White left-pointing triangle\nU+25C2 \u25C2 Black left-pointing small triangle\nU+25C3 \u25C3 White left-pointing small triangle\nU+25C4 \u25C4 Black left-pointing pointer\nU+25C5 \u25C5 White left-pointing pointer\nU+25C6 \u25C6 Black diamond\nU+25C7 \u25C7 White diamond\nU+25C8 \u25C8 White diamond containing small black diamond\nU+25C9 \u25C9 Fisheye\nU+25CA \u25CA Lozenge\nU+25CB \u25CB White circle\nU+25CC \u25CC Dotted circle\nU+25CD \u25CD Circle with vertical fill\nU+25CE \u25CE Bullseye\nU+25CF \u25CF Black circle\nU+25D0 \u25D0 Circle with left half black\nU+25D1 \u25D1 Circle with right half black\nU+25D2 \u25D2 Circle with lower half black\nU+25D3 \u25D3 Circle with upper half black\nU+25D4 \u25D4 Circle with upper right quadrant black\nU+25D5 \u25D5 Circle with all but upper left quadrant black\nU+25D6 \u25D6 Left half circle black\nU+25D7 \u25D7 Right half black circle\nU+25D8 \u25D8 Inverse bullet\nU+25D9 \u25D9 Inverse white circle\nU+25DA \u25DA Upper half inverse white circle\nU+25DB \u25DB Lower half inverse white circle\nU+25DC \u25DC Upper left quadrant circular arc\nU+25DD \u25DD Upper right quadrant circular arc\nU+25DE \u25DE Lower right quadrant circular arc\nU+25DF \u25DF Lower left quadrant circular arc\nU+25E0 \u25E0 Upper half circle\nU+25E1 \u25E1 Lower half circle\nU+25E2 \u25E2 Black lower right triangle\nU+25E3 \u25E3 Black lower left triangle\nU+25E4 \u25E4 Black upper left triangle\nU+25E5 \u25E5 Black upper right triangle\nU+25E6 \u25E6 White bullet\nU+25E7 \u25E7 Square with left half black\nU+25E8 \u25E8 Square with right half black\nU+25E9 \u25E9 Square with upper left diagonal half black\nU+25EA \u25EA Square with lower right diagonal half black\nU+25EB \u25EB White square with vertical bisecting line\nU+25EC \u25EC White up-pointing triangle with dot\nU+25ED \u25ED Up-pointing triangle with left half black\nU+25EE \u25EE Up-pointing triangle with right half black\nU+25EF \u25EF Large circle\nU+25F0 \u25F0 White square with upper left quadrant\nU+25F1 \u25F1 White square with lower left quadrant\nU+25F2 \u25F2 White square with lower right quadrant\nU+25F3 \u25F3 White square with upper right quadrant\nU+25F4 \u25F4 White circle with upper left quadrant\nU+25F5 \u25F5 White circle with lower left quadrant\nU+25F6 \u25F6 White circle with lower right quadrant\nU+25F7 \u25F7 White circle with upper right quadrant\nU+25F8 \u25F8 Upper left triangle\nU+25F9 \u25F9 Upper right triangle\nU+25FA \u25FA Lower-left triangle\nU+25FB \u25FB White medium square\nU+25FC \u25FC Black medium square\nU+25FD \u25FD White medium small square\nU+25FE \u25FE Black medium small square\nU+25FF \u25FF Lower right triangle\n\n\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are \"extended regex format\" requiring the\n * `XRegExp` library. When this `%option` has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n"); + var out = "\n/* parser generated by jison ".concat(version$2, " */\n\n/*\n * Returns a Parser object of the following structure:\n *\n * Parser: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" `yy` passed around to\n * the rule actions, etc. is a derivative/copy of this one,\n * not a direct reference!\n * }\n *\n * Parser.prototype: {\n * yy: {},\n * EOF: 1,\n * TERROR: 2,\n *\n * trace: function(errorMessage, ...),\n *\n * JisonParserError: function(msg, hash),\n *\n * quoteName: function(name),\n * Helper function which can be overridden by user code later on: put suitable\n * quotes around literal IDs in a description string.\n *\n * originalQuoteName: function(name),\n * The basic quoteName handler provided by JISON.\n * `cleanupAfterParse()` will clean up and reset `quoteName()` to reference this function\n * at the end of the `parse()`.\n *\n * describeSymbol: function(symbol),\n * Return a more-or-less human-readable description of the given symbol, when\n * available, or the symbol itself, serving as its own 'description' for lack\n * of something better to serve up.\n *\n * Return NULL when the symbol is unknown to the parser.\n *\n * symbols_: {associative list: name ==> number},\n * terminals_: {associative list: number ==> name},\n * nonterminals: {associative list: rule-name ==> {associative list: number ==> rule-alt}},\n * terminal_descriptions_: (if there are any) {associative list: number ==> description},\n * productions_: [...],\n *\n * performAction: function parser__performAction(yytext, yyleng, yylineno, yyloc, yystate, yysp, yyvstack, yylstack, yystack, yysstack),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `yyval` internal object, which has members (`$` and `_$`)\n * to store/reference the rule value `$$` and location info `@$`.\n *\n * One important thing to note about `this` a.k.a. `yyval`: every *reduce* action gets\n * to see the same object via the `this` reference, i.e. if you wish to carry custom\n * data from one reduce action through to the next within a single parse run, then you\n * may get nasty and use `yyval` a.k.a. `this` for storing you own semi-permanent data.\n *\n * `this.yy` is a direct reference to the `yy` shared state object.\n *\n * `%parse-param`-specified additional `parse()` arguments have been added to this `yy`\n * object at `parse()` start and are therefore available to the action code via the\n * same named `yy.xxxx` attributes (where `xxxx` represents a identifier name from\n * the %parse-param` list.\n *\n * - `yytext` : reference to the lexer value which belongs to the last lexer token used\n * to match this rule. This is *not* the look-ahead token, but the last token\n * that's actually part of this rule.\n *\n * Formulated another way, `yytext` is the value of the token immediately preceeding\n * the current look-ahead token.\n * Caveats apply for rules which don't require look-ahead, such as epsilon rules.\n *\n * - `yyleng` : ditto as `yytext`, only now for the lexer.yyleng value.\n *\n * - `yylineno`: ditto as `yytext`, only now for the lexer.yylineno value.\n *\n * - `yyloc` : ditto as `yytext`, only now for the lexer.yylloc lexer token location info.\n *\n * WARNING: since jison 0.4.18-186 this entry may be NULL/UNDEFINED instead\n * of an empty object when no suitable location info can be provided.\n *\n * - `yystate` : the current parser state number, used internally for dispatching and\n * executing the action code chunk matching the rule currently being reduced.\n *\n * - `yysp` : the current state stack position (a.k.a. 'stack pointer')\n *\n * This one comes in handy when you are going to do advanced things to the parser\n * stacks, all of which are accessible from your action code (see the next entries below).\n *\n * Also note that you can access this and other stack index values using the new double-hash\n * syntax, i.e. `##$ === ##0 === yysp`, while `##1` is the stack index for all things\n * related to the first rule term, just like you have `$1`, `@1` and `#1`.\n * This is made available to write very advanced grammar action rules, e.g. when you want\n * to investigate the parse state stack in your action code, which would, for example,\n * be relevant when you wish to implement error diagnostics and reporting schemes similar\n * to the work described here:\n *\n * + Pottier, F., 2016. Reachability and error diagnosis in LR(1) automata.\n * In Journ\xE9es Francophones des Languages Applicatifs.\n *\n * + Jeffery, C.L., 2003. Generating LR syntax error messages from examples.\n * ACM Transactions on Programming Languages and Systems (TOPLAS), 25(5), pp.631\u2013640.\n *\n * - `yyrulelength`: the current rule's term count, i.e. the number of entries occupied on the stack.\n *\n * This one comes in handy when you are going to do advanced things to the parser\n * stacks, all of which are accessible from your action code (see the next entries below).\n *\n * - `yyvstack`: reference to the parser value stack. Also accessed via the `$1` etc.\n * constructs.\n *\n * - `yylstack`: reference to the parser token location stack. Also accessed via\n * the `@1` etc. constructs.\n *\n * WARNING: since jison 0.4.18-186 this array MAY contain slots which are\n * UNDEFINED rather than an empty (location) object, when the lexer/parser\n * action code did not provide a suitable location info object when such a\n * slot was filled!\n *\n * - `yystack` : reference to the parser token id stack. Also accessed via the\n * `#1` etc. constructs.\n *\n * Note: this is a bit of a **white lie** as we can statically decode any `#n` reference to\n * its numeric token id value, hence that code wouldn't need the `yystack` but *you* might\n * want access this array for your own purposes, such as error analysis as mentioned above!\n *\n * Note that this stack stores the current stack of *tokens*, that is the sequence of\n * already parsed=reduced *nonterminals* (tokens representing rules) and *terminals*\n * (lexer tokens *shifted* onto the stack until the rule they belong to is found and\n * *reduced*.\n *\n * - `yysstack`: reference to the parser state stack. This one carries the internal parser\n * *states* such as the one in `yystate`, which are used to represent\n * the parser state machine in the *parse table*. *Very* *internal* stuff,\n * what can I say? If you access this one, you're clearly doing wicked things\n *\n * - `...` : the extra arguments you specified in the `%parse-param` statement in your\n * grammar definition file.\n *\n * table: [...],\n * State transition table\n * ----------------------\n *\n * index levels are:\n * - `state` --> hash table\n * - `symbol` --> action (number or array)\n *\n * If the `action` is an array, these are the elements' meaning:\n * - index [0]: 1 = shift, 2 = reduce, 3 = accept\n * - index [1]: GOTO `state`\n *\n * If the `action` is a number, it is the GOTO `state`\n *\n * defaultActions: {...},\n *\n * parseError: function(str, hash, ExceptionClass),\n * yyError: function(str, ...),\n * yyRecovering: function(),\n * yyErrOk: function(),\n * yyClearIn: function(),\n *\n * constructParseErrorInfo: function(error_message, exception_object, expected_token_set, is_recoverable),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.\n * See it's use in this parser kernel in many places; example usage:\n *\n * let infoObj = parser.constructParseErrorInfo('fail!', null,\n * parser.collect_expected_token_set(state), true);\n * let retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError);\n *\n * originalParseError: function(str, hash, ExceptionClass),\n * The basic `parseError` handler provided by JISON.\n * `cleanupAfterParse()` will clean up and reset `parseError()` to reference this function\n * at the end of the `parse()`.\n *\n * options: { ... parser %options ... },\n *\n * parse: function(input[, args...]),\n * Parse the given `input` and return the parsed value (or `true` when none was provided by\n * the root action, in which case the parser is acting as a *matcher*).\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of this grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Parser's additional `args...` parameters (via `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * The lexer MAY add its own set of additional parameters (via the `%parse-param` line in\n * the lexer section of the grammar spec): these will be inserted in the `yy` shared state\n * object and any collision with those will be reported by the lexer via a thrown exception.\n *\n * cleanupAfterParse: function(resultValue, invoke_post_methods, do_not_nuke_errorinfos),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * This helper API is invoked at the end of the `parse()` call, unless an exception was thrown\n * and `%options no-try-catch` has been defined for this grammar: in that case this helper MAY\n * be invoked by calling user code to ensure the `post_parse` callbacks are invoked and\n * the internal parser gets properly garbage collected under these particular circumstances.\n *\n * yyMergeLocationInfo: function(first_index, last_index, first_yylloc, last_yylloc, dont_look_back),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * This helper API can be invoked to calculate a spanning `yylloc` location info object.\n *\n * Note: %epsilon rules MAY specify no `first_index` and `first_yylloc`, in which case\n * this function will attempt to obtain a suitable location marker by inspecting the location stack\n * backwards.\n *\n * For more info see the documentation comment further below, immediately above this function's\n * implementation.\n *\n * lexer: {\n * yy: {...}, A reference to the so-called \"shared state\" `yy` once\n * received via a call to the `.setInput(input, yy)` lexer API.\n * EOF: 1,\n * ERROR: 2,\n * JisonLexerError: function(msg, hash),\n * parseError: function(str, hash, ExceptionClass),\n * setInput: function(input, [yy]),\n * input: function(),\n * unput: function(str),\n * more: function(),\n * reject: function(),\n * less: function(n),\n * pastInput: function(n),\n * upcomingInput: function(n),\n * showPosition: function(),\n * test_match: function(regex_match_array, rule_index, ...),\n * next: function(...),\n * lex: function(...),\n * begin: function(condition),\n * pushState: function(condition),\n * popState: function(),\n * topState: function(),\n * _currentRules: function(),\n * stateStackSize: function(),\n * cleanupAfterLex: function()\n *\n * options: { ... lexer %options ... },\n *\n * performAction: function(yy, yy_, $avoiding_name_collisions, YY_START, ...),\n * rules: [...],\n * conditions: {associative list: name ==> set},\n * }\n * }\n *\n *\n * token location info (@$, _$, etc.): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a 'hash' object with these members for lexer and\n * parser errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * }\n *\n * parser (grammar) errors will also provide these additional members:\n *\n * {\n * expected: (array describing the set of expected tokens;\n * may be UNDEFINED when we cannot easily produce such a set)\n * state: (integer (or array when the table includes grammar collisions);\n * represents the current internal state of the parser kernel.\n * can, for example, be used to pass to the `collect_expected_token_set()`\n * API to obtain the expected token set)\n * action: (integer; represents the current internal action which will be executed)\n * new_state: (integer; represents the next/planned internal state, once the current\n * action has executed)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * state_stack: (array: the current parser LALR/LR internal state stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * value_stack: (array: the current parser LALR/LR internal `$$` value stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * location_stack: (array: the current parser LALR/LR internal location stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * yy: (object: the current parser internal \"shared state\" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * parser: (reference to the current parser instance)\n * }\n *\n * while `this` will reference the current parser instance.\n *\n * When `parseError` is invoked by the lexer, `this` will still reference the related *parser*\n * instance, while these additional `hash` fields will also be provided:\n *\n * {\n * lexer: (reference to the current lexer instance which reported the error)\n * }\n *\n * When `parseError` is invoked by the parser due to a **JavaScript exception** being fired\n * from either the parser or lexer, `this` will still reference the related *parser*\n * instance, while these additional `hash` fields will also be provided:\n *\n * {\n * exception: (reference to the exception thrown)\n * }\n *\n * Please do note that in the latter situation, the `expected` field will be omitted as\n * this type of failure is assumed not to be due to *parse errors* but rather due to user\n * action code in either parser or lexer failing unexpectedly.\n *\n * ---\n *\n * You can specify parser options by setting / modifying the `.yy` object of your Parser instance.\n * These options are available:\n *\n * ### options which are global for all parser instances\n *\n * Parser.pre_parse: function(yy)\n * optional: you can specify a pre_parse() function in the chunk following\n * the grammar, i.e. after the last `%%`.\n * Parser.post_parse: function(yy, retval, parseInfo) { return retval; }\n * optional: you can specify a post_parse() function in the chunk following\n * the grammar, i.e. after the last `%%`. When it does not return any value,\n * the parser will return the original `retval`.\n *\n * ### options which can be set up per parser instance\n *\n * yy: {\n * pre_parse: function(yy)\n * optional: is invoked before the parse cycle starts (and before the first\n * invocation of `lex()`) but immediately after the invocation of\n * `parser.pre_parse()`).\n * post_parse: function(yy, retval, parseInfo) { return retval; }\n * optional: is invoked when the parse terminates due to success ('accept')\n * or failure (even when exceptions are thrown).\n * `retval` contains the return value to be produced by `Parser.parse()`;\n * this function can override the return value by returning another.\n * When it does not return any value, the parser will return the original\n * `retval`.\n * This function is invoked immediately before `parser.post_parse()`.\n *\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * quoteName: function(name),\n * optional: overrides the default `quoteName` function.\n * }\n *\n * parser.lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are \"extended regex format\" requiring the\n * `XRegExp` library. When this `%option` has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n"); return out; }; @@ -26338,7 +26654,7 @@ generatorMixin.generate = function parser_generate(opt) { generatorMixin.generateAMDModule = function generateAMDModule(opt) { opt = this.__prepareOptions(opt); var module = this.generateModule_(); - var out = [this.generateGenericHeaderComment(), '', 'define(function (require) {', module.initCode, module.commonCode, '', 'var parser = ' + module.moduleCode, module.modulePostlude]; + var out = [this.generateGenericHeaderComment(), '', 'define(function (require) {', module.initCode, module.commonCode, '', 'let parser = ' + module.moduleCode, module.modulePostlude]; if (this.lexer && this.lexer.generateModule) { var lexSrc = this.lexer.generateModule(); @@ -26357,7 +26673,7 @@ generatorMixin.generateAMDModule = function generateAMDModule(opt) { lrGeneratorMixin.generateESModule = function generateESModule(opt) { opt = this.__prepareOptions(opt); var module = this.generateModule_(); - var out = [this.generateGenericHeaderComment(), '', module.initCode, module.commonCode, '', 'var parser = ' + module.moduleCode, module.modulePostlude]; + var out = [this.generateGenericHeaderComment(), '', module.initCode, module.commonCode, '', 'let parser = ' + module.moduleCode, module.modulePostlude]; if (this.lexer && this.lexer.generateModule) { var lexSrc = this.lexer.generateModule(); @@ -26373,12 +26689,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(_templateObject156(), moduleImportsAsCode, moduleNameAsCode.trim())); + out.push(rmCommonWS$5(_templateObject157(), moduleImportsAsCode, moduleNameAsCode.trim())); exportMain = 'main: yyExecMain,'; - invokeMain = rmCommonWS$5(_templateObject157()); + invokeMain = rmCommonWS$5(_templateObject158()); } - out.push(rmCommonWS$5(_templateObject158(), invokeMain, exportMain)); + out.push(rmCommonWS$5(_templateObject159(), invokeMain, exportMain)); var src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; @@ -26392,10 +26708,10 @@ generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { if (!opt.noMain) { var moduleNameAsCode = String(opt.moduleMain || commonJsMain); var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); - main = rmCommonWS$5(_templateObject159(), moduleImportsAsCode, moduleNameAsCode.trim()); + main = rmCommonWS$5(_templateObject160(), moduleImportsAsCode, moduleNameAsCode.trim()); } - var out = this.generateModule(opt) + rmCommonWS$5(_templateObject160(), moduleName, moduleName, moduleName, moduleName, main); + var out = this.generateModule(opt) + rmCommonWS$5(_templateObject161(), moduleName, moduleName, moduleName, moduleName, main); opt.exportSourceCode.all = out; return out; }; @@ -26410,13 +26726,13 @@ generatorMixin.generateModule = function generateModule(opt) { var subModuleName = namespaces.shift(); if (subModuleName != null) { - var moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; + var _moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; if (namespaces.length > 0) { - return 'var ' + subModuleName + ';\n' + '(function (' + subModuleName + ') {\n' + _generateNamespace(namespaces, subModuleName, callback) + '\n})(' + subModuleName + (previousNamespace == null ? '' : ' = ' + moduleName) + ' || (' + moduleName + ' = {}));\n'; + return '(function (' + subModuleName + ') {\n' + _generateNamespace(namespaces, subModuleName, callback) + '\n})(' + subModuleName + (previousNamespace == null ? '' : ' = ' + _moduleName) + ' || (' + _moduleName + ' = {}));\n'; } - return callback(moduleName); + return callback(_moduleName); } return ''; @@ -26425,7 +26741,7 @@ generatorMixin.generateModule = function generateModule(opt) { var sourceCodeDef = self.generateModuleExpr(); out += "\n ".concat(sourceCodeDef.init, "\n "); out += _generateNamespace(moduleName.split('.'), null, function _generateNamespace_cb(moduleName) { - var name = moduleName.match(/\./) ? moduleName : 'var ' + moduleName; + var name = moduleName.match(/\./) ? moduleName : 'let ' + moduleName; return "\n ".concat(name, " = ").concat(sourceCodeDef.src, "\n "); }); opt.exportSourceCode.all = out; @@ -26433,12 +26749,10 @@ generatorMixin.generateModule = function generateModule(opt) { }; generatorMixin.generateModuleExpr = function generateModuleExpr() { - var out; - var opt = this.__prepareOptions(); var module = this.generateModule_(); - out = ['(function () {', module.commonCode, '', 'var parser = ' + module.moduleCode, module.modulePostlude]; + var out = ['(function () {', module.commonCode, '', 'let parser = ' + module.moduleCode, module.modulePostlude]; if (this.lexer && this.lexer.generateModule) { var lexSrc = this.lexer.generateModule(); @@ -26487,7 +26801,7 @@ function removeUnusedKernelFeatures(parseFn, info) { // if (typeof lexer.yyleng === 'undefined') { // lexer.yyleng = 0; // } - // var yyleng; + // let yyleng; // ... parseFn = parseFn.replace(/, yyleng\b/g, '').replace(/^.*?\bvar yyleng\b.*?$/gm, '').replace(/\s+if\b.*?\.yyleng\b.*?\{[^}]+\}/g, '\n').replace(/^.*?\byyleng = .+$/gm, '').replace(/^.*?\byyleng\b.*?=.*?\byyleng\b.*?$/gm, ''); @@ -26498,7 +26812,7 @@ function removeUnusedKernelFeatures(parseFn, info) { // so we can kill the local var and its usage at least: actionFn = actionFn.replace(/, yylineno\b/g, ''); // remove: // - // var yylineno; + // let yylineno; // ... parseFn = parseFn.replace(/\bvar yylineno\b.*?$/gm, '').replace(/, yylineno\b/g, '').replace(/^.*?\byylineno\b.*?=.*?\byylineno\b.*?$/gm, ''); @@ -26533,7 +26847,7 @@ function removeUnusedKernelFeatures(parseFn, info) { if (!info.actionsUseLocationTracking) { actionFn = actionFn.replace(/\byyloc, (.*?), yylstack\b/g, '$1'); // remove: // - // var yyloc = lexer.yylloc; + // let yyloc = lexer.yylloc; // lstack[sp] = yyloc; // ... // lstack[sp] = copy_yylloc(lexer.yylloc); @@ -26558,11 +26872,11 @@ function removeUnusedKernelFeatures(parseFn, info) { // } // // and - // + // // if (sp >= 0 && typeof vstack[sp] !== 'undefined') { // retval = vstack[sp]; // } - // + // // but keep the yyval declaration as either location tracking MAY // still be employed by the grammar OR the grammar uses advanced // code which uses `yyval` as a run-time store which carries data @@ -26601,12 +26915,12 @@ function removeUnusedKernelFeatures(parseFn, info) { if (info.actionsAreAllDefault) { // remove // - // var yyval = { + // let yyval = { // $: true, // _$: undefined, // yy: sharedState_yy // }; - parseFn = parseFn.replace(/\s+var yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); + parseFn = parseFn.replace(/\s+let yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); } } @@ -26620,10 +26934,14 @@ function removeUnusedKernelFeatures(parseFn, info) { // option set or by invoking JISON with the debug flag `-t`. // remove: // - // var yydebug = false; + // let yydebug = false; // ... and delete yydebug function definition ... // ... // if (yydebug) yydebug(...); + // ... + // if (yydebug) { + // yydebug(...); + // } // // and // @@ -26631,9 +26949,9 @@ function removeUnusedKernelFeatures(parseFn, info) { // if (sharedState_yy.yydebug === false) { // yydebug = undefined; // } - parseFn = parseFn.replace(/\s+var yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') // strip multi-line `if (debug) yydebug(..., {...});` statements + parseFn = parseFn.replace(/\s+let yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') // strip multi-line `if (debug) { yydebug(..., {...}); }` statements // also strip simple yet possibly multi-line `if (debug) yydebug('...');` statements - .replace(/\n\s+if\s+\(yydebug\)\s+yydebug\([^]+?['}]\);[^\r\n]*?/g, '\n\n\n\n\n\n\n\n\n') // strip single-line `yydebug(...);` statements + .replace(/\n\s+if\s+\(yydebug\)\s+\{[\r\n]+\s+yydebug\([^]+?}\);[\s\r\n]+}\s*/g, '\n\n\n\n\n\n\n\n\n').replace(/\n\s+if\s+\(yydebug\)\s+yydebug\([^]+?['}]\);[^\r\n]*?/g, '\n\n\n\n\n\n\n\n\n') // strip single-line `yydebug(...);` statements .replace(/^.*?\byydebug\b[^;]+?\);[^\r\n]*?$/gm, '') // strip `if (sharedState_yy.yydebug) {...}` chunk .replace(/\n\s+\/\/\s*disable\s*debugging.*?[\r\n]+\s+if\s+\(sharedState_yy\.yydebug[^]+?\}/g, '\n\n\n\n'); } @@ -26709,8 +27027,8 @@ function removeUnusedKernelFeatures(parseFn, info) { * ... __reentrant_call_depth ... */ parseFn = parseFn.replace(/\s+try \{([\s\r\n]+this\.__reentrant_call_depth[\s\S]+?)\} catch \(ex\) \{[\s\S]+?\} finally \{([^]+?)\}\s+\/\/\s+\/finally/, function replace_noTryCatch(m, p1, p2) { - p1 = p1.replace(/^ /mg, ' '); - p2 = p2.replace(/^ /mg, ' '); + p1 = p1.replace(/^ {8}/mg, ' '); + p2 = p2.replace(/^ {8}/mg, ' '); return '\n' + p1 + '\n // ... AND FINALLY ...\n' + p2; }).replace(/^[^\n]+\b__reentrant_call_depth\b[^\n]+$/gm, '\n'); } @@ -26767,11 +27085,11 @@ function expandParseArguments(parseFn, self) { if (!arglist || arglist.length === 0) { parseFn = parseFn.replace(/, parseParams\b/g, ''); parseFn = parseFn.replace(/\bparseParams\b/g, ''); - parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers:\s+parseParamsAsMembers\b/g, ''); + parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers\b/g, ''); } else { parseFn = parseFn.replace(/, parseParams\b/g, ', ' + arglist.join(', ')); parseFn = parseFn.replace(/\bparseParams\b/g, arglist.join(', ')); - parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers:\s+parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { + parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { var s = ','; // determine longest name of the bunch (for formatting the generated code) var max_k_len = 0; @@ -26783,9 +27101,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 i = 0, len = arglist.length; i < len; i++) { - var k = arglist[i]; - s += '\n' + ws + k + ': ' + k + (i < len - 1 ? ',' + wsi2.substr(0, max_k_len - k.length - 1) : wsi2.substr(0, max_k_len - k.length)) + ' // parseParams::' + k; + 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; } return s; @@ -26822,11 +27140,11 @@ function addOrRemoveTokenStack(fn, wantTokenStack) { // // if (wantTokenStack) { // try { - // var ast = esprima.parse(parseFn); - // var stackAst = esprima.parse(String(tokenStackLex)).body[0]; + // let ast = esprima.parse(parseFn); + // let stackAst = esprima.parse(String(tokenStackLex)).body[0]; // stackAst.id.name = 'lex'; // - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); // // labeled[0].body = stackAst; // @@ -26836,7 +27154,7 @@ function addOrRemoveTokenStack(fn, wantTokenStack) { // } // } else { // // remove the line: - // // var tstack = []; // token stack + // // let tstack = []; // token stack // parseFn = parseFn.replace(/tstack = .*$/m, ''); // return parseFn; // } @@ -26846,11 +27164,11 @@ function addOrRemoveTokenStack(fn, wantTokenStack) { if (wantTokenStack) { // And rename the `tokenStackLex` function to become the new `lex`: return parseFn.replace(/\btokenStackLex\b/g, 'lex'); - } else { - // Also nuke the support declaration statement: - // var tstack = []; - return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); - } + } // Also nuke the support declaration statement: + // let tstack = []; + + + return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); } // returns parse function with/without error recovery code @@ -26858,8 +27176,8 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { var parseFn = fn; // We don't use the Esprima+Escodegen toolchain as those loose the code comments easily; // instead we just chop the code using labels as sentinels for our chopping-it-up regexes: // try { - // var ast = esprima.parse(parseFn); - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("' + + // let ast = esprima.parse(parseFn); + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("' + // (!hasErrorRecovery ? '_handle_error_with_recovery' : '_handle_error_no_recovery') + // '"))', ast); // Jison.print('labeled: ', labeled); @@ -26875,7 +27193,7 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { if (!hasErrorRecovery) { // Also nuke the support declaration statement: - // var recovering = 0; + // let recovering = 0; // and the recovery support statements: // if (recovering > 0) { // recovering--; @@ -26883,15 +27201,15 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // and these yydebug particles: // , recovering: recovering // ASSERT(recovering === 0); - parseFn = parseFn.replace(/^\s*var recovering.*$/gm, '').replace(/, recovering: recovering/g, '').replace(/^.*?recovering =.*$/gm, '').replace(/^\s+recovering[,]?\s*$/gm, '').replace(/[ \t]*if \(recovering[^\)]+\) \{[^\0]+?\}\n/g, '\n\n\n\n\n') // And nuke the preErrorSymbol code as it is unused when there's no error recovery + parseFn = parseFn.replace(/^\s*let recovering.*$/gm, '').replace(/, recovering: recovering/g, '').replace(/^.*?recovering =.*$/gm, '').replace(/^\s+recovering[,]?\s*$/gm, '').replace(/[ \t]*if \(recovering[^\)]+\) \{[^\0]+?\}\n/g, '\n\n\n\n\n') // And nuke the preErrorSymbol code as it is unused when there's no error recovery // if (!preErrorSymbol) { // ... keep this chunk ... // } else { // ... KILL this chunk ... // } - .replace(/\s+if[^a-z]+preErrorSymbol.*?\{\s*\/\/[^\n]+([\s\S]+?)\} else \{[\s\S]+?\}\n\s+\}\n/g, '\n$1\n\n\n\n').replace(/^\s+(?:var )?preErrorSymbol = .*$/gm, '').replace(/^.*?\bpreErrorSymbol =.*$/gm, '') // And nuke the support declaration statement: - // var lastEofErrorStateDepth = 0; - .replace(/^\s*var lastEofErrorStateDepth.*$/gm, ''); + .replace(/\s+if[^a-z]+preErrorSymbol.*?\{\s*\/\/[^\n]+([\s\S]+?)\} else \{[\s\S]+?\}\n\s+\}\n/g, '\n$1\n\n\n\n').replace(/^\s+(?:let )?preErrorSymbol = .*$/gm, '').replace(/^.*?\bpreErrorSymbol =.*$/gm, '') // And nuke the support declaration statement: + // let lastEofErrorStateDepth = 0; + .replace(/^\s*let lastEofErrorStateDepth.*$/gm, ''); } return parseFn; @@ -26913,8 +27231,6 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { exportDest.parseTable = this.table; exportDest.defaultParseActions = this.defaultActions; exportDest.parseProductions = this.productions_; - var exportSourceCode = this.options.exportSourceCode; - assert__default['default'](exportSourceCode); var tableCode; switch (this.options.compressTables | 0) { @@ -26949,10 +27265,9 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { var a = Object.keys(tbl); a.sort(); var nt = {}; - var k; for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); + var k = a[i]; // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number // and we do not want `$eof`/`EOF` to show up in the symbol tables of generated parsers // as we use `$end` for that one! @@ -26969,11 +27284,10 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { function produceTerminalTable(tbl) { var a = Object.keys(tbl); var nt = {}; - var k, v; for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; - v = tbl[k]; + var k = a[i]; + var v = tbl[k]; nt[v] = +k; // convert numeric key back to number type; all terminals have numeric keys } @@ -27116,11 +27430,10 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { reachable: production.reachable }; // Determine state for given production, if it's not a production that's listed as part of a state: - var chk, idx; var lst = prods.rules[nonterm]; - chk = rv.symbol + ' : ' + rv.handle; + var chk = rv.symbol + ' : ' + rv.handle; - for (idx in lst) { + for (var idx in lst) { idx = +idx; var p = lst[idx]; @@ -27139,8 +27452,8 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { if (base && base.rules) { var pr = base.rules[rv.base_symbol]; - for (idx in pr) { - var bprod = pr[idx]; + for (var _idx in pr) { + var bprod = pr[_idx]; if (bprod.symbol + ' : ' + bprod.handle === chk) { assert__default['default'](rv.base_state === -1); @@ -27222,9 +27535,8 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { } var nt = tbl; - var sbn; - for (sbn in nt) { + for (var sbn in nt) { var orig_symbol = get_orig_symbol(sbn); var item = nt[sbn]; var firsts = item.first; @@ -27247,12 +27559,12 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { } } - for (sbn in prods.first) { - prods.first[sbn] = get_orig_symbol_set(prods.first[sbn]); + for (var _sbn in prods.first) { + prods.first[_sbn] = get_orig_symbol_set(prods.first[_sbn]); } - for (sbn in prods.follows) { - prods.follows[sbn] = get_orig_symbol_set(prods.follows[sbn]); + for (var _sbn2 in prods.follows) { + prods.follows[_sbn2] = get_orig_symbol_set(prods.follows[_sbn2]); } if (this.newg) { @@ -27408,7 +27720,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { lrGeneratorMixin.generateErrorClass = function () { // --- START parser error class --- - var prelude = "\n// See also:\n// http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n// but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n// with userland code which might access the derived class in a 'classic' way.\nfunction JisonParserError(msg, hash) {\n \"use strict\";\n\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'JisonParserError'\n });\n\n if (msg == null) msg = '???';\n\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n var stacktrace;\n if (hash && hash.exception instanceof Error) {\n var ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty('captureStackTrace')) { // V8/Chrome engine\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(JisonParserError.prototype, Error.prototype);\n} else {\n JisonParserError.prototype = Object.create(Error.prototype);\n}\nJisonParserError.prototype.constructor = JisonParserError;\nJisonParserError.prototype.name = 'JisonParserError';\n"; // --- END parser error class --- + var prelude = "\n// See also:\n// http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n// but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n// with userland code which might access the derived class in a 'classic' way.\nfunction JisonParserError(msg, hash) {\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'JisonParserError'\n });\n\n if (msg == null) msg = '???';\n\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n let stacktrace;\n if (hash && hash.exception instanceof Error) {\n let ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty('captureStackTrace')) { // V8/Chrome engine\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(JisonParserError.prototype, Error.prototype);\n} else {\n JisonParserError.prototype = Object.create(Error.prototype);\n}\nJisonParserError.prototype.constructor = JisonParserError;\nJisonParserError.prototype.name = 'JisonParserError';\n"; // --- END parser error class --- return { commonCode: '', @@ -27435,7 +27747,7 @@ lrGeneratorMixin.generateTableCode0 = function (table, defaultActions, productio // e.g., x([1, 3, 4], [6, 7], { x: 1, y: 2 }) = { 1: [6, 7]; 3: [6, 7], 4: [6, 7], x: 1, y: 2 } -var compressor1ObjectCode = "\nfunction x(k, v, o) {\n o = o || {};\n for (var l = k.length; l--; ) {\n o[k[l]] = v;\n }\n return o;\n}\n"; // Generate code that represents the specified parser table +var compressor1ObjectCode = "\nfunction x(k, v, o) {\n o = o || {};\n for (let l = k.length; l--; ) {\n o[k[l]] = v;\n }\n return o;\n}\n"; // Generate code that represents the specified parser table lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productions) { var tableCode = JSON.stringify(table, null, 2); @@ -27448,21 +27760,18 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio tableCode = tableCode.replace(/\{[\s\r\n]*\d+:[^\}]+,[\s\r\n]*\d+:[^\}]+\}/g, function (object) { // Find the value that occurs with the highest number of keys - var value, - frequentValue, - key, - keys = {}, - keyCount, - maxKeyCount = 0, - keyValue, - keyValues = [], - keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; + var frequentValue; + var keys = {}; + var maxKeyCount = 0; + var keyValue; + var keyValues = []; + var keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; while (keyValue = keyValueMatcher.exec(object)) { // For each value, store the keys where that value occurs - key = keyValue[1]; - value = keyValue[2].trim(); - keyCount = 1; + var key = keyValue[1]; + var value = keyValue[2].trim(); + var keyCount = 1; if (!(value in keys)) { keys[value] = [key]; @@ -27480,10 +27789,10 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio if (maxKeyCount > 1) { // Collect all non-frequent values into a remainder object - for (value in keys) { - if (value !== frequentValue) { - for (var k = keys[value], i = 0, l = k.length; i < l; i++) { - keyValues.push(k[i] + ':' + value); + for (var _value5 in keys) { + if (_value5 !== frequentValue) { + for (var k = keys[_value5], i = 0, l = k.length; i < l; i++) { + keyValues.push(k[i] + ':' + _value5); } } } @@ -27532,7 +27841,7 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio } if (frequentLists.length > 0) { - prelude.push('var u = [\n ' + frequentLists.join(',\n ') + '\n];'); + prelude.push('let u = [\n ' + frequentLists.join(',\n ') + '\n];'); prelude.push(''); } // Return the variable initialization code and the table code @@ -27579,11 +27888,10 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); function reportColumnsForCompression(def_arr) { - var i, key, len; var report = []; - len = 0; + var len = 0; - for (key in def_arr) { + for (var key in def_arr) { len = Math.max(len, def_arr[key].length); } @@ -27597,48 +27905,52 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } var track_prev4delta = {}; - var c, delta, val, delta_val; var line = []; line.push('║'); - for (c in def_arr) { - key = clip(c, col_width); - delta = clip('∆', col_delta_width); - line.push(key); + for (var _c3 in def_arr) { + var _key10 = clip(_c3, col_width); + + var delta = clip('∆', col_delta_width); + line.push(_key10); line.push('┊'); line.push(delta); line.push('║'); - track_prev4delta[c] = 10000000; + track_prev4delta[_c3] = 10000000; } report.push(line.join('')); - for (i = 0; i < len; i++) { + for (var i = 0; i < len; i++) { line = []; line.push('║'); - for (c in def_arr) { - var tbl = def_arr[c]; + for (var _c4 in def_arr) { + var val = void 0, + delta_val = void 0; + var tbl = def_arr[_c4]; if (tbl.length > i) { val = tbl[i] || 0; - delta_val = val - track_prev4delta[c]; // negative deltas are jumps: don't treat those as delta but as absolute value, sign-flipped: + delta_val = val - track_prev4delta[_c4]; // 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[c] = val; + track_prev4delta[_c4] = val; } else { val = '.'; delta_val = '.'; } - key = clip(val, col_width); - delta = clip(delta_val, col_delta_width); - line.push(key); + var _key11 = clip(val, col_width); + + var _delta = clip(delta_val, col_delta_width); + + line.push(_key11); line.push('┊'); - line.push(delta); + line.push(_delta); line.push('║'); } @@ -27671,9 +27983,9 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } var def_arr = { - 'len': len_col, - 'pop': pop_col, - 'rule': rule_col + len: len_col, + pop: pop_col, + rule: rule_col }; return def_arr; } // table is hash of 1/2-len arrays: @@ -27696,8 +28008,8 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } var def_arr = { - 'idx': idx_col, - 'goto': goto_col + idx: idx_col, + goto: goto_col }; return def_arr; } @@ -27715,16 +28027,15 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio var mode_col = []; // column: symbol hash entry goto state value if array slot type: var goto_col = []; // // column: merged: state_col + goto_col: - // var next_col = []; + // let next_col = []; var row_count = table.length; for (var state = 0; state < row_count; state++) { var hashtable = table[state]; var count = 0; - var symbol; - for (symbol in hashtable) { + for (var symbol in hashtable) { symbol = +symbol; symbol_col.push(symbol); var slot = hashtable[symbol]; @@ -27758,12 +28069,12 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } var def_arr = { - 'len': len_col, - 'symbol': symbol_col, - 'type': type_col, - 'state': state_col, - 'mode': mode_col, - 'goto': goto_col //'next': next_col, + len: len_col, + symbol: symbol_col, + type: type_col, + state: state_col, + mode: mode_col, + goto: goto_col //'next': next_col, }; return def_arr; @@ -27773,11 +28084,11 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function generateColumn(name, col) { var rv = []; - var i, j, len, l; - for (i = 0, len = col.length; i < len; i++) { + for (var i = 0, len = col.length; i < len; i++) { // try basic run-length encoding first: var v = col[i]; + var j = void 0; for (j = i + 1; j < len; j++) { if (col[j] !== v) { @@ -27807,6 +28118,8 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio var upper_bound = i - 2; for (j = 0; j < upper_bound; j++) { + var l = void 0; + for (l = 0; col[j + l] === col[i + l]; l++) {// No need to check for: // if (j + l === i) break; // because we know how the c() helper function will regenerate @@ -27875,10 +28188,10 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio var tableDef = analyzeGotoTableForCompression(table); var defaultActionsDef = analyzeSetForCompression(defaultActions); var productionsDef = analyzeTableForCompression(productions); - var bp_code_container = "\n // helper: reconstruct the productions[] table\n function bp(s) {\n var rv = [];\n var p = s.pop;\n var r = s.rule;\n for (var i = 0, l = p.length; i < l; i++) {\n rv.push([\n p[i],\n r[i]\n ]);\n }\n return rv;\n }\n "; - var bda_code_container = "\n // helper: reconstruct the defaultActions[] table\n function bda(s) {\n var rv = {};\n var d = s.idx;\n var g = s.goto;\n for (var i = 0, l = d.length; i < l; i++) {\n var j = d[i];\n rv[j] = g[i];\n }\n return rv;\n }\n "; - var bt_code_container = "\n // helper: reconstruct the 'goto' table\n function bt(s) {\n var rv = [];\n var d = s.len;\n var y = s.symbol;\n var t = s.type;\n var a = s.state;\n var m = s.mode;\n var g = s.goto;\n for (var i = 0, l = d.length; i < l; i++) {\n var n = d[i];\n var q = {};\n for (var j = 0; j < n; j++) {\n var z = y.shift();\n switch (t.shift()) {\n case 2:\n q[z] = [\n m.shift(),\n g.shift()\n ];\n break;\n\n case 0:\n q[z] = a.shift();\n break;\n\n default:\n // type === 1: accept\n q[z] = [\n 3\n ];\n }\n }\n rv.push(q);\n }\n return rv;\n }\n "; - var c_s_u_code_container = "\n // helper: runlength encoding with increment step: code, length: step (default step = 0)\n // `this` references an array\n function s(c, l, a) {\n a = a || 0;\n for (var i = 0; i < l; i++) {\n this.push(c);\n c += a;\n }\n }\n\n // helper: duplicate sequence from *relative* offset and length.\n // `this` references an array\n function c(i, l) {\n i = this.length - i;\n for (l += i; i < l; i++) {\n this.push(this[i]);\n }\n }\n\n // helper: unpack an array using helpers and data, all passed in an array argument 'a'.\n function u(a) {\n var rv = [];\n for (var i = 0, l = a.length; i < l; i++) {\n var e = a[i];\n // Is this entry a helper function?\n if (typeof e === 'function') {\n i++;\n e.apply(rv, a[i]);\n } else {\n rv.push(e);\n }\n }\n return rv;\n }\n "; + var bp_code_container = "\n // helper: reconstruct the productions[] table\n function bp(s) {\n let rv = [];\n let p = s.pop;\n let r = s.rule;\n for (let i = 0, l = p.length; i < l; i++) {\n rv.push([\n p[i],\n r[i]\n ]);\n }\n return rv;\n }\n "; + var bda_code_container = "\n // helper: reconstruct the defaultActions[] table\n function bda(s) {\n let rv = {};\n let d = s.idx;\n let g = s.goto;\n for (let i = 0, l = d.length; i < l; i++) {\n let j = d[i];\n rv[j] = g[i];\n }\n return rv;\n }\n "; + var bt_code_container = "\n // helper: reconstruct the 'goto' table\n function bt(s) {\n let rv = [];\n let d = s.len;\n let y = s.symbol;\n let t = s.type;\n let a = s.state;\n let m = s.mode;\n let g = s.goto;\n for (let i = 0, l = d.length; i < l; i++) {\n let n = d[i];\n let q = {};\n for (let j = 0; j < n; j++) {\n let z = y.shift();\n switch (t.shift()) {\n case 2:\n q[z] = [\n m.shift(),\n g.shift()\n ];\n break;\n\n case 0:\n q[z] = a.shift();\n break;\n\n default:\n // type === 1: accept\n q[z] = [\n 3\n ];\n }\n }\n rv.push(q);\n }\n return rv;\n }\n "; + var c_s_u_code_container = "\n // helper: runlength encoding with increment step: code, length: step (default step = 0)\n // `this` references an array\n function s(c, l, a) {\n a = a || 0;\n for (let i = 0; i < l; i++) {\n this.push(c);\n c += a;\n }\n }\n\n // helper: duplicate sequence from *relative* offset and length.\n // `this` references an array\n function c(i, l) {\n i = this.length - i;\n for (l += i; i < l; i++) {\n this.push(this[i]);\n }\n }\n\n // helper: unpack an array using helpers and data, all passed in an array argument 'a'.\n function u(a) {\n let rv = [];\n for (let i = 0, l = a.length; i < l; i++) {\n let e = a[i];\n // Is this entry a helper function?\n if (typeof e === 'function') {\n i++;\n e.apply(rv, a[i]);\n } else {\n rv.push(e);\n }\n }\n return rv;\n }\n "; has_compressed_a_table = false; var tc = generateCompressedGotoTable(tableDef); var compressGotoTable = has_compressed_a_table; @@ -27906,13 +28219,13 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio productionsCode: productionsCode }; }; // --- START of commonJsMain chunk --- -// +// // default main method for generated commonjs modules -var commonJsMain = "\nfunction (args) {\n \"use strict\";\n\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 var source = fs.readFileSync(path.normalize(args[1]), 'utf8');\n var 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 var 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 = "\nvar fs = require('fs');\nvar path = require('path');\n"; // debug mixin for LR parser generators +var commonJsMainImports = "\nconst fs = require('fs');\nconst path = require('path');\n"; // debug mixin for LR parser generators function printAction(a, gen) { var s = a[0] === SHIFT ? 'shift token (then go to state ' + a[1] + ')' : a[0] === REDUCE ? 'reduce by rule: ' + gen.productions[a[1]] : a[0] === ACCEPT ? 'accept' : 'UNDEFINED ACTION: ' + a[0]; @@ -27958,8 +28271,8 @@ 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(_templateObject161(), sourceCodeDef.init, sourceCodeDef.src); - var p = code_exec$2(sourcecode, function generated_code_exec_wrapper_jison(sourcecode) { + var sourcecode = rmCommonWS$5(_templateObject162(), 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); var rv = eval(sourcecode); @@ -27967,7 +28280,7 @@ generatorMixin.createParser = function createParser() { }, mkStdOptions$1(this.options, { dumpSourceCodeOnFailure: this.DEBUG, throwErrorOnCompileFailure: true - }), "parser"); + }), 'parser'); assert__default['default'](_typeof(p) === 'object'); assert__default['default'](typeof p.parse === 'function'); assert__default['default'](typeof p.parser === 'undefined'); @@ -28034,7 +28347,7 @@ parser$4.trace = generator.trace; parser$4.warn = generator.warn; parser$4.error = generator.error; // --- START parser Error class chunk --- -var parseErrorSourceCode = "\nfunction parseError(str, hash, ExceptionClass) {\n \"use strict\";\n\n if (hash.recoverable) {\n if (typeof this.trace === 'function') {\n this.trace(str);\n }\n hash.destroy(); // destroy... well, *almost*!\n } else {\n if (typeof this.trace === 'function') {\n this.trace(str);\n }\n if (!ExceptionClass) {\n ExceptionClass = this.JisonParserError;\n }\n throw new ExceptionClass(str, hash);\n }\n}\n"; // --- END of parseErrorSourceCode chunk --- +var parseErrorSourceCode = "\nfunction parseError(str, hash, ExceptionClass) {\n if (hash.recoverable) {\n if (typeof this.trace === 'function') {\n this.trace(str);\n }\n hash.destroy(); // destroy... well, *almost*!\n } else {\n if (typeof this.trace === 'function') {\n this.trace(str);\n }\n if (!ExceptionClass) {\n ExceptionClass = this.JisonParserError;\n }\n throw new ExceptionClass(str, hash);\n }\n}\n"; // --- END of parseErrorSourceCode chunk --- chkBugger$3(parseErrorSourceCode); parser$4.parseError = lrGeneratorMixin.parseError = eval(parseErrorSourceCode + '\n\nparseError;'); @@ -28050,7 +28363,7 @@ generatorMixin.createLexer = function createLexer(lexerSpec, input, tokens, opti // in the generated code: -var define_parser_APIs_1 = "\n TERROR: 2,\n EOF: 1,\n\n // internals: defined here so the object *structure* doesn't get modified by parse() et al,\n // thus helping JIT compilers like Chrome V8.\n originalQuoteName: null,\n originalParseError: null,\n cleanupAfterParse: null,\n constructParseErrorInfo: null,\n yyMergeLocationInfo: null,\n copy_yytext: null,\n copy_yylloc: null,\n\n __reentrant_call_depth: 0, // INTERNAL USE ONLY\n __error_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup\n __error_recovery_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup\n\n // APIs which will be set up depending on user action code analysis:\n //yyRecovering: 0,\n //yyErrOk: 0,\n //yyClearIn: 0,\n\n // Helper APIs\n // -----------\n\n // Helper function which can be overridden by user code later on: put suitable quotes around\n // literal IDs in a description string.\n quoteName: function parser_quoteName(id_str) {\n \"use strict\";\n\n return '\"' + id_str + '\"';\n },\n\n // Return the name of the given symbol (terminal or non-terminal) as a string, when available.\n //\n // Return NULL when the symbol is unknown to the parser.\n getSymbolName: function parser_getSymbolName(symbol) {\n \"use strict\";\n\n if (this.terminals_[symbol]) {\n return this.terminals_[symbol];\n }\n\n // Otherwise... this might refer to a RULE token i.e. a non-terminal: see if we can dig that one up.\n //\n // An example of this may be where a rule's action code contains a call like this:\n //\n // parser.getSymbolName(#$)\n //\n // to obtain a human-readable name of the current grammar rule.\n var s = this.symbols_;\n for (var key in s) {\n if (s[key] === symbol) {\n return key;\n }\n }\n return null;\n },\n\n // Return a more-or-less human-readable description of the given symbol, when available,\n // or the symbol itself, serving as its own 'description' for lack of something better to serve up.\n //\n // Return NULL when the symbol is unknown to the parser.\n describeSymbol: function parser_describeSymbol(symbol) {\n \"use strict\";\n\n if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) {\n return this.terminal_descriptions_[symbol];\n }\n else if (symbol === this.EOF) {\n return 'end of input';\n }\n var id = this.getSymbolName(symbol);\n if (id) {\n return this.quoteName(id);\n }\n return null;\n },\n\n // Produce a (more or less) human-readable list of expected tokens at the point of failure.\n //\n // The produced list may contain token or token set descriptions instead of the tokens\n // themselves to help turning this output into something that easier to read by humans\n // unless `do_not_describe` parameter is set, in which case a list of the raw, *numeric*,\n // expected terminals and nonterminals is produced.\n //\n // The returned list (array) will not contain any duplicate entries.\n collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) {\n \"use strict\";\n\n var TERROR = this.TERROR;\n var tokenset = [];\n var check = {};\n // Has this (error?) state been outfitted with a custom expectations description text for human consumption?\n // If so, use that one instead of the less palatable token set.\n if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) {\n return [\n this.state_descriptions_[state]\n ];\n }\n for (var p in this.table[state]) {\n p = +p;\n if (p !== TERROR) {\n var d = do_not_describe ? p : this.describeSymbol(p);\n if (d && !check[d]) {\n tokenset.push(d);\n check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries.\n }\n }\n }\n return tokenset;\n }\n"; // --- END of define_parser_APIs_1 chunk --- +var define_parser_APIs_1 = "\n TERROR: 2,\n EOF: 1,\n\n // internals: defined here so the object *structure* doesn't get modified by parse() et al,\n // thus helping JIT compilers like Chrome V8.\n originalQuoteName: null,\n originalParseError: null,\n cleanupAfterParse: null,\n constructParseErrorInfo: null,\n yyMergeLocationInfo: null,\n copy_yytext: null,\n copy_yylloc: null,\n\n __reentrant_call_depth: 0, // INTERNAL USE ONLY\n __error_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup\n __error_recovery_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup\n\n // APIs which will be set up depending on user action code analysis:\n //yyRecovering: 0,\n //yyErrOk: 0,\n //yyClearIn: 0,\n\n // Helper APIs\n // -----------\n\n // Helper function which can be overridden by user code later on: put suitable quotes around\n // literal IDs in a description string.\n quoteName: function parser_quoteName(id_str) {\n return '\"' + id_str + '\"';\n },\n\n // Return the name of the given symbol (terminal or non-terminal) as a string, when available.\n //\n // Return NULL when the symbol is unknown to the parser.\n getSymbolName: function parser_getSymbolName(symbol) {\n if (this.terminals_[symbol]) {\n return this.terminals_[symbol];\n }\n\n // Otherwise... this might refer to a RULE token i.e. a non-terminal: see if we can dig that one up.\n //\n // An example of this may be where a rule's action code contains a call like this:\n //\n // parser.getSymbolName(#$)\n //\n // to obtain a human-readable name of the current grammar rule.\n const s = this.symbols_;\n for (let key in s) {\n if (s[key] === symbol) {\n return key;\n }\n }\n return null;\n },\n\n // Return a more-or-less human-readable description of the given symbol, when available,\n // or the symbol itself, serving as its own 'description' for lack of something better to serve up.\n //\n // Return NULL when the symbol is unknown to the parser.\n describeSymbol: function parser_describeSymbol(symbol) {\n if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) {\n return this.terminal_descriptions_[symbol];\n } else if (symbol === this.EOF) {\n return 'end of input';\n }\n\n let id = this.getSymbolName(symbol);\n if (id) {\n return this.quoteName(id);\n }\n return null;\n },\n\n // Produce a (more or less) human-readable list of expected tokens at the point of failure.\n //\n // The produced list may contain token or token set descriptions instead of the tokens\n // themselves to help turning this output into something that easier to read by humans\n // unless `do_not_describe` parameter is set, in which case a list of the raw, *numeric*,\n // expected terminals and nonterminals is produced.\n //\n // The returned list (array) will not contain any duplicate entries.\n collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) {\n const TERROR = this.TERROR;\n let tokenset = [];\n let check = {};\n\n // Has this (error?) state been outfitted with a custom expectations description text for human consumption?\n // If so, use that one instead of the less palatable token set.\n if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) {\n return [\n this.state_descriptions_[state]\n ];\n }\n for (let p in this.table[state]) {\n p = +p;\n if (p !== TERROR) {\n let d = do_not_describe ? p : this.describeSymbol(p);\n if (d && !check[d]) {\n tokenset.push(d);\n check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries.\n }\n }\n }\n return tokenset;\n }\n"; // --- END of define_parser_APIs_1 chunk --- var api_set = new Function('', 'return { ' + define_parser_APIs_1 + ' };')(); @@ -28059,7 +28372,7 @@ for (var api in api_set) { } // --- START parser kernel --- -parser$4.parse = "\nfunction parse(input, parseParams) {\n \"use strict\";\n\n var self = this;\n var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage)\n var sstack = new Array(128); // state stack: stores states (column storage)\n var tstack = []; // token stack (only used when `%options token_stack` support has been enabled)\n var vstack = new Array(128); // semantic value stack\n var lstack = new Array(128); // location stack\n var table = this.table;\n var sp = 0; // 'stack pointer': index into the stacks\n var yyloc;\n var yytext;\n var yylineno;\n var yyleng;\n\n var symbol = 0;\n var preErrorSymbol = 0;\n var lastEofErrorStateDepth = Infinity;\n var recoveringErrorInfo = null;\n var recovering = 0; // (only used when the grammar contains error recovery rules)\n var TERROR = this.TERROR;\n var EOF = this.EOF;\n var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3;\n var NO_ACTION = [0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */];\n\n var lexer;\n if (this.__lexer__) {\n lexer = this.__lexer__;\n } else {\n lexer = this.__lexer__ = Object.create(this.lexer);\n }\n\n var sharedState_yy = {\n parseError: undefined,\n quoteName: undefined,\n lexer: undefined,\n parser: undefined,\n pre_parse: undefined,\n post_parse: undefined,\n pre_lex: undefined,\n post_lex: undefined,\n parseParamsAsMembers: parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes!\n };\n\n var ASSERT;\n if (typeof assert !== 'function') {\n ASSERT = function JisonAssert(cond, msg) {\n \"use strict\";\n\n if (!cond) {\n throw new Error('assertion failed: ' + (msg || '***'));\n }\n };\n } else {\n ASSERT = assert;\n }\n\n this.yyGetSharedState = function yyGetSharedState() {\n return sharedState_yy;\n };\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n this.yyGetErrorInfoTrack = function yyGetErrorInfoTrack() {\n return recoveringErrorInfo;\n };\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // shallow clone objects & arrays, straight copy of simple `src` values\n // e.g. `lexer.yytext` MAY be a complex value object,\n // rather than a simple string/value.\n //\n // https://jsperf.com/new-array-vs-splice-vs-slice/72\n // https://jsperf.com/instanceof-vs-typeof/20\n // benchmark:: http://127.0.0.1:8080/example/jsperf/#testfile=test0020-typeof-instanceof-isArray.json5\n // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5\n //\n function shallow_copy(src) {\n \"use strict\";\n\n if (src && typeof src === 'object') {\n // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned\n // using their constructor:\n if (src.constructor !== Object) {\n if (Array.isArray(src)) {\n return src.slice();\n }\n var dst = new src.constructor(src);\n\n // and make sure all custom attributes are added to the clone:\n shallow_copy_noclobber(dst, src);\n return dst;\n }\n // native objects must be cloned a different way:\n //\n //return Object.assign({}, src);\n var dst = {};\n shallow_copy_noclobber(dst, src);\n return dst;\n }\n return src;\n }\n // add elements from `src` to `dst` when:\n // - either the element does not yet exist in `src`\n // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst`\n function shallow_copy_noclobber(dst, src) {\n \"use strict\";\n\n const chk = Object.prototype.hasOwnProperty;\n for (var k in src) {\n if (!(k in dst)) {\n if (chk.call(src, k)) {\n dst[k] = src[k];\n }\n }\n else {\n if (src[k] != null && dst[k] == null && chk.call(src, k)) {\n dst[k] = src[k];\n }\n }\n }\n }\n function copy_yylloc_native(loc) {\n \"use strict\";\n\n var rv = shallow_copy(loc);\n // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries:\n if (rv) {\n rv.range = rv.range.slice();\n }\n return rv;\n }\n\n // copy state\n shallow_copy_noclobber(sharedState_yy, this.yy);\n\n sharedState_yy.lexer = lexer;\n sharedState_yy.parser = this;\n\n // allow userland code to override the yytext and yylloc copy/clone functions:\n this.copy_yytext = this.options.copy_yytext || sharedState_yy.copy_yytext || shallow_copy;\n this.copy_yylloc = this.options.copy_yylloc || sharedState_yy.copy_yylloc || copy_yylloc_native;\n\n var yydebug = false;\n if (this.options.debug) {\n yydebug = function yydebug_impl(msg, obj) {\n \"use strict\";\n\n var ref_list;\n var ref_names;\n\n function deepClone(from, sub) {\n \"use strict\";\n\n if (sub == null) {\n ref_list = [];\n ref_names = [];\n sub = 'root';\n }\n if (typeof from === 'function') return '[Function]';\n if (from == null || typeof from !== 'object') return from;\n if (from.constructor !== Object && from.constructor !== Array) {\n return from;\n }\n\n var i = ref_list.indexOf(from);\n if (i >= 0) {\n return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference\n }\n ref_list.push(from);\n ref_names.push(sub);\n\n var to = new from.constructor();\n for (var name in from) {\n if (name === 'parser') continue;\n if (name === 'lexer') continue;\n to[name] = deepClone(from[name], name);\n }\n return to;\n }\n\n obj = obj || {};\n if (obj.symbol) {\n obj.local_yytext = yytext;\n obj.lexer_yytext = lexer.yytext;\n obj.lexer_yylloc = lexer.yylloc;\n obj.lexer_yyllineno = lexer.yyllineno;\n }\n\n // warning: here we fetch from closure (stack et al)\n obj.symbol_stack = stack;\n obj.state_stack = sstack;\n obj.value_stack = vstack;\n obj.location_stack = lstack;\n obj.stack_pointer = sp;\n\n // ready the object for printing:\n obj = deepClone(obj);\n\n // wrap try/catch in a function to help the V8 JIT compiler...\n function yydebug_cvt(obj) {\n \"use strict\";\n\n var js;\n try {\n var re1;\n if (typeof XRegExp === 'undefined') {\n re1 = / \\\"([a-z_][a-z_0-9. ]*)\\\": /ig;\n } else {\n re1 = new XRegExp(' \\\"([\\\\p{Alphabetic}_][\\\\p{Alphabetic}\\\\p{Number}_. ]*)\\\": ', 'g');\n }\n js = JSON.stringify(obj, null, 2)\n .replace(re1, ' $1: ')\n .replace(/[\\n\\s]+/g, ' ')\n // shorten yylloc object dumps too:\n .replace(/\\{ first_line: (\\d+), first_column: (\\d+), last_line: (\\d+), last_column: (\\d+)/g, '{L/C: ($1,$2)..($3,$4)');\n } catch (ex) {\n js = String(obj);\n }\n return js;\n }\n\n self.trace(msg, yydebug_cvt(obj), '\\n');\n };\n }\n\n // disable debugging at run-time ANYWAY when you've *explicitly* set \"yy.yydebug = false\":\n if (sharedState_yy.yydebug === false) {\n yydebug = undefined;\n }\n\n // *Always* setup `yyError`, `YYRECOVERING`, `yyErrOk` and `yyClearIn` functions as it is paramount\n // to have *their* closure match ours -- if we only set them up once,\n // any subsequent `parse()` runs will fail in very obscure ways when\n // these functions are invoked in the user action code block(s) as\n // their closure will still refer to the `parse()` instance which set\n // them up. Hence we MUST set them up at the start of every `parse()` run!\n if (this.yyError) {\n this.yyError = function yyError(str /*, ...args */) {\n \"use strict\";\n\n if (yydebug) yydebug('yyerror: ', { message: str, args: arguments, symbol: symbol, state: state, newState: newState, recovering: recovering, action: action });\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1);\n var expected = this.collect_expected_token_set(state);\n var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0));\n // append to the old one?\n if (recoveringErrorInfo) {\n var esp = recoveringErrorInfo.info_stack_pointer;\n\n recoveringErrorInfo.symbol_stack[esp] = symbol;\n var v = this.shallowCopyErrorInfo(hash);\n v.yyError = true;\n v.errorRuleDepth = error_rule_depth;\n v.recovering = recovering;\n // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH;\n\n recoveringErrorInfo.value_stack[esp] = v;\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc);\n recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n } else {\n recoveringErrorInfo = this.shallowCopyErrorInfo(hash);\n recoveringErrorInfo.yyError = true;\n recoveringErrorInfo.errorRuleDepth = error_rule_depth;\n recoveringErrorInfo.recovering = recovering;\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n\n var expected = this.collect_expected_token_set(state);\n var hash = this.constructParseErrorInfo(str, null, expected, false);\n\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n var args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n hash.extra_error_attributes = args;\n }\n\n return this.parseError(str, hash, this.JisonParserError);\n };\n }\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n if (this.yyRecovering) {\n this.yyRecovering = function yyRecovering() {\n \"use strict\";\n\n if (yydebug) yydebug('yyrecovering: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action });\n return recovering;\n };\n }\n\n if (this.yyErrOk) {\n this.yyErrOk = function yyErrOk() {\n \"use strict\";\n\n if (yydebug) yydebug('yyerrok: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action });\n recovering = 0;\n\n // DO NOT reset/cleanup `recoveringErrorInfo` yet: userland code\n // MAY invoke this API before the error is actually fully\n // recovered, in which case the parser recovery code won't be able\n // to append the skipped tokens to this info object.\n //\n // The rest of the kernel code is safe enough that it won't inadvertedly\n // re-use an old `recoveringErrorInfo` chunk so we'ld better wait\n // with destruction/cleanup until the end of the parse or until another\n // fresh parse error rears its ugly head...\n //\n // if (recoveringErrorInfo && typeof recoveringErrorInfo.destroy === 'function') {\n // recoveringErrorInfo.destroy();\n // recoveringErrorInfo = undefined;\n // }\n };\n }\n\n if (this.yyClearIn) {\n this.yyClearIn = function yyClearIn() {\n \"use strict\";\n\n if (yydebug) yydebug('yyclearin: ', { symbol: symbol, newState: newState, recovering: recovering, action: action, preErrorSymbol: preErrorSymbol });\n if (symbol === TERROR) {\n symbol = 0;\n yytext = null;\n yyleng = 0;\n yyloc = undefined;\n }\n preErrorSymbol = 0;\n };\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // Does the shared state override the default `parseError` that already comes with this instance?\n if (typeof sharedState_yy.parseError === 'function') {\n this.parseError = function parseErrorAlt(str, hash, ExceptionClass) {\n \"use strict\";\n\n if (!ExceptionClass) {\n ExceptionClass = this.JisonParserError;\n }\n return sharedState_yy.parseError.call(this, str, hash, ExceptionClass);\n };\n } else {\n this.parseError = this.originalParseError;\n }\n\n // Does the shared state override the default `quoteName` that already comes with this instance?\n if (typeof sharedState_yy.quoteName === 'function') {\n this.quoteName = function quoteNameAlt(id_str) {\n \"use strict\";\n\n return sharedState_yy.quoteName.call(this, id_str);\n };\n } else {\n this.quoteName = this.originalQuoteName;\n }\n\n // set up the cleanup function; make it an API so that external code can re-use this one in case of\n // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which\n // case this parse() API method doesn't come with a `finally { ... }` block any more!\n //\n // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,\n // or else your `sharedState`, etc. references will be *wrong*!\n this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) {\n \"use strict\";\n\n var rv;\n\n if (invoke_post_methods) {\n var hash;\n\n if (sharedState_yy.post_parse || this.post_parse) {\n // create an error hash info instance: we re-use this API in a **non-error situation**\n // as this one delivers all parser internals ready for access by userland code.\n hash = this.constructParseErrorInfo(null /* no error! */, null /* no exception! */, null, false);\n }\n\n if (sharedState_yy.post_parse) {\n rv = sharedState_yy.post_parse.call(this, sharedState_yy, resultValue, hash);\n if (typeof rv !== 'undefined') resultValue = rv;\n }\n if (this.post_parse) {\n rv = this.post_parse.call(this, sharedState_yy, resultValue, hash);\n if (typeof rv !== 'undefined') resultValue = rv;\n }\n\n // cleanup:\n if (hash && hash.destroy) {\n hash.destroy();\n }\n }\n\n if (this.__reentrant_call_depth > 1) return resultValue; // do not (yet) kill the sharedState when this is a reentrant run.\n\n // clean up the lingering lexer structures as well:\n if (lexer.cleanupAfterLex) {\n lexer.cleanupAfterLex(do_not_nuke_errorinfos);\n }\n\n // prevent lingering circular references from causing memory leaks:\n if (sharedState_yy) {\n sharedState_yy.lexer = undefined;\n sharedState_yy.parser = undefined;\n if (lexer.yy === sharedState_yy) {\n lexer.yy = undefined;\n }\n }\n sharedState_yy = undefined;\n this.parseError = this.originalParseError;\n this.quoteName = this.originalQuoteName;\n\n // nuke the vstack[] array at least as that one will still reference obsoleted user values.\n // To be safe, we nuke the other internal stack columns as well...\n stack.length = 0; // fastest way to nuke an array without overly bothering the GC\n sstack.length = 0;\n lstack.length = 0;\n vstack.length = 0;\n sp = 0;\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (var i = this.__error_infos.length - 1; i >= 0; i--) {\n var el = this.__error_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) {\n var el = this.__error_recovery_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_recovery_infos.length = 0;\n\n // `recoveringErrorInfo` is also part of the `__error_recovery_infos` array,\n // hence has been destroyed already: no need to do that *twice*.\n if (recoveringErrorInfo) {\n recoveringErrorInfo = undefined;\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n }\n\n return resultValue;\n };\n\n // merge yylloc info into a new yylloc instance.\n //\n // `first_index` and `last_index` MAY be UNDEFINED/NULL or these are indexes into the `lstack[]` location stack array.\n //\n // `first_yylloc` and `last_yylloc` MAY be UNDEFINED/NULL or explicit (custom or regular) `yylloc` instances, in which\n // case these override the corresponding first/last indexes.\n //\n // `dont_look_back` is an optional flag (default: FALSE), which instructs this merge operation NOT to search\n // through the parse location stack for a location, which would otherwise be used to construct the new (epsilon!)\n // yylloc info.\n //\n // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL.\n this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) {\n \"use strict\";\n\n var i1 = first_index | 0,\n i2 = last_index | 0;\n var l1 = first_yylloc,\n l2 = last_yylloc;\n var rv;\n\n // rules:\n // - first/last yylloc entries override first/last indexes\n\n if (!l1) {\n if (first_index != null) {\n for (var i = i1; i <= i2; i++) {\n l1 = lstack[i];\n if (l1) {\n break;\n }\n }\n }\n }\n\n if (!l2) {\n if (last_index != null) {\n for (var i = i2; i >= i1; i--) {\n l2 = lstack[i];\n if (l2) {\n break;\n }\n }\n }\n }\n\n // - detect if an epsilon rule is being processed and act accordingly:\n if (!l1 && first_index == null) {\n // epsilon rule span merger. With optional look-ahead in l2.\n if (!dont_look_back) {\n for (var i = (i1 || sp) - 1; i >= 0; i--) {\n l1 = lstack[i];\n if (l1) {\n break;\n }\n }\n }\n if (!l1) {\n if (!l2) {\n // when we still don't have any valid yylloc info, we're looking at an epsilon rule\n // without look-ahead and no preceding terms and/or `dont_look_back` set:\n // in that case we ca do nothing but return NULL/UNDEFINED:\n return undefined;\n } else {\n // shallow-copy L2: after all, we MAY be looking\n // at unconventional yylloc info objects...\n rv = this.copy_yylloc(l2);\n return rv;\n }\n } else {\n // shallow-copy L1, then adjust first col/row 1 column past the end.\n rv = this.copy_yylloc(l1);\n rv.first_line = rv.last_line;\n rv.first_column = rv.last_column;\n rv.range[0] = rv.range[1];\n\n if (l2) {\n // shallow-mixin L2, then adjust last col/row accordingly.\n shallow_copy_noclobber(rv, l2);\n rv.last_line = l2.last_line;\n rv.last_column = l2.last_column;\n rv.range[1] = l2.range[1];\n }\n return rv;\n }\n }\n\n if (!l1) {\n l1 = l2;\n l2 = null;\n }\n if (!l1) {\n return undefined;\n }\n\n // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking\n // at unconventional yylloc info objects...\n rv = this.copy_yylloc(l1);\n\n if (l2) {\n shallow_copy_noclobber(rv, l2);\n rv.last_line = l2.last_line;\n rv.last_column = l2.last_column;\n rv.range[1] = l2.range[1];\n }\n\n return rv;\n };\n\n // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,\n // or else your `lexer`, `sharedState`, etc. references will be *wrong*!\n this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) {\n \"use strict\";\n\n var pei = {\n errStr: msg,\n exception: ex,\n text: lexer.match,\n value: this.copy_yytext(lexer.yytext),\n token: this.describeSymbol(symbol) || symbol,\n token_id: symbol,\n line: lexer.yylineno,\n loc: this.copy_yylloc(lexer.yylloc),\n expected: expected,\n recoverable: recoverable,\n state: state,\n action: action,\n new_state: newState,\n symbol_stack: stack,\n state_stack: sstack,\n value_stack: vstack,\n location_stack: lstack,\n stack_pointer: sp,\n yy: sharedState_yy,\n lexer: lexer,\n parser: this,\n\n // and make sure the error info doesn't stay due to potential\n // ref cycle via userland code manipulations.\n // These would otherwise all be memory leak opportunities!\n //\n // Note that only array and object references are nuked as those\n // constitute the set of elements which can produce a cyclic ref.\n // The rest of the members is kept intact as they are harmless.\n destroy: function destructParseErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // info.value = null;\n // info.value_stack = null;\n // ...\n \"use strict\";\n\n var rec = !!this.recoverable;\n for (var key in this) {\n if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n };\n\n // clone some parts of the (possibly enhanced!) errorInfo object\n // to give them some persistence.\n this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) {\n \"use strict\";\n\n var rv = shallow_copy(p);\n\n // remove the large parts which can only cause cyclic references\n // and are otherwise available from the parser kernel anyway.\n delete rv.sharedState_yy;\n delete rv.parser;\n delete rv.lexer;\n\n // lexer.yytext MAY be a complex value object, rather than a simple string/value:\n rv.value = this.copy_yytext(rv.value);\n\n // yylloc info:\n rv.loc = this.copy_yylloc(rv.loc);\n\n // the 'expected' set won't be modified, so no need to clone it:\n //rv.expected = rv.expected.slice();\n\n // symbol stack is a simple array:\n rv.symbol_stack = rv.symbol_stack.slice();\n // ditto for state stack:\n rv.state_stack = rv.state_stack.slice();\n // clone the yylloc's in the location stack?:\n rv.location_stack = rv.location_stack.map(this.copy_yylloc);\n // and the value stack may carry both simple and complex values:\n // shallow-copy the latter.\n rv.value_stack = rv.value_stack.map(this.copy_yytext);\n\n // and we don't bother with the sharedState_yy reference:\n //delete rv.yy;\n\n // now we prepare for tracking the COMBINE actions\n // in the error recovery code path:\n //\n // as we want to keep the maximum error info context, we\n // *scan* the state stack to find the first *empty* slot.\n // This position will surely be AT OR ABOVE the current\n // stack pointer, but we want to keep the 'used but discarded'\n // part of the parse stacks *intact* as those slots carry\n // error context that may be useful when you want to produce\n // very detailed error diagnostic reports.\n //\n // ### Purpose of each stack pointer:\n //\n // - stack_pointer: points at the top of the parse stack\n // **as it existed at the time of the error\n // occurrence, i.e. at the time the stack\n // snapshot was taken and copied into the\n // errorInfo object.**\n // - base_pointer: the bottom of the **empty part** of the\n // stack, i.e. **the start of the rest of\n // the stack space /above/ the existing\n // parse stack. This section will be filled\n // by the error recovery process as it\n // travels the parse state machine to\n // arrive at the resolving error recovery rule.**\n // - info_stack_pointer:\n // this stack pointer points to the **top of\n // the error recovery tracking stack space**, i.e.\n // this stack pointer takes up the role of\n // the `stack_pointer` for the error recovery\n // process. Any mutations in the **parse stack**\n // are **copy-appended** to this part of the\n // stack space, keeping the bottom part of the\n // stack (the 'snapshot' part where the parse\n // state at the time of error occurrence was kept)\n // intact.\n // - root_failure_pointer:\n // copy of the `stack_pointer`...\n //\n for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) {\n // empty\n }\n rv.base_pointer = i;\n rv.info_stack_pointer = i;\n\n rv.root_failure_pointer = rv.stack_pointer;\n\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_recovery_infos.push(rv);\n\n return rv;\n };\n\n function getNonTerminalFromCode(symbol) {\n \"use strict\";\n\n var tokenName = self.getSymbolName(symbol);\n if (!tokenName) {\n tokenName = symbol;\n }\n return tokenName;\n }\n\n//_lexer_without_token_stack:\n\n function stdLex() {\n \"use strict\";\n\n var token = lexer.lex();\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n var tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName: tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n function fastLex() {\n \"use strict\";\n\n var token = lexer.fastLex();\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n var tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName: tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n var lex = stdLex;\n\n//_lexer_with_token_stack:\n\n // lex function that supports token stacks\n function tokenStackLex() {\n \"use strict\";\n\n var token;\n token = tstack.pop() || lexer.lex() || EOF;\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n if (token instanceof Array) {\n // tokenstack CANNOT be nested, i.e. an 'array'-type token\n // now means the `tstack` is empty as this array of tokens\n // could only have originated from the `lexer.lex()`\n // call:\n tstack = token;\n token = tstack.pop();\n }\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n var tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName: tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n//_lexer_with_token_stack_end:\n\n var state, action, r, t;\n var yyval = {\n $: true,\n _$: undefined,\n yy: sharedState_yy\n };\n var p;\n var yyrulelen;\n var this_production;\n var newState;\n var retval = false;\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n // Return the rule stack depth where the nearest error rule can be found.\n // Return -1 when no error recovery rule was found.\n function locateNearestErrorRecoveryRule(state) {\n \"use strict\";\n\n var stack_probe = sp - 1;\n var depth = 0;\n\n // try to recover from error\n while (stack_probe >= 0) {\n // check for error recovery rule in this state\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #test#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n var t = (table[state] && table[state][TERROR]) || NO_ACTION;\n if (t[0]) {\n // We need to make sure we're not cycling forever:\n // once we hit EOF, even when we `yyerrok()` an error, we must\n // prevent the core from running forever,\n // e.g. when parent rules are still expecting certain input to\n // follow after this, for example when you handle an error inside a set\n // of braces which are matched by a parent rule in your grammar.\n //\n // Hence we require that every error handling/recovery attempt\n // *after we've hit EOF* has a diminishing state stack: this means\n // we will ultimately have unwound the state stack entirely and thus\n // terminate the parse in a controlled fashion even when we have\n // very complex error/recovery code interplay in the core + user\n // action code blocks:\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #found#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n if (symbol === EOF) {\n if (lastEofErrorStateDepth > sp - 1 - depth) {\n lastEofErrorStateDepth = sp - 1 - depth;\n } else {\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #skip#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n --stack_probe; // popStack(1): [symbol, action]\n state = sstack[stack_probe];\n ++depth;\n continue;\n }\n }\n return depth;\n }\n if (state === 0 /* $accept rule */ || stack_probe < 1) {\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n return -1; // No suitable error recovery rule available.\n }\n --stack_probe; // popStack(1): [symbol, action]\n state = sstack[stack_probe];\n ++depth;\n }\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n return -1; // No suitable error recovery rule available.\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n try {\n this.__reentrant_call_depth++;\n\n lexer.setInput(input, sharedState_yy);\n\n // NOTE: we *assume* no lexer pre/post handlers are set up *after*\n // this initial `setInput()` call: hence we can now check and decide\n // whether we'll go with the standard, slower, lex() API or the\n // `fast_lex()` one:\n if (typeof lexer.canIUse === 'function') {\n var lexerInfo = lexer.canIUse();\n if (lexerInfo.fastLex && typeof fastLex === 'function') {\n lex = fastLex;\n }\n }\n\n yyloc = this.copy_yylloc(lexer.yylloc);\n lstack[sp] = yyloc;\n vstack[sp] = null;\n sstack[sp] = 0;\n stack[sp] = 0;\n ++sp;\n\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyleng = lexer.yyleng;\n\n if (this.pre_parse) {\n this.pre_parse.call(this, sharedState_yy);\n }\n if (sharedState_yy.pre_parse) {\n sharedState_yy.pre_parse.call(this, sharedState_yy);\n }\n\n newState = sstack[sp - 1];\n for (;;) {\n // retrieve state number from top of stack\n state = newState; // sstack[sp - 1];\n\n // use default actions if available\n if (this.defaultActions[state]) {\n action = 2;\n newState = this.defaultActions[state];\n } else {\n // The single `==` condition below covers both these `===` comparisons in a single\n // operation:\n //\n // if (symbol === null || typeof symbol === 'undefined') ...\n if (!symbol) {\n symbol = lex();\n }\n // read action for current state and first input\n t = (table[state] && table[state][symbol]) || NO_ACTION;\n newState = t[1];\n action = t[0];\n\n if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action });\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n // handle parse error\n if (!action) {\n // first see if there's any chance at hitting an error recovery rule:\n var error_rule_depth = locateNearestErrorRecoveryRule(state);\n var errStr = null;\n var errSymbolDescr = (this.describeSymbol(symbol) || symbol);\n var expected = this.collect_expected_token_set(state);\n\n if (!recovering) {\n // Report error\n errStr = 'Parse error';\n if (typeof lexer.yylineno === 'number') {\n errStr += ' on line ' + (lexer.yylineno + 1);\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += ':\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n } else {\n errStr += ': ';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n\n p = this.constructParseErrorInfo(errStr, null, expected, (error_rule_depth >= 0));\n\n // DO NOT cleanup the old one before we start the new error info track:\n // the old one will *linger* on the error stack and stay alive until we\n // invoke the parser's cleanup API!\n recoveringErrorInfo = this.shallowCopyErrorInfo(p);\n\n if (yydebug) yydebug('error recovery rule detected: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p });\n\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n break;\n }\n\n // Protect against overly blunt userland `parseError` code which *sets*\n // the `recoverable` flag without properly checking first:\n // we always terminate the parse when there's no recovery rule available anyhow!\n if (!p.recoverable || error_rule_depth < 0) {\n break;\n } else {\n // TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process...\n }\n }\n\n if (yydebug) yydebug('after ERROR DETECT: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p });\n\n var esp = recoveringErrorInfo.info_stack_pointer;\n\n // just recovered from another error\n if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) {\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = this.copy_yytext(lexer.yytext);\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n\n // SHIFT current lookahead and grab another\n recoveringErrorInfo.symbol_stack[esp] = symbol;\n recoveringErrorInfo.value_stack[esp] = yytext;\n recoveringErrorInfo.location_stack[esp] = yyloc;\n recoveringErrorInfo.state_stack[esp] = newState; // push state\n ++esp;\n\n preErrorSymbol = 0;\n symbol = lex();\n\n if (yydebug) yydebug('after ERROR RECOVERY-3: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol] });\n }\n\n // try to recover from error\n if (error_rule_depth < 0) {\n ASSERT(recovering > 0, \"line 897\");\n recoveringErrorInfo.info_stack_pointer = esp;\n\n // barf a fatal hairball when we're out of look-ahead symbols and none hit a match\n // while we are still busy recovering from another error:\n var po = this.__error_infos[this.__error_infos.length - 1];\n\n // Report error\n if (typeof lexer.yylineno === 'number') {\n errStr = 'Parsing halted on line ' + (lexer.yylineno + 1) + ' while starting to recover from another error';\n } else {\n errStr = 'Parsing halted while starting to recover from another error';\n }\n\n if (po) {\n errStr += ' -- previous error which resulted in this fatal result: ' + po.errStr;\n } else {\n errStr += ': ';\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += '\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n\n p = this.constructParseErrorInfo(errStr, null, expected, false);\n if (po) {\n p.extra_error_attributes = po;\n }\n\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n\n preErrorSymbol = (symbol === TERROR ? 0 : symbol); // save the lookahead token\n symbol = TERROR; // insert generic error symbol as new lookahead\n\n const EXTRA_STACK_SAMPLE_DEPTH = 3;\n\n // REDUCE/COMBINE the pushed terms/tokens to a new ERROR token:\n recoveringErrorInfo.symbol_stack[esp] = preErrorSymbol;\n if (errStr) {\n recoveringErrorInfo.value_stack[esp] = {\n yytext: this.copy_yytext(lexer.yytext),\n errorRuleDepth: error_rule_depth,\n errStr: errStr,\n errorSymbolDescr: errSymbolDescr,\n expectedStr: expected,\n stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH\n };\n if (yydebug) yydebug('Error recovery process: pushed error info item on the info stack: ', {\n item: vstack[sp],\n sp,\n esp,\n vstack,\n stack,\n sstack,\n combineState: NO_ACTION[1]\n });\n } else {\n recoveringErrorInfo.value_stack[esp] = {\n yytext: this.copy_yytext(lexer.yytext),\n errorRuleDepth: error_rule_depth,\n stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH\n };\n }\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc);\n recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n\n yyval.$ = recoveringErrorInfo;\n yyval._$ = undefined;\n\n yyrulelen = error_rule_depth;\n\n if (yydebug) yydebug('Error recovery process: performAction: COMBINE: ', {\n yyval, yytext, sp, pop_size: yyrulelen, vstack, stack, sstack,\n combineState: NO_ACTION[1]\n });\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, NO_ACTION[1], sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof r !== 'undefined') {\n retval = r;\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // and move the top entries + discarded part of the parse stacks onto the error info stack:\n for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) {\n recoveringErrorInfo.symbol_stack[esp] = stack[idx];\n recoveringErrorInfo.value_stack[esp] = vstack[idx];\n recoveringErrorInfo.location_stack[esp] = lstack[idx];\n recoveringErrorInfo.state_stack[esp] = sstack[idx];\n }\n\n recoveringErrorInfo.symbol_stack[esp] = TERROR;\n recoveringErrorInfo.value_stack[esp] = this.copy_yytext(yyval.$);\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(yyval._$);\n\n // goto new state = table[STATE][NONTERMINAL]\n newState = sstack[sp - 1];\n\n if (this.defaultActions[newState]) {\n recoveringErrorInfo.state_stack[esp] = this.defaultActions[newState];\n } else {\n t = (table[newState] && table[newState][symbol]) || NO_ACTION;\n recoveringErrorInfo.state_stack[esp] = t[1];\n }\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n\n // allow N (default: 3) real symbols to be shifted before reporting a new error\n recovering = ERROR_RECOVERY_TOKEN_DISCARD_COUNT;\n\n if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth: error_rule_depth, symbol: symbol, preErrorSymbol: preErrorSymbol });\n\n // Now duplicate the standard parse machine here, at least its initial\n // couple of rounds until the TERROR symbol is **pushed onto the parse stack**,\n // as we wish to push something special then!\n //\n // Run the state machine in this copy of the parser state machine\n // until we *either* consume the error symbol (and its related information)\n // *or* we run into another error while recovering from this one\n // *or* we execute a `reduce` action which outputs a final parse\n // result (yes, that MAY happen!).\n //\n // We stay in this secondary parse loop until we have completed\n // the *error recovery phase* as the main parse loop (further below)\n // is optimized for regular parse operation and DOES NOT cope with\n // error recovery *at all*.\n //\n // We call the secondary parse loop just below the \"slow parse loop\",\n // while the main parse loop, which is an almost-duplicate of this one,\n // yet optimized for regular parse operation, is called the \"fast\n // parse loop\".\n //\n // Compare this to `bison` & (vanilla) `jison`, both of which have\n // only a single parse loop, which handles everything. Our goal is\n // to eke out every drop of performance in the main parse loop...\n\n ASSERT(recoveringErrorInfo, \"line 1049\");\n ASSERT(symbol === TERROR, \"line 1050\");\n ASSERT(!action, \"line 1051\");\n var errorSymbolFromParser = true;\n for (;;) {\n // retrieve state number from top of stack\n state = newState; // sstack[sp - 1];\n\n // use default actions if available\n if (this.defaultActions[state]) {\n action = 2;\n newState = this.defaultActions[state];\n } else {\n // The single `==` condition below covers both these `===` comparisons in a single\n // operation:\n //\n // if (symbol === null || typeof symbol === 'undefined') ...\n if (!symbol) {\n symbol = lex();\n // **Warning: Edge Case**: the *lexer* may produce\n // TERROR tokens of its own volition: *those* TERROR\n // tokens should be treated like *regular tokens*\n // i.e. tokens which have a lexer-provided `yyvalue`\n // and `yylloc`:\n errorSymbolFromParser = false;\n }\n // read action for current state and first input\n t = (table[state] && table[state][symbol]) || NO_ACTION;\n newState = t[1];\n action = t[0];\n\n if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action });\n\n // encountered another parse error? If so, break out to main loop\n // and take it from there!\n if (!action) {\n if (yydebug) yydebug('**NESTED ERROR DETECTED** while still recovering from previous error');\n\n ASSERT(recoveringErrorInfo, \"line 1087\");\n\n // Prep state variables so that upon breaking out of\n // this \"slow parse loop\" and hitting the `continue;`\n // statement in the outer \"fast parse loop\" we redo\n // the exact same state table lookup as the one above\n // so that the outer=main loop will also correctly\n // detect the 'parse error' state (`!action`) we have\n // just encountered above.\n newState = state;\n break;\n }\n }\n\n if (yydebug) yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) {\n \"use strict\";\n\n if (!nt || !nt.states || !nt.rules)\n return '';\n var rulename = nt.states[state];\n var rulespec = nt.rules[rulename][state];\n return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')';\n })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol });\n\n switch (action) {\n // catch misc. parse failures:\n default:\n // this shouldn't happen, unless resolve defaults are off\n //\n // SILENTLY SIGNAL that the outer \"fast parse loop\" should\n // take care of this internal error condition:\n // prevent useless code duplication now/here.\n break;\n\n // shift:\n case 1:\n stack[sp] = symbol;\n // ### Note/Warning ###\n //\n // The *lexer* may also produce TERROR tokens on its own,\n // so we specifically test for the TERROR we did set up\n // in the error recovery logic further above!\n if (symbol === TERROR && errorSymbolFromParser) {\n // Push a special value onto the stack when we're\n // shifting the `error` symbol that is related to the\n // error we're recovering from.\n ASSERT(recoveringErrorInfo, \"line 1131\");\n vstack[sp] = recoveringErrorInfo;\n lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true);\n } else {\n ASSERT(symbol !== 0, \"line 1135\");\n ASSERT(preErrorSymbol === 0, \"line 1136\");\n vstack[sp] = lexer.yytext;\n lstack[sp] = this.copy_yylloc(lexer.yylloc);\n }\n sstack[sp] = newState; // push state\n\n ++sp;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n var tokenName = this.getSymbolName(symbol || EOF);\n if (!tokenName) {\n tokenName = symbol;\n }\n\n Jison.parserDebugger.push({\n action: 'shift',\n text: lexer.yytext,\n terminal: tokenName,\n terminal_id: symbol\n });\n }\n\n symbol = 0;\n // **Warning: Edge Case**: the *lexer* may have produced\n // TERROR tokens of its own volition: *those* TERROR\n // tokens should be treated like *regular tokens*\n // i.e. tokens which have a lexer-provided `yyvalue`\n // and `yylloc`:\n errorSymbolFromParser = false;\n if (!preErrorSymbol) { // normal execution / no error\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n\n if (recovering > 0) {\n recovering--;\n if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering: recovering, symbol: symbol });\n }\n } else {\n // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode:\n ASSERT(recovering > 0, \"line 1163\");\n symbol = preErrorSymbol;\n preErrorSymbol = 0;\n if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering: recovering, symbol: symbol });\n // read action for current state and first input\n t = (table[newState] && table[newState][symbol]) || NO_ACTION;\n if (!t[0] || symbol === TERROR) {\n // forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where\n // (simple) stuff might have been missing before the token which caused the error we're\n // recovering from now...\n //\n // Also check if the LookAhead symbol isn't the ERROR token we set as part of the error\n // recovery, for then this we would we idling (cycling) on the error forever.\n // Yes, this does not take into account the possibility that the *lexer* may have\n // produced a *new* TERROR token all by itself, but that would be a very peculiar grammar!\n if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering: recovering, symbol: symbol });\n symbol = 0;\n }\n }\n\n // once we have pushed the special ERROR token value,\n // we REMAIN in this inner, \"slow parse loop\" until\n // the entire error recovery phase has completed.\n //\n // ### Note About Edge Case ###\n //\n // Userland action code MAY already have 'reset' the\n // error recovery phase marker `recovering` to ZERO(0)\n // while the error symbol hasn't been shifted onto\n // the stack yet. Hence we only exit this \"slow parse loop\"\n // when *both* conditions are met!\n ASSERT(preErrorSymbol === 0, \"line 1194\");\n if (recovering === 0) {\n break;\n }\n continue;\n\n // reduce:\n case 2:\n this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...\n yyrulelen = this_production[1];\n\n if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol });\n\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n var prereduceValue = vstack.slice(sp - yyrulelen, sp);\n var debuggableProductions = [];\n for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) {\n var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]);\n debuggableProductions.push(debuggableProduction);\n }\n\n // find the current nonterminal name (- nolan)\n var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0];\n var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode);\n\n Jison.parserDebugger.push({\n action: 'reduce',\n nonterminal: currentNonterminal,\n nonterminal_id: currentNonterminalCode,\n prereduce: prereduceValue,\n result: r,\n productions: debuggableProductions,\n text: yyval.$\n });\n }\n\n if (typeof r !== 'undefined') {\n // signal end of error recovery loop AND end of outer parse loop\n action = 3;\n retval = r;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n sp = -2; // magic number: signal outer \"fast parse loop\" ACCEPT state that we already have a properly set up `retval` parser return value.\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // don't overwrite the `symbol` variable: use a local var to speed things up:\n var ntsymbol = this_production[0]; // push nonterminal (reduce)\n stack[sp] = ntsymbol;\n vstack[sp] = yyval.$;\n lstack[sp] = yyval._$;\n // goto new state = table[STATE][NONTERMINAL]\n newState = table[sstack[sp - 1]][ntsymbol];\n sstack[sp] = newState;\n ++sp;\n if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol });\n continue;\n\n // accept:\n case 3:\n retval = true;\n // Return the `$accept` rule's `$$` result, if available.\n //\n // Also note that JISON always adds this top-most `$accept` rule (with implicit,\n // default, action):\n //\n // $accept: $end\n // %{ $$ = $1; @$ = @1; %}\n //\n // which, combined with the parse kernel's `$accept` state behaviour coded below,\n // will produce the `$$` value output of the rule as the parse result,\n // IFF that result is *not* `undefined`. (See also the parser kernel code.)\n //\n // In code:\n //\n // %{\n // @$ = @1; // if location tracking support is included\n // if (typeof $1 !== 'undefined')\n // return $1;\n // else\n // return true; // the default parse result if the rule actions don't produce anything\n // %}\n sp--;\n if (sp >= 0 && typeof vstack[sp] !== 'undefined') {\n retval = vstack[sp];\n }\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n sp = -2; // magic number: signal outer \"fast parse loop\" ACCEPT state that we already have a properly set up `retval` parser return value.\n break;\n }\n\n // break out of loop: we accept or fail with error\n break;\n }\n\n // should we also break out of the regular/outer parse loop,\n // i.e. did the parser already produce a parse result in here?!\n // *or* did we hit an unsupported parse state, to be handled\n // in the `switch/default` code further below?\n ASSERT(action !== 2, \"line 1272\");\n if (!action || action === 1) {\n continue;\n }\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n\n // handle parse error\n if (!action) {\n var errStr;\n var errSymbolDescr = (this.describeSymbol(symbol) || symbol);\n var expected = this.collect_expected_token_set(state);\n\n // Report error\n errStr = 'Parse error';\n if (typeof lexer.yylineno === 'number') {\n errStr += ' on line ' + (lexer.yylineno + 1);\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += ':\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n } else {\n errStr += ': ';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n // we cannot recover from the error!\n p = this.constructParseErrorInfo(errStr, null, expected, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n }\n\n if (yydebug) yydebug('::: MAIN CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) {\n \"use strict\";\n\n if (!nt || !nt.states || !nt.rules)\n return '';\n var rulename = nt.states[state];\n var rulespec = nt.rules[rulename][state];\n return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')';\n })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol });\n\n switch (action) {\n // catch misc. parse failures:\n default:\n // this shouldn't happen, unless resolve defaults are off\n if (action instanceof Array) {\n p = this.constructParseErrorInfo('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol, null, null, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n // Another case of better safe than sorry: in case state transitions come out of another error recovery process\n // or a buggy LUT (LookUp Table):\n p = this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.', null, null, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n\n // shift:\n case 1:\n stack[sp] = symbol;\n vstack[sp] = lexer.yytext;\n lstack[sp] = this.copy_yylloc(lexer.yylloc);\n sstack[sp] = newState; // push state\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n var tokenName = this.getSymbolName(symbol || EOF);\n if (!tokenName) {\n tokenName = symbol;\n }\n\n Jison.parserDebugger.push({\n action: 'shift',\n text: lexer.yytext,\n terminal: tokenName,\n terminal_id: symbol\n });\n }\n\n ++sp;\n\n symbol = 0;\n\n ASSERT(preErrorSymbol === 0, \"line 1352\"); // normal execution / no error\n ASSERT(recovering === 0, \"line 1353\"); // normal execution / no error\n\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n continue;\n\n // reduce:\n case 2:\n ASSERT(preErrorSymbol === 0, \"line 1364\"); // normal execution / no error\n ASSERT(recovering === 0, \"line 1365\"); // normal execution / no error\n\n this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...\n yyrulelen = this_production[1];\n\n if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol });\n\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n var prereduceValue = vstack.slice(sp - yyrulelen, sp);\n var debuggableProductions = [];\n for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) {\n var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]);\n debuggableProductions.push(debuggableProduction);\n }\n\n // find the current nonterminal name (- nolan)\n var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0];\n var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode);\n\n Jison.parserDebugger.push({\n action: 'reduce',\n nonterminal: currentNonterminal,\n nonterminal_id: currentNonterminalCode,\n prereduce: prereduceValue,\n result: r,\n productions: debuggableProductions,\n text: yyval.$\n });\n }\n\n if (typeof r !== 'undefined') {\n retval = r;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // don't overwrite the `symbol` variable: use a local var to speed things up:\n var ntsymbol = this_production[0]; // push nonterminal (reduce)\n stack[sp] = ntsymbol;\n vstack[sp] = yyval.$;\n lstack[sp] = yyval._$;\n // goto new state = table[STATE][NONTERMINAL]\n newState = table[sstack[sp - 1]][ntsymbol];\n sstack[sp] = newState;\n ++sp;\n if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol });\n continue;\n\n // accept:\n case 3:\n if (sp !== -2) {\n retval = true;\n // Return the `$accept` rule's `$$` result, if available.\n //\n // Also note that JISON always adds this top-most `$accept` rule (with implicit,\n // default, action):\n //\n // $accept: $end\n // %{ $$ = $1; @$ = @1; %}\n //\n // which, combined with the parse kernel's `$accept` state behaviour coded below,\n // will produce the `$$` value output of the rule as the parse result,\n // IFF that result is *not* `undefined`. (See also the parser kernel code.)\n //\n // In code:\n //\n // %{\n // @$ = @1; // if location tracking support is included\n // if (typeof $1 !== 'undefined')\n // return $1;\n // else\n // return true; // the default parse result if the rule actions don't produce anything\n // %}\n sp--;\n if (typeof vstack[sp] !== 'undefined') {\n retval = vstack[sp];\n }\n }\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n break;\n }\n\n // break out of loop: we accept or fail with error\n break;\n }\n } catch (ex) {\n // report exceptions through the parseError callback too, but keep the exception intact\n // if it is a known parser or lexer error which has been thrown by parseError() already:\n if (ex instanceof this.JisonParserError) {\n throw ex;\n }\n else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) {\n throw ex;\n }\n\n p = this.constructParseErrorInfo('Parsing aborted due to exception.', ex, null, false);\n retval = false;\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n } finally {\n retval = this.cleanupAfterParse(retval, true, true);\n this.__reentrant_call_depth--;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'return',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n } // /finally\n\n return retval;\n}\n"; // --- END parser kernel --- +parser$4.parse = "\nfunction parse(input, parseParams) {\n let self = this;\n let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage)\n let sstack = new Array(128); // state stack: stores states (column storage)\n let tstack = []; // token stack (only used when `%options token_stack` support has been enabled)\n let vstack = new Array(128); // semantic value stack\n let lstack = new Array(128); // location stack\n let table = this.table;\n let sp = 0; // 'stack pointer': index into the stacks\n let yyloc;\n let yytext;\n let yylineno;\n let yyleng;\n\n let symbol = 0;\n let preErrorSymbol = 0;\n let lastEofErrorStateDepth = Infinity;\n let recoveringErrorInfo = null;\n let recovering = 0; // (only used when the grammar contains error recovery rules)\n const TERROR = this.TERROR;\n const EOF = this.EOF;\n const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3;\n const NO_ACTION = [ 0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */];\n\n let lexer;\n if (this.__lexer__) {\n lexer = this.__lexer__;\n } else {\n lexer = this.__lexer__ = Object.create(this.lexer);\n }\n\n let sharedState_yy = {\n parseError: undefined,\n quoteName: undefined,\n lexer: undefined,\n parser: undefined,\n pre_parse: undefined,\n post_parse: undefined,\n pre_lex: undefined,\n post_lex: undefined,\n parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly!\n };\n\n const ASSERT = (\n typeof assert !== 'function' ?\n function JisonAssert(cond, msg) {\n if (!cond) {\n throw new Error('assertion failed: ' + (msg || '***'));\n }\n } :\n assert\n );\n\n this.yyGetSharedState = function yyGetSharedState() {\n return sharedState_yy;\n };\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n this.yyGetErrorInfoTrack = function yyGetErrorInfoTrack() {\n return recoveringErrorInfo;\n };\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // shallow clone objects & arrays, straight copy of simple `src` values\n // e.g. `lexer.yytext` MAY be a complex value object,\n // rather than a simple string/value.\n //\n // https://jsperf.com/new-array-vs-splice-vs-slice/72\n // https://jsperf.com/instanceof-vs-typeof/20\n // benchmark:: http://127.0.0.1:8080/example/jsperf/#testfile=test0020-typeof-instanceof-isArray.json5\n // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5\n //\n function shallow_copy(src) {\n if (src && typeof src === 'object') {\n // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned\n // using their constructor:\n if (src.constructor !== Object) {\n if (Array.isArray(src)) {\n return src.slice();\n }\n let dst = new src.constructor(src);\n\n // and make sure all custom attributes are added to the clone:\n shallow_copy_noclobber(dst, src);\n return dst;\n }\n // native objects must be cloned a different way:\n {\n //return Object.assign({}, src);\n let dst = {};\n shallow_copy_noclobber(dst, src);\n return dst;\n }\n }\n return src;\n }\n // add elements from `src` to `dst` when:\n // - either the element does not yet exist in `src`\n // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst`\n function shallow_copy_noclobber(dst, src) {\n const chk = Object.prototype.hasOwnProperty;\n for (let k in src) {\n if (!(k in dst)) {\n if (chk.call(src, k)) {\n dst[k] = src[k];\n }\n } else if (src[k] != null && dst[k] == null && chk.call(src, k)) {\n dst[k] = src[k];\n }\n }\n }\n function copy_yylloc_native(loc) {\n let rv = shallow_copy(loc);\n // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries:\n if (rv) {\n rv.range = rv.range.slice();\n }\n return rv;\n }\n\n // copy state\n shallow_copy_noclobber(sharedState_yy, this.yy);\n\n sharedState_yy.lexer = lexer;\n sharedState_yy.parser = this;\n\n // allow userland code to override the yytext and yylloc copy/clone functions:\n this.copy_yytext = this.options.copy_yytext || sharedState_yy.copy_yytext || shallow_copy;\n this.copy_yylloc = this.options.copy_yylloc || sharedState_yy.copy_yylloc || copy_yylloc_native;\n\n let yydebug = false;\n if (this.options.debug) {\n yydebug = function yydebug_impl(msg, obj) {\n let ref_list;\n let ref_names;\n\n function deepClone(from, sub) {\n if (sub == null) {\n ref_list = [];\n ref_names = [];\n sub = 'root';\n }\n if (typeof from === 'function') return '[Function]';\n if (from == null || typeof from !== 'object') return from;\n if (from.constructor !== Object && from.constructor !== Array) {\n return from;\n }\n\n let i = ref_list.indexOf(from);\n if (i >= 0) {\n return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference\n }\n ref_list.push(from);\n ref_names.push(sub);\n\n let to = new from.constructor();\n for (let name in from) {\n if (name === 'parser') continue;\n if (name === 'lexer') continue;\n to[name] = deepClone(from[name], name);\n }\n return to;\n }\n\n obj = obj || {};\n if (obj.symbol) {\n obj.local_yytext = yytext;\n obj.lexer_yytext = lexer.yytext;\n obj.lexer_yylloc = lexer.yylloc;\n obj.lexer_yyllineno = lexer.yyllineno;\n }\n\n // warning: here we fetch from closure (stack et al)\n obj.symbol_stack = stack;\n obj.state_stack = sstack;\n obj.value_stack = vstack;\n obj.location_stack = lstack;\n obj.stack_pointer = sp;\n\n // ready the object for printing:\n obj = deepClone(obj);\n\n // wrap try/catch in a function to help the V8 JIT compiler...\n function yydebug_cvt(obj) {\n let js;\n try {\n let re1;\n if (typeof XRegExp === 'undefined') {\n re1 = / {2}\\\"([a-z_][a-z_0-9. ]*)\\\": /ig;\n } else {\n re1 = new XRegExp(' \\\"([\\\\p{Alphabetic}_][\\\\p{Alphabetic}\\\\p{Number}_. ]*)\\\": ', 'g');\n }\n js = JSON.stringify(obj, null, 2)\n .replace(re1, ' $1: ')\n .replace(/[\\n\\s]+/g, ' ')\n // shorten yylloc object dumps too:\n .replace(/\\{ first_line: (\\d+), first_column: (\\d+), last_line: (\\d+), last_column: (\\d+)/g, '{L/C: ($1,$2)..($3,$4)');\n } catch (ex) {\n js = String(obj);\n }\n return js;\n }\n\n self.trace(msg, yydebug_cvt(obj), '\\n');\n };\n }\n\n // disable debugging at run-time ANYWAY when you've *explicitly* set \"yy.yydebug = false\":\n if (sharedState_yy.yydebug === false) {\n yydebug = undefined;\n }\n\n // *Always* setup `yyError`, `YYRECOVERING`, `yyErrOk` and `yyClearIn` functions as it is paramount\n // to have *their* closure match ours -- if we only set them up once,\n // any subsequent `parse()` runs will fail in very obscure ways when\n // these functions are invoked in the user action code block(s) as\n // their closure will still refer to the `parse()` instance which set\n // them up. Hence we MUST set them up at the start of every `parse()` run!\n if (this.yyError) {\n this.yyError = function yyError(str /*, ...args */) {\n if (yydebug) {\n yydebug('yyerror: ', {\n message: str,\n args: arguments,\n symbol, state, newState, recovering, action\n });\n }\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1);\n let expected = this.collect_expected_token_set(state);\n let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0));\n // append to the old one?\n if (recoveringErrorInfo) {\n let esp = recoveringErrorInfo.info_stack_pointer;\n\n recoveringErrorInfo.symbol_stack[esp] = symbol;\n let v = this.shallowCopyErrorInfo(hash);\n v.yyError = true;\n v.errorRuleDepth = error_rule_depth;\n v.recovering = recovering;\n // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH;\n\n recoveringErrorInfo.value_stack[esp] = v;\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc);\n recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n } else {\n recoveringErrorInfo = this.shallowCopyErrorInfo(hash);\n recoveringErrorInfo.yyError = true;\n recoveringErrorInfo.errorRuleDepth = error_rule_depth;\n recoveringErrorInfo.recovering = recovering;\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n\n let expected = this.collect_expected_token_set(state);\n let hash = this.constructParseErrorInfo(str, null, expected, false);\n\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n let args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n hash.extra_error_attributes = args;\n }\n\n return this.parseError(str, hash, this.JisonParserError);\n };\n }\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n if (this.yyRecovering) {\n this.yyRecovering = function yyRecovering() {\n if (yydebug) yydebug('yyrecovering: ', { symbol, state, newState, recovering, action });\n return recovering;\n };\n }\n\n if (this.yyErrOk) {\n this.yyErrOk = function yyErrOk() {\n if (yydebug) yydebug('yyerrok: ', { symbol, state, newState, recovering, action });\n recovering = 0;\n\n // DO NOT reset/cleanup `recoveringErrorInfo` yet: userland code\n // MAY invoke this API before the error is actually fully\n // recovered, in which case the parser recovery code won't be able\n // to append the skipped tokens to this info object.\n //\n // The rest of the kernel code is safe enough that it won't inadvertedly\n // re-use an old `recoveringErrorInfo` chunk so we'ld better wait\n // with destruction/cleanup until the end of the parse or until another\n // fresh parse error rears its ugly head...\n //\n // if (recoveringErrorInfo && typeof recoveringErrorInfo.destroy === 'function') {\n // recoveringErrorInfo.destroy();\n // recoveringErrorInfo = undefined;\n // }\n };\n }\n\n if (this.yyClearIn) {\n this.yyClearIn = function yyClearIn() {\n if (yydebug) yydebug('yyclearin: ', { symbol, newState, recovering, action, preErrorSymbol });\n if (symbol === TERROR) {\n symbol = 0;\n yytext = null;\n yyleng = 0;\n yyloc = undefined;\n }\n preErrorSymbol = 0;\n };\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // Does the shared state override the default `parseError` that already comes with this instance?\n if (typeof sharedState_yy.parseError === 'function') {\n this.parseError = function parseErrorAlt(str, hash, ExceptionClass) {\n if (!ExceptionClass) {\n ExceptionClass = this.JisonParserError;\n }\n return sharedState_yy.parseError.call(this, str, hash, ExceptionClass);\n };\n } else {\n this.parseError = this.originalParseError;\n }\n\n // Does the shared state override the default `quoteName` that already comes with this instance?\n if (typeof sharedState_yy.quoteName === 'function') {\n this.quoteName = function quoteNameAlt(id_str) {\n return sharedState_yy.quoteName.call(this, id_str);\n };\n } else {\n this.quoteName = this.originalQuoteName;\n }\n\n // set up the cleanup function; make it an API so that external code can re-use this one in case of\n // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which\n // case this parse() API method doesn't come with a `finally { ... }` block any more!\n //\n // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,\n // or else your `sharedState`, etc. references will be *wrong*!\n this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) {\n let rv;\n\n if (invoke_post_methods) {\n let hash;\n\n if (sharedState_yy.post_parse || this.post_parse) {\n // create an error hash info instance: we re-use this API in a **non-error situation**\n // as this one delivers all parser internals ready for access by userland code.\n hash = this.constructParseErrorInfo(null /* no error! */, null /* no exception! */, null, false);\n }\n\n if (sharedState_yy.post_parse) {\n rv = sharedState_yy.post_parse.call(this, sharedState_yy, resultValue, hash);\n if (typeof rv !== 'undefined') resultValue = rv;\n }\n if (this.post_parse) {\n rv = this.post_parse.call(this, sharedState_yy, resultValue, hash);\n if (typeof rv !== 'undefined') resultValue = rv;\n }\n\n // cleanup:\n if (hash && hash.destroy) {\n hash.destroy();\n }\n }\n\n if (this.__reentrant_call_depth > 1) return resultValue; // do not (yet) kill the sharedState when this is a reentrant run.\n\n // clean up the lingering lexer structures as well:\n if (lexer.cleanupAfterLex) {\n lexer.cleanupAfterLex(do_not_nuke_errorinfos);\n }\n\n // prevent lingering circular references from causing memory leaks:\n if (sharedState_yy) {\n sharedState_yy.lexer = undefined;\n sharedState_yy.parser = undefined;\n if (lexer.yy === sharedState_yy) {\n lexer.yy = undefined;\n }\n }\n sharedState_yy = undefined;\n this.parseError = this.originalParseError;\n this.quoteName = this.originalQuoteName;\n\n // nuke the vstack[] array at least as that one will still reference obsoleted user values.\n // To be safe, we nuke the other internal stack columns as well...\n stack.length = 0; // fastest way to nuke an array without overly bothering the GC\n sstack.length = 0;\n lstack.length = 0;\n vstack.length = 0;\n sp = 0;\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (let i = this.__error_infos.length - 1; i >= 0; i--) {\n let el = this.__error_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) {\n let el = this.__error_recovery_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_recovery_infos.length = 0;\n\n // `recoveringErrorInfo` is also part of the `__error_recovery_infos` array,\n // hence has been destroyed already: no need to do that *twice*.\n if (recoveringErrorInfo) {\n recoveringErrorInfo = undefined;\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n }\n\n return resultValue;\n };\n\n // merge yylloc info into a new yylloc instance.\n //\n // `first_index` and `last_index` MAY be UNDEFINED/NULL or these are indexes into the `lstack[]` location stack array.\n //\n // `first_yylloc` and `last_yylloc` MAY be UNDEFINED/NULL or explicit (custom or regular) `yylloc` instances, in which\n // case these override the corresponding first/last indexes.\n //\n // `dont_look_back` is an optional flag (default: FALSE), which instructs this merge operation NOT to search\n // through the parse location stack for a location, which would otherwise be used to construct the new (epsilon!)\n // yylloc info.\n //\n // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL.\n this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) {\n let i1 = first_index | 0;\n let i2 = last_index | 0;\n let l1 = first_yylloc;\n let l2 = last_yylloc;\n let rv;\n\n // rules:\n // - first/last yylloc entries override first/last indexes\n\n if (!l1) {\n if (first_index != null) {\n for (let i = i1; i <= i2; i++) {\n l1 = lstack[i];\n if (l1) {\n break;\n }\n }\n }\n }\n\n if (!l2) {\n if (last_index != null) {\n for (let i = i2; i >= i1; i--) {\n l2 = lstack[i];\n if (l2) {\n break;\n }\n }\n }\n }\n\n // - detect if an epsilon rule is being processed and act accordingly:\n if (!l1 && first_index == null) {\n // epsilon rule span merger. With optional look-ahead in l2.\n if (!dont_look_back) {\n for (let i = (i1 || sp) - 1; i >= 0; i--) {\n l1 = lstack[i];\n if (l1) {\n break;\n }\n }\n }\n if (!l1) {\n if (!l2) {\n // when we still don't have any valid yylloc info, we're looking at an epsilon rule\n // without look-ahead and no preceding terms and/or `dont_look_back` set:\n // in that case we ca do nothing but return NULL/UNDEFINED:\n return null;\n }\n // shallow-copy L2: after all, we MAY be looking\n // at unconventional yylloc info objects...\n rv = this.copy_yylloc(l2);\n return rv;\n }\n // shallow-copy L1, then adjust first col/row 1 column past the end.\n rv = this.copy_yylloc(l1);\n rv.first_line = rv.last_line;\n rv.first_column = rv.last_column;\n rv.range[0] = rv.range[1];\n\n if (l2) {\n // shallow-mixin L2, then adjust last col/row accordingly.\n shallow_copy_noclobber(rv, l2);\n rv.last_line = l2.last_line;\n rv.last_column = l2.last_column;\n rv.range[1] = l2.range[1];\n }\n return rv;\n }\n\n if (!l1) {\n l1 = l2;\n l2 = null;\n }\n if (!l1) {\n return null;\n }\n\n // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking\n // at unconventional yylloc info objects...\n rv = this.copy_yylloc(l1);\n\n if (l2) {\n shallow_copy_noclobber(rv, l2);\n rv.last_line = l2.last_line;\n rv.last_column = l2.last_column;\n rv.range[1] = l2.range[1];\n }\n\n return rv;\n };\n\n // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,\n // or else your `lexer`, `sharedState`, etc. references will be *wrong*!\n this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) {\n const pei = {\n errStr: msg,\n exception: ex,\n text: lexer.match,\n value: this.copy_yytext(lexer.yytext),\n token: this.describeSymbol(symbol) || symbol,\n token_id: symbol,\n line: lexer.yylineno,\n loc: this.copy_yylloc(lexer.yylloc),\n expected,\n recoverable,\n state,\n action,\n new_state: newState,\n symbol_stack: stack,\n state_stack: sstack,\n value_stack: vstack,\n location_stack: lstack,\n stack_pointer: sp,\n yy: sharedState_yy,\n lexer,\n parser: this,\n\n // and make sure the error info doesn't stay due to potential\n // ref cycle via userland code manipulations.\n // These would otherwise all be memory leak opportunities!\n //\n // Note that only array and object references are nuked as those\n // constitute the set of elements which can produce a cyclic ref.\n // The rest of the members is kept intact as they are harmless.\n destroy: function destructParseErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // info.value = null;\n // info.value_stack = null;\n // ...\n const rec = !!this.recoverable;\n for (let key in this) {\n if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n };\n\n // clone some parts of the (possibly enhanced!) errorInfo object\n // to give them some persistence.\n this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) {\n let rv = shallow_copy(p);\n\n // remove the large parts which can only cause cyclic references\n // and are otherwise available from the parser kernel anyway.\n delete rv.sharedState_yy;\n delete rv.parser;\n delete rv.lexer;\n\n // lexer.yytext MAY be a complex value object, rather than a simple string/value:\n rv.value = this.copy_yytext(rv.value);\n\n // yylloc info:\n rv.loc = this.copy_yylloc(rv.loc);\n\n // the 'expected' set won't be modified, so no need to clone it:\n //rv.expected = rv.expected.slice();\n\n // symbol stack is a simple array:\n rv.symbol_stack = rv.symbol_stack.slice();\n // ditto for state stack:\n rv.state_stack = rv.state_stack.slice();\n // clone the yylloc's in the location stack?:\n rv.location_stack = rv.location_stack.map(this.copy_yylloc);\n // and the value stack may carry both simple and complex values:\n // shallow-copy the latter.\n rv.value_stack = rv.value_stack.map(this.copy_yytext);\n\n // and we don't bother with the sharedState_yy reference:\n //delete rv.yy;\n\n // now we prepare for tracking the COMBINE actions\n // in the error recovery code path:\n //\n // as we want to keep the maximum error info context, we\n // *scan* the state stack to find the first *empty* slot.\n // This position will surely be AT OR ABOVE the current\n // stack pointer, but we want to keep the 'used but discarded'\n // part of the parse stacks *intact* as those slots carry\n // error context that may be useful when you want to produce\n // very detailed error diagnostic reports.\n //\n // ### Purpose of each stack pointer:\n //\n // - stack_pointer: points at the top of the parse stack\n // **as it existed at the time of the error\n // occurrence, i.e. at the time the stack\n // snapshot was taken and copied into the\n // errorInfo object.**\n // - base_pointer: the bottom of the **empty part** of the\n // stack, i.e. **the start of the rest of\n // the stack space /above/ the existing\n // parse stack. This section will be filled\n // by the error recovery process as it\n // travels the parse state machine to\n // arrive at the resolving error recovery rule.**\n // - info_stack_pointer:\n // this stack pointer points to the **top of\n // the error recovery tracking stack space**, i.e.\n // this stack pointer takes up the role of\n // the `stack_pointer` for the error recovery\n // process. Any mutations in the **parse stack**\n // are **copy-appended** to this part of the\n // stack space, keeping the bottom part of the\n // stack (the 'snapshot' part where the parse\n // state at the time of error occurrence was kept)\n // intact.\n // - root_failure_pointer:\n // copy of the `stack_pointer`...\n //\n {\n let i;\n for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) {\n // empty\n }\n rv.base_pointer = i;\n rv.info_stack_pointer = i;\n }\n\n rv.root_failure_pointer = rv.stack_pointer;\n\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_recovery_infos.push(rv);\n\n return rv;\n };\n\n function getNonTerminalFromCode(symbol) {\n let tokenName = self.getSymbolName(symbol);\n if (!tokenName) {\n tokenName = symbol;\n }\n return tokenName;\n }\n\n//_lexer_without_token_stack:\n\n function stdLex() {\n let token = lexer.lex();\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n let tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n function fastLex() {\n let token = lexer.fastLex();\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n let tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n let lex = stdLex;\n\n//_lexer_with_token_stack:\n\n // lex function that supports token stacks\n function tokenStackLex() {\n let token;\n token = tstack.pop() || lexer.lex() || EOF;\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n if (token instanceof Array) {\n // tokenstack CANNOT be nested, i.e. an 'array'-type token\n // now means the `tstack` is empty as this array of tokens\n // could only have originated from the `lexer.lex()`\n // call:\n tstack = token;\n token = tstack.pop();\n }\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n let tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n//_lexer_with_token_stack_end:\n\n let state, action, r, t;\n let yyval = {\n $: true,\n _$: undefined,\n yy: sharedState_yy\n };\n let p;\n let yyrulelen;\n let this_production;\n let newState;\n let retval = false;\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n // Return the rule stack depth where the nearest error rule can be found.\n // Return -1 when no error recovery rule was found.\n function locateNearestErrorRecoveryRule(state) {\n let stack_probe = sp - 1;\n let depth = 0;\n\n // try to recover from error\n while (stack_probe >= 0) {\n // check for error recovery rule in this state\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #test#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n const t = (table[state] && table[state][TERROR]) || NO_ACTION;\n if (t[0]) {\n // We need to make sure we're not cycling forever:\n // once we hit EOF, even when we `yyerrok()` an error, we must\n // prevent the core from running forever,\n // e.g. when parent rules are still expecting certain input to\n // follow after this, for example when you handle an error inside a set\n // of braces which are matched by a parent rule in your grammar.\n //\n // Hence we require that every error handling/recovery attempt\n // *after we've hit EOF* has a diminishing state stack: this means\n // we will ultimately have unwound the state stack entirely and thus\n // terminate the parse in a controlled fashion even when we have\n // very complex error/recovery code interplay in the core + user\n // action code blocks:\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #found#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n if (symbol === EOF) {\n if (lastEofErrorStateDepth > sp - 1 - depth) {\n lastEofErrorStateDepth = sp - 1 - depth;\n } else {\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #skip#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n --stack_probe; // popStack(1): [symbol, action]\n state = sstack[stack_probe];\n ++depth;\n continue;\n }\n }\n return depth;\n }\n if (state === 0 /* $accept rule */ || stack_probe < 1) {\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n return -1; // No suitable error recovery rule available.\n }\n --stack_probe; // popStack(1): [symbol, action]\n state = sstack[stack_probe];\n ++depth;\n }\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n return -1; // No suitable error recovery rule available.\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n try {\n this.__reentrant_call_depth++;\n\n lexer.setInput(input, sharedState_yy);\n\n // NOTE: we *assume* no lexer pre/post handlers are set up *after*\n // this initial `setInput()` call: hence we can now check and decide\n // whether we'll go with the standard, slower, lex() API or the\n // `fast_lex()` one:\n if (typeof lexer.canIUse === 'function') {\n let lexerInfo = lexer.canIUse();\n if (lexerInfo.fastLex && typeof fastLex === 'function') {\n lex = fastLex;\n }\n }\n\n yyloc = this.copy_yylloc(lexer.yylloc);\n lstack[sp] = yyloc;\n vstack[sp] = null;\n sstack[sp] = 0;\n stack[sp] = 0;\n ++sp;\n\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyleng = lexer.yyleng;\n\n if (this.pre_parse) {\n this.pre_parse.call(this, sharedState_yy);\n }\n if (sharedState_yy.pre_parse) {\n sharedState_yy.pre_parse.call(this, sharedState_yy);\n }\n\n newState = sstack[sp - 1];\n for (;;) {\n // retrieve state number from top of stack\n state = newState; // sstack[sp - 1];\n\n // use default actions if available\n if (this.defaultActions[state]) {\n action = 2;\n newState = this.defaultActions[state];\n } else {\n // The single `==` condition below covers both these `===` comparisons in a single\n // operation:\n //\n // if (symbol === null || typeof symbol === 'undefined') ...\n if (!symbol) {\n symbol = lex();\n }\n // read action for current state and first input\n t = (table[state] && table[state][symbol]) || NO_ACTION;\n newState = t[1];\n action = t[0];\n\n if (yydebug) {\n yydebug('after FETCH/LEX: ', {\n symbol,\n symbolID: this.terminals_ && this.terminals_[symbol],\n state, newState, recovering, action\n });\n }\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n // handle parse error\n if (!action) {\n // first see if there's any chance at hitting an error recovery rule:\n let error_rule_depth = locateNearestErrorRecoveryRule(state);\n let errStr = null;\n let errSymbolDescr = (this.describeSymbol(symbol) || symbol);\n let expected = this.collect_expected_token_set(state);\n\n if (!recovering) {\n // Report error\n errStr = 'Parse error';\n if (typeof lexer.yylineno === 'number') {\n errStr += ' on line ' + (lexer.yylineno + 1);\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += ':\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n } else {\n errStr += ': ';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n\n p = this.constructParseErrorInfo(errStr, null, expected, (error_rule_depth >= 0));\n\n // DO NOT cleanup the old one before we start the new error info track:\n // the old one will *linger* on the error stack and stay alive until we\n // invoke the parser's cleanup API!\n recoveringErrorInfo = this.shallowCopyErrorInfo(p);\n\n if (yydebug) {\n yydebug('error recovery rule detected: ', {\n error_rule_depth,\n error: p.errStr,\n error_hash: p\n });\n }\n\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n break;\n }\n\n // Protect against overly blunt userland `parseError` code which *sets*\n // the `recoverable` flag without properly checking first:\n // we always terminate the parse when there's no recovery rule available anyhow!\n if (!p.recoverable || error_rule_depth < 0) {\n break;\n } else {\n // TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process...\n }\n }\n\n if (yydebug) {\n yydebug('after ERROR DETECT: ', {\n error_rule_depth,\n error: p.errStr,\n error_hash: p\n });\n }\n\n let esp = recoveringErrorInfo.info_stack_pointer;\n\n // just recovered from another error\n if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) {\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = this.copy_yytext(lexer.yytext);\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n\n // SHIFT current lookahead and grab another\n recoveringErrorInfo.symbol_stack[esp] = symbol;\n recoveringErrorInfo.value_stack[esp] = yytext;\n recoveringErrorInfo.location_stack[esp] = yyloc;\n recoveringErrorInfo.state_stack[esp] = newState; // push state\n ++esp;\n\n preErrorSymbol = 0;\n symbol = lex();\n\n if (yydebug) {\n yydebug('after ERROR RECOVERY-3: ', {\n symbol,\n symbolID: this.terminals_ && this.terminals_[symbol]\n });\n }\n }\n\n // try to recover from error\n if (error_rule_depth < 0) {\n ASSERT(recovering > 0, 'Line 1048');\n recoveringErrorInfo.info_stack_pointer = esp;\n\n // barf a fatal hairball when we're out of look-ahead symbols and none hit a match\n // while we are still busy recovering from another error:\n let po = this.__error_infos[this.__error_infos.length - 1];\n\n // Report error\n if (typeof lexer.yylineno === 'number') {\n errStr = 'Parsing halted on line ' + (lexer.yylineno + 1) + ' while starting to recover from another error';\n } else {\n errStr = 'Parsing halted while starting to recover from another error';\n }\n\n if (po) {\n errStr += ' -- previous error which resulted in this fatal result: ' + po.errStr;\n } else {\n errStr += ': ';\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += '\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n\n p = this.constructParseErrorInfo(errStr, null, expected, false);\n if (po) {\n p.extra_error_attributes = po;\n }\n\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n\n preErrorSymbol = (symbol === TERROR ? 0 : symbol); // save the lookahead token\n symbol = TERROR; // insert generic error symbol as new lookahead\n\n const EXTRA_STACK_SAMPLE_DEPTH = 3;\n\n // REDUCE/COMBINE the pushed terms/tokens to a new ERROR token:\n recoveringErrorInfo.symbol_stack[esp] = preErrorSymbol;\n if (errStr) {\n recoveringErrorInfo.value_stack[esp] = {\n yytext: this.copy_yytext(lexer.yytext),\n errorRuleDepth: error_rule_depth,\n errStr,\n errSymbolDescr,\n expectedStr: expected,\n stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH\n };\n if (yydebug) {\n yydebug('Error recovery process: pushed error info item on the info stack: ', {\n item: vstack[sp],\n sp, esp, vstack, stack, sstack,\n combineState: NO_ACTION[1]\n });\n }\n } else {\n recoveringErrorInfo.value_stack[esp] = {\n yytext: this.copy_yytext(lexer.yytext),\n errorRuleDepth: error_rule_depth,\n stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH\n };\n }\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc);\n recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n\n yyval.$ = recoveringErrorInfo;\n yyval._$ = undefined;\n\n yyrulelen = error_rule_depth;\n\n let combineState = NO_ACTION[1];\n\n if (yydebug) {\n yydebug('Error recovery process: performAction: COMBINE: ', {\n yyval, yytext, sp,\n pop_size: yyrulelen,\n vstack, stack, sstack,\n combineState\n });\n }\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, combineState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof r !== 'undefined') {\n retval = r;\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // and move the top entries + discarded part of the parse stacks onto the error info stack:\n for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) {\n recoveringErrorInfo.symbol_stack[esp] = stack[idx];\n recoveringErrorInfo.value_stack[esp] = vstack[idx];\n recoveringErrorInfo.location_stack[esp] = lstack[idx];\n recoveringErrorInfo.state_stack[esp] = sstack[idx];\n }\n\n recoveringErrorInfo.symbol_stack[esp] = TERROR;\n recoveringErrorInfo.value_stack[esp] = this.copy_yytext(yyval.$);\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(yyval._$);\n\n // goto new state = table[STATE][NONTERMINAL]\n newState = sstack[sp - 1];\n\n if (this.defaultActions[newState]) {\n recoveringErrorInfo.state_stack[esp] = this.defaultActions[newState];\n } else {\n t = (table[newState] && table[newState][symbol]) || NO_ACTION;\n recoveringErrorInfo.state_stack[esp] = t[1];\n }\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n\n // allow N (default: 3) real symbols to be shifted before reporting a new error\n recovering = ERROR_RECOVERY_TOKEN_DISCARD_COUNT;\n\n if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth, symbol, preErrorSymbol });\n\n // Now duplicate the standard parse machine here, at least its initial\n // couple of rounds until the TERROR symbol is **pushed onto the parse stack**,\n // as we wish to push something special then!\n //\n // Run the state machine in this copy of the parser state machine\n // until we *either* consume the error symbol (and its related information)\n // *or* we run into another error while recovering from this one\n // *or* we execute a `reduce` action which outputs a final parse\n // result (yes, that MAY happen!).\n //\n // We stay in this secondary parse loop until we have completed\n // the *error recovery phase* as the main parse loop (further below)\n // is optimized for regular parse operation and DOES NOT cope with\n // error recovery *at all*.\n //\n // We call the secondary parse loop just below the \"slow parse loop\",\n // while the main parse loop, which is an almost-duplicate of this one,\n // yet optimized for regular parse operation, is called the \"fast\n // parse loop\".\n //\n // Compare this to `bison` & (vanilla) `jison`, both of which have\n // only a single parse loop, which handles everything. Our goal is\n // to eke out every drop of performance in the main parse loop...\n\n ASSERT(recoveringErrorInfo, 'Line 1204');\n ASSERT(symbol === TERROR, 'Line 1205');\n ASSERT(!action, 'Line 1206');\n let errorSymbolFromParser = true;\n for (;;) {\n // retrieve state number from top of stack\n state = newState; // sstack[sp - 1];\n\n // use default actions if available\n if (this.defaultActions[state]) {\n action = 2;\n newState = this.defaultActions[state];\n } else {\n // The single `==` condition below covers both these `===` comparisons in a single\n // operation:\n //\n // if (symbol === null || typeof symbol === 'undefined') ...\n if (!symbol) {\n symbol = lex();\n // **Warning: Edge Case**: the *lexer* may produce\n // TERROR tokens of its own volition: *those* TERROR\n // tokens should be treated like *regular tokens*\n // i.e. tokens which have a lexer-provided `yyvalue`\n // and `yylloc`:\n errorSymbolFromParser = false;\n }\n // read action for current state and first input\n t = (table[state] && table[state][symbol]) || NO_ACTION;\n newState = t[1];\n action = t[0];\n\n if (yydebug) {\n yydebug('after FETCH/LEX: ', {\n symbol,\n symbolID: this.terminals_ && this.terminals_[symbol],\n state, newState, recovering, action\n });\n }\n\n // encountered another parse error? If so, break out to main loop\n // and take it from there!\n if (!action) {\n if (yydebug) yydebug('**NESTED ERROR DETECTED** while still recovering from previous error');\n\n ASSERT(recoveringErrorInfo, 'Line 1248');\n\n // Prep state variables so that upon breaking out of\n // this \"slow parse loop\" and hitting the `continue;`\n // statement in the outer \"fast parse loop\" we redo\n // the exact same state table lookup as the one above\n // so that the outer=main loop will also correctly\n // detect the 'parse error' state (`!action`) we have\n // just encountered above.\n newState = state;\n break;\n }\n }\n\n if (yydebug) {\n yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' +\n (action === 1 ?\n 'shift token ' + symbol + ' (then go to state ' + newState + ')' :\n action === 2 ?\n 'reduce by rule: ' + newState + (function __print_rule(nt, state) {\n if (!nt || !nt.states || !nt.rules) {\n return '';\n }\n let rulename = nt.states[state];\n let rulespec = nt.rules[rulename][state];\n return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')';\n })(this.nonterminals_, newState) :\n action === 3 ?\n 'accept' :\n '???unexpected???'\n ), {\n action, newState, recovering, symbol\n });\n }\n\n switch (action) {\n // catch misc. parse failures:\n default:\n // this shouldn't happen, unless resolve defaults are off\n //\n // SILENTLY SIGNAL that the outer \"fast parse loop\" should\n // take care of this internal error condition:\n // prevent useless code duplication now/here.\n break;\n\n // shift:\n case 1:\n stack[sp] = symbol;\n // ### Note/Warning ###\n //\n // The *lexer* may also produce TERROR tokens on its own,\n // so we specifically test for the TERROR we did set up\n // in the error recovery logic further above!\n if (symbol === TERROR && errorSymbolFromParser) {\n // Push a special value onto the stack when we're\n // shifting the `error` symbol that is related to the\n // error we're recovering from.\n ASSERT(recoveringErrorInfo, 'Line 1305');\n vstack[sp] = recoveringErrorInfo;\n lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true);\n } else {\n ASSERT(symbol !== 0, 'Line 1309');\n ASSERT(preErrorSymbol === 0, 'Line 1310');\n vstack[sp] = lexer.yytext;\n lstack[sp] = this.copy_yylloc(lexer.yylloc);\n }\n sstack[sp] = newState; // push state\n\n ++sp;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n let tokenName = this.getSymbolName(symbol || EOF);\n if (!tokenName) {\n tokenName = symbol;\n }\n\n Jison.parserDebugger.push({\n action: 'shift',\n text: lexer.yytext,\n terminal: tokenName,\n terminal_id: symbol\n });\n }\n\n symbol = 0;\n // **Warning: Edge Case**: the *lexer* may have produced\n // TERROR tokens of its own volition: *those* TERROR\n // tokens should be treated like *regular tokens*\n // i.e. tokens which have a lexer-provided `yyvalue`\n // and `yylloc`:\n errorSymbolFromParser = false;\n if (!preErrorSymbol) { // normal execution / no error\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n\n if (recovering > 0) {\n recovering--;\n if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering, symbol });\n }\n } else {\n // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode:\n ASSERT(recovering > 0, 'Line 1352');\n symbol = preErrorSymbol;\n preErrorSymbol = 0;\n if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering, symbol });\n // read action for current state and first input\n t = (table[newState] && table[newState][symbol]) || NO_ACTION;\n if (!t[0] || symbol === TERROR) {\n // forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where\n // (simple) stuff might have been missing before the token which caused the error we're\n // recovering from now...\n //\n // Also check if the LookAhead symbol isn't the ERROR token we set as part of the error\n // recovery, for then this we would we idling (cycling) on the error forever.\n // Yes, this does not take into account the possibility that the *lexer* may have\n // produced a *new* TERROR token all by itself, but that would be a very peculiar grammar!\n if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering, symbol });\n symbol = 0;\n }\n }\n\n // once we have pushed the special ERROR token value,\n // we REMAIN in this inner, \"slow parse loop\" until\n // the entire error recovery phase has completed.\n //\n // ### Note About Edge Case ###\n //\n // Userland action code MAY already have 'reset' the\n // error recovery phase marker `recovering` to ZERO(0)\n // while the error symbol hasn't been shifted onto\n // the stack yet. Hence we only exit this \"slow parse loop\"\n // when *both* conditions are met!\n ASSERT(preErrorSymbol === 0, 'Line 1383');\n if (recovering === 0) {\n break;\n }\n continue;\n\n // reduce:\n case 2:\n this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...\n yyrulelen = this_production[1];\n\n if (yydebug) {\n yydebug('~~~ REDUCE: ', {\n pop_size: yyrulelen,\n newState, recovering, symbol\n });\n }\n\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n let prereduceValue = vstack.slice(sp - yyrulelen, sp);\n let debuggableProductions = [];\n for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) {\n let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]);\n debuggableProductions.push(debuggableProduction);\n }\n\n // find the current nonterminal name (- nolan)\n let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0];\n let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode);\n\n Jison.parserDebugger.push({\n action: 'reduce',\n nonterminal: currentNonterminal,\n nonterminal_id: currentNonterminalCode,\n prereduce: prereduceValue,\n result: r,\n productions: debuggableProductions,\n text: yyval.$\n });\n }\n\n if (typeof r !== 'undefined') {\n // signal end of error recovery loop AND end of outer parse loop\n action = 3;\n retval = r;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n sp = -2; // magic number: signal outer \"fast parse loop\" ACCEPT state that we already have a properly set up `retval` parser return value.\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // don't overwrite the `symbol` variable: use a local var to speed things up:\n {\n let ntsymbol = this_production[0]; // push nonterminal (reduce)\n stack[sp] = ntsymbol;\n vstack[sp] = yyval.$;\n lstack[sp] = yyval._$;\n // goto new state = table[STATE][NONTERMINAL]\n newState = table[sstack[sp - 1]][ntsymbol];\n sstack[sp] = newState;\n ++sp;\n if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol });\n }\n continue;\n\n // accept:\n case 3:\n retval = true;\n // Return the `$accept` rule's `$$` result, if available.\n //\n // Also note that JISON always adds this top-most `$accept` rule (with implicit,\n // default, action):\n //\n // $accept: $end\n // %{ $$ = $1; @$ = @1; %}\n //\n // which, combined with the parse kernel's `$accept` state behaviour coded below,\n // will produce the `$$` value output of the rule as the parse result,\n // IFF that result is *not* `undefined`. (See also the parser kernel code.)\n //\n // In code:\n //\n // %{\n // @$ = @1; // if location tracking support is included\n // if (typeof $1 !== 'undefined')\n // return $1;\n // else\n // return true; // the default parse result if the rule actions don't produce anything\n // %}\n sp--;\n if (sp >= 0 && typeof vstack[sp] !== 'undefined') {\n retval = vstack[sp];\n }\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n sp = -2; // magic number: signal outer \"fast parse loop\" ACCEPT state that we already have a properly set up `retval` parser return value.\n break;\n }\n\n // break out of loop: we accept or fail with error\n break;\n }\n\n // should we also break out of the regular/outer parse loop,\n // i.e. did the parser already produce a parse result in here?!\n // *or* did we hit an unsupported parse state, to be handled\n // in the `switch/default` code further below?\n ASSERT(action !== 2, 'Line 1509');\n if (!action || action === 1) {\n continue;\n }\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n\n // handle parse error\n if (!action) {\n let errStr;\n let errSymbolDescr = (this.describeSymbol(symbol) || symbol);\n let expected = this.collect_expected_token_set(state);\n\n // Report error\n errStr = 'Parse error';\n if (typeof lexer.yylineno === 'number') {\n errStr += ' on line ' + (lexer.yylineno + 1);\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += ':\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n } else {\n errStr += ': ';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n // we cannot recover from the error!\n p = this.constructParseErrorInfo(errStr, null, expected, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n }\n\n if (yydebug) {\n yydebug('::: MAIN CYCLE action: ' +\n (action === 1 ?\n 'shift token ' + symbol + ' (then go to state ' + newState + ')' :\n action === 2 ?\n 'reduce by rule: ' + newState + (function __print_rule(nt, state) {\n if (!nt || !nt.states || !nt.rules) {\n return '';\n }\n let rulename = nt.states[state];\n let rulespec = nt.rules[rulename][state];\n return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')';\n })(this.nonterminals_, newState) :\n action === 3 ?\n 'accept' :\n '???unexpected???'\n ), {\n action, newState, recovering, symbol\n });\n }\n\n switch (action) {\n // catch misc. parse failures:\n default:\n // this shouldn't happen, unless resolve defaults are off\n if (action instanceof Array) {\n p = this.constructParseErrorInfo('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol, null, null, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n // Another case of better safe than sorry: in case state transitions come out of another error recovery process\n // or a buggy LUT (LookUp Table):\n p = this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.', null, null, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n\n // shift:\n case 1:\n stack[sp] = symbol;\n vstack[sp] = lexer.yytext;\n lstack[sp] = this.copy_yylloc(lexer.yylloc);\n sstack[sp] = newState; // push state\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n let tokenName = this.getSymbolName(symbol || EOF);\n if (!tokenName) {\n tokenName = symbol;\n }\n\n Jison.parserDebugger.push({\n action: 'shift',\n text: lexer.yytext,\n terminal: tokenName,\n terminal_id: symbol\n });\n }\n\n ++sp;\n\n symbol = 0;\n\n ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error\n ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error\n\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n continue;\n\n // reduce:\n case 2:\n ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error\n ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error\n\n this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...\n yyrulelen = this_production[1];\n\n if (yydebug) {\n yydebug('~~~ REDUCE: ', {\n pop_size: yyrulelen,\n newState, recovering, symbol\n });\n }\n\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n let prereduceValue = vstack.slice(sp - yyrulelen, sp);\n let debuggableProductions = [];\n for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) {\n let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]);\n debuggableProductions.push(debuggableProduction);\n }\n\n // find the current nonterminal name (- nolan)\n let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0];\n let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode);\n\n Jison.parserDebugger.push({\n action: 'reduce',\n nonterminal: currentNonterminal,\n nonterminal_id: currentNonterminalCode,\n prereduce: prereduceValue,\n result: r,\n productions: debuggableProductions,\n text: yyval.$\n });\n }\n\n if (typeof r !== 'undefined') {\n retval = r;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // don't overwrite the `symbol` variable: use a local var to speed things up:\n {\n let ntsymbol = this_production[0]; // push nonterminal (reduce)\n stack[sp] = ntsymbol;\n vstack[sp] = yyval.$;\n lstack[sp] = yyval._$;\n // goto new state = table[STATE][NONTERMINAL]\n newState = table[sstack[sp - 1]][ntsymbol];\n sstack[sp] = newState;\n ++sp;\n if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol });\n }\n continue;\n\n // accept:\n case 3:\n if (sp !== -2) {\n retval = true;\n // Return the `$accept` rule's `$$` result, if available.\n //\n // Also note that JISON always adds this top-most `$accept` rule (with implicit,\n // default, action):\n //\n // $accept: $end\n // %{ $$ = $1; @$ = @1; %}\n //\n // which, combined with the parse kernel's `$accept` state behaviour coded below,\n // will produce the `$$` value output of the rule as the parse result,\n // IFF that result is *not* `undefined`. (See also the parser kernel code.)\n //\n // In code:\n //\n // %{\n // @$ = @1; // if location tracking support is included\n // if (typeof $1 !== 'undefined')\n // return $1;\n // else\n // return true; // the default parse result if the rule actions don't produce anything\n // %}\n sp--;\n if (typeof vstack[sp] !== 'undefined') {\n retval = vstack[sp];\n }\n }\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n break;\n }\n\n // break out of loop: we accept or fail with error\n break;\n }\n } catch (ex) {\n // report exceptions through the parseError callback too, but keep the exception intact\n // if it is a known parser or lexer error which has been thrown by parseError() already:\n if (ex instanceof this.JisonParserError) {\n throw ex;\n } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) {\n throw ex;\n }\n\n p = this.constructParseErrorInfo('Parsing aborted due to exception.', ex, null, false);\n retval = false;\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n } finally {\n retval = this.cleanupAfterParse(retval, true, true);\n this.__reentrant_call_depth--;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'return',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n } // /finally\n\n return retval;\n}\n"; // --- END parser kernel --- /* * LR(0) Parser @@ -28284,7 +28597,7 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { }, unionLookaheads: function LALR_unionLookaheads() { var self = this, - newg = this.newg; // var states = !!this.onDemandLookahead ? this.inadequateStates : this.states; + newg = this.newg; // let states = !!this.onDemandLookahead ? this.inadequateStates : this.states; var these_states = this.states; these_states.forEach(function union_states_forEach(state, i) { @@ -28400,19 +28713,17 @@ var lr1 = lrLookaheadGenerator.beget({ closureOperation: function LR_ClosureOperation(itemSet) { var closureSet = new this.ItemSet(); var self = this; - var set = itemSet, - itemQueue; + var set = itemSet; - do { - itemQueue = new Set(); + var _loop3 = function _loop3() { + var itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function LR_AddItemToClosureSets(item) { - var symbol = item.markedSymbol; - var b, r; // if token is a nonterminal, recursively add closures + var symbol = item.markedSymbol; // if token is a nonterminal, recursively add closures if (symbol && self.nonterminals[symbol]) { - r = item.remainingHandle(); - b = self.first(r); + var r = item.remainingHandle(); + var b = self.first(r); if (b.length === 0 || item.production.nullable || self.nullable(r)) { b = b.concat(item.follows); @@ -28431,7 +28742,11 @@ var lr1 = lrLookaheadGenerator.beget({ } }); set = itemQueue; - } while (!itemQueue.isEmpty()); + }; + + do { + _loop3(); + } while (!set.isEmpty()); return closureSet; } @@ -28462,9 +28777,9 @@ var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { //cleanupTable(this.table); }, parseTable: function ll_ParseTable(productions) { - var table = {}, - symbols_ = this.symbols_, - self = this; + var table = {}; + var symbols_ = this.symbols_; + var self = this; productions.forEach(function (production, i) { var row = table[production.symbol] || {}; var tokens = production.first; @@ -28517,7 +28832,7 @@ Jison$1.Generator = function Jison_Generator(grammar, optionalLexerSection, opti // Anyway, API/CLI options **override** options coming in from the grammar spec. // - options = mkStdOptions$1("NODEFAULT", grammar.options, options); + options = mkStdOptions$1('NODEFAULT', grammar.options, options); switch (options.type || Jison$1.defaultJisonOptions.type) { case 'lr0': @@ -28557,5 +28872,20 @@ function Parser$3(g, l, options) { return gen.createParser(); } -Jison$1.Parser = Parser$3; +Jison$1.Parser = Parser$3; // exports for unit/system testing purposes: + +Jison$1.TestExports = { + lookaheadMixin: lookaheadMixin, + generatorMixin: generatorMixin, + lrGeneratorMixin: lrGeneratorMixin, + lalr: lalr, + lr0: lr0, + lr1: lr1, + ll: ll, + parser: parser$4, + pickErrorHandlingChunk: pickErrorHandlingChunk, + addOrRemoveTokenStack: addOrRemoveTokenStack, + removeUnusedKernelFeatures: removeUnusedKernelFeatures, + expandParseArguments: expandParseArguments +}; module.exports = Jison$1; diff --git a/dist/jison-cjs.js b/dist/jison-cjs.js index 51298d458..fafde8311 100644 --- a/dist/jison-cjs.js +++ b/dist/jison-cjs.js @@ -3,6 +3,7 @@ var fs = require('fs'); var path$1 = require('path'); var JSON5 = require('@gerhobbelt/json5'); +var mkdirp = require('mkdirp'); var XRegExp = require('@gerhobbelt/xregexp'); var recast = require('recast'); var babel = require('@babel/core'); @@ -14,12 +15,13 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); +var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); var astUtils__default = /*#__PURE__*/_interopDefaultLegacy(astUtils); -// Return TRUE if `src` starts with `searchString`. +// Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -42,19 +44,19 @@ function rmCommonWS(strings, ...values) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -73,19 +75,21 @@ function rmCommonWS(strings, ...values) { // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -94,16 +98,19 @@ function rmCommonWS(strings, ...values) { } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -114,27 +121,79 @@ function camelCase(s) { return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } +// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; +})([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' +]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -152,6 +211,11 @@ function mkIdentifier(s) { .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -160,13 +224,13 @@ function mkIdentifier(s) { function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -177,23 +241,17 @@ function scanRegExp(s) { break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -216,34 +274,33 @@ function isLineTerminator(cp) { /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote$1(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -266,28 +323,76 @@ function chkBugger(src) { // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } +function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; +} + + +function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); +} + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -298,27 +403,37 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -328,7 +443,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -336,7 +451,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -362,27 +477,43 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; } - const debug = 0; + const debug = options.debug || 0; - var p; + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); + } + + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -395,9 +526,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -419,22 +551,22 @@ assert__default['default'](recast__default['default']); // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; -// Determine which Unicode NonAsciiIdentifierStart characters +// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -442,40 +574,40 @@ const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -483,30 +615,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -517,59 +649,59 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -611,38 +743,38 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -654,18 +786,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -676,56 +808,56 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -733,97 +865,97 @@ function generateMapper4JisonGrammarIdentifiers(input) { typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -831,7 +963,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -844,7 +976,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -857,7 +989,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -870,7 +1002,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -889,37 +1021,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -951,7 +1083,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -968,37 +1100,37 @@ function parseCodeChunkToAST(src, options) { .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return babel.transformSync(src, options); // => { code, map, ast } @@ -1006,8 +1138,8 @@ function compileCodeToES5(src, options) { function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1016,7 +1148,7 @@ function prettyPrintAST(ast, options) { // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1039,25 +1171,25 @@ function prettyPrintAST(ast, options) { // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1068,9 +1200,9 @@ function checkActionBlock(src, yylloc, options) { // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1078,7 +1210,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1087,14 +1219,14 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1148,7 +1280,7 @@ var parse2AST = { trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1162,7 +1294,7 @@ function chkBugger$1(src) { /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1174,24 +1306,24 @@ const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?: /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1208,8 +1340,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1220,14 +1352,14 @@ function printFunctionSourceCodeContainer(f) { action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1238,17 +1370,17 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; -// -// -// +// +// +// function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1274,7 +1406,7 @@ function detectIstanbulGlobal() { // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1322,7 +1454,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1385,13 +1517,13 @@ var reHelpers = { getRegExpInfo: getRegExpInfo }; -var cycleref = []; -var cyclerefpath = []; +let cycleref = []; +let cyclerefpath = []; -var linkref = []; -var linkrefpath = []; +let linkref = []; +let linkrefpath = []; -var path = []; +let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1399,14 +1531,14 @@ function shallow_copy(src) { return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1419,11 +1551,11 @@ function shallow_copy(src) { function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1436,9 +1568,9 @@ function shallow_copy_and_strip_depth(src, parentKey) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1453,16 +1585,52 @@ function shallow_copy_and_strip_depth(src, parentKey) { } +// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } +// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; +} + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1477,7 +1645,7 @@ function trim_array_tail(arr) { function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1503,10 +1671,10 @@ function treat_value_stack(v) { } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1604,7 +1772,7 @@ function treat_hash(h) { function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1621,7 +1789,7 @@ function treat_error_report_info(e) { path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1649,7 +1817,7 @@ function treat_error_report_info(e) { function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1665,7 +1833,7 @@ function treat_object(e) { linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1677,14 +1845,14 @@ function treat_object(e) { // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1694,7 +1862,7 @@ function trimErrorForTestReporting(e) { cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1708,12 +1876,14 @@ var helpers = { dquote: dquote$1, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1728,7 +1898,7 @@ var helpers = { printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; /* @@ -1738,23 +1908,23 @@ var helpers = { * By Zachary Carter * MIT Licensed */ -var mkIdentifier$1 = helpers.mkIdentifier; +let mkIdentifier$1 = helpers.mkIdentifier; -var create = Object.create || function (o) { - function F(){} - F.prototype = o; - return new F(); +let create = Object.create || function (o) { + function F() {} + F.prototype = o; + return new F(); }; -var position = /^(before|after)/; +let position = /^(before|after)/; // basic method layering // always returns original method's return value function layerMethod(pos, key, prop, fun) { if (pos === 'after') { return function () { - var ret = prop.apply(this, arguments); - var args = [].slice.call(arguments); + let ret = prop.apply(this, arguments); + let args = [].slice.call(arguments); args.splice(0, 0, ret); fun.apply(this, args); return ret; @@ -1762,7 +1932,7 @@ function layerMethod(pos, key, prop, fun) { } else if (pos === 'before') { return function () { fun.apply(this, arguments); - var ret = prop.apply(this, arguments); + let ret = prop.apply(this, arguments); return ret; }; } @@ -1773,7 +1943,7 @@ function layerMethod(pos, key, prop, fun) { // overwriting them or layering them. i.e. an object method 'meth' is // layered by mixin methods 'beforemeth' or 'aftermeth' function typal_mix() { - var i, o, k; + let i, o, k; for (i = 0; i < arguments.length; i++) { o = arguments[i]; if (!o) continue; @@ -1785,8 +1955,8 @@ function typal_mix() { } for (k in o) { if (Object.prototype.hasOwnProperty.call(o, k)) { - var match = k.match(position); - var key = k.replace(position, ''); + let match = k.match(position); + let key = k.replace(position, ''); if (match && typeof this[key] === 'function') { this[key] = layerMethod(match[0], key, this[key], o[k]); } else { @@ -1800,15 +1970,15 @@ function typal_mix() { // Same as typal_mix but also camelCases every object member and 'standardizes' the key set of every input // argument through a caLLback function. -// +// // This is useful for processing options with dashes in their key, e.g. `token-stack` --> tokenStack. function typal_camel_mix(cb) { - var i, o, k; + let i, o, k; // Convert first character to lowercase function lcase0(s) { - return s.replace(/^\w/, function (match) { - return match.toLowerCase(); + return s.replace(/^\w/, function (match) { + return match.toLowerCase(); }); } @@ -1826,16 +1996,15 @@ function typal_camel_mix(cb) { } for (k in o) { if (Object.prototype.hasOwnProperty.call(o, k)) { - var nk = mkIdentifier$1(k); - var match = k.match(position); - var key = k.replace(position, ''); + let nk = mkIdentifier$1(k); + let match = k.match(position); + let key = k.replace(position, ''); // This anticipates before/after members to be camelcased already, e.g. - // 'afterParse()' for layering 'parse()': - var alt_key = lcase0(key); + // 'afterParse()' for layering 'parse()': + let alt_key = lcase0(key); if (match && typeof this[key] === 'function') { this[key] = layerMethod(match[0], key, this[key], o[k]); - } - else if (match && typeof this[alt_key] === 'function') { + } else if (match && typeof this[alt_key] === 'function') { this[alt_key] = layerMethod(match[0], alt_key, this[alt_key], o[k]); } else { this[nk] = o[k]; @@ -1846,7 +2015,7 @@ function typal_camel_mix(cb) { return this; } -var typal = { +let typal = { // extend object with own properties of each argument mix: typal_mix, @@ -1861,9 +2030,9 @@ var typal = { // Creates a new Class function based on an object with a constructor method construct: function typal_construct() { - var o = typal_mix.apply(create(this), arguments); - var constructor = o.constructor; - var Klass = o.constructor = function () { return constructor.apply(this, arguments); }; + let o = typal_mix.apply(create(this), arguments); + let constructor = o.constructor; + let Klass = o.constructor = function () { return constructor.apply(this, arguments); }; Klass.prototype = o; Klass.mix = typal_mix; // allow for easy singleton property extension return Klass; @@ -1875,13 +2044,12 @@ var typal = { // Set class to wrap arrays -var setMixin = { +let setMixin = { constructor: function Set_constructor(set, raw) { this._items = []; if (set && set.constructor === Array) { - this._items = raw ? set: set.slice(0); - } - else if (arguments.length) { + this._items = raw ? set : set.slice(0); + } else if (arguments.length) { this._items = [].slice.call(arguments, 0); } }, @@ -1894,7 +2062,7 @@ var setMixin = { }, indexOf: function indexOf(item) { if (item && item.eq) { - for (var k = 0; k < this._items.length; k++) { + for (let k = 0; k < this._items.length; k++) { if (item.eq(this._items[k])) { return k; } @@ -1909,14 +2077,14 @@ var setMixin = { }); }, complement: function complement(set) { - var that = this; + let that = this; return set.filter(function sub_complement(elm) { return !that.contains(elm); }); }, subset: function subset(set) { - var cont = true; - for (var i = 0; i < this._items.length && cont; i++) { + let cont = true; + for (let i = 0; i < this._items.length && cont; i++) { cont = cont && set.contains(this._items[i]); } return cont; @@ -1927,60 +2095,59 @@ var setMixin = { joinSet: function joinSet(set) { return this.concat(this.complement(set)); }, - contains: function contains(item) { - return this.indexOf(item) !== -1; + contains: function contains(item) { + return this.indexOf(item) !== -1; }, - item: function item(v) { - return this._items[v]; + item: function item(v) { + return this._items[v]; }, - i: function i(v) { - return this._items[v]; + i: function i(v) { + return this._items[v]; }, - assign: function assign(index, value) { + assign: function assign(index, value) { this._items[index] = value; - return this; + return this; }, - first: function first() { - return this._items[0]; + first: function first() { + return this._items[0]; }, - last: function last() { - return this._items[this._items.length - 1]; + last: function last() { + return this._items[this._items.length - 1]; }, - size: function size() { - return this._items.length; + size: function size() { + return this._items.length; }, - isEmpty: function isEmpty() { - return this._items.length === 0; + isEmpty: function isEmpty() { + return this._items.length === 0; }, - copy: function copy() { - return new Set(this._items); + copy: function copy() { + return new Set$1(this._items); }, - toString: function toString() { - return this._items.toString(); + toString: function toString() { + return this._items.toString(); } }; 'push shift unshift forEach some every join sort'.split(' ').forEach(function (e, i) { - setMixin[e] = function () { - return Array.prototype[e].apply(this._items, arguments); + setMixin[e] = function () { + return Array.prototype[e].apply(this._items, arguments); }; //setMixin[e].name = e; }); 'filter slice map'.split(' ').forEach(function (e, i) { - setMixin[e] = function () { - return new Set(Array.prototype[e].apply(this._items, arguments), true); + setMixin[e] = function () { + return new Set$1(Array.prototype[e].apply(this._items, arguments), true); }; //setMixin[e].name = e; }); -var Set = typal.construct(setMixin); +var Set$1 = typal.construct(setMixin); // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1997,9 +2164,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -2032,10 +2199,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -2048,11 +2215,11 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -2062,18 +2229,18 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -2104,7 +2271,7 @@ JisonParserError.prototype.name = 'JisonParserError'; // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -2121,9 +2288,9 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -2136,7 +2303,7 @@ JisonParserError.prototype.name = 'JisonParserError'; } -var parser = { +let parser = { // Code Generator Information Report // --------------------------------- // @@ -2386,7 +2553,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2394,7 +2560,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2406,8 +2571,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2420,14 +2585,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2443,10 +2607,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2454,10 +2618,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2612,9 +2776,9 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -2626,18 +2790,18 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2667,9 +2831,9 @@ case 1: case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -2682,10 +2846,10 @@ case 2: case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2712,9 +2876,9 @@ case 3: case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -2723,10 +2887,10 @@ case 4: case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2754,9 +2918,9 @@ case 5: case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -2765,10 +2929,10 @@ case 6: case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -2807,9 +2971,9 @@ case 7: case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2874,9 +3038,9 @@ case 8: case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2891,9 +3055,9 @@ case 9: case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -2928,10 +3092,10 @@ case 10: case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2948,9 +3112,9 @@ case 11: case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2967,10 +3131,10 @@ case 12: case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2987,9 +3151,9 @@ case 13: case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -3006,10 +3170,10 @@ case 14: case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3026,9 +3190,9 @@ case 15: case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3052,9 +3216,9 @@ case 17: case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3065,9 +3229,9 @@ case 132: case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3087,9 +3251,9 @@ case 18: case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3113,9 +3277,9 @@ case 19: case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -3128,10 +3292,10 @@ case 20: case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3148,9 +3312,9 @@ case 21: case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -3162,9 +3326,9 @@ case 22: case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -3204,10 +3368,10 @@ case 23: case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3227,9 +3391,9 @@ case 24: case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3279,10 +3443,10 @@ case 25: case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -3306,10 +3470,10 @@ case 26: case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3329,10 +3493,10 @@ case 27: case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3356,10 +3520,10 @@ case 28: case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3380,10 +3544,10 @@ case 29: case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3395,10 +3559,10 @@ case 31: case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3408,10 +3572,10 @@ case 33: case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3421,10 +3585,10 @@ case 32: case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3434,10 +3598,10 @@ case 34: case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3447,10 +3611,10 @@ case 35: case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -3460,10 +3624,10 @@ case 36: case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3473,10 +3637,10 @@ case 37: case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3486,9 +3650,9 @@ case 38: case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -3497,9 +3661,9 @@ case 39: case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -3508,9 +3672,9 @@ case 40: case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3532,9 +3696,9 @@ case 41: case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3545,9 +3709,9 @@ case 42: case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3567,9 +3731,9 @@ case 43: case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3623,9 +3787,9 @@ case 49: case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3645,9 +3809,9 @@ case 51: case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -3656,9 +3820,9 @@ case 58: case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -3670,9 +3834,9 @@ case 52: case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -3686,10 +3850,10 @@ case 53: case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3709,10 +3873,10 @@ case 54: case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3732,10 +3896,10 @@ case 55: case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3755,9 +3919,9 @@ case 56: case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3768,9 +3932,9 @@ case 59: case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3789,9 +3953,9 @@ case 60: case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -3832,9 +3996,9 @@ case 61: case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3858,9 +4022,9 @@ case 62: case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3886,9 +4050,9 @@ case 63: case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3933,9 +4097,9 @@ case 64: case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -3961,9 +4125,9 @@ case 106: case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -3972,9 +4136,9 @@ case 127: case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -3983,10 +4147,10 @@ case 67: case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4000,10 +4164,10 @@ case 68: case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4017,10 +4181,10 @@ case 69: case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4034,10 +4198,10 @@ case 70: case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4056,9 +4220,9 @@ case 72: case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4067,9 +4231,9 @@ case 77: case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -4107,10 +4271,10 @@ case 73: case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -4134,9 +4298,9 @@ case 74: case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -4215,9 +4379,9 @@ case 110: case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -4226,9 +4390,9 @@ case 129: case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -4237,9 +4401,9 @@ case 78: case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -4248,9 +4412,9 @@ case 79: case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -4259,9 +4423,9 @@ case 80: case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -4270,9 +4434,9 @@ case 81: case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -4281,9 +4445,9 @@ case 85: case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -4294,10 +4458,10 @@ case 87: case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4314,9 +4478,9 @@ case 88: case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -4325,9 +4489,9 @@ case 89: case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -4336,9 +4500,9 @@ case 90: case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -4347,9 +4511,9 @@ case 91: case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -4358,9 +4522,9 @@ case 92: case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -4379,18 +4543,18 @@ case 107: case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -4399,9 +4563,9 @@ case 97: case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -4410,9 +4574,9 @@ case 98: case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -4421,9 +4585,9 @@ case 99: case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -4432,9 +4596,9 @@ case 102: case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -4443,10 +4607,10 @@ case 104: case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4463,9 +4627,9 @@ case 105: case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -4482,9 +4646,9 @@ case 109: case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -4496,9 +4660,9 @@ case 111: case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -4508,9 +4672,9 @@ case 112: case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4545,9 +4709,9 @@ case 113: case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4566,9 +4730,9 @@ case 114: case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -4577,9 +4741,9 @@ case 115: case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -4588,9 +4752,9 @@ case 116: case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4608,10 +4772,10 @@ case 117: case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -4629,10 +4793,10 @@ case 118: case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -4653,9 +4817,9 @@ case 119: case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4688,9 +4852,9 @@ case 120: case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4716,9 +4880,9 @@ case 121: case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5__default['default'].parse(yyvstack[yysp]); @@ -4727,9 +4891,9 @@ case 122: case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue(yyvstack[yysp]); @@ -4738,9 +4902,9 @@ case 123: case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4749,9 +4913,9 @@ case 124: case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -4772,10 +4936,10 @@ case 125: case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4792,9 +4956,9 @@ case 126: case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -4813,9 +4977,9 @@ case 128: case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4839,9 +5003,9 @@ case 130: case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -4861,9 +5025,9 @@ case 131: case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4874,9 +5038,9 @@ case 133: case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -4932,10 +5096,10 @@ case 134: case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6538,7 +6702,6 @@ defaultActions: bda({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -6555,38 +6718,34 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -6594,20 +6753,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -6629,7 +6786,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -6637,18 +6793,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -6656,24 +6813,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -6711,18 +6863,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -6743,7 +6892,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -6761,7 +6910,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -6774,7 +6922,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -6788,11 +6935,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -6846,8 +6992,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6855,8 +7001,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6888,19 +7034,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -6911,7 +7056,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -6924,7 +7069,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -6936,29 +7081,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -6966,7 +7109,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -6986,8 +7129,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -6996,10 +7138,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -7007,7 +7149,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -7018,9 +7160,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -7036,8 +7183,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -7106,11 +7252,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -7121,8 +7270,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -7131,21 +7279,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -7155,21 +7302,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -7178,28 +7324,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -7212,8 +7357,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -7236,8 +7380,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -7249,8 +7392,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -7267,8 +7409,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -7282,8 +7423,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -7297,7 +7437,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -7350,16 +7490,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -7393,9 +7530,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -7418,9 +7553,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -7447,17 +7580,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -7504,8 +7636,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -7517,8 +7649,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -7536,6 +7667,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -7544,7 +7676,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -7555,7 +7687,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -7615,10 +7747,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -7653,9 +7785,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -7668,7 +7798,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -7689,9 +7819,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7713,12 +7841,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -7727,7 +7855,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7768,7 +7896,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -7815,7 +7943,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -7833,21 +7961,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7881,14 +8007,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7898,6 +8025,7 @@ parse: function parse(input) { + } continue; // accept: @@ -7949,7 +8077,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -7965,9 +8093,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7996,7 +8122,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -8013,8 +8139,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -8025,8 +8151,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -8038,21 +8164,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -8083,14 +8207,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -8100,6 +8225,7 @@ parse: function parse(input) { + } continue; // accept: @@ -8152,8 +8278,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -8414,7 +8539,6 @@ var lexer = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -8431,10 +8555,10 @@ var lexer = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -8466,7 +8590,7 @@ var lexer = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -8508,7 +8632,9 @@ var lexer = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -8594,7 +8720,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -8602,7 +8728,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -8615,7 +8741,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -8641,10 +8767,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -8667,7 +8796,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -8690,16 +8818,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -8721,7 +8849,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -8729,8 +8856,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -8759,7 +8886,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -8784,7 +8911,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -8796,17 +8923,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -8900,7 +9027,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -8921,7 +9048,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -8932,7 +9058,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -8943,15 +9069,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -8985,8 +9111,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -9019,9 +9145,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -9040,9 +9166,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -9052,8 +9178,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -9080,20 +9206,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -9133,17 +9258,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -9152,7 +9279,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -9167,8 +9294,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -9194,24 +9321,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -9222,7 +9351,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -9244,8 +9373,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -9267,8 +9396,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -9412,21 +9540,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -9441,11 +9569,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -9464,13 +9592,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -9494,13 +9622,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -9515,8 +9643,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -9547,7 +9675,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -9579,9 +9707,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -9610,7 +9738,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -9628,7 +9756,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -9653,7 +9781,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -9663,8 +9790,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -9673,7 +9798,7 @@ EOF: 1, this.clear(); } - 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. @@ -9685,13 +9810,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -9701,68 +9826,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -9787,7 +9918,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -9835,24 +9966,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9872,7 +10003,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -9882,24 +10013,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9920,8 +10051,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -9961,14 +10091,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -9984,9 +10114,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -9997,8 +10127,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -10006,7 +10136,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -11696,7 +11826,7 @@ const UNICODE_BASE_PLANE_MAX_CP = 65535; // The expanded regex sets which are equivalent to the given `\\{c}` escapes: // // `/\s/`: -const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; +const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; // `/\d/`: const DIGIT_SETSTR = '0-9'; // `/\w/`: @@ -11708,7 +11838,7 @@ const WORDCHAR_SETSTR = 'A-Za-z0-9_'; // Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex function i2c(i) { - var c, x; + let c, x; switch (i) { case 10: @@ -11748,7 +11878,7 @@ function i2c(i) { || i > 0xFFF0 /* Unicode Specials, also in UTF16 */ || (i >= 0xD800 && i <= 0xDFFF) /* Unicode Supplementary Planes; we're TOAST in JavaScript as we're NOT UTF-16 but UCS-2! */ || String.fromCharCode(i).match(/[\u2028\u2029]/) /* Code compilation via `new Function()` does not like to see these, or rather: treats them as just another form of CRLF, which breaks your generated regex code! */ - ) { + ) { // Detail about a detail: // U+2028 and U+2029 are part of the `\s` regex escape code (`\s` and `[\s]` match either of these) and when placed in a JavaScript // source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report @@ -11756,11 +11886,10 @@ function i2c(i) { // Hence we MUST escape these buggers everywhere we go... x = i.toString(16); if (x.length >= 1 && i <= 0xFFFF) { - c = '0000' + x; - return '\\u' + c.substr(c.length - 4); - } else { - return '\\u{' + x + '}'; + c = '0000' + x; + return '\\u' + c.substr(c.length - 4); } + return '\\u{' + x + '}'; } return String.fromCharCode(i); } @@ -11769,18 +11898,18 @@ function i2c(i) { // Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating // this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a // `\\p{NAME}` shorthand to represent [part of] the bitarray: -var Pcodes_bitarray_cache = {}; -var Pcodes_bitarray_cache_test_order = []; +let Pcodes_bitarray_cache = {}; +let Pcodes_bitarray_cache_test_order = []; -// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by +// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. -var EscCode_bitarray_output_refs; +let EscCode_bitarray_output_refs; // now initialize the EscCodes_... table above: init_EscCode_lookup_table(); function init_EscCode_lookup_table() { - var s, bitarr, set2esc = {}, esc2bitarr = {}; + let s, bitarr, set2esc = {}, esc2bitarr = {}; // patch global lookup tables for the time being, while we calculate their *real* content in this function: EscCode_bitarray_output_refs = { @@ -11849,13 +11978,13 @@ function init_EscCode_lookup_table() { }; updatePcodesBitarrayCacheTestOrder(); -} +} function updatePcodesBitarrayCacheTestOrder(opts) { - var t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var l = {}; - var user_has_xregexp = opts && opts.options && opts.options.xregexp; - var i, j, k, ba; + let t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let l = {}; + let user_has_xregexp = opts && opts.options && opts.options.xregexp; + let i, j, k, ba; // mark every character with which regex pcodes they are part of: for (k in Pcodes_bitarray_cache) { @@ -11865,12 +11994,12 @@ function updatePcodesBitarrayCacheTestOrder(opts) { continue; } - var cnt = 0; + let cnt = 0; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { cnt++; if (!t[i]) { - t[i] = [k]; + t[i] = [ k ]; } else { t[i].push(k); } @@ -11880,27 +12009,27 @@ function updatePcodesBitarrayCacheTestOrder(opts) { } // now dig out the unique ones: only need one per pcode. - // + // // We ASSUME every \\p{NAME} 'pcode' has at least ONE character - // in it that is ONLY matched by that particular pcode. + // in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode - // won't be tested during optimization. - // + // won't be tested during optimization. + // // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to // look for markers which match multiple escapes/pcodes for those // ones where a unique item isn't available... - var lut = []; - var done = {}; - var keys = Object.keys(Pcodes_bitarray_cache); + let lut = []; + let done = {}; + let keys = Object.keys(Pcodes_bitarray_cache); for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { k = t[i][0]; if (t[i].length === 1 && !done[k]) { assert__default['default'](l[k] > 0); - lut.push([i, k]); + lut.push([ i, k ]); done[k] = true; } } @@ -11911,19 +12040,19 @@ function updatePcodesBitarrayCacheTestOrder(opts) { if (!user_has_xregexp && k.indexOf('\\p{') >= 0) { continue; } - + if (!done[k]) { assert__default['default'](l[k] > 0); // find a minimum span character to mark this one: - var w = Infinity; + let w = Infinity; var rv; ba = Pcodes_bitarray_cache[k]; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { - var tl = t[i].length; + let tl = t[i].length; if (tl > 1 && tl < w) { assert__default['default'](l[k] > 0); - rv = [i, k]; + rv = [ i, k ]; w = tl; } } @@ -11937,16 +12066,16 @@ function updatePcodesBitarrayCacheTestOrder(opts) { // order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. - // + // // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more - // optimal minification of the regex set expression. - // + // optimal minification of the regex set expression. + // // This is a guestimate/heuristic only! lut.sort(function (a, b) { - var k1 = a[1]; - var k2 = b[1]; - var ld = l[k2] - l[k1]; + let k1 = a[1]; + let k2 = b[1]; + let ld = l[k2] - l[k1]; if (ld) { return ld; } @@ -11964,19 +12093,19 @@ function updatePcodesBitarrayCacheTestOrder(opts) { // 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set. function set2bitarray(bitarr, s, opts) { - var orig = s; - var set_is_inverted = false; - var bitarr_orig; + let orig = s; + let set_is_inverted = false; + let bitarr_orig; function mark(d1, d2) { if (d2 == null) d2 = d1; - for (var i = d1; i <= d2; i++) { + for (let i = d1; i <= d2; i++) { bitarr[i] = true; } } function add2bitarray(dst, src) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (src[i]) { dst[i] = true; } @@ -11984,10 +12113,10 @@ function set2bitarray(bitarr, s, opts) { } function eval_escaped_code(s) { - var c; + let c; // decode escaped code? If none, just take the character as-is if (s.indexOf('\\') === 0) { - var l = s.substr(0, 2); + let l = s.substr(0, 2); switch (l) { case '\\c': c = s.charCodeAt(2) - 'A'.charCodeAt(0) + 1; @@ -12005,7 +12134,7 @@ function set2bitarray(bitarr, s, opts) { } c = parseInt(s, 16); if (c >= 0x10000) { - return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); + return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); } return String.fromCharCode(c); @@ -12049,7 +12178,7 @@ function set2bitarray(bitarr, s, opts) { } if (s && s.length) { - var c1, c2; + let c1, c2; // inverted set? if (s[0] === '^') { @@ -12080,13 +12209,13 @@ function set2bitarray(bitarr, s, opts) { c2 = c2[0]; s = s.substr(c2.length); // do we have this one cached already? - var pex = c1 + c2; - var ba4p = Pcodes_bitarray_cache[pex]; + let pex = c1 + c2; + let ba4p = Pcodes_bitarray_cache[pex]; if (!ba4p) { // expand escape: - var xr = new XRegExp__default['default']('[' + pex + ']'); // TODO: case-insensitive grammar??? + let xr = new XRegExp__default['default']('[' + pex + ']'); // TODO: case-insensitive grammar??? // rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`: - var xs = '' + xr; + let xs = '' + xr; // remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: xs = xs.substr(1, xs.length - 2); @@ -12121,7 +12250,7 @@ function set2bitarray(bitarr, s, opts) { break; } } - var v1 = eval_escaped_code(c1); + let v1 = eval_escaped_code(c1); // propagate deferred exceptions = error reports. if (v1 instanceof Error) { return v1; @@ -12139,7 +12268,7 @@ function set2bitarray(bitarr, s, opts) { } else { c2 = c2[0]; } - var v2 = eval_escaped_code(c2); + let v2 = eval_escaped_code(c2); // propagate deferred exceptions = error reports. if (v2 instanceof Error) { return v1; @@ -12162,12 +12291,12 @@ function set2bitarray(bitarr, s, opts) { } // When we have marked all slots, '^' NEGATES the set, hence we flip all slots. - // + // // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. if (set_is_inverted) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (!bitarr[i]) { bitarr_orig[i] = true; } @@ -12186,10 +12315,10 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // below can be simple and fast: l[UNICODE_BASE_PLANE_MAX_CP + 1] = 1; // now reconstruct the regex set: - var rv = []; - var i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; - var bitarr_is_cloned = false; - var l_orig = l; + let rv = []; + let i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; + let bitarr_is_cloned = false; + let l_orig = l; if (output_inverted_variant) { // generate the inverted set, hence all unmarked slots are part of the output range: @@ -12203,8 +12332,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. // BUT... since we output the INVERTED set, we output the match-all set instead: return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` // BUT... since we output the INVERTED set, we output the match-nothing set instead: @@ -12236,9 +12364,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12265,7 +12393,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } } - + i = 0; while (i <= UNICODE_BASE_PLANE_MAX_CP) { // find first character not in original set: @@ -12296,8 +12424,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. return '^\\S\\s'; } @@ -12327,9 +12454,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12381,11 +12508,11 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } assert__default['default'](rv.length); - var s = rv.join(''); + let s = rv.join(''); assert__default['default'](s); // Check if the set is better represented by one of the regex escapes: - var esc4s = EscCode_bitarray_output_refs.set2esc[s]; + let esc4s = EscCode_bitarray_output_refs.set2esc[s]; if (esc4s) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return '\\' + esc4s; @@ -12400,25 +12527,24 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there; // ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`. function reduceRegexToSetBitArray(s, name, opts) { - var orig = s; + let orig = s; // propagate deferred exceptions = error reports. if (s instanceof Error) { return s; } - var l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var internal_state = 0; - var derr; + let l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let internal_state = 0; + let derr; while (s.length) { - var c1 = s.match(CHR_RE); + let c1 = s.match(CHR_RE); if (!c1) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"'); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12426,15 +12552,14 @@ function reduceRegexToSetBitArray(s, name, opts) { // this is starting a set within the regex: scan until end of set! var set_content = []; while (s.length) { - var inner = s.match(SET_PART_RE); + let inner = s.match(SET_PART_RE); if (!inner) { inner = s.match(CHR_RE); if (!inner) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"'); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12448,9 +12573,8 @@ function reduceRegexToSetBitArray(s, name, opts) { if (!c2) { // cope with illegal escape sequences too! return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error('regex set expression is broken in regex: ' + orig); } @@ -12534,10 +12658,9 @@ function reduceRegexToSetBitArray(s, name, opts) { // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; assert__default['default'](s); assert__default['default'](!(s instanceof Error)); - re = new XRegExp__default['default']('[' + s + ']'); + let re = new XRegExp__default['default']('[' + s + ']'); re.test(s[0]); // One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` @@ -12562,25 +12685,24 @@ function reduceRegexToSetBitArray(s, name, opts) { -// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` +// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! function produceOptimizedRegex4Set(bitarr) { // First try to produce a minimum regex from the bitarray directly: - var s1 = bitarray2set(bitarr, false, true); + let s1 = bitarray2set(bitarr, false, true); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s1.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s1; - } else { - s1 = '[' + s1 + ']'; } + s1 = '[' + s1 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s2 = bitarray2set(bitarr, true, true); + let s2 = bitarray2set(bitarr, true, true); if (s2[0] === '^') { s2 = s2.substr(1); @@ -12595,23 +12717,22 @@ function produceOptimizedRegex4Set(bitarr) { // Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: - // + // // First try to produce a minimum regex from the bitarray directly: - var s3 = bitarray2set(bitarr, false, false); + let s3 = bitarray2set(bitarr, false, false); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s3.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s3; - } else { - s3 = '[' + s3 + ']'; } + s3 = '[' + s3 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s4 = bitarray2set(bitarr, true, false); + let s4 = bitarray2set(bitarr, true, false); if (s4[0] === '^') { s4 = s4.substr(1); @@ -12643,30 +12764,30 @@ function produceOptimizedRegex4Set(bitarr) { var setmgmt = { - XREGEXP_UNICODE_ESCAPE_RE, - CHR_RE, - SET_PART_RE, - NOTHING_SPECIAL_RE, - SET_IS_SINGLE_PCODE_RE, - - UNICODE_BASE_PLANE_MAX_CP, - - WHITESPACE_SETSTR, - DIGIT_SETSTR, - WORDCHAR_SETSTR, - - set2bitarray, - bitarray2set, - produceOptimizedRegex4Set, - reduceRegexToSetBitArray, + XREGEXP_UNICODE_ESCAPE_RE, + CHR_RE, + SET_PART_RE, + NOTHING_SPECIAL_RE, + SET_IS_SINGLE_PCODE_RE, + + UNICODE_BASE_PLANE_MAX_CP, + + WHITESPACE_SETSTR, + DIGIT_SETSTR, + WORDCHAR_SETSTR, + + set2bitarray, + bitarray2set, + produceOptimizedRegex4Set, + reduceRegexToSetBitArray }; // Basic Lexer implemented using JavaScript regular expressions -var rmCommonWS$2 = helpers.rmCommonWS; -var mkIdentifier$3 = helpers.mkIdentifier; -var code_exec$1 = helpers.exec; +const rmCommonWS$2 = helpers.rmCommonWS; +const mkIdentifier$3 = helpers.mkIdentifier; +const code_exec = helpers.exec; -var version = '0.6.2-220'; // require('./package.json').version; +const version = '0.6.2-220'; // require('./package.json').version; @@ -12727,7 +12848,7 @@ const defaultJisonLexOptions = { exportAST: false, prettyCfg: true, pre_lex: undefined, - post_lex: undefined, + post_lex: undefined }; @@ -12745,23 +12866,23 @@ const defaultJisonLexOptions = { // Return a fresh set of options. /** @public */ function mkStdOptions(/*...args*/) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - var args = [].concat.apply([], arguments); + let opts = {}; + let args = [].concat.apply([], arguments); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(defaultJisonLexOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; for (var p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { @@ -12799,7 +12920,7 @@ function mkStdOptions(/*...args*/) { function prepExportStructures(options) { // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -12820,8 +12941,8 @@ function prepExportStructures(options) { // Otherwise return the *parsed* lexer spec as it has // been processed through LexParser. function autodetectAndConvertToJSONformat(lexerSpec, options) { - var chk_l = null; - var ex1, err; + let chk_l = null; + let ex1, err; if (typeof lexerSpec === 'string') { if (options.json) { @@ -12873,9 +12994,9 @@ function autodetectAndConvertToJSONformat(lexerSpec, options) { /should be separated/, /an error in one or more of your lexer regex rules/, /an error in your lexer epilogue/, - /unsupported definition type/, + /unsupported definition type/ ]; - var cmnerr = commonErrors.filter(function check(re) { + let cmnerr = commonErrors.filter(function check(re) { return e.message.match(re); }); if (cmnerr.length > 0) { @@ -12904,14 +13025,14 @@ function autodetectAndConvertToJSONformat(lexerSpec, options) { // expand macros and convert matchers to RegExp's function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) { - var m, i, k, rule, action, conditions; - var active_conditions; + let m, i, k, rule, action, conditions; + let active_conditions; assert__default['default'](Array.isArray(dict.rules)); - var rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! - var newRules = []; - var macros = {}; - var regular_rule_count = 0; - var simple_rule_count = 0; + let rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! + let newRules = []; + let macros = {}; + let regular_rule_count = 0; + let simple_rule_count = 0; // Assure all options are camelCased: assert__default['default'](typeof opts.options['case-insensitive'] === 'undefined'); @@ -12921,7 +13042,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) } if (opts.options.flex && rules.length > 0) { - rules.push(['.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']); + rules.push([ '.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */' ]); } // Depending on the location within the regex we need different expansions of the macros: @@ -12945,7 +13066,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) return str; } - var routingCode = ['switch(yyrulenumber) {']; + let routingCode = [ 'switch(yyrulenumber) {' ]; for (i = 0; i < rules.length; i++) { rule = rules[i].slice(0); // shallow copy: do not modify input rules @@ -12999,7 +13120,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) action = action.replace(/return\s*\(?'((?:\\'|[^']+)+)'\)?/g, tokenNumberReplacement); action = action.replace(/return\s*\(?"((?:\\"|[^"]+)+)"\)?/g, tokenNumberReplacement); - var code = ['\n/*! Conditions::']; + let code = [ '\n/*! Conditions::' ]; code.push(postprocessComment(active_conditions)); code.push('*/', '\n/*! Rule:: '); code.push(postprocessComment(rule[0])); @@ -13020,7 +13141,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) // 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'. - var match_nr = /^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim()); + 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 ')); @@ -13047,7 +13168,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) macros: macros, regular_rule_count: regular_rule_count, - simple_rule_count: simple_rule_count, + simple_rule_count: simple_rule_count }; } @@ -13060,14 +13181,13 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) // 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. function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElsewhere_cb) { - var orig = s; + let orig = s; function errinfo() { if (name) { return 'macro [[' + name + ']]'; - } else { - return 'regex [[' + orig + ']]'; } + return 'regex [[' + orig + ']]'; } // propagate deferred exceptions = error reports. @@ -13075,19 +13195,18 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse return s; } - var c1, c2; - var rv = []; - var derr; - var se; + let c1, c2; + let rv = []; + let derr; + let se; while (s.length) { c1 = s.match(CHR_RE$1); if (!c1) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -13097,15 +13216,14 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse var l = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1); while (s.length) { - var inner = s.match(SET_PART_RE$1); + let inner = s.match(SET_PART_RE$1); if (!inner) { inner = s.match(CHR_RE$1); if (!inner) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -13119,9 +13237,8 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse if (!c2) { // cope with illegal escape sequences too! return new Error(errinfo() + ': regex set expression is broken: "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error(errinfo() + ': regex set expression is broken: apparently unterminated'); } @@ -13182,7 +13299,7 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse c2 = c2[0]; s = s.substr(c2.length); - var c3 = s[0]; + let c3 = s[0]; s = s.substr(c3.length); if (c3 === '}') { // possibly a macro name in there... Expand if possible: @@ -13235,7 +13352,7 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; + let re; re = new XRegExp__default['default'](s); re.test(s[0]); } catch (ex) { @@ -13251,11 +13368,11 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse // expand macros within macros and cache the result function prepareMacros(dict_macros, opts) { - var macros = {}; + let macros = {}; // expand a `{NAME}` macro which exists inside a `[...]` set: function expandMacroInSet(i) { - var k, a, m; + let k, a, m; if (!macros[i]) { m = dict_macros[i]; @@ -13289,7 +13406,7 @@ function prepareMacros(dict_macros, opts) { a = m.split('{' + k + '}'); if (a.length > 1) { - var x = expandMacroInSet(k); + let x = expandMacroInSet(k); assert__default['default'](x); if (x instanceof Error) { m = x; @@ -13301,9 +13418,9 @@ function prepareMacros(dict_macros, opts) { } } - var mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); + let mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); - var s1; + let s1; // propagate deferred exceptions = error reports. if (mba instanceof Error) { @@ -13337,7 +13454,7 @@ function prepareMacros(dict_macros, opts) { } function expandMacroElsewhere(i) { - var m; + let m; if (macros[i].elsewhere == null) { m = dict_macros[i]; @@ -13372,13 +13489,13 @@ function prepareMacros(dict_macros, opts) { } function expandAllMacrosInSet(s) { - var i, x; + let i, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { for (i in macros) { if (macros.hasOwnProperty(i)) { - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroInSet(i); assert__default['default'](x); @@ -13400,7 +13517,7 @@ function prepareMacros(dict_macros, opts) { } function expandAllMacrosElsewhere(s) { - var i, x; + let i, x; // When we process the remaining macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13415,7 +13532,7 @@ function prepareMacros(dict_macros, opts) { for (i in macros) { if (macros.hasOwnProperty(i)) { // These are all submacro expansions, hence non-capturing grouping is applied: - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroElsewhere(i); assert__default['default'](x); @@ -13437,7 +13554,7 @@ function prepareMacros(dict_macros, opts) { } - var i; + let i; if (opts.debug) console.log('\n############## RAW macros: ', dict_macros); @@ -13468,13 +13585,13 @@ function prepareMacros(dict_macros, opts) { // expand macros in a regex; expands them recursively function expandMacros(src, macros, opts) { - var expansion_count = 0; + let expansion_count = 0; // By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! // Hence things should be easy in there: function expandAllMacrosInSet(s) { - var i, m, x; + let i, m, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { @@ -13482,7 +13599,7 @@ function expandMacros(src, macros, opts) { if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = m.in_set; @@ -13513,7 +13630,7 @@ function expandMacros(src, macros, opts) { } function expandAllMacrosElsewhere(s) { - var i, m, x; + let i, m, x; // When we process the main macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13529,7 +13646,7 @@ function expandMacros(src, macros, opts) { if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { // These are all main macro expansions, hence CAPTURING grouping is applied: x = m.elsewhere; @@ -13565,7 +13682,7 @@ function expandMacros(src, macros, opts) { // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! - var s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); + let s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); // propagate deferred exceptions = error reports. if (s2 instanceof Error) { throw s2; @@ -13590,8 +13707,8 @@ function expandMacros(src, macros, opts) { } function prepareStartConditions(conditions) { - var sc; - var hash = {}; + let sc; + let hash = {}; for (sc in conditions) { if (conditions.hasOwnProperty(sc)) { @@ -13605,22 +13722,22 @@ function prepareStartConditions(conditions) { } function buildActions(dict, tokens, opts) { - var actions = [dict.actionInclude || '', 'var YYSTATE = YY_START;']; - var tok; - var toks = {}; - var caseHelper = []; + let actions = [ dict.actionInclude || '', 'var YYSTATE = YY_START;' ]; + let tok; + let toks = {}; + let caseHelper = []; // tokens: map/array of token numbers to token names for (tok in tokens) { - var idx = parseInt(tok); + let idx = parseInt(tok); if (idx && idx > 0) { toks[tokens[tok]] = idx; } } - var gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); + let gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); - var code = actions.join('\n'); + let code = actions.join('\n'); 'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function (yy) { code = code.replace(new RegExp('\\b(' + yy + ')\\b', 'g'), 'yy_.$1'); }); @@ -13638,7 +13755,7 @@ function buildActions(dict, tokens, opts) { macros: gen.macros, // propagate these for debugging/diagnostic purposes regular_rule_count: gen.regular_rule_count, - simple_rule_count: gen.simple_rule_count, + simple_rule_count: gen.simple_rule_count }; } @@ -13649,7 +13766,7 @@ function buildActions(dict, tokens, opts) { function generateErrorClass() { // --- START lexer error class --- -var prelude = `/** +const prelude = `/** * 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 @@ -13660,8 +13777,6 @@ var prelude = `/** * @nocollapse */ function JisonLexerError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -13678,9 +13793,9 @@ function JisonLexerError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -13741,8 +13856,8 @@ function generateFakeXRegExpClassSrcCode() { /** @constructor */ function RegExpLexer(dict, input, tokens, build_options) { - var opts; - var dump = false; + let opts; + let dump = false; function test_me(tweak_cb, description, src_exception, ex_callback) { opts = processGrammar(dict, tokens, build_options); @@ -13752,7 +13867,7 @@ function RegExpLexer(dict, input, tokens, build_options) { if (tweak_cb) { tweak_cb(); } - var source = generateModuleBody(opts); + let source = generateModuleBody(opts); try { // The generated code will always have the `lexer` variable declared at local scope // as `eval()` will use the local scope. @@ -13760,16 +13875,16 @@ function RegExpLexer(dict, input, tokens, build_options) { // The compiled code will look something like this: // // ``` - // var lexer; + // let lexer; // bla bla... // ``` // // or // // ``` - // var lexer = { bla... }; + // const lexer = { bla... }; // ``` - var testcode = [ + let testcode = [ '// provide a local version for test purposes:', jisonLexerErrorDefinition, '', @@ -13777,14 +13892,33 @@ function RegExpLexer(dict, input, tokens, build_options) { '', source, '', + rmCommonWS$2` + // JISON INJECTED VALIDATION CODE + // which attempts to ascertain you have defined a minimal viable lexer at least: + if (typeof lexer === "undefined") { + throw new SyntaxError("user-defined lexer does not define the required 'lexer' instance."); + } + if (!lexer) { + throw new SyntaxError("user-defined lexer does not define a non-NULL 'lexer' instance."); + } + if (typeof lexer.setInput !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.setInput()' API function."); + } + if (typeof lexer.lex !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.lex()' API function."); + } + // END OF JISON INJECTED VALIDATION CODE + `, 'return lexer;' ].join('\n'); - var lexer = code_exec$1(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { + let lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { //console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$2(sourcecode); - var lexer_f = new Function('', sourcecode); + let lexer_f = new Function('', sourcecode); return lexer_f(); - }, opts.options, "lexer"); + }, Object.assign({}, opts.options, { + throwErrorOnCompileFailure: true + }), 'lexer'); if (!lexer) { throw new Error('no lexer defined *at all*?!'); @@ -13801,7 +13935,7 @@ function RegExpLexer(dict, input, tokens, build_options) { // When we do NOT crash, we found/killed the problem area just before this call! if (src_exception && description) { - var msg = description; + let msg = description; if (typeof description === 'function') { msg = description(); } @@ -13810,8 +13944,8 @@ function RegExpLexer(dict, input, tokens, build_options) { // patch the pre and post handlers in there, now that we have some live code to work with: if (opts.options) { - var pre = opts.options.pre_lex; - var post = opts.options.post_lex; + let pre = opts.options.pre_lex; + let post = opts.options.post_lex; // since JSON cannot encode functions, we'll have to do it manually now: if (typeof pre === 'function') { lexer.options.pre_lex = pre; @@ -13825,7 +13959,7 @@ function RegExpLexer(dict, input, tokens, build_options) { if (typeof opts.options.showSource === 'function') { opts.options.showSource(lexer, source, opts, RegExpLexer); } else { - console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n"); + console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n', source, '\n----------------------------------------\n'); } } return lexer; @@ -13844,13 +13978,13 @@ function RegExpLexer(dict, input, tokens, build_options) { } /** @constructor */ - var lexer = test_me(null, null, null, function (ex) { + let lexer = test_me(null, null, null, function (ex) { // When we get an exception here, it means some part of the user-specified lexer is botched. // // Now we go and try to narrow down the problem area/category: assert__default['default'](opts.options); assert__default['default'](opts.options.xregexp !== undefined); - var orig_xregexp_opt = !!opts.options.xregexp; + let orig_xregexp_opt = !!opts.options.xregexp; if (!test_me(function () { assert__default['default'](opts.options.xregexp !== undefined); opts.options.xregexp = false; @@ -13869,7 +14003,7 @@ function RegExpLexer(dict, input, tokens, build_options) { 'Your custom lexer is somehow botched.' ); }, ex, null)) { - var rulesSpecSize; + let rulesSpecSize; if (!test_me(function () { // store the parsed rule set size so we can use that info in case // this attempt also fails: @@ -13882,7 +14016,7 @@ function RegExpLexer(dict, input, tokens, build_options) { opts.__in_rules_failure_analysis_mode__ = true; }, 'One or more of your lexer rules are possibly botched?', ex, null)) { // kill each rule action block, one at a time and test again after each 'edit': - var rv = false; + let rv = false; for (var i = 0, len = rulesSpecSize; i < len; i++) { var lastEditedRuleSpec; rv = test_me(function () { @@ -13894,10 +14028,10 @@ function RegExpLexer(dict, input, tokens, build_options) { // opts.__in_rules_failure_analysis_mode__ = true; // nuke all rules' actions up to and including rule numero `i`: - for (var j = 0; j <= i; j++) { + for (let j = 0; j <= i; j++) { // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; // now we want to edit the *action* part: - var rule = opts.rules[j]; + let rule = opts.rules[j]; assert__default['default'](Array.isArray(rule)); assert__default['default'](rule.length === 2 || rule.length === 3); rule.pop(); @@ -14031,8 +14165,6 @@ return `{ * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -14042,14 +14174,14 @@ return `{ } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\\n\\s*$/.test(msg)) { msg += '\\n'; } msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') { msg += '\\n' + pos_str; @@ -14060,14 +14192,14 @@ return `{ } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the \`upcomingInput\` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -14087,9 +14219,8 @@ return `{ // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -14109,8 +14240,6 @@ return `{ * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -14131,16 +14260,14 @@ return `{ * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -14161,8 +14288,6 @@ return `{ * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -14170,8 +14295,8 @@ return `{ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -14189,8 +14314,6 @@ return `{ * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -14200,14 +14323,14 @@ return `{ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -14218,8 +14341,6 @@ return `{ * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -14227,40 +14348,40 @@ return `{ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -14272,7 +14393,7 @@ return `{ this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -14280,7 +14401,7 @@ return `{ last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -14341,9 +14462,7 @@ return `{ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -14362,8 +14481,6 @@ return `{ * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set \`done\` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -14372,7 +14489,7 @@ return `{ this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -14382,13 +14499,13 @@ return `{ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\\n') { lines = true; } else if (ch === '\\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\\n') { slice_len++; ch += ch2; @@ -14420,10 +14537,8 @@ return `{ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -14455,8 +14570,8 @@ return `{ // Get last entirely matched line into the \`pre_lines[]\` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -14474,9 +14589,9 @@ return `{ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -14486,14 +14601,12 @@ return `{ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -14504,8 +14617,6 @@ return `{ * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -14518,19 +14629,17 @@ return `{ * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the \`parseError()\` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // \`.lex()\` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -14543,8 +14652,6 @@ return `{ * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -14567,24 +14674,24 @@ return `{ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substr\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14596,8 +14703,8 @@ return `{ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to \`maxSize\` (default: 20). @@ -14623,24 +14730,25 @@ return `{ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > \`lookAhead()\` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substring\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -14649,7 +14757,7 @@ return `{ } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14668,10 +14776,8 @@ return `{ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^'; }, @@ -14693,15 +14799,13 @@ return `{ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -14832,58 +14936,54 @@ return `{ * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\\t/g, ' '); @@ -14892,13 +14992,13 @@ return `{ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -14920,15 +15020,13 @@ return `{ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -14940,8 +15038,8 @@ return `{ rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -14970,13 +15068,7 @@ return `{ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -15005,10 +15097,10 @@ return `{ }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -15036,7 +15128,7 @@ return `{ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -15047,7 +15139,7 @@ return `{ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -15069,8 +15161,6 @@ return `{ * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -15079,17 +15169,13 @@ return `{ this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -15099,67 +15185,75 @@ return `{ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that \`parseError()\` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) \`parseError()\` @@ -15186,9 +15280,7 @@ return `{ * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15231,24 +15323,24 @@ return `{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15268,9 +15360,7 @@ return `{ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15280,24 +15370,24 @@ return `{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15305,7 +15395,7 @@ return `{ this._clear_state = 0; } - + return r; }, @@ -15318,9 +15408,7 @@ return `{ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -15328,7 +15416,7 @@ return `{ (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -15343,8 +15431,6 @@ return `{ * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -15356,8 +15442,6 @@ return `{ * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -15371,15 +15455,12 @@ return `{ * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -15391,14 +15472,11 @@ return `{ * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -15409,16 +15487,14 @@ return `{ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -15428,8 +15504,6 @@ return `{ * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; } }`; @@ -15461,18 +15535,17 @@ function stripUnusedLexerCode(src, opt) { // ............................. ${opt.lexerActionsUseDisplayAPIs} // uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC} - var new_src; + let new_src; try { - var ast = helpers.parseCodeChunkToAST(src, opt); + let ast = helpers.parseCodeChunkToAST(src, opt); new_src = helpers.prettyPrintAST(ast, opt); - } - catch (ex) { + } catch (ex) { let line = ex.lineNumber || 0; let a = src.split(/\r?\n/g); let len = a.length; let minl = Math.max(0, line - 10); let b = a.slice(minl, line + 10); - let c = b.splice(line - minl, 0, "", "^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", ""); + let c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); let offendingChunk = ' ' + b.join('\n '); console.error(rmCommonWS$2` stripUnusedLexerCode WARNING: @@ -15488,17 +15561,11 @@ function stripUnusedLexerCode(src, opt) { ${offendingChunk} `); - + new_src = src; } - - - - - - // inject analysis report now: new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2` // Code Generator Information Report @@ -15553,7 +15620,7 @@ function stripUnusedLexerCode(src, opt) { // generate lexer source from a grammar /** @public */ function generate(dict, tokens, build_options) { - var opt = processGrammar(dict, tokens, build_options); + let opt = processGrammar(dict, tokens, build_options); return generateFromOpts(opt); } @@ -15562,7 +15629,7 @@ function generate(dict, tokens, build_options) { /** @public */ function processGrammar(dict, tokens, build_options) { build_options = build_options || {}; - var opts = { + let opts = { // include the knowledge passed through `build_options` about which lexer // features will actually be *used* by the environment (which in 99.9% // of cases is a jison *parser*): @@ -15602,7 +15669,7 @@ function processGrammar(dict, tokens, build_options) { lexerActionsUseReject: '???', lexerActionsUseLess: '???', lexerActionsUseDisplayAPIs: '???', - lexerActionsUseDescribeYYLOC: '???', + lexerActionsUseDescribeYYLOC: '???' }; dict = autodetectAndConvertToJSONformat(dict, build_options) || {}; @@ -15627,7 +15694,7 @@ function processGrammar(dict, tokens, build_options) { // only produce rule action code blocks when there are any rules at all; // a "custom lexer" has ZERO rules and must be defined entirely in // other code blocks: - var code = (dict.rules ? buildActions(dict, tokens, opts) : {}); + let code = (dict.rules ? buildActions(dict, tokens, opts) : {}); opts.performAction = code.actions; opts.caseHelperInclude = code.caseHelperInclude; opts.rules = code.rules || []; @@ -15636,7 +15703,7 @@ function processGrammar(dict, tokens, build_options) { opts.regular_rule_count = code.regular_rule_count; opts.simple_rule_count = code.simple_rule_count; - opts.conditionStack = ['INITIAL']; + opts.conditionStack = [ 'INITIAL' ]; opts.actionInclude = (dict.actionInclude || ''); opts.moduleInclude = (opts.moduleInclude || '') + (dict.moduleInclude || '').trim(); @@ -15647,7 +15714,7 @@ function processGrammar(dict, tokens, build_options) { // Assemble the final source from the processed grammar /** @public */ function generateFromOpts(opt) { - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -15670,12 +15737,12 @@ function generateFromOpts(opt) { } function generateRegexesInitTableCode(opt) { - var a = opt.rules; - var print_xregexp = opt.options && opt.options.xregexp; - var id_display_width = (1 + Math.log10(a.length | 1) | 0); - var ws_prefix = new Array(id_display_width).join(' '); - var b = a.map(function generateXRegExpInitCode(re, idx) { - var idx_str = (ws_prefix + idx).substr(-id_display_width); + let a = opt.rules; + let print_xregexp = opt.options && opt.options.xregexp; + let id_display_width = (1 + Math.log10(a.length | 1) | 0); + let ws_prefix = new Array(id_display_width).join(' '); + let b = a.map(function generateXRegExpInitCode(re, idx) { + let idx_str = (ws_prefix + idx).substr(-id_display_width); if (re instanceof XRegExp__default['default']) { // When we don't need the special XRegExp sauce at run-time, we do with the original @@ -15685,11 +15752,11 @@ function generateRegexesInitTableCode(opt) { } // And make sure to escape the regex to make it suitable for placement inside a *string* // as it is passed as a string argument to the XRegExp constructor here. - var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); + let re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); return `/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`; - } else { - return `/* ${idx_str}: */ ${re}`; } + return `/* ${idx_str}: */ ${re}`; + }); return b.join(',\n'); } @@ -15697,77 +15764,77 @@ function generateRegexesInitTableCode(opt) { function generateModuleBody(opt) { // make the JSON output look more like JavaScript: function cleanupJSON(str) { - str = str.replace(/ "rules": \[/g, ' rules: ['); - str = str.replace(/ "inclusive": /g, ' inclusive: '); + str = str.replace(/ {2}"rules": \[/g, ' rules: ['); + str = str.replace(/ {2}"inclusive": /g, ' inclusive: '); return str; } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - json: 1, - _: 1, - noMain: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - lexerErrorsAreRecoverable: 0, - flex: 0, - backtrack_lexer: 0, - caseInsensitive: 0, - showSource: 1, - exportAST: 1, - exportAllTables: 1, - exportSourceCode: 1, - prettyCfg: 1, - parseActionsUseYYLENG: 1, - parseActionsUseYYLINENO: 1, - parseActionsUseYYTEXT: 1, - parseActionsUseYYLOC: 1, - parseActionsUseParseError: 1, - parseActionsUseYYERROR: 1, - parseActionsUseYYRECOVERING: 1, - parseActionsUseYYERROK: 1, - parseActionsUseYYCLEARIN: 1, - parseActionsUseValueTracking: 1, - parseActionsUseValueAssignment: 1, - parseActionsUseLocationTracking: 1, - parseActionsUseLocationAssignment: 1, - parseActionsUseYYSTACK: 1, - parseActionsUseYYSSTACK: 1, - parseActionsUseYYSTACKPOINTER: 1, - parseActionsUseYYRULELENGTH: 1, - parseActionsUseYYMERGELOCATIONINFO: 1, - parserHasErrorRecovery: 1, - parserHasErrorReporting: 1, - lexerActionsUseYYLENG: 1, - lexerActionsUseYYLINENO: 1, - lexerActionsUseYYTEXT: 1, - lexerActionsUseYYLOC: 1, - lexerActionsUseParseError: 1, - lexerActionsUseYYERROR: 1, - lexerActionsUseLocationTracking: 1, - lexerActionsUseMore: 1, - lexerActionsUseUnput: 1, - lexerActionsUseReject: 1, - lexerActionsUseLess: 1, - lexerActionsUseDisplayAPIs: 1, - lexerActionsUseDescribeYYLOC: 1, + let obj = {}; + const do_not_pass = { + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + json: 1, + _: 1, + noMain: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + lexerErrorsAreRecoverable: 0, + flex: 0, + backtrack_lexer: 0, + caseInsensitive: 0, + showSource: 1, + exportAST: 1, + exportAllTables: 1, + exportSourceCode: 1, + prettyCfg: 1, + parseActionsUseYYLENG: 1, + parseActionsUseYYLINENO: 1, + parseActionsUseYYTEXT: 1, + parseActionsUseYYLOC: 1, + parseActionsUseParseError: 1, + parseActionsUseYYERROR: 1, + parseActionsUseYYRECOVERING: 1, + parseActionsUseYYERROK: 1, + parseActionsUseYYCLEARIN: 1, + parseActionsUseValueTracking: 1, + parseActionsUseValueAssignment: 1, + parseActionsUseLocationTracking: 1, + parseActionsUseLocationAssignment: 1, + parseActionsUseYYSTACK: 1, + parseActionsUseYYSSTACK: 1, + parseActionsUseYYSTACKPOINTER: 1, + parseActionsUseYYRULELENGTH: 1, + parseActionsUseYYMERGELOCATIONINFO: 1, + parserHasErrorRecovery: 1, + parserHasErrorReporting: 1, + lexerActionsUseYYLENG: 1, + lexerActionsUseYYLINENO: 1, + lexerActionsUseYYTEXT: 1, + lexerActionsUseYYLOC: 1, + lexerActionsUseParseError: 1, + lexerActionsUseYYERROR: 1, + lexerActionsUseLocationTracking: 1, + lexerActionsUseMore: 1, + lexerActionsUseUnput: 1, + lexerActionsUseReject: 1, + lexerActionsUseLess: 1, + lexerActionsUseDisplayAPIs: 1, + lexerActionsUseDescribeYYLOC: 1 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -15778,8 +15845,8 @@ function generateModuleBody(opt) { } // And now some options which should receive some special processing: - var pre = obj.pre_lex; - var post = obj.post_lex; + let pre = obj.pre_lex; + let post = obj.post_lex; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_lex = true; @@ -15788,7 +15855,7 @@ function generateModuleBody(opt) { obj.post_lex = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$1})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_lex: true(,)?$/gm, function (m, ls, tc) { @@ -15801,17 +15868,17 @@ function generateModuleBody(opt) { } - var out; + let out; if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) { // we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. - var code = [rmCommonWS$2` - var lexer = { - `, '/*JISON-LEX-ANALYTICS-REPORT*/' /* slot #1: placeholder for analysis report further below */ + let code = [ rmCommonWS$2` + const lexer = { + `, '/* JISON-LEX-ANALYTICS-REPORT */\n' /* slot #1: placeholder for analysis report further below */ ]; // get the RegExpLexer.prototype in source code form: - var protosrc = getRegExpLexerPrototype(); + let protosrc = getRegExpLexerPrototype(); // and strip off the surrounding bits we don't want: protosrc = protosrc .replace(/^[\s\r\n]*\{/, '') @@ -15838,10 +15905,10 @@ function generateModuleBody(opt) { } */ - var performActionCode = String(opt.performAction); - var simpleCaseActionClustersCode = String(opt.caseHelperInclude); - var rulesCode = generateRegexesInitTableCode(opt); - var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); + let performActionCode = String(opt.performAction); + let simpleCaseActionClustersCode = String(opt.caseHelperInclude); + let rulesCode = generateRegexesInitTableCode(opt); + let conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); code.push(rmCommonWS$2`, JisonLexerError: JisonLexerError, performAction: ${performActionCode}, @@ -15861,9 +15928,9 @@ function generateModuleBody(opt) { // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // - // Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter + // Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. - out = 'var lexer;\n'; + out = '\n'; assert__default['default'](opt.regular_rule_count === 0); assert__default['default'](opt.simple_rule_count === 0); @@ -15877,8 +15944,6 @@ function generateModuleBody(opt) { // The output of this function is guaranteed to read something like this: // // ``` - // var lexer; - // // bla bla bla bla ... lotsa bla bla; // ``` // @@ -15887,7 +15952,7 @@ function generateModuleBody(opt) { } function generateGenericHeaderComment() { - var out = rmCommonWS$2` + let out = rmCommonWS$2` /* lexer generated by jison-lex ${version} */ /* @@ -16116,7 +16181,7 @@ function prepareOptions(opt) { // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else { @@ -16134,9 +16199,9 @@ function prepareOptions(opt) { function generateModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -16159,9 +16224,9 @@ function generateModule(opt) { function generateAMDModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} define([], function () { @@ -16184,12 +16249,12 @@ function generateAMDModule(opt) { function generateESModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} - var lexer = (function () { + const lexer = (function () { "use strict"; ${jisonLexerErrorDefinition} @@ -16218,9 +16283,9 @@ function generateESModule(opt) { function generateCommonJSModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -16262,7 +16327,6 @@ RegExpLexer.autodetectAndConvertToJSONformat = autodetectAndConvertToJSONformat; // 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. function JisonParserError$1(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -16279,9 +16343,9 @@ function JisonParserError$1(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -16314,10 +16378,10 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp$1(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -16332,18 +16396,18 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt$1(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -16374,7 +16438,7 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // `this` references an array function s$1(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -16391,9 +16455,9 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$1(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -16406,7 +16470,7 @@ JisonParserError$1.prototype.name = 'JisonParserError'; } -var parser$1 = { +let parser$1 = { // Code Generator Information Report // --------------------------------- // @@ -16532,7 +16596,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -16540,7 +16603,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -16552,8 +16614,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -16566,14 +16628,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -16589,10 +16650,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -16600,10 +16661,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -16647,9 +16708,9 @@ performAction: function parser__PerformAction(yystate /* action[1] */, yysp, yyv /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; @@ -16657,17 +16718,17 @@ performAction: function parser__PerformAction(yystate /* action[1] */, yysp, yyv case 0: /*! Production:: $accept : production $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-) break; case 1: /*! Production:: production : handle EOF */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-) return yyvstack[yysp - 1]; @@ -16903,7 +16964,6 @@ defaultActions: { 19: 3 }, parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -16920,37 +16980,32 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) + let vstack = new Array(128); // semantic value stack - var vstack = new Array(128); // semantic value stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks + let symbol = 0; - + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - var symbol = 0; - - - - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -16958,20 +17013,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -16988,7 +17041,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -16996,18 +17048,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -17015,18 +17068,14 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -17048,7 +17097,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -17061,7 +17109,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -17075,11 +17122,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -17133,8 +17179,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -17283,8 +17329,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -17293,10 +17338,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -17304,7 +17349,7 @@ parse: function parse(input) { stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -17315,9 +17360,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -17343,8 +17393,7 @@ parse: function parse(input) { function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -17353,21 +17402,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -17377,21 +17425,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -17400,20 +17447,20 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; try { @@ -17426,7 +17473,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -17479,14 +17526,11 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { - var errStr; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let errStr; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); // Report error errStr = 'Parse error'; @@ -17523,9 +17567,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -17554,7 +17596,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -17596,21 +17638,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, newState, sp - 1, vstack); +r = this.performAction.call(yyval, newState, sp - 1, vstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -17641,14 +17681,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -17658,6 +17699,7 @@ parse: function parse(input) { + } continue; // accept: @@ -17710,8 +17752,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -17971,7 +18012,6 @@ var lexer$1 = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -17988,10 +18028,10 @@ var lexer$1 = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -18023,7 +18063,7 @@ var lexer$1 = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -18065,7 +18105,9 @@ var lexer$1 = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -18151,7 +18193,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -18159,7 +18201,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -18172,7 +18214,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -18198,10 +18240,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -18224,7 +18269,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -18247,16 +18291,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -18278,7 +18322,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -18286,8 +18329,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -18316,7 +18359,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -18341,7 +18384,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -18353,17 +18396,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -18457,7 +18500,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -18478,7 +18521,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -18489,7 +18531,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -18500,15 +18542,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -18542,8 +18584,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -18576,9 +18618,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -18597,9 +18639,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -18609,8 +18651,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -18637,20 +18679,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -18690,17 +18731,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -18709,7 +18752,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -18724,8 +18767,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -18751,24 +18794,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -18779,7 +18824,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -18801,8 +18846,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -18824,8 +18869,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -18969,21 +19013,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -18998,11 +19042,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -19021,13 +19065,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -19051,13 +19095,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -19072,8 +19116,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -19104,7 +19148,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -19136,9 +19180,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -19167,7 +19211,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -19185,7 +19229,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -19210,7 +19254,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -19220,8 +19263,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -19230,7 +19271,7 @@ EOF: 1, this.clear(); } - 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. @@ -19242,13 +19283,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -19258,68 +19299,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -19344,7 +19391,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -19392,24 +19439,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -19429,7 +19476,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -19439,24 +19486,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -19477,8 +19524,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -19518,14 +19564,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -19541,9 +19587,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -19554,8 +19600,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -19563,7 +19609,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -19716,9 +19762,9 @@ const ID_REGEX_BASE$2 = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // guaranteed not to collide with previously generated / already existing // rules (~ symbols). function generateUniqueSymbol(id, postfix, opts) { - var sym = id + postfix; + let sym = id + postfix; if (opts.grammar[sym]) { - var i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. + let i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. do { sym = id + postfix + i; i++; @@ -19728,8 +19774,8 @@ function generateUniqueSymbol(id, postfix, opts) { } function generatePushAction(handle, offset) { - var terms = handle.terms; - var rv = []; + const terms = handle.terms; + let rv = []; for (var i = 0, len = terms.length; i < len; i++) { rv.push('$' + (i + offset)); @@ -19745,11 +19791,11 @@ function generatePushAction(handle, offset) { } function transformExpression(e, opts, emit) { - var type = e[0], - value = e[1], - name = false, - has_transformed = 0; - var list, n; + let type = e[0]; + let value = e[1]; + let name = false; + let has_transformed = 0; + let list, n; if (type === 'xalias') { type = e[1]; @@ -19776,7 +19822,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ list.fragment, @@ -19796,7 +19842,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ '', @@ -19816,7 +19862,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); // you want to be able to check if 0 or 1 occurrences were recognized: since jison // by default *copies* the lexer token value, i.e. `$$ = $1` is the (optional) default action, // we will need to set the action up explicitly in case of the 0-count match: @@ -19852,7 +19898,7 @@ function transformExpression(e, opts, emit) { opts = optsForProduction(name, opts.grammar); opts.grammar[name] = value.map(function (handle) { - var list = transformExpressionList(handle, opts); + let list = transformExpressionList(handle, opts); return [ list.fragment, '$$ = ' + generatePushAction(list, 1) + ';' @@ -19865,11 +19911,11 @@ function transformExpression(e, opts, emit) { } function transformExpressionList(list, opts) { - var first_transformed_term_index = false; - var terms = list.reduce(function (tot, e) { - var ci = tot.length; + let first_transformed_term_index = false; + let terms = list.reduce(function (tot, e) { + let ci = tot.length; - var has_transformed = transformExpression(e, opts, function (name) { + let has_transformed = transformExpression(e, opts, function (name) { if (name.terms) { tot.push.apply(tot, name.terms); } else { @@ -19898,42 +19944,42 @@ function optsForProduction(id, grammar) { } function transformProduction(id, production, grammar) { - var transform_opts = optsForProduction(id, grammar); + let transform_opts = optsForProduction(id, grammar); return production.map(function (handle) { - var action = null, - opts = null; - var i, len, n; + let action = null; + let opts = null; + let i, len, n; if (typeof handle !== 'string') { action = handle[1]; opts = handle[2]; handle = handle[0]; } - var expressions = handle; + let expressions = handle; if (typeof expressions === 'string') { expressions = parser$2.parse(handle); } - var list = transformExpressionList(expressions, transform_opts); + let list = transformExpressionList(expressions, transform_opts); - var ret = [list.fragment]; + let ret = [ list.fragment ]; if (action) { // make sure the action doesn't address any inner items. if (list.first_transformed_term_index) { // seek out all names and aliases; strip out literal tokens first as those cannot serve as $names: - var alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); + let alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); - var alias_re = new XRegExp__default['default'](`\\[${ID_REGEX_BASE$2}\\]`); - var term_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$2}$`); + let alias_re = new XRegExp__default['default'](`\\[${ID_REGEX_BASE$2}\\]`); + let term_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$2}$`); // and collect the PERMITTED aliases: the names of the terms and all the remaining aliases - var good_aliases = {}; - var alias_cnt = {}; - var donotalias = {}; + let good_aliases = {}; + let alias_cnt = {}; + let donotalias = {}; // WARNING: this replicates the knowledge/code of jison.js::addName() - var addName = function addNameEBNF(s, i) { - var base = s.replace(/[0-9]+$/, ''); - var dna = donotalias[base]; + let addName = function addNameEBNF(s, i) { + let base = s.replace(/[0-9]+$/, ''); + let dna = donotalias[base]; if (good_aliases[s]) { alias_cnt[s]++; @@ -19952,7 +19998,7 @@ function transformProduction(id, production, grammar) { }; // WARNING: this replicates the knowledge/code of jison.js::markBasename() - var markBasename = function markBasenameEBNF(s) { + let markBasename = function markBasenameEBNF(s) { if (/[0-9]$/.test(s)) { s = s.replace(/[0-9]+$/, ''); donotalias[s] = true; @@ -19989,13 +20035,13 @@ function transformProduction(id, production, grammar) { // now scan the action for all named and numeric semantic values ($nonterminal / $1 / @1, ##1, ...) // // Note that `#name` are straight **static** symbol translations, which are okay as they don't - // require access to the parse stack: `#n` references can be resolved completely + // require access to the parse stack: `#n` references can be resolved completely // at grammar compile time. // - var nameref_re = new XRegExp__default['default'](`(?:[$@]|##)${ID_REGEX_BASE$2}`, 'g'); - var named_spots = nameref_re.exec(action); - var numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); - var max_term_index = list.terms.length; + let nameref_re = new XRegExp__default['default'](`(?:[$@]|##)${ID_REGEX_BASE$2}`, 'g'); + let named_spots = nameref_re.exec(action); + let numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); + let max_term_index = list.terms.length; // loop through the XRegExp alias regex matches in `action` while (named_spots) { @@ -20025,7 +20071,7 @@ function transformProduction(id, production, grammar) { for (i = 0, len = numbered_spots.length; i < len; i++) { n = parseInt(numbered_spots[i].replace(/^(?:[$@]|##)/, '')); if (n > max_term_index) { - /* @const */ var n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; + /* @const */ let n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; throw new Error('The action block references the ' + n + n_suffixes[Math.max(0, Math.min(3, n - 1))] + ' term, ' + 'which is not available in production "' + handle + '"; ' + 'Be reminded that you cannot reference sub-elements within EBNF */+/? groups, ' + @@ -20043,13 +20089,14 @@ function transformProduction(id, production, grammar) { if (ret.length === 1) { return ret[0]; - } else { - return ret; } + return ret; + }); } -var ref_list; -var ref_names; + +let ref_list; +let ref_names; // create a deep copy of the input, so we will keep the input constant. function deepClone(from, sub) { @@ -20064,7 +20111,7 @@ function deepClone(from, sub) { return from; } - var idx = ref_list.indexOf(from); + let idx = ref_list.indexOf(from); if (idx >= 0) { throw new Error('[Circular/Xref:' + ref_names[i] + ']'); // circular or cross reference } @@ -20080,7 +20127,7 @@ function deepClone(from, sub) { sub += '.'; var to = new from.constructor(); - for (var name in from) { + for (let name in from) { to[name] = deepClone(from[name], sub + name); } } @@ -20096,8 +20143,9 @@ function transformGrammar(grammar) { return grammar; } + function transform(ebnf) { - var rv = transformGrammar(ebnf); + let rv = transformGrammar(ebnf); return rv; } @@ -20107,7 +20155,6 @@ function transform(ebnf) { // 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. function JisonParserError$2(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -20124,9 +20171,9 @@ function JisonParserError$2(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -20159,10 +20206,10 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp$2(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -20175,11 +20222,11 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda$1(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -20189,18 +20236,18 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt$2(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -20231,7 +20278,7 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // `this` references an array function s$2(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -20248,9 +20295,9 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$2(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -20263,7 +20310,7 @@ JisonParserError$2.prototype.name = 'JisonParserError'; } -var parser$3 = { +let parser$3 = { // Code Generator Information Report // --------------------------------- // @@ -20499,7 +20546,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -20507,7 +20553,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -20519,8 +20564,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -20533,14 +20578,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -20556,10 +20600,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -20567,10 +20611,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -20751,26 +20795,26 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; switch (yystate) { case 0: /*! Production:: $accept : spec $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break; case 1: /*! Production:: spec : declaration_list "%%" grammar optional_end_block EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4]; @@ -20782,10 +20826,10 @@ case 1: case 2: /*! Production:: spec : declaration_list "%%" grammar error EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -20804,10 +20848,10 @@ case 2: case 3: /*! Production:: spec : declaration_list error EOF */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -20829,9 +20873,9 @@ case 118: case 133: /*! Production:: optional_module_code_chunk : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -20840,9 +20884,9 @@ case 133: case 5: /*! Production:: optional_end_block : "%%" extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20862,9 +20906,9 @@ case 6: case 10: /*! Production:: declaration_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; @@ -20875,9 +20919,9 @@ case 7: case 8: /*! Production:: optional_action_header_block : optional_action_header_block include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -20896,9 +20940,9 @@ case 8: case 9: /*! Production:: declaration_list : declaration_list declaration */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20907,10 +20951,10 @@ case 9: case 11: /*! Production:: declaration_list : declaration_list error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -20925,9 +20969,9 @@ case 11: case 12: /*! Production:: declaration : START id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {start: yyvstack[yysp]}; @@ -20936,9 +20980,9 @@ case 12: case 13: /*! Production:: declaration : LEX_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {lex: {text: yyvstack[yysp], position: yylstack[yysp]}}; @@ -20947,9 +20991,9 @@ case 13: case 14: /*! Production:: declaration : operator */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {operator: yyvstack[yysp]}; @@ -20958,9 +21002,9 @@ case 14: case 15: /*! Production:: declaration : TOKEN full_token_definitions */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {token_list: yyvstack[yysp]}; @@ -20969,9 +21013,9 @@ case 15: case 16: /*! Production:: declaration : ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20989,9 +21033,9 @@ case 16: case 17: /*! Production:: declaration : include_macro_code */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21009,9 +21053,9 @@ case 17: case 18: /*! Production:: declaration : parse_params */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parseParams: yyvstack[yysp]}; @@ -21020,9 +21064,9 @@ case 18: case 19: /*! Production:: declaration : parser_type */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parserType: yyvstack[yysp]}; @@ -21031,9 +21075,9 @@ case 19: case 20: /*! Production:: declaration : options */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: yyvstack[yysp]}; @@ -21042,9 +21086,9 @@ case 20: case 21: /*! Production:: declaration : DEBUG */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: [['debug', true]]}; @@ -21053,9 +21097,9 @@ case 21: case 22: /*! Production:: declaration : EBNF */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) ebnf = true; @@ -21065,9 +21109,9 @@ case 22: case 23: /*! Production:: declaration : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {unknownDecl: yyvstack[yysp]}; @@ -21076,9 +21120,9 @@ case 23: case 24: /*! Production:: declaration : IMPORT import_name import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = {imports: {name: yyvstack[yysp - 1], path: yyvstack[yysp]}}; @@ -21087,10 +21131,10 @@ case 24: case 25: /*! Production:: declaration : IMPORT import_name error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21106,10 +21150,10 @@ case 25: case 26: /*! Production:: declaration : IMPORT error import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21125,9 +21169,9 @@ case 26: case 27: /*! Production:: declaration : INIT_CODE init_code_name action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21150,10 +21194,10 @@ case 27: case 28: /*! Production:: declaration : INIT_CODE error action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21169,10 +21213,10 @@ case 28: case 29: /*! Production:: declaration : START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21187,10 +21231,10 @@ case 29: case 30: /*! Production:: declaration : TOKEN error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21205,10 +21249,10 @@ case 30: case 31: /*! Production:: declaration : IMPORT error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21273,9 +21317,9 @@ case 129: case 132: /*! Production:: optional_module_code_chunk : module_code_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -21286,9 +21330,9 @@ case 39: case 111: /*! Production:: action_ne : "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21297,10 +21341,10 @@ case 111: case 40: /*! Production:: options : OPTIONS error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21315,10 +21359,10 @@ case 40: case 41: /*! Production:: options : OPTIONS error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21337,9 +21381,9 @@ case 59: case 70: /*! Production:: id_list : id_list id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21354,9 +21398,9 @@ case 71: case 84: /*! Production:: handle_list : handle_action */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -21365,9 +21409,9 @@ case 84: case 44: /*! Production:: option : NAME */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -21376,9 +21420,9 @@ case 44: case 45: /*! Production:: option : NAME "=" OPTION_STRING_VALUE */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -21389,9 +21433,9 @@ case 46: case 47: /*! Production:: option : NAME "=" NAME */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], parseValue$1(yyvstack[yysp])]; @@ -21400,10 +21444,10 @@ case 47: case 48: /*! Production:: option : NAME "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21418,10 +21462,10 @@ case 48: case 49: /*! Production:: option : NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21438,9 +21482,9 @@ case 50: case 52: /*! Production:: parser_type : PARSER_TYPE symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -21449,10 +21493,10 @@ case 52: case 51: /*! Production:: parse_params : PARSE_PARAM error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21470,10 +21514,10 @@ case 51: case 53: /*! Production:: parser_type : PARSER_TYPE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21491,9 +21535,9 @@ case 53: case 54: /*! Production:: operator : associativity token_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1]]; this.$.push.apply(this.$, yyvstack[yysp]); @@ -21502,10 +21546,10 @@ case 54: case 55: /*! Production:: operator : associativity error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21523,9 +21567,9 @@ case 55: case 56: /*! Production:: associativity : LEFT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'left'; @@ -21534,9 +21578,9 @@ case 56: case 57: /*! Production:: associativity : RIGHT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'right'; @@ -21545,9 +21589,9 @@ case 57: case 58: /*! Production:: associativity : NONASSOC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'nonassoc'; @@ -21556,9 +21600,9 @@ case 58: case 61: /*! Production:: full_token_definitions : optional_token_type id_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var rv = []; @@ -21577,9 +21621,9 @@ case 61: case 62: /*! Production:: full_token_definitions : optional_token_type one_full_token */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var m = yyvstack[yysp]; @@ -21592,9 +21636,9 @@ case 62: case 63: /*! Production:: one_full_token : id token_value token_description */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21607,9 +21651,9 @@ case 63: case 64: /*! Production:: one_full_token : id token_description */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21621,9 +21665,9 @@ case 64: case 65: /*! Production:: one_full_token : id token_value */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21635,9 +21679,9 @@ case 65: case 66: /*! Production:: optional_token_type : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = false; @@ -21646,9 +21690,9 @@ case 66: case 72: /*! Production:: grammar : optional_action_header_block production_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21658,9 +21702,9 @@ case 72: case 73: /*! Production:: production_list : production_list production */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21674,9 +21718,9 @@ case 73: case 74: /*! Production:: production_list : production */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; this.$[yyvstack[yysp][0]] = yyvstack[yysp][1]; @@ -21685,9 +21729,9 @@ case 74: case 75: /*! Production:: production : production_id handle_list ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp - 1]]; @@ -21696,10 +21740,10 @@ case 75: case 76: /*! Production:: production : production_id error ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21717,10 +21761,10 @@ case 76: case 77: /*! Production:: production : production_id error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21738,9 +21782,9 @@ case 77: case 78: /*! Production:: production_id : id optional_production_description ":" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21751,10 +21795,10 @@ case 78: case 79: /*! Production:: production_id : id optional_production_description error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21772,10 +21816,10 @@ case 79: case 80: /*! Production:: production_id : id optional_production_description ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21799,18 +21843,18 @@ case 80: case 82: /*! Production:: optional_production_description : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) break; case 83: /*! Production:: handle_list : handle_list "|" handle_action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21820,10 +21864,10 @@ case 83: case 85: /*! Production:: handle_list : handle_list "|" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21841,10 +21885,10 @@ case 85: case 86: /*! Production:: handle_list : handle_list ":" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21859,9 +21903,9 @@ case 86: case 87: /*! Production:: handle_action : handle prec action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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(' ') : '')]; @@ -21896,9 +21940,9 @@ case 87: case 88: /*! Production:: handle_action : EPSILON action */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = ['']; @@ -21922,10 +21966,10 @@ case 88: case 89: /*! Production:: handle_action : EPSILON error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21940,9 +21984,9 @@ case 89: case 90: /*! Production:: handle : handle suffixed_expression */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21952,9 +21996,9 @@ case 90: case 91: /*! Production:: handle : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -21963,9 +22007,9 @@ case 91: case 92: /*! Production:: handle_sublist : handle_sublist "|" handle */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21975,9 +22019,9 @@ case 92: case 93: /*! Production:: handle_sublist : handle */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp].join(' ')]; @@ -21986,9 +22030,9 @@ case 93: case 94: /*! Production:: suffixed_expression : expression suffix ALIAS */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + "[" + yyvstack[yysp] + "]"; @@ -22001,9 +22045,9 @@ case 124: case 130: /*! Production:: module_code_chunk : module_code_chunk CODE */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22012,9 +22056,9 @@ case 130: case 97: /*! Production:: expression : EOF_ID */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$end'; @@ -22023,9 +22067,9 @@ case 97: case 98: /*! Production:: expression : STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // Re-encode the string *anyway* as it will @@ -22038,9 +22082,9 @@ case 98: case 99: /*! Production:: expression : "(" handle_sublist ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1].join(' | ') + ')'; @@ -22049,10 +22093,10 @@ case 99: case 100: /*! Production:: expression : "(" handle_sublist error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22066,9 +22110,9 @@ case 100: case 105: /*! Production:: prec : PREC symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { prec: yyvstack[yysp] }; @@ -22077,10 +22121,10 @@ case 105: case 106: /*! Production:: prec : PREC error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -22098,9 +22142,9 @@ case 106: case 107: /*! Production:: prec : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = null; @@ -22109,10 +22153,10 @@ case 107: case 112: /*! Production:: action_ne : "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22126,9 +22170,9 @@ case 112: case 116: /*! Production:: action : ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$$ = (' + yyvstack[yysp] + ');'; @@ -22137,9 +22181,9 @@ case 116: case 120: /*! Production:: action_body : action_body "{" action_body "}" action_comments_body */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4] + yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22148,9 +22192,9 @@ case 120: case 121: /*! Production:: action_body : action_body "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22159,10 +22203,10 @@ case 121: case 122: /*! Production:: action_body : action_body "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22176,9 +22220,9 @@ case 122: case 126: /*! Production:: extra_parser_module_code : optional_module_code_chunk include_macro_code extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22187,9 +22231,9 @@ case 126: case 127: /*! Production:: include_macro_code : INCLUDE PATH */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' }); @@ -22209,10 +22253,10 @@ case 127: case 128: /*! Production:: include_macro_code : INCLUDE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22225,10 +22269,10 @@ case 128: case 131: /*! Production:: module_code_chunk : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -23621,7 +23665,6 @@ defaultActions: bda$1({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -23638,38 +23681,34 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -23677,20 +23716,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -23712,7 +23749,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -23720,18 +23756,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -23739,24 +23776,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -23794,18 +23826,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -23826,7 +23855,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -23844,7 +23873,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -23857,7 +23885,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -23871,11 +23898,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -23929,8 +23955,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -23938,8 +23964,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -23971,19 +23997,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -23994,7 +24019,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -24007,7 +24032,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -24019,29 +24044,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -24049,7 +24072,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -24069,8 +24092,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -24079,10 +24101,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -24090,7 +24112,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -24101,9 +24123,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -24119,8 +24146,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -24189,11 +24215,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -24204,8 +24233,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -24214,21 +24242,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -24238,21 +24265,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -24261,28 +24287,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -24295,8 +24320,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -24319,8 +24343,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -24332,8 +24355,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -24350,8 +24372,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -24365,8 +24386,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -24380,7 +24400,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -24433,16 +24453,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -24476,9 +24493,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -24501,9 +24516,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -24530,17 +24543,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -24587,8 +24599,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -24600,8 +24612,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -24619,6 +24630,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -24627,7 +24639,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -24638,7 +24650,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -24698,10 +24710,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -24736,9 +24748,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -24751,7 +24761,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -24772,9 +24782,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -24796,12 +24804,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -24810,7 +24818,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -24851,7 +24859,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -24898,7 +24906,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -24916,21 +24924,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -24964,14 +24970,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -24981,6 +24988,7 @@ parse: function parse(input) { + } continue; // accept: @@ -25032,7 +25040,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -25048,9 +25056,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -25079,7 +25085,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -25096,8 +25102,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -25108,8 +25114,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -25121,21 +25127,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -25166,14 +25170,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -25183,6 +25188,7 @@ parse: function parse(input) { + } continue; // accept: @@ -25235,8 +25241,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -25497,7 +25502,6 @@ var lexer$2 = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -25514,10 +25518,10 @@ var lexer$2 = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -25549,7 +25553,7 @@ var lexer$2 = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -25591,7 +25595,9 @@ var lexer$2 = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -25677,7 +25683,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -25685,7 +25691,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -25698,7 +25704,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -25724,10 +25730,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -25750,7 +25759,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -25773,16 +25781,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -25804,7 +25812,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -25812,8 +25819,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -25842,7 +25849,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -25867,7 +25874,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -25879,17 +25886,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -25983,7 +25990,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -26004,7 +26011,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -26015,7 +26021,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -26026,15 +26032,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -26068,8 +26074,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -26102,9 +26108,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -26123,9 +26129,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -26135,8 +26141,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -26163,20 +26169,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -26216,17 +26221,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -26235,7 +26242,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -26250,8 +26257,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -26277,24 +26284,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -26305,7 +26314,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -26327,8 +26336,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -26350,8 +26359,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -26495,21 +26503,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -26524,11 +26532,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -26547,13 +26555,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -26577,13 +26585,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -26598,8 +26606,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -26630,7 +26638,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -26662,9 +26670,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -26693,7 +26701,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -26711,7 +26719,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -26736,7 +26744,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -26746,8 +26753,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -26756,7 +26761,7 @@ EOF: 1, this.clear(); } - 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. @@ -26768,13 +26773,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -26784,68 +26789,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -26870,7 +26881,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -26918,24 +26929,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -26955,7 +26966,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -26965,24 +26976,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -27003,8 +27014,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -27044,14 +27054,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -27067,9 +27077,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -27080,8 +27090,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -27089,7 +27099,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -28134,7 +28144,7 @@ var bnf = { }; -var version$1 = '0.6.2-220'; // require('./package.json').version; +const version$1 = '0.6.2-220'; // require('./package.json').version; function parse(grammar) { return bnf.parser.parse(grammar); @@ -28200,7 +28210,7 @@ bnf.parser.yy.addDeclaration = function bnfAddDeclaration(grammar, decl) { if (decl.options) { if (!grammar.options) grammar.options = {}; // last occurrence of `%options` wins: - for (var i = 0; i < decl.options.length; i++) { + for (let i = 0; i < decl.options.length; i++) { grammar.options[decl.options[i][0]] = decl.options[i][1]; } } @@ -28240,9 +28250,9 @@ function parseLex(text, position) { // which matches the original input file: position = position || {}; position.range = position.range || []; - var l = position.first_line | 0; - var c = position.range[0] | 0; - var prelude = ''; + let l = position.first_line | 0; + let c = position.range[0] | 0; + let prelude = ''; if (l > 1) { prelude += (new Array(l)).join('\n'); c -= prelude.length; @@ -28267,10 +28277,10 @@ var ebnfParser = { ebnf_parser, bnf_lexer: lexParser, - version: version$1, + version: version$1 }; -var rmCommonWS$4 = helpers.rmCommonWS; +const rmCommonWS$4 = helpers.rmCommonWS; /** @@ -28296,14 +28306,14 @@ function grammarPrinter(raw, options) { case 'json5': options.format = 'json5'; break; - + case '.y': case '.yacc': options.format = 'jison'; options.showLexer = false; options.showParser = true; break; - + case '.l': case '.lex': options.format = 'jison'; @@ -28325,20 +28335,20 @@ function grammarPrinter(raw, options) { // which MAY get corrupted that way as their actual content would change then! // construct fake nesting levels to arrive at the intended start indent value: `num` - var nesting_levels = num / 2; - var pre = '// **PRE**', - post = '// **POST**'; - for ( ; nesting_levels > 0; nesting_levels--) { + let nesting_levels = num / 2; + let pre = '// **PRE**'; + let post = '// **POST**'; + for (; nesting_levels > 0; nesting_levels--) { pre = 'function x() {\n' + pre; post += '\n}'; } - src = '\n' + pre + '\n' + src + '\n' + post + '\n'; + src = '\n' + pre + '\n' + src + '\n' + post + '\n'; - var ast = helpers.parseCodeChunkToAST(src, options); - var new_src = helpers.prettyPrintAST(ast, options); + let ast = helpers.parseCodeChunkToAST(src, options); + let new_src = helpers.prettyPrintAST(ast, options); - var start = new_src.indexOf('// **PRE**'); - var end = new_src.lastIndexOf('// **POST**'); + let start = new_src.indexOf('// **PRE**'); + let end = new_src.lastIndexOf('// **POST**'); new_src = new_src .substring(start + 10, end) .trim(); @@ -28347,13 +28357,13 @@ function grammarPrinter(raw, options) { } function isEmptyObj(obj) { - var keys = obj && typeof obj === 'object' && Object.keys(obj); + let keys = obj && typeof obj === 'object' && Object.keys(obj); return keys && keys.length === 0; } function isEmptyArr(arr) { if (arr && arr instanceof Array) { - for (var i = 0, len = arr.length; i < len; i++) { + for (let i = 0, len = arr.length; i < len; i++) { if (arr[i] !== undefined) { return false; } @@ -28366,8 +28376,8 @@ function grammarPrinter(raw, options) { // Copied from Crokford's implementation of JSON // See https://github.com/douglascrockford/JSON-js/blob/e39db4b7e6249f04a195e7dd0840e610cc9e941e/json2.js#L195 // Begin - var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - meta = { // table of character substitutions + let escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; + let meta = { // table of character substitutions '\b': '\\b', '\t': '\\t', '\n': '\\n', @@ -28384,15 +28394,15 @@ function grammarPrinter(raw, options) { // sequences. escapable.lastIndex = 0; return escapable.test(string) ? '"' + string.replace(escapable, function (a) { - var c = meta[a]; + let c = meta[a]; return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }) + '"' : '"' + string + '"'; } - var ref_list; - var ref_names; + let ref_list; + let ref_names; // create a deep copy of the input, so we can delete the parts we converted and dump the remainder // so that we always output the entire thing, even when we don't know all the details about the @@ -28409,7 +28419,7 @@ function grammarPrinter(raw, options) { return from; } - for (var i = 0, len = ref_list.length; i < len; i++) { + for (let i = 0, len = ref_list.length; i < len; i++) { if (ref_list[i] === from) { return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference } @@ -28418,204 +28428,211 @@ function grammarPrinter(raw, options) { ref_names.push(sub); sub += '.'; - var to = new from.constructor(); - for (var name in from) { + let to = new from.constructor(); + for (let name in from) { to[name] = deepClone(from[name], sub + name); } return to; } - var originalInput = raw; + let originalInput = raw; raw = deepClone(raw); - var lex_out_str = ''; + let lex_out_str = ''; if (raw.lex) { var lex_pre = []; - var lex_rules = []; - var lex_post = []; - var key, src; + let lex_rules = []; + let lex_post = []; + + { + let src = raw.lex.macros; + delete raw.lex.macros; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // macros: + `); - src = raw.lex.macros; - delete raw.lex.macros; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // macros: - `); + let keylen = 0; + for (let key in src) { + keylen = Math.max(keylen, key.length); + } + console.log('macros keylen:', keylen); + keylen = ((keylen / 4) | 0) * 4 + 4; + console.log('macros keylen B:', keylen); + for (let key in src) { + lex_pre.push(padRight(key, keylen) + src[key]); + } - var keylen = 0; - for (key in src) { - keylen = Math.max(keylen, key.length); - } - console.log('macros keylen:', keylen); - keylen = ((keylen / 4) | 0) * 4 + 4; - console.log('macros keylen B:', keylen); - for (key in src) { - lex_pre.push(padRight(key, keylen) + src[key]); + lex_pre.push(rmCommonWS$4` + // END of the lexer macros. + `); } - - lex_pre.push(rmCommonWS$4` - // END of the lexer macros. - `); } - src = raw.lex.unknownDecls; - delete raw.lex.unknownDecls; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // unknown declarations: - `); + { + let src = raw.lex.unknownDecls; + delete raw.lex.unknownDecls; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // unknown declarations: + `); - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry.name; + let value = entry.value; - lex_pre.push('%' + key + ' ' + value); - } + lex_pre.push('%' + key + ' ' + value); + } - lex_pre.push(rmCommonWS$4` - // END of unknown declarations. - `); + lex_pre.push(rmCommonWS$4` + // END of unknown declarations. + `); + } } - src = raw.lex.options; - delete raw.lex.options; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // options: - `); + { + let src = raw.lex.options; + delete raw.lex.options; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // options: + `); - for (key in src) { - var value = src[key]; - if (value) { - lex_pre.push('%options ' + key + '=' + value); - } - else { - lex_pre.push('%options ' + key); + for (let key in src) { + let value = src[key]; + if (value) { + lex_pre.push('%options ' + key + '=' + value); + } else { + lex_pre.push('%options ' + key); + } } } } - src = raw.lex.startConditions; - delete raw.lex.startConditions; - if (src && !isEmptyObj(src)) { - for (key in src) { - var value = src[key]; + { + let src = raw.lex.startConditions; + delete raw.lex.startConditions; + if (src && !isEmptyObj(src)) { + for (let key in src) { + let value = src[key]; - lex_pre.push((value ? '%x ' : '%s ') + key); + lex_pre.push((value ? '%x ' : '%s ') + key); + } } } - src = raw.lex.actionInclude; - delete raw.lex.actionInclude; - if (src && src.trim()) { - lex_pre.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + { + let src = raw.lex.actionInclude; + delete raw.lex.actionInclude; + if (src && src.trim()) { + lex_pre.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + } } - src = raw.lex.rules; - delete raw.lex.rules; - if (src) { - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - key = entry[0]; - var action = indentAction(entry[1], 4); - - var actionHasLF = /[\r\n]/.test(action); - console.log('indented action:', { - entry: entry[1], - action, - actionHasLF - }); - if (key.length <= 12) { - if (!actionHasLF) { - lex_rules.push(padRight(key, 16) + indentAction(action, 16)); - } - else { - lex_rules.push(padRight(key, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); - } - } - else { - if (!actionHasLF) { + { + let src = raw.lex.rules; + delete raw.lex.rules; + if (src) { + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry[0]; + let action = indentAction(entry[1], 4); + + let actionHasLF = /[\r\n]/.test(action); + console.log('indented action:', { + entry: entry[1], + action, + actionHasLF + }); + if (key.length <= 12) { + if (!actionHasLF) { + lex_rules.push(padRight(key, 16) + indentAction(action, 16)); + } else { + lex_rules.push(padRight(key, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + } + } else if (!actionHasLF) { lex_rules.push(key, makeIndent(16) + indentAction(action, 16)); - } - else { + } else { lex_rules.push(key, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } } } - src = raw.lex.moduleInclude; - delete raw.lex.moduleInclude; - if (src && src.trim()) { - lex_post.push(indentAction(src.trim(), 0)); + { + let src = raw.lex.moduleInclude; + delete raw.lex.moduleInclude; + if (src && src.trim()) { + lex_post.push(indentAction(src.trim(), 0)); + } } - var out = ''; + { + let out = ''; - if (!isEmptyObj(raw.lex)) { - // dump the remainder as a comment: - var rem = JSON5__default['default'].stringify(raw.lex, null, 2); - out += rmCommonWS$4` - /* - * Lexer stuff that's unknown to the JISON prettyPrint service: - * - * ${rem.replace(/\*\//g, '*\\/')} - */ + if (!isEmptyObj(raw.lex)) { + // dump the remainder as a comment: + let rem = JSON5__default['default'].stringify(raw.lex, null, 2); + out += rmCommonWS$4` + /* + * Lexer stuff that's unknown to the JISON prettyPrint service: + * + * ${rem.replace(/\*\//g, '*\\/')} + */ - `; - } - delete raw.lex; - - out += lex_pre.join('\n') + '\n\n'; - out += rmCommonWS$4` - - %% + `; + } + delete raw.lex; - ` + lex_rules.join('\n') + '\n\n'; - if (lex_post.length > 0) { + out += lex_pre.join('\n') + '\n\n'; out += rmCommonWS$4` %% - ` + lex_post.join('\n') + '\n\n'; + ` + lex_rules.join('\n') + '\n\n'; + if (lex_post.length > 0) { + out += rmCommonWS$4` + + %% + + ` + lex_post.join('\n') + '\n\n'; + } + lex_out_str = out; } - lex_out_str = out; } - var grammar_pre = []; - var grammar_mid = []; - var ebnf_rules = []; - var bnf_rules = []; - var grammar_post = []; - var key, src; + let grammar_pre = []; + let grammar_mid = []; + let ebnf_rules = []; + let bnf_rules = []; + let grammar_post = []; - var fmtprod = function fmtprod(rule, prodset) { - var backup = deepClone(prodset); + let fmtprod = function fmtprod(rule, prodset) { + let backup = deepClone(prodset); rule += prodset[0] ? prodset[0] : '%epsilon'; - var prec = null; - var lead = rule.split(/\r\n\|\n|\r/).pop(); + let prec = null; + let lead = rule.split(/\r\n\|\n|\r/).pop(); delete prodset[0]; if (prodset.length === 3 && typeof prodset[2] === 'object') { prec = '%prec ' + prodset[2].prec; if (lead.length < 12) { rule += makeIndent(12 - lead.length); - } + } rule += ' ' + prec; delete prodset[2].prec; if (isEmptyObj(prodset[2])) { delete prodset[2]; } - } - else if (prodset.length === 2 && typeof prodset[1] === 'object') { + } else if (prodset.length === 2 && typeof prodset[1] === 'object') { prec = '%prec ' + prodset[1].prec; if (lead.length < 12) { rule += makeIndent(12 - lead.length); - } + } rule += ' ' + prec; delete prodset[1].prec; @@ -28624,84 +28641,73 @@ function grammarPrinter(raw, options) { } } if (typeof prodset[1] === 'string') { - var action = prodset[1]; + let action = prodset[1]; if (lead.length < 12 - 1) { - rule += makeIndent(12 - lead.length) + indentAction('{ ' + action + ' }', 12); - } - else { - rule += '\n' + makeIndent(12) + indentAction('{ ' + action + ' }', 12); + rule += makeIndent(12 - lead.length) + indentAction('{ ' + action + ' }', 12); + } else { + rule += '\n' + makeIndent(12) + indentAction('{ ' + action + ' }', 12); } delete prodset[1]; } if (isEmptyArr(prodset)) { prodset.length = 0; - } - else { + } else { prodset = backup; } return rule; }; - var grammarfmt = function grammarfmt(src) { - var key; - var dst = []; + let grammarfmt = function grammarfmt(src) { + let dst = []; - for (key in src) { - var prodset = src[key]; - var rule; + for (let key in src) { + let prodset = src[key]; + let rule; console.log('format one rule:', { - key, + key, prodset }); if (typeof prodset === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; + rule = fmtprod(key + ' : ', [ prodset ]) + ';'; delete src[key]; - } - else if (prodset instanceof Array) { + } else if (prodset instanceof Array) { if (prodset.length === 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; + rule = fmtprod(key + ' : ', [ prodset ]) + ';'; delete src[key]; - } - else if (prodset[0] instanceof Array) { + } else if (prodset[0] instanceof Array) { rule = fmtprod(key + ' : ', prodset[0]); rule += '\n ;'; if (prodset[0].length === 0) { delete src[key]; } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - } - else if (prodset.length > 1) { + } else if (prodset.length > 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + '\n : ', [prodset[0]]); + rule = fmtprod(key + '\n : ', [ prodset[0] ]); delete prodset[0]; - } - else if (prodset[0] instanceof Array) { + } else if (prodset[0] instanceof Array) { rule = fmtprod(key + '\n : ', prodset[0]); if (prodset[0].length === 0) { delete prodset[0]; } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - for (var i = 1, len = prodset.length; i < len; i++) { + for (let i = 1, len = prodset.length; i < len; i++) { if (typeof prodset[i] === 'string') { - rule += fmtprod('\n | ', [prodset[i]]); + rule += fmtprod('\n | ', [ prodset[i] ]); delete prodset[i]; - } - else if (prodset[i] instanceof Array) { + } else if (prodset[i] instanceof Array) { rule += fmtprod('\n | ', prodset[i]); if (prodset[i].length === 0) { delete prodset[i]; } - } - else { + } else { rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[i]; } } @@ -28711,8 +28717,7 @@ function grammarPrinter(raw, options) { delete src[key]; } } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; } dst.push(rule); @@ -28721,46 +28726,52 @@ function grammarPrinter(raw, options) { return dst; }; - src = raw.ebnf; - if (src) { - ebnf_rules = grammarfmt(src); + { + let src = raw.ebnf; + if (src) { + ebnf_rules = grammarfmt(src); - if (isEmptyObj(src)) { - delete raw.ebnf; + if (isEmptyObj(src)) { + delete raw.ebnf; + } } } - src = raw.bnf; - //delete raw.bnf; - if (src) { - bnf_rules = grammarfmt(src); + { + let src = raw.bnf; + //delete raw.bnf; + if (src) { + bnf_rules = grammarfmt(src); - if (isEmptyObj(src)) { - delete raw.bnf; + if (isEmptyObj(src)) { + delete raw.bnf; + } } } - src = raw.unknownDecls; - delete raw.unknownDecls; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // unknown declarations: - `); + { + let src = raw.unknownDecls; + delete raw.unknownDecls; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // unknown declarations: + `); - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry.name; + let value = entry.value; - lex_pre.push('%' + key + ' ' + value); - } + lex_pre.push('%' + key + ' ' + value); + } - lex_pre.push(rmCommonWS$4` - // END of unknown declarations. - `); + lex_pre.push(rmCommonWS$4` + // END of unknown declarations. + `); + } } - //src = raw.lex; + //let src = raw.lex; //delete raw.lex; //if (src) { if (lex_out_str.trim() && options.showLexer) { @@ -28778,294 +28789,305 @@ function grammarPrinter(raw, options) { `); } - src = raw.options; - delete raw.options; - if (src && !isEmptyObj(src)) { - var a = []; - for (key in src) { - var value = src[key]; - switch (key) { - default: - if (value !== true) { - a.push('options', '%options ' + key + '=' + value); - } - else { - a.push('options', '%options ' + key); - } - break; + { + let src = raw.options; + delete raw.options; + if (src && !isEmptyObj(src)) { + let a = []; + for (let key in src) { + let value = src[key]; + switch (key) { + default: + if (value !== true) { + a.push('options', '%options ' + key + '=' + value); + } else { + a.push('options', '%options ' + key); + } + break; - case 'ebnf': - if (value) { - a.push(key, '%ebnf'); - } - break; + case 'ebnf': + if (value) { + a.push(key, '%ebnf'); + } + break; - case 'type': - if (value) { - a.push(key, '%parser-type ' + value); - } - break; + case 'type': + if (value) { + a.push(key, '%parser-type ' + value); + } + break; - case 'debug': - if (typeof value !== 'boolean') { - a.push(key, '%debug ' + value); - } - else if (value) { - a.push(key, '%debug'); + case 'debug': + if (typeof value !== 'boolean') { + a.push(key, '%debug ' + value); + } else if (value) { + a.push(key, '%debug'); + } + break; } - break; } - } - var type = null; - for (var i = 0, len = a.length; i < len; i += 2) { - var t = a[i]; - var line = a[i + 1]; - if (t !== type) { - type = t; - grammar_pre.push(''); + let type = null; + for (let i = 0, len = a.length; i < len; i += 2) { + let t = a[i]; + let line = a[i + 1]; + if (t !== type) { + type = t; + grammar_pre.push(''); + } + grammar_pre.push(line); } - grammar_pre.push(line); + grammar_pre.push(''); } - grammar_pre.push(''); } - src = raw.imports; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - - grammar_pre.push('%import ' + entry.name + ' ' + entry.path); - delete entry.name; - delete entry.path; - if (isEmptyObj(entry)) { - delete src[i]; + { + let src = raw.imports; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + + grammar_pre.push('%import ' + entry.name + ' ' + entry.path); + delete entry.name; + delete entry.path; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } + } + if (clean) { + delete raw.imports; } - else { - clean = false; - } - } - if (clean) { - delete raw.imports; } } - src = raw.moduleInit; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - - grammar_pre.push('%code ' + entry.qualifier + ' ' + entry.include); - delete entry.qualifier; - delete entry.include; - if (isEmptyObj(entry)) { - delete src[i]; + { + let src = raw.moduleInit; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + + grammar_pre.push('%code ' + entry.qualifier + ' ' + entry.include); + delete entry.qualifier; + delete entry.include; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } + } + if (clean) { + delete raw.moduleInit; } - else { - clean = false; - } - } - if (clean) { - delete raw.moduleInit; } } - src = raw.operators; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var tokens = entry[1]; - var line = '%' + entry[0] + ' '; - - for (var t = 0, tlen = tokens.length; t < tlen; t++) { - line += ' ' + tokens[t]; - } + { + let src = raw.operators; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let tokens = entry[1]; + let line = '%' + entry[0] + ' '; + + for (let t = 0, tlen = tokens.length; t < tlen; t++) { + line += ' ' + tokens[t]; + } - grammar_pre.push(line); + grammar_pre.push(line); - if (entry.length === 2) { - delete src[i]; + if (entry.length === 2) { + delete src[i]; + } else { + clean = false; + } } - else { - clean = false; + if (clean) { + delete raw.operators; } } - if (clean) { - delete raw.operators; - } } - src = raw.extra_tokens; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var line = '%token ' + entry.id; - - if (entry.type) { - line += ' <' + entry.type + '>'; - delete entry.type; - } - if (entry.value) { - line += ' ' + entry.value; - delete entry.value; - } - if (entry.description) { - line += ' ' + escapeString(entry.description); - delete entry.description; - } + { + let src = raw.extra_tokens; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let line = '%token ' + entry.id; + + if (entry.type) { + line += ' <' + entry.type + '>'; + delete entry.type; + } + if (entry.value) { + line += ' ' + entry.value; + delete entry.value; + } + if (entry.description) { + line += ' ' + escapeString(entry.description); + delete entry.description; + } - grammar_pre.push(line); + grammar_pre.push(line); - delete entry.id; - if (isEmptyObj(entry)) { - delete src[i]; + delete entry.id; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } } - else { - clean = false; + if (clean) { + delete raw.extra_tokens; } } - if (clean) { - delete raw.extra_tokens; - } } - src = raw.parseParams; - delete raw.parseParams; - if (src) { - grammar_pre.push('%parse-param ' + src.join(' ')); + { + let src = raw.parseParams; + delete raw.parseParams; + if (src) { + grammar_pre.push('%parse-param ' + src.join(' ')); + } } - src = raw.start; - delete raw.start; - if (src) { - grammar_pre.push('%start ' + src); + { + let src = raw.start; + delete raw.start; + if (src) { + grammar_pre.push('%start ' + src); + } } - src = raw.moduleInclude; - delete raw.moduleInclude; - if (src && src.trim()) { - grammar_post.push(indentAction(src.trim(), 0)); + { + let src = raw.moduleInclude; + delete raw.moduleInclude; + if (src && src.trim()) { + grammar_post.push(indentAction(src.trim(), 0)); + } } - src = raw.actionInclude; - delete raw.actionInclude; - if (src && src.trim()) { - grammar_mid.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + { + let src = raw.actionInclude; + delete raw.actionInclude; + if (src && src.trim()) { + grammar_mid.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + } } - var out = ''; + { + let out = ''; - if (!isEmptyObj(raw)) { - // dump the remainder as a comment: - var rem = JSON5__default['default'].stringify(raw, null, 2); - out += rmCommonWS$4` - /* - * Parser stuff that's unknown to the JISON prettyPrint service: - * - * ${rem.replace(/\*\//g, '*\\/')} - */ + if (!isEmptyObj(raw)) { + // dump the remainder as a comment: + let rem = JSON5__default['default'].stringify(raw, null, 2); + out += rmCommonWS$4` + /* + * Parser stuff that's unknown to the JISON prettyPrint service: + * + * ${rem.replace(/\*\//g, '*\\/')} + */ - `; - // delete raw; - } + `; + // delete raw; + } - if (!options.showParser) { - out += lex_out_str; - } - else { - out += grammar_pre.join('\n') + '\n\n'; - out += rmCommonWS$4` + if (!options.showParser) { + out += lex_out_str; + } else { + out += grammar_pre.join('\n') + '\n\n'; + out += rmCommonWS$4` - %% + %% - `; - if (grammar_mid.length > 0) { - out += grammar_mid.join('\n') + '\n\n'; - } - if (ebnf_rules.length > 0) { - if (bnf_rules.length > 0) { + `; + if (grammar_mid.length > 0) { + out += grammar_mid.join('\n') + '\n\n'; + } + if (ebnf_rules.length > 0) { + if (bnf_rules.length > 0) { // dump the original EBNF grammar as source and dump the BNF derivative as COMMENT: - var bnf_deriv = bnf_rules.join('\n\n'); - var a = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); + let bnf_deriv = bnf_rules.join('\n\n'); + let a = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - out += rmCommonWS$4` - // - // JISON says: - // - // This is a EBNF grammar. The resulting **BNF** grammar has been - // reproduced here for your convenience: - // - // ---------------------------- START --------------------------- - ${a.join('\n')} - // ---------------------------- END OF BNF grammar -------------- - // + out += rmCommonWS$4` + // + // JISON says: + // + // This is a EBNF grammar. The resulting **BNF** grammar has been + // reproduced here for your convenience: + // + // ---------------------------- START --------------------------- + ${a.join('\n')} + // ---------------------------- END OF BNF grammar -------------- + // - `; + `; + } + out += ebnf_rules.join('\n\n') + '\n\n'; + } else if (bnf_rules.length > 0) { + out += bnf_rules.join('\n\n') + '\n\n'; } - out += ebnf_rules.join('\n\n') + '\n\n'; - } - else if (bnf_rules.length > 0) { - out += bnf_rules.join('\n\n') + '\n\n'; - } - if (grammar_post.length > 0) { - out += rmCommonWS$4` + if (grammar_post.length > 0) { + out += rmCommonWS$4` - %% + %% - ` + grammar_post.join('\n') + '\n\n'; + ` + grammar_post.join('\n') + '\n\n'; + } } - } - if (options.format === 'json5') { - var a = out.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); + if (options.format === 'json5') { + let a = out.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - out = rmCommonWS$4` - // - // JISON says: - // - // The JISON ${options.showParser ? 'grammar' : 'lexer'} has been - // reproduced here for your convenience: - // - // ---------------------------- START --------------------------- - ${a.join('\n')} - // ---------------------------- END ----------------------------- - // + out = rmCommonWS$4` + // + // JISON says: + // + // The JISON ${options.showParser ? 'grammar' : 'lexer'} has been + // reproduced here for your convenience: + // + // ---------------------------- START --------------------------- + ${a.join('\n')} + // ---------------------------- END ----------------------------- + // - `; + `; - // process the original input once again: this time via JSON5 - raw = deepClone(originalInput); + // process the original input once again: this time via JSON5 + raw = deepClone(originalInput); - if (!options.showLexer) { - delete raw.lex; - out += JSON5__default['default'].stringify(raw, null, 2); - } - else if (!options.showParser) { - out += JSON5__default['default'].stringify(raw.lex, null, 2); + if (!options.showLexer) { + delete raw.lex; + out += JSON5__default['default'].stringify(raw, null, 2); + } else if (!options.showParser) { + out += JSON5__default['default'].stringify(raw.lex, null, 2); + } } - } - return out; + return out; + } } // Jison, an LR(0), SLR(1), LARL(1), LR(1) Parser Generator -var rmCommonWS$5 = helpers.rmCommonWS; -var mkIdentifier$4 = helpers.mkIdentifier; -var code_exec$2 = helpers.exec; +const rmCommonWS$5 = helpers.rmCommonWS; +const mkIdentifier$4 = helpers.mkIdentifier; +const code_exec$1 = helpers.exec; -var version$2 = '0.6.2-220'; +const version$2 = '0.7.0-220'; -var devDebug = 0; +let devDebug = 0; function chkBugger$3(src) { src = '' + src; @@ -29081,7 +29103,7 @@ function chkBugger$3(src) { // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE$3 = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -var Jison$1 = { +let Jison$1 = { version: version$2 }; @@ -29096,8 +29118,8 @@ const defaultJisonOptions = { compressTables: 2, // 0, 1, 2 outputDebugTables: false, noDefaultResolve: false, - defaultActionMode: ["classic", "merge"], // {classic, ast, none, skip}, {classic, ast, merge, none, skip} - testCompileActionCode: "parser:*,lexer:*", + defaultActionMode: [ 'classic', 'merge' ], // {classic, ast, none, skip}, {classic, ast, merge, none, skip} + testCompileActionCode: 'parser:*,lexer:*', noTryCatch: false, hasPartialLrUpgradeOnConflict: true, errorRecoveryTokenDiscardCount: 3, @@ -29155,7 +29177,7 @@ const defaultJisonOptions = { actionsUseYYSTACKPOINTER: false, actionsUseYYTEXT: false, hasErrorRecovery: false, - hasErrorReporting: false, + hasErrorReporting: false }; Jison$1.defaultJisonOptions = defaultJisonOptions; @@ -29176,25 +29198,25 @@ Jison$1.defaultJisonOptions = defaultJisonOptions; // Return a fresh set of options. /** @public */ function mkStdOptions$1(...args) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - //var args = Array.prototype.concat.apply([], args); + let opts = {}; + //let args = Array.prototype.concat.apply([], args); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(Jison$1.defaultJisonOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; - for (var p in o) { + for (let p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { o2[mkIdentifier$4(p)] = o[p]; } @@ -29226,7 +29248,7 @@ function mkStdOptions$1(...args) { } // fall through case 'string': - var a = String(o2.defaultActionMode).split(',').map(function (m) { + let a = String(o2.defaultActionMode).split(',').map(function (m) { return m.trim(); }); if (a.length === 1) { @@ -29290,7 +29312,7 @@ function mkStdOptions$1(...args) { } // now see if we have an overriding option here: - for (var p in o2) { + for (let p in o2) { if (h.call(o2, p)) { if (typeof o2[p] !== 'undefined') { opts[p] = o2[p]; @@ -29306,7 +29328,7 @@ function mkStdOptions$1(...args) { function prepExportStructures$1(options) { // set up the 'option' `exportAllTables` as a hash object for returning // all generated tables to the caller - var exportDest = options.exportAllTables; + let exportDest = options.exportAllTables; if (!exportDest || typeof exportDest !== 'object') { exportDest = { enabled: !!exportDest @@ -29318,7 +29340,7 @@ function prepExportStructures$1(options) { // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -29339,128 +29361,128 @@ function prepExportStructures$1(options) { // Otherwise return the *parsed* grammar and optional lexer specs as they have // been processed through EBNFParser and LEXParser respectively. function autodetectAndConvertToJSONformat$1(grammar, optionalLexerSection, options) { - var chk_g = null; - var chk_l = null; - var ex1, err; + let chk_g = null; + let chk_l = null; + let ex1, err; if (typeof grammar === 'string') { - if (options.json) { - try { - chk_g = JSON5__default['default'].parse(grammar); + if (options.json) { + try { + chk_g = JSON5__default['default'].parse(grammar); - // When JSON5-based parsing of the grammar succeeds, this implies the grammar is specified in `JSON mode` - // *OR* there's a JSON/JSON5 format error in the input: - } catch (e) { - ex1 = e; + // When JSON5-based parsing of the grammar succeeds, this implies the grammar is specified in `JSON mode` + // *OR* there's a JSON/JSON5 format error in the input: + } catch (e) { + ex1 = e; + } } - } - if (!chk_g) { - try { - chk_g = ebnfParser.parse(grammar); - } catch (e) { - if (options.json) { - // When both JSON5 and JISON input modes barf a hairball, assume the most important - // error is the JISON one (show that one first!), while it MAY be a JSON5 format - // error that triggered it (show that one last!). - // - // Also check for common JISON errors which are obviously never triggered by any - // odd JSON5 input format error: when we encounter such an error here, we don't - // confuse matters and forget about the JSON5 fail as it's irrelevant: - const commonErrors = [ - /does not compile/, - /you did not correctly separate trailing code/, - /You did not specify/, - /You cannot specify/, - /must be qualified/, - /%start/, - /%token/, - /%import/, - /%include/, - /%options/, - /%parse-params/, - /%parser-type/, - /%epsilon/, - /definition list error/, - /token list error/, - /declaration error/, - /should be followed/, - /should be separated/, - /an error in one or more of your lexer regex rules/, - /an error in your lexer epilogue/, - /unsupported definition type/, - ]; - var cmnerr = commonErrors.filter(function check(re) { - return e.message.match(re); - }); - if (cmnerr.length > 0) { - err = e; + if (!chk_g) { + try { + chk_g = ebnfParser.parse(grammar); + } catch (e) { + if (options.json) { + // When both JSON5 and JISON input modes barf a hairball, assume the most important + // error is the JISON one (show that one first!), while it MAY be a JSON5 format + // error that triggered it (show that one last!). + // + // Also check for common JISON errors which are obviously never triggered by any + // odd JSON5 input format error: when we encounter such an error here, we don't + // confuse matters and forget about the JSON5 fail as it's irrelevant: + const commonErrors = [ + /does not compile/, + /you did not correctly separate trailing code/, + /You did not specify/, + /You cannot specify/, + /must be qualified/, + /%start/, + /%token/, + /%import/, + /%include/, + /%options/, + /%parse-params/, + /%parser-type/, + /%epsilon/, + /definition list error/, + /token list error/, + /declaration error/, + /should be followed/, + /should be separated/, + /an error in one or more of your lexer regex rules/, + /an error in your lexer epilogue/, + /unsupported definition type/ + ]; + let cmnerr = commonErrors.filter(function check(re) { + return e.message.match(re); + }); + if (cmnerr.length > 0) { + err = e; + } else { + err = new Error('Could not parse jison grammar in JSON AUTODETECT mode:\nin JISON Mode we get Error: ' + e.message + '\nwhile JSON5 Mode produces Error: ' + ex1.message); + err.secondary_exception = e; + err.stack = ex1.stack; + } } else { - err = new Error('Could not parse jison grammar in JSON AUTODETECT mode:\nin JISON Mode we get Error: ' + e.message + '\nwhile JSON5 Mode produces Error: ' + ex1.message); - err.secondary_exception = e; - err.stack = ex1.stack; + err = new Error('Could not parse jison grammar\nError: ' + e.message); + err.stack = e.stack; } - } else { - err = new Error('Could not parse jison grammar\nError: ' + e.message); - err.stack = e.stack; + throw err; } - throw err; } - } - // Save time! Don't reparse the entire grammar *again* inside the code generators when that's not necessary: - // if (chk_g) { - // grammar = chk_g; - // } + // Save time! Don't reparse the entire grammar *again* inside the code generators when that's not necessary: + // if (chk_g) { + // grammar = chk_g; + // } } else { chk_g = grammar; } // Now the same treatment for the lexer: if (chk_g && optionalLexerSection) { - if (chk_g.lex) { - throw new Error('Cannot invoke with both a lexer section in the grammar input and a separate lexer input at the same time!'); - } + if (chk_g.lex) { + throw new Error('Cannot invoke with both a lexer section in the grammar input and a separate lexer input at the same time!'); + } - if (typeof optionalLexerSection === 'string') { - if (options.json) { - try { - chk_l = JSON5__default['default'].parse(optionalLexerSection); + if (typeof optionalLexerSection === 'string') { + if (options.json) { + try { + chk_l = JSON5__default['default'].parse(optionalLexerSection); - // When JSON5-based parsing of the lexer spec succeeds, this implies the lexer spec is specified in `JSON mode` - // *OR* there's a JSON/JSON5 format error in the input: - } catch (e) { - ex1 = e; - } - } - if (!chk_l) { - // // WARNING: the lexer may receive options specified in the **grammar spec file**, - // // hence we should mix the options to ensure the lexParser always - // // receives the full set! - // // - // // make sure all options are 'standardized' before we go and mix them together: - // options = mkStdOptions(grammar.options, options); - try { - chk_l = lexParser.parse(optionalLexerSection); - } catch (e) { - if (options.json) { - err = new Error('Could not parse lexer spec in JSON AUTODETECT mode\nError: ' + ex1.message + ' (' + e.message + ')'); - err.secondary_exception = e; - err.stack = ex1.stack; - } else { - err = new Error('Could not parse lexer spec\nError: ' + e.message); - err.stack = e.stack; - } - throw err; - } + // When JSON5-based parsing of the lexer spec succeeds, this implies the lexer spec is specified in `JSON mode` + // *OR* there's a JSON/JSON5 format error in the input: + } catch (e) { + ex1 = e; + } + } + if (!chk_l) { + // // WARNING: the lexer may receive options specified in the **grammar spec file**, + // // hence we should mix the options to ensure the lexParser always + // // receives the full set! + // // + // // make sure all options are 'standardized' before we go and mix them together: + // options = mkStdOptions(grammar.options, options); + try { + chk_l = lexParser.parse(optionalLexerSection); + } catch (e) { + if (options.json) { + err = new Error('Could not parse lexer spec in JSON AUTODETECT mode\nError: ' + ex1.message + ' (' + e.message + ')'); + err.secondary_exception = e; + err.stack = ex1.stack; + } else { + err = new Error('Could not parse lexer spec\nError: ' + e.message); + err.stack = e.stack; + } + throw err; + } + } + } else { + chk_l = optionalLexerSection; } - } else { - chk_l = optionalLexerSection; - } - // Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: - if (chk_l) { - chk_g.lex = chk_l; - } + // Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: + if (chk_l) { + chk_g.lex = chk_l; + } } return chk_g; @@ -29477,7 +29499,7 @@ if (typeof console !== 'undefined' && console.log) { // wrap console.log to prevent 'Illegal Invocation' exceptions when Jison.print() is used, e.g. // in the web tryout pages where this code is employed. Jison$1.print = function console_log(/* ... */) { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); args.unshift(''); // prevent `%.` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args console.log.apply(console, args); }; @@ -29498,7 +29520,7 @@ if (typeof console !== 'undefined' && console.log) { Jison$1.Lexer = RegExpLexer; Jison$1.ebnfParser = ebnfParser; Jison$1.lexParser = lexParser; -Jison$1.codeExec = code_exec$2; +Jison$1.codeExec = code_exec$1; Jison$1.XRegExp = XRegExp__default['default']; Jison$1.recast = recast__default['default']; Jison$1.astUtils = astUtils__default['default']; @@ -29513,7 +29535,7 @@ function each(obj, func) { if (typeof obj.forEach === 'function') { obj.forEach(func); } else { - var p; + let p; for (p in obj) { if (obj.hasOwnProperty(p)) { func.call(obj, obj[p], p, obj); @@ -29543,10 +29565,10 @@ function union(a, b) { // site for this jscore grammar as the naive scan consistently // outperformed the old smarter hash-object code for smaller // thresholds (10, 20, 32, 42!) - var k, len; + let k, len; if (a.length > 52) { - var ar = {}; + let ar = {}; for (k = 0, len = a.length; k < len; k++) { ar[a[k]] = true; } @@ -29556,7 +29578,7 @@ function union(a, b) { } } } else { - var bn = []; + let bn = []; for (k = 0, len = b.length; k < len; k++) { if (a.indexOf(b[k]) < 0) { bn.push(b[k]); @@ -29567,17 +29589,17 @@ function union(a, b) { return a; } -var Nonterminal = typal.construct({ +let Nonterminal = typal.construct({ constructor: function Nonterminal(symbol) { this.symbol = symbol; - this.productions = new Set(); + this.productions = new Set$1(); this.first = []; this.follows = []; this.nullable = false; }, toString: function Nonterminal_toString() { - var str = this.symbol; - var attr_str = []; + let str = this.symbol; + let attr_str = []; if (this.nullable) { attr_str.push('nullable'); @@ -29594,7 +29616,7 @@ var Nonterminal = typal.construct({ } }); -var Production = typal.construct({ +let Production = typal.construct({ constructor: function Production(symbol, handle, id, handle_aliases, handle_action) { this.symbol = symbol; this.handle = handle; @@ -29608,9 +29630,9 @@ var Production = typal.construct({ this.reachable = false; }, toString: function Production_toString() { - var str = this.symbol; + let str = this.symbol; - var attr_str = []; + let attr_str = []; if (this.nullable) { attr_str.push('~'); @@ -29630,9 +29652,9 @@ var Production = typal.construct({ return str; }, describe: function Production_describe() { - var str = this.symbol; + let str = this.symbol; - var attr_str = []; + let attr_str = []; if (this.nullable) { attr_str.push('nullable'); @@ -29653,7 +29675,7 @@ var Production = typal.construct({ -var generator = typal.beget(); +let generator = typal.beget(); // `optionalLexerSection` is an optional {String} argument, specifying the lexer rules. // May only be specified when the specified `grammar` also is a yet-unparsed @@ -29728,11 +29750,11 @@ var generator = typal.beget(); generator.constructor = function Jison_Generator(grammar, optionalLexerSection, options) { // pick the correct argument for the `options` for this call: if (!options && optionalLexerSection && typeof optionalLexerSection !== 'string') { - options = optionalLexerSection; - optionalLexerSection = null; + options = optionalLexerSection; + optionalLexerSection = null; } // and standardize it: - var preliminary_options = mkStdOptions$1(options); + let preliminary_options = mkStdOptions$1(options); grammar = autodetectAndConvertToJSONformat$1(grammar, optionalLexerSection, preliminary_options); @@ -29780,7 +29802,7 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, // } // calculate the input path; if none is specified, it's the present working directory - var inpath = options.file || options.outfile || './dummy'; + let inpath = options.file || options.outfile || './dummy'; inpath = path__default['default'].normalize(inpath); options.inputPath = path__default['default'].dirname(inpath); options.inputFilename = path__default['default'].basename(inpath); @@ -29811,7 +29833,7 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, this.processGrammar(grammar); if (grammar.lex) { - var lexer_options = { + let lexer_options = { // include the knowledge about which parser/lexer // features will actually be *used* by the environment: // @@ -29866,7 +29888,7 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, exportAST: this.options.exportAST, prettyCfg: this.options.prettyCfg, pre_lex: this.options.pre_lex, - post_lex: this.options.post_lex, + post_lex: this.options.post_lex }; this.lexer = new RegExpLexer(grammar.lex, null, this.terminals_, lexer_options); @@ -29874,10 +29896,10 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, }; generator.processGrammar = function processGrammarDef(grammar) { - var bnf = grammar.bnf, - tokens = grammar.tokens, - nonterminals = this.nonterminals = {}, - productions = this.productions; + let bnf = grammar.bnf; + let tokens = grammar.tokens; + let nonterminals = this.nonterminals = {}; + let productions = this.productions; if (!grammar.bnf && grammar.ebnf) { bnf = grammar.bnf = ebnfParser.transform(grammar.ebnf); @@ -29893,18 +29915,18 @@ generator.processGrammar = function processGrammarDef(grammar) { // did the grammar user also provide a predefined set of symbols to be (re)used with this grammar? // (This is used when you want to generate multiple lexers and parsers which share a common symbol set // so as to make the parsers and lexers mutually interchangeable.) - var predefined_symbols = null; + let predefined_symbols = null; if (grammar.imports) { - var symbols_import = grammar.imports.find(function (el, idx) { + let symbols_import = grammar.imports.find(function (el, idx) { if (el.name === 'symbols') { return el; } return false; }); if (symbols_import) { - var filepath = path__default['default'].resolve(symbols_import.path); + let filepath = path__default['default'].resolve(symbols_import.path); - var source = fs__default['default'].readFileSync(filepath, 'utf8'); + let source = fs__default['default'].readFileSync(filepath, 'utf8'); // It's either a JSON file or a JISON generated output file: // // symbols_: { @@ -29914,7 +29936,7 @@ generator.processGrammar = function processGrammarDef(grammar) { predefined_symbols = JSON5__default['default'].parse(source); } catch (ex) { try { - var m = /[\r\n]\s*symbols_:\s*(\{[\s\S]*?\}),\s*[\r\n]/.exec(source); + let m = /[\r\n]\s*symbols_:\s*(\{[\s\S]*?\}),\s*[\r\n]/.exec(source); if (m && m[1]) { source = m[1]; predefined_symbols = JSON5__default['default'].parse(source); @@ -29929,18 +29951,18 @@ generator.processGrammar = function processGrammarDef(grammar) { } // Make sure all predefined symbols are unique and *numeric* and do not include predefined tokens JISON already defines to a fixed ID on its own: - delete predefined_symbols['$accept']; - delete predefined_symbols['$end']; - delete predefined_symbols['error']; - delete predefined_symbols['$eof']; - delete predefined_symbols['EOF']; + delete predefined_symbols.$accept; + delete predefined_symbols.$end; + delete predefined_symbols.error; + delete predefined_symbols.$eof; + delete predefined_symbols.EOF; - var symdef_uniq_check = {}; + let symdef_uniq_check = {}; // Only these symbols are allowed to have the values 1 or 2: symdef_uniq_check[1] = 'EOF'; symdef_uniq_check[2] = 'error'; Object.keys(predefined_symbols).forEach(function cvt_symbol_id_to_numeric(sym) { - var v = predefined_symbols[sym]; + let v = predefined_symbols[sym]; // Symbol value may be defined as boolean TRUE, in which case we let JISON pick the value for us: if (v === true) return; @@ -29948,17 +29970,17 @@ generator.processGrammar = function processGrammarDef(grammar) { // Symbol value may be defined as a one-character string: if (typeof v !== 'number') { if (typeof v !== 'string' || v.length !== 1) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a non-numeric symbol ID value must be a single-character string.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a non-numeric symbol ID value must be a single-character string."); } v = v.charCodeAt(0); } - v = v | 0; + v |= 0; if (!v || v < 0) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a symbol ID value must be an integer value, 3 or greater.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a symbol ID value must be an integer value, 3 or greater."); } if (symdef_uniq_check[v]) { if (symdef_uniq_check[v] !== sym) { - throw new Error('Error: `%import symbols `: symbol table contains duplicate ID values for keys \'' + sym + '\' and \'' + symdef_uniq_check[v] + '\''); + throw new Error("Error: `%import symbols `: symbol table contains duplicate ID values for keys '" + sym + "' and '" + symdef_uniq_check[v] + "'"); } } symdef_uniq_check[v] = sym; @@ -29967,15 +29989,15 @@ generator.processGrammar = function processGrammarDef(grammar) { } } - var symbols = this.symbols = []; + let symbols = this.symbols = []; // calculate precedence of operators - var operators = this.operators = processOperators(grammar.operators); + let operators = this.operators = processOperators(grammar.operators); // build productions from CFG and calculate the symbol sets (terminals and nonterminals) and their name-to-ID mappings this.buildProductions(bnf, productions, nonterminals, symbols, operators, predefined_symbols, grammar.extra_tokens); if (tokens) { - var termset = this.terminals.filter(function (t) { + let termset = this.terminals.filter(function (t) { switch (t) { case 'EOF': case 'error': @@ -29987,7 +30009,7 @@ generator.processGrammar = function processGrammarDef(grammar) { return true; } }); - var diffset = termset.filter(function (t) { + let diffset = termset.filter(function (t) { return tokens.indexOf(t) === -1; }); diffset = diffset.concat(tokens.filter(function (t) { @@ -30044,7 +30066,7 @@ generator.augmentGrammar = function augmentGrammar(grammar) { // return true; // the default parse result if the rule actions don't produce anything // %} // - var acceptProduction = new Production('$accept', [this.startSymbol, '$end'], 0); + let acceptProduction = new Production('$accept', [ this.startSymbol, '$end' ], 0); this.productions.unshift(acceptProduction); // prepend parser tokens // moved to generator.buildProductions() @@ -30063,14 +30085,13 @@ generator.augmentGrammar = function augmentGrammar(grammar) { // Mark unused productions generator.signalUnusedProductions = function () { - var mark = {}; + let mark = {}; - var productions = this.productions; - var nonterminals = this.nonterminals; - var i, len, nt, sym; + let productions = this.productions; + let nonterminals = this.nonterminals; - for (i = 0, len = nonterminals.length; i < len; i++) { - nt = nonterminals[i]; + for (let i = 0, len = nonterminals.length; i < len; i++) { + let nt = nonterminals[i]; assert__default['default'](nt.symbol); mark[nt.symbol] = false; } @@ -30081,15 +30102,15 @@ generator.signalUnusedProductions = function () { assert__default['default'](nt.symbol); mark[nt.symbol] = true; - var prods = nt.productions; + let prods = nt.productions; assert__default['default'](prods); prods.forEach(function (p) { assert__default['default'](p.symbol === nt.symbol); assert__default['default'](p.handle); - var rhs = p.handle; + let rhs = p.handle; - for (var j = 0, len = rhs.length; j < len; j++) { - var sym = rhs[j]; + for (let j = 0, len = rhs.length; j < len; j++) { + let sym = rhs[j]; assert__default['default'](!sym ? !nonterminals[sym] : true); if (nonterminals[sym] && !mark[sym]) { traverseGrammar(nonterminals[sym]); @@ -30098,15 +30119,15 @@ generator.signalUnusedProductions = function () { }); } - traverseGrammar(nonterminals['$accept' /* this.startSymbol */ ]); + traverseGrammar(nonterminals['$accept' /* this.startSymbol */]); // now any production which is not yet marked is *unused*: - for (sym in mark) { - nt = nonterminals[sym]; + for (let sym in mark) { + let nt = nonterminals[sym]; assert__default['default'](nt); - var prods = nt.productions; + let prods = nt.productions; assert__default['default'](prods); - var in_use = mark[sym]; + let in_use = mark[sym]; prods.forEach(function (p) { assert__default['default'](p); if (in_use) { @@ -30135,8 +30156,8 @@ generator.signalUnusedProductions = function () { // set precedence and associativity of operators function processOperators(ops) { if (!ops) return {}; - var operators = {}; - for (var i = 0, k, prec; (prec = ops[i]); i++) { + let operators = {}; + for (let i = 0, k, prec; (prec = ops[i]); i++) { for (k = 1; k < prec.length; k++) { operators[prec[k]] = { precedence: i + 1, @@ -30151,8 +30172,8 @@ function processOperators(ops) { // // Note that the first line doesn't count as the chunk is very probably trimmed! function reindentCodeBlock(action, indent_level) { - var width = 0; - var lines = action + let width = 0; + let lines = action .trim() .split('\n') // measure the indent: @@ -30169,7 +30190,7 @@ function reindentCodeBlock(action, indent_level) { return s.replace(/\t/g, ' '); }); - var m = /^[ ]+/.exec(line); + let m = /^[ ]+/.exec(line); if (m) { width = Math.min(m[0].length, width); } @@ -30180,8 +30201,8 @@ function reindentCodeBlock(action, indent_level) { .map(function checkIndentation(line, idx) { line = line .replace(/^[ ]*/, function adjustIndent(s) { - var l = Math.max(s.length - width, 0) + indent_level; - var shift = (new Array(l + 1)).join(' '); + let l = Math.max(s.length - width, 0) + indent_level; + let shift = (new Array(l + 1)).join(' '); return shift; }); return line; @@ -30192,21 +30213,21 @@ function reindentCodeBlock(action, indent_level) { generator.buildProductions = function buildProductions(bnf, productions, nonterminals, symbols, operators, predefined_symbols, descriptions) { - var self = this; - var prods, symbol, symId; - var productions_ = []; - var symbols_ = {}; - var descriptions_ = {}; - var usedSymbolIds = [/* $accept = 0 */ true, /* $end = 1 */ true, /* error = 2 */ true]; - var usedSymbolIdsLowIndex = 3; + let self = this; + let prods, symId; + let productions_ = []; + let symbols_ = {}; + let descriptions_ = {}; + let usedSymbolIds = [/* $accept = 0 */ true, /* $end = 1 */ true, /* error = 2 */ true ]; + let usedSymbolIdsLowIndex = 3; // set up the required symbols `$accept` and `$end` (a.k.a. EOF) and make sure they occupy the expected slots: this.EOF = '$end'; symbols_.$accept = 0; symbols_[this.EOF] = 1; - symbols_['$eof'] = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! - symbols_['EOF'] = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.$eof = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.EOF = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! symbols[0] = '$accept'; symbols[1] = this.EOF; @@ -30217,7 +30238,7 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm symbols[2] = 'error'; if (predefined_symbols) { - for (symbol in predefined_symbols) { + for (let symbol in predefined_symbols) { symId = predefined_symbols[symbol]; if (symId === true) { // add symbol to queue which must be assigned a value by JISON; after all the other predefined symbols have been processed. @@ -30240,7 +30261,7 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm // preferably assign readable ASCII-range token IDs to tokens added from the predefined list // but only when maximum table compression isn't demanded: usedSymbolIdsLowIndex = ((this.options.compressTables | 0) < 2 ? 32 : 3); - for (symbol in predefined_symbols) { + for (let symbol in predefined_symbols) { symId = predefined_symbols[symbol]; addSymbol(symbol); } @@ -30260,11 +30281,11 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm } - var hasErrorRecovery = false; // has error recovery + let hasErrorRecovery = false; // has error recovery // Produce the next available unique symbolID: function getNextSymbolId() { - for (var i = usedSymbolIdsLowIndex; ; i++) { + for (let i = usedSymbolIdsLowIndex; ; i++) { if (!usedSymbolIds[i]) { usedSymbolIds[i] = true; usedSymbolIdsLowIndex = i + 1; @@ -30275,7 +30296,7 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm function addSymbol(s) { if (s && !symbols_[s]) { - var i; + let i; // assign the Unicode codepoint index to single-character symbols, // but only when maximum table compression isn't demanded: @@ -30299,46 +30320,45 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm // `this` is options object with `maxTokenLength` option to guide us which literal tokens we want to process: function collectLiteralTokensInProduction(handle) { - var rhs, i, sym; + let rhs; - try{ - if (devDebug) ; + try { + if (devDebug) ; - var maxlen = this.maxTokenLength || Infinity; + let maxlen = this.maxTokenLength || Infinity; - if (handle.constructor === Array) { - var rhs_i; - rhs = (typeof handle[0] === 'string') ? - splitStringIntoSymbols(handle[0]) : - handle[0].slice(0); + if (handle.constructor === Array) { + rhs = (typeof handle[0] === 'string') ? + splitStringIntoSymbols(handle[0]) : + handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; - // check for aliased names, e.g., id[alias] and strip them - rhs_i = sym.match(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]$`)); - if (rhs_i) { - sym = sym.substr(0, sym.length - rhs_i[0].length); - } + for (let i = 0; i < rhs.length; i++) { + let sym = rhs[i]; + // check for aliased names, e.g., id[alias] and strip them + let rhs_i = sym.match(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]$`)); + if (rhs_i) { + sym = sym.substr(0, sym.length - rhs_i[0].length); + } - if (!bnf[sym] && sym.length <= maxlen) { - addSymbol(sym); + if (!bnf[sym] && sym.length <= maxlen) { + addSymbol(sym); + } } - } - } else { - // no action -> don't care about aliases; strip them. - handle = handle.replace(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); - rhs = splitStringIntoSymbols(handle); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; - if (!bnf[sym] && sym.length <= maxlen) { - addSymbol(sym); + } else { + // no action -> don't care about aliases; strip them. + handle = handle.replace(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); + rhs = splitStringIntoSymbols(handle); + for (let i = 0; i < rhs.length; i++) { + let sym = rhs[i]; + if (!bnf[sym] && sym.length <= maxlen) { + addSymbol(sym); + } } } + } catch (ex) { + console.error(ex, '\ncollectLiteralTokensInProduction: ', this.symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { rhs }); + throw ex; } - }catch (ex) { -console.error(ex, '\ncollectLiteralTokensInProduction: ', symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { i, sym, rhs }); -throw ex; - } } // Before we go process the grammar for real, we collect the 'literal' non-terminals and add them to the symbol table @@ -30346,8 +30366,8 @@ throw ex; // which helps debugging/diagnosis of generated grammars. // (This is why previously we had set `usedSymbolIdsLowIndex` to 127 instead of 3!) - var prodsLUT = {}; - for (symbol in bnf) { + let prodsLUT = {}; + for (let symbol in bnf) { if (!bnf.hasOwnProperty(symbol)) continue; if (typeof bnf[symbol] === 'string') { @@ -30360,21 +30380,23 @@ throw ex; } // First we collect all single-character literal tokens: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: 1 + maxTokenLength: 1, + symbol }); } // Next we collect all other literal tokens: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: Infinity + maxTokenLength: Infinity, + symbol }); } @@ -30383,7 +30405,7 @@ throw ex; // for each of those: nonterminals should all have IDs assigned before they // should be processed as part of a *production* rule, where these MAY be // referenced: - for (symbol in bnf) { + for (let symbol in bnf) { if (!bnf.hasOwnProperty(symbol)) continue; addSymbol(symbol); @@ -30392,15 +30414,15 @@ throw ex; // now that we have collected all nonterminals in our symbol table, it's finally // time to process the productions: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; - prods.forEach(buildProduction); + prods.forEach(buildProduction, { symbol }); } - var terms = [], - terms_ = {}; + let terms = []; + let terms_ = {}; each(symbols_, function (id, sym) { // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number @@ -30416,7 +30438,7 @@ throw ex; // fix error recovery related options now that we know whether we actually have any recovery // rules at all: if (!this.hasErrorRecovery) { - var chk_er_opt = function check_error_recovery_option(opt, label) { + let chk_er_opt = function check_error_recovery_option(opt, label) { if (self.options[opt]) { self.options[opt] = false; self.warn('The grammar does not have any error recovery rules, so using the ' + label + ' is rather useless.'); @@ -30428,9 +30450,9 @@ throw ex; // Hmmmm... why would lexer errors need to be NON-recoverable when there's no ERROR rules in the GRAMMAR?! chk_er_opt('lexerErrorsAreRecoverable', 'lexer-errors-are-recoverable feature/option'); - chk_er_opt('parseActionsUseYYRECOVERING', 'YYRECOVERING macro/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYERROK', 'yyerrok() function/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYCLEARIN', 'yyclearin() function/API in grammar rules\' action code'); + chk_er_opt('parseActionsUseYYRECOVERING', "YYRECOVERING macro/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYERROK', "yyerrok() function/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYCLEARIN', "yyclearin() function/API in grammar rules' action code"); } this.terminals = terms; @@ -30449,8 +30471,8 @@ throw ex; function splitStringIntoSymbols(rhs) { // when there's no literal tokens in there, we can fast-track this baby: rhs = rhs.trim(); - var pos1 = rhs.indexOf("'"); - var pos2 = rhs.indexOf('"'); + let pos1 = rhs.indexOf("'"); + let pos2 = rhs.indexOf('"'); if (pos1 < 0 && pos2 < 0) { return rhs.split(' '); } @@ -30458,10 +30480,10 @@ throw ex; // // rhs has at least one literal: we will need to parse the rhs into tokens // with a little more effort now. - var tokens = []; + let tokens = []; while (pos1 >= 0 || pos2 >= 0) { - var pos = pos1; - var marker = "'"; + let pos = pos1; + let marker = "'"; if (pos < 0) { assert__default['default'](pos2 >= 0); pos = pos2; @@ -30470,7 +30492,7 @@ throw ex; pos = pos2; marker = '"'; } - var ls = rhs.substr(0, pos).trim(); + let ls = rhs.substr(0, pos).trim(); if (ls.length > 0) { tokens.push.apply(tokens, ls.split(' ')); } @@ -30479,7 +30501,7 @@ throw ex; // // Edge case: token MAY include the ESCAPED MARKER... or other escapes! // Hence we need to skip over ALL escapes inside the token! - var pos3 = rhs.indexOf('\\'); + let pos3 = rhs.indexOf('\\'); pos = rhs.indexOf(marker); ls = ''; while (pos3 >= 0 && pos3 < pos) { @@ -30494,7 +30516,7 @@ throw ex; ls += rhs.substr(0, pos); // check for aliased literals, e.g., `'>'[gt]` and keep it and the alias together rhs = rhs.substr(pos + 1); - var alias = rhs.match(new XRegExp__default['default'](`^\\[${ID_REGEX_BASE$3}\\]`)); + let alias = rhs.match(new XRegExp__default['default'](`^\\[${ID_REGEX_BASE$3}\\]`)); if (alias) { ls += alias[0]; rhs = rhs.substr(alias[0].length); @@ -30514,22 +30536,21 @@ throw ex; return tokens; } + // options object { symbol } is `this` for this functon/callback: function buildProduction(handle) { - var r, rhs, i, - precedence_override, - aliased = [], - action = null; + let rhs; + let precedence_override = null; + let aliased = []; + let action = null; if (handle.constructor === Array) { - var rhs_i; - rhs = (typeof handle[0] === 'string') ? - splitStringIntoSymbols(handle[0]) : - handle[0].slice(0); + splitStringIntoSymbols(handle[0]) : + handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // check for aliased names, e.g., id[alias] and strip them - rhs_i = rhs[i].match(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]$`)); + let rhs_i = rhs[i].match(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]$`)); if (rhs_i) { rhs[i] = rhs[i].substr(0, rhs[i].length - rhs_i[0].length); rhs_i = rhs_i[0].substr(1, rhs_i[0].length - 2); @@ -30571,7 +30592,7 @@ throw ex; // no action -> don't care about aliases; strip them. handle = handle.replace(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { if (rhs[i] === 'error') { hasErrorRecovery = true; } @@ -30581,35 +30602,33 @@ throw ex; } } - r = new Production(symbol, rhs, productions.length + 1, aliased, action); + let r = new Production(this.symbol, rhs, productions.length + 1, aliased, action); // set precedence assert__default['default'](r.precedence === 0); if (precedence_override) { r.precedence = precedence_override.spec.precedence; - } - else { - var prec_symbols = []; - var winning_symbol; + } else { + let prec_symbols = []; + let winning_symbol; - for (i = r.handle.length - 1; i >= 0; i--) { + for (let i = r.handle.length - 1; i >= 0; i--) { if (!(r.handle[i] in nonterminals) && r.handle[i] in operators) { - var old_prec = r.precedence; - var new_prec = operators[r.handle[i]].precedence; + let old_prec = r.precedence; + let new_prec = operators[r.handle[i]].precedence; if (old_prec !== 0 && old_prec !== new_prec) { prec_symbols.push(r.handle[i]); - // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], symbol, handle[0]); + // 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[i]; - } - else { + } else { // keep previously set precedence: new_prec = old_prec; } } else if (old_prec === 0) { prec_symbols.push(r.handle[i]); winning_symbol = r.handle[i]; - // Jison.print('precedence set first time: ', old_prec, r.handle[i], symbol, handle[0]); + // Jison.print('precedence set first time: ', old_prec, r.handle[i], this.symbol, handle[0]); } r.precedence = new_prec; } @@ -30617,14 +30636,14 @@ throw ex; if (prec_symbols.length > 1) { if (self.DEBUG || 1) { - self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); + self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + this.symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); } } } productions.push(r); - productions_.push([symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length]); - nonterminals[symbol].productions.push(r); + productions_.push([ symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length ]); + nonterminals[this.symbol].productions.push(r); } }; @@ -30729,8 +30748,9 @@ function preprocessActionCode(s) { // with our pants down in constructs like // `'"' + $$ + '"'` vs. `"'" + $$ + "'"` - var dqpos, sqpos, ccmtpos, cppcmtpos, first = -1; - for (var c = 0;; c++) { + let dqpos, sqpos, ccmtpos, cppcmtpos; + let first = -1; + for (let c = 0; ; c++) { first++; dqpos = s.indexOf('"', first); sqpos = s.indexOf("'", first); @@ -30774,11 +30794,11 @@ function postprocessActionCode(s) { .replace(/\x01\x82/g, '$') .replace(/\x01\x83/g, '@') // and revert the string and regex markers: - .replace(/\x01\x87/g, '\'') + .replace(/\x01\x87/g, "'") .replace(/\x01\x88/g, '\"') .replace(/\x01\x89/g, '##') .replace(/\x01\x90/g, '\\\\') - .replace(/\x01\x91/g, '\\\'') + .replace(/\x01\x91/g, "\\'") .replace(/\x01\x92/g, '\\\"') .replace(/\x01\x93/g, '\\\/') .replace(/\x01\x94/g, 'YYABORT') @@ -30811,7 +30831,7 @@ function mkHashIndex(s) { } function analyzeFeatureUsage(sourcecode, feature, threshold) { - var found = sourcecode.match(feature); + let found = sourcecode.match(feature); return !!(found && found.length > threshold); } @@ -30819,7 +30839,7 @@ function analyzeFeatureUsage(sourcecode, feature, threshold) { function mkParserFeatureHash(self) { assert__default['default'](self.options.exportAllTables); // check that this function isn't called too early in the process or the hash will be bogus assert__default['default'](self.options.exportSourceCode); - var h = [ + let h = [ self.actionsAreAllDefault, self.actionsUseLocationAssignment, self.actionsUseLocationTracking, @@ -30868,7 +30888,7 @@ function mkParserFeatureHash(self) { self.options.prettyCfg, '======================================', self.performAction, - '======================================', + '======================================' ]; return JSON.stringify(h); } @@ -30883,23 +30903,23 @@ generator.buildProductionActions = function buildProductionActions() { this.productions_ = productions_; assert(this.productions === productions); */ - var productions = this.productions, - nonterminals = this.nonterminals, - symbols = this.symbols, - operators = this.operators, - self = this; + let productions = this.productions; + let nonterminals = this.nonterminals; + let symbols = this.symbols; + let operators = this.operators; + let self = this; // As a SIDE EFFECT of this call, we also fixup // the other code chunks specified in the grammar file: // // Replace direct symbol references, e.g. #NUMBER# when there's a `%token NUMBER` for your grammar. // We allow these tokens to be referenced anywhere in your code as #TOKEN#. - var moduleInclude = preprocessActionCode(this.moduleInclude) + let moduleInclude = preprocessActionCode(this.moduleInclude) .replace(new XRegExp__default['default'](`#(${ID_REGEX_BASE$3})#`, 'g'), function (_, sym) { return provideSymbolAsSourcecode(sym); }); // and COPY the `moduleInit` array, after preprocessing the individual COPIES: - var moduleInit = this.moduleInit.map(function (chunk) { + let moduleInit = this.moduleInit.map(function (chunk) { assert__default['default'](chunk.qualifier); assert__default['default'](typeof chunk.include === 'string'); return { @@ -30915,39 +30935,38 @@ generator.buildProductionActions = function buildProductionActions() { // We potentially need multiple (2+) rounds to produce the correct actions // as userland action code determines whether the default actions should // include location tracking or not: - var gen_level = 0; - var prev_gen_hash = 'n'; - var gen_hash = 'y'; + let gen_level = 0; + let prev_gen_hash = 'n'; + let gen_hash = 'y'; this.performAction = null; while (gen_hash !== prev_gen_hash) { - var preludeCode = preprocessActionCode(this.actionInclude || ''); - var actions = [` + let preludeCode = preprocessActionCode(this.actionInclude || ''); + let actions = [ ` /* this == yyval */ // the JS engine itself can go and remove these statements when \`yy\` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; ${preludeCode} switch (yystate) {` ]; - var actionGroups = {}; // used to combine identical actions into single instances: no use duplicating action code needlessly - var actionGroupValue = {}; // stores the unaltered, expanded, user-defined action code for each action group. - var stateHasAction = []; // marks which state IDs have an action, either user-specified or default. - var symbol; + let actionGroups = {}; // used to combine identical actions into single instances: no use duplicating action code needlessly + let actionGroupValue = {}; // stores the unaltered, expanded, user-defined action code for each action group. + let stateHasAction = []; // marks which state IDs have an action, either user-specified or default. // and now go and process the entire grammar: - productions.forEach(buildProductionAction); + productions.forEach(buildProductionAction, { actionGroups, actionGroupValue, stateHasAction }); - for (var hash in actionGroups) { + for (let hash in actionGroups) { actions.push([].concat.apply([], actionGroups[hash]).join('\n') + '\n\n' + actionGroupValue[hash] + '\n break;\n'); } // add the special error recovery reduction action: if (this.hasErrorRecovery) { - var userland_err_recov_redux_code = ''; + let userland_err_recov_redux_code = ''; actions.push(`case YY_ERROR_RECOVERY_COMBINE_ID: // === NO_ACTION[1] :: ensures that anyone (but us) using this new state will fail dramatically! // error recovery reduction action (action generated by jison, @@ -30960,16 +30979,16 @@ generator.buildProductionActions = function buildProductionActions() { } // check if all IDs have an action now: - var missingActions = []; - for (var idx = 0, len = stateHasAction.length; idx < len; idx++) { + let missingActions = []; + for (let idx = 0, len = stateHasAction.length; idx < len; idx++) { if (!stateHasAction[idx]) { missingActions.push(idx); } } - this.missingActions = missingActions; + this.missingActions = missingActions; if (missingActions.length) { if ( this.DEBUG) { - this.warn("WARNING: missing actions for states: ", missingActions); + this.warn('WARNING: missing actions for states: ', missingActions); } actions.push(`default: @@ -30977,7 +30996,7 @@ generator.buildProductionActions = function buildProductionActions() { // When we hit this entry, it's always a non-recoverable issue as this is a severe internal parser state failure: function __b0rk_on_internal_failure(str) { - var hash = yyparser.constructParseErrorInfo(str, null, null, false); + let hash = yyparser.constructParseErrorInfo(str, null, null, false); return yyparser.parseError(str, hash, yyparser.JisonParserError); } @@ -30987,7 +31006,7 @@ generator.buildProductionActions = function buildProductionActions() { } actions.push('}'); - var parameters = 'yytext, yyleng, yylineno, yyloc, yystate /* action[1] */, yysp, yyrulelength, yyvstack, yylstack, yystack, yysstack'; + let parameters = 'yytext, yyleng, yylineno, yyloc, yystate /* action[1] */, yysp, yyrulelength, yyvstack, yylstack, yystack, yysstack'; this.performAction = [].concat( 'function parser__PerformAction(' + parameters + ') {', @@ -31106,7 +31125,7 @@ generator.buildProductionActions = function buildProductionActions() { moduleInit.forEach(function (chunk) { assert__default['default'](chunk.qualifier); assert__default['default'](typeof chunk.include === 'string'); - var moduleInclude = chunk.include; + let moduleInclude = chunk.include; //self.actionsUseYYLENG = self.actionsUseYYLENG || analyzeFeatureUsage(moduleInclude, /\byyleng\b/g, 0); //self.actionsUseYYLINENO = self.actionsUseYYLINENO || analyzeFeatureUsage(moduleInclude, /\byylineno\b/g, 0); @@ -31174,8 +31193,8 @@ generator.buildProductionActions = function buildProductionActions() { this.actionsUseValueAssignment = true; break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": // <-- this one injects *nothing* + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'skip': // <-- this one injects *nothing* break; } this.actionsUseValueTracking = this.actionsUseValueTracking || this.actionsUseYYLENG || this.actionsUseYYTEXT || this.actionsUseValueAssignment; @@ -31184,8 +31203,8 @@ generator.buildProductionActions = function buildProductionActions() { default: break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": // <-- this one injects *nothing* + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'skip': // <-- this one injects *nothing* break; } this.actionsUseLocationTracking = this.actionsUseLocationTracking || this.actionsUseYYLINENO || this.actionsUseYYLOC || this.actionsUseLocationAssignment || this.actionsUseYYMERGELOCATIONINFO; @@ -31206,7 +31225,7 @@ generator.buildProductionActions = function buildProductionActions() { gen_hash = null; // create check hash of the new generated code: - var new_hash = mkParserFeatureHash(this); + let new_hash = mkParserFeatureHash(this); if ( this.DEBUG) { Jison$1.print('Optimization analysis:\n', { @@ -31235,7 +31254,7 @@ generator.buildProductionActions = function buildProductionActions() { hasErrorReporting: this.hasErrorReporting, defaultActionMode: this.options.defaultActionMode, testCompileActionCode: this.options.testCompileActionCode, - noTryCatch: this.options.noTryCatch, + noTryCatch: this.options.noTryCatch }); } @@ -31258,9 +31277,9 @@ generator.buildProductionActions = function buildProductionActions() { moduleInit.__consumedInitCodeSlots__ = []; moduleInit.getInitCodeSection = function getInitCodeSection(section) { - var rv = []; - for (var i = 0, len = this.length; i < len; i++) { - var m = this[i]; + let rv = []; + for (let i = 0, len = this.length; i < len; i++) { + let m = this[i]; if (m.qualifier === section) { if (m.include.trim()) { rv.push(m.include); @@ -31272,9 +31291,9 @@ generator.buildProductionActions = function buildProductionActions() { }; moduleInit.getRemainingInitCodeSections = function getRemainingInitCodeSections() { - var rv = []; - for (var i = 0, len = this.length; i < len; i++) { - var m = this[i]; + let rv = []; + for (let i = 0, len = this.length; i < len; i++) { + let m = this[i]; if (!this.__consumedInitCodeSlots__[i]) { rv.push(rmCommonWS$5` @@ -31290,8 +31309,6 @@ generator.buildProductionActions = function buildProductionActions() { }; - - // make sure a comment does not contain any embedded '*/' end-of-comment marker // as that would break the generated code function postprocessComment(str) { @@ -31315,13 +31332,13 @@ generator.buildProductionActions = function buildProductionActions() { } function provideSymbolAsSourcecode(sym) { - var ss = String(sym); + let ss = String(sym); return ' /* ' + postprocessComment(ss) + ' */ ' + getSymbolId(sym); } // helper: convert index string/number to proper JS add/subtract expression function indexToJsExpr(n, len, rule4msg) { - var v = parseInt(n, 10); + let v = parseInt(n, 10); // the usual situation: `$3`; MUST reference an rhs[] element or it will be considered an ERROR: if (v > 0) { if (v > len) { @@ -31351,35 +31368,33 @@ generator.buildProductionActions = function buildProductionActions() { return ''; } + // options object { actionGroups, actionGroupValue, stateHasAction } is `this` for this function/callback: function buildProductionAction(handle) { - var i; - var aliased = handle.aliases, - rhs_i; + let aliased = handle.aliases; - var rhs = handle.handle; - var named_token_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$3}$`); + let rhs = handle.handle; + let named_token_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$3}$`); // semantic action specified - var label = [ + let label = [ 'case ', handle.id, ':', '\n /*! Production:: ', postprocessComment(handle.symbol), ' : ' ].concat(postprocessComment(rhs.map(function (sym) { // check if the symbol is a literal terminal, and if it is, quote it: if (sym && !self.nonterminals[sym] && !named_token_re.test(sym) && sym !== self.EOF) { return '"' + sym.replace(/["]/g, '\\"') + '"'; - } - else if (!sym) { + } else if (!sym) { sym = '%epsilon'; } return sym; })), ' */').join(''); - var action = preprocessActionCode(handle.action || ''); - var rule4msg = handle.symbol + ': ' + rhs.join(' '); + let action = preprocessActionCode(handle.action || ''); + let rule4msg = handle.symbol + ': ' + rhs.join(' '); assert__default['default'](typeof handle.id === 'number'); assert__default['default'](handle.id >= 0); - stateHasAction[handle.id] = true; + this.stateHasAction[handle.id] = true; // before anything else, replace direct symbol references, e.g. #NUMBER# when there's a %token NUMBER for your grammar. // This is done to prevent incorrect expansions where tokens are used in rules as RHS elements: we allow these to @@ -31394,9 +31409,9 @@ generator.buildProductionActions = function buildProductionActions() { // replace named semantic values ($nonterminal) if (action.match(new XRegExp__default['default'](`(?:[$@#]|##)${ID_REGEX_BASE$3}`))) { - var count = {}, - names = {}, - donotalias = {}; + let count = {}; + let names = {}; + let donotalias = {}; // When the rule is fitted with aliases it doesn't mean that the action code MUST use those: // we therefor allow access to both the original (non)terminal and the alias. @@ -31427,9 +31442,9 @@ generator.buildProductionActions = function buildProductionActions() { // as an explicit alias: adding auto-alias `e1` would then break the system, // while `e2` would be ambiguous from the human perspective as he *might* then // expect `e2` and `e3`. - var addName = function addName(s) { - var base = s.replace(/[0-9]+$/, ''); - var dna = donotalias[base]; + let addName = function addName(s, i) { + let base = s.replace(/[0-9]+$/, ''); + let dna = donotalias[base]; if (names[s]) { count[s]++; @@ -31450,28 +31465,28 @@ generator.buildProductionActions = function buildProductionActions() { // register the alias/rule name when the real one ends with a number, e.g. `rule5` as // *blocking* the auto-aliasing process for the term of the same base, e.g. `rule`. // This will catch the `WORD[e1]` example above too, via `e1` --> `donotalias['e']` - var markBasename = function markBasename(s) { + let markBasename = function markBasename(s) { if (/[0-9]$/.test(s)) { s = s.replace(/[0-9]+$/, ''); donotalias[s] = true; } }; - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // mark both regular and aliased names, e.g., `id[alias1]` and `id1` - rhs_i = aliased[i]; + let rhs_i = aliased[i]; markBasename(rhs_i); if (rhs_i !== rhs[i]) { markBasename(rhs[i]); } } - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // check for aliased names, e.g., id[alias] - rhs_i = aliased[i]; - addName(rhs_i); + let rhs_i = aliased[i]; + addName(rhs_i, i); if (rhs_i !== rhs[i]) { - addName(rhs[i]); + addName(rhs[i], i); } } action = action.replace( @@ -31488,7 +31503,7 @@ generator.buildProductionActions = function buildProductionActions() { .replace(/\$\$/g, 'this.$') .replace(/@\$/g, 'this._$') .replace(/#\$/g, function (_) { - return provideSymbolAsSourcecode(symbol); + return provideSymbolAsSourcecode(handle.symbol); }) // replace semantic value references ($n) with stack value (stack[n]) .replace(/\$(-?\d+)\b/g, function (_, n) { @@ -31507,7 +31522,7 @@ generator.buildProductionActions = function buildProductionActions() { }) // same as above for token ID references (#n) .replace(/#(-?\d+)\b/g, function (_, n) { - var i = parseInt(n, 10) - 1; + let i = parseInt(n, 10) - 1; if (!rhs[i]) { throw new Error(`invalid token location reference in action code for rule: "${rule4msg}" - location reference: "${_}"`); } @@ -31551,7 +31566,7 @@ generator.buildProductionActions = function buildProductionActions() { // the action code: if some Smart Alec decides to code `this.$` instead of // `$$` it SHOULD NOT confuse the code analysis here! - var uses_$$ = analyzeFeatureUsage(action, /\bthis\.\$[^\w]/g, 0); // use includes assignment, not just read accesses! + let uses_$$ = analyzeFeatureUsage(action, /\bthis\.\$[^\w]/g, 0); // use includes assignment, not just read accesses! // the next check is very rough; we need the AST of the code to do better than this. function analyzeFeatureAssignmentBeforeUse(source, assignment_re, access_re) { @@ -31560,8 +31575,8 @@ generator.buildProductionActions = function buildProductionActions() { // // If no assignment can be found at all, we're probably looking at access-only // OR weird constructs we don't yet understand, in which case we play it safe. - var prelude = source; - var m = source.match(assignment_re); + let prelude = source; + let m = source.match(assignment_re); if (m) { // check the closure exists in the regex: m[1] is filled with its content: assert__default['default'](m[1] != null); @@ -31591,21 +31606,21 @@ generator.buildProductionActions = function buildProductionActions() { return false; // assignment before access (or no usage and assignments at all!) } - var uses_$$_before_assignment = uses_$$ && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\.\$\s*=[^=>]/, /\bthis\.\$[^\w]/g); + let uses_$$_before_assignment = uses_$$ && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\.\$\s*=[^=>]/, /\bthis\.\$[^\w]/g); // ditto for location tracking, but only iff we use it at all: - var uses_$loc = false; - var uses_$loc_before_assignment = false; + let uses_$loc = false; + let uses_$loc_before_assignment = false; if (self.actionsUseLocationTracking) { uses_$loc = analyzeFeatureUsage(action, /\bthis\._\$[^\w]/g, 0); uses_$loc_before_assignment = uses_$loc && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\._\$\s*=[^=>]/, /\bthis\._\$[^\w]/g); } - var inject_default_value_action = (uses_$$_before_assignment || (self.actionsUseValueTracking && !uses_$$)); - var inject_default_loc_action = (uses_$loc_before_assignment || (self.actionsUseLocationTracking && !uses_$loc)); + let inject_default_value_action = (uses_$$_before_assignment || (self.actionsUseValueTracking && !uses_$$)); + let inject_default_loc_action = (uses_$loc_before_assignment || (self.actionsUseLocationTracking && !uses_$loc)); - var default_action = []; + let default_action = []; // Note: // @@ -31616,26 +31631,27 @@ generator.buildProductionActions = function buildProductionActions() { // $$ = undefined; // $@ = undefined; // - var vmode = !inject_default_value_action ? "skip" : self.options.defaultActionMode[0]; - var lmode = !inject_default_loc_action ? "skip" : self.options.defaultActionMode[1]; + let vmode = !inject_default_value_action ? 'skip' : self.options.defaultActionMode[0]; + let lmode = !inject_default_loc_action ? 'skip' : self.options.defaultActionMode[1]; // check if there's no user action specified. Insert default action if it isn't. // first determine the actual number of terms in the production: - var rhs = handle.handle.slice(0); - var real_rhs_length = rhs.length; + let rhs_reduced_length = rhs.length; + let real_rhs_length = rhs.length; // strip away EOF terms at the end of the rule, ditto for epsilon terms: - if (rhs.length) { - switch (rhs[rhs.length - 1]) { + while (rhs_reduced_length) { + switch (rhs[rhs_reduced_length - 1]) { case '$end': - rhs.length--; - break; + rhs_reduced_length--; + continue; case '': // %epsilon - rhs.length--; - break; + rhs_reduced_length--; + continue; } + break; } // then we can choose what to do, depending on the number of terms in the production. @@ -31652,18 +31668,18 @@ generator.buildProductionActions = function buildProductionActions() { // // Ditto for location tracking default actions... // - switch (rhs.length) { + switch (rhs_reduced_length) { case 0: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; <-- but that would cause nondeterministic behaviour, so // we fall back to the default here! - case "ast": - case "none": - default_action.push("this.$ = undefined;"); + case 'ast': + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31672,22 +31688,22 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // an empty production has no location as there are no terms parsed. // ergo: we produce a zero-width location which points at the tail // end of the previous content: // @$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);"); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31698,19 +31714,19 @@ generator.buildProductionActions = function buildProductionActions() { case 1: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; // // WARNING: be careful with the ACCEPT rule as that one's production has - // rhs.length === 1 **BUT** has real_rhs_length === 2 as we have discarded + // rhs_reduced_length === 1 **BUT** has real_rhs_length === 2 as we have discarded // the `$end` term at the end! // Here we need to account for that magick though! - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // As we're looking at a production which has one(1) useful term, we can simply // reference-copy that one intom a fresh array, instead of `slice()`-ing it out // of the vstack. @@ -31719,14 +31735,14 @@ generator.buildProductionActions = function buildProductionActions() { // WARNING/NOTE: as above, and ditto BTW for rule productions which end with // `EOF` as a last term: as we now construct an entire AST, we DO NOT include // those 'values' here! - default_action.push("this.$ = [yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "]];"); + default_action.push('this.$ = [yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ']];'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31735,23 +31751,23 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: // as we have a production length of 1 only, we can simply ref-copy @1: // @$ = @1; // // WARNING: same as above for the value copying: we may have discarded an `EOF` or `$end` term! - default_action.push("this._$ = yylstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this._$ = yylstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31762,29 +31778,29 @@ generator.buildProductionActions = function buildProductionActions() { default: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // - // WARNING: as with the situation further above where rhs.length === 1 after we + // WARNING: as with the situation further above where rhs_reduced_length === 1 after we // have got rid of a possible `EOF` or `$end` at the end of the production, // we again have to account for our trickery earlier and compensate the // action above: again we DO NOT include the value of the EOF/$end token in the // resulting array 'AST', hence our `slice()` end index may vary by one(1): - var end_offset = 1 - real_rhs_length + rhs.length; - default_action.push("this.$ = yyvstack.slice(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp" + /* CANNOT USE indexToJsExpr(rhs.length + 1, real_rhs_length, rule4msg) HERE! */ (end_offset === 0 ? "" : " + " + end_offset) + ");"); + let end_offset = 1 - real_rhs_length + rhs_reduced_length; + default_action.push('this.$ = yyvstack.slice(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp' + /* CANNOT USE indexToJsExpr(rhs_reduced_length + 1, real_rhs_length, rule4msg) HERE! */ (end_offset === 0 ? '' : ' + ' + end_offset) + ');'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31793,20 +31809,20 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: - // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs.length - 1}, yysp); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp);"); + // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs_reduced_length - 1}, yysp); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31819,16 +31835,16 @@ generator.buildProductionActions = function buildProductionActions() { // comment/mark the default action chunk, if any, so we can simply observe // what is user code and what is generated by us in the final product: if (default_action.length > 0) { - var flags = [ - rhs.length, - self.actionsUseValueTracking ? "VT" : "-", - self.actionsUseValueAssignment ? "VA" : "-", - uses_$$ ? "VU" : "-", - uses_$$_before_assignment ? "VUbA" : "-", - self.actionsUseLocationTracking ? "LT" : "-", - self.actionsUseLocationAssignment ? "LA" : "-", - uses_$loc ? "LU" : "-", - uses_$loc_before_assignment ? "LUbA" : "-", + let flags = [ + rhs_reduced_length + '/' + real_rhs_length, + self.actionsUseValueTracking ? 'VT' : '-', + self.actionsUseValueAssignment ? 'VA' : '-', + uses_$$ ? 'VU' : '-', + uses_$$_before_assignment ? 'VUbA' : '-', + self.actionsUseLocationTracking ? 'LT' : '-', + self.actionsUseLocationAssignment ? 'LA' : '-', + uses_$loc ? 'LU' : '-', + uses_$loc_before_assignment ? 'LUbA' : '-' ].join(','); default_action.unshift(`// default action (generated by JISON mode ${self.options.defaultActionMode[0]}/${self.options.defaultActionMode[1]} :: ${flags}):`); @@ -31842,16 +31858,16 @@ generator.buildProductionActions = function buildProductionActions() { action = reindentCodeBlock(action, 4); - var actionHash = mkHashIndex(action); + let actionHash = mkHashIndex(action); // Delay running the postprocess (restore) process until we've done ALL macro expansions: //action = postprocessActionCode(action); - if (actionHash in actionGroups) { - actionGroups[actionHash].push(label); + if (actionHash in this.actionGroups) { + this.actionGroups[actionHash].push(label); } else { - actionGroups[actionHash] = [label]; - actionGroupValue[actionHash] = action; + this.actionGroups[actionHash] = [ label ]; + this.actionGroupValue[actionHash] = action; } } }; @@ -31871,7 +31887,7 @@ generator.trace = (new Function('', 'function no_op_trace() { }\nreturn no_op_tr //generator.trace.name = 'no_op_trace'; generator.warn = function warn() { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); Jison$1.print.call(null, args.join('')); }; @@ -31918,9 +31934,9 @@ generator.reportGrammarInformation = function reportGrammarInformation() { // LR specific mixin class later on, so that we can have another // implementation/report for LL and PEG type grammars. - var rows = 0, cols = 0; - var colmarks = {}; - var i, j, len; + let rows = 0, cols = 0; + let colmarks = {}; + let i, j, len; for (i = 0, len = this.table.length; i < len; i++) { rows++; @@ -31931,8 +31947,8 @@ generator.reportGrammarInformation = function reportGrammarInformation() { } } } - var defrows = 0; - var rowmarks = {}; + let defrows = 0; + let rowmarks = {}; for (j in this.defaultActions) { if (!rowmarks[j]) { rowmarks[j] = true; @@ -31940,8 +31956,8 @@ generator.reportGrammarInformation = function reportGrammarInformation() { } } - var ntc = 0; - for (var nt in this.nonterminals) { + let ntc = 0; + for (let nt in this.nonterminals) { ntc++; } @@ -31960,14 +31976,12 @@ generator.reportGrammarInformation = function reportGrammarInformation() { // --- START of debugTraceSrc chunk --- const debugTraceSrc = ` function debug_trace() { - "use strict"; - if (typeof Jison !== 'undefined' && Jison.print) { Jison.print.apply(null, arguments); } else if (typeof print !== 'undefined') { print.apply(null, arguments); } else if (typeof console !== 'undefined' && console.log) { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); args.unshift(''); // prevent \`%.\` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args console.log.apply(null, args); } @@ -31977,14 +31991,14 @@ function debug_trace() { // Generator debug mixin -var generatorDebug = { +const generatorDebug = { trace: (new Function('', debugTraceSrc + ` return debug_trace;`))(), beforeprocessGrammar: function () { this.trace('Processing grammar.'); }, afteraugmentGrammar: function () { - var trace = this.trace; + let trace = this.trace; trace('\nSymbols:\n'); each(this.symbols, function (sym, i) { trace(sym + '(' + i + ')'); @@ -31998,7 +32012,7 @@ var generatorDebug = { /* * Mixin for common behaviors of lookahead parsers */ -var lookaheadMixin = {}; +let lookaheadMixin = {}; lookaheadMixin.computeLookaheads = function computeLookaheads() { if (this.DEBUG) { @@ -32012,11 +32026,11 @@ lookaheadMixin.computeLookaheads = function computeLookaheads() { }; lookaheadMixin.displayFollowSets = function displayFollowSets() { - var self = this; - var symfollowdbg = {}; + let self = this; + let symfollowdbg = {}; this.productions.forEach(function Follow_prod_forEach_debugOut(production, k) { - var key = ['prod-', k, ': ', production.symbol, ' := ', production.handle.join(' ')].join(''); - var flw = '[' + self.nonterminals[production.symbol].follows.join('] [') + ']'; + let key = [ 'prod-', k, ': ', production.symbol, ' := ', production.handle.join(' ') ].join(''); + let flw = '[' + self.nonterminals[production.symbol].follows.join('] [') + ']'; if (!symfollowdbg[flw]) { symfollowdbg[flw] = {}; } @@ -32027,9 +32041,9 @@ lookaheadMixin.displayFollowSets = function displayFollowSets() { symfollowdbg[flw][key]++; } }); - for (var l in symfollowdbg) { - var lst = []; - for (var k in symfollowdbg[l]) { + for (let l in symfollowdbg) { + let lst = []; + for (let k in symfollowdbg[l]) { lst.push(k); } self.trace('Symbol/Follows:\n ', lst.join('\n '), ' -->\n ', l); @@ -32038,10 +32052,10 @@ lookaheadMixin.displayFollowSets = function displayFollowSets() { // calculate follow sets based on first and nullable lookaheadMixin.followSets = function followSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true; + let productions = this.productions; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { @@ -32050,23 +32064,23 @@ lookaheadMixin.followSets = function followSets() { productions.forEach(function Follow_prod_forEach(production, k) { // q is used in Simple LALR algorithm determine follows in context - var q; - var ctx = !!self.go_; + let q; + let ctx = !!self.go_; - for (var i = 0, t; (t = production.handle[i]); ++i) { + for (let i = 0, t; (t = production.handle[i]); ++i) { if (!nonterminals[t]) continue; // for Simple LALR algorithm, self.go_ checks if if (ctx) { q = self.go_(production.symbol, production.handle.slice(0, i)); } - var bool = (!ctx || q === self.nterms_[t]); - var set; + let bool = (!ctx || q === self.nterms_[t]); + let set; if (i === production.handle.length - 1 && bool) { set = nonterminals[production.symbol].follows; } else { - var part = production.handle.slice(i + 1); + let part = production.handle.slice(i + 1); set = self.first(part); if (self.nullable(part) && bool) { @@ -32074,8 +32088,8 @@ lookaheadMixin.followSets = function followSets() { set.push.apply(set, nonterminals[production.symbol].follows); } } - var follows = nonterminals[t].follows; - var oldcount = follows.length; + let follows = nonterminals[t].follows; + let oldcount = follows.length; follows = union(follows, set); if (oldcount !== follows.length) { cont = true; @@ -32097,8 +32111,8 @@ lookaheadMixin.first = function first(symbol) { return []; // RHS } else if (symbol instanceof Array) { - var firsts = []; - for (var i = 0, t; (t = symbol[i]); ++i) { + let firsts = []; + for (let i = 0, t; (t = symbol[i]); ++i) { if (!this.nonterminals[t]) { if (firsts.indexOf(t) === -1) { firsts.push(t); @@ -32106,41 +32120,39 @@ lookaheadMixin.first = function first(symbol) { } else { firsts = union(firsts, this.nonterminals[t].first); } - if (!this.nullable(t)) - break; + if (!this.nullable(t)) { break; } } return firsts; // terminal } else if (!this.nonterminals[symbol]) { - return [symbol]; + return [ symbol ]; // nonterminal - } else { - return this.nonterminals[symbol].first; } + return this.nonterminals[symbol].first; + }; // fixed-point calculation of FIRST sets lookaheadMixin.firstSets = function firstSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true, - symbol, firsts; + let productions = this.productions; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { cont = false; productions.forEach(function FirstSets_forEach(production, k) { - var firsts = self.first(production.handle); + let firsts = self.first(production.handle); if (firsts.length !== production.first.length) { production.first = firsts; cont = true; } }); - for (symbol in nonterminals) { - firsts = []; + for (let symbol in nonterminals) { + let firsts = []; nonterminals[symbol].productions.forEach(function FirstSets_forEachNonTerm(production) { firsts = union(firsts, production.first); }); @@ -32154,9 +32166,9 @@ lookaheadMixin.firstSets = function firstSets() { // fixed-point calculation of NULLABLE lookaheadMixin.nullableSets = function nullableSets() { - var nonterminals = this.nonterminals, - self = this, - cont = true; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { @@ -32165,7 +32177,9 @@ lookaheadMixin.nullableSets = function nullableSets() { // check if each production is nullable this.productions.forEach(function isEachProductionNullable(production, k) { if (!production.nullable) { - for (var i = 0, n = 0, t; (t = production.handle[i]); ++i) { + let i = 0; + let n = 0; + for (let t; (t = production.handle[i]); ++i) { if (self.nullable(t)) n++; } if (n === i) { // production is nullable if all tokens are nullable @@ -32175,9 +32189,9 @@ lookaheadMixin.nullableSets = function nullableSets() { }); // check if each symbol is nullable - for (var symbol in nonterminals) { + for (let symbol in nonterminals) { if (!this.nullable(symbol)) { - for (var i = 0, production; (production = nonterminals[symbol].productions.item(i)); i++) { + for (let i = 0, production; (production = nonterminals[symbol].productions.item(i)); i++) { if (production.nullable) { nonterminals[symbol].nullable = cont = true; } @@ -32194,7 +32208,7 @@ lookaheadMixin.nullable = function nullable(symbol) { return true; // RHS } else if (symbol instanceof Array) { - for (var i = 0, t; (t = symbol[i]); ++i) { + for (let i = 0, t; (t = symbol[i]); ++i) { if (!this.nullable(t)) { return false; } @@ -32204,14 +32218,14 @@ lookaheadMixin.nullable = function nullable(symbol) { } else if (!this.nonterminals[symbol]) { return false; // nonterminal - } else { - return this.nonterminals[symbol].nullable; } + return this.nonterminals[symbol].nullable; + }; // lookahead debug mixin -var lookaheadDebug = { +const lookaheadDebug = { beforenullableSets: function () { this.trace('Computing Nullable sets.'); }, @@ -32222,7 +32236,7 @@ var lookaheadDebug = { this.trace('Computing Follow sets.'); }, afterfollowSets: function () { - var trace = this.trace; + let trace = this.trace; trace('\nNonterminals:\n'); each(this.nonterminals, function (nt, t) { trace(nt.toString(), '\n'); @@ -32234,7 +32248,7 @@ var lookaheadDebug = { /* * Mixin for common LR parser behavior */ -var lrGeneratorMixin = {}; +let lrGeneratorMixin = {}; // LR state machine actions: @@ -32287,16 +32301,16 @@ lrGeneratorMixin.Item = typal.construct({ return e.id === this.id; }, handleToString: function () { - var handle = this.production.handle.slice(0); + let handle = this.production.handle.slice(0); handle[this.dotPosition] = '.' + (handle[this.dotPosition] || ''); return handle.join(' '); }, toString: function () { - var temp = this.production.handle.slice(0); + let temp = this.production.handle.slice(0); temp[this.dotPosition] = '.' + (temp[this.dotPosition] || ''); - var s = this.production.symbol + ' -> ' + temp.join(' '); - var padlen = Math.max(4, 40 - s.length); - var pad = new Array(padlen); + let s = this.production.symbol + ' -> ' + temp.join(' '); + let padlen = Math.max(4, 40 - s.length); + let pad = new Array(padlen); if (this.follows.length) { s += pad.join(' ') + '#lookaheads= [' + this.follows.join('] [') + ']'; pad = new Array(2); @@ -32309,7 +32323,7 @@ lrGeneratorMixin.Item = typal.construct({ } }); -lrGeneratorMixin.ItemSet = Set.prototype.construct({ +lrGeneratorMixin.ItemSet = Set$1.prototype.construct({ afterconstructor: function () { this.reductions = []; this.goes = {}; @@ -32317,13 +32331,13 @@ lrGeneratorMixin.ItemSet = Set.prototype.construct({ this.shifts = false; this.inadequate = false; this.hash_ = {}; - for (var i = this._items.length - 1; i >= 0; i--) { + for (let i = this._items.length - 1; i >= 0; i--) { this.hash_[this._items[i].id] = true; //i; } }, concat: function concat(set) { - var a = set._items || set; - for (var i = a.length - 1; i >= 0; i--) { + let a = set._items || set; + for (let i = a.length - 1; i >= 0; i--) { this.hash_[a[i].id] = true; } this._items.push.apply(this._items, a); @@ -32337,31 +32351,31 @@ lrGeneratorMixin.ItemSet = Set.prototype.construct({ return this.hash_[item.id]; }, valueOf: function toValue() { - var v = this._items.map(function (a) { return a.id; }).sort().join('|'); + let v = this._items.map(function (a) { return a.id; }).sort().join('|'); this.valueOf = function valueOf_inner() { return v; }; return v; } }); lrGeneratorMixin.closureOperation = function closureOperation(itemSet) { - var closureSet = new this.ItemSet(); - var self = this; + let closureSet = new this.ItemSet(); + let self = this; - var set = itemSet, - itemQueue, - syms = {}; + let set = itemSet; + let itemQueue; + let syms = {}; do { - itemQueue = new Set(); + itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function CO_set_forEach(item) { - var symbol = item.markedSymbol; + let symbol = item.markedSymbol; // if token is a non-terminal, recursively add closures if (symbol && self.nonterminals[symbol]) { if (!syms[symbol]) { self.nonterminals[symbol].productions.forEach(function CO_nt_forEach(production) { - var newItem = new self.Item(production, 0); + let newItem = new self.Item(production, 0); if (!closureSet.contains(newItem)) { itemQueue.push(newItem); } @@ -32386,8 +32400,8 @@ lrGeneratorMixin.closureOperation = function closureOperation(itemSet) { }; lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) { - var gotoSet = new this.ItemSet(), - self = this; + let gotoSet = new this.ItemSet(); + let self = this; itemSet.forEach(function goto_forEach(item, n) { if (item.markedSymbol === symbol) { @@ -32402,14 +32416,14 @@ lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) { * Create unique set of item sets */ lrGeneratorMixin.canonicalCollection = function canonicalCollection() { - var item1 = new this.Item(this.productions[0], 0, [this.EOF]); - var firstStateNoClosure = new this.ItemSet(item1), - firstState = this.closureOperation(firstStateNoClosure), - states = new Set(firstState), - marked = 0, - self = this, - itemSet, - markedSymbols; + let item1 = new this.Item(this.productions[0], 0, [ this.EOF ]); + let firstStateNoClosure = new this.ItemSet(item1); + let firstState = this.closureOperation(firstStateNoClosure); + let states = new Set$1(firstState); + let marked = 0; + let self = this; + let itemSet; + let markedSymbols; states.has = {}; states.has[firstStateNoClosure.valueOf()] = 0; @@ -32431,8 +32445,8 @@ lrGeneratorMixin.canonicalCollection = function canonicalCollection() { // Pushes a unique state into the queue. Some parsing algorithms may perform additional operations lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert(symbol, itemSet, states, stateNum) { - var g = this.gotoOperation(itemSet, symbol), - state = states.has[g.valueOf()]; + let g = this.gotoOperation(itemSet, symbol); + let state = states.has[g.valueOf()]; if (typeof state !== 'undefined') { itemSet.edges[symbol] = state; // store goto transition for table @@ -32447,36 +32461,36 @@ lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert( } itemSet.edges[symbol] = states.size(); // store goto transition for table states.push(g); - g.predecessors[symbol] = [stateNum]; + g.predecessors[symbol] = [ stateNum ]; } } }; lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { - var states = [], - nonterminals = this.nonterminals, - operators = this.operators, - conflictedStates = {}, // set of [state, token] tuples - self = this; + let states = []; + let nonterminals = this.nonterminals; + let operators = this.operators; + let conflictedStates = {}; // set of [state, token] tuples + let self = this; // for each item set itemSets.forEach(function parseTableItem(itemSet, k) { k = +k; - var state = states[k] = {}; - var action, stackSymbol; + let state = states[k] = {}; + let action, stackSymbol; // set shift and goto actions for (stackSymbol in itemSet.edges) { itemSet.forEach(function findShiftAndGotoActions(item, j) { // find shift and goto actions if (item.markedSymbol === stackSymbol) { - var gotoState = itemSet.edges[stackSymbol]; + let gotoState = itemSet.edges[stackSymbol]; assert__default['default'](gotoState); if (nonterminals[stackSymbol]) { // store state to go to after a reduce state[self.symbols_[stackSymbol]] = gotoState; } else { - state[self.symbols_[stackSymbol]] = [SHIFT, gotoState]; + state[self.symbols_[stackSymbol]] = [ SHIFT, gotoState ]; } } }); @@ -32486,25 +32500,25 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { itemSet.forEach(function setAcceptAction(item, j) { if (item.markedSymbol === self.EOF) { // accept - state[self.symbols_[self.EOF]] = [ACCEPT]; + state[self.symbols_[self.EOF]] = [ ACCEPT ]; } }); - var allterms = self.lookAheads ? false : self.terminals; + let allterms = self.lookAheads ? false : self.terminals; // set reductions and resolve potential conflicts itemSet.reductions.forEach(function calcReduction(item, j) { // if parser uses lookahead, only enumerate those terminals - var terminals = allterms || self.lookAheads(itemSet, item); + let terminals = allterms || self.lookAheads(itemSet, item); terminals.forEach(function (stackSymbol) { action = state[self.symbols_[stackSymbol]]; - var op = operators[stackSymbol]; + let op = operators[stackSymbol]; // Reading a terminal and current position is at the end of a production, try to reduce if (action) { - var sol = resolveConflict(item.production, op, [REDUCE, item.production.id], action[0] instanceof Array ? action[0] : action); - self.resolutions.push([k, stackSymbol, sol]); + let sol = resolveConflict(item.production, op, [ REDUCE, item.production.id ], action[0] instanceof Array ? action[0] : action); + self.resolutions.push([ k, stackSymbol, sol ]); if (sol.bydefault) { self.conflicts++; @@ -32542,7 +32556,7 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { if (self.options.noDefaultResolve) { if (!(action[0] instanceof Array)) { - action = [action]; + action = [ action ]; } action.push(sol.r); } @@ -32550,7 +32564,7 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { action = sol.action; } } else { - action = [REDUCE, item.production.id]; + action = [ REDUCE, item.production.id ]; } if (action && action.length) { state[self.symbols_[stackSymbol]] = action; @@ -32601,25 +32615,25 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { // only this time we are careful about the TERROR symbol as a state carrying that one // is an explicitly encoded error recovery rule and should remain as-is. function findDefaults(states, hasErrorRecovery) { - var defaults = {}; + let defaults = {}; states.forEach(function (state, k) { - var act, sym, st; - var i = 0; - var gotos = {}; + let act; + let i = 0; + let gotos = {}; - for (sym in state) { + for (let sym in state) { assert__default['default']({}.hasOwnProperty.call(state, sym)); // it this isn't true, the last part of this function won't work! // keep state rows where there's an error recovery state: if (sym === 2 /* TERROR */) { return; } - st = state[sym]; + let st = state[sym]; if (typeof st !== 'number') { if (st[0] !== REDUCE) { // not a reduce action: forget about this row! return; } - var go = st[1]; + let go = st[1]; if (!gotos[go]) { gotos[go] = true; i++; @@ -32647,8 +32661,8 @@ function findDefaults(states, hasErrorRecovery) { // ... hence we only nuke these table entries (as that makes for a smaller table --> smaller parser file) // when there's no error recovery code included in the generated parser: if (!hasErrorRecovery) { - for (sym in state) { - st = state[sym]; + for (let sym in state) { + let st = state[sym]; if (typeof st !== 'number') { delete state[sym]; } @@ -32663,9 +32677,7 @@ function findDefaults(states, hasErrorRecovery) { // Remove all NONASSOC state transitions from the generated table now that we don't need them any longer function cleanupTable(table) { table.forEach(function (state, k) { - var symbol; - - for (symbol in state) { + for (let symbol in state) { if (state[symbol] === NONASSOC) { delete state[symbol]; } @@ -32675,16 +32687,16 @@ function cleanupTable(table) { // resolves shift-reduce and reduce-reduce conflicts function resolveConflict(production, op, reduce, shift) { - var sln = { - production: production, - operator: op, - r: reduce, - s: shift, - - msg: null, - action: null, - bydefault: false - }; + let sln = { + production: production, + operator: op, + r: reduce, + s: shift, + + msg: null, + action: null, + bydefault: false + }; if (shift[0] === REDUCE) { sln.msg = 'Resolved R/R conflict: use first production declared in grammar.'; @@ -32722,7 +32734,7 @@ function resolveConflict(production, op, reduce, shift) { /* * Mixin for common LR/LL/*any* parser behavior */ -var generatorMixin = {}; +let generatorMixin = {}; // internal helper function: generatorMixin.__prepareOptions = function parser___prepare_Options(opt) { @@ -32736,7 +32748,7 @@ generatorMixin.__prepareOptions = function parser___prepare_Options(opt) { // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*?[a-zA-Z0-9_$]$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "parser" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "parser" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else if (opt.warn_cb) { @@ -32752,7 +32764,7 @@ generatorMixin.__prepareOptions = function parser___prepare_Options(opt) { }; generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComment() { - var out = ` + let out = ` /* parser generated by jison ${version$2} */ /* @@ -32916,9 +32928,9 @@ generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComm * Produces a new errorInfo 'hash object' which can be passed into \`parseError()\`. * See it's use in this parser kernel in many places; example usage: * - * var infoObj = parser.constructParseErrorInfo('fail!', null, + * let infoObj = parser.constructParseErrorInfo('fail!', null, * parser.collect_expected_token_set(state), true); - * var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); + * let retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); * * originalParseError: function(str, hash, ExceptionClass), * The basic \`parseError\` handler provided by JISON. @@ -33120,212 +33132,7 @@ generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComm * flex: boolean * optional: \`true\` ==> flex-like lexing behaviour where the rules are tested * exhaustively to find the longest match. - * backtrack_lexer: boolean (⅏ 센 ⅊ ⁖ ⁘ ⁙ ⁚ ⁛ ⁜ ⁝ ⁞ † ‡ - a⯈b - ∀ ∁ ∂ ∃ ∄ ∅ ∆ ∇ ∈ ∉ ∊ ∋ ∌ ∍ ∎ ∏ -U+221x ∐ ∑ − ∓ ∔ ∕ ∖ ∗ ∘ ∙ √ ∛ ∜ ∝ ∞ ∟ -U+222x ∠ ∡ ∢ ∣ ∤ ∥ ∦ ∧ ∨ ∩ ∪ ∫ ∬ ∭ ∮ ∯ -U+223x ∰ ∱ ∲ ∳ ∴ ∵ ∶ ∷ ∸ ∹ ∺ ∻ ∼ ∽ ∾ ∿ -U+224x ≀ ≁ ≂ ≃ ≄ ≅ ≆ ≇ ≈ ≉ ≊ ≋ ≌ ≍ ≎ ≏ -U+225x ≐ ≑ ≒ ≓ ≔ ≕ ≖ ≗ ≘ ≙ ≚ ≛ ≜ ≝ ≞ ≟ -U+226x ≠ ≡ ≢ ≣ ≤ ≥ ≦ ≧ ≨ ≩ ≪ ≫ ≬ ≭ ≮ ≯ -U+227x ≰ ≱ ≲ ≳ ≴ ≵ ≶ ≷ ≸ ≹ ≺ ≻ ≼ ≽ ≾ ≿ -U+228x ⊀ ⊁ ⊂ ⊃ ⊄ ⊅ ⊆ ⊇ ⊈ ⊉ ⊊ ⊋ ⊌ ⊍ ⊎ ⊏ -U+229x ⊐ ⊑ ⊒ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊜ ⊝ ⊞ ⊟ -U+22Ax ⊠ ⊡ ⊢ ⊣ ⊤ ⊥ ⊦ ⊧ ⊨ ⊩ ⊪ ⊫ ⊬ ⊭ ⊮ ⊯ -U+22Bx ⊰ ⊱ ⊲ ⊳ ⊴ ⊵ ⊶ ⊷ ⊸ ⊹ ⊺ ⊻ ⊼ ⊽ ⊾ ⊿ -U+22Cx ⋀ ⋁ ⋂ ⋃ ⋄ ⋅ ⋆ ⋇ ⋈ ⋉ ⋊ ⋋ ⋌ ⋍ ⋎ ⋏ -U+22Dx ⋐ ⋑ ⋒ ⋓ ⋔ ⋕ ⋖ ⋗ ⋘ ⋙ ⋚ ⋛ ⋜ ⋝ ⋞ ⋟ -U+22Ex ⋠ ⋡ ⋢ ⋣ ⋤ ⋥ ⋦ ⋧ ⋨ ⋩ ⋪ ⋫ ⋬ ⋭ ⋮ ⋯ -U+22Fx ⋰ ⋱ ⋲ ⋳ ⋴ ⋵ ⋶ ⋷ ⋸ ⋹ ⋺ ⋻ ⋼ ⋽ ⋾ ⋿) -U+230x ⌀ ⌁ ⌂ ⌃ ⌄ ⌅ ⌆ ⌇ ⌈ ⌉ ⌊ ⌋ ⌌ ⌍ ⌎ ⌏ -U+231x ⌐ ⌑ ⌒ ⌓ ⌔ ⌕ ⌖ ⌗ ⌘ ⌙ ⌚ ⌛ ⌜ ⌝ ⌞ ⌟ -U+232x ⌠ ⌡ ⌢ ⌣ ⌤ ⌥ ⌦ ⌧ ⌨ 〈 〉 ⌫ ⌬ ⌭ ⌮ ⌯ -U+233x ⌰ ⌱ ⌲ ⌳ ⌴ ⌵ ⌶ ⌷ ⌸ ⌹ ⌺ ⌻ ⌼ ⌽ ⌾ ⌿ -U+234x ⍀ ⍁ ⍂ ⍃ ⍄ ⍅ ⍆ ⍇ ⍈ ⍉ ⍊ ⍋ ⍌ ⍍ ⍎ ⍏ -U+235x ⍐ ⍑ ⍒ ⍓ ⍔ ⍕ ⍖ ⍗ ⍘ ⍙ ⍚ ⍛ ⍜ ⍝ ⍞ ⍟ -U+236x ⍠ ⍡ ⍢ ⍣ ⍤ ⍥ ⍦ ⍧ ⍨ ⍩ ⍪ ⍫ ⍬ ⍭ ⍮ ⍯ -U+237x ⍰ ⍱ ⍲ ⍳ ⍴ ⍵ ⍶ ⍷ ⍸ ⍹ ⍺ ⍻ ⍼ ⍽ ⍾ ⍿ -U+238x ⎀ ⎁ ⎂ ⎃ ⎄ ⎅ ⎆ ⎇ ⎈ ⎉ ⎊ ⎋ ⎌ ⎍ ⎎ ⎏ -U+239x ⎐ ⎑ ⎒ ⎓ ⎔ ⎕ ⎖ ⎗ ⎘ ⎙ ⎚ ⎛ ⎜ ⎝ ⎞ ⎟ -U+23Ax ⎠ ⎡ ⎢ ⎣ ⎤ ⎥ ⎦ ⎧ ⎨ ⎩ ⎪ ⎫ ⎬ ⎭ ⎮ ⎯ -U+23Bx ⎰ ⎱ ⎲ ⎳ ⎴ ⎵ ⎶ ⎷ ⎸ ⎹ ⎺ ⎻ ⎼ ⎽ ⎾ ⎿ -U+23Cx ⏀ ⏁ ⏂ ⏃ ⏄ ⏅ ⏆ ⏇ ⏈ ⏉ ⏊ ⏋ ⏌ ⏍ ⏎ ⏏ -U+23Dx ⏐ ⏑ ⏒ ⏓ ⏔ ⏕ ⏖ ⏗ ⏘ ⏙ ⏚ ⏛ ⏜ ⏝ ⏞ ⏟ -U+23Ex ⏠ ⏡ ⏢ ⏣ ⏤ ⏥ ⏦ ⏧ ⏨ ⏩ ⏪ ⏫ ⏬ ⏭ ⏮ ⏯ -U+23Fx ⏰ ⏱ ⏲ ⏳ ⏴ ⏵ ⏶ ⏷ ⏸ ⏹ ⏺ ⏻ ⏼ ⏽ ⏾ ⏿ - -U+260x ☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☎ ☏ -U+261x ☐ ☑ ☒ ☓ ☔ ☕ ☖ ☗ ☘ ☙ ☚ ☛ ☜ ☝ ☞ ☟ -U+262x ☠ ☡ ☢ ☣ ☤ ☥ ☦ ☧ ☨ ☩ ☪ ☫ ☬ ☭ ☮ ☯ -U+263x ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷ ☸ ☹ ☺ ☻ ☼ ☽ ☾ ☿ -U+264x ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇ ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ -U+265x ♐ ♑ ♒ ♓ ♔ ♕ ♖ ♗ ♘ ♙ ♚ ♛ ♜ ♝ ♞ ♟ -U+266x ♠ ♡ ♢ ♣ ♤ ♥ ♦ ♧ ♨ ♩ ♪ ♫ ♬ ♭ ♮ ♯ -U+267x ♰ ♱ ♲ ♳ ♴ ♵ ♶ ♷ ♸ ♹ ♺ ♻ ♼ ♽ ♾ ♿ -U+268x ⚀ ⚁ ⚂ ⚃ ⚄ ⚅ ⚆ ⚇ ⚈ ⚉ ⚊ ⚋ ⚌ ⚍ ⚎ ⚏ -U+269x ⚐ ⚑ ⚒ ⚓ ⚔ ⚕ ⚖ ⚗ ⚘ ⚙ ⚚ ⚛ ⚜ ⚝ ⚞ ⚟ -U+26Ax ⚠ ⚡ ⚢ ⚣ ⚤ ⚥ ⚦ ⚧ ⚨ ⚩ ⚪ ⚫ ⚬ ⚭ ⚮ ⚯ -U+26Bx ⚰ ⚱ ⚲ ⚳ ⚴ ⚵ ⚶ ⚷ ⚸ ⚹ ⚺ ⚻ ⚼ ⚽ ⚾ ⚿ -U+26Cx ⛀ ⛁ ⛂ ⛃ ⛄ ⛅ ⛆ ⛇ ⛈ ⛉ ⛊ ⛋ ⛌ ⛍ ⛎ ⛏ -U+26Dx ⛐ ⛑ ⛒ ⛓ ⛔ ⛕ ⛖ ⛗ ⛘ ⛙ ⛚ ⛛ ⛜ ⛝ ⛞ ⛟ -U+26Ex ⛠ ⛡ ⛢ ⛣ ⛤ ⛥ ⛦ ⛧ ⛨ ⛩ ⛪ ⛫ ⛬ ⛭ ⛮ ⛯ -U+26Fx ⛰ ⛱ ⛲ ⛳ ⛴ ⛵ ⛶ ⛷ ⛸ ⛹ ⛺ ⛻ ⛼ ⛽ ⛾ ⛿ - - ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ☛ ☞ ✌ ✍ ✎ ✏ -✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -✠ ✡ ✢ ✣ ✤ ✥ ✦ ✧ ★ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ● ❍ ■ ❏ -☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ❐ ❑ ❒ ▲ ▼ ◆ ❖ -◗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ - -U+270x ✀ ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ✊ ✋ ✌ ✍ ✎ ✏ -U+271x ✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -U+272x ✠ ✡ ✢ ✣ a✤b a✥b a✦b a✧b ✨ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -U+273x ✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -U+274x ❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ❌ ❍ ❎ ❏ -U+275x ❐ ❑ ❒ ❓ ❔ ❕ ❖ ❗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ ❟ -U+276x ❠ ❡ ❢ ❣ ❤ ❥ ❦ ❧ ❨ ❩ ❪ ❫ ❬ ❭ ❮ a❯b -U+277x ❰ ❱ ❲ ❳ ❴ ❵ ❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ ❾ ❿ -U+278x ➀ ➁ ➂ ➃ ➄ ➅ ➆ ➇ ➈ ➉ ➊ ➋ ➌ ➍ ➎ ➏ -U+279x ➐ ➑ ➒ ➓ ➔ ➕ ➖ ➗ ➘ ➙ ➚ ➛ ➜ ➝ ➞ ➟ -U+27Ax ➠ ➡ ➢ ➣ ➤ ➥ ➦ ➧ a➨b ➩ ➪ ➫ ➬ ➭ ➮ ➯ -U+27Bx ➰ a➱b ➲ ➳ ➴ ➵ ➶ ➷ ➸ ➹ ➺ ➻ ➼ ➽ ➾ ➿ - -U+2580 ▀ Upper half block -U+2581 ▁ Lower one eighth block -U+2582 ▂ Lower one quarter block -U+2583 ▃ Lower three eighths block -U+2584 ▄ Lower half block -U+2585 ▅ Lower five eighths block -U+2586 ▆ Lower three quarters block -U+2587 ▇ Lower seven eighths block -U+2588 █ Full block -U+2589 ▉ Left seven eighths block -U+258A ▊ Left three quarters block -U+258B ▋ Left five eighths block -U+258C ▌ Left half block -U+258D ▍ Left three eighths block -U+258E ▎ Left one quarter block -U+258F ▏ Left one eighth block -U+2590 ▐ Right half block -U+2591 ░ Light shade -U+2592 ▒ Medium shade -U+2593 ▓ Dark shade -U+2594 ▔ Upper one eighth block -U+2595 ▕ Right one eighth block -U+2596 ▖ Quadrant lower left -U+2597 ▗ Quadrant lower right -U+2598 ▘ Quadrant upper left -U+2599 ▙ Quadrant upper left and lower left and lower right -U+259A ▚ Quadrant upper left and lower right -U+259B ▛ Quadrant upper left and upper right and lower left -U+259C ▜ Quadrant upper left and upper right and lower right -U+259D ▝ Quadrant upper right -U+259E ▞ Quadrant upper right and lower left -U+259F ▟ Quadrant upper right and lower left and lower right -Geometric Shapes -Main articles: Geometric Shapes (Unicode block) and Geometric Shapes Extended (Unicode block) -[hide]Code Glyph Description -U+25A0 ■ Black square -U+25A1 □ White square -U+25A2 ▢ White square with rounded corners -U+25A3 ▣ White square containing small black square -U+25A4 ▤ Square with horizontal fill -U+25A5 ▥ Square with vertical fill -U+25A6 ▦ Square with orthogonal crosshatch fill -U+25A7 ▧ Square with upper left to lower right fill -U+25A8 ▨ Square with upper right to lower left fill -U+25A9 ▩ Square with diagonal crosshatch fill -U+25AA ▪ Black small square -U+25AB ▫ White small square -U+25AC ▬ Black rectangle -U+25AD ▭ White rectangle -U+25AE ▮ Black vertical rectangle -U+25AF ▯ White vertical rectangle -U+25B0 ▰ Black parallelogram -U+25B1 ▱ White parallelogram -U+25B2 ▲ Black up-pointing triangle -U+25B3 △ White up-pointing triangle -U+25B4 ▴ Black up-pointing small triangle -U+25B5 ▵ White up-pointing small triangle -U+25B6 ▶ Black right-pointing triangle -U+25B7 ▷ White right-pointing triangle -U+25B8 ▸ Black right-pointing small triangle -U+25B9 ▹ White right-pointing small triangle -U+25BA ► Black right-pointing pointer -U+25BB ▻ White right-pointing pointer -U+25BC ▼ Black down-pointing triangle -U+25BD ▽ White down-pointing triangle -U+25BE ▾ Black down-pointing small triangle -U+25BF ▿ White down-pointing small triangle -U+25C0 ◀ Black left-pointing triangle -U+25C1 ◁ White left-pointing triangle -U+25C2 ◂ Black left-pointing small triangle -U+25C3 ◃ White left-pointing small triangle -U+25C4 ◄ Black left-pointing pointer -U+25C5 ◅ White left-pointing pointer -U+25C6 ◆ Black diamond -U+25C7 ◇ White diamond -U+25C8 ◈ White diamond containing small black diamond -U+25C9 ◉ Fisheye -U+25CA ◊ Lozenge -U+25CB ○ White circle -U+25CC ◌ Dotted circle -U+25CD ◍ Circle with vertical fill -U+25CE ◎ Bullseye -U+25CF ● Black circle -U+25D0 ◐ Circle with left half black -U+25D1 ◑ Circle with right half black -U+25D2 ◒ Circle with lower half black -U+25D3 ◓ Circle with upper half black -U+25D4 ◔ Circle with upper right quadrant black -U+25D5 ◕ Circle with all but upper left quadrant black -U+25D6 ◖ Left half circle black -U+25D7 ◗ Right half black circle -U+25D8 ◘ Inverse bullet -U+25D9 ◙ Inverse white circle -U+25DA ◚ Upper half inverse white circle -U+25DB ◛ Lower half inverse white circle -U+25DC ◜ Upper left quadrant circular arc -U+25DD ◝ Upper right quadrant circular arc -U+25DE ◞ Lower right quadrant circular arc -U+25DF ◟ Lower left quadrant circular arc -U+25E0 ◠ Upper half circle -U+25E1 ◡ Lower half circle -U+25E2 ◢ Black lower right triangle -U+25E3 ◣ Black lower left triangle -U+25E4 ◤ Black upper left triangle -U+25E5 ◥ Black upper right triangle -U+25E6 ◦ White bullet -U+25E7 ◧ Square with left half black -U+25E8 ◨ Square with right half black -U+25E9 ◩ Square with upper left diagonal half black -U+25EA ◪ Square with lower right diagonal half black -U+25EB ◫ White square with vertical bisecting line -U+25EC ◬ White up-pointing triangle with dot -U+25ED ◭ Up-pointing triangle with left half black -U+25EE ◮ Up-pointing triangle with right half black -U+25EF ◯ Large circle -U+25F0 ◰ White square with upper left quadrant -U+25F1 ◱ White square with lower left quadrant -U+25F2 ◲ White square with lower right quadrant -U+25F3 ◳ White square with upper right quadrant -U+25F4 ◴ White circle with upper left quadrant -U+25F5 ◵ White circle with lower left quadrant -U+25F6 ◶ White circle with lower right quadrant -U+25F7 ◷ White circle with upper right quadrant -U+25F8 ◸ Upper left triangle -U+25F9 ◹ Upper right triangle -U+25FA ◺ Lower-left triangle -U+25FB ◻ White medium square -U+25FC ◼ Black medium square -U+25FD ◽ White medium small square -U+25FE ◾ Black medium small square -U+25FF ◿ Lower right triangle - - + * backtrack_lexer: boolean * optional: \`true\` ==> lexer regexes are tested in order and for invoked; * the lexer terminates the scan when a token is returned by the action code. * xregexp: boolean @@ -33342,7 +33149,7 @@ U+25FF ◿ Lower right triangle generatorMixin.generate = function parser_generate(opt) { opt = this.__prepareOptions(opt); - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -33368,19 +33175,19 @@ generatorMixin.generate = function parser_generate(opt) { generatorMixin.generateAMDModule = function generateAMDModule(opt) { opt = this.__prepareOptions(opt); - var module = this.generateModule_(); - var out = [ + let module = this.generateModule_(); + let out = [ this.generateGenericHeaderComment(), '', 'define(function (require) {', module.initCode, module.commonCode, '', - 'var parser = ' + module.moduleCode, + 'let parser = ' + module.moduleCode, module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(lexSrc); out.push('parser.lexer = lexer;'); @@ -33388,7 +33195,7 @@ generatorMixin.generateAMDModule = function generateAMDModule(opt) { out.push('', module.moduleInclude, '', 'return parser;'); out.push('});'); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; }; @@ -33396,35 +33203,35 @@ generatorMixin.generateAMDModule = function generateAMDModule(opt) { lrGeneratorMixin.generateESModule = function generateESModule(opt) { opt = this.__prepareOptions(opt); - var module = this.generateModule_(); - var out = [ + let module = this.generateModule_(); + let out = [ this.generateGenericHeaderComment(), '', module.initCode, module.commonCode, '', - 'var parser = ' + module.moduleCode, - module.modulePostlude, + 'let parser = ' + module.moduleCode, + module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(this.lexer.generateModule()); out.push('parser.lexer = lexer;'); } out.push('', module.moduleInclude, ''); - var exportMain = ''; - var invokeMain = ''; + let exportMain = ''; + let invokeMain = ''; if (!opt.noMain) { - var moduleNameAsCode = String(opt.moduleMain || commonJsMain); - var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); + let moduleNameAsCode = String(opt.moduleMain || commonJsMain); + let moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); out.push(rmCommonWS$5` ${moduleImportsAsCode} - var yymain = ${moduleNameAsCode.trim()}; + let yymain = ${moduleNameAsCode.trim()}; function yyExecMain() { yymain(process.argv.slice(1)); @@ -33460,7 +33267,7 @@ lrGeneratorMixin.generateESModule = function generateESModule(opt) { }; `); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; }; @@ -33468,11 +33275,11 @@ lrGeneratorMixin.generateESModule = function generateESModule(opt) { generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { opt = this.__prepareOptions(opt); - var moduleName = opt.moduleName; - var main = ''; + let moduleName = opt.moduleName; + let main = ''; if (!opt.noMain) { - var moduleNameAsCode = String(opt.moduleMain || commonJsMain); - var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); + let moduleNameAsCode = String(opt.moduleMain || commonJsMain); + let moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); main = rmCommonWS$5` @@ -33487,7 +33294,7 @@ generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { } `; } - var out = this.generateModule(opt) + + let out = this.generateModule(opt) + rmCommonWS$5` @@ -33508,17 +33315,16 @@ generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { generatorMixin.generateModule = function generateModule(opt) { opt = this.__prepareOptions(opt); - var moduleName = opt.moduleName; - var out = this.generateGenericHeaderComment(); + let moduleName = opt.moduleName; + let out = this.generateGenericHeaderComment(); - var self = this; + let self = this; function _generateNamespace(namespaces, previousNamespace, callback) { - var subModuleName = namespaces.shift(); + let subModuleName = namespaces.shift(); if (subModuleName != null) { - var moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; + let moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; if (namespaces.length > 0) { - return 'var ' + subModuleName + ';\n' - + '(function (' + subModuleName + ') {\n' + return '(function (' + subModuleName + ') {\n' + _generateNamespace(namespaces, subModuleName, callback) + '\n})(' + subModuleName + (previousNamespace == null ? '' : ' = ' + moduleName) + ' || (' + moduleName + ' = {}));\n'; } @@ -33527,14 +33333,14 @@ generatorMixin.generateModule = function generateModule(opt) { return ''; } - var sourceCodeDef = self.generateModuleExpr(); + let sourceCodeDef = self.generateModuleExpr(); out += ` ${sourceCodeDef.init} `; out += _generateNamespace(moduleName.split('.'), null, function _generateNamespace_cb(moduleName) { - var name = (moduleName.match(/\./) ? moduleName : 'var ' + moduleName); + let name = (moduleName.match(/\./) ? moduleName : 'let ' + moduleName); return ` ${name} = ${sourceCodeDef.src} `; @@ -33546,24 +33352,23 @@ generatorMixin.generateModule = function generateModule(opt) { generatorMixin.generateModuleExpr = function generateModuleExpr() { - var out; - var opt = this.__prepareOptions(); - var module = this.generateModule_(); + let opt = this.__prepareOptions(); + let module = this.generateModule_(); - out = [ + let out = [ '(function () {', module.commonCode, '', - 'var parser = ' + module.moduleCode, - module.modulePostlude, + 'let parser = ' + module.moduleCode, + module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(lexSrc); out.push('parser.lexer = lexer;'); } - out = out.concat(['', + out = out.concat([ '', module.moduleInclude, '', 'function Parser() {', @@ -33576,7 +33381,7 @@ generatorMixin.generateModuleExpr = function generateModuleExpr() { '})();' ]); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return { @@ -33586,7 +33391,7 @@ generatorMixin.generateModuleExpr = function generateModuleExpr() { }; function removeUnusedKernelFeatures(parseFn, info) { - var actionFn = info.performAction; + let actionFn = info.performAction; if (info.actionsAreAllDefault) { // in this case, there's no need to call the parseAction function at all: @@ -33628,7 +33433,7 @@ function removeUnusedKernelFeatures(parseFn, info) { // if (typeof lexer.yyleng === 'undefined') { // lexer.yyleng = 0; // } - // var yyleng; + // let yyleng; // ... parseFn = parseFn @@ -33647,7 +33452,7 @@ function removeUnusedKernelFeatures(parseFn, info) { // remove: // - // var yylineno; + // let yylineno; // ... parseFn = parseFn @@ -33702,7 +33507,7 @@ function removeUnusedKernelFeatures(parseFn, info) { // remove: // - // var yyloc = lexer.yylloc; + // let yyloc = lexer.yylloc; // lstack[sp] = yyloc; // ... // lstack[sp] = copy_yylloc(lexer.yylloc); @@ -33742,11 +33547,11 @@ function removeUnusedKernelFeatures(parseFn, info) { // } // // and - // + // // if (sp >= 0 && typeof vstack[sp] !== 'undefined') { // retval = vstack[sp]; // } - // + // // but keep the yyval declaration as either location tracking MAY // still be employed by the grammar OR the grammar uses advanced // code which uses `yyval` as a run-time store which carries data @@ -33792,13 +33597,13 @@ function removeUnusedKernelFeatures(parseFn, info) { if (info.actionsAreAllDefault) { // remove // - // var yyval = { + // let yyval = { // $: true, // _$: undefined, // yy: sharedState_yy // }; parseFn = parseFn - .replace(/\s+var yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); + .replace(/\s+let yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); } } @@ -33813,10 +33618,14 @@ function removeUnusedKernelFeatures(parseFn, info) { // remove: // - // var yydebug = false; + // let yydebug = false; // ... and delete yydebug function definition ... // ... // if (yydebug) yydebug(...); + // ... + // if (yydebug) { + // yydebug(...); + // } // // and // @@ -33827,9 +33636,10 @@ function removeUnusedKernelFeatures(parseFn, info) { parseFn = parseFn - .replace(/\s+var yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') - // strip multi-line `if (debug) yydebug(..., {...});` statements + .replace(/\s+let yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') + // strip multi-line `if (debug) { yydebug(..., {...}); }` statements // also strip simple yet possibly multi-line `if (debug) yydebug('...');` statements + .replace(/\n\s+if\s+\(yydebug\)\s+\{[\r\n]+\s+yydebug\([^]+?}\);[\s\r\n]+}\s*/g, '\n\n\n\n\n\n\n\n\n') .replace(/\n\s+if\s+\(yydebug\)\s+yydebug\([^]+?['}]\);[^\r\n]*?/g, '\n\n\n\n\n\n\n\n\n') // strip single-line `yydebug(...);` statements .replace(/^.*?\byydebug\b[^;]+?\);[^\r\n]*?$/gm, '') @@ -33914,8 +33724,8 @@ function removeUnusedKernelFeatures(parseFn, info) { */ parseFn = parseFn .replace(/\s+try \{([\s\r\n]+this\.__reentrant_call_depth[\s\S]+?)\} catch \(ex\) \{[\s\S]+?\} finally \{([^]+?)\}\s+\/\/\s+\/finally/, function replace_noTryCatch(m, p1, p2) { - p1 = p1.replace(/^ /mg, ' '); - p2 = p2.replace(/^ /mg, ' '); + p1 = p1.replace(/^ {8}/mg, ' '); + p2 = p2.replace(/^ {8}/mg, ' '); return '\n' + p1 + '\n // ... AND FINALLY ...\n' + p2; }) .replace(/^[^\n]+\b__reentrant_call_depth\b[^\n]+$/gm, '\n'); @@ -33973,29 +33783,29 @@ function removeUnusedKernelFeatures(parseFn, info) { // // https://github.com/zaach/jison/pull/332 function expandParseArguments(parseFn, self) { - var arglist = self.parseParams; + let arglist = self.parseParams; if (!arglist || arglist.length === 0) { parseFn = parseFn.replace(/, parseParams\b/g, ''); parseFn = parseFn.replace(/\bparseParams\b/g, ''); - parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers:\s+parseParamsAsMembers\b/g, ''); + parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers\b/g, ''); } else { parseFn = parseFn.replace(/, parseParams\b/g, ', ' + arglist.join(', ')); parseFn = parseFn.replace(/\bparseParams\b/g, arglist.join(', ')); - parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers:\s+parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { - var s = ','; + parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { + let s = ','; // determine longest name of the bunch (for formatting the generated code) - var max_k_len = 0; - for (var i = 0, len = arglist.length; i < len; i++) { - var k = arglist[i]; + let max_k_len = 0; + for (let i = 0, len = arglist.length; i < len; i++) { + let k = arglist[i]; max_k_len = Math.max(max_k_len, k.length); } - var wsi2 = (new Array(max_k_len + 1)).join(' '); + let 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 i = 0, len = arglist.length; i < len; i++) { - var k = arglist[i]; + for (let i = 0, len = arglist.length; i < len; i++) { + let k = arglist[i]; s += '\n' + ws + k + ': ' + k + (i < len - 1 ? ',' + wsi2.substr(0, max_k_len - k.length - 1) : wsi2.substr(0, max_k_len - k.length)) + ' // parseParams::' + k; } return s; @@ -34030,17 +33840,17 @@ function pickOneOfTwoCodeAlternatives(parseFn, pick_A_not_B, A_start_marker, B_s } function addOrRemoveTokenStack(fn, wantTokenStack) { - var parseFn = fn; + let parseFn = fn; // We don't use the Esprima+Escodegen toolchain as those loose the code comments easily; // instead we just chop the code using labels as sentinels for our chopping-it-up regexes: // // if (wantTokenStack) { // try { - // var ast = esprima.parse(parseFn); - // var stackAst = esprima.parse(String(tokenStackLex)).body[0]; + // let ast = esprima.parse(parseFn); + // let stackAst = esprima.parse(String(tokenStackLex)).body[0]; // stackAst.id.name = 'lex'; // - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); // // labeled[0].body = stackAst; // @@ -34050,7 +33860,7 @@ function addOrRemoveTokenStack(fn, wantTokenStack) { // } // } else { // // remove the line: - // // var tstack = []; // token stack + // // let tstack = []; // token stack // parseFn = parseFn.replace(/tstack = .*$/m, ''); // return parseFn; // } @@ -34059,23 +33869,23 @@ function addOrRemoveTokenStack(fn, wantTokenStack) { if (wantTokenStack) { // And rename the `tokenStackLex` function to become the new `lex`: return parseFn.replace(/\btokenStackLex\b/g, 'lex'); - } else { - // Also nuke the support declaration statement: - // var tstack = []; - return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); } + // Also nuke the support declaration statement: + // let tstack = []; + return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); + } // returns parse function with/without error recovery code function pickErrorHandlingChunk(fn, hasErrorRecovery) { - var parseFn = fn; + let parseFn = fn; // We don't use the Esprima+Escodegen toolchain as those loose the code comments easily; // instead we just chop the code using labels as sentinels for our chopping-it-up regexes: // try { - // var ast = esprima.parse(parseFn); + // let ast = esprima.parse(parseFn); - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("' + + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("' + // (!hasErrorRecovery ? '_handle_error_with_recovery' : '_handle_error_no_recovery') + // '"))', ast); // Jison.print('labeled: ', labeled); @@ -34091,7 +33901,7 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // and some post-coital touch-ups: if (!hasErrorRecovery) { // Also nuke the support declaration statement: - // var recovering = 0; + // let recovering = 0; // and the recovery support statements: // if (recovering > 0) { // recovering--; @@ -34100,7 +33910,7 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // , recovering: recovering // ASSERT(recovering === 0); parseFn = parseFn - .replace(/^\s*var recovering.*$/gm, '') + .replace(/^\s*let recovering.*$/gm, '') .replace(/, recovering: recovering/g, '') .replace(/^.*?recovering =.*$/gm, '') .replace(/^\s+recovering[,]?\s*$/gm, '') @@ -34112,11 +33922,11 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // ... KILL this chunk ... // } .replace(/\s+if[^a-z]+preErrorSymbol.*?\{\s*\/\/[^\n]+([\s\S]+?)\} else \{[\s\S]+?\}\n\s+\}\n/g, '\n$1\n\n\n\n') - .replace(/^\s+(?:var )?preErrorSymbol = .*$/gm, '') + .replace(/^\s+(?:let )?preErrorSymbol = .*$/gm, '') .replace(/^.*?\bpreErrorSymbol =.*$/gm, '') // And nuke the support declaration statement: - // var lastEofErrorStateDepth = 0; - .replace(/^\s*var lastEofErrorStateDepth.*$/gm, ''); + // let lastEofErrorStateDepth = 0; + .replace(/^\s*let lastEofErrorStateDepth.*$/gm, ''); } return parseFn; } @@ -34125,7 +33935,7 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // - module.commonCode: initialization code that should be placed before the module // - module.moduleCode: code that creates the module object lrGeneratorMixin.generateModule_ = function generateModule_() { - var parseFn = String(parser$4.parse); + let parseFn = String(parser$4.parse); parseFn = pickErrorHandlingChunk(parseFn, this.hasErrorRecovery); parseFn = addOrRemoveTokenStack(parseFn, this.options.tokenStack); @@ -34134,9 +33944,9 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { parseFn = expandParseArguments(parseFn, this); - var errorClassCode = this.generateErrorClass(); + let errorClassCode = this.generateErrorClass(); - var exportDest = this.options.exportAllTables; + let exportDest = this.options.exportAllTables; assert__default['default'](exportDest); // store the parse tables: @@ -34144,10 +33954,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { exportDest.defaultParseActions = this.defaultActions; exportDest.parseProductions = this.productions_; - var exportSourceCode = this.options.exportSourceCode; - assert__default['default'](exportSourceCode); - - var tableCode; + let tableCode; switch (this.options.compressTables | 0) { case 0: // no compression tableCode = this.generateTableCode0(this.table, this.defaultActions, this.productions_); @@ -34170,29 +33977,27 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // Generate the initialization code - var initCode = [].concat( + let initCode = [].concat( this.moduleInit.getInitCodeSection('imports'), this.moduleInit.getInitCodeSection('init') ); - var commonCode = [].concat( + let commonCode = [].concat( this.moduleInit.getInitCodeSection('required'), errorClassCode.commonCode, errorClassCode.moduleCode, - ['\nYY_REMAINING_INIT_CODE_SECTIONS_GO_HERE\n'], + [ '\nYY_REMAINING_INIT_CODE_SECTIONS_GO_HERE\n' ], tableCode.commonCode ); - // sort hash table by key to produce a nicer output: function produceSymbolTable(tbl) { - var a = Object.keys(tbl); + let a = Object.keys(tbl); a.sort(); - var nt = {}; - var k; - for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; + let nt = {}; + for (let i = 0, len = a.length; i < len; i++) { + let k = a[i]; // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number // and we do not want `$eof`/`EOF` to show up in the symbol tables of generated parsers @@ -34206,12 +34011,11 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // swap key and value and then sort hash table by key to produce a nicer output: function produceTerminalTable(tbl) { - var a = Object.keys(tbl); - var nt = {}; - var k, v; - for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; - v = tbl[k]; + let a = Object.keys(tbl); + let nt = {}; + for (let i = 0, len = a.length; i < len; i++) { + let k = a[i]; + let v = tbl[k]; nt[v] = +k; // convert numeric key back to number type; all terminals have numeric keys } return produceSymbolTable(nt); @@ -34219,71 +34023,71 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { function produceProductionsForDebugging(options, symbols, base) { function get_orig_symbol(s) { - var a = s.split(':'); + let a = s.split(':'); if (a.length === 1 || a[0] === '') { return { state: -1, symbol: s }; } - var state = a[0]; + let state = a[0]; a.shift(); return { state: +state, - symbol: a.join(':'), + symbol: a.join(':') }; } function get_orig_symbol_set(arr) { - var rv = {}; - for (var i = 0, len = arr.length; i < len; i++) { - var item = arr[i]; - var symbol = get_orig_symbol(item); + let rv = {}; + for (let i = 0, len = arr.length; i < len; i++) { + let item = arr[i]; + let symbol = get_orig_symbol(item); rv[symbol.symbol] = symbol.state; } return Object.keys(rv); } - var tbl = this.nonterminals; - var sym = this.symbols_ || symbols; + let tbl = this.nonterminals; + let sym = this.symbols_ || symbols; if (!options.outputDebugTables && !options.exportAllTables.enabled) { return undefined; } - var prods = { + let prods = { ids: {}, states: {}, rules: {}, nonterminals: {}, symbols: {}, first: {}, - follows: {}, + follows: {} }; - var self = this; + let self = this; this.productions.forEach(function Follow_prod_forEach_genDebugTable(production, k) { - var nonterm = production.symbol; + let nonterm = production.symbol; prods.states[k] = nonterm; prods.ids[nonterm] = sym[nonterm]; - var lst = prods.rules[nonterm] || {}; + let lst = prods.rules[nonterm] || {}; lst[k] = gen_lalr_states_production(production, k, false, k, true); prods.rules[nonterm] = lst; }); function gen_nonterminal(nt) { - var l = nt.productions._items; - var lst = l.map(function (p, i) { + let l = nt.productions._items; + let lst = l.map(function (p, i) { return gen_lalr_states_production(p, i, false, false, false); }); - var rv = { + let rv = { symbol: nt.symbol, productions: lst, first: nt.first, base_first: get_orig_symbol_set(nt.first), follows: nt.follows, base_follows: get_orig_symbol_set(nt.follows), - nullable: nt.nullable, + nullable: nt.nullable }; // clean up structure: ditch superfluous elements: @@ -34297,7 +34101,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { return rv; } - for (var key in tbl) { + for (let key in tbl) { prods.nonterminals[key] = gen_nonterminal(tbl[key]); } @@ -34306,9 +34110,9 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { } function gen_lalr_states_production(production, index, dotPosition, state, patch_base) { - var nonterm = production.symbol; - var hlen = production.handle.length; - var rulestr = production.handle.map(function (t, idx) { + let nonterm = production.symbol; + let hlen = production.handle.length; + let rulestr = production.handle.map(function (t, idx) { if (!t) { t = '%epsilon'; } @@ -34322,7 +34126,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { rulestr += ' ⬤'; } - var base_rulestr = production.handle.map(function (t) { + let base_rulestr = production.handle.map(function (t) { if (!t) { t = '%epsilon'; } @@ -34330,7 +34134,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { return t; }).join(' '); - var rv = { + let rv = { symbol: nonterm, base_symbol: get_orig_symbol(nonterm).symbol, handle: rulestr, @@ -34349,12 +34153,11 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { }; // Determine state for given production, if it's not a production that's listed as part of a state: - var chk, idx; - var lst = prods.rules[nonterm]; - chk = rv.symbol + ' : ' + rv.handle; - for (idx in lst) { + let lst = prods.rules[nonterm]; + let chk = rv.symbol + ' : ' + rv.handle; + for (let idx in lst) { idx = +idx; - var p = lst[idx]; + let p = lst[idx]; if (p) { if (p.symbol + ' : ' + p.handle === chk) { assert__default['default'](rv.state === -1); @@ -34367,9 +34170,9 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // Try to reference base productions from newg child productions and vice versa: chk = rv.base_symbol + ' : ' + rv.base_handle; if (base && base.rules) { - var pr = base.rules[rv.base_symbol]; - for (idx in pr) { - var bprod = pr[idx]; + let pr = base.rules[rv.base_symbol]; + for (let idx in pr) { + let bprod = pr[idx]; if (bprod.symbol + ' : ' + bprod.handle === chk) { assert__default['default'](rv.base_state === -1); rv.base_state = bprod.state; @@ -34403,13 +34206,13 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { if (this.states) { prods.lalr_states = []; - var these_states = this.states; + let these_states = this.states; these_states.forEach(function traverse_states(state, i) { //assert(state.inadequate ? these_states.inadequate : true); state.forEach(function traverse_state(item, j) { // is this a REDUCE state? - var nterm_first = self.nonterminals[item.production.symbol].first; - var rv = { + let nterm_first = self.nonterminals[item.production.symbol].first; + let rv = { state: i, item_index: j, is_reduce_state: (item.dotPosition === item.production.handle.length), @@ -34422,7 +34225,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { nterm_first: nterm_first, base_nterm_first: get_orig_symbol_set(nterm_first), prod_first: item.production.first, - base_prod_first: get_orig_symbol_set(item.production.first), + base_prod_first: get_orig_symbol_set(item.production.first) }; // clean up structure: ditch superfluous elements: @@ -34441,13 +34244,12 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { }); } - var nt = tbl; - var sbn; - for (sbn in nt) { - var orig_symbol = get_orig_symbol(sbn); - var item = nt[sbn]; - var firsts = item.first; - var follows = item.follows; + let nt = tbl; + for (let sbn in nt) { + let orig_symbol = get_orig_symbol(sbn); + let item = nt[sbn]; + let firsts = item.first; + let follows = item.follows; if (!prods.symbols[orig_symbol.symbol]) { prods.symbols[orig_symbol.symbol] = orig_symbol.state; } @@ -34462,10 +34264,10 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { prods.follows[orig_symbol.symbol] = prods.follows[orig_symbol.symbol].concat(follows); } } - for (sbn in prods.first) { + for (let sbn in prods.first) { prods.first[sbn] = get_orig_symbol_set(prods.first[sbn]); } - for (sbn in prods.follows) { + for (let sbn in prods.follows) { prods.follows[sbn] = get_orig_symbol_set(prods.follows[sbn]); } @@ -34476,11 +34278,11 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { } function produceTerminalDescriptions(tbl, sym) { - var rv = {}; - var count = 0; - for (var k in tbl) { - var descr = tbl[k]; - var id = sym[k]; + let rv = {}; + let count = 0; + for (let k in tbl) { + let descr = tbl[k]; + let id = sym[k]; if (id && descr && descr !== id) { rv[id] = descr; count++; @@ -34490,56 +34292,56 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - type: 0, // CLI: --parserType option - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - numExpectedConflictStates: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - json: 1, - _: 1, - noMain: 1, - moduleMain: 1, - moduleMainImports: 1, - noDefaultResolve: 1, - defaultActionMode: 1, - testCompileActionCode: 1, - noTryCatch: 1, - hasPartialLrUpgradeOnConflict: 0, - compressTables: 1, - outputDebugTables: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - lexfile: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - exportAllTables: 1, - exportSourceCode: 1, - tokenStack: 0, - parserErrorsAreRecoverable: 0, - lexerErrorsAreRecoverable: 1, - showSource: 1, - exportAST: 1, - prettyCfg: 1, - - errorRecoveryTokenDiscardCount: 0, - - warn_cb: 0, // function(msg) | true (= use Jison.Print) | false (= throw Exception) - - parseParams: 1, - ranges: 0, + let obj = {}; + let do_not_pass = { + type: 0, // CLI: --parserType option + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + numExpectedConflictStates: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + json: 1, + _: 1, + noMain: 1, + moduleMain: 1, + moduleMainImports: 1, + noDefaultResolve: 1, + defaultActionMode: 1, + testCompileActionCode: 1, + noTryCatch: 1, + hasPartialLrUpgradeOnConflict: 0, + compressTables: 1, + outputDebugTables: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + lexfile: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + exportAllTables: 1, + exportSourceCode: 1, + tokenStack: 0, + parserErrorsAreRecoverable: 0, + lexerErrorsAreRecoverable: 1, + showSource: 1, + exportAST: 1, + prettyCfg: 1, + + errorRecoveryTokenDiscardCount: 0, + + warn_cb: 0, // function(msg) | true (= use Jison.Print) | false (= throw Exception) + + parseParams: 1, + ranges: 0 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -34551,12 +34353,12 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // And now some options which should receive some special processing: if (!obj.hasPartialLrUpgradeOnConflict) { - // only list this option when it's actually TRUE: - delete obj.hasPartialLrUpgradeOnConflict; + // only list this option when it's actually TRUE: + delete obj.hasPartialLrUpgradeOnConflict; } - var pre = obj.pre_parse; - var post = obj.post_parse; + let pre = obj.pre_parse; + let post = obj.post_parse; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_parse = true; @@ -34565,7 +34367,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { obj.post_parse = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$3})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_parse: true(,)?$/gm, function (m, ls, tc) { @@ -34579,27 +34381,27 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // Generate the module creation code - var termDescrs = produceTerminalDescriptions(this.descriptions_, this.symbols_); + let termDescrs = produceTerminalDescriptions(this.descriptions_, this.symbols_); exportDest.terminalDescriptions = termDescrs; - var descrLst = JSON.stringify(termDescrs, null, 2); + let descrLst = JSON.stringify(termDescrs, null, 2); if (descrLst) { descrLst = descrLst.replace(/"([0-9]+)":/g, '$1:'); } - var rules4Dbg = produceProductionsForDebugging.call(this, this.options); + let rules4Dbg = produceProductionsForDebugging.call(this, this.options); exportDest.parseRules = rules4Dbg; - var rulesLst = ((this.options.outputDebugTables || this.options.exportAllTables.enabled) ? JSON.stringify(rules4Dbg, null, 2) : undefined); + let rulesLst = ((this.options.outputDebugTables || this.options.exportAllTables.enabled) ? JSON.stringify(rules4Dbg, null, 2) : undefined); if (rulesLst) { rulesLst = rulesLst.replace(/"([0-9]+)":/g, '$1:').replace(/^(\s+)"([a-z_][a-z_0-9]*)":/gmi, '$1$2:'); } - var symbolTable = produceSymbolTable(this.symbols_); + let symbolTable = produceSymbolTable(this.symbols_); exportDest.symbolTable = symbolTable; // produce a hash lookup table from the terminal set exportDest.terminalTable = produceTerminalTable(this.terminals_); - var moduleCode = `{ + let moduleCode = `{ // Code Generator Information Report // --------------------------------- // @@ -34663,22 +34465,22 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { 'yy: {}', 'options: ' + produceOptions(this.options), 'symbols_: ' + JSON.stringify(symbolTable, null, 2), - 'terminals_: ' + JSON.stringify(this.terminals_, null, 2).replace(/"([0-9]+)":/g, '$1:'), + 'terminals_: ' + JSON.stringify(this.terminals_, null, 2).replace(/"([0-9]+)":/g, '$1:') ].concat( rulesLst ? - 'nonterminals_: ' + rulesLst : - [] + 'nonterminals_: ' + rulesLst : + [] ).concat( descrLst ? - 'terminal_descriptions_: ' + descrLst : - [] + 'terminal_descriptions_: ' + descrLst : + [] ).concat([ define_parser_APIs_1.trim(), 'productions_: ' + tableCode.productionsCode ]).concat( String(this.performAction).trim() !== '' ? - 'performAction: ' + String(this.performAction) : - [] + 'performAction: ' + String(this.performAction) : + [] ).concat([ 'table: ' + tableCode.tableCode, 'defaultActions: ' + tableCode.defaultActionsCode, @@ -34686,24 +34488,24 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { 'parse: ' + parseFn.trim() ]).concat( this.actionsUseYYERROR ? - 'yyError: 1' : - [] + 'yyError: 1' : + [] ).concat( this.actionsUseYYRECOVERING ? - 'yyRecovering: 1' : - [] + 'yyRecovering: 1' : + [] ).concat( this.actionsUseYYERROK ? - 'yyErrOk: 1' : - [] + 'yyErrOk: 1' : + [] ).concat( this.actionsUseYYCLEARIN ? - 'yyClearIn: 1' : - [] + 'yyClearIn: 1' : + [] ).join(',\n'); moduleCode += '\n};'; - var exportSourceCode = this.options.exportSourceCode; + const exportSourceCode = this.options.exportSourceCode; assert__default['default'](exportSourceCode); exportSourceCode.parserChunks = { initCode: expandConstantsInGeneratedCode(initCode.join('\n'), this), @@ -34711,8 +34513,8 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { moduleCode: expandConstantsInGeneratedCode(moduleCode, this), modulePostlude: [ 'parser.originalParseError = parser.parseError;', - 'parser.originalQuoteName = parser.quoteName;', - ].join('\n'), + 'parser.originalQuoteName = parser.quoteName;' + ].join('\n'), moduleInclude: expandConstantsInGeneratedCode(this.moduleInclude, this) }; return exportSourceCode.parserChunks; @@ -34726,8 +34528,6 @@ lrGeneratorMixin.generateErrorClass = function () { // 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. function JisonParserError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -34744,9 +34544,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -34784,14 +34584,14 @@ JisonParserError.prototype.name = 'JisonParserError'; // Generate code that represents the specified parser table lrGeneratorMixin.generateTableCode0 = function (table, defaultActions, productions) { - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); // Don't surround numerical property name numbers in quotes tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); - var prelude = []; + let prelude = []; // Return the variable initialization code and the table code return { @@ -34804,10 +34604,10 @@ lrGeneratorMixin.generateTableCode0 = function (table, defaultActions, productio // Function that extends an object with the given value for all given keys // e.g., x([1, 3, 4], [6, 7], { x: 1, y: 2 }) = { 1: [6, 7]; 3: [6, 7], 4: [6, 7], x: 1, y: 2 } -var compressor1ObjectCode = ` +let compressor1ObjectCode = ` function x(k, v, o) { o = o || {}; - for (var l = k.length; l--; ) { + for (let l = k.length; l--; ) { o[k[l]] = v; } return o; @@ -34816,10 +34616,10 @@ function x(k, v, o) { // Generate code that represents the specified parser table lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productions) { - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); - var usesCompressor = false; + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); + let usesCompressor = false; // Don't surround numerical property name numbers in quotes tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); @@ -34828,22 +34628,21 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio // e.g., { 1: [6, 7]; 3: [6, 7], 4: [6, 7], 5: 8 } = x([1, 3, 4], [6, 7], { 5: 8 }) tableCode = tableCode.replace(/\{[\s\r\n]*\d+:[^\}]+,[\s\r\n]*\d+:[^\}]+\}/g, function (object) { // Find the value that occurs with the highest number of keys - var value, frequentValue, key, - keys = {}, - keyCount, - maxKeyCount = 0, - keyValue, - keyValues = [], - keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; + let frequentValue; + let keys = {}; + let maxKeyCount = 0; + let keyValue; + let keyValues = []; + let keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; while ((keyValue = keyValueMatcher.exec(object))) { // For each value, store the keys where that value occurs - key = keyValue[1]; - value = keyValue[2].trim(); - keyCount = 1; + let key = keyValue[1]; + let value = keyValue[2].trim(); + let keyCount = 1; if (!(value in keys)) { - keys[value] = [key]; + keys[value] = [ key ]; } else { keyCount = keys[value].push(key); } @@ -34856,9 +34655,9 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio // Construct the object with a function call if the most frequent value occurs multiple times if (maxKeyCount > 1) { // Collect all non-frequent values into a remainder object - for (value in keys) { + for (let value in keys) { if (value !== frequentValue) { - for (var k = keys[value], i = 0, l = k.length; i < l; i++) { + for (let k = keys[value], i = 0, l = k.length; i < l; i++) { keyValues.push(k[i] + ':' + value); } } @@ -34872,10 +34671,10 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio }); // Count occurrences of number lists - var list; - var lists = {}; - var listMatcher = /\[[0-9,]+\]/g; - var frequentLists = []; + let list; + let lists = {}; + let listMatcher = /\[[0-9,]+\]/g; + let frequentLists = []; while ((list = listMatcher.exec(tableCode))) { lists[list] = (lists[list] || 0) + 1; @@ -34883,7 +34682,7 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio // Replace frequently occurring number lists with variables tableCode = tableCode.replace(listMatcher, function (list) { - var listId = lists[list]; + let listId = lists[list]; // If listId is a number, it represents the list's occurrence frequency if (typeof listId === 'number') { // If the list does not occur frequently, represent it by the list @@ -34898,7 +34697,7 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio return listId; }); - var prelude = []; + let prelude = []; // Only include the expander function when it's actually used // (tiny grammars don't have much state duplication, so this shaves off @@ -34909,7 +34708,7 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio } if (frequentLists.length > 0) { - prelude.push('var u = [\n ' + frequentLists.join(',\n ') + '\n];'); + prelude.push('let u = [\n ' + frequentLists.join(',\n ') + '\n];'); prelude.push(''); } @@ -34928,9 +34727,9 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio throw new Error("Table Compression mode 2 corrupts the table when the 'noDefaultResolve' option is turned on and one or more conflicts occur. Please use a different compression mode and/or disable this option."); } - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); // We know a couple of things about the parse table: // @@ -34958,33 +34757,29 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); - - function reportColumnsForCompression(def_arr) { - var i, key, len; - var report = []; + let report = []; - len = 0; - for (key in def_arr) { + let len = 0; + for (let key in def_arr) { len = Math.max(len, def_arr[key].length); } - var col_width = 6; - var col_delta_width = 4; + let col_width = 6; + let col_delta_width = 4; function clip(val, width) { - var s = ' ' + val; + let s = ' ' + val; s = s.substr(s.length - width); return s; } - var track_prev4delta = {}; - var c, delta, val, delta_val; - var line = []; + let track_prev4delta = {}; + let line = []; line.push('║'); - for (c in def_arr) { - key = clip(c, col_width); - delta = clip('∆', col_delta_width); + for (let c in def_arr) { + let key = clip(c, col_width); + let delta = clip('∆', col_delta_width); line.push(key); line.push('┊'); line.push(delta); @@ -34994,12 +34789,13 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } report.push(line.join('')); - for (i = 0; i < len; i++) { + for (let i = 0; i < len; i++) { line = []; line.push('║'); - for (c in def_arr) { - var tbl = def_arr[c]; + for (let c in def_arr) { + let val, delta_val; + let tbl = def_arr[c]; if (tbl.length > i) { val = tbl[i] || 0; @@ -35014,8 +34810,8 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio delta_val = '.'; } - key = clip(val, col_width); - delta = clip(delta_val, col_delta_width); + let key = clip(val, col_width); + let delta = clip(delta_val, col_delta_width); line.push(key); line.push('┊'); line.push(delta); @@ -35031,16 +34827,16 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // table is array of 1/2-len arrays: function analyzeTableForCompression(table) { // column: productions' row length - var len_col = []; + let len_col = []; // column: productions' shift size / action column - var pop_col = []; + let pop_col = []; // column: rule number for each slot ('rule'): - var rule_col = []; + let rule_col = []; - var i; - var row_count = table.length; + let i; + let row_count = table.length; for (i = 0; i < row_count; i++) { - var prod = table[i]; + let prod = table[i]; len_col.push(prod.length); assert__default['default'](prod.length <= 2); @@ -35051,10 +34847,10 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio rule_col.push(prod[1]); } - var def_arr = { - 'len': len_col, - 'pop': pop_col, - 'rule': rule_col, + let def_arr = { + len: len_col, + pop: pop_col, + rule: rule_col }; return def_arr; } @@ -35065,14 +34861,14 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // table is hash of 1/2-len arrays: function analyzeSetForCompression(table) { // column: row index - var idx_col = []; + let idx_col = []; // column: REDUCE productions' goto column - var goto_col = []; + let goto_col = []; - var i; + let i; for (i in table) { i = +i; - var prod = table[i]; + let prod = table[i]; idx_col.push(i); // and the special knowledge about the defaultActions[] table: @@ -35080,9 +34876,9 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio goto_col.push(prod); } - var def_arr = { - 'idx': idx_col, - 'goto': goto_col, + let def_arr = { + idx: idx_col, + goto: goto_col }; return def_arr; } @@ -35091,30 +34887,29 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function analyzeGotoTableForCompression(table) { // column: number of symbol hash entries per state slot ('length'): - var len_col = []; + let len_col = []; // column: symbol hash entry key for each slot ('symbol'): - var symbol_col = []; + let symbol_col = []; // column: symbol hash entry value type: number (0) or array (array.length) ('type'): - var type_col = []; + let type_col = []; // column: symbol hash entry value if single GOTO state number ('state'): - var state_col = []; + let state_col = []; // column: symbol hash entry mode value if array slot type (reduce/shift/accept): - var mode_col = []; + let mode_col = []; // column: symbol hash entry goto state value if array slot type: - var goto_col = []; + let goto_col = []; // // column: merged: state_col + goto_col: - // var next_col = []; - - var row_count = table.length; - for (var state = 0; state < row_count; state++) { - var hashtable = table[state]; - var count = 0; - var symbol; - for (symbol in hashtable) { + // let next_col = []; + + let row_count = table.length; + for (let state = 0; state < row_count; state++) { + let hashtable = table[state]; + let count = 0; + for (let symbol in hashtable) { symbol = +symbol; symbol_col.push(symbol); - var slot = hashtable[symbol]; + let slot = hashtable[symbol]; if (slot && slot.length) { // array type slot: assert__default['default'](slot.length === 2 || slot.length === 1); @@ -35141,40 +34936,40 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio len_col.push(count); } - var def_arr = { - 'len': len_col, - 'symbol': symbol_col, - 'type': type_col, - 'state': state_col, - 'mode': mode_col, - 'goto': goto_col, + let def_arr = { + len: len_col, + symbol: symbol_col, + type: type_col, + state: state_col, + mode: mode_col, + goto: goto_col //'next': next_col, }; return def_arr; } - var has_compressed_a_table = false; + let has_compressed_a_table = false; function generateColumn(name, col) { - var rv = []; - var i, j, len, l; + let rv = []; - for (i = 0, len = col.length; i < len; i++) { + for (let i = 0, len = col.length; i < len; i++) { // try basic run-length encoding first: - var v = col[i]; + let v = col[i]; + let j; for (j = i + 1; j < len; j++) { if (col[j] !== v) { break; } } - var runlength = j - i; + let runlength = j - i; // try stepped run-length encoding next: - var delta = col[i + 1] - v; - var steplength = 0; + let delta = col[i + 1] - v; + let steplength = 0; // we don't want to replicate the runlength result, so only look for a match // when delta !== 0: @@ -35188,10 +34983,11 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } // try to match the pattern in history: - var best_pos = 0; - var best_len = 0; - var upper_bound = i - 2; + let best_pos = 0; + let best_len = 0; + let upper_bound = i - 2; for (j = 0; j < upper_bound; j++) { + let l; for (l = 0; col[j + l] === col[i + l]; l++) { // No need to check for: // if (j + l === i) break; @@ -35215,28 +35011,24 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } // weight our options now: - var gain = [ + let gain = [ runlength - 2, steplength - 3, best_len - 2 ]; - var optimum_gain = Math.max.apply(null, gain); + let optimum_gain = Math.max.apply(null, gain); if (optimum_gain <= 0) { rv.push(v); - } - else if (optimum_gain === gain[0]) { + } else if (optimum_gain === gain[0]) { rv.push('s', '[' + v + ', ' + runlength + ']'); i += runlength - 1; - } - else if (optimum_gain === gain[1]) { + } else if (optimum_gain === gain[1]) { rv.push('s', '[' + v + ', ' + steplength + ', ' + delta + ']'); i += steplength - 1; - } - else if (optimum_gain === gain[2]) { + } else if (optimum_gain === gain[2]) { rv.push('c', '[' + best_pos + ', ' + best_len + ']'); i += best_len - 1; - } - else { + } else { rv.push(v); //assert(0); // should never get here! } @@ -35246,11 +35038,11 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } } - var code = [ + let code = [ ' ', name, ': ', 'u([', '\n ', - rv.join(',\n '), // JSON.stringify(col, null, 2), + rv.join(',\n '), // JSON.stringify(col, null, 2), '\n', '])' ].join(''); @@ -35259,7 +35051,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function generateCompressedTable(def_arr) { - var code = [ + let code = [ 'bp({', generateColumn('pop', def_arr.pop) + ',', generateColumn('rule', def_arr.rule), @@ -35270,7 +35062,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function generateCompressedSet(def_arr) { - var code = [ + let code = [ 'bda({', generateColumn('idx', def_arr.idx) + ',', generateColumn('goto', def_arr.goto), @@ -35281,7 +35073,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function generateCompressedGotoTable(def_arr) { - var code = [ + let code = [ 'bt({', generateColumn('len', def_arr.len) + ',', generateColumn('symbol', def_arr.symbol) + ',', @@ -35295,18 +35087,18 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } - var tableDef = analyzeGotoTableForCompression(table); - var defaultActionsDef = analyzeSetForCompression(defaultActions); - var productionsDef = analyzeTableForCompression(productions); + let tableDef = analyzeGotoTableForCompression(table); + let defaultActionsDef = analyzeSetForCompression(defaultActions); + let productionsDef = analyzeTableForCompression(productions); const bp_code_container = ` // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -35319,11 +35111,11 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio const bda_code_container = ` // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -35333,18 +35125,18 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio const bt_code_container = ` // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -35375,7 +35167,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // \`this\` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -35392,9 +35184,9 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -35408,25 +35200,25 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio `; has_compressed_a_table = false; - var tc = generateCompressedGotoTable(tableDef); - var compressGotoTable = has_compressed_a_table; + let tc = generateCompressedGotoTable(tableDef); + let compressGotoTable = has_compressed_a_table; has_compressed_a_table = false; - var dac = generateCompressedSet(defaultActionsDef); - var compressDefaultActions = has_compressed_a_table; + let dac = generateCompressedSet(defaultActionsDef); + let compressDefaultActions = has_compressed_a_table; has_compressed_a_table = false; - var pc = generateCompressedTable(productionsDef); - var compressProductions = has_compressed_a_table; + let pc = generateCompressedTable(productionsDef); + let compressProductions = has_compressed_a_table; - var compressAnything = (compressProductions || compressDefaultActions || compressGotoTable); + let compressAnything = (compressProductions || compressDefaultActions || compressGotoTable); tableCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(tableDef) : '') + (compressGotoTable ? tc : tableCode); defaultActionsCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(defaultActionsDef) : '') + (compressDefaultActions ? dac : defaultActionsCode); productionsCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(productionsDef) : '') + (compressProductions ? pc : productionsCode); - var prelude = [ + let prelude = [ '', compressProductions ? bp_code_container : '', '', @@ -35434,7 +35226,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio '', compressGotoTable ? bt_code_container : '', '', - c_s_u_code_container, + c_s_u_code_container ]; if (!compressAnything) { prelude = []; @@ -35450,31 +35242,29 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio }; // --- START of commonJsMain chunk --- -// +// // default main method for generated commonjs modules const commonJsMain = ` -function (args) { - "use strict"; - +function __jison_default_main__(args) { // When the parser comes with its own \`main\` function, then use that one: if (typeof exports.parser.main === 'function') { - return exports.parser.main(args); + return exports.parser.main(args); } if (!args[1]) { console.log('Usage:', path.basename(args[0]) + ' FILE'); process.exit(1); } - var source = fs.readFileSync(path.normalize(args[1]), 'utf8'); - var dst = exports.parser.parse(source); + const source = fs.readFileSync(path.normalize(args[1]), 'utf8'); + const dst = exports.parser.parse(source); console.log('parser output:\\n\\n', { type: typeof dst, value: dst }); try { - console.log("\\n\\nor as JSON:\\n", JSON.stringify(dst, null, 2)); + 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... */ } - var rv = 0; + let rv = 0; if (typeof dst === 'number' || typeof dst === 'boolean') { rv = dst; } @@ -35484,16 +35274,16 @@ function (args) { // --- END of commonJsMain chunk --- const commonJsMainImports = ` -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); `; // debug mixin for LR parser generators function printAction(a, gen) { - var s = a[0] === SHIFT ? 'shift token (then go to state ' + a[1] + ')' : + let s = a[0] === SHIFT ? 'shift token (then go to state ' + a[1] + ')' : a[0] === REDUCE ? 'reduce by rule: ' + gen.productions[a[1]] : - a[0] === ACCEPT ? 'accept' : 'UNDEFINED ACTION: ' + a[0]; + a[0] === ACCEPT ? 'accept' : 'UNDEFINED ACTION: ' + a[0]; return s; } @@ -35507,13 +35297,13 @@ function traceStates(trace, states, title) { trace('\n'); } -var lrGeneratorDebug = { +const lrGeneratorDebug = { beforeparseTable: function () { this.trace('Building parse table.'); }, afterparseTable: function () { - var trace = this.trace; - var self = this; + let trace = this.trace; + let self = this; if (this.conflicts > 0) { trace('\nConflicts:\n'); this.resolutions.forEach(function (r, i) { @@ -35525,21 +35315,21 @@ var lrGeneratorDebug = { } trace('Done.\n'); }, - aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */ ) { + aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */) { traceStates(this.trace, states, 'as produced by LR::canonicalCollection()'); } }; -var parser$4 = typal.beget(); +const parser$4 = typal.beget(); generatorMixin.createParser = function createParser() { - var sourceCodeDef = this.generateModuleExpr(); + let sourceCodeDef = this.generateModuleExpr(); // produce a chunk of sourcecode that's suitable for evaluation through `eval()`: - var sourcecode = rmCommonWS$5` + let sourcecode = rmCommonWS$5` ${sourceCodeDef.init} - var yy__parser = ${sourceCodeDef.src}; + let yy__parser = ${sourceCodeDef.src}; // produce the generated parser function/class as the last value // in this chunk of code so that we can be sure to produce *that* @@ -35550,15 +35340,15 @@ generatorMixin.createParser = function createParser() { yy__parser; `; - var p = code_exec$2(sourcecode, function generated_code_exec_wrapper_jison(sourcecode) { + let 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); - var rv = eval(sourcecode); + let rv = eval(sourcecode); return rv; }, mkStdOptions$1(this.options, { dumpSourceCodeOnFailure: this.DEBUG, throwErrorOnCompileFailure: true - }), "parser"); + }), 'parser'); assert__default['default'](typeof p === 'object'); assert__default['default'](typeof p.parse === 'function'); assert__default['default'](typeof p.parser === 'undefined'); @@ -35602,7 +35392,7 @@ generatorMixin.createParser = function createParser() { } p.sourceCode = sourceCodeDef; - var self = this; + let self = this; function bind(method) { return function () { self.lexer = p.lexer; @@ -35629,8 +35419,6 @@ parser$4.error = generator.error; // --- START parser Error class chunk --- const parseErrorSourceCode = ` function parseError(str, hash, ExceptionClass) { - "use strict"; - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -35655,7 +35443,7 @@ parser$4.parseError = lrGeneratorMixin.parseError = eval(parseErrorSourceCode + generatorMixin.createLexer = function createLexer(lexerSpec, input, tokens, options) { // TODO: construct options from generator options: // lexer_options = ... - var lexer = new RegExpLexer(lexerSpec, input, tokens, options); + let lexer = new RegExpLexer(lexerSpec, input, tokens, options); return lexer; }; @@ -35694,8 +35482,6 @@ const define_parser_APIs_1 = ` // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - "use strict"; - return '"' + id_str + '"'; }, @@ -35703,8 +35489,6 @@ const define_parser_APIs_1 = ` // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - "use strict"; - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -35716,8 +35500,8 @@ const define_parser_APIs_1 = ` // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -35730,15 +35514,13 @@ const define_parser_APIs_1 = ` // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - "use strict"; - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -35754,11 +35536,10 @@ const define_parser_APIs_1 = ` // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { - "use strict"; + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -35766,10 +35547,10 @@ const define_parser_APIs_1 = ` this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -35781,8 +35562,8 @@ const define_parser_APIs_1 = ` `; // --- END of define_parser_APIs_1 chunk --- -var api_set = (new Function('', 'return { ' + define_parser_APIs_1 + ' };'))(); -for (var api in api_set) { +const api_set = (new Function('', 'return { ' + define_parser_APIs_1 + ' };'))(); +for (let api in api_set) { parser$4[api] = api_set[api]; } @@ -35790,39 +35571,37 @@ for (var api in api_set) { // --- START parser kernel --- parser$4.parse = ` function parse(input, parseParams) { - "use strict"; - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - var tstack = []; // token stack (only used when \`%options token_stack\` support has been enabled) - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - var yytext; - var yylineno; - var yyleng; - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + let tstack = []; // token stack (only used when \`%options token_stack\` support has been enabled) + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + let yytext; + let yylineno; + let yyleng; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -35831,21 +35610,18 @@ function parse(input, parseParams) { post_parse: undefined, pre_lex: undefined, post_lex: undefined, - parseParamsAsMembers: parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - "use strict"; - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -35870,8 +35646,6 @@ function parse(input, parseParams) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - "use strict"; - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -35879,18 +35653,19 @@ function parse(input, parseParams) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -35898,26 +35673,19 @@ function parse(input, parseParams) { // - either the element does not yet exist in \`src\` // - or exists in \`src\` but is NULL or UNDEFINED there, while its value is non-NULL in \`dst\` function shallow_copy_noclobber(dst, src) { - "use strict"; - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - "use strict"; - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -35935,17 +35703,13 @@ function parse(input, parseParams) { this.copy_yytext = this.options.copy_yytext || sharedState_yy.copy_yytext || shallow_copy; this.copy_yylloc = this.options.copy_yylloc || sharedState_yy.copy_yylloc || copy_yylloc_native; - var yydebug = false; + let yydebug = false; if (this.options.debug) { yydebug = function yydebug_impl(msg, obj) { - "use strict"; - - var ref_list; - var ref_names; + let ref_list; + let ref_names; function deepClone(from, sub) { - "use strict"; - if (sub == null) { ref_list = []; ref_names = []; @@ -35957,15 +35721,15 @@ function parse(input, parseParams) { return from; } - var i = ref_list.indexOf(from); + let i = ref_list.indexOf(from); if (i >= 0) { return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference } ref_list.push(from); ref_names.push(sub); - var to = new from.constructor(); - for (var name in from) { + let to = new from.constructor(); + for (let name in from) { if (name === 'parser') continue; if (name === 'lexer') continue; to[name] = deepClone(from[name], name); @@ -35993,13 +35757,11 @@ function parse(input, parseParams) { // wrap try/catch in a function to help the V8 JIT compiler... function yydebug_cvt(obj) { - "use strict"; - - var js; + let js; try { - var re1; + let re1; if (typeof XRegExp === 'undefined') { - re1 = / \\"([a-z_][a-z_0-9. ]*)\\": /ig; + re1 = / {2}\\"([a-z_][a-z_0-9. ]*)\\": /ig; } else { re1 = new XRegExp(' \\"([\\\\p{Alphabetic}_][\\\\p{Alphabetic}\\\\p{Number}_. ]*)\\": ', 'g'); } @@ -36031,21 +35793,25 @@ function parse(input, parseParams) { // them up. Hence we MUST set them up at the start of every \`parse()\` run! if (this.yyError) { this.yyError = function yyError(str /*, ...args */) { - "use strict"; - - if (yydebug) yydebug('yyerror: ', { message: str, args: arguments, symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('yyerror: ', { + message: str, + args: arguments, + symbol, state, newState, recovering, action + }); + } //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); + let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -36066,13 +35832,13 @@ function parse(input, parseParams) { //_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, false); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, false); //_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -36085,18 +35851,14 @@ function parse(input, parseParams) { if (this.yyRecovering) { this.yyRecovering = function yyRecovering() { - "use strict"; - - if (yydebug) yydebug('yyrecovering: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) yydebug('yyrecovering: ', { symbol, state, newState, recovering, action }); return recovering; }; } if (this.yyErrOk) { this.yyErrOk = function yyErrOk() { - "use strict"; - - if (yydebug) yydebug('yyerrok: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) yydebug('yyerrok: ', { symbol, state, newState, recovering, action }); recovering = 0; // DO NOT reset/cleanup \`recoveringErrorInfo\` yet: userland code @@ -36118,9 +35880,7 @@ function parse(input, parseParams) { if (this.yyClearIn) { this.yyClearIn = function yyClearIn() { - "use strict"; - - if (yydebug) yydebug('yyclearin: ', { symbol: symbol, newState: newState, recovering: recovering, action: action, preErrorSymbol: preErrorSymbol }); + if (yydebug) yydebug('yyclearin: ', { symbol, newState, recovering, action, preErrorSymbol }); if (symbol === TERROR) { symbol = 0; yytext = null; @@ -36137,8 +35897,6 @@ function parse(input, parseParams) { // Does the shared state override the default \`parseError\` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -36151,8 +35909,6 @@ function parse(input, parseParams) { // Does the shared state override the default \`quoteName\` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - "use strict"; - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -36166,12 +35922,10 @@ function parse(input, parseParams) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your \`sharedState\`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - "use strict"; - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -36225,8 +35979,8 @@ function parse(input, parseParams) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -36235,8 +35989,8 @@ function parse(input, parseParams) { //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -36270,20 +36024,18 @@ function parse(input, parseParams) { // // Note: epsilon rule's yylloc situation is detected by passing both \`first_index\` and \`first_yylloc\` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - "use strict"; - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -36294,7 +36046,7 @@ function parse(input, parseParams) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -36307,7 +36059,7 @@ function parse(input, parseParams) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -36319,29 +36071,27 @@ function parse(input, parseParams) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or \`dont_look_back\` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -36349,7 +36099,7 @@ function parse(input, parseParams) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -36369,9 +36119,7 @@ function parse(input, parseParams) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your \`lexer\`, \`sharedState\`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - "use strict"; - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -36380,10 +36128,10 @@ function parse(input, parseParams) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -36391,7 +36139,7 @@ function parse(input, parseParams) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -36408,10 +36156,8 @@ function parse(input, parseParams) { // info.value = null; // info.value_stack = null; // ... - "use strict"; - - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -36427,9 +36173,7 @@ function parse(input, parseParams) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - "use strict"; - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -36498,11 +36242,14 @@ function parse(input, parseParams) { // - root_failure_pointer: // copy of the \`stack_pointer\`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -36513,9 +36260,7 @@ function parse(input, parseParams) { }; function getNonTerminalFromCode(symbol) { - "use strict"; - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -36525,22 +36270,20 @@ function parse(input, parseParams) { //_lexer_without_token_stack: function stdLex() { - "use strict"; - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36550,22 +36293,20 @@ function parse(input, parseParams) { } function fastLex() { - "use strict"; - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36574,15 +36315,13 @@ function parse(input, parseParams) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; //_lexer_with_token_stack: // lex function that supports token stacks function tokenStackLex() { - "use strict"; - - var token; + let token; token = tstack.pop() || lexer.lex() || EOF; // if token isn't its numeric value, convert if (typeof token !== 'number') { @@ -36601,13 +36340,13 @@ function parse(input, parseParams) { } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36618,33 +36357,37 @@ function parse(input, parseParams) { //_lexer_with_token_stack_end: - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - "use strict"; - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { // check for error recovery rule in this state - if (yydebug) yydebug('locateNearestErrorRecoveryRule #test#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); - var t = (table[state] && table[state][TERROR]) || NO_ACTION; + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #test#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } + const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we \`yyerrok()\` an error, we must @@ -36659,12 +36402,24 @@ function parse(input, parseParams) { // terminate the parse in a controlled fashion even when we have // very complex error/recovery code interplay in the core + user // action code blocks: - if (yydebug) yydebug('locateNearestErrorRecoveryRule #found#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #found#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { - if (yydebug) yydebug('locateNearestErrorRecoveryRule #skip#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #skip#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; @@ -36674,14 +36429,26 @@ function parse(input, parseParams) { return depth; } if (state === 0 /* $accept rule */ || stack_probe < 1) { - if (yydebug) yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; } - if (yydebug) yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } return -1; // No suitable error recovery rule available. } @@ -36698,7 +36465,7 @@ function parse(input, parseParams) { // whether we'll go with the standard, slower, lex() API or the // \`fast_lex()\` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -36744,17 +36511,23 @@ function parse(input, parseParams) { newState = t[1]; action = t[0]; - if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('after FETCH/LEX: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol], + state, newState, recovering, action + }); + } //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules // handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -36781,7 +36554,13 @@ function parse(input, parseParams) { // invoke the parser's cleanup API! recoveringErrorInfo = this.shallowCopyErrorInfo(p); - if (yydebug) yydebug('error recovery rule detected: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p }); + if (yydebug) { + yydebug('error recovery rule detected: ', { + error_rule_depth, + error: p.errStr, + error_hash: p + }); + } r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { @@ -36799,9 +36578,15 @@ function parse(input, parseParams) { } } - if (yydebug) yydebug('after ERROR DETECT: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p }); + if (yydebug) { + yydebug('after ERROR DETECT: ', { + error_rule_depth, + error: p.errStr, + error_hash: p + }); + } - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -36821,17 +36606,22 @@ function parse(input, parseParams) { preErrorSymbol = 0; symbol = lex(); - if (yydebug) yydebug('after ERROR RECOVERY-3: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol] }); + if (yydebug) { + yydebug('after ERROR RECOVERY-3: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol] + }); + } } // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -36878,20 +36668,18 @@ function parse(input, parseParams) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; - if (yydebug) yydebug('Error recovery process: pushed error info item on the info stack: ', { - item: vstack[sp], - sp, - esp, - vstack, - stack, - sstack, - combineState: NO_ACTION[1] - }); + if (yydebug) { + yydebug('Error recovery process: pushed error info item on the info stack: ', { + item: vstack[sp], + sp, esp, vstack, stack, sstack, + combineState: NO_ACTION[1] + }); + } } else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), @@ -36910,11 +36698,17 @@ function parse(input, parseParams) { yyrulelen = error_rule_depth; - if (yydebug) yydebug('Error recovery process: performAction: COMBINE: ', { - yyval, yytext, sp, pop_size: yyrulelen, vstack, stack, sstack, - combineState: NO_ACTION[1] - }); - r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, NO_ACTION[1], sp - 1, yyrulelen, vstack, lstack, stack, sstack); + let combineState = NO_ACTION[1]; + + if (yydebug) { + yydebug('Error recovery process: performAction: COMBINE: ', { + yyval, yytext, sp, + pop_size: yyrulelen, + vstack, stack, sstack, + combineState + }); + } + r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, combineState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof r !== 'undefined') { retval = r; @@ -36925,7 +36719,7 @@ function parse(input, parseParams) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -36952,7 +36746,7 @@ function parse(input, parseParams) { // allow N (default: 3) real symbols to be shifted before reporting a new error recovering = ERROR_RECOVERY_TOKEN_DISCARD_COUNT; - if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth: error_rule_depth, symbol: symbol, preErrorSymbol: preErrorSymbol }); + if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth, symbol, preErrorSymbol }); // Now duplicate the standard parse machine here, at least its initial // couple of rounds until the TERROR symbol is **pushed onto the parse stack**, @@ -36978,10 +36772,10 @@ function parse(input, parseParams) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -37009,14 +36803,20 @@ function parse(input, parseParams) { newState = t[1]; action = t[0]; - if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('after FETCH/LEX: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol], + state, newState, recovering, action + }); + } // encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { if (yydebug) yydebug('**NESTED ERROR DETECTED** while still recovering from previous error'); - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the \`continue;\` @@ -37030,15 +36830,26 @@ function parse(input, parseParams) { } } - if (yydebug) yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) { - "use strict"; - - if (!nt || !nt.states || !nt.rules) - return ''; - var rulename = nt.states[state]; - var rulespec = nt.rules[rulename][state]; - return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; - })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' + + (action === 1 ? + 'shift token ' + symbol + ' (then go to state ' + newState + ')' : + action === 2 ? + 'reduce by rule: ' + newState + (function __print_rule(nt, state) { + if (!nt || !nt.states || !nt.rules) { + return ''; + } + let rulename = nt.states[state]; + let rulespec = nt.rules[rulename][state]; + return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; + })(this.nonterminals_, newState) : + action === 3 ? + 'accept' : + '???unexpected???' + ), { + action, newState, recovering, symbol + }); + } switch (action) { // catch misc. parse failures: @@ -37062,12 +36873,12 @@ function parse(input, parseParams) { // Push a special value onto the stack when we're // shifting the \`error\` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -37076,7 +36887,7 @@ function parse(input, parseParams) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -37105,14 +36916,14 @@ function parse(input, parseParams) { if (recovering > 0) { recovering--; - if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering, symbol }); } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; - if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering, symbol }); // read action for current state and first input t = (table[newState] && table[newState][symbol]) || NO_ACTION; if (!t[0] || symbol === TERROR) { @@ -37124,7 +36935,7 @@ function parse(input, parseParams) { // recovery, for then this we would we idling (cycling) on the error forever. // Yes, this does not take into account the possibility that the *lexer* may have // produced a *new* TERROR token all by itself, but that would be a very peculiar grammar! - if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering, symbol }); symbol = 0; } } @@ -37140,7 +36951,7 @@ function parse(input, parseParams) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -37151,21 +36962,26 @@ function parse(input, parseParams) { this_production = this.productions_[newState - 1]; // \`this.productions_[]\` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; - if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('~~~ REDUCE: ', { + pop_size: yyrulelen, + newState, recovering, symbol + }); + } r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -37199,15 +37015,17 @@ function parse(input, parseParams) { sp -= yyrulelen; // don't overwrite the \`symbol\` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; - if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol }); + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol }); + } continue; // accept: @@ -37259,7 +37077,7 @@ function parse(input, parseParams) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the \`switch/default\` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -37269,9 +37087,9 @@ function parse(input, parseParams) { // handle parse error if (!action) { - var errStr; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let errStr; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); // Report error errStr = 'Parse error'; @@ -37302,15 +37120,26 @@ function parse(input, parseParams) { } - if (yydebug) yydebug('::: MAIN CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) { - "use strict"; - - if (!nt || !nt.states || !nt.rules) - return ''; - var rulename = nt.states[state]; - var rulespec = nt.rules[rulename][state]; - return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; - })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('::: MAIN CYCLE action: ' + + (action === 1 ? + 'shift token ' + symbol + ' (then go to state ' + newState + ')' : + action === 2 ? + 'reduce by rule: ' + newState + (function __print_rule(nt, state) { + if (!nt || !nt.states || !nt.rules) { + return ''; + } + let rulename = nt.states[state]; + let rulespec = nt.rules[rulename][state]; + return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; + })(this.nonterminals_, newState) : + action === 3 ? + 'accept' : + '???unexpected???' + ), { + action, newState, recovering, symbol + }); + } switch (action) { // catch misc. parse failures: @@ -37341,7 +37170,7 @@ function parse(input, parseParams) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -37358,8 +37187,8 @@ function parse(input, parseParams) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyleng = lexer.yyleng; @@ -37370,27 +37199,32 @@ function parse(input, parseParams) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // \`this.productions_[]\` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; - if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('~~~ REDUCE: ', { + pop_size: yyrulelen, + newState, recovering, symbol + }); + } r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -37421,15 +37255,17 @@ function parse(input, parseParams) { sp -= yyrulelen; // don't overwrite the \`symbol\` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; - if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol }); + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol }); + } continue; // accept: @@ -37482,8 +37318,7 @@ function parse(input, parseParams) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -37516,30 +37351,30 @@ function parse(input, parseParams) { * LR(0) Parser */ -var lr0 = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { +const lr0 = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LR(0)', afterconstructor: function lr0_afterconstructor() { this.buildTable(); } }); -var LR0Generator = Jison$1.LR0Generator = lr0.construct(); +const LR0Generator = Jison$1.LR0Generator = lr0.construct(); /* * Simple LALR(1) */ -var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { +const lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LALR(1)', afterconstructor: function lalr_afterconstructor() { - var self = this; + let self = this; if (this.DEBUG) { this.mix(lrGeneratorDebug, lalrGeneratorDebug); // mixin debug methods } - for (var round = 1; /* infinite loop if it weren't for the `break`s at the end */ ; round++) { + for (let round = 1; /* infinite loop if it weren't for the `break`s at the end */ ; round++) { this.states = this.canonicalCollection(); if (this.DEBUG || devDebug) { @@ -37550,13 +37385,13 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { this.terms_ = {}; - var newg = this.newg = typal.beget(lookaheadMixin, { + let newg = this.newg = typal.beget(lookaheadMixin, { oldg: this, trace: this.trace, nterms_: {}, DEBUG: false, go_: function (productionSymbol, productionHandle) { - var stateNum = productionSymbol.split(':')[0]; // grab state # + let stateNum = productionSymbol.split(':')[0]; // grab state # assert__default['default'](stateNum == +stateNum); stateNum = +stateNum; productionHandle = productionHandle.map(function (rhsElem) { @@ -37593,8 +37428,8 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { // backprop `nullable` value for each nonterminal and production back to original grammar: each(newg.nonterminals, function (newg_nt, t) { // extract original symbol: - var sym; - var a = newg_nt.symbol.split(':'); + let sym; + let a = newg_nt.symbol.split(':'); if (a.length === 1 || a[0] === '') { sym = newg_nt.symbol; } else { @@ -37669,8 +37504,8 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { go: function LALR_go(stateNum, productionHandle, productionSymbol) { assert__default['default'](typeof stateNum === 'number'); - var endStateNum = stateNum; - for (var i = 0; i < productionHandle.length; i++) { + let endStateNum = stateNum; + for (let i = 0; i < productionHandle.length; i++) { endStateNum = this.states.item(endStateNum).edges[productionHandle[i]] || endStateNum; } return endStateNum; @@ -37678,10 +37513,10 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { goPath: function LALR_goPath(stateNum, productionHandle, productionSymbol) { assert__default['default'](typeof stateNum === 'number'); - var endStateNum = stateNum, - t, - path = []; - for (var i = 0; i < productionHandle.length; i++) { + let endStateNum = stateNum, + t, + path = []; + for (let i = 0; i < productionHandle.length; i++) { t = productionHandle[i] ? endStateNum + ':' + productionHandle[i] /* + ':' + productionSymbol */ : ''; if (t) { this.newg.nterms_[t] = endStateNum; @@ -37699,34 +37534,34 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { // every disjoint reduction of a nonterminal becomes a production in G' buildNewGrammar: function LALR_buildNewGrammar() { - var self = this, - newg = this.newg; + let self = this, + newg = this.newg; this.states.forEach(function (state, i) { i = +i; state.forEach(function LALR_buildNewHandle(item) { if (item.dotPosition === 0) { // new symbols are a combination of state and transition symbol - var symbol = i + ':' + item.production.symbol; + let symbol = i + ':' + item.production.symbol; assert__default['default'](typeof self.terms_[symbol] === 'undefined' || self.terms_[symbol] === item.production.symbol); self.terms_[symbol] = item.production.symbol; newg.nterms_[symbol] = i; if (!newg.nonterminals[symbol]) { newg.nonterminals[symbol] = new Nonterminal(symbol); } - var pathInfo = self.goPath(i, item.production.handle, item.production.symbol); - var p = new Production(symbol, pathInfo.path, newg.productions.length); + let pathInfo = self.goPath(i, item.production.handle, item.production.symbol); + let p = new Production(symbol, pathInfo.path, newg.productions.length); newg.productions.push(p); newg.nonterminals[symbol].productions.push(p); // store the transition that gets 'backed up to' after reduction on path - var handle = item.production.handle.join(' '); + let handle = item.production.handle.join(' '); if (self.conflict_fixing_round && self.conflict_states_LU[i]) ; if (self.conflict_fixing_round && self.conflict_productions_LU[item.production.id]) { handle += ':P' + item.production.id; } - var goes = self.states.item(pathInfo.endState).goes; + let goes = self.states.item(pathInfo.endState).goes; if (!goes[handle]) { goes[handle] = []; } @@ -37740,22 +37575,22 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { }, unionLookaheads: function LALR_unionLookaheads() { - var self = this, - newg = this.newg; - // var states = !!this.onDemandLookahead ? this.inadequateStates : this.states; + let self = this, + newg = this.newg; + // let states = !!this.onDemandLookahead ? this.inadequateStates : this.states; - var these_states = this.states; + let these_states = this.states; these_states.forEach(function union_states_forEach(state, i) { i = +i; //assert(state.inadequate ? these_states.inadequate : true); - var treat_me = (self.onDemandLookahead ? these_states.inadequate || state.inadequate : true); + let treat_me = (self.onDemandLookahead ? these_states.inadequate || state.inadequate : true); if (state.reductions.length && treat_me) { state.reductions.forEach(function union_reduction_forEach(item) { - var follows = {}; - for (var k = 0; k < item.follows.length; k++) { + let follows = {}; + for (let k = 0; k < item.follows.length; k++) { follows[item.follows[k]] = true; } - var handle = item.production.handle.join(' '); + let handle = item.production.handle.join(' '); if (self.conflict_fixing_round && self.conflict_states_LU[i]) ; if (self.conflict_fixing_round && self.conflict_productions_LU[item.production.id]) { handle += ':P' + item.production.id; @@ -37766,7 +37601,7 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { state.goes[handle].forEach(function reduction_goes_forEach(symbol) { newg.nonterminals[symbol].follows.forEach(function goes_follows_forEach(symbol) { - var terminal = self.terms_[symbol]; + let terminal = self.terms_[symbol]; if (!follows[terminal]) { follows[terminal] = true; @@ -37780,11 +37615,11 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { } }); -var LALRGenerator = Jison$1.LALRGenerator = lalr.construct(); +const LALRGenerator = Jison$1.LALRGenerator = lalr.construct(); // LALR generator debug mixin -var lalrGeneratorDebug = { +const lalrGeneratorDebug = { beforebuildNewGrammar: function () { this.trace(this.states.size() + ' states.'); this.trace('Building lookahead grammar.'); @@ -37801,7 +37636,7 @@ var lalrGeneratorDebug = { aftercomputeLookaheads: function () { traceStates(this.trace, this.states, 'after LALR::computeLookaheads()'); }, - aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */ ) { + aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */) { traceStates(this.trace, states, 'as produced by LALR::canonicalCollection()'); } }; @@ -37811,7 +37646,7 @@ var lalrGeneratorDebug = { * * Define base type */ -var lrLookaheadGenerator = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { +const lrLookaheadGenerator = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { afterconstructor: function lr_aftercontructor() { this.computeLookaheads(); @@ -37828,7 +37663,7 @@ var lrLookaheadGenerator = generator.beget(lookaheadMixin, generatorMixin, lrGen /* * SLR Parser */ -var SLRGenerator = Jison$1.SLRGenerator = lrLookaheadGenerator.construct({ +const SLRGenerator = Jison$1.SLRGenerator = lrLookaheadGenerator.construct({ type: 'SLR(1)', lookAheads: function SLR_lookAhead(state, item) { @@ -37840,7 +37675,7 @@ var SLRGenerator = Jison$1.SLRGenerator = lrLookaheadGenerator.construct({ /* * LR(1) Parser */ -var lr1 = lrLookaheadGenerator.beget({ +const lr1 = lrLookaheadGenerator.beget({ type: 'Canonical LR(1)', lookAheads: function LR_lookAheads(state, item) { @@ -37857,28 +37692,26 @@ var lr1 = lrLookaheadGenerator.beget({ }), closureOperation: function LR_ClosureOperation(itemSet) { - var closureSet = new this.ItemSet(); - var self = this; + let closureSet = new this.ItemSet(); + let self = this; - var set = itemSet, - itemQueue; + let set = itemSet; do { - itemQueue = new Set(); + let itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function LR_AddItemToClosureSets(item) { - var symbol = item.markedSymbol; - var b, r; + let symbol = item.markedSymbol; // if token is a nonterminal, recursively add closures if (symbol && self.nonterminals[symbol]) { - r = item.remainingHandle(); - b = self.first(r); + let r = item.remainingHandle(); + let b = self.first(r); if (b.length === 0 || item.production.nullable || self.nullable(r)) { b = b.concat(item.follows); } self.nonterminals[symbol].productions.forEach(function (production) { - var newItem = new self.Item(production, 0, b); + let newItem = new self.Item(production, 0, b); if (!closureSet.contains(newItem) && !itemQueue.contains(newItem)) { itemQueue.push(newItem); } @@ -37890,18 +37723,18 @@ var lr1 = lrLookaheadGenerator.beget({ }); set = itemQueue; - } while (!itemQueue.isEmpty()); + } while (!set.isEmpty()); return closureSet; } }); -var LR1Generator = Jison$1.LR1Generator = lr1.construct(); +const LR1Generator = Jison$1.LR1Generator = lr1.construct(); /* * LL Parser */ -var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { +const ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LL(1)', afterconstructor: function ll_aftercontructor() { @@ -37924,13 +37757,13 @@ var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { }, parseTable: function ll_ParseTable(productions) { - var table = {}, - symbols_ = this.symbols_, - self = this; + let table = {}; + let symbols_ = this.symbols_; + let self = this; productions.forEach(function (production, i) { - var row = table[production.symbol] || {}; - var tokens = production.first; + let row = table[production.symbol] || {}; + let tokens = production.first; if (self.nullable(production.handle)) { tokens = union(tokens, self.nonterminals[production.symbol].follows); } @@ -37939,7 +37772,7 @@ var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { row[token].push(i); self.conflicts++; } else { - row[token] = [i]; + row[token] = [ i ]; } }); table[production.symbol] = row; @@ -37950,16 +37783,16 @@ var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { } }); -var LLGenerator = Jison$1.LLGenerator = ll.construct(); +const LLGenerator = Jison$1.LLGenerator = ll.construct(); Jison$1.Generator = function Jison_Generator(grammar, optionalLexerSection, options) { // pick the correct argument for the `options` for this call: if (!options && optionalLexerSection && typeof optionalLexerSection !== 'string') { - options = optionalLexerSection; - optionalLexerSection = null; + options = optionalLexerSection; + optionalLexerSection = null; } // and standardize it: - var preliminary_options = mkStdOptions$1(options); + let preliminary_options = mkStdOptions$1(options); // Provisionally parse the grammar, really only to obtain the *options.type* // specified within the grammar, if specified (via `%parser-type`). @@ -37981,7 +37814,7 @@ Jison$1.Generator = function Jison_Generator(grammar, optionalLexerSection, opti // // Anyway, API/CLI options **override** options coming in from the grammar spec. // - options = mkStdOptions$1("NODEFAULT", grammar.options, options); + options = mkStdOptions$1('NODEFAULT', grammar.options, options); switch (options.type || Jison$1.defaultJisonOptions.type) { case 'lr0': options.hasPartialLrUpgradeOnConflict = false; // kill this unsupported option @@ -38007,10 +37840,24 @@ Jison$1.Generator = function Jison_Generator(grammar, optionalLexerSection, opti }; function Parser$3(g, l, options) { - var gen = Jison$1.Generator(g, l, options); + let gen = Jison$1.Generator(g, l, options); return gen.createParser(); } Jison$1.Parser = Parser$3; +// exports for unit/system testing purposes: +Jison$1.TestExports = { + lookaheadMixin, generatorMixin, lrGeneratorMixin, + lalr, + lr0, + lr1, + ll, + parser: parser$4, + pickErrorHandlingChunk, + addOrRemoveTokenStack, + removeUnusedKernelFeatures, + expandParseArguments +}; + module.exports = Jison$1; diff --git a/dist/jison-es6.js b/dist/jison-es6.js index 508c4c7a7..8057c54be 100644 --- a/dist/jison-es6.js +++ b/dist/jison-es6.js @@ -1,13 +1,14 @@ import fs from 'fs'; import path$1 from 'path'; import JSON5 from '@gerhobbelt/json5'; +import mkdirp from 'mkdirp'; import XRegExp from '@gerhobbelt/xregexp'; import recast from 'recast'; import { transformSync } from '@babel/core'; import assert$1 from 'assert'; import astUtils from 'ast-util'; -// Return TRUE if `src` starts with `searchString`. +// Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -30,19 +31,19 @@ function rmCommonWS(strings, ...values) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -61,19 +62,21 @@ function rmCommonWS(strings, ...values) { // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -82,16 +85,19 @@ function rmCommonWS(strings, ...values) { } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -102,27 +108,79 @@ function camelCase(s) { return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } +// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; +})([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' +]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -140,6 +198,11 @@ function mkIdentifier(s) { .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -148,13 +211,13 @@ function mkIdentifier(s) { function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -165,23 +228,17 @@ function scanRegExp(s) { break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -204,34 +261,33 @@ function isLineTerminator(cp) { /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote$1(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -254,28 +310,76 @@ function chkBugger(src) { // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } +function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; +} + + +function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); +} + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path$1.dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path$1.basename(options.inputFilename || options.moduleName || (options.outfile ? path$1.dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path$1.dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path$1.basename(options.inputFilename || options.moduleName || (options.outfile ? path$1.dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -286,27 +390,37 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path$1.normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path$1.normalize(path$1.join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5.stringify(dump, null, 2); + let d = JSON5.stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp(path$1.dirname(dumpfile)); fs.writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -316,7 +430,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -324,7 +438,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -350,27 +464,43 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; } - const debug = 0; + const debug = options.debug || 0; - var p; + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); + } + + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -383,9 +513,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -407,22 +538,22 @@ assert$1(recast); // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; -// Determine which Unicode NonAsciiIdentifierStart characters +// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -430,40 +561,40 @@ const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -471,30 +602,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -505,59 +636,59 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -599,38 +730,38 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -642,18 +773,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -664,56 +795,56 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -721,97 +852,97 @@ function generateMapper4JisonGrammarIdentifiers(input) { typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp(`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp(`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp(`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp(`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp(`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp(`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp(`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp(`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp(`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp(`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp(`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -819,7 +950,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -832,7 +963,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -845,7 +976,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -858,7 +989,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -877,37 +1008,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -939,7 +1070,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -956,37 +1087,37 @@ function parseCodeChunkToAST(src, options) { .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast.parse(src); + const ast = recast.parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return transformSync(src, options); // => { code, map, ast } @@ -994,8 +1125,8 @@ function compileCodeToES5(src, options) { function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1004,7 +1135,7 @@ function prettyPrintAST(ast, options) { // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1027,25 +1158,25 @@ function prettyPrintAST(ast, options) { // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1056,9 +1187,9 @@ function checkActionBlock(src, yylloc, options) { // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1066,7 +1197,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1075,14 +1206,14 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1136,7 +1267,7 @@ var parse2AST = { trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1150,7 +1281,7 @@ function chkBugger$1(src) { /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1162,24 +1293,24 @@ const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?: /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1196,8 +1327,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1208,14 +1339,14 @@ function printFunctionSourceCodeContainer(f) { action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1226,17 +1357,17 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; -// -// -// +// +// +// function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1262,7 +1393,7 @@ function detectIstanbulGlobal() { // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1310,7 +1441,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1373,13 +1504,13 @@ var reHelpers = { getRegExpInfo: getRegExpInfo }; -var cycleref = []; -var cyclerefpath = []; +let cycleref = []; +let cyclerefpath = []; -var linkref = []; -var linkrefpath = []; +let linkref = []; +let linkrefpath = []; -var path = []; +let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1387,14 +1518,14 @@ function shallow_copy(src) { return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1407,11 +1538,11 @@ function shallow_copy(src) { function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1424,9 +1555,9 @@ function shallow_copy_and_strip_depth(src, parentKey) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1441,16 +1572,52 @@ function shallow_copy_and_strip_depth(src, parentKey) { } +// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } +// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; +} + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1465,7 +1632,7 @@ function trim_array_tail(arr) { function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1491,10 +1658,10 @@ function treat_value_stack(v) { } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1592,7 +1759,7 @@ function treat_hash(h) { function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1609,7 +1776,7 @@ function treat_error_report_info(e) { path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1637,7 +1804,7 @@ function treat_error_report_info(e) { function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1653,7 +1820,7 @@ function treat_object(e) { linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1665,14 +1832,14 @@ function treat_object(e) { // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1682,7 +1849,7 @@ function trimErrorForTestReporting(e) { cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1696,12 +1863,14 @@ var helpers = { dquote: dquote$1, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1716,7 +1885,7 @@ var helpers = { printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; /* @@ -1726,23 +1895,23 @@ var helpers = { * By Zachary Carter * MIT Licensed */ -var mkIdentifier$1 = helpers.mkIdentifier; +let mkIdentifier$1 = helpers.mkIdentifier; -var create = Object.create || function (o) { - function F(){} - F.prototype = o; - return new F(); +let create = Object.create || function (o) { + function F() {} + F.prototype = o; + return new F(); }; -var position = /^(before|after)/; +let position = /^(before|after)/; // basic method layering // always returns original method's return value function layerMethod(pos, key, prop, fun) { if (pos === 'after') { return function () { - var ret = prop.apply(this, arguments); - var args = [].slice.call(arguments); + let ret = prop.apply(this, arguments); + let args = [].slice.call(arguments); args.splice(0, 0, ret); fun.apply(this, args); return ret; @@ -1750,7 +1919,7 @@ function layerMethod(pos, key, prop, fun) { } else if (pos === 'before') { return function () { fun.apply(this, arguments); - var ret = prop.apply(this, arguments); + let ret = prop.apply(this, arguments); return ret; }; } @@ -1761,7 +1930,7 @@ function layerMethod(pos, key, prop, fun) { // overwriting them or layering them. i.e. an object method 'meth' is // layered by mixin methods 'beforemeth' or 'aftermeth' function typal_mix() { - var i, o, k; + let i, o, k; for (i = 0; i < arguments.length; i++) { o = arguments[i]; if (!o) continue; @@ -1773,8 +1942,8 @@ function typal_mix() { } for (k in o) { if (Object.prototype.hasOwnProperty.call(o, k)) { - var match = k.match(position); - var key = k.replace(position, ''); + let match = k.match(position); + let key = k.replace(position, ''); if (match && typeof this[key] === 'function') { this[key] = layerMethod(match[0], key, this[key], o[k]); } else { @@ -1788,15 +1957,15 @@ function typal_mix() { // Same as typal_mix but also camelCases every object member and 'standardizes' the key set of every input // argument through a caLLback function. -// +// // This is useful for processing options with dashes in their key, e.g. `token-stack` --> tokenStack. function typal_camel_mix(cb) { - var i, o, k; + let i, o, k; // Convert first character to lowercase function lcase0(s) { - return s.replace(/^\w/, function (match) { - return match.toLowerCase(); + return s.replace(/^\w/, function (match) { + return match.toLowerCase(); }); } @@ -1814,16 +1983,15 @@ function typal_camel_mix(cb) { } for (k in o) { if (Object.prototype.hasOwnProperty.call(o, k)) { - var nk = mkIdentifier$1(k); - var match = k.match(position); - var key = k.replace(position, ''); + let nk = mkIdentifier$1(k); + let match = k.match(position); + let key = k.replace(position, ''); // This anticipates before/after members to be camelcased already, e.g. - // 'afterParse()' for layering 'parse()': - var alt_key = lcase0(key); + // 'afterParse()' for layering 'parse()': + let alt_key = lcase0(key); if (match && typeof this[key] === 'function') { this[key] = layerMethod(match[0], key, this[key], o[k]); - } - else if (match && typeof this[alt_key] === 'function') { + } else if (match && typeof this[alt_key] === 'function') { this[alt_key] = layerMethod(match[0], alt_key, this[alt_key], o[k]); } else { this[nk] = o[k]; @@ -1834,7 +2002,7 @@ function typal_camel_mix(cb) { return this; } -var typal = { +let typal = { // extend object with own properties of each argument mix: typal_mix, @@ -1849,9 +2017,9 @@ var typal = { // Creates a new Class function based on an object with a constructor method construct: function typal_construct() { - var o = typal_mix.apply(create(this), arguments); - var constructor = o.constructor; - var Klass = o.constructor = function () { return constructor.apply(this, arguments); }; + let o = typal_mix.apply(create(this), arguments); + let constructor = o.constructor; + let Klass = o.constructor = function () { return constructor.apply(this, arguments); }; Klass.prototype = o; Klass.mix = typal_mix; // allow for easy singleton property extension return Klass; @@ -1863,13 +2031,12 @@ var typal = { // Set class to wrap arrays -var setMixin = { +let setMixin = { constructor: function Set_constructor(set, raw) { this._items = []; if (set && set.constructor === Array) { - this._items = raw ? set: set.slice(0); - } - else if (arguments.length) { + this._items = raw ? set : set.slice(0); + } else if (arguments.length) { this._items = [].slice.call(arguments, 0); } }, @@ -1882,7 +2049,7 @@ var setMixin = { }, indexOf: function indexOf(item) { if (item && item.eq) { - for (var k = 0; k < this._items.length; k++) { + for (let k = 0; k < this._items.length; k++) { if (item.eq(this._items[k])) { return k; } @@ -1897,14 +2064,14 @@ var setMixin = { }); }, complement: function complement(set) { - var that = this; + let that = this; return set.filter(function sub_complement(elm) { return !that.contains(elm); }); }, subset: function subset(set) { - var cont = true; - for (var i = 0; i < this._items.length && cont; i++) { + let cont = true; + for (let i = 0; i < this._items.length && cont; i++) { cont = cont && set.contains(this._items[i]); } return cont; @@ -1915,60 +2082,59 @@ var setMixin = { joinSet: function joinSet(set) { return this.concat(this.complement(set)); }, - contains: function contains(item) { - return this.indexOf(item) !== -1; + contains: function contains(item) { + return this.indexOf(item) !== -1; }, - item: function item(v) { - return this._items[v]; + item: function item(v) { + return this._items[v]; }, - i: function i(v) { - return this._items[v]; + i: function i(v) { + return this._items[v]; }, - assign: function assign(index, value) { + assign: function assign(index, value) { this._items[index] = value; - return this; + return this; }, - first: function first() { - return this._items[0]; + first: function first() { + return this._items[0]; }, - last: function last() { - return this._items[this._items.length - 1]; + last: function last() { + return this._items[this._items.length - 1]; }, - size: function size() { - return this._items.length; + size: function size() { + return this._items.length; }, - isEmpty: function isEmpty() { - return this._items.length === 0; + isEmpty: function isEmpty() { + return this._items.length === 0; }, - copy: function copy() { - return new Set(this._items); + copy: function copy() { + return new Set$1(this._items); }, - toString: function toString() { - return this._items.toString(); + toString: function toString() { + return this._items.toString(); } }; 'push shift unshift forEach some every join sort'.split(' ').forEach(function (e, i) { - setMixin[e] = function () { - return Array.prototype[e].apply(this._items, arguments); + setMixin[e] = function () { + return Array.prototype[e].apply(this._items, arguments); }; //setMixin[e].name = e; }); 'filter slice map'.split(' ').forEach(function (e, i) { - setMixin[e] = function () { - return new Set(Array.prototype[e].apply(this._items, arguments), true); + setMixin[e] = function () { + return new Set$1(Array.prototype[e].apply(this._items, arguments), true); }; //setMixin[e].name = e; }); -var Set = typal.construct(setMixin); +var Set$1 = typal.construct(setMixin); // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1985,9 +2151,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -2020,10 +2186,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -2036,11 +2202,11 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -2050,18 +2216,18 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -2092,7 +2258,7 @@ JisonParserError.prototype.name = 'JisonParserError'; // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -2109,9 +2275,9 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -2124,7 +2290,7 @@ JisonParserError.prototype.name = 'JisonParserError'; } -var parser = { +let parser = { // Code Generator Information Report // --------------------------------- // @@ -2374,7 +2540,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2382,7 +2547,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2394,8 +2558,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2408,14 +2572,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2431,10 +2594,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2442,10 +2605,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2600,9 +2763,9 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -2614,18 +2777,18 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2655,9 +2818,9 @@ case 1: case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -2670,10 +2833,10 @@ case 2: case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2700,9 +2863,9 @@ case 3: case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -2711,10 +2874,10 @@ case 4: case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2742,9 +2905,9 @@ case 5: case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -2753,10 +2916,10 @@ case 6: case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -2795,9 +2958,9 @@ case 7: case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2862,9 +3025,9 @@ case 8: case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2879,9 +3042,9 @@ case 9: case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -2916,10 +3079,10 @@ case 10: case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2936,9 +3099,9 @@ case 11: case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2955,10 +3118,10 @@ case 12: case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2975,9 +3138,9 @@ case 13: case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2994,10 +3157,10 @@ case 14: case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3014,9 +3177,9 @@ case 15: case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3040,9 +3203,9 @@ case 17: case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3053,9 +3216,9 @@ case 132: case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3075,9 +3238,9 @@ case 18: case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3101,9 +3264,9 @@ case 19: case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -3116,10 +3279,10 @@ case 20: case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3136,9 +3299,9 @@ case 21: case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -3150,9 +3313,9 @@ case 22: case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -3192,10 +3355,10 @@ case 23: case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3215,9 +3378,9 @@ case 24: case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3267,10 +3430,10 @@ case 25: case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -3294,10 +3457,10 @@ case 26: case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3317,10 +3480,10 @@ case 27: case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3344,10 +3507,10 @@ case 28: case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3368,10 +3531,10 @@ case 29: case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3383,10 +3546,10 @@ case 31: case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3396,10 +3559,10 @@ case 33: case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3409,10 +3572,10 @@ case 32: case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3422,10 +3585,10 @@ case 34: case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3435,10 +3598,10 @@ case 35: case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -3448,10 +3611,10 @@ case 36: case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3461,10 +3624,10 @@ case 37: case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3474,9 +3637,9 @@ case 38: case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -3485,9 +3648,9 @@ case 39: case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -3496,9 +3659,9 @@ case 40: case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3520,9 +3683,9 @@ case 41: case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3533,9 +3696,9 @@ case 42: case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3555,9 +3718,9 @@ case 43: case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3611,9 +3774,9 @@ case 49: case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3633,9 +3796,9 @@ case 51: case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -3644,9 +3807,9 @@ case 58: case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -3658,9 +3821,9 @@ case 52: case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -3674,10 +3837,10 @@ case 53: case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3697,10 +3860,10 @@ case 54: case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3720,10 +3883,10 @@ case 55: case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3743,9 +3906,9 @@ case 56: case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3756,9 +3919,9 @@ case 59: case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3777,9 +3940,9 @@ case 60: case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -3820,9 +3983,9 @@ case 61: case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3846,9 +4009,9 @@ case 62: case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3874,9 +4037,9 @@ case 63: case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3921,9 +4084,9 @@ case 64: case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -3949,9 +4112,9 @@ case 106: case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -3960,9 +4123,9 @@ case 127: case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -3971,10 +4134,10 @@ case 67: case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3988,10 +4151,10 @@ case 68: case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4005,10 +4168,10 @@ case 69: case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4022,10 +4185,10 @@ case 70: case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4044,9 +4207,9 @@ case 72: case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4055,9 +4218,9 @@ case 77: case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -4095,10 +4258,10 @@ case 73: case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -4122,9 +4285,9 @@ case 74: case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -4203,9 +4366,9 @@ case 110: case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -4214,9 +4377,9 @@ case 129: case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -4225,9 +4388,9 @@ case 78: case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -4236,9 +4399,9 @@ case 79: case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -4247,9 +4410,9 @@ case 80: case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -4258,9 +4421,9 @@ case 81: case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -4269,9 +4432,9 @@ case 85: case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -4282,10 +4445,10 @@ case 87: case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4302,9 +4465,9 @@ case 88: case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -4313,9 +4476,9 @@ case 89: case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -4324,9 +4487,9 @@ case 90: case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -4335,9 +4498,9 @@ case 91: case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -4346,9 +4509,9 @@ case 92: case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -4367,18 +4530,18 @@ case 107: case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -4387,9 +4550,9 @@ case 97: case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -4398,9 +4561,9 @@ case 98: case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -4409,9 +4572,9 @@ case 99: case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -4420,9 +4583,9 @@ case 102: case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -4431,10 +4594,10 @@ case 104: case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4451,9 +4614,9 @@ case 105: case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -4470,9 +4633,9 @@ case 109: case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -4484,9 +4647,9 @@ case 111: case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -4496,9 +4659,9 @@ case 112: case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4533,9 +4696,9 @@ case 113: case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4554,9 +4717,9 @@ case 114: case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -4565,9 +4728,9 @@ case 115: case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -4576,9 +4739,9 @@ case 116: case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4596,10 +4759,10 @@ case 117: case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -4617,10 +4780,10 @@ case 118: case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -4641,9 +4804,9 @@ case 119: case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4676,9 +4839,9 @@ case 120: case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4704,9 +4867,9 @@ case 121: case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5.parse(yyvstack[yysp]); @@ -4715,9 +4878,9 @@ case 122: case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue(yyvstack[yysp]); @@ -4726,9 +4889,9 @@ case 123: case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4737,9 +4900,9 @@ case 124: case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -4760,10 +4923,10 @@ case 125: case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4780,9 +4943,9 @@ case 126: case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -4801,9 +4964,9 @@ case 128: case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4827,9 +4990,9 @@ case 130: case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -4849,9 +5012,9 @@ case 131: case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4862,9 +5025,9 @@ case 133: case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -4920,10 +5083,10 @@ case 134: case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6526,7 +6689,6 @@ defaultActions: bda({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -6543,38 +6705,34 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -6582,20 +6740,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -6617,7 +6773,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -6625,18 +6780,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -6644,24 +6800,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -6699,18 +6850,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -6731,7 +6879,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -6749,7 +6897,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -6762,7 +6909,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -6776,11 +6922,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -6834,8 +6979,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6843,8 +6988,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6876,19 +7021,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -6899,7 +7043,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -6912,7 +7056,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -6924,29 +7068,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -6954,7 +7096,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -6974,8 +7116,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -6984,10 +7125,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -6995,7 +7136,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -7006,9 +7147,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -7024,8 +7170,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -7094,11 +7239,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -7109,8 +7257,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -7119,21 +7266,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -7143,21 +7289,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -7166,28 +7311,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -7200,8 +7344,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -7224,8 +7367,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -7237,8 +7379,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -7255,8 +7396,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -7270,8 +7410,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -7285,7 +7424,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -7338,16 +7477,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -7381,9 +7517,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -7406,9 +7540,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -7435,17 +7567,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -7492,8 +7623,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -7505,8 +7636,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -7524,6 +7654,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -7532,7 +7663,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -7543,7 +7674,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -7603,10 +7734,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -7641,9 +7772,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -7656,7 +7785,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -7677,9 +7806,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7701,12 +7828,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -7715,7 +7842,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7756,7 +7883,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -7803,7 +7930,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -7821,21 +7948,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7869,14 +7994,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7886,6 +8012,7 @@ parse: function parse(input) { + } continue; // accept: @@ -7937,7 +8064,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -7953,9 +8080,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7984,7 +8109,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -8001,8 +8126,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -8013,8 +8138,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -8026,21 +8151,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -8071,14 +8194,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -8088,6 +8212,7 @@ parse: function parse(input) { + } continue; // accept: @@ -8140,8 +8265,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -8402,7 +8526,6 @@ var lexer = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -8419,10 +8542,10 @@ var lexer = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -8454,7 +8577,7 @@ var lexer = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -8496,7 +8619,9 @@ var lexer = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -8582,7 +8707,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -8590,7 +8715,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -8603,7 +8728,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -8629,10 +8754,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -8655,7 +8783,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -8678,16 +8805,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -8709,7 +8836,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -8717,8 +8843,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -8747,7 +8873,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -8772,7 +8898,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -8784,17 +8910,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -8888,7 +9014,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -8909,7 +9035,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -8920,7 +9045,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -8931,15 +9056,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -8973,8 +9098,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -9007,9 +9132,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -9028,9 +9153,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -9040,8 +9165,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -9068,20 +9193,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -9121,17 +9245,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -9140,7 +9266,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -9155,8 +9281,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -9182,24 +9308,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -9210,7 +9338,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -9232,8 +9360,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -9255,8 +9383,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -9400,21 +9527,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -9429,11 +9556,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -9452,13 +9579,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -9482,13 +9609,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -9503,8 +9630,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -9535,7 +9662,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -9567,9 +9694,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -9598,7 +9725,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -9616,7 +9743,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -9641,7 +9768,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -9651,8 +9777,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -9661,7 +9785,7 @@ EOF: 1, this.clear(); } - 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. @@ -9673,13 +9797,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -9689,68 +9813,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -9775,7 +9905,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -9823,24 +9953,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9860,7 +9990,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -9870,24 +10000,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9908,8 +10038,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -9949,14 +10078,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -9972,9 +10101,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -9985,8 +10114,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -9994,7 +10123,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -11684,7 +11813,7 @@ const UNICODE_BASE_PLANE_MAX_CP = 65535; // The expanded regex sets which are equivalent to the given `\\{c}` escapes: // // `/\s/`: -const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; +const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; // `/\d/`: const DIGIT_SETSTR = '0-9'; // `/\w/`: @@ -11696,7 +11825,7 @@ const WORDCHAR_SETSTR = 'A-Za-z0-9_'; // Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex function i2c(i) { - var c, x; + let c, x; switch (i) { case 10: @@ -11736,7 +11865,7 @@ function i2c(i) { || i > 0xFFF0 /* Unicode Specials, also in UTF16 */ || (i >= 0xD800 && i <= 0xDFFF) /* Unicode Supplementary Planes; we're TOAST in JavaScript as we're NOT UTF-16 but UCS-2! */ || String.fromCharCode(i).match(/[\u2028\u2029]/) /* Code compilation via `new Function()` does not like to see these, or rather: treats them as just another form of CRLF, which breaks your generated regex code! */ - ) { + ) { // Detail about a detail: // U+2028 and U+2029 are part of the `\s` regex escape code (`\s` and `[\s]` match either of these) and when placed in a JavaScript // source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report @@ -11744,11 +11873,10 @@ function i2c(i) { // Hence we MUST escape these buggers everywhere we go... x = i.toString(16); if (x.length >= 1 && i <= 0xFFFF) { - c = '0000' + x; - return '\\u' + c.substr(c.length - 4); - } else { - return '\\u{' + x + '}'; + c = '0000' + x; + return '\\u' + c.substr(c.length - 4); } + return '\\u{' + x + '}'; } return String.fromCharCode(i); } @@ -11757,18 +11885,18 @@ function i2c(i) { // Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating // this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a // `\\p{NAME}` shorthand to represent [part of] the bitarray: -var Pcodes_bitarray_cache = {}; -var Pcodes_bitarray_cache_test_order = []; +let Pcodes_bitarray_cache = {}; +let Pcodes_bitarray_cache_test_order = []; -// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by +// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. -var EscCode_bitarray_output_refs; +let EscCode_bitarray_output_refs; // now initialize the EscCodes_... table above: init_EscCode_lookup_table(); function init_EscCode_lookup_table() { - var s, bitarr, set2esc = {}, esc2bitarr = {}; + let s, bitarr, set2esc = {}, esc2bitarr = {}; // patch global lookup tables for the time being, while we calculate their *real* content in this function: EscCode_bitarray_output_refs = { @@ -11837,13 +11965,13 @@ function init_EscCode_lookup_table() { }; updatePcodesBitarrayCacheTestOrder(); -} +} function updatePcodesBitarrayCacheTestOrder(opts) { - var t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var l = {}; - var user_has_xregexp = opts && opts.options && opts.options.xregexp; - var i, j, k, ba; + let t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let l = {}; + let user_has_xregexp = opts && opts.options && opts.options.xregexp; + let i, j, k, ba; // mark every character with which regex pcodes they are part of: for (k in Pcodes_bitarray_cache) { @@ -11853,12 +11981,12 @@ function updatePcodesBitarrayCacheTestOrder(opts) { continue; } - var cnt = 0; + let cnt = 0; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { cnt++; if (!t[i]) { - t[i] = [k]; + t[i] = [ k ]; } else { t[i].push(k); } @@ -11868,27 +11996,27 @@ function updatePcodesBitarrayCacheTestOrder(opts) { } // now dig out the unique ones: only need one per pcode. - // + // // We ASSUME every \\p{NAME} 'pcode' has at least ONE character - // in it that is ONLY matched by that particular pcode. + // in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode - // won't be tested during optimization. - // + // won't be tested during optimization. + // // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to // look for markers which match multiple escapes/pcodes for those // ones where a unique item isn't available... - var lut = []; - var done = {}; - var keys = Object.keys(Pcodes_bitarray_cache); + let lut = []; + let done = {}; + let keys = Object.keys(Pcodes_bitarray_cache); for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { k = t[i][0]; if (t[i].length === 1 && !done[k]) { assert$1(l[k] > 0); - lut.push([i, k]); + lut.push([ i, k ]); done[k] = true; } } @@ -11899,19 +12027,19 @@ function updatePcodesBitarrayCacheTestOrder(opts) { if (!user_has_xregexp && k.indexOf('\\p{') >= 0) { continue; } - + if (!done[k]) { assert$1(l[k] > 0); // find a minimum span character to mark this one: - var w = Infinity; + let w = Infinity; var rv; ba = Pcodes_bitarray_cache[k]; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { - var tl = t[i].length; + let tl = t[i].length; if (tl > 1 && tl < w) { assert$1(l[k] > 0); - rv = [i, k]; + rv = [ i, k ]; w = tl; } } @@ -11925,16 +12053,16 @@ function updatePcodesBitarrayCacheTestOrder(opts) { // order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. - // + // // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more - // optimal minification of the regex set expression. - // + // optimal minification of the regex set expression. + // // This is a guestimate/heuristic only! lut.sort(function (a, b) { - var k1 = a[1]; - var k2 = b[1]; - var ld = l[k2] - l[k1]; + let k1 = a[1]; + let k2 = b[1]; + let ld = l[k2] - l[k1]; if (ld) { return ld; } @@ -11952,19 +12080,19 @@ function updatePcodesBitarrayCacheTestOrder(opts) { // 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set. function set2bitarray(bitarr, s, opts) { - var orig = s; - var set_is_inverted = false; - var bitarr_orig; + let orig = s; + let set_is_inverted = false; + let bitarr_orig; function mark(d1, d2) { if (d2 == null) d2 = d1; - for (var i = d1; i <= d2; i++) { + for (let i = d1; i <= d2; i++) { bitarr[i] = true; } } function add2bitarray(dst, src) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (src[i]) { dst[i] = true; } @@ -11972,10 +12100,10 @@ function set2bitarray(bitarr, s, opts) { } function eval_escaped_code(s) { - var c; + let c; // decode escaped code? If none, just take the character as-is if (s.indexOf('\\') === 0) { - var l = s.substr(0, 2); + let l = s.substr(0, 2); switch (l) { case '\\c': c = s.charCodeAt(2) - 'A'.charCodeAt(0) + 1; @@ -11993,7 +12121,7 @@ function set2bitarray(bitarr, s, opts) { } c = parseInt(s, 16); if (c >= 0x10000) { - return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); + return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); } return String.fromCharCode(c); @@ -12037,7 +12165,7 @@ function set2bitarray(bitarr, s, opts) { } if (s && s.length) { - var c1, c2; + let c1, c2; // inverted set? if (s[0] === '^') { @@ -12068,13 +12196,13 @@ function set2bitarray(bitarr, s, opts) { c2 = c2[0]; s = s.substr(c2.length); // do we have this one cached already? - var pex = c1 + c2; - var ba4p = Pcodes_bitarray_cache[pex]; + let pex = c1 + c2; + let ba4p = Pcodes_bitarray_cache[pex]; if (!ba4p) { // expand escape: - var xr = new XRegExp('[' + pex + ']'); // TODO: case-insensitive grammar??? + let xr = new XRegExp('[' + pex + ']'); // TODO: case-insensitive grammar??? // rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`: - var xs = '' + xr; + let xs = '' + xr; // remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: xs = xs.substr(1, xs.length - 2); @@ -12109,7 +12237,7 @@ function set2bitarray(bitarr, s, opts) { break; } } - var v1 = eval_escaped_code(c1); + let v1 = eval_escaped_code(c1); // propagate deferred exceptions = error reports. if (v1 instanceof Error) { return v1; @@ -12127,7 +12255,7 @@ function set2bitarray(bitarr, s, opts) { } else { c2 = c2[0]; } - var v2 = eval_escaped_code(c2); + let v2 = eval_escaped_code(c2); // propagate deferred exceptions = error reports. if (v2 instanceof Error) { return v1; @@ -12150,12 +12278,12 @@ function set2bitarray(bitarr, s, opts) { } // When we have marked all slots, '^' NEGATES the set, hence we flip all slots. - // + // // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. if (set_is_inverted) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (!bitarr[i]) { bitarr_orig[i] = true; } @@ -12174,10 +12302,10 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // below can be simple and fast: l[UNICODE_BASE_PLANE_MAX_CP + 1] = 1; // now reconstruct the regex set: - var rv = []; - var i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; - var bitarr_is_cloned = false; - var l_orig = l; + let rv = []; + let i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; + let bitarr_is_cloned = false; + let l_orig = l; if (output_inverted_variant) { // generate the inverted set, hence all unmarked slots are part of the output range: @@ -12191,8 +12319,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. // BUT... since we output the INVERTED set, we output the match-all set instead: return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` // BUT... since we output the INVERTED set, we output the match-nothing set instead: @@ -12224,9 +12351,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12253,7 +12380,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } } - + i = 0; while (i <= UNICODE_BASE_PLANE_MAX_CP) { // find first character not in original set: @@ -12284,8 +12411,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. return '^\\S\\s'; } @@ -12315,9 +12441,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12369,11 +12495,11 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } assert$1(rv.length); - var s = rv.join(''); + let s = rv.join(''); assert$1(s); // Check if the set is better represented by one of the regex escapes: - var esc4s = EscCode_bitarray_output_refs.set2esc[s]; + let esc4s = EscCode_bitarray_output_refs.set2esc[s]; if (esc4s) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return '\\' + esc4s; @@ -12388,25 +12514,24 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there; // ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`. function reduceRegexToSetBitArray(s, name, opts) { - var orig = s; + let orig = s; // propagate deferred exceptions = error reports. if (s instanceof Error) { return s; } - var l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var internal_state = 0; - var derr; + let l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let internal_state = 0; + let derr; while (s.length) { - var c1 = s.match(CHR_RE); + let c1 = s.match(CHR_RE); if (!c1) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"'); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12414,15 +12539,14 @@ function reduceRegexToSetBitArray(s, name, opts) { // this is starting a set within the regex: scan until end of set! var set_content = []; while (s.length) { - var inner = s.match(SET_PART_RE); + let inner = s.match(SET_PART_RE); if (!inner) { inner = s.match(CHR_RE); if (!inner) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"'); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12436,9 +12560,8 @@ function reduceRegexToSetBitArray(s, name, opts) { if (!c2) { // cope with illegal escape sequences too! return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error('regex set expression is broken in regex: ' + orig); } @@ -12522,10 +12645,9 @@ function reduceRegexToSetBitArray(s, name, opts) { // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; assert$1(s); assert$1(!(s instanceof Error)); - re = new XRegExp('[' + s + ']'); + let re = new XRegExp('[' + s + ']'); re.test(s[0]); // One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` @@ -12550,25 +12672,24 @@ function reduceRegexToSetBitArray(s, name, opts) { -// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` +// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! function produceOptimizedRegex4Set(bitarr) { // First try to produce a minimum regex from the bitarray directly: - var s1 = bitarray2set(bitarr, false, true); + let s1 = bitarray2set(bitarr, false, true); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s1.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s1; - } else { - s1 = '[' + s1 + ']'; } + s1 = '[' + s1 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s2 = bitarray2set(bitarr, true, true); + let s2 = bitarray2set(bitarr, true, true); if (s2[0] === '^') { s2 = s2.substr(1); @@ -12583,23 +12704,22 @@ function produceOptimizedRegex4Set(bitarr) { // Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: - // + // // First try to produce a minimum regex from the bitarray directly: - var s3 = bitarray2set(bitarr, false, false); + let s3 = bitarray2set(bitarr, false, false); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s3.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s3; - } else { - s3 = '[' + s3 + ']'; } + s3 = '[' + s3 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s4 = bitarray2set(bitarr, true, false); + let s4 = bitarray2set(bitarr, true, false); if (s4[0] === '^') { s4 = s4.substr(1); @@ -12631,30 +12751,30 @@ function produceOptimizedRegex4Set(bitarr) { var setmgmt = { - XREGEXP_UNICODE_ESCAPE_RE, - CHR_RE, - SET_PART_RE, - NOTHING_SPECIAL_RE, - SET_IS_SINGLE_PCODE_RE, - - UNICODE_BASE_PLANE_MAX_CP, - - WHITESPACE_SETSTR, - DIGIT_SETSTR, - WORDCHAR_SETSTR, - - set2bitarray, - bitarray2set, - produceOptimizedRegex4Set, - reduceRegexToSetBitArray, + XREGEXP_UNICODE_ESCAPE_RE, + CHR_RE, + SET_PART_RE, + NOTHING_SPECIAL_RE, + SET_IS_SINGLE_PCODE_RE, + + UNICODE_BASE_PLANE_MAX_CP, + + WHITESPACE_SETSTR, + DIGIT_SETSTR, + WORDCHAR_SETSTR, + + set2bitarray, + bitarray2set, + produceOptimizedRegex4Set, + reduceRegexToSetBitArray }; // Basic Lexer implemented using JavaScript regular expressions -var rmCommonWS$2 = helpers.rmCommonWS; -var mkIdentifier$3 = helpers.mkIdentifier; -var code_exec$1 = helpers.exec; +const rmCommonWS$2 = helpers.rmCommonWS; +const mkIdentifier$3 = helpers.mkIdentifier; +const code_exec = helpers.exec; -var version = '0.6.2-220'; // require('./package.json').version; +const version = '0.6.2-220'; // require('./package.json').version; @@ -12715,7 +12835,7 @@ const defaultJisonLexOptions = { exportAST: false, prettyCfg: true, pre_lex: undefined, - post_lex: undefined, + post_lex: undefined }; @@ -12733,23 +12853,23 @@ const defaultJisonLexOptions = { // Return a fresh set of options. /** @public */ function mkStdOptions(/*...args*/) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - var args = [].concat.apply([], arguments); + let opts = {}; + let args = [].concat.apply([], arguments); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(defaultJisonLexOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; for (var p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { @@ -12787,7 +12907,7 @@ function mkStdOptions(/*...args*/) { function prepExportStructures(options) { // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -12808,8 +12928,8 @@ function prepExportStructures(options) { // Otherwise return the *parsed* lexer spec as it has // been processed through LexParser. function autodetectAndConvertToJSONformat(lexerSpec, options) { - var chk_l = null; - var ex1, err; + let chk_l = null; + let ex1, err; if (typeof lexerSpec === 'string') { if (options.json) { @@ -12861,9 +12981,9 @@ function autodetectAndConvertToJSONformat(lexerSpec, options) { /should be separated/, /an error in one or more of your lexer regex rules/, /an error in your lexer epilogue/, - /unsupported definition type/, + /unsupported definition type/ ]; - var cmnerr = commonErrors.filter(function check(re) { + let cmnerr = commonErrors.filter(function check(re) { return e.message.match(re); }); if (cmnerr.length > 0) { @@ -12892,14 +13012,14 @@ function autodetectAndConvertToJSONformat(lexerSpec, options) { // expand macros and convert matchers to RegExp's function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) { - var m, i, k, rule, action, conditions; - var active_conditions; + let m, i, k, rule, action, conditions; + let active_conditions; assert$1(Array.isArray(dict.rules)); - var rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! - var newRules = []; - var macros = {}; - var regular_rule_count = 0; - var simple_rule_count = 0; + let rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! + let newRules = []; + let macros = {}; + let regular_rule_count = 0; + let simple_rule_count = 0; // Assure all options are camelCased: assert$1(typeof opts.options['case-insensitive'] === 'undefined'); @@ -12909,7 +13029,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) } if (opts.options.flex && rules.length > 0) { - rules.push(['.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']); + rules.push([ '.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */' ]); } // Depending on the location within the regex we need different expansions of the macros: @@ -12933,7 +13053,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) return str; } - var routingCode = ['switch(yyrulenumber) {']; + let routingCode = [ 'switch(yyrulenumber) {' ]; for (i = 0; i < rules.length; i++) { rule = rules[i].slice(0); // shallow copy: do not modify input rules @@ -12987,7 +13107,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) action = action.replace(/return\s*\(?'((?:\\'|[^']+)+)'\)?/g, tokenNumberReplacement); action = action.replace(/return\s*\(?"((?:\\"|[^"]+)+)"\)?/g, tokenNumberReplacement); - var code = ['\n/*! Conditions::']; + let code = [ '\n/*! Conditions::' ]; code.push(postprocessComment(active_conditions)); code.push('*/', '\n/*! Rule:: '); code.push(postprocessComment(rule[0])); @@ -13008,7 +13128,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) // 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'. - var match_nr = /^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim()); + 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 ')); @@ -13035,7 +13155,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) macros: macros, regular_rule_count: regular_rule_count, - simple_rule_count: simple_rule_count, + simple_rule_count: simple_rule_count }; } @@ -13048,14 +13168,13 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) // 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. function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElsewhere_cb) { - var orig = s; + let orig = s; function errinfo() { if (name) { return 'macro [[' + name + ']]'; - } else { - return 'regex [[' + orig + ']]'; } + return 'regex [[' + orig + ']]'; } // propagate deferred exceptions = error reports. @@ -13063,19 +13182,18 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse return s; } - var c1, c2; - var rv = []; - var derr; - var se; + let c1, c2; + let rv = []; + let derr; + let se; while (s.length) { c1 = s.match(CHR_RE$1); if (!c1) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -13085,15 +13203,14 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse var l = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1); while (s.length) { - var inner = s.match(SET_PART_RE$1); + let inner = s.match(SET_PART_RE$1); if (!inner) { inner = s.match(CHR_RE$1); if (!inner) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -13107,9 +13224,8 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse if (!c2) { // cope with illegal escape sequences too! return new Error(errinfo() + ': regex set expression is broken: "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error(errinfo() + ': regex set expression is broken: apparently unterminated'); } @@ -13170,7 +13286,7 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse c2 = c2[0]; s = s.substr(c2.length); - var c3 = s[0]; + let c3 = s[0]; s = s.substr(c3.length); if (c3 === '}') { // possibly a macro name in there... Expand if possible: @@ -13223,7 +13339,7 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; + let re; re = new XRegExp(s); re.test(s[0]); } catch (ex) { @@ -13239,11 +13355,11 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse // expand macros within macros and cache the result function prepareMacros(dict_macros, opts) { - var macros = {}; + let macros = {}; // expand a `{NAME}` macro which exists inside a `[...]` set: function expandMacroInSet(i) { - var k, a, m; + let k, a, m; if (!macros[i]) { m = dict_macros[i]; @@ -13277,7 +13393,7 @@ function prepareMacros(dict_macros, opts) { a = m.split('{' + k + '}'); if (a.length > 1) { - var x = expandMacroInSet(k); + let x = expandMacroInSet(k); assert$1(x); if (x instanceof Error) { m = x; @@ -13289,9 +13405,9 @@ function prepareMacros(dict_macros, opts) { } } - var mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); + let mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); - var s1; + let s1; // propagate deferred exceptions = error reports. if (mba instanceof Error) { @@ -13325,7 +13441,7 @@ function prepareMacros(dict_macros, opts) { } function expandMacroElsewhere(i) { - var m; + let m; if (macros[i].elsewhere == null) { m = dict_macros[i]; @@ -13360,13 +13476,13 @@ function prepareMacros(dict_macros, opts) { } function expandAllMacrosInSet(s) { - var i, x; + let i, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { for (i in macros) { if (macros.hasOwnProperty(i)) { - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroInSet(i); assert$1(x); @@ -13388,7 +13504,7 @@ function prepareMacros(dict_macros, opts) { } function expandAllMacrosElsewhere(s) { - var i, x; + let i, x; // When we process the remaining macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13403,7 +13519,7 @@ function prepareMacros(dict_macros, opts) { for (i in macros) { if (macros.hasOwnProperty(i)) { // These are all submacro expansions, hence non-capturing grouping is applied: - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroElsewhere(i); assert$1(x); @@ -13425,7 +13541,7 @@ function prepareMacros(dict_macros, opts) { } - var i; + let i; if (opts.debug) console.log('\n############## RAW macros: ', dict_macros); @@ -13456,13 +13572,13 @@ function prepareMacros(dict_macros, opts) { // expand macros in a regex; expands them recursively function expandMacros(src, macros, opts) { - var expansion_count = 0; + let expansion_count = 0; // By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! // Hence things should be easy in there: function expandAllMacrosInSet(s) { - var i, m, x; + let i, m, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { @@ -13470,7 +13586,7 @@ function expandMacros(src, macros, opts) { if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = m.in_set; @@ -13501,7 +13617,7 @@ function expandMacros(src, macros, opts) { } function expandAllMacrosElsewhere(s) { - var i, m, x; + let i, m, x; // When we process the main macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13517,7 +13633,7 @@ function expandMacros(src, macros, opts) { if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { // These are all main macro expansions, hence CAPTURING grouping is applied: x = m.elsewhere; @@ -13553,7 +13669,7 @@ function expandMacros(src, macros, opts) { // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! - var s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); + let s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); // propagate deferred exceptions = error reports. if (s2 instanceof Error) { throw s2; @@ -13578,8 +13694,8 @@ function expandMacros(src, macros, opts) { } function prepareStartConditions(conditions) { - var sc; - var hash = {}; + let sc; + let hash = {}; for (sc in conditions) { if (conditions.hasOwnProperty(sc)) { @@ -13593,22 +13709,22 @@ function prepareStartConditions(conditions) { } function buildActions(dict, tokens, opts) { - var actions = [dict.actionInclude || '', 'var YYSTATE = YY_START;']; - var tok; - var toks = {}; - var caseHelper = []; + let actions = [ dict.actionInclude || '', 'var YYSTATE = YY_START;' ]; + let tok; + let toks = {}; + let caseHelper = []; // tokens: map/array of token numbers to token names for (tok in tokens) { - var idx = parseInt(tok); + let idx = parseInt(tok); if (idx && idx > 0) { toks[tokens[tok]] = idx; } } - var gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); + let gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); - var code = actions.join('\n'); + let code = actions.join('\n'); 'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function (yy) { code = code.replace(new RegExp('\\b(' + yy + ')\\b', 'g'), 'yy_.$1'); }); @@ -13626,7 +13742,7 @@ function buildActions(dict, tokens, opts) { macros: gen.macros, // propagate these for debugging/diagnostic purposes regular_rule_count: gen.regular_rule_count, - simple_rule_count: gen.simple_rule_count, + simple_rule_count: gen.simple_rule_count }; } @@ -13637,7 +13753,7 @@ function buildActions(dict, tokens, opts) { function generateErrorClass() { // --- START lexer error class --- -var prelude = `/** +const prelude = `/** * 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 @@ -13648,8 +13764,6 @@ var prelude = `/** * @nocollapse */ function JisonLexerError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -13666,9 +13780,9 @@ function JisonLexerError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -13729,8 +13843,8 @@ function generateFakeXRegExpClassSrcCode() { /** @constructor */ function RegExpLexer(dict, input, tokens, build_options) { - var opts; - var dump = false; + let opts; + let dump = false; function test_me(tweak_cb, description, src_exception, ex_callback) { opts = processGrammar(dict, tokens, build_options); @@ -13740,7 +13854,7 @@ function RegExpLexer(dict, input, tokens, build_options) { if (tweak_cb) { tweak_cb(); } - var source = generateModuleBody(opts); + let source = generateModuleBody(opts); try { // The generated code will always have the `lexer` variable declared at local scope // as `eval()` will use the local scope. @@ -13748,16 +13862,16 @@ function RegExpLexer(dict, input, tokens, build_options) { // The compiled code will look something like this: // // ``` - // var lexer; + // let lexer; // bla bla... // ``` // // or // // ``` - // var lexer = { bla... }; + // const lexer = { bla... }; // ``` - var testcode = [ + let testcode = [ '// provide a local version for test purposes:', jisonLexerErrorDefinition, '', @@ -13765,14 +13879,33 @@ function RegExpLexer(dict, input, tokens, build_options) { '', source, '', + rmCommonWS$2` + // JISON INJECTED VALIDATION CODE + // which attempts to ascertain you have defined a minimal viable lexer at least: + if (typeof lexer === "undefined") { + throw new SyntaxError("user-defined lexer does not define the required 'lexer' instance."); + } + if (!lexer) { + throw new SyntaxError("user-defined lexer does not define a non-NULL 'lexer' instance."); + } + if (typeof lexer.setInput !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.setInput()' API function."); + } + if (typeof lexer.lex !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.lex()' API function."); + } + // END OF JISON INJECTED VALIDATION CODE + `, 'return lexer;' ].join('\n'); - var lexer = code_exec$1(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { + let lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { //console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$2(sourcecode); - var lexer_f = new Function('', sourcecode); + let lexer_f = new Function('', sourcecode); return lexer_f(); - }, opts.options, "lexer"); + }, Object.assign({}, opts.options, { + throwErrorOnCompileFailure: true + }), 'lexer'); if (!lexer) { throw new Error('no lexer defined *at all*?!'); @@ -13789,7 +13922,7 @@ function RegExpLexer(dict, input, tokens, build_options) { // When we do NOT crash, we found/killed the problem area just before this call! if (src_exception && description) { - var msg = description; + let msg = description; if (typeof description === 'function') { msg = description(); } @@ -13798,8 +13931,8 @@ function RegExpLexer(dict, input, tokens, build_options) { // patch the pre and post handlers in there, now that we have some live code to work with: if (opts.options) { - var pre = opts.options.pre_lex; - var post = opts.options.post_lex; + let pre = opts.options.pre_lex; + let post = opts.options.post_lex; // since JSON cannot encode functions, we'll have to do it manually now: if (typeof pre === 'function') { lexer.options.pre_lex = pre; @@ -13813,7 +13946,7 @@ function RegExpLexer(dict, input, tokens, build_options) { if (typeof opts.options.showSource === 'function') { opts.options.showSource(lexer, source, opts, RegExpLexer); } else { - console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n"); + console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n', source, '\n----------------------------------------\n'); } } return lexer; @@ -13832,13 +13965,13 @@ function RegExpLexer(dict, input, tokens, build_options) { } /** @constructor */ - var lexer = test_me(null, null, null, function (ex) { + let lexer = test_me(null, null, null, function (ex) { // When we get an exception here, it means some part of the user-specified lexer is botched. // // Now we go and try to narrow down the problem area/category: assert$1(opts.options); assert$1(opts.options.xregexp !== undefined); - var orig_xregexp_opt = !!opts.options.xregexp; + let orig_xregexp_opt = !!opts.options.xregexp; if (!test_me(function () { assert$1(opts.options.xregexp !== undefined); opts.options.xregexp = false; @@ -13857,7 +13990,7 @@ function RegExpLexer(dict, input, tokens, build_options) { 'Your custom lexer is somehow botched.' ); }, ex, null)) { - var rulesSpecSize; + let rulesSpecSize; if (!test_me(function () { // store the parsed rule set size so we can use that info in case // this attempt also fails: @@ -13870,7 +14003,7 @@ function RegExpLexer(dict, input, tokens, build_options) { opts.__in_rules_failure_analysis_mode__ = true; }, 'One or more of your lexer rules are possibly botched?', ex, null)) { // kill each rule action block, one at a time and test again after each 'edit': - var rv = false; + let rv = false; for (var i = 0, len = rulesSpecSize; i < len; i++) { var lastEditedRuleSpec; rv = test_me(function () { @@ -13882,10 +14015,10 @@ function RegExpLexer(dict, input, tokens, build_options) { // opts.__in_rules_failure_analysis_mode__ = true; // nuke all rules' actions up to and including rule numero `i`: - for (var j = 0; j <= i; j++) { + for (let j = 0; j <= i; j++) { // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; // now we want to edit the *action* part: - var rule = opts.rules[j]; + let rule = opts.rules[j]; assert$1(Array.isArray(rule)); assert$1(rule.length === 2 || rule.length === 3); rule.pop(); @@ -14019,8 +14152,6 @@ return `{ * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -14030,14 +14161,14 @@ return `{ } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\\n\\s*$/.test(msg)) { msg += '\\n'; } msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') { msg += '\\n' + pos_str; @@ -14048,14 +14179,14 @@ return `{ } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the \`upcomingInput\` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -14075,9 +14206,8 @@ return `{ // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -14097,8 +14227,6 @@ return `{ * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -14119,16 +14247,14 @@ return `{ * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -14149,8 +14275,6 @@ return `{ * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -14158,8 +14282,8 @@ return `{ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -14177,8 +14301,6 @@ return `{ * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -14188,14 +14310,14 @@ return `{ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -14206,8 +14328,6 @@ return `{ * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -14215,40 +14335,40 @@ return `{ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -14260,7 +14380,7 @@ return `{ this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -14268,7 +14388,7 @@ return `{ last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -14329,9 +14449,7 @@ return `{ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -14350,8 +14468,6 @@ return `{ * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set \`done\` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -14360,7 +14476,7 @@ return `{ this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -14370,13 +14486,13 @@ return `{ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\\n') { lines = true; } else if (ch === '\\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\\n') { slice_len++; ch += ch2; @@ -14408,10 +14524,8 @@ return `{ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -14443,8 +14557,8 @@ return `{ // Get last entirely matched line into the \`pre_lines[]\` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -14462,9 +14576,9 @@ return `{ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -14474,14 +14588,12 @@ return `{ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -14492,8 +14604,6 @@ return `{ * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -14506,19 +14616,17 @@ return `{ * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the \`parseError()\` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // \`.lex()\` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -14531,8 +14639,6 @@ return `{ * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -14555,24 +14661,24 @@ return `{ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substr\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14584,8 +14690,8 @@ return `{ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to \`maxSize\` (default: 20). @@ -14611,24 +14717,25 @@ return `{ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > \`lookAhead()\` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substring\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -14637,7 +14744,7 @@ return `{ } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14656,10 +14763,8 @@ return `{ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^'; }, @@ -14681,15 +14786,13 @@ return `{ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -14820,58 +14923,54 @@ return `{ * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\\t/g, ' '); @@ -14880,13 +14979,13 @@ return `{ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -14908,15 +15007,13 @@ return `{ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -14928,8 +15025,8 @@ return `{ rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -14958,13 +15055,7 @@ return `{ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -14993,10 +15084,10 @@ return `{ }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -15024,7 +15115,7 @@ return `{ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -15035,7 +15126,7 @@ return `{ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -15057,8 +15148,6 @@ return `{ * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -15067,17 +15156,13 @@ return `{ this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -15087,67 +15172,75 @@ return `{ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that \`parseError()\` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) \`parseError()\` @@ -15174,9 +15267,7 @@ return `{ * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15219,24 +15310,24 @@ return `{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15256,9 +15347,7 @@ return `{ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15268,24 +15357,24 @@ return `{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15293,7 +15382,7 @@ return `{ this._clear_state = 0; } - + return r; }, @@ -15306,9 +15395,7 @@ return `{ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -15316,7 +15403,7 @@ return `{ (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -15331,8 +15418,6 @@ return `{ * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -15344,8 +15429,6 @@ return `{ * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -15359,15 +15442,12 @@ return `{ * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -15379,14 +15459,11 @@ return `{ * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -15397,16 +15474,14 @@ return `{ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -15416,8 +15491,6 @@ return `{ * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; } }`; @@ -15449,18 +15522,17 @@ function stripUnusedLexerCode(src, opt) { // ............................. ${opt.lexerActionsUseDisplayAPIs} // uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC} - var new_src; + let new_src; try { - var ast = helpers.parseCodeChunkToAST(src, opt); + let ast = helpers.parseCodeChunkToAST(src, opt); new_src = helpers.prettyPrintAST(ast, opt); - } - catch (ex) { + } catch (ex) { let line = ex.lineNumber || 0; let a = src.split(/\r?\n/g); let len = a.length; let minl = Math.max(0, line - 10); let b = a.slice(minl, line + 10); - let c = b.splice(line - minl, 0, "", "^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", ""); + let c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); let offendingChunk = ' ' + b.join('\n '); console.error(rmCommonWS$2` stripUnusedLexerCode WARNING: @@ -15476,17 +15548,11 @@ function stripUnusedLexerCode(src, opt) { ${offendingChunk} `); - + new_src = src; } - - - - - - // inject analysis report now: new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2` // Code Generator Information Report @@ -15541,7 +15607,7 @@ function stripUnusedLexerCode(src, opt) { // generate lexer source from a grammar /** @public */ function generate(dict, tokens, build_options) { - var opt = processGrammar(dict, tokens, build_options); + let opt = processGrammar(dict, tokens, build_options); return generateFromOpts(opt); } @@ -15550,7 +15616,7 @@ function generate(dict, tokens, build_options) { /** @public */ function processGrammar(dict, tokens, build_options) { build_options = build_options || {}; - var opts = { + let opts = { // include the knowledge passed through `build_options` about which lexer // features will actually be *used* by the environment (which in 99.9% // of cases is a jison *parser*): @@ -15590,7 +15656,7 @@ function processGrammar(dict, tokens, build_options) { lexerActionsUseReject: '???', lexerActionsUseLess: '???', lexerActionsUseDisplayAPIs: '???', - lexerActionsUseDescribeYYLOC: '???', + lexerActionsUseDescribeYYLOC: '???' }; dict = autodetectAndConvertToJSONformat(dict, build_options) || {}; @@ -15615,7 +15681,7 @@ function processGrammar(dict, tokens, build_options) { // only produce rule action code blocks when there are any rules at all; // a "custom lexer" has ZERO rules and must be defined entirely in // other code blocks: - var code = (dict.rules ? buildActions(dict, tokens, opts) : {}); + let code = (dict.rules ? buildActions(dict, tokens, opts) : {}); opts.performAction = code.actions; opts.caseHelperInclude = code.caseHelperInclude; opts.rules = code.rules || []; @@ -15624,7 +15690,7 @@ function processGrammar(dict, tokens, build_options) { opts.regular_rule_count = code.regular_rule_count; opts.simple_rule_count = code.simple_rule_count; - opts.conditionStack = ['INITIAL']; + opts.conditionStack = [ 'INITIAL' ]; opts.actionInclude = (dict.actionInclude || ''); opts.moduleInclude = (opts.moduleInclude || '') + (dict.moduleInclude || '').trim(); @@ -15635,7 +15701,7 @@ function processGrammar(dict, tokens, build_options) { // Assemble the final source from the processed grammar /** @public */ function generateFromOpts(opt) { - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -15658,12 +15724,12 @@ function generateFromOpts(opt) { } function generateRegexesInitTableCode(opt) { - var a = opt.rules; - var print_xregexp = opt.options && opt.options.xregexp; - var id_display_width = (1 + Math.log10(a.length | 1) | 0); - var ws_prefix = new Array(id_display_width).join(' '); - var b = a.map(function generateXRegExpInitCode(re, idx) { - var idx_str = (ws_prefix + idx).substr(-id_display_width); + let a = opt.rules; + let print_xregexp = opt.options && opt.options.xregexp; + let id_display_width = (1 + Math.log10(a.length | 1) | 0); + let ws_prefix = new Array(id_display_width).join(' '); + let b = a.map(function generateXRegExpInitCode(re, idx) { + let idx_str = (ws_prefix + idx).substr(-id_display_width); if (re instanceof XRegExp) { // When we don't need the special XRegExp sauce at run-time, we do with the original @@ -15673,11 +15739,11 @@ function generateRegexesInitTableCode(opt) { } // And make sure to escape the regex to make it suitable for placement inside a *string* // as it is passed as a string argument to the XRegExp constructor here. - var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); + let re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); return `/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`; - } else { - return `/* ${idx_str}: */ ${re}`; } + return `/* ${idx_str}: */ ${re}`; + }); return b.join(',\n'); } @@ -15685,77 +15751,77 @@ function generateRegexesInitTableCode(opt) { function generateModuleBody(opt) { // make the JSON output look more like JavaScript: function cleanupJSON(str) { - str = str.replace(/ "rules": \[/g, ' rules: ['); - str = str.replace(/ "inclusive": /g, ' inclusive: '); + str = str.replace(/ {2}"rules": \[/g, ' rules: ['); + str = str.replace(/ {2}"inclusive": /g, ' inclusive: '); return str; } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - json: 1, - _: 1, - noMain: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - lexerErrorsAreRecoverable: 0, - flex: 0, - backtrack_lexer: 0, - caseInsensitive: 0, - showSource: 1, - exportAST: 1, - exportAllTables: 1, - exportSourceCode: 1, - prettyCfg: 1, - parseActionsUseYYLENG: 1, - parseActionsUseYYLINENO: 1, - parseActionsUseYYTEXT: 1, - parseActionsUseYYLOC: 1, - parseActionsUseParseError: 1, - parseActionsUseYYERROR: 1, - parseActionsUseYYRECOVERING: 1, - parseActionsUseYYERROK: 1, - parseActionsUseYYCLEARIN: 1, - parseActionsUseValueTracking: 1, - parseActionsUseValueAssignment: 1, - parseActionsUseLocationTracking: 1, - parseActionsUseLocationAssignment: 1, - parseActionsUseYYSTACK: 1, - parseActionsUseYYSSTACK: 1, - parseActionsUseYYSTACKPOINTER: 1, - parseActionsUseYYRULELENGTH: 1, - parseActionsUseYYMERGELOCATIONINFO: 1, - parserHasErrorRecovery: 1, - parserHasErrorReporting: 1, - lexerActionsUseYYLENG: 1, - lexerActionsUseYYLINENO: 1, - lexerActionsUseYYTEXT: 1, - lexerActionsUseYYLOC: 1, - lexerActionsUseParseError: 1, - lexerActionsUseYYERROR: 1, - lexerActionsUseLocationTracking: 1, - lexerActionsUseMore: 1, - lexerActionsUseUnput: 1, - lexerActionsUseReject: 1, - lexerActionsUseLess: 1, - lexerActionsUseDisplayAPIs: 1, - lexerActionsUseDescribeYYLOC: 1, + let obj = {}; + const do_not_pass = { + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + json: 1, + _: 1, + noMain: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + lexerErrorsAreRecoverable: 0, + flex: 0, + backtrack_lexer: 0, + caseInsensitive: 0, + showSource: 1, + exportAST: 1, + exportAllTables: 1, + exportSourceCode: 1, + prettyCfg: 1, + parseActionsUseYYLENG: 1, + parseActionsUseYYLINENO: 1, + parseActionsUseYYTEXT: 1, + parseActionsUseYYLOC: 1, + parseActionsUseParseError: 1, + parseActionsUseYYERROR: 1, + parseActionsUseYYRECOVERING: 1, + parseActionsUseYYERROK: 1, + parseActionsUseYYCLEARIN: 1, + parseActionsUseValueTracking: 1, + parseActionsUseValueAssignment: 1, + parseActionsUseLocationTracking: 1, + parseActionsUseLocationAssignment: 1, + parseActionsUseYYSTACK: 1, + parseActionsUseYYSSTACK: 1, + parseActionsUseYYSTACKPOINTER: 1, + parseActionsUseYYRULELENGTH: 1, + parseActionsUseYYMERGELOCATIONINFO: 1, + parserHasErrorRecovery: 1, + parserHasErrorReporting: 1, + lexerActionsUseYYLENG: 1, + lexerActionsUseYYLINENO: 1, + lexerActionsUseYYTEXT: 1, + lexerActionsUseYYLOC: 1, + lexerActionsUseParseError: 1, + lexerActionsUseYYERROR: 1, + lexerActionsUseLocationTracking: 1, + lexerActionsUseMore: 1, + lexerActionsUseUnput: 1, + lexerActionsUseReject: 1, + lexerActionsUseLess: 1, + lexerActionsUseDisplayAPIs: 1, + lexerActionsUseDescribeYYLOC: 1 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -15766,8 +15832,8 @@ function generateModuleBody(opt) { } // And now some options which should receive some special processing: - var pre = obj.pre_lex; - var post = obj.post_lex; + let pre = obj.pre_lex; + let post = obj.post_lex; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_lex = true; @@ -15776,7 +15842,7 @@ function generateModuleBody(opt) { obj.post_lex = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp(` "(${ID_REGEX_BASE$1})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_lex: true(,)?$/gm, function (m, ls, tc) { @@ -15789,17 +15855,17 @@ function generateModuleBody(opt) { } - var out; + let out; if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) { // we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. - var code = [rmCommonWS$2` - var lexer = { - `, '/*JISON-LEX-ANALYTICS-REPORT*/' /* slot #1: placeholder for analysis report further below */ + let code = [ rmCommonWS$2` + const lexer = { + `, '/* JISON-LEX-ANALYTICS-REPORT */\n' /* slot #1: placeholder for analysis report further below */ ]; // get the RegExpLexer.prototype in source code form: - var protosrc = getRegExpLexerPrototype(); + let protosrc = getRegExpLexerPrototype(); // and strip off the surrounding bits we don't want: protosrc = protosrc .replace(/^[\s\r\n]*\{/, '') @@ -15826,10 +15892,10 @@ function generateModuleBody(opt) { } */ - var performActionCode = String(opt.performAction); - var simpleCaseActionClustersCode = String(opt.caseHelperInclude); - var rulesCode = generateRegexesInitTableCode(opt); - var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); + let performActionCode = String(opt.performAction); + let simpleCaseActionClustersCode = String(opt.caseHelperInclude); + let rulesCode = generateRegexesInitTableCode(opt); + let conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); code.push(rmCommonWS$2`, JisonLexerError: JisonLexerError, performAction: ${performActionCode}, @@ -15849,9 +15915,9 @@ function generateModuleBody(opt) { // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // - // Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter + // Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. - out = 'var lexer;\n'; + out = '\n'; assert$1(opt.regular_rule_count === 0); assert$1(opt.simple_rule_count === 0); @@ -15865,8 +15931,6 @@ function generateModuleBody(opt) { // The output of this function is guaranteed to read something like this: // // ``` - // var lexer; - // // bla bla bla bla ... lotsa bla bla; // ``` // @@ -15875,7 +15939,7 @@ function generateModuleBody(opt) { } function generateGenericHeaderComment() { - var out = rmCommonWS$2` + let out = rmCommonWS$2` /* lexer generated by jison-lex ${version} */ /* @@ -16104,7 +16168,7 @@ function prepareOptions(opt) { // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else { @@ -16122,9 +16186,9 @@ function prepareOptions(opt) { function generateModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -16147,9 +16211,9 @@ function generateModule(opt) { function generateAMDModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} define([], function () { @@ -16172,12 +16236,12 @@ function generateAMDModule(opt) { function generateESModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} - var lexer = (function () { + const lexer = (function () { "use strict"; ${jisonLexerErrorDefinition} @@ -16206,9 +16270,9 @@ function generateESModule(opt) { function generateCommonJSModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -16250,7 +16314,6 @@ RegExpLexer.autodetectAndConvertToJSONformat = autodetectAndConvertToJSONformat; // 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. function JisonParserError$1(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -16267,9 +16330,9 @@ function JisonParserError$1(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -16302,10 +16365,10 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp$1(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -16320,18 +16383,18 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt$1(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -16362,7 +16425,7 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // `this` references an array function s$1(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -16379,9 +16442,9 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$1(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -16394,7 +16457,7 @@ JisonParserError$1.prototype.name = 'JisonParserError'; } -var parser$1 = { +let parser$1 = { // Code Generator Information Report // --------------------------------- // @@ -16520,7 +16583,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -16528,7 +16590,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -16540,8 +16601,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -16554,14 +16615,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -16577,10 +16637,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -16588,10 +16648,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -16635,9 +16695,9 @@ performAction: function parser__PerformAction(yystate /* action[1] */, yysp, yyv /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; @@ -16645,17 +16705,17 @@ performAction: function parser__PerformAction(yystate /* action[1] */, yysp, yyv case 0: /*! Production:: $accept : production $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-) break; case 1: /*! Production:: production : handle EOF */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-) return yyvstack[yysp - 1]; @@ -16891,7 +16951,6 @@ defaultActions: { 19: 3 }, parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -16908,37 +16967,32 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) + let vstack = new Array(128); // semantic value stack - var vstack = new Array(128); // semantic value stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks + let symbol = 0; - + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - var symbol = 0; - - - - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -16946,20 +17000,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -16976,7 +17028,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -16984,18 +17035,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -17003,18 +17055,14 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -17036,7 +17084,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -17049,7 +17096,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -17063,11 +17109,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -17121,8 +17166,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -17271,8 +17316,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -17281,10 +17325,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -17292,7 +17336,7 @@ parse: function parse(input) { stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -17303,9 +17347,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -17331,8 +17380,7 @@ parse: function parse(input) { function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -17341,21 +17389,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -17365,21 +17412,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -17388,20 +17434,20 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; try { @@ -17414,7 +17460,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -17467,14 +17513,11 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { - var errStr; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let errStr; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); // Report error errStr = 'Parse error'; @@ -17511,9 +17554,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -17542,7 +17583,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -17584,21 +17625,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, newState, sp - 1, vstack); +r = this.performAction.call(yyval, newState, sp - 1, vstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -17629,14 +17668,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -17646,6 +17686,7 @@ parse: function parse(input) { + } continue; // accept: @@ -17698,8 +17739,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -17959,7 +17999,6 @@ var lexer$1 = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -17976,10 +18015,10 @@ var lexer$1 = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -18011,7 +18050,7 @@ var lexer$1 = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -18053,7 +18092,9 @@ var lexer$1 = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -18139,7 +18180,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -18147,7 +18188,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -18160,7 +18201,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -18186,10 +18227,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -18212,7 +18256,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -18235,16 +18278,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -18266,7 +18309,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -18274,8 +18316,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -18304,7 +18346,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -18329,7 +18371,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -18341,17 +18383,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -18445,7 +18487,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -18466,7 +18508,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -18477,7 +18518,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -18488,15 +18529,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -18530,8 +18571,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -18564,9 +18605,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -18585,9 +18626,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -18597,8 +18638,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -18625,20 +18666,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -18678,17 +18718,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -18697,7 +18739,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -18712,8 +18754,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -18739,24 +18781,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -18767,7 +18811,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -18789,8 +18833,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -18812,8 +18856,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -18957,21 +19000,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -18986,11 +19029,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -19009,13 +19052,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -19039,13 +19082,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -19060,8 +19103,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -19092,7 +19135,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -19124,9 +19167,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -19155,7 +19198,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -19173,7 +19216,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -19198,7 +19241,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -19208,8 +19250,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -19218,7 +19258,7 @@ EOF: 1, this.clear(); } - 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. @@ -19230,13 +19270,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -19246,68 +19286,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -19332,7 +19378,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -19380,24 +19426,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -19417,7 +19463,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -19427,24 +19473,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -19465,8 +19511,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -19506,14 +19551,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -19529,9 +19574,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -19542,8 +19587,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -19551,7 +19596,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -19704,9 +19749,9 @@ const ID_REGEX_BASE$2 = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // guaranteed not to collide with previously generated / already existing // rules (~ symbols). function generateUniqueSymbol(id, postfix, opts) { - var sym = id + postfix; + let sym = id + postfix; if (opts.grammar[sym]) { - var i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. + let i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. do { sym = id + postfix + i; i++; @@ -19716,8 +19761,8 @@ function generateUniqueSymbol(id, postfix, opts) { } function generatePushAction(handle, offset) { - var terms = handle.terms; - var rv = []; + const terms = handle.terms; + let rv = []; for (var i = 0, len = terms.length; i < len; i++) { rv.push('$' + (i + offset)); @@ -19733,11 +19778,11 @@ function generatePushAction(handle, offset) { } function transformExpression(e, opts, emit) { - var type = e[0], - value = e[1], - name = false, - has_transformed = 0; - var list, n; + let type = e[0]; + let value = e[1]; + let name = false; + let has_transformed = 0; + let list, n; if (type === 'xalias') { type = e[1]; @@ -19764,7 +19809,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ list.fragment, @@ -19784,7 +19829,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ '', @@ -19804,7 +19849,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); // you want to be able to check if 0 or 1 occurrences were recognized: since jison // by default *copies* the lexer token value, i.e. `$$ = $1` is the (optional) default action, // we will need to set the action up explicitly in case of the 0-count match: @@ -19840,7 +19885,7 @@ function transformExpression(e, opts, emit) { opts = optsForProduction(name, opts.grammar); opts.grammar[name] = value.map(function (handle) { - var list = transformExpressionList(handle, opts); + let list = transformExpressionList(handle, opts); return [ list.fragment, '$$ = ' + generatePushAction(list, 1) + ';' @@ -19853,11 +19898,11 @@ function transformExpression(e, opts, emit) { } function transformExpressionList(list, opts) { - var first_transformed_term_index = false; - var terms = list.reduce(function (tot, e) { - var ci = tot.length; + let first_transformed_term_index = false; + let terms = list.reduce(function (tot, e) { + let ci = tot.length; - var has_transformed = transformExpression(e, opts, function (name) { + let has_transformed = transformExpression(e, opts, function (name) { if (name.terms) { tot.push.apply(tot, name.terms); } else { @@ -19886,42 +19931,42 @@ function optsForProduction(id, grammar) { } function transformProduction(id, production, grammar) { - var transform_opts = optsForProduction(id, grammar); + let transform_opts = optsForProduction(id, grammar); return production.map(function (handle) { - var action = null, - opts = null; - var i, len, n; + let action = null; + let opts = null; + let i, len, n; if (typeof handle !== 'string') { action = handle[1]; opts = handle[2]; handle = handle[0]; } - var expressions = handle; + let expressions = handle; if (typeof expressions === 'string') { expressions = parser$2.parse(handle); } - var list = transformExpressionList(expressions, transform_opts); + let list = transformExpressionList(expressions, transform_opts); - var ret = [list.fragment]; + let ret = [ list.fragment ]; if (action) { // make sure the action doesn't address any inner items. if (list.first_transformed_term_index) { // seek out all names and aliases; strip out literal tokens first as those cannot serve as $names: - var alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); + let alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); - var alias_re = new XRegExp(`\\[${ID_REGEX_BASE$2}\\]`); - var term_re = new XRegExp(`^${ID_REGEX_BASE$2}$`); + let alias_re = new XRegExp(`\\[${ID_REGEX_BASE$2}\\]`); + let term_re = new XRegExp(`^${ID_REGEX_BASE$2}$`); // and collect the PERMITTED aliases: the names of the terms and all the remaining aliases - var good_aliases = {}; - var alias_cnt = {}; - var donotalias = {}; + let good_aliases = {}; + let alias_cnt = {}; + let donotalias = {}; // WARNING: this replicates the knowledge/code of jison.js::addName() - var addName = function addNameEBNF(s, i) { - var base = s.replace(/[0-9]+$/, ''); - var dna = donotalias[base]; + let addName = function addNameEBNF(s, i) { + let base = s.replace(/[0-9]+$/, ''); + let dna = donotalias[base]; if (good_aliases[s]) { alias_cnt[s]++; @@ -19940,7 +19985,7 @@ function transformProduction(id, production, grammar) { }; // WARNING: this replicates the knowledge/code of jison.js::markBasename() - var markBasename = function markBasenameEBNF(s) { + let markBasename = function markBasenameEBNF(s) { if (/[0-9]$/.test(s)) { s = s.replace(/[0-9]+$/, ''); donotalias[s] = true; @@ -19977,13 +20022,13 @@ function transformProduction(id, production, grammar) { // now scan the action for all named and numeric semantic values ($nonterminal / $1 / @1, ##1, ...) // // Note that `#name` are straight **static** symbol translations, which are okay as they don't - // require access to the parse stack: `#n` references can be resolved completely + // require access to the parse stack: `#n` references can be resolved completely // at grammar compile time. // - var nameref_re = new XRegExp(`(?:[$@]|##)${ID_REGEX_BASE$2}`, 'g'); - var named_spots = nameref_re.exec(action); - var numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); - var max_term_index = list.terms.length; + let nameref_re = new XRegExp(`(?:[$@]|##)${ID_REGEX_BASE$2}`, 'g'); + let named_spots = nameref_re.exec(action); + let numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); + let max_term_index = list.terms.length; // loop through the XRegExp alias regex matches in `action` while (named_spots) { @@ -20013,7 +20058,7 @@ function transformProduction(id, production, grammar) { for (i = 0, len = numbered_spots.length; i < len; i++) { n = parseInt(numbered_spots[i].replace(/^(?:[$@]|##)/, '')); if (n > max_term_index) { - /* @const */ var n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; + /* @const */ let n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; throw new Error('The action block references the ' + n + n_suffixes[Math.max(0, Math.min(3, n - 1))] + ' term, ' + 'which is not available in production "' + handle + '"; ' + 'Be reminded that you cannot reference sub-elements within EBNF */+/? groups, ' + @@ -20031,13 +20076,14 @@ function transformProduction(id, production, grammar) { if (ret.length === 1) { return ret[0]; - } else { - return ret; } + return ret; + }); } -var ref_list; -var ref_names; + +let ref_list; +let ref_names; // create a deep copy of the input, so we will keep the input constant. function deepClone(from, sub) { @@ -20052,7 +20098,7 @@ function deepClone(from, sub) { return from; } - var idx = ref_list.indexOf(from); + let idx = ref_list.indexOf(from); if (idx >= 0) { throw new Error('[Circular/Xref:' + ref_names[i] + ']'); // circular or cross reference } @@ -20068,7 +20114,7 @@ function deepClone(from, sub) { sub += '.'; var to = new from.constructor(); - for (var name in from) { + for (let name in from) { to[name] = deepClone(from[name], sub + name); } } @@ -20084,8 +20130,9 @@ function transformGrammar(grammar) { return grammar; } + function transform(ebnf) { - var rv = transformGrammar(ebnf); + let rv = transformGrammar(ebnf); return rv; } @@ -20095,7 +20142,6 @@ function transform(ebnf) { // 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. function JisonParserError$2(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -20112,9 +20158,9 @@ function JisonParserError$2(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -20147,10 +20193,10 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp$2(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -20163,11 +20209,11 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda$1(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -20177,18 +20223,18 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt$2(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -20219,7 +20265,7 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // `this` references an array function s$2(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -20236,9 +20282,9 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$2(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -20251,7 +20297,7 @@ JisonParserError$2.prototype.name = 'JisonParserError'; } -var parser$3 = { +let parser$3 = { // Code Generator Information Report // --------------------------------- // @@ -20487,7 +20533,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -20495,7 +20540,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -20507,8 +20551,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -20521,14 +20565,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -20544,10 +20587,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -20555,10 +20598,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -20739,26 +20782,26 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; switch (yystate) { case 0: /*! Production:: $accept : spec $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break; case 1: /*! Production:: spec : declaration_list "%%" grammar optional_end_block EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4]; @@ -20770,10 +20813,10 @@ case 1: case 2: /*! Production:: spec : declaration_list "%%" grammar error EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -20792,10 +20835,10 @@ case 2: case 3: /*! Production:: spec : declaration_list error EOF */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -20817,9 +20860,9 @@ case 118: case 133: /*! Production:: optional_module_code_chunk : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -20828,9 +20871,9 @@ case 133: case 5: /*! Production:: optional_end_block : "%%" extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20850,9 +20893,9 @@ case 6: case 10: /*! Production:: declaration_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; @@ -20863,9 +20906,9 @@ case 7: case 8: /*! Production:: optional_action_header_block : optional_action_header_block include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -20884,9 +20927,9 @@ case 8: case 9: /*! Production:: declaration_list : declaration_list declaration */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20895,10 +20938,10 @@ case 9: case 11: /*! Production:: declaration_list : declaration_list error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -20913,9 +20956,9 @@ case 11: case 12: /*! Production:: declaration : START id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {start: yyvstack[yysp]}; @@ -20924,9 +20967,9 @@ case 12: case 13: /*! Production:: declaration : LEX_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {lex: {text: yyvstack[yysp], position: yylstack[yysp]}}; @@ -20935,9 +20978,9 @@ case 13: case 14: /*! Production:: declaration : operator */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {operator: yyvstack[yysp]}; @@ -20946,9 +20989,9 @@ case 14: case 15: /*! Production:: declaration : TOKEN full_token_definitions */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {token_list: yyvstack[yysp]}; @@ -20957,9 +21000,9 @@ case 15: case 16: /*! Production:: declaration : ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20977,9 +21020,9 @@ case 16: case 17: /*! Production:: declaration : include_macro_code */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20997,9 +21040,9 @@ case 17: case 18: /*! Production:: declaration : parse_params */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parseParams: yyvstack[yysp]}; @@ -21008,9 +21051,9 @@ case 18: case 19: /*! Production:: declaration : parser_type */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parserType: yyvstack[yysp]}; @@ -21019,9 +21062,9 @@ case 19: case 20: /*! Production:: declaration : options */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: yyvstack[yysp]}; @@ -21030,9 +21073,9 @@ case 20: case 21: /*! Production:: declaration : DEBUG */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: [['debug', true]]}; @@ -21041,9 +21084,9 @@ case 21: case 22: /*! Production:: declaration : EBNF */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) ebnf = true; @@ -21053,9 +21096,9 @@ case 22: case 23: /*! Production:: declaration : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {unknownDecl: yyvstack[yysp]}; @@ -21064,9 +21107,9 @@ case 23: case 24: /*! Production:: declaration : IMPORT import_name import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = {imports: {name: yyvstack[yysp - 1], path: yyvstack[yysp]}}; @@ -21075,10 +21118,10 @@ case 24: case 25: /*! Production:: declaration : IMPORT import_name error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21094,10 +21137,10 @@ case 25: case 26: /*! Production:: declaration : IMPORT error import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21113,9 +21156,9 @@ case 26: case 27: /*! Production:: declaration : INIT_CODE init_code_name action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21138,10 +21181,10 @@ case 27: case 28: /*! Production:: declaration : INIT_CODE error action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21157,10 +21200,10 @@ case 28: case 29: /*! Production:: declaration : START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21175,10 +21218,10 @@ case 29: case 30: /*! Production:: declaration : TOKEN error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21193,10 +21236,10 @@ case 30: case 31: /*! Production:: declaration : IMPORT error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21261,9 +21304,9 @@ case 129: case 132: /*! Production:: optional_module_code_chunk : module_code_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -21274,9 +21317,9 @@ case 39: case 111: /*! Production:: action_ne : "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21285,10 +21328,10 @@ case 111: case 40: /*! Production:: options : OPTIONS error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21303,10 +21346,10 @@ case 40: case 41: /*! Production:: options : OPTIONS error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21325,9 +21368,9 @@ case 59: case 70: /*! Production:: id_list : id_list id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21342,9 +21385,9 @@ case 71: case 84: /*! Production:: handle_list : handle_action */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -21353,9 +21396,9 @@ case 84: case 44: /*! Production:: option : NAME */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -21364,9 +21407,9 @@ case 44: case 45: /*! Production:: option : NAME "=" OPTION_STRING_VALUE */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -21377,9 +21420,9 @@ case 46: case 47: /*! Production:: option : NAME "=" NAME */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], parseValue$1(yyvstack[yysp])]; @@ -21388,10 +21431,10 @@ case 47: case 48: /*! Production:: option : NAME "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21406,10 +21449,10 @@ case 48: case 49: /*! Production:: option : NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21426,9 +21469,9 @@ case 50: case 52: /*! Production:: parser_type : PARSER_TYPE symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -21437,10 +21480,10 @@ case 52: case 51: /*! Production:: parse_params : PARSE_PARAM error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21458,10 +21501,10 @@ case 51: case 53: /*! Production:: parser_type : PARSER_TYPE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21479,9 +21522,9 @@ case 53: case 54: /*! Production:: operator : associativity token_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1]]; this.$.push.apply(this.$, yyvstack[yysp]); @@ -21490,10 +21533,10 @@ case 54: case 55: /*! Production:: operator : associativity error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21511,9 +21554,9 @@ case 55: case 56: /*! Production:: associativity : LEFT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'left'; @@ -21522,9 +21565,9 @@ case 56: case 57: /*! Production:: associativity : RIGHT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'right'; @@ -21533,9 +21576,9 @@ case 57: case 58: /*! Production:: associativity : NONASSOC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'nonassoc'; @@ -21544,9 +21587,9 @@ case 58: case 61: /*! Production:: full_token_definitions : optional_token_type id_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var rv = []; @@ -21565,9 +21608,9 @@ case 61: case 62: /*! Production:: full_token_definitions : optional_token_type one_full_token */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var m = yyvstack[yysp]; @@ -21580,9 +21623,9 @@ case 62: case 63: /*! Production:: one_full_token : id token_value token_description */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21595,9 +21638,9 @@ case 63: case 64: /*! Production:: one_full_token : id token_description */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21609,9 +21652,9 @@ case 64: case 65: /*! Production:: one_full_token : id token_value */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21623,9 +21666,9 @@ case 65: case 66: /*! Production:: optional_token_type : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = false; @@ -21634,9 +21677,9 @@ case 66: case 72: /*! Production:: grammar : optional_action_header_block production_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21646,9 +21689,9 @@ case 72: case 73: /*! Production:: production_list : production_list production */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21662,9 +21705,9 @@ case 73: case 74: /*! Production:: production_list : production */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; this.$[yyvstack[yysp][0]] = yyvstack[yysp][1]; @@ -21673,9 +21716,9 @@ case 74: case 75: /*! Production:: production : production_id handle_list ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp - 1]]; @@ -21684,10 +21727,10 @@ case 75: case 76: /*! Production:: production : production_id error ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21705,10 +21748,10 @@ case 76: case 77: /*! Production:: production : production_id error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21726,9 +21769,9 @@ case 77: case 78: /*! Production:: production_id : id optional_production_description ":" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21739,10 +21782,10 @@ case 78: case 79: /*! Production:: production_id : id optional_production_description error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21760,10 +21803,10 @@ case 79: case 80: /*! Production:: production_id : id optional_production_description ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21787,18 +21830,18 @@ case 80: case 82: /*! Production:: optional_production_description : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) break; case 83: /*! Production:: handle_list : handle_list "|" handle_action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21808,10 +21851,10 @@ case 83: case 85: /*! Production:: handle_list : handle_list "|" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21829,10 +21872,10 @@ case 85: case 86: /*! Production:: handle_list : handle_list ":" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21847,9 +21890,9 @@ case 86: case 87: /*! Production:: handle_action : handle prec action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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(' ') : '')]; @@ -21884,9 +21927,9 @@ case 87: case 88: /*! Production:: handle_action : EPSILON action */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = ['']; @@ -21910,10 +21953,10 @@ case 88: case 89: /*! Production:: handle_action : EPSILON error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21928,9 +21971,9 @@ case 89: case 90: /*! Production:: handle : handle suffixed_expression */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21940,9 +21983,9 @@ case 90: case 91: /*! Production:: handle : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -21951,9 +21994,9 @@ case 91: case 92: /*! Production:: handle_sublist : handle_sublist "|" handle */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21963,9 +22006,9 @@ case 92: case 93: /*! Production:: handle_sublist : handle */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp].join(' ')]; @@ -21974,9 +22017,9 @@ case 93: case 94: /*! Production:: suffixed_expression : expression suffix ALIAS */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + "[" + yyvstack[yysp] + "]"; @@ -21989,9 +22032,9 @@ case 124: case 130: /*! Production:: module_code_chunk : module_code_chunk CODE */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22000,9 +22043,9 @@ case 130: case 97: /*! Production:: expression : EOF_ID */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$end'; @@ -22011,9 +22054,9 @@ case 97: case 98: /*! Production:: expression : STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // Re-encode the string *anyway* as it will @@ -22026,9 +22069,9 @@ case 98: case 99: /*! Production:: expression : "(" handle_sublist ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1].join(' | ') + ')'; @@ -22037,10 +22080,10 @@ case 99: case 100: /*! Production:: expression : "(" handle_sublist error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22054,9 +22097,9 @@ case 100: case 105: /*! Production:: prec : PREC symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { prec: yyvstack[yysp] }; @@ -22065,10 +22108,10 @@ case 105: case 106: /*! Production:: prec : PREC error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -22086,9 +22129,9 @@ case 106: case 107: /*! Production:: prec : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = null; @@ -22097,10 +22140,10 @@ case 107: case 112: /*! Production:: action_ne : "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22114,9 +22157,9 @@ case 112: case 116: /*! Production:: action : ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$$ = (' + yyvstack[yysp] + ');'; @@ -22125,9 +22168,9 @@ case 116: case 120: /*! Production:: action_body : action_body "{" action_body "}" action_comments_body */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4] + yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22136,9 +22179,9 @@ case 120: case 121: /*! Production:: action_body : action_body "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22147,10 +22190,10 @@ case 121: case 122: /*! Production:: action_body : action_body "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22164,9 +22207,9 @@ case 122: case 126: /*! Production:: extra_parser_module_code : optional_module_code_chunk include_macro_code extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22175,9 +22218,9 @@ case 126: case 127: /*! Production:: include_macro_code : INCLUDE PATH */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' }); @@ -22197,10 +22240,10 @@ case 127: case 128: /*! Production:: include_macro_code : INCLUDE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22213,10 +22256,10 @@ case 128: case 131: /*! Production:: module_code_chunk : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -23609,7 +23652,6 @@ defaultActions: bda$1({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -23626,38 +23668,34 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -23665,20 +23703,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -23700,7 +23736,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -23708,18 +23743,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -23727,24 +23763,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -23782,18 +23813,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -23814,7 +23842,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -23832,7 +23860,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -23845,7 +23872,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -23859,11 +23885,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -23917,8 +23942,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -23926,8 +23951,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -23959,19 +23984,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -23982,7 +24006,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -23995,7 +24019,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -24007,29 +24031,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -24037,7 +24059,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -24057,8 +24079,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -24067,10 +24088,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -24078,7 +24099,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -24089,9 +24110,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -24107,8 +24133,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -24177,11 +24202,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -24192,8 +24220,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -24202,21 +24229,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -24226,21 +24252,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -24249,28 +24274,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -24283,8 +24307,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -24307,8 +24330,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -24320,8 +24342,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -24338,8 +24359,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -24353,8 +24373,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -24368,7 +24387,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -24421,16 +24440,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -24464,9 +24480,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -24489,9 +24503,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -24518,17 +24530,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -24575,8 +24586,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -24588,8 +24599,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -24607,6 +24617,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -24615,7 +24626,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -24626,7 +24637,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -24686,10 +24697,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -24724,9 +24735,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -24739,7 +24748,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -24760,9 +24769,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -24784,12 +24791,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -24798,7 +24805,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -24839,7 +24846,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -24886,7 +24893,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -24904,21 +24911,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -24952,14 +24957,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -24969,6 +24975,7 @@ parse: function parse(input) { + } continue; // accept: @@ -25020,7 +25027,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -25036,9 +25043,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -25067,7 +25072,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -25084,8 +25089,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -25096,8 +25101,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -25109,21 +25114,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -25154,14 +25157,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -25171,6 +25175,7 @@ parse: function parse(input) { + } continue; // accept: @@ -25223,8 +25228,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -25485,7 +25489,6 @@ var lexer$2 = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -25502,10 +25505,10 @@ var lexer$2 = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -25537,7 +25540,7 @@ var lexer$2 = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -25579,7 +25582,9 @@ var lexer$2 = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -25665,7 +25670,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -25673,7 +25678,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -25686,7 +25691,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -25712,10 +25717,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -25738,7 +25746,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -25761,16 +25768,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -25792,7 +25799,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -25800,8 +25806,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -25830,7 +25836,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -25855,7 +25861,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -25867,17 +25873,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -25971,7 +25977,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -25992,7 +25998,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -26003,7 +26008,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -26014,15 +26019,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -26056,8 +26061,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -26090,9 +26095,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -26111,9 +26116,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -26123,8 +26128,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -26151,20 +26156,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -26204,17 +26208,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -26223,7 +26229,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -26238,8 +26244,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -26265,24 +26271,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -26293,7 +26301,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -26315,8 +26323,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -26338,8 +26346,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -26483,21 +26490,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -26512,11 +26519,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -26535,13 +26542,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -26565,13 +26572,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -26586,8 +26593,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -26618,7 +26625,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -26650,9 +26657,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -26681,7 +26688,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -26699,7 +26706,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -26724,7 +26731,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -26734,8 +26740,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -26744,7 +26748,7 @@ EOF: 1, this.clear(); } - 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. @@ -26756,13 +26760,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -26772,68 +26776,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -26858,7 +26868,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -26906,24 +26916,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -26943,7 +26953,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -26953,24 +26963,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -26991,8 +27001,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -27032,14 +27041,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -27055,9 +27064,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -27068,8 +27077,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -27077,7 +27086,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -28122,7 +28131,7 @@ var bnf = { }; -var version$1 = '0.6.2-220'; // require('./package.json').version; +const version$1 = '0.6.2-220'; // require('./package.json').version; function parse(grammar) { return bnf.parser.parse(grammar); @@ -28188,7 +28197,7 @@ bnf.parser.yy.addDeclaration = function bnfAddDeclaration(grammar, decl) { if (decl.options) { if (!grammar.options) grammar.options = {}; // last occurrence of `%options` wins: - for (var i = 0; i < decl.options.length; i++) { + for (let i = 0; i < decl.options.length; i++) { grammar.options[decl.options[i][0]] = decl.options[i][1]; } } @@ -28228,9 +28237,9 @@ function parseLex(text, position) { // which matches the original input file: position = position || {}; position.range = position.range || []; - var l = position.first_line | 0; - var c = position.range[0] | 0; - var prelude = ''; + let l = position.first_line | 0; + let c = position.range[0] | 0; + let prelude = ''; if (l > 1) { prelude += (new Array(l)).join('\n'); c -= prelude.length; @@ -28255,10 +28264,10 @@ var ebnfParser = { ebnf_parser, bnf_lexer: lexParser, - version: version$1, + version: version$1 }; -var rmCommonWS$4 = helpers.rmCommonWS; +const rmCommonWS$4 = helpers.rmCommonWS; /** @@ -28284,14 +28293,14 @@ function grammarPrinter(raw, options) { case 'json5': options.format = 'json5'; break; - + case '.y': case '.yacc': options.format = 'jison'; options.showLexer = false; options.showParser = true; break; - + case '.l': case '.lex': options.format = 'jison'; @@ -28313,20 +28322,20 @@ function grammarPrinter(raw, options) { // which MAY get corrupted that way as their actual content would change then! // construct fake nesting levels to arrive at the intended start indent value: `num` - var nesting_levels = num / 2; - var pre = '// **PRE**', - post = '// **POST**'; - for ( ; nesting_levels > 0; nesting_levels--) { + let nesting_levels = num / 2; + let pre = '// **PRE**'; + let post = '// **POST**'; + for (; nesting_levels > 0; nesting_levels--) { pre = 'function x() {\n' + pre; post += '\n}'; } - src = '\n' + pre + '\n' + src + '\n' + post + '\n'; + src = '\n' + pre + '\n' + src + '\n' + post + '\n'; - var ast = helpers.parseCodeChunkToAST(src, options); - var new_src = helpers.prettyPrintAST(ast, options); + let ast = helpers.parseCodeChunkToAST(src, options); + let new_src = helpers.prettyPrintAST(ast, options); - var start = new_src.indexOf('// **PRE**'); - var end = new_src.lastIndexOf('// **POST**'); + let start = new_src.indexOf('// **PRE**'); + let end = new_src.lastIndexOf('// **POST**'); new_src = new_src .substring(start + 10, end) .trim(); @@ -28335,13 +28344,13 @@ function grammarPrinter(raw, options) { } function isEmptyObj(obj) { - var keys = obj && typeof obj === 'object' && Object.keys(obj); + let keys = obj && typeof obj === 'object' && Object.keys(obj); return keys && keys.length === 0; } function isEmptyArr(arr) { if (arr && arr instanceof Array) { - for (var i = 0, len = arr.length; i < len; i++) { + for (let i = 0, len = arr.length; i < len; i++) { if (arr[i] !== undefined) { return false; } @@ -28354,8 +28363,8 @@ function grammarPrinter(raw, options) { // Copied from Crokford's implementation of JSON // See https://github.com/douglascrockford/JSON-js/blob/e39db4b7e6249f04a195e7dd0840e610cc9e941e/json2.js#L195 // Begin - var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - meta = { // table of character substitutions + let escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; + let meta = { // table of character substitutions '\b': '\\b', '\t': '\\t', '\n': '\\n', @@ -28372,15 +28381,15 @@ function grammarPrinter(raw, options) { // sequences. escapable.lastIndex = 0; return escapable.test(string) ? '"' + string.replace(escapable, function (a) { - var c = meta[a]; + let c = meta[a]; return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }) + '"' : '"' + string + '"'; } - var ref_list; - var ref_names; + let ref_list; + let ref_names; // create a deep copy of the input, so we can delete the parts we converted and dump the remainder // so that we always output the entire thing, even when we don't know all the details about the @@ -28397,7 +28406,7 @@ function grammarPrinter(raw, options) { return from; } - for (var i = 0, len = ref_list.length; i < len; i++) { + for (let i = 0, len = ref_list.length; i < len; i++) { if (ref_list[i] === from) { return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference } @@ -28406,204 +28415,211 @@ function grammarPrinter(raw, options) { ref_names.push(sub); sub += '.'; - var to = new from.constructor(); - for (var name in from) { + let to = new from.constructor(); + for (let name in from) { to[name] = deepClone(from[name], sub + name); } return to; } - var originalInput = raw; + let originalInput = raw; raw = deepClone(raw); - var lex_out_str = ''; + let lex_out_str = ''; if (raw.lex) { var lex_pre = []; - var lex_rules = []; - var lex_post = []; - var key, src; + let lex_rules = []; + let lex_post = []; + + { + let src = raw.lex.macros; + delete raw.lex.macros; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // macros: + `); - src = raw.lex.macros; - delete raw.lex.macros; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // macros: - `); + let keylen = 0; + for (let key in src) { + keylen = Math.max(keylen, key.length); + } + console.log('macros keylen:', keylen); + keylen = ((keylen / 4) | 0) * 4 + 4; + console.log('macros keylen B:', keylen); + for (let key in src) { + lex_pre.push(padRight(key, keylen) + src[key]); + } - var keylen = 0; - for (key in src) { - keylen = Math.max(keylen, key.length); - } - console.log('macros keylen:', keylen); - keylen = ((keylen / 4) | 0) * 4 + 4; - console.log('macros keylen B:', keylen); - for (key in src) { - lex_pre.push(padRight(key, keylen) + src[key]); + lex_pre.push(rmCommonWS$4` + // END of the lexer macros. + `); } - - lex_pre.push(rmCommonWS$4` - // END of the lexer macros. - `); } - src = raw.lex.unknownDecls; - delete raw.lex.unknownDecls; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // unknown declarations: - `); + { + let src = raw.lex.unknownDecls; + delete raw.lex.unknownDecls; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // unknown declarations: + `); - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry.name; + let value = entry.value; - lex_pre.push('%' + key + ' ' + value); - } + lex_pre.push('%' + key + ' ' + value); + } - lex_pre.push(rmCommonWS$4` - // END of unknown declarations. - `); + lex_pre.push(rmCommonWS$4` + // END of unknown declarations. + `); + } } - src = raw.lex.options; - delete raw.lex.options; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // options: - `); + { + let src = raw.lex.options; + delete raw.lex.options; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // options: + `); - for (key in src) { - var value = src[key]; - if (value) { - lex_pre.push('%options ' + key + '=' + value); - } - else { - lex_pre.push('%options ' + key); + for (let key in src) { + let value = src[key]; + if (value) { + lex_pre.push('%options ' + key + '=' + value); + } else { + lex_pre.push('%options ' + key); + } } } } - src = raw.lex.startConditions; - delete raw.lex.startConditions; - if (src && !isEmptyObj(src)) { - for (key in src) { - var value = src[key]; + { + let src = raw.lex.startConditions; + delete raw.lex.startConditions; + if (src && !isEmptyObj(src)) { + for (let key in src) { + let value = src[key]; - lex_pre.push((value ? '%x ' : '%s ') + key); + lex_pre.push((value ? '%x ' : '%s ') + key); + } } } - src = raw.lex.actionInclude; - delete raw.lex.actionInclude; - if (src && src.trim()) { - lex_pre.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + { + let src = raw.lex.actionInclude; + delete raw.lex.actionInclude; + if (src && src.trim()) { + lex_pre.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + } } - src = raw.lex.rules; - delete raw.lex.rules; - if (src) { - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - key = entry[0]; - var action = indentAction(entry[1], 4); - - var actionHasLF = /[\r\n]/.test(action); - console.log('indented action:', { - entry: entry[1], - action, - actionHasLF - }); - if (key.length <= 12) { - if (!actionHasLF) { - lex_rules.push(padRight(key, 16) + indentAction(action, 16)); - } - else { - lex_rules.push(padRight(key, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); - } - } - else { - if (!actionHasLF) { + { + let src = raw.lex.rules; + delete raw.lex.rules; + if (src) { + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry[0]; + let action = indentAction(entry[1], 4); + + let actionHasLF = /[\r\n]/.test(action); + console.log('indented action:', { + entry: entry[1], + action, + actionHasLF + }); + if (key.length <= 12) { + if (!actionHasLF) { + lex_rules.push(padRight(key, 16) + indentAction(action, 16)); + } else { + lex_rules.push(padRight(key, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + } + } else if (!actionHasLF) { lex_rules.push(key, makeIndent(16) + indentAction(action, 16)); - } - else { + } else { lex_rules.push(key, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } } } - src = raw.lex.moduleInclude; - delete raw.lex.moduleInclude; - if (src && src.trim()) { - lex_post.push(indentAction(src.trim(), 0)); + { + let src = raw.lex.moduleInclude; + delete raw.lex.moduleInclude; + if (src && src.trim()) { + lex_post.push(indentAction(src.trim(), 0)); + } } - var out = ''; + { + let out = ''; - if (!isEmptyObj(raw.lex)) { - // dump the remainder as a comment: - var rem = JSON5.stringify(raw.lex, null, 2); - out += rmCommonWS$4` - /* - * Lexer stuff that's unknown to the JISON prettyPrint service: - * - * ${rem.replace(/\*\//g, '*\\/')} - */ + if (!isEmptyObj(raw.lex)) { + // dump the remainder as a comment: + let rem = JSON5.stringify(raw.lex, null, 2); + out += rmCommonWS$4` + /* + * Lexer stuff that's unknown to the JISON prettyPrint service: + * + * ${rem.replace(/\*\//g, '*\\/')} + */ - `; - } - delete raw.lex; - - out += lex_pre.join('\n') + '\n\n'; - out += rmCommonWS$4` - - %% + `; + } + delete raw.lex; - ` + lex_rules.join('\n') + '\n\n'; - if (lex_post.length > 0) { + out += lex_pre.join('\n') + '\n\n'; out += rmCommonWS$4` %% - ` + lex_post.join('\n') + '\n\n'; + ` + lex_rules.join('\n') + '\n\n'; + if (lex_post.length > 0) { + out += rmCommonWS$4` + + %% + + ` + lex_post.join('\n') + '\n\n'; + } + lex_out_str = out; } - lex_out_str = out; } - var grammar_pre = []; - var grammar_mid = []; - var ebnf_rules = []; - var bnf_rules = []; - var grammar_post = []; - var key, src; + let grammar_pre = []; + let grammar_mid = []; + let ebnf_rules = []; + let bnf_rules = []; + let grammar_post = []; - var fmtprod = function fmtprod(rule, prodset) { - var backup = deepClone(prodset); + let fmtprod = function fmtprod(rule, prodset) { + let backup = deepClone(prodset); rule += prodset[0] ? prodset[0] : '%epsilon'; - var prec = null; - var lead = rule.split(/\r\n\|\n|\r/).pop(); + let prec = null; + let lead = rule.split(/\r\n\|\n|\r/).pop(); delete prodset[0]; if (prodset.length === 3 && typeof prodset[2] === 'object') { prec = '%prec ' + prodset[2].prec; if (lead.length < 12) { rule += makeIndent(12 - lead.length); - } + } rule += ' ' + prec; delete prodset[2].prec; if (isEmptyObj(prodset[2])) { delete prodset[2]; } - } - else if (prodset.length === 2 && typeof prodset[1] === 'object') { + } else if (prodset.length === 2 && typeof prodset[1] === 'object') { prec = '%prec ' + prodset[1].prec; if (lead.length < 12) { rule += makeIndent(12 - lead.length); - } + } rule += ' ' + prec; delete prodset[1].prec; @@ -28612,84 +28628,73 @@ function grammarPrinter(raw, options) { } } if (typeof prodset[1] === 'string') { - var action = prodset[1]; + let action = prodset[1]; if (lead.length < 12 - 1) { - rule += makeIndent(12 - lead.length) + indentAction('{ ' + action + ' }', 12); - } - else { - rule += '\n' + makeIndent(12) + indentAction('{ ' + action + ' }', 12); + rule += makeIndent(12 - lead.length) + indentAction('{ ' + action + ' }', 12); + } else { + rule += '\n' + makeIndent(12) + indentAction('{ ' + action + ' }', 12); } delete prodset[1]; } if (isEmptyArr(prodset)) { prodset.length = 0; - } - else { + } else { prodset = backup; } return rule; }; - var grammarfmt = function grammarfmt(src) { - var key; - var dst = []; + let grammarfmt = function grammarfmt(src) { + let dst = []; - for (key in src) { - var prodset = src[key]; - var rule; + for (let key in src) { + let prodset = src[key]; + let rule; console.log('format one rule:', { - key, + key, prodset }); if (typeof prodset === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; + rule = fmtprod(key + ' : ', [ prodset ]) + ';'; delete src[key]; - } - else if (prodset instanceof Array) { + } else if (prodset instanceof Array) { if (prodset.length === 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; + rule = fmtprod(key + ' : ', [ prodset ]) + ';'; delete src[key]; - } - else if (prodset[0] instanceof Array) { + } else if (prodset[0] instanceof Array) { rule = fmtprod(key + ' : ', prodset[0]); rule += '\n ;'; if (prodset[0].length === 0) { delete src[key]; } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - } - else if (prodset.length > 1) { + } else if (prodset.length > 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + '\n : ', [prodset[0]]); + rule = fmtprod(key + '\n : ', [ prodset[0] ]); delete prodset[0]; - } - else if (prodset[0] instanceof Array) { + } else if (prodset[0] instanceof Array) { rule = fmtprod(key + '\n : ', prodset[0]); if (prodset[0].length === 0) { delete prodset[0]; } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - for (var i = 1, len = prodset.length; i < len; i++) { + for (let i = 1, len = prodset.length; i < len; i++) { if (typeof prodset[i] === 'string') { - rule += fmtprod('\n | ', [prodset[i]]); + rule += fmtprod('\n | ', [ prodset[i] ]); delete prodset[i]; - } - else if (prodset[i] instanceof Array) { + } else if (prodset[i] instanceof Array) { rule += fmtprod('\n | ', prodset[i]); if (prodset[i].length === 0) { delete prodset[i]; } - } - else { + } else { rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[i]; } } @@ -28699,8 +28704,7 @@ function grammarPrinter(raw, options) { delete src[key]; } } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; } dst.push(rule); @@ -28709,46 +28713,52 @@ function grammarPrinter(raw, options) { return dst; }; - src = raw.ebnf; - if (src) { - ebnf_rules = grammarfmt(src); + { + let src = raw.ebnf; + if (src) { + ebnf_rules = grammarfmt(src); - if (isEmptyObj(src)) { - delete raw.ebnf; + if (isEmptyObj(src)) { + delete raw.ebnf; + } } } - src = raw.bnf; - //delete raw.bnf; - if (src) { - bnf_rules = grammarfmt(src); + { + let src = raw.bnf; + //delete raw.bnf; + if (src) { + bnf_rules = grammarfmt(src); - if (isEmptyObj(src)) { - delete raw.bnf; + if (isEmptyObj(src)) { + delete raw.bnf; + } } } - src = raw.unknownDecls; - delete raw.unknownDecls; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // unknown declarations: - `); + { + let src = raw.unknownDecls; + delete raw.unknownDecls; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // unknown declarations: + `); - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry.name; + let value = entry.value; - lex_pre.push('%' + key + ' ' + value); - } + lex_pre.push('%' + key + ' ' + value); + } - lex_pre.push(rmCommonWS$4` - // END of unknown declarations. - `); + lex_pre.push(rmCommonWS$4` + // END of unknown declarations. + `); + } } - //src = raw.lex; + //let src = raw.lex; //delete raw.lex; //if (src) { if (lex_out_str.trim() && options.showLexer) { @@ -28766,294 +28776,305 @@ function grammarPrinter(raw, options) { `); } - src = raw.options; - delete raw.options; - if (src && !isEmptyObj(src)) { - var a = []; - for (key in src) { - var value = src[key]; - switch (key) { - default: - if (value !== true) { - a.push('options', '%options ' + key + '=' + value); - } - else { - a.push('options', '%options ' + key); - } - break; + { + let src = raw.options; + delete raw.options; + if (src && !isEmptyObj(src)) { + let a = []; + for (let key in src) { + let value = src[key]; + switch (key) { + default: + if (value !== true) { + a.push('options', '%options ' + key + '=' + value); + } else { + a.push('options', '%options ' + key); + } + break; - case 'ebnf': - if (value) { - a.push(key, '%ebnf'); - } - break; + case 'ebnf': + if (value) { + a.push(key, '%ebnf'); + } + break; - case 'type': - if (value) { - a.push(key, '%parser-type ' + value); - } - break; + case 'type': + if (value) { + a.push(key, '%parser-type ' + value); + } + break; - case 'debug': - if (typeof value !== 'boolean') { - a.push(key, '%debug ' + value); - } - else if (value) { - a.push(key, '%debug'); + case 'debug': + if (typeof value !== 'boolean') { + a.push(key, '%debug ' + value); + } else if (value) { + a.push(key, '%debug'); + } + break; } - break; } - } - var type = null; - for (var i = 0, len = a.length; i < len; i += 2) { - var t = a[i]; - var line = a[i + 1]; - if (t !== type) { - type = t; - grammar_pre.push(''); + let type = null; + for (let i = 0, len = a.length; i < len; i += 2) { + let t = a[i]; + let line = a[i + 1]; + if (t !== type) { + type = t; + grammar_pre.push(''); + } + grammar_pre.push(line); } - grammar_pre.push(line); + grammar_pre.push(''); } - grammar_pre.push(''); } - src = raw.imports; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - - grammar_pre.push('%import ' + entry.name + ' ' + entry.path); - delete entry.name; - delete entry.path; - if (isEmptyObj(entry)) { - delete src[i]; + { + let src = raw.imports; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + + grammar_pre.push('%import ' + entry.name + ' ' + entry.path); + delete entry.name; + delete entry.path; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } + } + if (clean) { + delete raw.imports; } - else { - clean = false; - } - } - if (clean) { - delete raw.imports; } } - src = raw.moduleInit; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - - grammar_pre.push('%code ' + entry.qualifier + ' ' + entry.include); - delete entry.qualifier; - delete entry.include; - if (isEmptyObj(entry)) { - delete src[i]; + { + let src = raw.moduleInit; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + + grammar_pre.push('%code ' + entry.qualifier + ' ' + entry.include); + delete entry.qualifier; + delete entry.include; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } + } + if (clean) { + delete raw.moduleInit; } - else { - clean = false; - } - } - if (clean) { - delete raw.moduleInit; } } - src = raw.operators; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var tokens = entry[1]; - var line = '%' + entry[0] + ' '; - - for (var t = 0, tlen = tokens.length; t < tlen; t++) { - line += ' ' + tokens[t]; - } + { + let src = raw.operators; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let tokens = entry[1]; + let line = '%' + entry[0] + ' '; + + for (let t = 0, tlen = tokens.length; t < tlen; t++) { + line += ' ' + tokens[t]; + } - grammar_pre.push(line); + grammar_pre.push(line); - if (entry.length === 2) { - delete src[i]; + if (entry.length === 2) { + delete src[i]; + } else { + clean = false; + } } - else { - clean = false; + if (clean) { + delete raw.operators; } } - if (clean) { - delete raw.operators; - } } - src = raw.extra_tokens; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var line = '%token ' + entry.id; - - if (entry.type) { - line += ' <' + entry.type + '>'; - delete entry.type; - } - if (entry.value) { - line += ' ' + entry.value; - delete entry.value; - } - if (entry.description) { - line += ' ' + escapeString(entry.description); - delete entry.description; - } + { + let src = raw.extra_tokens; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let line = '%token ' + entry.id; + + if (entry.type) { + line += ' <' + entry.type + '>'; + delete entry.type; + } + if (entry.value) { + line += ' ' + entry.value; + delete entry.value; + } + if (entry.description) { + line += ' ' + escapeString(entry.description); + delete entry.description; + } - grammar_pre.push(line); + grammar_pre.push(line); - delete entry.id; - if (isEmptyObj(entry)) { - delete src[i]; + delete entry.id; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } } - else { - clean = false; + if (clean) { + delete raw.extra_tokens; } } - if (clean) { - delete raw.extra_tokens; - } } - src = raw.parseParams; - delete raw.parseParams; - if (src) { - grammar_pre.push('%parse-param ' + src.join(' ')); + { + let src = raw.parseParams; + delete raw.parseParams; + if (src) { + grammar_pre.push('%parse-param ' + src.join(' ')); + } } - src = raw.start; - delete raw.start; - if (src) { - grammar_pre.push('%start ' + src); + { + let src = raw.start; + delete raw.start; + if (src) { + grammar_pre.push('%start ' + src); + } } - src = raw.moduleInclude; - delete raw.moduleInclude; - if (src && src.trim()) { - grammar_post.push(indentAction(src.trim(), 0)); + { + let src = raw.moduleInclude; + delete raw.moduleInclude; + if (src && src.trim()) { + grammar_post.push(indentAction(src.trim(), 0)); + } } - src = raw.actionInclude; - delete raw.actionInclude; - if (src && src.trim()) { - grammar_mid.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + { + let src = raw.actionInclude; + delete raw.actionInclude; + if (src && src.trim()) { + grammar_mid.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + } } - var out = ''; + { + let out = ''; - if (!isEmptyObj(raw)) { - // dump the remainder as a comment: - var rem = JSON5.stringify(raw, null, 2); - out += rmCommonWS$4` - /* - * Parser stuff that's unknown to the JISON prettyPrint service: - * - * ${rem.replace(/\*\//g, '*\\/')} - */ + if (!isEmptyObj(raw)) { + // dump the remainder as a comment: + let rem = JSON5.stringify(raw, null, 2); + out += rmCommonWS$4` + /* + * Parser stuff that's unknown to the JISON prettyPrint service: + * + * ${rem.replace(/\*\//g, '*\\/')} + */ - `; - // delete raw; - } + `; + // delete raw; + } - if (!options.showParser) { - out += lex_out_str; - } - else { - out += grammar_pre.join('\n') + '\n\n'; - out += rmCommonWS$4` + if (!options.showParser) { + out += lex_out_str; + } else { + out += grammar_pre.join('\n') + '\n\n'; + out += rmCommonWS$4` - %% + %% - `; - if (grammar_mid.length > 0) { - out += grammar_mid.join('\n') + '\n\n'; - } - if (ebnf_rules.length > 0) { - if (bnf_rules.length > 0) { + `; + if (grammar_mid.length > 0) { + out += grammar_mid.join('\n') + '\n\n'; + } + if (ebnf_rules.length > 0) { + if (bnf_rules.length > 0) { // dump the original EBNF grammar as source and dump the BNF derivative as COMMENT: - var bnf_deriv = bnf_rules.join('\n\n'); - var a = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); + let bnf_deriv = bnf_rules.join('\n\n'); + let a = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - out += rmCommonWS$4` - // - // JISON says: - // - // This is a EBNF grammar. The resulting **BNF** grammar has been - // reproduced here for your convenience: - // - // ---------------------------- START --------------------------- - ${a.join('\n')} - // ---------------------------- END OF BNF grammar -------------- - // + out += rmCommonWS$4` + // + // JISON says: + // + // This is a EBNF grammar. The resulting **BNF** grammar has been + // reproduced here for your convenience: + // + // ---------------------------- START --------------------------- + ${a.join('\n')} + // ---------------------------- END OF BNF grammar -------------- + // - `; + `; + } + out += ebnf_rules.join('\n\n') + '\n\n'; + } else if (bnf_rules.length > 0) { + out += bnf_rules.join('\n\n') + '\n\n'; } - out += ebnf_rules.join('\n\n') + '\n\n'; - } - else if (bnf_rules.length > 0) { - out += bnf_rules.join('\n\n') + '\n\n'; - } - if (grammar_post.length > 0) { - out += rmCommonWS$4` + if (grammar_post.length > 0) { + out += rmCommonWS$4` - %% + %% - ` + grammar_post.join('\n') + '\n\n'; + ` + grammar_post.join('\n') + '\n\n'; + } } - } - if (options.format === 'json5') { - var a = out.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); + if (options.format === 'json5') { + let a = out.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - out = rmCommonWS$4` - // - // JISON says: - // - // The JISON ${options.showParser ? 'grammar' : 'lexer'} has been - // reproduced here for your convenience: - // - // ---------------------------- START --------------------------- - ${a.join('\n')} - // ---------------------------- END ----------------------------- - // + out = rmCommonWS$4` + // + // JISON says: + // + // The JISON ${options.showParser ? 'grammar' : 'lexer'} has been + // reproduced here for your convenience: + // + // ---------------------------- START --------------------------- + ${a.join('\n')} + // ---------------------------- END ----------------------------- + // - `; + `; - // process the original input once again: this time via JSON5 - raw = deepClone(originalInput); + // process the original input once again: this time via JSON5 + raw = deepClone(originalInput); - if (!options.showLexer) { - delete raw.lex; - out += JSON5.stringify(raw, null, 2); - } - else if (!options.showParser) { - out += JSON5.stringify(raw.lex, null, 2); + if (!options.showLexer) { + delete raw.lex; + out += JSON5.stringify(raw, null, 2); + } else if (!options.showParser) { + out += JSON5.stringify(raw.lex, null, 2); + } } - } - return out; + return out; + } } // Jison, an LR(0), SLR(1), LARL(1), LR(1) Parser Generator -var rmCommonWS$5 = helpers.rmCommonWS; -var mkIdentifier$4 = helpers.mkIdentifier; -var code_exec$2 = helpers.exec; +const rmCommonWS$5 = helpers.rmCommonWS; +const mkIdentifier$4 = helpers.mkIdentifier; +const code_exec$1 = helpers.exec; -var version$2 = '0.6.2-220'; +const version$2 = '0.7.0-220'; -var devDebug = 0; +let devDebug = 0; function chkBugger$3(src) { src = '' + src; @@ -29069,7 +29090,7 @@ function chkBugger$3(src) { // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE$3 = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -var Jison$1 = { +let Jison$1 = { version: version$2 }; @@ -29084,8 +29105,8 @@ const defaultJisonOptions = { compressTables: 2, // 0, 1, 2 outputDebugTables: false, noDefaultResolve: false, - defaultActionMode: ["classic", "merge"], // {classic, ast, none, skip}, {classic, ast, merge, none, skip} - testCompileActionCode: "parser:*,lexer:*", + defaultActionMode: [ 'classic', 'merge' ], // {classic, ast, none, skip}, {classic, ast, merge, none, skip} + testCompileActionCode: 'parser:*,lexer:*', noTryCatch: false, hasPartialLrUpgradeOnConflict: true, errorRecoveryTokenDiscardCount: 3, @@ -29143,7 +29164,7 @@ const defaultJisonOptions = { actionsUseYYSTACKPOINTER: false, actionsUseYYTEXT: false, hasErrorRecovery: false, - hasErrorReporting: false, + hasErrorReporting: false }; Jison$1.defaultJisonOptions = defaultJisonOptions; @@ -29164,25 +29185,25 @@ Jison$1.defaultJisonOptions = defaultJisonOptions; // Return a fresh set of options. /** @public */ function mkStdOptions$1(...args) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - //var args = Array.prototype.concat.apply([], args); + let opts = {}; + //let args = Array.prototype.concat.apply([], args); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(Jison$1.defaultJisonOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; - for (var p in o) { + for (let p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { o2[mkIdentifier$4(p)] = o[p]; } @@ -29214,7 +29235,7 @@ function mkStdOptions$1(...args) { } // fall through case 'string': - var a = String(o2.defaultActionMode).split(',').map(function (m) { + let a = String(o2.defaultActionMode).split(',').map(function (m) { return m.trim(); }); if (a.length === 1) { @@ -29278,7 +29299,7 @@ function mkStdOptions$1(...args) { } // now see if we have an overriding option here: - for (var p in o2) { + for (let p in o2) { if (h.call(o2, p)) { if (typeof o2[p] !== 'undefined') { opts[p] = o2[p]; @@ -29294,7 +29315,7 @@ function mkStdOptions$1(...args) { function prepExportStructures$1(options) { // set up the 'option' `exportAllTables` as a hash object for returning // all generated tables to the caller - var exportDest = options.exportAllTables; + let exportDest = options.exportAllTables; if (!exportDest || typeof exportDest !== 'object') { exportDest = { enabled: !!exportDest @@ -29306,7 +29327,7 @@ function prepExportStructures$1(options) { // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -29327,128 +29348,128 @@ function prepExportStructures$1(options) { // Otherwise return the *parsed* grammar and optional lexer specs as they have // been processed through EBNFParser and LEXParser respectively. function autodetectAndConvertToJSONformat$1(grammar, optionalLexerSection, options) { - var chk_g = null; - var chk_l = null; - var ex1, err; + let chk_g = null; + let chk_l = null; + let ex1, err; if (typeof grammar === 'string') { - if (options.json) { - try { - chk_g = JSON5.parse(grammar); + if (options.json) { + try { + chk_g = JSON5.parse(grammar); - // When JSON5-based parsing of the grammar succeeds, this implies the grammar is specified in `JSON mode` - // *OR* there's a JSON/JSON5 format error in the input: - } catch (e) { - ex1 = e; + // When JSON5-based parsing of the grammar succeeds, this implies the grammar is specified in `JSON mode` + // *OR* there's a JSON/JSON5 format error in the input: + } catch (e) { + ex1 = e; + } } - } - if (!chk_g) { - try { - chk_g = ebnfParser.parse(grammar); - } catch (e) { - if (options.json) { - // When both JSON5 and JISON input modes barf a hairball, assume the most important - // error is the JISON one (show that one first!), while it MAY be a JSON5 format - // error that triggered it (show that one last!). - // - // Also check for common JISON errors which are obviously never triggered by any - // odd JSON5 input format error: when we encounter such an error here, we don't - // confuse matters and forget about the JSON5 fail as it's irrelevant: - const commonErrors = [ - /does not compile/, - /you did not correctly separate trailing code/, - /You did not specify/, - /You cannot specify/, - /must be qualified/, - /%start/, - /%token/, - /%import/, - /%include/, - /%options/, - /%parse-params/, - /%parser-type/, - /%epsilon/, - /definition list error/, - /token list error/, - /declaration error/, - /should be followed/, - /should be separated/, - /an error in one or more of your lexer regex rules/, - /an error in your lexer epilogue/, - /unsupported definition type/, - ]; - var cmnerr = commonErrors.filter(function check(re) { - return e.message.match(re); - }); - if (cmnerr.length > 0) { - err = e; + if (!chk_g) { + try { + chk_g = ebnfParser.parse(grammar); + } catch (e) { + if (options.json) { + // When both JSON5 and JISON input modes barf a hairball, assume the most important + // error is the JISON one (show that one first!), while it MAY be a JSON5 format + // error that triggered it (show that one last!). + // + // Also check for common JISON errors which are obviously never triggered by any + // odd JSON5 input format error: when we encounter such an error here, we don't + // confuse matters and forget about the JSON5 fail as it's irrelevant: + const commonErrors = [ + /does not compile/, + /you did not correctly separate trailing code/, + /You did not specify/, + /You cannot specify/, + /must be qualified/, + /%start/, + /%token/, + /%import/, + /%include/, + /%options/, + /%parse-params/, + /%parser-type/, + /%epsilon/, + /definition list error/, + /token list error/, + /declaration error/, + /should be followed/, + /should be separated/, + /an error in one or more of your lexer regex rules/, + /an error in your lexer epilogue/, + /unsupported definition type/ + ]; + let cmnerr = commonErrors.filter(function check(re) { + return e.message.match(re); + }); + if (cmnerr.length > 0) { + err = e; + } else { + err = new Error('Could not parse jison grammar in JSON AUTODETECT mode:\nin JISON Mode we get Error: ' + e.message + '\nwhile JSON5 Mode produces Error: ' + ex1.message); + err.secondary_exception = e; + err.stack = ex1.stack; + } } else { - err = new Error('Could not parse jison grammar in JSON AUTODETECT mode:\nin JISON Mode we get Error: ' + e.message + '\nwhile JSON5 Mode produces Error: ' + ex1.message); - err.secondary_exception = e; - err.stack = ex1.stack; + err = new Error('Could not parse jison grammar\nError: ' + e.message); + err.stack = e.stack; } - } else { - err = new Error('Could not parse jison grammar\nError: ' + e.message); - err.stack = e.stack; + throw err; } - throw err; } - } - // Save time! Don't reparse the entire grammar *again* inside the code generators when that's not necessary: - // if (chk_g) { - // grammar = chk_g; - // } + // Save time! Don't reparse the entire grammar *again* inside the code generators when that's not necessary: + // if (chk_g) { + // grammar = chk_g; + // } } else { chk_g = grammar; } // Now the same treatment for the lexer: if (chk_g && optionalLexerSection) { - if (chk_g.lex) { - throw new Error('Cannot invoke with both a lexer section in the grammar input and a separate lexer input at the same time!'); - } + if (chk_g.lex) { + throw new Error('Cannot invoke with both a lexer section in the grammar input and a separate lexer input at the same time!'); + } - if (typeof optionalLexerSection === 'string') { - if (options.json) { - try { - chk_l = JSON5.parse(optionalLexerSection); + if (typeof optionalLexerSection === 'string') { + if (options.json) { + try { + chk_l = JSON5.parse(optionalLexerSection); - // When JSON5-based parsing of the lexer spec succeeds, this implies the lexer spec is specified in `JSON mode` - // *OR* there's a JSON/JSON5 format error in the input: - } catch (e) { - ex1 = e; - } - } - if (!chk_l) { - // // WARNING: the lexer may receive options specified in the **grammar spec file**, - // // hence we should mix the options to ensure the lexParser always - // // receives the full set! - // // - // // make sure all options are 'standardized' before we go and mix them together: - // options = mkStdOptions(grammar.options, options); - try { - chk_l = lexParser.parse(optionalLexerSection); - } catch (e) { - if (options.json) { - err = new Error('Could not parse lexer spec in JSON AUTODETECT mode\nError: ' + ex1.message + ' (' + e.message + ')'); - err.secondary_exception = e; - err.stack = ex1.stack; - } else { - err = new Error('Could not parse lexer spec\nError: ' + e.message); - err.stack = e.stack; - } - throw err; - } + // When JSON5-based parsing of the lexer spec succeeds, this implies the lexer spec is specified in `JSON mode` + // *OR* there's a JSON/JSON5 format error in the input: + } catch (e) { + ex1 = e; + } + } + if (!chk_l) { + // // WARNING: the lexer may receive options specified in the **grammar spec file**, + // // hence we should mix the options to ensure the lexParser always + // // receives the full set! + // // + // // make sure all options are 'standardized' before we go and mix them together: + // options = mkStdOptions(grammar.options, options); + try { + chk_l = lexParser.parse(optionalLexerSection); + } catch (e) { + if (options.json) { + err = new Error('Could not parse lexer spec in JSON AUTODETECT mode\nError: ' + ex1.message + ' (' + e.message + ')'); + err.secondary_exception = e; + err.stack = ex1.stack; + } else { + err = new Error('Could not parse lexer spec\nError: ' + e.message); + err.stack = e.stack; + } + throw err; + } + } + } else { + chk_l = optionalLexerSection; } - } else { - chk_l = optionalLexerSection; - } - // Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: - if (chk_l) { - chk_g.lex = chk_l; - } + // Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: + if (chk_l) { + chk_g.lex = chk_l; + } } return chk_g; @@ -29465,7 +29486,7 @@ if (typeof console !== 'undefined' && console.log) { // wrap console.log to prevent 'Illegal Invocation' exceptions when Jison.print() is used, e.g. // in the web tryout pages where this code is employed. Jison$1.print = function console_log(/* ... */) { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); args.unshift(''); // prevent `%.` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args console.log.apply(console, args); }; @@ -29486,7 +29507,7 @@ if (typeof console !== 'undefined' && console.log) { Jison$1.Lexer = RegExpLexer; Jison$1.ebnfParser = ebnfParser; Jison$1.lexParser = lexParser; -Jison$1.codeExec = code_exec$2; +Jison$1.codeExec = code_exec$1; Jison$1.XRegExp = XRegExp; Jison$1.recast = recast; Jison$1.astUtils = astUtils; @@ -29501,7 +29522,7 @@ function each(obj, func) { if (typeof obj.forEach === 'function') { obj.forEach(func); } else { - var p; + let p; for (p in obj) { if (obj.hasOwnProperty(p)) { func.call(obj, obj[p], p, obj); @@ -29531,10 +29552,10 @@ function union(a, b) { // site for this jscore grammar as the naive scan consistently // outperformed the old smarter hash-object code for smaller // thresholds (10, 20, 32, 42!) - var k, len; + let k, len; if (a.length > 52) { - var ar = {}; + let ar = {}; for (k = 0, len = a.length; k < len; k++) { ar[a[k]] = true; } @@ -29544,7 +29565,7 @@ function union(a, b) { } } } else { - var bn = []; + let bn = []; for (k = 0, len = b.length; k < len; k++) { if (a.indexOf(b[k]) < 0) { bn.push(b[k]); @@ -29555,17 +29576,17 @@ function union(a, b) { return a; } -var Nonterminal = typal.construct({ +let Nonterminal = typal.construct({ constructor: function Nonterminal(symbol) { this.symbol = symbol; - this.productions = new Set(); + this.productions = new Set$1(); this.first = []; this.follows = []; this.nullable = false; }, toString: function Nonterminal_toString() { - var str = this.symbol; - var attr_str = []; + let str = this.symbol; + let attr_str = []; if (this.nullable) { attr_str.push('nullable'); @@ -29582,7 +29603,7 @@ var Nonterminal = typal.construct({ } }); -var Production = typal.construct({ +let Production = typal.construct({ constructor: function Production(symbol, handle, id, handle_aliases, handle_action) { this.symbol = symbol; this.handle = handle; @@ -29596,9 +29617,9 @@ var Production = typal.construct({ this.reachable = false; }, toString: function Production_toString() { - var str = this.symbol; + let str = this.symbol; - var attr_str = []; + let attr_str = []; if (this.nullable) { attr_str.push('~'); @@ -29618,9 +29639,9 @@ var Production = typal.construct({ return str; }, describe: function Production_describe() { - var str = this.symbol; + let str = this.symbol; - var attr_str = []; + let attr_str = []; if (this.nullable) { attr_str.push('nullable'); @@ -29641,7 +29662,7 @@ var Production = typal.construct({ -var generator = typal.beget(); +let generator = typal.beget(); // `optionalLexerSection` is an optional {String} argument, specifying the lexer rules. // May only be specified when the specified `grammar` also is a yet-unparsed @@ -29716,11 +29737,11 @@ var generator = typal.beget(); generator.constructor = function Jison_Generator(grammar, optionalLexerSection, options) { // pick the correct argument for the `options` for this call: if (!options && optionalLexerSection && typeof optionalLexerSection !== 'string') { - options = optionalLexerSection; - optionalLexerSection = null; + options = optionalLexerSection; + optionalLexerSection = null; } // and standardize it: - var preliminary_options = mkStdOptions$1(options); + let preliminary_options = mkStdOptions$1(options); grammar = autodetectAndConvertToJSONformat$1(grammar, optionalLexerSection, preliminary_options); @@ -29768,7 +29789,7 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, // } // calculate the input path; if none is specified, it's the present working directory - var inpath = options.file || options.outfile || './dummy'; + let inpath = options.file || options.outfile || './dummy'; inpath = path$1.normalize(inpath); options.inputPath = path$1.dirname(inpath); options.inputFilename = path$1.basename(inpath); @@ -29799,7 +29820,7 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, this.processGrammar(grammar); if (grammar.lex) { - var lexer_options = { + let lexer_options = { // include the knowledge about which parser/lexer // features will actually be *used* by the environment: // @@ -29854,7 +29875,7 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, exportAST: this.options.exportAST, prettyCfg: this.options.prettyCfg, pre_lex: this.options.pre_lex, - post_lex: this.options.post_lex, + post_lex: this.options.post_lex }; this.lexer = new RegExpLexer(grammar.lex, null, this.terminals_, lexer_options); @@ -29862,10 +29883,10 @@ generator.constructor = function Jison_Generator(grammar, optionalLexerSection, }; generator.processGrammar = function processGrammarDef(grammar) { - var bnf = grammar.bnf, - tokens = grammar.tokens, - nonterminals = this.nonterminals = {}, - productions = this.productions; + let bnf = grammar.bnf; + let tokens = grammar.tokens; + let nonterminals = this.nonterminals = {}; + let productions = this.productions; if (!grammar.bnf && grammar.ebnf) { bnf = grammar.bnf = ebnfParser.transform(grammar.ebnf); @@ -29881,18 +29902,18 @@ generator.processGrammar = function processGrammarDef(grammar) { // did the grammar user also provide a predefined set of symbols to be (re)used with this grammar? // (This is used when you want to generate multiple lexers and parsers which share a common symbol set // so as to make the parsers and lexers mutually interchangeable.) - var predefined_symbols = null; + let predefined_symbols = null; if (grammar.imports) { - var symbols_import = grammar.imports.find(function (el, idx) { + let symbols_import = grammar.imports.find(function (el, idx) { if (el.name === 'symbols') { return el; } return false; }); if (symbols_import) { - var filepath = path$1.resolve(symbols_import.path); + let filepath = path$1.resolve(symbols_import.path); - var source = fs.readFileSync(filepath, 'utf8'); + let source = fs.readFileSync(filepath, 'utf8'); // It's either a JSON file or a JISON generated output file: // // symbols_: { @@ -29902,7 +29923,7 @@ generator.processGrammar = function processGrammarDef(grammar) { predefined_symbols = JSON5.parse(source); } catch (ex) { try { - var m = /[\r\n]\s*symbols_:\s*(\{[\s\S]*?\}),\s*[\r\n]/.exec(source); + let m = /[\r\n]\s*symbols_:\s*(\{[\s\S]*?\}),\s*[\r\n]/.exec(source); if (m && m[1]) { source = m[1]; predefined_symbols = JSON5.parse(source); @@ -29917,18 +29938,18 @@ generator.processGrammar = function processGrammarDef(grammar) { } // Make sure all predefined symbols are unique and *numeric* and do not include predefined tokens JISON already defines to a fixed ID on its own: - delete predefined_symbols['$accept']; - delete predefined_symbols['$end']; - delete predefined_symbols['error']; - delete predefined_symbols['$eof']; - delete predefined_symbols['EOF']; + delete predefined_symbols.$accept; + delete predefined_symbols.$end; + delete predefined_symbols.error; + delete predefined_symbols.$eof; + delete predefined_symbols.EOF; - var symdef_uniq_check = {}; + let symdef_uniq_check = {}; // Only these symbols are allowed to have the values 1 or 2: symdef_uniq_check[1] = 'EOF'; symdef_uniq_check[2] = 'error'; Object.keys(predefined_symbols).forEach(function cvt_symbol_id_to_numeric(sym) { - var v = predefined_symbols[sym]; + let v = predefined_symbols[sym]; // Symbol value may be defined as boolean TRUE, in which case we let JISON pick the value for us: if (v === true) return; @@ -29936,17 +29957,17 @@ generator.processGrammar = function processGrammarDef(grammar) { // Symbol value may be defined as a one-character string: if (typeof v !== 'number') { if (typeof v !== 'string' || v.length !== 1) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a non-numeric symbol ID value must be a single-character string.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a non-numeric symbol ID value must be a single-character string."); } v = v.charCodeAt(0); } - v = v | 0; + v |= 0; if (!v || v < 0) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a symbol ID value must be an integer value, 3 or greater.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a symbol ID value must be an integer value, 3 or greater."); } if (symdef_uniq_check[v]) { if (symdef_uniq_check[v] !== sym) { - throw new Error('Error: `%import symbols `: symbol table contains duplicate ID values for keys \'' + sym + '\' and \'' + symdef_uniq_check[v] + '\''); + throw new Error("Error: `%import symbols `: symbol table contains duplicate ID values for keys '" + sym + "' and '" + symdef_uniq_check[v] + "'"); } } symdef_uniq_check[v] = sym; @@ -29955,15 +29976,15 @@ generator.processGrammar = function processGrammarDef(grammar) { } } - var symbols = this.symbols = []; + let symbols = this.symbols = []; // calculate precedence of operators - var operators = this.operators = processOperators(grammar.operators); + let operators = this.operators = processOperators(grammar.operators); // build productions from CFG and calculate the symbol sets (terminals and nonterminals) and their name-to-ID mappings this.buildProductions(bnf, productions, nonterminals, symbols, operators, predefined_symbols, grammar.extra_tokens); if (tokens) { - var termset = this.terminals.filter(function (t) { + let termset = this.terminals.filter(function (t) { switch (t) { case 'EOF': case 'error': @@ -29975,7 +29996,7 @@ generator.processGrammar = function processGrammarDef(grammar) { return true; } }); - var diffset = termset.filter(function (t) { + let diffset = termset.filter(function (t) { return tokens.indexOf(t) === -1; }); diffset = diffset.concat(tokens.filter(function (t) { @@ -30032,7 +30053,7 @@ generator.augmentGrammar = function augmentGrammar(grammar) { // return true; // the default parse result if the rule actions don't produce anything // %} // - var acceptProduction = new Production('$accept', [this.startSymbol, '$end'], 0); + let acceptProduction = new Production('$accept', [ this.startSymbol, '$end' ], 0); this.productions.unshift(acceptProduction); // prepend parser tokens // moved to generator.buildProductions() @@ -30051,14 +30072,13 @@ generator.augmentGrammar = function augmentGrammar(grammar) { // Mark unused productions generator.signalUnusedProductions = function () { - var mark = {}; + let mark = {}; - var productions = this.productions; - var nonterminals = this.nonterminals; - var i, len, nt, sym; + let productions = this.productions; + let nonterminals = this.nonterminals; - for (i = 0, len = nonterminals.length; i < len; i++) { - nt = nonterminals[i]; + for (let i = 0, len = nonterminals.length; i < len; i++) { + let nt = nonterminals[i]; assert$1(nt.symbol); mark[nt.symbol] = false; } @@ -30069,15 +30089,15 @@ generator.signalUnusedProductions = function () { assert$1(nt.symbol); mark[nt.symbol] = true; - var prods = nt.productions; + let prods = nt.productions; assert$1(prods); prods.forEach(function (p) { assert$1(p.symbol === nt.symbol); assert$1(p.handle); - var rhs = p.handle; + let rhs = p.handle; - for (var j = 0, len = rhs.length; j < len; j++) { - var sym = rhs[j]; + for (let j = 0, len = rhs.length; j < len; j++) { + let sym = rhs[j]; assert$1(!sym ? !nonterminals[sym] : true); if (nonterminals[sym] && !mark[sym]) { traverseGrammar(nonterminals[sym]); @@ -30086,15 +30106,15 @@ generator.signalUnusedProductions = function () { }); } - traverseGrammar(nonterminals['$accept' /* this.startSymbol */ ]); + traverseGrammar(nonterminals['$accept' /* this.startSymbol */]); // now any production which is not yet marked is *unused*: - for (sym in mark) { - nt = nonterminals[sym]; + for (let sym in mark) { + let nt = nonterminals[sym]; assert$1(nt); - var prods = nt.productions; + let prods = nt.productions; assert$1(prods); - var in_use = mark[sym]; + let in_use = mark[sym]; prods.forEach(function (p) { assert$1(p); if (in_use) { @@ -30123,8 +30143,8 @@ generator.signalUnusedProductions = function () { // set precedence and associativity of operators function processOperators(ops) { if (!ops) return {}; - var operators = {}; - for (var i = 0, k, prec; (prec = ops[i]); i++) { + let operators = {}; + for (let i = 0, k, prec; (prec = ops[i]); i++) { for (k = 1; k < prec.length; k++) { operators[prec[k]] = { precedence: i + 1, @@ -30139,8 +30159,8 @@ function processOperators(ops) { // // Note that the first line doesn't count as the chunk is very probably trimmed! function reindentCodeBlock(action, indent_level) { - var width = 0; - var lines = action + let width = 0; + let lines = action .trim() .split('\n') // measure the indent: @@ -30157,7 +30177,7 @@ function reindentCodeBlock(action, indent_level) { return s.replace(/\t/g, ' '); }); - var m = /^[ ]+/.exec(line); + let m = /^[ ]+/.exec(line); if (m) { width = Math.min(m[0].length, width); } @@ -30168,8 +30188,8 @@ function reindentCodeBlock(action, indent_level) { .map(function checkIndentation(line, idx) { line = line .replace(/^[ ]*/, function adjustIndent(s) { - var l = Math.max(s.length - width, 0) + indent_level; - var shift = (new Array(l + 1)).join(' '); + let l = Math.max(s.length - width, 0) + indent_level; + let shift = (new Array(l + 1)).join(' '); return shift; }); return line; @@ -30180,21 +30200,21 @@ function reindentCodeBlock(action, indent_level) { generator.buildProductions = function buildProductions(bnf, productions, nonterminals, symbols, operators, predefined_symbols, descriptions) { - var self = this; - var prods, symbol, symId; - var productions_ = []; - var symbols_ = {}; - var descriptions_ = {}; - var usedSymbolIds = [/* $accept = 0 */ true, /* $end = 1 */ true, /* error = 2 */ true]; - var usedSymbolIdsLowIndex = 3; + let self = this; + let prods, symId; + let productions_ = []; + let symbols_ = {}; + let descriptions_ = {}; + let usedSymbolIds = [/* $accept = 0 */ true, /* $end = 1 */ true, /* error = 2 */ true ]; + let usedSymbolIdsLowIndex = 3; // set up the required symbols `$accept` and `$end` (a.k.a. EOF) and make sure they occupy the expected slots: this.EOF = '$end'; symbols_.$accept = 0; symbols_[this.EOF] = 1; - symbols_['$eof'] = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! - symbols_['EOF'] = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.$eof = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.EOF = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! symbols[0] = '$accept'; symbols[1] = this.EOF; @@ -30205,7 +30225,7 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm symbols[2] = 'error'; if (predefined_symbols) { - for (symbol in predefined_symbols) { + for (let symbol in predefined_symbols) { symId = predefined_symbols[symbol]; if (symId === true) { // add symbol to queue which must be assigned a value by JISON; after all the other predefined symbols have been processed. @@ -30228,7 +30248,7 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm // preferably assign readable ASCII-range token IDs to tokens added from the predefined list // but only when maximum table compression isn't demanded: usedSymbolIdsLowIndex = ((this.options.compressTables | 0) < 2 ? 32 : 3); - for (symbol in predefined_symbols) { + for (let symbol in predefined_symbols) { symId = predefined_symbols[symbol]; addSymbol(symbol); } @@ -30248,11 +30268,11 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm } - var hasErrorRecovery = false; // has error recovery + let hasErrorRecovery = false; // has error recovery // Produce the next available unique symbolID: function getNextSymbolId() { - for (var i = usedSymbolIdsLowIndex; ; i++) { + for (let i = usedSymbolIdsLowIndex; ; i++) { if (!usedSymbolIds[i]) { usedSymbolIds[i] = true; usedSymbolIdsLowIndex = i + 1; @@ -30263,7 +30283,7 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm function addSymbol(s) { if (s && !symbols_[s]) { - var i; + let i; // assign the Unicode codepoint index to single-character symbols, // but only when maximum table compression isn't demanded: @@ -30287,46 +30307,45 @@ generator.buildProductions = function buildProductions(bnf, productions, nonterm // `this` is options object with `maxTokenLength` option to guide us which literal tokens we want to process: function collectLiteralTokensInProduction(handle) { - var rhs, i, sym; + let rhs; - try{ - if (devDebug) ; + try { + if (devDebug) ; - var maxlen = this.maxTokenLength || Infinity; + let maxlen = this.maxTokenLength || Infinity; - if (handle.constructor === Array) { - var rhs_i; - rhs = (typeof handle[0] === 'string') ? - splitStringIntoSymbols(handle[0]) : - handle[0].slice(0); + if (handle.constructor === Array) { + rhs = (typeof handle[0] === 'string') ? + splitStringIntoSymbols(handle[0]) : + handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; - // check for aliased names, e.g., id[alias] and strip them - rhs_i = sym.match(new XRegExp(`\\[${ID_REGEX_BASE$3}\\]$`)); - if (rhs_i) { - sym = sym.substr(0, sym.length - rhs_i[0].length); - } + for (let i = 0; i < rhs.length; i++) { + let sym = rhs[i]; + // check for aliased names, e.g., id[alias] and strip them + let rhs_i = sym.match(new XRegExp(`\\[${ID_REGEX_BASE$3}\\]$`)); + if (rhs_i) { + sym = sym.substr(0, sym.length - rhs_i[0].length); + } - if (!bnf[sym] && sym.length <= maxlen) { - addSymbol(sym); + if (!bnf[sym] && sym.length <= maxlen) { + addSymbol(sym); + } } - } - } else { - // no action -> don't care about aliases; strip them. - handle = handle.replace(new XRegExp(`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); - rhs = splitStringIntoSymbols(handle); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; - if (!bnf[sym] && sym.length <= maxlen) { - addSymbol(sym); + } else { + // no action -> don't care about aliases; strip them. + handle = handle.replace(new XRegExp(`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); + rhs = splitStringIntoSymbols(handle); + for (let i = 0; i < rhs.length; i++) { + let sym = rhs[i]; + if (!bnf[sym] && sym.length <= maxlen) { + addSymbol(sym); + } } } + } catch (ex) { + console.error(ex, '\ncollectLiteralTokensInProduction: ', this.symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { rhs }); + throw ex; } - }catch (ex) { -console.error(ex, '\ncollectLiteralTokensInProduction: ', symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { i, sym, rhs }); -throw ex; - } } // Before we go process the grammar for real, we collect the 'literal' non-terminals and add them to the symbol table @@ -30334,8 +30353,8 @@ throw ex; // which helps debugging/diagnosis of generated grammars. // (This is why previously we had set `usedSymbolIdsLowIndex` to 127 instead of 3!) - var prodsLUT = {}; - for (symbol in bnf) { + let prodsLUT = {}; + for (let symbol in bnf) { if (!bnf.hasOwnProperty(symbol)) continue; if (typeof bnf[symbol] === 'string') { @@ -30348,21 +30367,23 @@ throw ex; } // First we collect all single-character literal tokens: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: 1 + maxTokenLength: 1, + symbol }); } // Next we collect all other literal tokens: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: Infinity + maxTokenLength: Infinity, + symbol }); } @@ -30371,7 +30392,7 @@ throw ex; // for each of those: nonterminals should all have IDs assigned before they // should be processed as part of a *production* rule, where these MAY be // referenced: - for (symbol in bnf) { + for (let symbol in bnf) { if (!bnf.hasOwnProperty(symbol)) continue; addSymbol(symbol); @@ -30380,15 +30401,15 @@ throw ex; // now that we have collected all nonterminals in our symbol table, it's finally // time to process the productions: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; - prods.forEach(buildProduction); + prods.forEach(buildProduction, { symbol }); } - var terms = [], - terms_ = {}; + let terms = []; + let terms_ = {}; each(symbols_, function (id, sym) { // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number @@ -30404,7 +30425,7 @@ throw ex; // fix error recovery related options now that we know whether we actually have any recovery // rules at all: if (!this.hasErrorRecovery) { - var chk_er_opt = function check_error_recovery_option(opt, label) { + let chk_er_opt = function check_error_recovery_option(opt, label) { if (self.options[opt]) { self.options[opt] = false; self.warn('The grammar does not have any error recovery rules, so using the ' + label + ' is rather useless.'); @@ -30416,9 +30437,9 @@ throw ex; // Hmmmm... why would lexer errors need to be NON-recoverable when there's no ERROR rules in the GRAMMAR?! chk_er_opt('lexerErrorsAreRecoverable', 'lexer-errors-are-recoverable feature/option'); - chk_er_opt('parseActionsUseYYRECOVERING', 'YYRECOVERING macro/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYERROK', 'yyerrok() function/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYCLEARIN', 'yyclearin() function/API in grammar rules\' action code'); + chk_er_opt('parseActionsUseYYRECOVERING', "YYRECOVERING macro/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYERROK', "yyerrok() function/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYCLEARIN', "yyclearin() function/API in grammar rules' action code"); } this.terminals = terms; @@ -30437,8 +30458,8 @@ throw ex; function splitStringIntoSymbols(rhs) { // when there's no literal tokens in there, we can fast-track this baby: rhs = rhs.trim(); - var pos1 = rhs.indexOf("'"); - var pos2 = rhs.indexOf('"'); + let pos1 = rhs.indexOf("'"); + let pos2 = rhs.indexOf('"'); if (pos1 < 0 && pos2 < 0) { return rhs.split(' '); } @@ -30446,10 +30467,10 @@ throw ex; // // rhs has at least one literal: we will need to parse the rhs into tokens // with a little more effort now. - var tokens = []; + let tokens = []; while (pos1 >= 0 || pos2 >= 0) { - var pos = pos1; - var marker = "'"; + let pos = pos1; + let marker = "'"; if (pos < 0) { assert$1(pos2 >= 0); pos = pos2; @@ -30458,7 +30479,7 @@ throw ex; pos = pos2; marker = '"'; } - var ls = rhs.substr(0, pos).trim(); + let ls = rhs.substr(0, pos).trim(); if (ls.length > 0) { tokens.push.apply(tokens, ls.split(' ')); } @@ -30467,7 +30488,7 @@ throw ex; // // Edge case: token MAY include the ESCAPED MARKER... or other escapes! // Hence we need to skip over ALL escapes inside the token! - var pos3 = rhs.indexOf('\\'); + let pos3 = rhs.indexOf('\\'); pos = rhs.indexOf(marker); ls = ''; while (pos3 >= 0 && pos3 < pos) { @@ -30482,7 +30503,7 @@ throw ex; ls += rhs.substr(0, pos); // check for aliased literals, e.g., `'>'[gt]` and keep it and the alias together rhs = rhs.substr(pos + 1); - var alias = rhs.match(new XRegExp(`^\\[${ID_REGEX_BASE$3}\\]`)); + let alias = rhs.match(new XRegExp(`^\\[${ID_REGEX_BASE$3}\\]`)); if (alias) { ls += alias[0]; rhs = rhs.substr(alias[0].length); @@ -30502,22 +30523,21 @@ throw ex; return tokens; } + // options object { symbol } is `this` for this functon/callback: function buildProduction(handle) { - var r, rhs, i, - precedence_override, - aliased = [], - action = null; + let rhs; + let precedence_override = null; + let aliased = []; + let action = null; if (handle.constructor === Array) { - var rhs_i; - rhs = (typeof handle[0] === 'string') ? - splitStringIntoSymbols(handle[0]) : - handle[0].slice(0); + splitStringIntoSymbols(handle[0]) : + handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // check for aliased names, e.g., id[alias] and strip them - rhs_i = rhs[i].match(new XRegExp(`\\[${ID_REGEX_BASE$3}\\]$`)); + let rhs_i = rhs[i].match(new XRegExp(`\\[${ID_REGEX_BASE$3}\\]$`)); if (rhs_i) { rhs[i] = rhs[i].substr(0, rhs[i].length - rhs_i[0].length); rhs_i = rhs_i[0].substr(1, rhs_i[0].length - 2); @@ -30559,7 +30579,7 @@ throw ex; // no action -> don't care about aliases; strip them. handle = handle.replace(new XRegExp(`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { if (rhs[i] === 'error') { hasErrorRecovery = true; } @@ -30569,35 +30589,33 @@ throw ex; } } - r = new Production(symbol, rhs, productions.length + 1, aliased, action); + let r = new Production(this.symbol, rhs, productions.length + 1, aliased, action); // set precedence assert$1(r.precedence === 0); if (precedence_override) { r.precedence = precedence_override.spec.precedence; - } - else { - var prec_symbols = []; - var winning_symbol; + } else { + let prec_symbols = []; + let winning_symbol; - for (i = r.handle.length - 1; i >= 0; i--) { + for (let i = r.handle.length - 1; i >= 0; i--) { if (!(r.handle[i] in nonterminals) && r.handle[i] in operators) { - var old_prec = r.precedence; - var new_prec = operators[r.handle[i]].precedence; + let old_prec = r.precedence; + let new_prec = operators[r.handle[i]].precedence; if (old_prec !== 0 && old_prec !== new_prec) { prec_symbols.push(r.handle[i]); - // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], symbol, handle[0]); + // 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[i]; - } - else { + } else { // keep previously set precedence: new_prec = old_prec; } } else if (old_prec === 0) { prec_symbols.push(r.handle[i]); winning_symbol = r.handle[i]; - // Jison.print('precedence set first time: ', old_prec, r.handle[i], symbol, handle[0]); + // Jison.print('precedence set first time: ', old_prec, r.handle[i], this.symbol, handle[0]); } r.precedence = new_prec; } @@ -30605,14 +30623,14 @@ throw ex; if (prec_symbols.length > 1) { if (self.DEBUG || 1) { - self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); + self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + this.symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); } } } productions.push(r); - productions_.push([symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length]); - nonterminals[symbol].productions.push(r); + productions_.push([ symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length ]); + nonterminals[this.symbol].productions.push(r); } }; @@ -30717,8 +30735,9 @@ function preprocessActionCode(s) { // with our pants down in constructs like // `'"' + $$ + '"'` vs. `"'" + $$ + "'"` - var dqpos, sqpos, ccmtpos, cppcmtpos, first = -1; - for (var c = 0;; c++) { + let dqpos, sqpos, ccmtpos, cppcmtpos; + let first = -1; + for (let c = 0; ; c++) { first++; dqpos = s.indexOf('"', first); sqpos = s.indexOf("'", first); @@ -30762,11 +30781,11 @@ function postprocessActionCode(s) { .replace(/\x01\x82/g, '$') .replace(/\x01\x83/g, '@') // and revert the string and regex markers: - .replace(/\x01\x87/g, '\'') + .replace(/\x01\x87/g, "'") .replace(/\x01\x88/g, '\"') .replace(/\x01\x89/g, '##') .replace(/\x01\x90/g, '\\\\') - .replace(/\x01\x91/g, '\\\'') + .replace(/\x01\x91/g, "\\'") .replace(/\x01\x92/g, '\\\"') .replace(/\x01\x93/g, '\\\/') .replace(/\x01\x94/g, 'YYABORT') @@ -30799,7 +30818,7 @@ function mkHashIndex(s) { } function analyzeFeatureUsage(sourcecode, feature, threshold) { - var found = sourcecode.match(feature); + let found = sourcecode.match(feature); return !!(found && found.length > threshold); } @@ -30807,7 +30826,7 @@ function analyzeFeatureUsage(sourcecode, feature, threshold) { function mkParserFeatureHash(self) { assert$1(self.options.exportAllTables); // check that this function isn't called too early in the process or the hash will be bogus assert$1(self.options.exportSourceCode); - var h = [ + let h = [ self.actionsAreAllDefault, self.actionsUseLocationAssignment, self.actionsUseLocationTracking, @@ -30856,7 +30875,7 @@ function mkParserFeatureHash(self) { self.options.prettyCfg, '======================================', self.performAction, - '======================================', + '======================================' ]; return JSON.stringify(h); } @@ -30871,23 +30890,23 @@ generator.buildProductionActions = function buildProductionActions() { this.productions_ = productions_; assert(this.productions === productions); */ - var productions = this.productions, - nonterminals = this.nonterminals, - symbols = this.symbols, - operators = this.operators, - self = this; + let productions = this.productions; + let nonterminals = this.nonterminals; + let symbols = this.symbols; + let operators = this.operators; + let self = this; // As a SIDE EFFECT of this call, we also fixup // the other code chunks specified in the grammar file: // // Replace direct symbol references, e.g. #NUMBER# when there's a `%token NUMBER` for your grammar. // We allow these tokens to be referenced anywhere in your code as #TOKEN#. - var moduleInclude = preprocessActionCode(this.moduleInclude) + let moduleInclude = preprocessActionCode(this.moduleInclude) .replace(new XRegExp(`#(${ID_REGEX_BASE$3})#`, 'g'), function (_, sym) { return provideSymbolAsSourcecode(sym); }); // and COPY the `moduleInit` array, after preprocessing the individual COPIES: - var moduleInit = this.moduleInit.map(function (chunk) { + let moduleInit = this.moduleInit.map(function (chunk) { assert$1(chunk.qualifier); assert$1(typeof chunk.include === 'string'); return { @@ -30903,39 +30922,38 @@ generator.buildProductionActions = function buildProductionActions() { // We potentially need multiple (2+) rounds to produce the correct actions // as userland action code determines whether the default actions should // include location tracking or not: - var gen_level = 0; - var prev_gen_hash = 'n'; - var gen_hash = 'y'; + let gen_level = 0; + let prev_gen_hash = 'n'; + let gen_hash = 'y'; this.performAction = null; while (gen_hash !== prev_gen_hash) { - var preludeCode = preprocessActionCode(this.actionInclude || ''); - var actions = [` + let preludeCode = preprocessActionCode(this.actionInclude || ''); + let actions = [ ` /* this == yyval */ // the JS engine itself can go and remove these statements when \`yy\` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; ${preludeCode} switch (yystate) {` ]; - var actionGroups = {}; // used to combine identical actions into single instances: no use duplicating action code needlessly - var actionGroupValue = {}; // stores the unaltered, expanded, user-defined action code for each action group. - var stateHasAction = []; // marks which state IDs have an action, either user-specified or default. - var symbol; + let actionGroups = {}; // used to combine identical actions into single instances: no use duplicating action code needlessly + let actionGroupValue = {}; // stores the unaltered, expanded, user-defined action code for each action group. + let stateHasAction = []; // marks which state IDs have an action, either user-specified or default. // and now go and process the entire grammar: - productions.forEach(buildProductionAction); + productions.forEach(buildProductionAction, { actionGroups, actionGroupValue, stateHasAction }); - for (var hash in actionGroups) { + for (let hash in actionGroups) { actions.push([].concat.apply([], actionGroups[hash]).join('\n') + '\n\n' + actionGroupValue[hash] + '\n break;\n'); } // add the special error recovery reduction action: if (this.hasErrorRecovery) { - var userland_err_recov_redux_code = ''; + let userland_err_recov_redux_code = ''; actions.push(`case YY_ERROR_RECOVERY_COMBINE_ID: // === NO_ACTION[1] :: ensures that anyone (but us) using this new state will fail dramatically! // error recovery reduction action (action generated by jison, @@ -30948,16 +30966,16 @@ generator.buildProductionActions = function buildProductionActions() { } // check if all IDs have an action now: - var missingActions = []; - for (var idx = 0, len = stateHasAction.length; idx < len; idx++) { + let missingActions = []; + for (let idx = 0, len = stateHasAction.length; idx < len; idx++) { if (!stateHasAction[idx]) { missingActions.push(idx); } } - this.missingActions = missingActions; + this.missingActions = missingActions; if (missingActions.length) { if ( this.DEBUG) { - this.warn("WARNING: missing actions for states: ", missingActions); + this.warn('WARNING: missing actions for states: ', missingActions); } actions.push(`default: @@ -30965,7 +30983,7 @@ generator.buildProductionActions = function buildProductionActions() { // When we hit this entry, it's always a non-recoverable issue as this is a severe internal parser state failure: function __b0rk_on_internal_failure(str) { - var hash = yyparser.constructParseErrorInfo(str, null, null, false); + let hash = yyparser.constructParseErrorInfo(str, null, null, false); return yyparser.parseError(str, hash, yyparser.JisonParserError); } @@ -30975,7 +30993,7 @@ generator.buildProductionActions = function buildProductionActions() { } actions.push('}'); - var parameters = 'yytext, yyleng, yylineno, yyloc, yystate /* action[1] */, yysp, yyrulelength, yyvstack, yylstack, yystack, yysstack'; + let parameters = 'yytext, yyleng, yylineno, yyloc, yystate /* action[1] */, yysp, yyrulelength, yyvstack, yylstack, yystack, yysstack'; this.performAction = [].concat( 'function parser__PerformAction(' + parameters + ') {', @@ -31094,7 +31112,7 @@ generator.buildProductionActions = function buildProductionActions() { moduleInit.forEach(function (chunk) { assert$1(chunk.qualifier); assert$1(typeof chunk.include === 'string'); - var moduleInclude = chunk.include; + let moduleInclude = chunk.include; //self.actionsUseYYLENG = self.actionsUseYYLENG || analyzeFeatureUsage(moduleInclude, /\byyleng\b/g, 0); //self.actionsUseYYLINENO = self.actionsUseYYLINENO || analyzeFeatureUsage(moduleInclude, /\byylineno\b/g, 0); @@ -31162,8 +31180,8 @@ generator.buildProductionActions = function buildProductionActions() { this.actionsUseValueAssignment = true; break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": // <-- this one injects *nothing* + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'skip': // <-- this one injects *nothing* break; } this.actionsUseValueTracking = this.actionsUseValueTracking || this.actionsUseYYLENG || this.actionsUseYYTEXT || this.actionsUseValueAssignment; @@ -31172,8 +31190,8 @@ generator.buildProductionActions = function buildProductionActions() { default: break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": // <-- this one injects *nothing* + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'skip': // <-- this one injects *nothing* break; } this.actionsUseLocationTracking = this.actionsUseLocationTracking || this.actionsUseYYLINENO || this.actionsUseYYLOC || this.actionsUseLocationAssignment || this.actionsUseYYMERGELOCATIONINFO; @@ -31194,7 +31212,7 @@ generator.buildProductionActions = function buildProductionActions() { gen_hash = null; // create check hash of the new generated code: - var new_hash = mkParserFeatureHash(this); + let new_hash = mkParserFeatureHash(this); if ( this.DEBUG) { Jison$1.print('Optimization analysis:\n', { @@ -31223,7 +31241,7 @@ generator.buildProductionActions = function buildProductionActions() { hasErrorReporting: this.hasErrorReporting, defaultActionMode: this.options.defaultActionMode, testCompileActionCode: this.options.testCompileActionCode, - noTryCatch: this.options.noTryCatch, + noTryCatch: this.options.noTryCatch }); } @@ -31246,9 +31264,9 @@ generator.buildProductionActions = function buildProductionActions() { moduleInit.__consumedInitCodeSlots__ = []; moduleInit.getInitCodeSection = function getInitCodeSection(section) { - var rv = []; - for (var i = 0, len = this.length; i < len; i++) { - var m = this[i]; + let rv = []; + for (let i = 0, len = this.length; i < len; i++) { + let m = this[i]; if (m.qualifier === section) { if (m.include.trim()) { rv.push(m.include); @@ -31260,9 +31278,9 @@ generator.buildProductionActions = function buildProductionActions() { }; moduleInit.getRemainingInitCodeSections = function getRemainingInitCodeSections() { - var rv = []; - for (var i = 0, len = this.length; i < len; i++) { - var m = this[i]; + let rv = []; + for (let i = 0, len = this.length; i < len; i++) { + let m = this[i]; if (!this.__consumedInitCodeSlots__[i]) { rv.push(rmCommonWS$5` @@ -31278,8 +31296,6 @@ generator.buildProductionActions = function buildProductionActions() { }; - - // make sure a comment does not contain any embedded '*/' end-of-comment marker // as that would break the generated code function postprocessComment(str) { @@ -31303,13 +31319,13 @@ generator.buildProductionActions = function buildProductionActions() { } function provideSymbolAsSourcecode(sym) { - var ss = String(sym); + let ss = String(sym); return ' /* ' + postprocessComment(ss) + ' */ ' + getSymbolId(sym); } // helper: convert index string/number to proper JS add/subtract expression function indexToJsExpr(n, len, rule4msg) { - var v = parseInt(n, 10); + let v = parseInt(n, 10); // the usual situation: `$3`; MUST reference an rhs[] element or it will be considered an ERROR: if (v > 0) { if (v > len) { @@ -31339,35 +31355,33 @@ generator.buildProductionActions = function buildProductionActions() { return ''; } + // options object { actionGroups, actionGroupValue, stateHasAction } is `this` for this function/callback: function buildProductionAction(handle) { - var i; - var aliased = handle.aliases, - rhs_i; + let aliased = handle.aliases; - var rhs = handle.handle; - var named_token_re = new XRegExp(`^${ID_REGEX_BASE$3}$`); + let rhs = handle.handle; + let named_token_re = new XRegExp(`^${ID_REGEX_BASE$3}$`); // semantic action specified - var label = [ + let label = [ 'case ', handle.id, ':', '\n /*! Production:: ', postprocessComment(handle.symbol), ' : ' ].concat(postprocessComment(rhs.map(function (sym) { // check if the symbol is a literal terminal, and if it is, quote it: if (sym && !self.nonterminals[sym] && !named_token_re.test(sym) && sym !== self.EOF) { return '"' + sym.replace(/["]/g, '\\"') + '"'; - } - else if (!sym) { + } else if (!sym) { sym = '%epsilon'; } return sym; })), ' */').join(''); - var action = preprocessActionCode(handle.action || ''); - var rule4msg = handle.symbol + ': ' + rhs.join(' '); + let action = preprocessActionCode(handle.action || ''); + let rule4msg = handle.symbol + ': ' + rhs.join(' '); assert$1(typeof handle.id === 'number'); assert$1(handle.id >= 0); - stateHasAction[handle.id] = true; + this.stateHasAction[handle.id] = true; // before anything else, replace direct symbol references, e.g. #NUMBER# when there's a %token NUMBER for your grammar. // This is done to prevent incorrect expansions where tokens are used in rules as RHS elements: we allow these to @@ -31382,9 +31396,9 @@ generator.buildProductionActions = function buildProductionActions() { // replace named semantic values ($nonterminal) if (action.match(new XRegExp(`(?:[$@#]|##)${ID_REGEX_BASE$3}`))) { - var count = {}, - names = {}, - donotalias = {}; + let count = {}; + let names = {}; + let donotalias = {}; // When the rule is fitted with aliases it doesn't mean that the action code MUST use those: // we therefor allow access to both the original (non)terminal and the alias. @@ -31415,9 +31429,9 @@ generator.buildProductionActions = function buildProductionActions() { // as an explicit alias: adding auto-alias `e1` would then break the system, // while `e2` would be ambiguous from the human perspective as he *might* then // expect `e2` and `e3`. - var addName = function addName(s) { - var base = s.replace(/[0-9]+$/, ''); - var dna = donotalias[base]; + let addName = function addName(s, i) { + let base = s.replace(/[0-9]+$/, ''); + let dna = donotalias[base]; if (names[s]) { count[s]++; @@ -31438,28 +31452,28 @@ generator.buildProductionActions = function buildProductionActions() { // register the alias/rule name when the real one ends with a number, e.g. `rule5` as // *blocking* the auto-aliasing process for the term of the same base, e.g. `rule`. // This will catch the `WORD[e1]` example above too, via `e1` --> `donotalias['e']` - var markBasename = function markBasename(s) { + let markBasename = function markBasename(s) { if (/[0-9]$/.test(s)) { s = s.replace(/[0-9]+$/, ''); donotalias[s] = true; } }; - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // mark both regular and aliased names, e.g., `id[alias1]` and `id1` - rhs_i = aliased[i]; + let rhs_i = aliased[i]; markBasename(rhs_i); if (rhs_i !== rhs[i]) { markBasename(rhs[i]); } } - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // check for aliased names, e.g., id[alias] - rhs_i = aliased[i]; - addName(rhs_i); + let rhs_i = aliased[i]; + addName(rhs_i, i); if (rhs_i !== rhs[i]) { - addName(rhs[i]); + addName(rhs[i], i); } } action = action.replace( @@ -31476,7 +31490,7 @@ generator.buildProductionActions = function buildProductionActions() { .replace(/\$\$/g, 'this.$') .replace(/@\$/g, 'this._$') .replace(/#\$/g, function (_) { - return provideSymbolAsSourcecode(symbol); + return provideSymbolAsSourcecode(handle.symbol); }) // replace semantic value references ($n) with stack value (stack[n]) .replace(/\$(-?\d+)\b/g, function (_, n) { @@ -31495,7 +31509,7 @@ generator.buildProductionActions = function buildProductionActions() { }) // same as above for token ID references (#n) .replace(/#(-?\d+)\b/g, function (_, n) { - var i = parseInt(n, 10) - 1; + let i = parseInt(n, 10) - 1; if (!rhs[i]) { throw new Error(`invalid token location reference in action code for rule: "${rule4msg}" - location reference: "${_}"`); } @@ -31539,7 +31553,7 @@ generator.buildProductionActions = function buildProductionActions() { // the action code: if some Smart Alec decides to code `this.$` instead of // `$$` it SHOULD NOT confuse the code analysis here! - var uses_$$ = analyzeFeatureUsage(action, /\bthis\.\$[^\w]/g, 0); // use includes assignment, not just read accesses! + let uses_$$ = analyzeFeatureUsage(action, /\bthis\.\$[^\w]/g, 0); // use includes assignment, not just read accesses! // the next check is very rough; we need the AST of the code to do better than this. function analyzeFeatureAssignmentBeforeUse(source, assignment_re, access_re) { @@ -31548,8 +31562,8 @@ generator.buildProductionActions = function buildProductionActions() { // // If no assignment can be found at all, we're probably looking at access-only // OR weird constructs we don't yet understand, in which case we play it safe. - var prelude = source; - var m = source.match(assignment_re); + let prelude = source; + let m = source.match(assignment_re); if (m) { // check the closure exists in the regex: m[1] is filled with its content: assert$1(m[1] != null); @@ -31579,21 +31593,21 @@ generator.buildProductionActions = function buildProductionActions() { return false; // assignment before access (or no usage and assignments at all!) } - var uses_$$_before_assignment = uses_$$ && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\.\$\s*=[^=>]/, /\bthis\.\$[^\w]/g); + let uses_$$_before_assignment = uses_$$ && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\.\$\s*=[^=>]/, /\bthis\.\$[^\w]/g); // ditto for location tracking, but only iff we use it at all: - var uses_$loc = false; - var uses_$loc_before_assignment = false; + let uses_$loc = false; + let uses_$loc_before_assignment = false; if (self.actionsUseLocationTracking) { uses_$loc = analyzeFeatureUsage(action, /\bthis\._\$[^\w]/g, 0); uses_$loc_before_assignment = uses_$loc && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\._\$\s*=[^=>]/, /\bthis\._\$[^\w]/g); } - var inject_default_value_action = (uses_$$_before_assignment || (self.actionsUseValueTracking && !uses_$$)); - var inject_default_loc_action = (uses_$loc_before_assignment || (self.actionsUseLocationTracking && !uses_$loc)); + let inject_default_value_action = (uses_$$_before_assignment || (self.actionsUseValueTracking && !uses_$$)); + let inject_default_loc_action = (uses_$loc_before_assignment || (self.actionsUseLocationTracking && !uses_$loc)); - var default_action = []; + let default_action = []; // Note: // @@ -31604,26 +31618,27 @@ generator.buildProductionActions = function buildProductionActions() { // $$ = undefined; // $@ = undefined; // - var vmode = !inject_default_value_action ? "skip" : self.options.defaultActionMode[0]; - var lmode = !inject_default_loc_action ? "skip" : self.options.defaultActionMode[1]; + let vmode = !inject_default_value_action ? 'skip' : self.options.defaultActionMode[0]; + let lmode = !inject_default_loc_action ? 'skip' : self.options.defaultActionMode[1]; // check if there's no user action specified. Insert default action if it isn't. // first determine the actual number of terms in the production: - var rhs = handle.handle.slice(0); - var real_rhs_length = rhs.length; + let rhs_reduced_length = rhs.length; + let real_rhs_length = rhs.length; // strip away EOF terms at the end of the rule, ditto for epsilon terms: - if (rhs.length) { - switch (rhs[rhs.length - 1]) { + while (rhs_reduced_length) { + switch (rhs[rhs_reduced_length - 1]) { case '$end': - rhs.length--; - break; + rhs_reduced_length--; + continue; case '': // %epsilon - rhs.length--; - break; + rhs_reduced_length--; + continue; } + break; } // then we can choose what to do, depending on the number of terms in the production. @@ -31640,18 +31655,18 @@ generator.buildProductionActions = function buildProductionActions() { // // Ditto for location tracking default actions... // - switch (rhs.length) { + switch (rhs_reduced_length) { case 0: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; <-- but that would cause nondeterministic behaviour, so // we fall back to the default here! - case "ast": - case "none": - default_action.push("this.$ = undefined;"); + case 'ast': + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31660,22 +31675,22 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // an empty production has no location as there are no terms parsed. // ergo: we produce a zero-width location which points at the tail // end of the previous content: // @$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);"); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31686,19 +31701,19 @@ generator.buildProductionActions = function buildProductionActions() { case 1: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; // // WARNING: be careful with the ACCEPT rule as that one's production has - // rhs.length === 1 **BUT** has real_rhs_length === 2 as we have discarded + // rhs_reduced_length === 1 **BUT** has real_rhs_length === 2 as we have discarded // the `$end` term at the end! // Here we need to account for that magick though! - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // As we're looking at a production which has one(1) useful term, we can simply // reference-copy that one intom a fresh array, instead of `slice()`-ing it out // of the vstack. @@ -31707,14 +31722,14 @@ generator.buildProductionActions = function buildProductionActions() { // WARNING/NOTE: as above, and ditto BTW for rule productions which end with // `EOF` as a last term: as we now construct an entire AST, we DO NOT include // those 'values' here! - default_action.push("this.$ = [yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "]];"); + default_action.push('this.$ = [yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ']];'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31723,23 +31738,23 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: // as we have a production length of 1 only, we can simply ref-copy @1: // @$ = @1; // // WARNING: same as above for the value copying: we may have discarded an `EOF` or `$end` term! - default_action.push("this._$ = yylstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this._$ = yylstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31750,29 +31765,29 @@ generator.buildProductionActions = function buildProductionActions() { default: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // - // WARNING: as with the situation further above where rhs.length === 1 after we + // WARNING: as with the situation further above where rhs_reduced_length === 1 after we // have got rid of a possible `EOF` or `$end` at the end of the production, // we again have to account for our trickery earlier and compensate the // action above: again we DO NOT include the value of the EOF/$end token in the // resulting array 'AST', hence our `slice()` end index may vary by one(1): - var end_offset = 1 - real_rhs_length + rhs.length; - default_action.push("this.$ = yyvstack.slice(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp" + /* CANNOT USE indexToJsExpr(rhs.length + 1, real_rhs_length, rule4msg) HERE! */ (end_offset === 0 ? "" : " + " + end_offset) + ");"); + let end_offset = 1 - real_rhs_length + rhs_reduced_length; + default_action.push('this.$ = yyvstack.slice(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp' + /* CANNOT USE indexToJsExpr(rhs_reduced_length + 1, real_rhs_length, rule4msg) HERE! */ (end_offset === 0 ? '' : ' + ' + end_offset) + ');'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31781,20 +31796,20 @@ generator.buildProductionActions = function buildProductionActions() { } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: - // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs.length - 1}, yysp); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp);"); + // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs_reduced_length - 1}, yysp); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31807,16 +31822,16 @@ generator.buildProductionActions = function buildProductionActions() { // comment/mark the default action chunk, if any, so we can simply observe // what is user code and what is generated by us in the final product: if (default_action.length > 0) { - var flags = [ - rhs.length, - self.actionsUseValueTracking ? "VT" : "-", - self.actionsUseValueAssignment ? "VA" : "-", - uses_$$ ? "VU" : "-", - uses_$$_before_assignment ? "VUbA" : "-", - self.actionsUseLocationTracking ? "LT" : "-", - self.actionsUseLocationAssignment ? "LA" : "-", - uses_$loc ? "LU" : "-", - uses_$loc_before_assignment ? "LUbA" : "-", + let flags = [ + rhs_reduced_length + '/' + real_rhs_length, + self.actionsUseValueTracking ? 'VT' : '-', + self.actionsUseValueAssignment ? 'VA' : '-', + uses_$$ ? 'VU' : '-', + uses_$$_before_assignment ? 'VUbA' : '-', + self.actionsUseLocationTracking ? 'LT' : '-', + self.actionsUseLocationAssignment ? 'LA' : '-', + uses_$loc ? 'LU' : '-', + uses_$loc_before_assignment ? 'LUbA' : '-' ].join(','); default_action.unshift(`// default action (generated by JISON mode ${self.options.defaultActionMode[0]}/${self.options.defaultActionMode[1]} :: ${flags}):`); @@ -31830,16 +31845,16 @@ generator.buildProductionActions = function buildProductionActions() { action = reindentCodeBlock(action, 4); - var actionHash = mkHashIndex(action); + let actionHash = mkHashIndex(action); // Delay running the postprocess (restore) process until we've done ALL macro expansions: //action = postprocessActionCode(action); - if (actionHash in actionGroups) { - actionGroups[actionHash].push(label); + if (actionHash in this.actionGroups) { + this.actionGroups[actionHash].push(label); } else { - actionGroups[actionHash] = [label]; - actionGroupValue[actionHash] = action; + this.actionGroups[actionHash] = [ label ]; + this.actionGroupValue[actionHash] = action; } } }; @@ -31859,7 +31874,7 @@ generator.trace = (new Function('', 'function no_op_trace() { }\nreturn no_op_tr //generator.trace.name = 'no_op_trace'; generator.warn = function warn() { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); Jison$1.print.call(null, args.join('')); }; @@ -31906,9 +31921,9 @@ generator.reportGrammarInformation = function reportGrammarInformation() { // LR specific mixin class later on, so that we can have another // implementation/report for LL and PEG type grammars. - var rows = 0, cols = 0; - var colmarks = {}; - var i, j, len; + let rows = 0, cols = 0; + let colmarks = {}; + let i, j, len; for (i = 0, len = this.table.length; i < len; i++) { rows++; @@ -31919,8 +31934,8 @@ generator.reportGrammarInformation = function reportGrammarInformation() { } } } - var defrows = 0; - var rowmarks = {}; + let defrows = 0; + let rowmarks = {}; for (j in this.defaultActions) { if (!rowmarks[j]) { rowmarks[j] = true; @@ -31928,8 +31943,8 @@ generator.reportGrammarInformation = function reportGrammarInformation() { } } - var ntc = 0; - for (var nt in this.nonterminals) { + let ntc = 0; + for (let nt in this.nonterminals) { ntc++; } @@ -31948,14 +31963,12 @@ generator.reportGrammarInformation = function reportGrammarInformation() { // --- START of debugTraceSrc chunk --- const debugTraceSrc = ` function debug_trace() { - "use strict"; - if (typeof Jison !== 'undefined' && Jison.print) { Jison.print.apply(null, arguments); } else if (typeof print !== 'undefined') { print.apply(null, arguments); } else if (typeof console !== 'undefined' && console.log) { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); args.unshift(''); // prevent \`%.\` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args console.log.apply(null, args); } @@ -31965,14 +31978,14 @@ function debug_trace() { // Generator debug mixin -var generatorDebug = { +const generatorDebug = { trace: (new Function('', debugTraceSrc + ` return debug_trace;`))(), beforeprocessGrammar: function () { this.trace('Processing grammar.'); }, afteraugmentGrammar: function () { - var trace = this.trace; + let trace = this.trace; trace('\nSymbols:\n'); each(this.symbols, function (sym, i) { trace(sym + '(' + i + ')'); @@ -31986,7 +31999,7 @@ var generatorDebug = { /* * Mixin for common behaviors of lookahead parsers */ -var lookaheadMixin = {}; +let lookaheadMixin = {}; lookaheadMixin.computeLookaheads = function computeLookaheads() { if (this.DEBUG) { @@ -32000,11 +32013,11 @@ lookaheadMixin.computeLookaheads = function computeLookaheads() { }; lookaheadMixin.displayFollowSets = function displayFollowSets() { - var self = this; - var symfollowdbg = {}; + let self = this; + let symfollowdbg = {}; this.productions.forEach(function Follow_prod_forEach_debugOut(production, k) { - var key = ['prod-', k, ': ', production.symbol, ' := ', production.handle.join(' ')].join(''); - var flw = '[' + self.nonterminals[production.symbol].follows.join('] [') + ']'; + let key = [ 'prod-', k, ': ', production.symbol, ' := ', production.handle.join(' ') ].join(''); + let flw = '[' + self.nonterminals[production.symbol].follows.join('] [') + ']'; if (!symfollowdbg[flw]) { symfollowdbg[flw] = {}; } @@ -32015,9 +32028,9 @@ lookaheadMixin.displayFollowSets = function displayFollowSets() { symfollowdbg[flw][key]++; } }); - for (var l in symfollowdbg) { - var lst = []; - for (var k in symfollowdbg[l]) { + for (let l in symfollowdbg) { + let lst = []; + for (let k in symfollowdbg[l]) { lst.push(k); } self.trace('Symbol/Follows:\n ', lst.join('\n '), ' -->\n ', l); @@ -32026,10 +32039,10 @@ lookaheadMixin.displayFollowSets = function displayFollowSets() { // calculate follow sets based on first and nullable lookaheadMixin.followSets = function followSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true; + let productions = this.productions; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { @@ -32038,23 +32051,23 @@ lookaheadMixin.followSets = function followSets() { productions.forEach(function Follow_prod_forEach(production, k) { // q is used in Simple LALR algorithm determine follows in context - var q; - var ctx = !!self.go_; + let q; + let ctx = !!self.go_; - for (var i = 0, t; (t = production.handle[i]); ++i) { + for (let i = 0, t; (t = production.handle[i]); ++i) { if (!nonterminals[t]) continue; // for Simple LALR algorithm, self.go_ checks if if (ctx) { q = self.go_(production.symbol, production.handle.slice(0, i)); } - var bool = (!ctx || q === self.nterms_[t]); - var set; + let bool = (!ctx || q === self.nterms_[t]); + let set; if (i === production.handle.length - 1 && bool) { set = nonterminals[production.symbol].follows; } else { - var part = production.handle.slice(i + 1); + let part = production.handle.slice(i + 1); set = self.first(part); if (self.nullable(part) && bool) { @@ -32062,8 +32075,8 @@ lookaheadMixin.followSets = function followSets() { set.push.apply(set, nonterminals[production.symbol].follows); } } - var follows = nonterminals[t].follows; - var oldcount = follows.length; + let follows = nonterminals[t].follows; + let oldcount = follows.length; follows = union(follows, set); if (oldcount !== follows.length) { cont = true; @@ -32085,8 +32098,8 @@ lookaheadMixin.first = function first(symbol) { return []; // RHS } else if (symbol instanceof Array) { - var firsts = []; - for (var i = 0, t; (t = symbol[i]); ++i) { + let firsts = []; + for (let i = 0, t; (t = symbol[i]); ++i) { if (!this.nonterminals[t]) { if (firsts.indexOf(t) === -1) { firsts.push(t); @@ -32094,41 +32107,39 @@ lookaheadMixin.first = function first(symbol) { } else { firsts = union(firsts, this.nonterminals[t].first); } - if (!this.nullable(t)) - break; + if (!this.nullable(t)) { break; } } return firsts; // terminal } else if (!this.nonterminals[symbol]) { - return [symbol]; + return [ symbol ]; // nonterminal - } else { - return this.nonterminals[symbol].first; } + return this.nonterminals[symbol].first; + }; // fixed-point calculation of FIRST sets lookaheadMixin.firstSets = function firstSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true, - symbol, firsts; + let productions = this.productions; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { cont = false; productions.forEach(function FirstSets_forEach(production, k) { - var firsts = self.first(production.handle); + let firsts = self.first(production.handle); if (firsts.length !== production.first.length) { production.first = firsts; cont = true; } }); - for (symbol in nonterminals) { - firsts = []; + for (let symbol in nonterminals) { + let firsts = []; nonterminals[symbol].productions.forEach(function FirstSets_forEachNonTerm(production) { firsts = union(firsts, production.first); }); @@ -32142,9 +32153,9 @@ lookaheadMixin.firstSets = function firstSets() { // fixed-point calculation of NULLABLE lookaheadMixin.nullableSets = function nullableSets() { - var nonterminals = this.nonterminals, - self = this, - cont = true; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { @@ -32153,7 +32164,9 @@ lookaheadMixin.nullableSets = function nullableSets() { // check if each production is nullable this.productions.forEach(function isEachProductionNullable(production, k) { if (!production.nullable) { - for (var i = 0, n = 0, t; (t = production.handle[i]); ++i) { + let i = 0; + let n = 0; + for (let t; (t = production.handle[i]); ++i) { if (self.nullable(t)) n++; } if (n === i) { // production is nullable if all tokens are nullable @@ -32163,9 +32176,9 @@ lookaheadMixin.nullableSets = function nullableSets() { }); // check if each symbol is nullable - for (var symbol in nonterminals) { + for (let symbol in nonterminals) { if (!this.nullable(symbol)) { - for (var i = 0, production; (production = nonterminals[symbol].productions.item(i)); i++) { + for (let i = 0, production; (production = nonterminals[symbol].productions.item(i)); i++) { if (production.nullable) { nonterminals[symbol].nullable = cont = true; } @@ -32182,7 +32195,7 @@ lookaheadMixin.nullable = function nullable(symbol) { return true; // RHS } else if (symbol instanceof Array) { - for (var i = 0, t; (t = symbol[i]); ++i) { + for (let i = 0, t; (t = symbol[i]); ++i) { if (!this.nullable(t)) { return false; } @@ -32192,14 +32205,14 @@ lookaheadMixin.nullable = function nullable(symbol) { } else if (!this.nonterminals[symbol]) { return false; // nonterminal - } else { - return this.nonterminals[symbol].nullable; } + return this.nonterminals[symbol].nullable; + }; // lookahead debug mixin -var lookaheadDebug = { +const lookaheadDebug = { beforenullableSets: function () { this.trace('Computing Nullable sets.'); }, @@ -32210,7 +32223,7 @@ var lookaheadDebug = { this.trace('Computing Follow sets.'); }, afterfollowSets: function () { - var trace = this.trace; + let trace = this.trace; trace('\nNonterminals:\n'); each(this.nonterminals, function (nt, t) { trace(nt.toString(), '\n'); @@ -32222,7 +32235,7 @@ var lookaheadDebug = { /* * Mixin for common LR parser behavior */ -var lrGeneratorMixin = {}; +let lrGeneratorMixin = {}; // LR state machine actions: @@ -32275,16 +32288,16 @@ lrGeneratorMixin.Item = typal.construct({ return e.id === this.id; }, handleToString: function () { - var handle = this.production.handle.slice(0); + let handle = this.production.handle.slice(0); handle[this.dotPosition] = '.' + (handle[this.dotPosition] || ''); return handle.join(' '); }, toString: function () { - var temp = this.production.handle.slice(0); + let temp = this.production.handle.slice(0); temp[this.dotPosition] = '.' + (temp[this.dotPosition] || ''); - var s = this.production.symbol + ' -> ' + temp.join(' '); - var padlen = Math.max(4, 40 - s.length); - var pad = new Array(padlen); + let s = this.production.symbol + ' -> ' + temp.join(' '); + let padlen = Math.max(4, 40 - s.length); + let pad = new Array(padlen); if (this.follows.length) { s += pad.join(' ') + '#lookaheads= [' + this.follows.join('] [') + ']'; pad = new Array(2); @@ -32297,7 +32310,7 @@ lrGeneratorMixin.Item = typal.construct({ } }); -lrGeneratorMixin.ItemSet = Set.prototype.construct({ +lrGeneratorMixin.ItemSet = Set$1.prototype.construct({ afterconstructor: function () { this.reductions = []; this.goes = {}; @@ -32305,13 +32318,13 @@ lrGeneratorMixin.ItemSet = Set.prototype.construct({ this.shifts = false; this.inadequate = false; this.hash_ = {}; - for (var i = this._items.length - 1; i >= 0; i--) { + for (let i = this._items.length - 1; i >= 0; i--) { this.hash_[this._items[i].id] = true; //i; } }, concat: function concat(set) { - var a = set._items || set; - for (var i = a.length - 1; i >= 0; i--) { + let a = set._items || set; + for (let i = a.length - 1; i >= 0; i--) { this.hash_[a[i].id] = true; } this._items.push.apply(this._items, a); @@ -32325,31 +32338,31 @@ lrGeneratorMixin.ItemSet = Set.prototype.construct({ return this.hash_[item.id]; }, valueOf: function toValue() { - var v = this._items.map(function (a) { return a.id; }).sort().join('|'); + let v = this._items.map(function (a) { return a.id; }).sort().join('|'); this.valueOf = function valueOf_inner() { return v; }; return v; } }); lrGeneratorMixin.closureOperation = function closureOperation(itemSet) { - var closureSet = new this.ItemSet(); - var self = this; + let closureSet = new this.ItemSet(); + let self = this; - var set = itemSet, - itemQueue, - syms = {}; + let set = itemSet; + let itemQueue; + let syms = {}; do { - itemQueue = new Set(); + itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function CO_set_forEach(item) { - var symbol = item.markedSymbol; + let symbol = item.markedSymbol; // if token is a non-terminal, recursively add closures if (symbol && self.nonterminals[symbol]) { if (!syms[symbol]) { self.nonterminals[symbol].productions.forEach(function CO_nt_forEach(production) { - var newItem = new self.Item(production, 0); + let newItem = new self.Item(production, 0); if (!closureSet.contains(newItem)) { itemQueue.push(newItem); } @@ -32374,8 +32387,8 @@ lrGeneratorMixin.closureOperation = function closureOperation(itemSet) { }; lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) { - var gotoSet = new this.ItemSet(), - self = this; + let gotoSet = new this.ItemSet(); + let self = this; itemSet.forEach(function goto_forEach(item, n) { if (item.markedSymbol === symbol) { @@ -32390,14 +32403,14 @@ lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) { * Create unique set of item sets */ lrGeneratorMixin.canonicalCollection = function canonicalCollection() { - var item1 = new this.Item(this.productions[0], 0, [this.EOF]); - var firstStateNoClosure = new this.ItemSet(item1), - firstState = this.closureOperation(firstStateNoClosure), - states = new Set(firstState), - marked = 0, - self = this, - itemSet, - markedSymbols; + let item1 = new this.Item(this.productions[0], 0, [ this.EOF ]); + let firstStateNoClosure = new this.ItemSet(item1); + let firstState = this.closureOperation(firstStateNoClosure); + let states = new Set$1(firstState); + let marked = 0; + let self = this; + let itemSet; + let markedSymbols; states.has = {}; states.has[firstStateNoClosure.valueOf()] = 0; @@ -32419,8 +32432,8 @@ lrGeneratorMixin.canonicalCollection = function canonicalCollection() { // Pushes a unique state into the queue. Some parsing algorithms may perform additional operations lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert(symbol, itemSet, states, stateNum) { - var g = this.gotoOperation(itemSet, symbol), - state = states.has[g.valueOf()]; + let g = this.gotoOperation(itemSet, symbol); + let state = states.has[g.valueOf()]; if (typeof state !== 'undefined') { itemSet.edges[symbol] = state; // store goto transition for table @@ -32435,36 +32448,36 @@ lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert( } itemSet.edges[symbol] = states.size(); // store goto transition for table states.push(g); - g.predecessors[symbol] = [stateNum]; + g.predecessors[symbol] = [ stateNum ]; } } }; lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { - var states = [], - nonterminals = this.nonterminals, - operators = this.operators, - conflictedStates = {}, // set of [state, token] tuples - self = this; + let states = []; + let nonterminals = this.nonterminals; + let operators = this.operators; + let conflictedStates = {}; // set of [state, token] tuples + let self = this; // for each item set itemSets.forEach(function parseTableItem(itemSet, k) { k = +k; - var state = states[k] = {}; - var action, stackSymbol; + let state = states[k] = {}; + let action, stackSymbol; // set shift and goto actions for (stackSymbol in itemSet.edges) { itemSet.forEach(function findShiftAndGotoActions(item, j) { // find shift and goto actions if (item.markedSymbol === stackSymbol) { - var gotoState = itemSet.edges[stackSymbol]; + let gotoState = itemSet.edges[stackSymbol]; assert$1(gotoState); if (nonterminals[stackSymbol]) { // store state to go to after a reduce state[self.symbols_[stackSymbol]] = gotoState; } else { - state[self.symbols_[stackSymbol]] = [SHIFT, gotoState]; + state[self.symbols_[stackSymbol]] = [ SHIFT, gotoState ]; } } }); @@ -32474,25 +32487,25 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { itemSet.forEach(function setAcceptAction(item, j) { if (item.markedSymbol === self.EOF) { // accept - state[self.symbols_[self.EOF]] = [ACCEPT]; + state[self.symbols_[self.EOF]] = [ ACCEPT ]; } }); - var allterms = self.lookAheads ? false : self.terminals; + let allterms = self.lookAheads ? false : self.terminals; // set reductions and resolve potential conflicts itemSet.reductions.forEach(function calcReduction(item, j) { // if parser uses lookahead, only enumerate those terminals - var terminals = allterms || self.lookAheads(itemSet, item); + let terminals = allterms || self.lookAheads(itemSet, item); terminals.forEach(function (stackSymbol) { action = state[self.symbols_[stackSymbol]]; - var op = operators[stackSymbol]; + let op = operators[stackSymbol]; // Reading a terminal and current position is at the end of a production, try to reduce if (action) { - var sol = resolveConflict(item.production, op, [REDUCE, item.production.id], action[0] instanceof Array ? action[0] : action); - self.resolutions.push([k, stackSymbol, sol]); + let sol = resolveConflict(item.production, op, [ REDUCE, item.production.id ], action[0] instanceof Array ? action[0] : action); + self.resolutions.push([ k, stackSymbol, sol ]); if (sol.bydefault) { self.conflicts++; @@ -32530,7 +32543,7 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { if (self.options.noDefaultResolve) { if (!(action[0] instanceof Array)) { - action = [action]; + action = [ action ]; } action.push(sol.r); } @@ -32538,7 +32551,7 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { action = sol.action; } } else { - action = [REDUCE, item.production.id]; + action = [ REDUCE, item.production.id ]; } if (action && action.length) { state[self.symbols_[stackSymbol]] = action; @@ -32589,25 +32602,25 @@ lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { // only this time we are careful about the TERROR symbol as a state carrying that one // is an explicitly encoded error recovery rule and should remain as-is. function findDefaults(states, hasErrorRecovery) { - var defaults = {}; + let defaults = {}; states.forEach(function (state, k) { - var act, sym, st; - var i = 0; - var gotos = {}; + let act; + let i = 0; + let gotos = {}; - for (sym in state) { + for (let sym in state) { assert$1({}.hasOwnProperty.call(state, sym)); // it this isn't true, the last part of this function won't work! // keep state rows where there's an error recovery state: if (sym === 2 /* TERROR */) { return; } - st = state[sym]; + let st = state[sym]; if (typeof st !== 'number') { if (st[0] !== REDUCE) { // not a reduce action: forget about this row! return; } - var go = st[1]; + let go = st[1]; if (!gotos[go]) { gotos[go] = true; i++; @@ -32635,8 +32648,8 @@ function findDefaults(states, hasErrorRecovery) { // ... hence we only nuke these table entries (as that makes for a smaller table --> smaller parser file) // when there's no error recovery code included in the generated parser: if (!hasErrorRecovery) { - for (sym in state) { - st = state[sym]; + for (let sym in state) { + let st = state[sym]; if (typeof st !== 'number') { delete state[sym]; } @@ -32651,9 +32664,7 @@ function findDefaults(states, hasErrorRecovery) { // Remove all NONASSOC state transitions from the generated table now that we don't need them any longer function cleanupTable(table) { table.forEach(function (state, k) { - var symbol; - - for (symbol in state) { + for (let symbol in state) { if (state[symbol] === NONASSOC) { delete state[symbol]; } @@ -32663,16 +32674,16 @@ function cleanupTable(table) { // resolves shift-reduce and reduce-reduce conflicts function resolveConflict(production, op, reduce, shift) { - var sln = { - production: production, - operator: op, - r: reduce, - s: shift, - - msg: null, - action: null, - bydefault: false - }; + let sln = { + production: production, + operator: op, + r: reduce, + s: shift, + + msg: null, + action: null, + bydefault: false + }; if (shift[0] === REDUCE) { sln.msg = 'Resolved R/R conflict: use first production declared in grammar.'; @@ -32710,7 +32721,7 @@ function resolveConflict(production, op, reduce, shift) { /* * Mixin for common LR/LL/*any* parser behavior */ -var generatorMixin = {}; +let generatorMixin = {}; // internal helper function: generatorMixin.__prepareOptions = function parser___prepare_Options(opt) { @@ -32724,7 +32735,7 @@ generatorMixin.__prepareOptions = function parser___prepare_Options(opt) { // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*?[a-zA-Z0-9_$]$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "parser" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "parser" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else if (opt.warn_cb) { @@ -32740,7 +32751,7 @@ generatorMixin.__prepareOptions = function parser___prepare_Options(opt) { }; generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComment() { - var out = ` + let out = ` /* parser generated by jison ${version$2} */ /* @@ -32904,9 +32915,9 @@ generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComm * Produces a new errorInfo 'hash object' which can be passed into \`parseError()\`. * See it's use in this parser kernel in many places; example usage: * - * var infoObj = parser.constructParseErrorInfo('fail!', null, + * let infoObj = parser.constructParseErrorInfo('fail!', null, * parser.collect_expected_token_set(state), true); - * var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); + * let retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); * * originalParseError: function(str, hash, ExceptionClass), * The basic \`parseError\` handler provided by JISON. @@ -33108,212 +33119,7 @@ generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComm * flex: boolean * optional: \`true\` ==> flex-like lexing behaviour where the rules are tested * exhaustively to find the longest match. - * backtrack_lexer: boolean (⅏ 센 ⅊ ⁖ ⁘ ⁙ ⁚ ⁛ ⁜ ⁝ ⁞ † ‡ - a⯈b - ∀ ∁ ∂ ∃ ∄ ∅ ∆ ∇ ∈ ∉ ∊ ∋ ∌ ∍ ∎ ∏ -U+221x ∐ ∑ − ∓ ∔ ∕ ∖ ∗ ∘ ∙ √ ∛ ∜ ∝ ∞ ∟ -U+222x ∠ ∡ ∢ ∣ ∤ ∥ ∦ ∧ ∨ ∩ ∪ ∫ ∬ ∭ ∮ ∯ -U+223x ∰ ∱ ∲ ∳ ∴ ∵ ∶ ∷ ∸ ∹ ∺ ∻ ∼ ∽ ∾ ∿ -U+224x ≀ ≁ ≂ ≃ ≄ ≅ ≆ ≇ ≈ ≉ ≊ ≋ ≌ ≍ ≎ ≏ -U+225x ≐ ≑ ≒ ≓ ≔ ≕ ≖ ≗ ≘ ≙ ≚ ≛ ≜ ≝ ≞ ≟ -U+226x ≠ ≡ ≢ ≣ ≤ ≥ ≦ ≧ ≨ ≩ ≪ ≫ ≬ ≭ ≮ ≯ -U+227x ≰ ≱ ≲ ≳ ≴ ≵ ≶ ≷ ≸ ≹ ≺ ≻ ≼ ≽ ≾ ≿ -U+228x ⊀ ⊁ ⊂ ⊃ ⊄ ⊅ ⊆ ⊇ ⊈ ⊉ ⊊ ⊋ ⊌ ⊍ ⊎ ⊏ -U+229x ⊐ ⊑ ⊒ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊜ ⊝ ⊞ ⊟ -U+22Ax ⊠ ⊡ ⊢ ⊣ ⊤ ⊥ ⊦ ⊧ ⊨ ⊩ ⊪ ⊫ ⊬ ⊭ ⊮ ⊯ -U+22Bx ⊰ ⊱ ⊲ ⊳ ⊴ ⊵ ⊶ ⊷ ⊸ ⊹ ⊺ ⊻ ⊼ ⊽ ⊾ ⊿ -U+22Cx ⋀ ⋁ ⋂ ⋃ ⋄ ⋅ ⋆ ⋇ ⋈ ⋉ ⋊ ⋋ ⋌ ⋍ ⋎ ⋏ -U+22Dx ⋐ ⋑ ⋒ ⋓ ⋔ ⋕ ⋖ ⋗ ⋘ ⋙ ⋚ ⋛ ⋜ ⋝ ⋞ ⋟ -U+22Ex ⋠ ⋡ ⋢ ⋣ ⋤ ⋥ ⋦ ⋧ ⋨ ⋩ ⋪ ⋫ ⋬ ⋭ ⋮ ⋯ -U+22Fx ⋰ ⋱ ⋲ ⋳ ⋴ ⋵ ⋶ ⋷ ⋸ ⋹ ⋺ ⋻ ⋼ ⋽ ⋾ ⋿) -U+230x ⌀ ⌁ ⌂ ⌃ ⌄ ⌅ ⌆ ⌇ ⌈ ⌉ ⌊ ⌋ ⌌ ⌍ ⌎ ⌏ -U+231x ⌐ ⌑ ⌒ ⌓ ⌔ ⌕ ⌖ ⌗ ⌘ ⌙ ⌚ ⌛ ⌜ ⌝ ⌞ ⌟ -U+232x ⌠ ⌡ ⌢ ⌣ ⌤ ⌥ ⌦ ⌧ ⌨ 〈 〉 ⌫ ⌬ ⌭ ⌮ ⌯ -U+233x ⌰ ⌱ ⌲ ⌳ ⌴ ⌵ ⌶ ⌷ ⌸ ⌹ ⌺ ⌻ ⌼ ⌽ ⌾ ⌿ -U+234x ⍀ ⍁ ⍂ ⍃ ⍄ ⍅ ⍆ ⍇ ⍈ ⍉ ⍊ ⍋ ⍌ ⍍ ⍎ ⍏ -U+235x ⍐ ⍑ ⍒ ⍓ ⍔ ⍕ ⍖ ⍗ ⍘ ⍙ ⍚ ⍛ ⍜ ⍝ ⍞ ⍟ -U+236x ⍠ ⍡ ⍢ ⍣ ⍤ ⍥ ⍦ ⍧ ⍨ ⍩ ⍪ ⍫ ⍬ ⍭ ⍮ ⍯ -U+237x ⍰ ⍱ ⍲ ⍳ ⍴ ⍵ ⍶ ⍷ ⍸ ⍹ ⍺ ⍻ ⍼ ⍽ ⍾ ⍿ -U+238x ⎀ ⎁ ⎂ ⎃ ⎄ ⎅ ⎆ ⎇ ⎈ ⎉ ⎊ ⎋ ⎌ ⎍ ⎎ ⎏ -U+239x ⎐ ⎑ ⎒ ⎓ ⎔ ⎕ ⎖ ⎗ ⎘ ⎙ ⎚ ⎛ ⎜ ⎝ ⎞ ⎟ -U+23Ax ⎠ ⎡ ⎢ ⎣ ⎤ ⎥ ⎦ ⎧ ⎨ ⎩ ⎪ ⎫ ⎬ ⎭ ⎮ ⎯ -U+23Bx ⎰ ⎱ ⎲ ⎳ ⎴ ⎵ ⎶ ⎷ ⎸ ⎹ ⎺ ⎻ ⎼ ⎽ ⎾ ⎿ -U+23Cx ⏀ ⏁ ⏂ ⏃ ⏄ ⏅ ⏆ ⏇ ⏈ ⏉ ⏊ ⏋ ⏌ ⏍ ⏎ ⏏ -U+23Dx ⏐ ⏑ ⏒ ⏓ ⏔ ⏕ ⏖ ⏗ ⏘ ⏙ ⏚ ⏛ ⏜ ⏝ ⏞ ⏟ -U+23Ex ⏠ ⏡ ⏢ ⏣ ⏤ ⏥ ⏦ ⏧ ⏨ ⏩ ⏪ ⏫ ⏬ ⏭ ⏮ ⏯ -U+23Fx ⏰ ⏱ ⏲ ⏳ ⏴ ⏵ ⏶ ⏷ ⏸ ⏹ ⏺ ⏻ ⏼ ⏽ ⏾ ⏿ - -U+260x ☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☎ ☏ -U+261x ☐ ☑ ☒ ☓ ☔ ☕ ☖ ☗ ☘ ☙ ☚ ☛ ☜ ☝ ☞ ☟ -U+262x ☠ ☡ ☢ ☣ ☤ ☥ ☦ ☧ ☨ ☩ ☪ ☫ ☬ ☭ ☮ ☯ -U+263x ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷ ☸ ☹ ☺ ☻ ☼ ☽ ☾ ☿ -U+264x ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇ ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ -U+265x ♐ ♑ ♒ ♓ ♔ ♕ ♖ ♗ ♘ ♙ ♚ ♛ ♜ ♝ ♞ ♟ -U+266x ♠ ♡ ♢ ♣ ♤ ♥ ♦ ♧ ♨ ♩ ♪ ♫ ♬ ♭ ♮ ♯ -U+267x ♰ ♱ ♲ ♳ ♴ ♵ ♶ ♷ ♸ ♹ ♺ ♻ ♼ ♽ ♾ ♿ -U+268x ⚀ ⚁ ⚂ ⚃ ⚄ ⚅ ⚆ ⚇ ⚈ ⚉ ⚊ ⚋ ⚌ ⚍ ⚎ ⚏ -U+269x ⚐ ⚑ ⚒ ⚓ ⚔ ⚕ ⚖ ⚗ ⚘ ⚙ ⚚ ⚛ ⚜ ⚝ ⚞ ⚟ -U+26Ax ⚠ ⚡ ⚢ ⚣ ⚤ ⚥ ⚦ ⚧ ⚨ ⚩ ⚪ ⚫ ⚬ ⚭ ⚮ ⚯ -U+26Bx ⚰ ⚱ ⚲ ⚳ ⚴ ⚵ ⚶ ⚷ ⚸ ⚹ ⚺ ⚻ ⚼ ⚽ ⚾ ⚿ -U+26Cx ⛀ ⛁ ⛂ ⛃ ⛄ ⛅ ⛆ ⛇ ⛈ ⛉ ⛊ ⛋ ⛌ ⛍ ⛎ ⛏ -U+26Dx ⛐ ⛑ ⛒ ⛓ ⛔ ⛕ ⛖ ⛗ ⛘ ⛙ ⛚ ⛛ ⛜ ⛝ ⛞ ⛟ -U+26Ex ⛠ ⛡ ⛢ ⛣ ⛤ ⛥ ⛦ ⛧ ⛨ ⛩ ⛪ ⛫ ⛬ ⛭ ⛮ ⛯ -U+26Fx ⛰ ⛱ ⛲ ⛳ ⛴ ⛵ ⛶ ⛷ ⛸ ⛹ ⛺ ⛻ ⛼ ⛽ ⛾ ⛿ - - ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ☛ ☞ ✌ ✍ ✎ ✏ -✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -✠ ✡ ✢ ✣ ✤ ✥ ✦ ✧ ★ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ● ❍ ■ ❏ -☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ❐ ❑ ❒ ▲ ▼ ◆ ❖ -◗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ - -U+270x ✀ ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ✊ ✋ ✌ ✍ ✎ ✏ -U+271x ✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -U+272x ✠ ✡ ✢ ✣ a✤b a✥b a✦b a✧b ✨ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -U+273x ✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -U+274x ❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ❌ ❍ ❎ ❏ -U+275x ❐ ❑ ❒ ❓ ❔ ❕ ❖ ❗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ ❟ -U+276x ❠ ❡ ❢ ❣ ❤ ❥ ❦ ❧ ❨ ❩ ❪ ❫ ❬ ❭ ❮ a❯b -U+277x ❰ ❱ ❲ ❳ ❴ ❵ ❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ ❾ ❿ -U+278x ➀ ➁ ➂ ➃ ➄ ➅ ➆ ➇ ➈ ➉ ➊ ➋ ➌ ➍ ➎ ➏ -U+279x ➐ ➑ ➒ ➓ ➔ ➕ ➖ ➗ ➘ ➙ ➚ ➛ ➜ ➝ ➞ ➟ -U+27Ax ➠ ➡ ➢ ➣ ➤ ➥ ➦ ➧ a➨b ➩ ➪ ➫ ➬ ➭ ➮ ➯ -U+27Bx ➰ a➱b ➲ ➳ ➴ ➵ ➶ ➷ ➸ ➹ ➺ ➻ ➼ ➽ ➾ ➿ - -U+2580 ▀ Upper half block -U+2581 ▁ Lower one eighth block -U+2582 ▂ Lower one quarter block -U+2583 ▃ Lower three eighths block -U+2584 ▄ Lower half block -U+2585 ▅ Lower five eighths block -U+2586 ▆ Lower three quarters block -U+2587 ▇ Lower seven eighths block -U+2588 █ Full block -U+2589 ▉ Left seven eighths block -U+258A ▊ Left three quarters block -U+258B ▋ Left five eighths block -U+258C ▌ Left half block -U+258D ▍ Left three eighths block -U+258E ▎ Left one quarter block -U+258F ▏ Left one eighth block -U+2590 ▐ Right half block -U+2591 ░ Light shade -U+2592 ▒ Medium shade -U+2593 ▓ Dark shade -U+2594 ▔ Upper one eighth block -U+2595 ▕ Right one eighth block -U+2596 ▖ Quadrant lower left -U+2597 ▗ Quadrant lower right -U+2598 ▘ Quadrant upper left -U+2599 ▙ Quadrant upper left and lower left and lower right -U+259A ▚ Quadrant upper left and lower right -U+259B ▛ Quadrant upper left and upper right and lower left -U+259C ▜ Quadrant upper left and upper right and lower right -U+259D ▝ Quadrant upper right -U+259E ▞ Quadrant upper right and lower left -U+259F ▟ Quadrant upper right and lower left and lower right -Geometric Shapes -Main articles: Geometric Shapes (Unicode block) and Geometric Shapes Extended (Unicode block) -[hide]Code Glyph Description -U+25A0 ■ Black square -U+25A1 □ White square -U+25A2 ▢ White square with rounded corners -U+25A3 ▣ White square containing small black square -U+25A4 ▤ Square with horizontal fill -U+25A5 ▥ Square with vertical fill -U+25A6 ▦ Square with orthogonal crosshatch fill -U+25A7 ▧ Square with upper left to lower right fill -U+25A8 ▨ Square with upper right to lower left fill -U+25A9 ▩ Square with diagonal crosshatch fill -U+25AA ▪ Black small square -U+25AB ▫ White small square -U+25AC ▬ Black rectangle -U+25AD ▭ White rectangle -U+25AE ▮ Black vertical rectangle -U+25AF ▯ White vertical rectangle -U+25B0 ▰ Black parallelogram -U+25B1 ▱ White parallelogram -U+25B2 ▲ Black up-pointing triangle -U+25B3 △ White up-pointing triangle -U+25B4 ▴ Black up-pointing small triangle -U+25B5 ▵ White up-pointing small triangle -U+25B6 ▶ Black right-pointing triangle -U+25B7 ▷ White right-pointing triangle -U+25B8 ▸ Black right-pointing small triangle -U+25B9 ▹ White right-pointing small triangle -U+25BA ► Black right-pointing pointer -U+25BB ▻ White right-pointing pointer -U+25BC ▼ Black down-pointing triangle -U+25BD ▽ White down-pointing triangle -U+25BE ▾ Black down-pointing small triangle -U+25BF ▿ White down-pointing small triangle -U+25C0 ◀ Black left-pointing triangle -U+25C1 ◁ White left-pointing triangle -U+25C2 ◂ Black left-pointing small triangle -U+25C3 ◃ White left-pointing small triangle -U+25C4 ◄ Black left-pointing pointer -U+25C5 ◅ White left-pointing pointer -U+25C6 ◆ Black diamond -U+25C7 ◇ White diamond -U+25C8 ◈ White diamond containing small black diamond -U+25C9 ◉ Fisheye -U+25CA ◊ Lozenge -U+25CB ○ White circle -U+25CC ◌ Dotted circle -U+25CD ◍ Circle with vertical fill -U+25CE ◎ Bullseye -U+25CF ● Black circle -U+25D0 ◐ Circle with left half black -U+25D1 ◑ Circle with right half black -U+25D2 ◒ Circle with lower half black -U+25D3 ◓ Circle with upper half black -U+25D4 ◔ Circle with upper right quadrant black -U+25D5 ◕ Circle with all but upper left quadrant black -U+25D6 ◖ Left half circle black -U+25D7 ◗ Right half black circle -U+25D8 ◘ Inverse bullet -U+25D9 ◙ Inverse white circle -U+25DA ◚ Upper half inverse white circle -U+25DB ◛ Lower half inverse white circle -U+25DC ◜ Upper left quadrant circular arc -U+25DD ◝ Upper right quadrant circular arc -U+25DE ◞ Lower right quadrant circular arc -U+25DF ◟ Lower left quadrant circular arc -U+25E0 ◠ Upper half circle -U+25E1 ◡ Lower half circle -U+25E2 ◢ Black lower right triangle -U+25E3 ◣ Black lower left triangle -U+25E4 ◤ Black upper left triangle -U+25E5 ◥ Black upper right triangle -U+25E6 ◦ White bullet -U+25E7 ◧ Square with left half black -U+25E8 ◨ Square with right half black -U+25E9 ◩ Square with upper left diagonal half black -U+25EA ◪ Square with lower right diagonal half black -U+25EB ◫ White square with vertical bisecting line -U+25EC ◬ White up-pointing triangle with dot -U+25ED ◭ Up-pointing triangle with left half black -U+25EE ◮ Up-pointing triangle with right half black -U+25EF ◯ Large circle -U+25F0 ◰ White square with upper left quadrant -U+25F1 ◱ White square with lower left quadrant -U+25F2 ◲ White square with lower right quadrant -U+25F3 ◳ White square with upper right quadrant -U+25F4 ◴ White circle with upper left quadrant -U+25F5 ◵ White circle with lower left quadrant -U+25F6 ◶ White circle with lower right quadrant -U+25F7 ◷ White circle with upper right quadrant -U+25F8 ◸ Upper left triangle -U+25F9 ◹ Upper right triangle -U+25FA ◺ Lower-left triangle -U+25FB ◻ White medium square -U+25FC ◼ Black medium square -U+25FD ◽ White medium small square -U+25FE ◾ Black medium small square -U+25FF ◿ Lower right triangle - - + * backtrack_lexer: boolean * optional: \`true\` ==> lexer regexes are tested in order and for invoked; * the lexer terminates the scan when a token is returned by the action code. * xregexp: boolean @@ -33330,7 +33136,7 @@ U+25FF ◿ Lower right triangle generatorMixin.generate = function parser_generate(opt) { opt = this.__prepareOptions(opt); - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -33356,19 +33162,19 @@ generatorMixin.generate = function parser_generate(opt) { generatorMixin.generateAMDModule = function generateAMDModule(opt) { opt = this.__prepareOptions(opt); - var module = this.generateModule_(); - var out = [ + let module = this.generateModule_(); + let out = [ this.generateGenericHeaderComment(), '', 'define(function (require) {', module.initCode, module.commonCode, '', - 'var parser = ' + module.moduleCode, + 'let parser = ' + module.moduleCode, module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(lexSrc); out.push('parser.lexer = lexer;'); @@ -33376,7 +33182,7 @@ generatorMixin.generateAMDModule = function generateAMDModule(opt) { out.push('', module.moduleInclude, '', 'return parser;'); out.push('});'); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; }; @@ -33384,35 +33190,35 @@ generatorMixin.generateAMDModule = function generateAMDModule(opt) { lrGeneratorMixin.generateESModule = function generateESModule(opt) { opt = this.__prepareOptions(opt); - var module = this.generateModule_(); - var out = [ + let module = this.generateModule_(); + let out = [ this.generateGenericHeaderComment(), '', module.initCode, module.commonCode, '', - 'var parser = ' + module.moduleCode, - module.modulePostlude, + 'let parser = ' + module.moduleCode, + module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(this.lexer.generateModule()); out.push('parser.lexer = lexer;'); } out.push('', module.moduleInclude, ''); - var exportMain = ''; - var invokeMain = ''; + let exportMain = ''; + let invokeMain = ''; if (!opt.noMain) { - var moduleNameAsCode = String(opt.moduleMain || commonJsMain); - var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); + let moduleNameAsCode = String(opt.moduleMain || commonJsMain); + let moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); out.push(rmCommonWS$5` ${moduleImportsAsCode} - var yymain = ${moduleNameAsCode.trim()}; + let yymain = ${moduleNameAsCode.trim()}; function yyExecMain() { yymain(process.argv.slice(1)); @@ -33448,7 +33254,7 @@ lrGeneratorMixin.generateESModule = function generateESModule(opt) { }; `); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; }; @@ -33456,11 +33262,11 @@ lrGeneratorMixin.generateESModule = function generateESModule(opt) { generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { opt = this.__prepareOptions(opt); - var moduleName = opt.moduleName; - var main = ''; + let moduleName = opt.moduleName; + let main = ''; if (!opt.noMain) { - var moduleNameAsCode = String(opt.moduleMain || commonJsMain); - var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); + let moduleNameAsCode = String(opt.moduleMain || commonJsMain); + let moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); main = rmCommonWS$5` @@ -33475,7 +33281,7 @@ generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { } `; } - var out = this.generateModule(opt) + + let out = this.generateModule(opt) + rmCommonWS$5` @@ -33496,17 +33302,16 @@ generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { generatorMixin.generateModule = function generateModule(opt) { opt = this.__prepareOptions(opt); - var moduleName = opt.moduleName; - var out = this.generateGenericHeaderComment(); + let moduleName = opt.moduleName; + let out = this.generateGenericHeaderComment(); - var self = this; + let self = this; function _generateNamespace(namespaces, previousNamespace, callback) { - var subModuleName = namespaces.shift(); + let subModuleName = namespaces.shift(); if (subModuleName != null) { - var moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; + let moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; if (namespaces.length > 0) { - return 'var ' + subModuleName + ';\n' - + '(function (' + subModuleName + ') {\n' + return '(function (' + subModuleName + ') {\n' + _generateNamespace(namespaces, subModuleName, callback) + '\n})(' + subModuleName + (previousNamespace == null ? '' : ' = ' + moduleName) + ' || (' + moduleName + ' = {}));\n'; } @@ -33515,14 +33320,14 @@ generatorMixin.generateModule = function generateModule(opt) { return ''; } - var sourceCodeDef = self.generateModuleExpr(); + let sourceCodeDef = self.generateModuleExpr(); out += ` ${sourceCodeDef.init} `; out += _generateNamespace(moduleName.split('.'), null, function _generateNamespace_cb(moduleName) { - var name = (moduleName.match(/\./) ? moduleName : 'var ' + moduleName); + let name = (moduleName.match(/\./) ? moduleName : 'let ' + moduleName); return ` ${name} = ${sourceCodeDef.src} `; @@ -33534,24 +33339,23 @@ generatorMixin.generateModule = function generateModule(opt) { generatorMixin.generateModuleExpr = function generateModuleExpr() { - var out; - var opt = this.__prepareOptions(); - var module = this.generateModule_(); + let opt = this.__prepareOptions(); + let module = this.generateModule_(); - out = [ + let out = [ '(function () {', module.commonCode, '', - 'var parser = ' + module.moduleCode, - module.modulePostlude, + 'let parser = ' + module.moduleCode, + module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(lexSrc); out.push('parser.lexer = lexer;'); } - out = out.concat(['', + out = out.concat([ '', module.moduleInclude, '', 'function Parser() {', @@ -33564,7 +33368,7 @@ generatorMixin.generateModuleExpr = function generateModuleExpr() { '})();' ]); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return { @@ -33574,7 +33378,7 @@ generatorMixin.generateModuleExpr = function generateModuleExpr() { }; function removeUnusedKernelFeatures(parseFn, info) { - var actionFn = info.performAction; + let actionFn = info.performAction; if (info.actionsAreAllDefault) { // in this case, there's no need to call the parseAction function at all: @@ -33616,7 +33420,7 @@ function removeUnusedKernelFeatures(parseFn, info) { // if (typeof lexer.yyleng === 'undefined') { // lexer.yyleng = 0; // } - // var yyleng; + // let yyleng; // ... parseFn = parseFn @@ -33635,7 +33439,7 @@ function removeUnusedKernelFeatures(parseFn, info) { // remove: // - // var yylineno; + // let yylineno; // ... parseFn = parseFn @@ -33690,7 +33494,7 @@ function removeUnusedKernelFeatures(parseFn, info) { // remove: // - // var yyloc = lexer.yylloc; + // let yyloc = lexer.yylloc; // lstack[sp] = yyloc; // ... // lstack[sp] = copy_yylloc(lexer.yylloc); @@ -33730,11 +33534,11 @@ function removeUnusedKernelFeatures(parseFn, info) { // } // // and - // + // // if (sp >= 0 && typeof vstack[sp] !== 'undefined') { // retval = vstack[sp]; // } - // + // // but keep the yyval declaration as either location tracking MAY // still be employed by the grammar OR the grammar uses advanced // code which uses `yyval` as a run-time store which carries data @@ -33780,13 +33584,13 @@ function removeUnusedKernelFeatures(parseFn, info) { if (info.actionsAreAllDefault) { // remove // - // var yyval = { + // let yyval = { // $: true, // _$: undefined, // yy: sharedState_yy // }; parseFn = parseFn - .replace(/\s+var yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); + .replace(/\s+let yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); } } @@ -33801,10 +33605,14 @@ function removeUnusedKernelFeatures(parseFn, info) { // remove: // - // var yydebug = false; + // let yydebug = false; // ... and delete yydebug function definition ... // ... // if (yydebug) yydebug(...); + // ... + // if (yydebug) { + // yydebug(...); + // } // // and // @@ -33815,9 +33623,10 @@ function removeUnusedKernelFeatures(parseFn, info) { parseFn = parseFn - .replace(/\s+var yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') - // strip multi-line `if (debug) yydebug(..., {...});` statements + .replace(/\s+let yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') + // strip multi-line `if (debug) { yydebug(..., {...}); }` statements // also strip simple yet possibly multi-line `if (debug) yydebug('...');` statements + .replace(/\n\s+if\s+\(yydebug\)\s+\{[\r\n]+\s+yydebug\([^]+?}\);[\s\r\n]+}\s*/g, '\n\n\n\n\n\n\n\n\n') .replace(/\n\s+if\s+\(yydebug\)\s+yydebug\([^]+?['}]\);[^\r\n]*?/g, '\n\n\n\n\n\n\n\n\n') // strip single-line `yydebug(...);` statements .replace(/^.*?\byydebug\b[^;]+?\);[^\r\n]*?$/gm, '') @@ -33902,8 +33711,8 @@ function removeUnusedKernelFeatures(parseFn, info) { */ parseFn = parseFn .replace(/\s+try \{([\s\r\n]+this\.__reentrant_call_depth[\s\S]+?)\} catch \(ex\) \{[\s\S]+?\} finally \{([^]+?)\}\s+\/\/\s+\/finally/, function replace_noTryCatch(m, p1, p2) { - p1 = p1.replace(/^ /mg, ' '); - p2 = p2.replace(/^ /mg, ' '); + p1 = p1.replace(/^ {8}/mg, ' '); + p2 = p2.replace(/^ {8}/mg, ' '); return '\n' + p1 + '\n // ... AND FINALLY ...\n' + p2; }) .replace(/^[^\n]+\b__reentrant_call_depth\b[^\n]+$/gm, '\n'); @@ -33961,29 +33770,29 @@ function removeUnusedKernelFeatures(parseFn, info) { // // https://github.com/zaach/jison/pull/332 function expandParseArguments(parseFn, self) { - var arglist = self.parseParams; + let arglist = self.parseParams; if (!arglist || arglist.length === 0) { parseFn = parseFn.replace(/, parseParams\b/g, ''); parseFn = parseFn.replace(/\bparseParams\b/g, ''); - parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers:\s+parseParamsAsMembers\b/g, ''); + parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers\b/g, ''); } else { parseFn = parseFn.replace(/, parseParams\b/g, ', ' + arglist.join(', ')); parseFn = parseFn.replace(/\bparseParams\b/g, arglist.join(', ')); - parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers:\s+parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { - var s = ','; + parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { + let s = ','; // determine longest name of the bunch (for formatting the generated code) - var max_k_len = 0; - for (var i = 0, len = arglist.length; i < len; i++) { - var k = arglist[i]; + let max_k_len = 0; + for (let i = 0, len = arglist.length; i < len; i++) { + let k = arglist[i]; max_k_len = Math.max(max_k_len, k.length); } - var wsi2 = (new Array(max_k_len + 1)).join(' '); + let 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 i = 0, len = arglist.length; i < len; i++) { - var k = arglist[i]; + for (let i = 0, len = arglist.length; i < len; i++) { + let k = arglist[i]; s += '\n' + ws + k + ': ' + k + (i < len - 1 ? ',' + wsi2.substr(0, max_k_len - k.length - 1) : wsi2.substr(0, max_k_len - k.length)) + ' // parseParams::' + k; } return s; @@ -34018,17 +33827,17 @@ function pickOneOfTwoCodeAlternatives(parseFn, pick_A_not_B, A_start_marker, B_s } function addOrRemoveTokenStack(fn, wantTokenStack) { - var parseFn = fn; + let parseFn = fn; // We don't use the Esprima+Escodegen toolchain as those loose the code comments easily; // instead we just chop the code using labels as sentinels for our chopping-it-up regexes: // // if (wantTokenStack) { // try { - // var ast = esprima.parse(parseFn); - // var stackAst = esprima.parse(String(tokenStackLex)).body[0]; + // let ast = esprima.parse(parseFn); + // let stackAst = esprima.parse(String(tokenStackLex)).body[0]; // stackAst.id.name = 'lex'; // - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); // // labeled[0].body = stackAst; // @@ -34038,7 +33847,7 @@ function addOrRemoveTokenStack(fn, wantTokenStack) { // } // } else { // // remove the line: - // // var tstack = []; // token stack + // // let tstack = []; // token stack // parseFn = parseFn.replace(/tstack = .*$/m, ''); // return parseFn; // } @@ -34047,23 +33856,23 @@ function addOrRemoveTokenStack(fn, wantTokenStack) { if (wantTokenStack) { // And rename the `tokenStackLex` function to become the new `lex`: return parseFn.replace(/\btokenStackLex\b/g, 'lex'); - } else { - // Also nuke the support declaration statement: - // var tstack = []; - return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); } + // Also nuke the support declaration statement: + // let tstack = []; + return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); + } // returns parse function with/without error recovery code function pickErrorHandlingChunk(fn, hasErrorRecovery) { - var parseFn = fn; + let parseFn = fn; // We don't use the Esprima+Escodegen toolchain as those loose the code comments easily; // instead we just chop the code using labels as sentinels for our chopping-it-up regexes: // try { - // var ast = esprima.parse(parseFn); + // let ast = esprima.parse(parseFn); - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("' + + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("' + // (!hasErrorRecovery ? '_handle_error_with_recovery' : '_handle_error_no_recovery') + // '"))', ast); // Jison.print('labeled: ', labeled); @@ -34079,7 +33888,7 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // and some post-coital touch-ups: if (!hasErrorRecovery) { // Also nuke the support declaration statement: - // var recovering = 0; + // let recovering = 0; // and the recovery support statements: // if (recovering > 0) { // recovering--; @@ -34088,7 +33897,7 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // , recovering: recovering // ASSERT(recovering === 0); parseFn = parseFn - .replace(/^\s*var recovering.*$/gm, '') + .replace(/^\s*let recovering.*$/gm, '') .replace(/, recovering: recovering/g, '') .replace(/^.*?recovering =.*$/gm, '') .replace(/^\s+recovering[,]?\s*$/gm, '') @@ -34100,11 +33909,11 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // ... KILL this chunk ... // } .replace(/\s+if[^a-z]+preErrorSymbol.*?\{\s*\/\/[^\n]+([\s\S]+?)\} else \{[\s\S]+?\}\n\s+\}\n/g, '\n$1\n\n\n\n') - .replace(/^\s+(?:var )?preErrorSymbol = .*$/gm, '') + .replace(/^\s+(?:let )?preErrorSymbol = .*$/gm, '') .replace(/^.*?\bpreErrorSymbol =.*$/gm, '') // And nuke the support declaration statement: - // var lastEofErrorStateDepth = 0; - .replace(/^\s*var lastEofErrorStateDepth.*$/gm, ''); + // let lastEofErrorStateDepth = 0; + .replace(/^\s*let lastEofErrorStateDepth.*$/gm, ''); } return parseFn; } @@ -34113,7 +33922,7 @@ function pickErrorHandlingChunk(fn, hasErrorRecovery) { // - module.commonCode: initialization code that should be placed before the module // - module.moduleCode: code that creates the module object lrGeneratorMixin.generateModule_ = function generateModule_() { - var parseFn = String(parser$4.parse); + let parseFn = String(parser$4.parse); parseFn = pickErrorHandlingChunk(parseFn, this.hasErrorRecovery); parseFn = addOrRemoveTokenStack(parseFn, this.options.tokenStack); @@ -34122,9 +33931,9 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { parseFn = expandParseArguments(parseFn, this); - var errorClassCode = this.generateErrorClass(); + let errorClassCode = this.generateErrorClass(); - var exportDest = this.options.exportAllTables; + let exportDest = this.options.exportAllTables; assert$1(exportDest); // store the parse tables: @@ -34132,10 +33941,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { exportDest.defaultParseActions = this.defaultActions; exportDest.parseProductions = this.productions_; - var exportSourceCode = this.options.exportSourceCode; - assert$1(exportSourceCode); - - var tableCode; + let tableCode; switch (this.options.compressTables | 0) { case 0: // no compression tableCode = this.generateTableCode0(this.table, this.defaultActions, this.productions_); @@ -34158,29 +33964,27 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // Generate the initialization code - var initCode = [].concat( + let initCode = [].concat( this.moduleInit.getInitCodeSection('imports'), this.moduleInit.getInitCodeSection('init') ); - var commonCode = [].concat( + let commonCode = [].concat( this.moduleInit.getInitCodeSection('required'), errorClassCode.commonCode, errorClassCode.moduleCode, - ['\nYY_REMAINING_INIT_CODE_SECTIONS_GO_HERE\n'], + [ '\nYY_REMAINING_INIT_CODE_SECTIONS_GO_HERE\n' ], tableCode.commonCode ); - // sort hash table by key to produce a nicer output: function produceSymbolTable(tbl) { - var a = Object.keys(tbl); + let a = Object.keys(tbl); a.sort(); - var nt = {}; - var k; - for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; + let nt = {}; + for (let i = 0, len = a.length; i < len; i++) { + let k = a[i]; // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number // and we do not want `$eof`/`EOF` to show up in the symbol tables of generated parsers @@ -34194,12 +33998,11 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // swap key and value and then sort hash table by key to produce a nicer output: function produceTerminalTable(tbl) { - var a = Object.keys(tbl); - var nt = {}; - var k, v; - for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; - v = tbl[k]; + let a = Object.keys(tbl); + let nt = {}; + for (let i = 0, len = a.length; i < len; i++) { + let k = a[i]; + let v = tbl[k]; nt[v] = +k; // convert numeric key back to number type; all terminals have numeric keys } return produceSymbolTable(nt); @@ -34207,71 +34010,71 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { function produceProductionsForDebugging(options, symbols, base) { function get_orig_symbol(s) { - var a = s.split(':'); + let a = s.split(':'); if (a.length === 1 || a[0] === '') { return { state: -1, symbol: s }; } - var state = a[0]; + let state = a[0]; a.shift(); return { state: +state, - symbol: a.join(':'), + symbol: a.join(':') }; } function get_orig_symbol_set(arr) { - var rv = {}; - for (var i = 0, len = arr.length; i < len; i++) { - var item = arr[i]; - var symbol = get_orig_symbol(item); + let rv = {}; + for (let i = 0, len = arr.length; i < len; i++) { + let item = arr[i]; + let symbol = get_orig_symbol(item); rv[symbol.symbol] = symbol.state; } return Object.keys(rv); } - var tbl = this.nonterminals; - var sym = this.symbols_ || symbols; + let tbl = this.nonterminals; + let sym = this.symbols_ || symbols; if (!options.outputDebugTables && !options.exportAllTables.enabled) { return undefined; } - var prods = { + let prods = { ids: {}, states: {}, rules: {}, nonterminals: {}, symbols: {}, first: {}, - follows: {}, + follows: {} }; - var self = this; + let self = this; this.productions.forEach(function Follow_prod_forEach_genDebugTable(production, k) { - var nonterm = production.symbol; + let nonterm = production.symbol; prods.states[k] = nonterm; prods.ids[nonterm] = sym[nonterm]; - var lst = prods.rules[nonterm] || {}; + let lst = prods.rules[nonterm] || {}; lst[k] = gen_lalr_states_production(production, k, false, k, true); prods.rules[nonterm] = lst; }); function gen_nonterminal(nt) { - var l = nt.productions._items; - var lst = l.map(function (p, i) { + let l = nt.productions._items; + let lst = l.map(function (p, i) { return gen_lalr_states_production(p, i, false, false, false); }); - var rv = { + let rv = { symbol: nt.symbol, productions: lst, first: nt.first, base_first: get_orig_symbol_set(nt.first), follows: nt.follows, base_follows: get_orig_symbol_set(nt.follows), - nullable: nt.nullable, + nullable: nt.nullable }; // clean up structure: ditch superfluous elements: @@ -34285,7 +34088,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { return rv; } - for (var key in tbl) { + for (let key in tbl) { prods.nonterminals[key] = gen_nonterminal(tbl[key]); } @@ -34294,9 +34097,9 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { } function gen_lalr_states_production(production, index, dotPosition, state, patch_base) { - var nonterm = production.symbol; - var hlen = production.handle.length; - var rulestr = production.handle.map(function (t, idx) { + let nonterm = production.symbol; + let hlen = production.handle.length; + let rulestr = production.handle.map(function (t, idx) { if (!t) { t = '%epsilon'; } @@ -34310,7 +34113,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { rulestr += ' ⬤'; } - var base_rulestr = production.handle.map(function (t) { + let base_rulestr = production.handle.map(function (t) { if (!t) { t = '%epsilon'; } @@ -34318,7 +34121,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { return t; }).join(' '); - var rv = { + let rv = { symbol: nonterm, base_symbol: get_orig_symbol(nonterm).symbol, handle: rulestr, @@ -34337,12 +34140,11 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { }; // Determine state for given production, if it's not a production that's listed as part of a state: - var chk, idx; - var lst = prods.rules[nonterm]; - chk = rv.symbol + ' : ' + rv.handle; - for (idx in lst) { + let lst = prods.rules[nonterm]; + let chk = rv.symbol + ' : ' + rv.handle; + for (let idx in lst) { idx = +idx; - var p = lst[idx]; + let p = lst[idx]; if (p) { if (p.symbol + ' : ' + p.handle === chk) { assert$1(rv.state === -1); @@ -34355,9 +34157,9 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // Try to reference base productions from newg child productions and vice versa: chk = rv.base_symbol + ' : ' + rv.base_handle; if (base && base.rules) { - var pr = base.rules[rv.base_symbol]; - for (idx in pr) { - var bprod = pr[idx]; + let pr = base.rules[rv.base_symbol]; + for (let idx in pr) { + let bprod = pr[idx]; if (bprod.symbol + ' : ' + bprod.handle === chk) { assert$1(rv.base_state === -1); rv.base_state = bprod.state; @@ -34391,13 +34193,13 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { if (this.states) { prods.lalr_states = []; - var these_states = this.states; + let these_states = this.states; these_states.forEach(function traverse_states(state, i) { //assert(state.inadequate ? these_states.inadequate : true); state.forEach(function traverse_state(item, j) { // is this a REDUCE state? - var nterm_first = self.nonterminals[item.production.symbol].first; - var rv = { + let nterm_first = self.nonterminals[item.production.symbol].first; + let rv = { state: i, item_index: j, is_reduce_state: (item.dotPosition === item.production.handle.length), @@ -34410,7 +34212,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { nterm_first: nterm_first, base_nterm_first: get_orig_symbol_set(nterm_first), prod_first: item.production.first, - base_prod_first: get_orig_symbol_set(item.production.first), + base_prod_first: get_orig_symbol_set(item.production.first) }; // clean up structure: ditch superfluous elements: @@ -34429,13 +34231,12 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { }); } - var nt = tbl; - var sbn; - for (sbn in nt) { - var orig_symbol = get_orig_symbol(sbn); - var item = nt[sbn]; - var firsts = item.first; - var follows = item.follows; + let nt = tbl; + for (let sbn in nt) { + let orig_symbol = get_orig_symbol(sbn); + let item = nt[sbn]; + let firsts = item.first; + let follows = item.follows; if (!prods.symbols[orig_symbol.symbol]) { prods.symbols[orig_symbol.symbol] = orig_symbol.state; } @@ -34450,10 +34251,10 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { prods.follows[orig_symbol.symbol] = prods.follows[orig_symbol.symbol].concat(follows); } } - for (sbn in prods.first) { + for (let sbn in prods.first) { prods.first[sbn] = get_orig_symbol_set(prods.first[sbn]); } - for (sbn in prods.follows) { + for (let sbn in prods.follows) { prods.follows[sbn] = get_orig_symbol_set(prods.follows[sbn]); } @@ -34464,11 +34265,11 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { } function produceTerminalDescriptions(tbl, sym) { - var rv = {}; - var count = 0; - for (var k in tbl) { - var descr = tbl[k]; - var id = sym[k]; + let rv = {}; + let count = 0; + for (let k in tbl) { + let descr = tbl[k]; + let id = sym[k]; if (id && descr && descr !== id) { rv[id] = descr; count++; @@ -34478,56 +34279,56 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - type: 0, // CLI: --parserType option - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - numExpectedConflictStates: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - json: 1, - _: 1, - noMain: 1, - moduleMain: 1, - moduleMainImports: 1, - noDefaultResolve: 1, - defaultActionMode: 1, - testCompileActionCode: 1, - noTryCatch: 1, - hasPartialLrUpgradeOnConflict: 0, - compressTables: 1, - outputDebugTables: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - lexfile: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - exportAllTables: 1, - exportSourceCode: 1, - tokenStack: 0, - parserErrorsAreRecoverable: 0, - lexerErrorsAreRecoverable: 1, - showSource: 1, - exportAST: 1, - prettyCfg: 1, - - errorRecoveryTokenDiscardCount: 0, - - warn_cb: 0, // function(msg) | true (= use Jison.Print) | false (= throw Exception) - - parseParams: 1, - ranges: 0, + let obj = {}; + let do_not_pass = { + type: 0, // CLI: --parserType option + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + numExpectedConflictStates: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + json: 1, + _: 1, + noMain: 1, + moduleMain: 1, + moduleMainImports: 1, + noDefaultResolve: 1, + defaultActionMode: 1, + testCompileActionCode: 1, + noTryCatch: 1, + hasPartialLrUpgradeOnConflict: 0, + compressTables: 1, + outputDebugTables: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + lexfile: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + exportAllTables: 1, + exportSourceCode: 1, + tokenStack: 0, + parserErrorsAreRecoverable: 0, + lexerErrorsAreRecoverable: 1, + showSource: 1, + exportAST: 1, + prettyCfg: 1, + + errorRecoveryTokenDiscardCount: 0, + + warn_cb: 0, // function(msg) | true (= use Jison.Print) | false (= throw Exception) + + parseParams: 1, + ranges: 0 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -34539,12 +34340,12 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // And now some options which should receive some special processing: if (!obj.hasPartialLrUpgradeOnConflict) { - // only list this option when it's actually TRUE: - delete obj.hasPartialLrUpgradeOnConflict; + // only list this option when it's actually TRUE: + delete obj.hasPartialLrUpgradeOnConflict; } - var pre = obj.pre_parse; - var post = obj.post_parse; + let pre = obj.pre_parse; + let post = obj.post_parse; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_parse = true; @@ -34553,7 +34354,7 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { obj.post_parse = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp(` "(${ID_REGEX_BASE$3})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_parse: true(,)?$/gm, function (m, ls, tc) { @@ -34567,27 +34368,27 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { // Generate the module creation code - var termDescrs = produceTerminalDescriptions(this.descriptions_, this.symbols_); + let termDescrs = produceTerminalDescriptions(this.descriptions_, this.symbols_); exportDest.terminalDescriptions = termDescrs; - var descrLst = JSON.stringify(termDescrs, null, 2); + let descrLst = JSON.stringify(termDescrs, null, 2); if (descrLst) { descrLst = descrLst.replace(/"([0-9]+)":/g, '$1:'); } - var rules4Dbg = produceProductionsForDebugging.call(this, this.options); + let rules4Dbg = produceProductionsForDebugging.call(this, this.options); exportDest.parseRules = rules4Dbg; - var rulesLst = ((this.options.outputDebugTables || this.options.exportAllTables.enabled) ? JSON.stringify(rules4Dbg, null, 2) : undefined); + let rulesLst = ((this.options.outputDebugTables || this.options.exportAllTables.enabled) ? JSON.stringify(rules4Dbg, null, 2) : undefined); if (rulesLst) { rulesLst = rulesLst.replace(/"([0-9]+)":/g, '$1:').replace(/^(\s+)"([a-z_][a-z_0-9]*)":/gmi, '$1$2:'); } - var symbolTable = produceSymbolTable(this.symbols_); + let symbolTable = produceSymbolTable(this.symbols_); exportDest.symbolTable = symbolTable; // produce a hash lookup table from the terminal set exportDest.terminalTable = produceTerminalTable(this.terminals_); - var moduleCode = `{ + let moduleCode = `{ // Code Generator Information Report // --------------------------------- // @@ -34651,22 +34452,22 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { 'yy: {}', 'options: ' + produceOptions(this.options), 'symbols_: ' + JSON.stringify(symbolTable, null, 2), - 'terminals_: ' + JSON.stringify(this.terminals_, null, 2).replace(/"([0-9]+)":/g, '$1:'), + 'terminals_: ' + JSON.stringify(this.terminals_, null, 2).replace(/"([0-9]+)":/g, '$1:') ].concat( rulesLst ? - 'nonterminals_: ' + rulesLst : - [] + 'nonterminals_: ' + rulesLst : + [] ).concat( descrLst ? - 'terminal_descriptions_: ' + descrLst : - [] + 'terminal_descriptions_: ' + descrLst : + [] ).concat([ define_parser_APIs_1.trim(), 'productions_: ' + tableCode.productionsCode ]).concat( String(this.performAction).trim() !== '' ? - 'performAction: ' + String(this.performAction) : - [] + 'performAction: ' + String(this.performAction) : + [] ).concat([ 'table: ' + tableCode.tableCode, 'defaultActions: ' + tableCode.defaultActionsCode, @@ -34674,24 +34475,24 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { 'parse: ' + parseFn.trim() ]).concat( this.actionsUseYYERROR ? - 'yyError: 1' : - [] + 'yyError: 1' : + [] ).concat( this.actionsUseYYRECOVERING ? - 'yyRecovering: 1' : - [] + 'yyRecovering: 1' : + [] ).concat( this.actionsUseYYERROK ? - 'yyErrOk: 1' : - [] + 'yyErrOk: 1' : + [] ).concat( this.actionsUseYYCLEARIN ? - 'yyClearIn: 1' : - [] + 'yyClearIn: 1' : + [] ).join(',\n'); moduleCode += '\n};'; - var exportSourceCode = this.options.exportSourceCode; + const exportSourceCode = this.options.exportSourceCode; assert$1(exportSourceCode); exportSourceCode.parserChunks = { initCode: expandConstantsInGeneratedCode(initCode.join('\n'), this), @@ -34699,8 +34500,8 @@ lrGeneratorMixin.generateModule_ = function generateModule_() { moduleCode: expandConstantsInGeneratedCode(moduleCode, this), modulePostlude: [ 'parser.originalParseError = parser.parseError;', - 'parser.originalQuoteName = parser.quoteName;', - ].join('\n'), + 'parser.originalQuoteName = parser.quoteName;' + ].join('\n'), moduleInclude: expandConstantsInGeneratedCode(this.moduleInclude, this) }; return exportSourceCode.parserChunks; @@ -34714,8 +34515,6 @@ lrGeneratorMixin.generateErrorClass = function () { // 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. function JisonParserError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -34732,9 +34531,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -34772,14 +34571,14 @@ JisonParserError.prototype.name = 'JisonParserError'; // Generate code that represents the specified parser table lrGeneratorMixin.generateTableCode0 = function (table, defaultActions, productions) { - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); // Don't surround numerical property name numbers in quotes tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); - var prelude = []; + let prelude = []; // Return the variable initialization code and the table code return { @@ -34792,10 +34591,10 @@ lrGeneratorMixin.generateTableCode0 = function (table, defaultActions, productio // Function that extends an object with the given value for all given keys // e.g., x([1, 3, 4], [6, 7], { x: 1, y: 2 }) = { 1: [6, 7]; 3: [6, 7], 4: [6, 7], x: 1, y: 2 } -var compressor1ObjectCode = ` +let compressor1ObjectCode = ` function x(k, v, o) { o = o || {}; - for (var l = k.length; l--; ) { + for (let l = k.length; l--; ) { o[k[l]] = v; } return o; @@ -34804,10 +34603,10 @@ function x(k, v, o) { // Generate code that represents the specified parser table lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productions) { - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); - var usesCompressor = false; + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); + let usesCompressor = false; // Don't surround numerical property name numbers in quotes tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); @@ -34816,22 +34615,21 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio // e.g., { 1: [6, 7]; 3: [6, 7], 4: [6, 7], 5: 8 } = x([1, 3, 4], [6, 7], { 5: 8 }) tableCode = tableCode.replace(/\{[\s\r\n]*\d+:[^\}]+,[\s\r\n]*\d+:[^\}]+\}/g, function (object) { // Find the value that occurs with the highest number of keys - var value, frequentValue, key, - keys = {}, - keyCount, - maxKeyCount = 0, - keyValue, - keyValues = [], - keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; + let frequentValue; + let keys = {}; + let maxKeyCount = 0; + let keyValue; + let keyValues = []; + let keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; while ((keyValue = keyValueMatcher.exec(object))) { // For each value, store the keys where that value occurs - key = keyValue[1]; - value = keyValue[2].trim(); - keyCount = 1; + let key = keyValue[1]; + let value = keyValue[2].trim(); + let keyCount = 1; if (!(value in keys)) { - keys[value] = [key]; + keys[value] = [ key ]; } else { keyCount = keys[value].push(key); } @@ -34844,9 +34642,9 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio // Construct the object with a function call if the most frequent value occurs multiple times if (maxKeyCount > 1) { // Collect all non-frequent values into a remainder object - for (value in keys) { + for (let value in keys) { if (value !== frequentValue) { - for (var k = keys[value], i = 0, l = k.length; i < l; i++) { + for (let k = keys[value], i = 0, l = k.length; i < l; i++) { keyValues.push(k[i] + ':' + value); } } @@ -34860,10 +34658,10 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio }); // Count occurrences of number lists - var list; - var lists = {}; - var listMatcher = /\[[0-9,]+\]/g; - var frequentLists = []; + let list; + let lists = {}; + let listMatcher = /\[[0-9,]+\]/g; + let frequentLists = []; while ((list = listMatcher.exec(tableCode))) { lists[list] = (lists[list] || 0) + 1; @@ -34871,7 +34669,7 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio // Replace frequently occurring number lists with variables tableCode = tableCode.replace(listMatcher, function (list) { - var listId = lists[list]; + let listId = lists[list]; // If listId is a number, it represents the list's occurrence frequency if (typeof listId === 'number') { // If the list does not occur frequently, represent it by the list @@ -34886,7 +34684,7 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio return listId; }); - var prelude = []; + let prelude = []; // Only include the expander function when it's actually used // (tiny grammars don't have much state duplication, so this shaves off @@ -34897,7 +34695,7 @@ lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productio } if (frequentLists.length > 0) { - prelude.push('var u = [\n ' + frequentLists.join(',\n ') + '\n];'); + prelude.push('let u = [\n ' + frequentLists.join(',\n ') + '\n];'); prelude.push(''); } @@ -34916,9 +34714,9 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio throw new Error("Table Compression mode 2 corrupts the table when the 'noDefaultResolve' option is turned on and one or more conflicts occur. Please use a different compression mode and/or disable this option."); } - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); // We know a couple of things about the parse table: // @@ -34946,33 +34744,29 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); - - function reportColumnsForCompression(def_arr) { - var i, key, len; - var report = []; + let report = []; - len = 0; - for (key in def_arr) { + let len = 0; + for (let key in def_arr) { len = Math.max(len, def_arr[key].length); } - var col_width = 6; - var col_delta_width = 4; + let col_width = 6; + let col_delta_width = 4; function clip(val, width) { - var s = ' ' + val; + let s = ' ' + val; s = s.substr(s.length - width); return s; } - var track_prev4delta = {}; - var c, delta, val, delta_val; - var line = []; + let track_prev4delta = {}; + let line = []; line.push('║'); - for (c in def_arr) { - key = clip(c, col_width); - delta = clip('∆', col_delta_width); + for (let c in def_arr) { + let key = clip(c, col_width); + let delta = clip('∆', col_delta_width); line.push(key); line.push('┊'); line.push(delta); @@ -34982,12 +34776,13 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } report.push(line.join('')); - for (i = 0; i < len; i++) { + for (let i = 0; i < len; i++) { line = []; line.push('║'); - for (c in def_arr) { - var tbl = def_arr[c]; + for (let c in def_arr) { + let val, delta_val; + let tbl = def_arr[c]; if (tbl.length > i) { val = tbl[i] || 0; @@ -35002,8 +34797,8 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio delta_val = '.'; } - key = clip(val, col_width); - delta = clip(delta_val, col_delta_width); + let key = clip(val, col_width); + let delta = clip(delta_val, col_delta_width); line.push(key); line.push('┊'); line.push(delta); @@ -35019,16 +34814,16 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // table is array of 1/2-len arrays: function analyzeTableForCompression(table) { // column: productions' row length - var len_col = []; + let len_col = []; // column: productions' shift size / action column - var pop_col = []; + let pop_col = []; // column: rule number for each slot ('rule'): - var rule_col = []; + let rule_col = []; - var i; - var row_count = table.length; + let i; + let row_count = table.length; for (i = 0; i < row_count; i++) { - var prod = table[i]; + let prod = table[i]; len_col.push(prod.length); assert$1(prod.length <= 2); @@ -35039,10 +34834,10 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio rule_col.push(prod[1]); } - var def_arr = { - 'len': len_col, - 'pop': pop_col, - 'rule': rule_col, + let def_arr = { + len: len_col, + pop: pop_col, + rule: rule_col }; return def_arr; } @@ -35053,14 +34848,14 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // table is hash of 1/2-len arrays: function analyzeSetForCompression(table) { // column: row index - var idx_col = []; + let idx_col = []; // column: REDUCE productions' goto column - var goto_col = []; + let goto_col = []; - var i; + let i; for (i in table) { i = +i; - var prod = table[i]; + let prod = table[i]; idx_col.push(i); // and the special knowledge about the defaultActions[] table: @@ -35068,9 +34863,9 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio goto_col.push(prod); } - var def_arr = { - 'idx': idx_col, - 'goto': goto_col, + let def_arr = { + idx: idx_col, + goto: goto_col }; return def_arr; } @@ -35079,30 +34874,29 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function analyzeGotoTableForCompression(table) { // column: number of symbol hash entries per state slot ('length'): - var len_col = []; + let len_col = []; // column: symbol hash entry key for each slot ('symbol'): - var symbol_col = []; + let symbol_col = []; // column: symbol hash entry value type: number (0) or array (array.length) ('type'): - var type_col = []; + let type_col = []; // column: symbol hash entry value if single GOTO state number ('state'): - var state_col = []; + let state_col = []; // column: symbol hash entry mode value if array slot type (reduce/shift/accept): - var mode_col = []; + let mode_col = []; // column: symbol hash entry goto state value if array slot type: - var goto_col = []; + let goto_col = []; // // column: merged: state_col + goto_col: - // var next_col = []; - - var row_count = table.length; - for (var state = 0; state < row_count; state++) { - var hashtable = table[state]; - var count = 0; - var symbol; - for (symbol in hashtable) { + // let next_col = []; + + let row_count = table.length; + for (let state = 0; state < row_count; state++) { + let hashtable = table[state]; + let count = 0; + for (let symbol in hashtable) { symbol = +symbol; symbol_col.push(symbol); - var slot = hashtable[symbol]; + let slot = hashtable[symbol]; if (slot && slot.length) { // array type slot: assert$1(slot.length === 2 || slot.length === 1); @@ -35129,40 +34923,40 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio len_col.push(count); } - var def_arr = { - 'len': len_col, - 'symbol': symbol_col, - 'type': type_col, - 'state': state_col, - 'mode': mode_col, - 'goto': goto_col, + let def_arr = { + len: len_col, + symbol: symbol_col, + type: type_col, + state: state_col, + mode: mode_col, + goto: goto_col //'next': next_col, }; return def_arr; } - var has_compressed_a_table = false; + let has_compressed_a_table = false; function generateColumn(name, col) { - var rv = []; - var i, j, len, l; + let rv = []; - for (i = 0, len = col.length; i < len; i++) { + for (let i = 0, len = col.length; i < len; i++) { // try basic run-length encoding first: - var v = col[i]; + let v = col[i]; + let j; for (j = i + 1; j < len; j++) { if (col[j] !== v) { break; } } - var runlength = j - i; + let runlength = j - i; // try stepped run-length encoding next: - var delta = col[i + 1] - v; - var steplength = 0; + let delta = col[i + 1] - v; + let steplength = 0; // we don't want to replicate the runlength result, so only look for a match // when delta !== 0: @@ -35176,10 +34970,11 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } // try to match the pattern in history: - var best_pos = 0; - var best_len = 0; - var upper_bound = i - 2; + let best_pos = 0; + let best_len = 0; + let upper_bound = i - 2; for (j = 0; j < upper_bound; j++) { + let l; for (l = 0; col[j + l] === col[i + l]; l++) { // No need to check for: // if (j + l === i) break; @@ -35203,28 +34998,24 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } // weight our options now: - var gain = [ + let gain = [ runlength - 2, steplength - 3, best_len - 2 ]; - var optimum_gain = Math.max.apply(null, gain); + let optimum_gain = Math.max.apply(null, gain); if (optimum_gain <= 0) { rv.push(v); - } - else if (optimum_gain === gain[0]) { + } else if (optimum_gain === gain[0]) { rv.push('s', '[' + v + ', ' + runlength + ']'); i += runlength - 1; - } - else if (optimum_gain === gain[1]) { + } else if (optimum_gain === gain[1]) { rv.push('s', '[' + v + ', ' + steplength + ', ' + delta + ']'); i += steplength - 1; - } - else if (optimum_gain === gain[2]) { + } else if (optimum_gain === gain[2]) { rv.push('c', '[' + best_pos + ', ' + best_len + ']'); i += best_len - 1; - } - else { + } else { rv.push(v); //assert(0); // should never get here! } @@ -35234,11 +35025,11 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } } - var code = [ + let code = [ ' ', name, ': ', 'u([', '\n ', - rv.join(',\n '), // JSON.stringify(col, null, 2), + rv.join(',\n '), // JSON.stringify(col, null, 2), '\n', '])' ].join(''); @@ -35247,7 +35038,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function generateCompressedTable(def_arr) { - var code = [ + let code = [ 'bp({', generateColumn('pop', def_arr.pop) + ',', generateColumn('rule', def_arr.rule), @@ -35258,7 +35049,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function generateCompressedSet(def_arr) { - var code = [ + let code = [ 'bda({', generateColumn('idx', def_arr.idx) + ',', generateColumn('goto', def_arr.goto), @@ -35269,7 +35060,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio function generateCompressedGotoTable(def_arr) { - var code = [ + let code = [ 'bt({', generateColumn('len', def_arr.len) + ',', generateColumn('symbol', def_arr.symbol) + ',', @@ -35283,18 +35074,18 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio } - var tableDef = analyzeGotoTableForCompression(table); - var defaultActionsDef = analyzeSetForCompression(defaultActions); - var productionsDef = analyzeTableForCompression(productions); + let tableDef = analyzeGotoTableForCompression(table); + let defaultActionsDef = analyzeSetForCompression(defaultActions); + let productionsDef = analyzeTableForCompression(productions); const bp_code_container = ` // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -35307,11 +35098,11 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio const bda_code_container = ` // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -35321,18 +35112,18 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio const bt_code_container = ` // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -35363,7 +35154,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // \`this\` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -35380,9 +35171,9 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -35396,25 +35187,25 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio `; has_compressed_a_table = false; - var tc = generateCompressedGotoTable(tableDef); - var compressGotoTable = has_compressed_a_table; + let tc = generateCompressedGotoTable(tableDef); + let compressGotoTable = has_compressed_a_table; has_compressed_a_table = false; - var dac = generateCompressedSet(defaultActionsDef); - var compressDefaultActions = has_compressed_a_table; + let dac = generateCompressedSet(defaultActionsDef); + let compressDefaultActions = has_compressed_a_table; has_compressed_a_table = false; - var pc = generateCompressedTable(productionsDef); - var compressProductions = has_compressed_a_table; + let pc = generateCompressedTable(productionsDef); + let compressProductions = has_compressed_a_table; - var compressAnything = (compressProductions || compressDefaultActions || compressGotoTable); + let compressAnything = (compressProductions || compressDefaultActions || compressGotoTable); tableCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(tableDef) : '') + (compressGotoTable ? tc : tableCode); defaultActionsCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(defaultActionsDef) : '') + (compressDefaultActions ? dac : defaultActionsCode); productionsCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(productionsDef) : '') + (compressProductions ? pc : productionsCode); - var prelude = [ + let prelude = [ '', compressProductions ? bp_code_container : '', '', @@ -35422,7 +35213,7 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio '', compressGotoTable ? bt_code_container : '', '', - c_s_u_code_container, + c_s_u_code_container ]; if (!compressAnything) { prelude = []; @@ -35438,31 +35229,29 @@ lrGeneratorMixin.generateTableCode2 = function (table, defaultActions, productio }; // --- START of commonJsMain chunk --- -// +// // default main method for generated commonjs modules const commonJsMain = ` -function (args) { - "use strict"; - +function __jison_default_main__(args) { // When the parser comes with its own \`main\` function, then use that one: if (typeof exports.parser.main === 'function') { - return exports.parser.main(args); + return exports.parser.main(args); } if (!args[1]) { console.log('Usage:', path.basename(args[0]) + ' FILE'); process.exit(1); } - var source = fs.readFileSync(path.normalize(args[1]), 'utf8'); - var dst = exports.parser.parse(source); + const source = fs.readFileSync(path.normalize(args[1]), 'utf8'); + const dst = exports.parser.parse(source); console.log('parser output:\\n\\n', { type: typeof dst, value: dst }); try { - console.log("\\n\\nor as JSON:\\n", JSON.stringify(dst, null, 2)); + 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... */ } - var rv = 0; + let rv = 0; if (typeof dst === 'number' || typeof dst === 'boolean') { rv = dst; } @@ -35472,16 +35261,16 @@ function (args) { // --- END of commonJsMain chunk --- const commonJsMainImports = ` -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); `; // debug mixin for LR parser generators function printAction(a, gen) { - var s = a[0] === SHIFT ? 'shift token (then go to state ' + a[1] + ')' : + let s = a[0] === SHIFT ? 'shift token (then go to state ' + a[1] + ')' : a[0] === REDUCE ? 'reduce by rule: ' + gen.productions[a[1]] : - a[0] === ACCEPT ? 'accept' : 'UNDEFINED ACTION: ' + a[0]; + a[0] === ACCEPT ? 'accept' : 'UNDEFINED ACTION: ' + a[0]; return s; } @@ -35495,13 +35284,13 @@ function traceStates(trace, states, title) { trace('\n'); } -var lrGeneratorDebug = { +const lrGeneratorDebug = { beforeparseTable: function () { this.trace('Building parse table.'); }, afterparseTable: function () { - var trace = this.trace; - var self = this; + let trace = this.trace; + let self = this; if (this.conflicts > 0) { trace('\nConflicts:\n'); this.resolutions.forEach(function (r, i) { @@ -35513,21 +35302,21 @@ var lrGeneratorDebug = { } trace('Done.\n'); }, - aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */ ) { + aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */) { traceStates(this.trace, states, 'as produced by LR::canonicalCollection()'); } }; -var parser$4 = typal.beget(); +const parser$4 = typal.beget(); generatorMixin.createParser = function createParser() { - var sourceCodeDef = this.generateModuleExpr(); + let sourceCodeDef = this.generateModuleExpr(); // produce a chunk of sourcecode that's suitable for evaluation through `eval()`: - var sourcecode = rmCommonWS$5` + let sourcecode = rmCommonWS$5` ${sourceCodeDef.init} - var yy__parser = ${sourceCodeDef.src}; + let yy__parser = ${sourceCodeDef.src}; // produce the generated parser function/class as the last value // in this chunk of code so that we can be sure to produce *that* @@ -35538,15 +35327,15 @@ generatorMixin.createParser = function createParser() { yy__parser; `; - var p = code_exec$2(sourcecode, function generated_code_exec_wrapper_jison(sourcecode) { + let 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); - var rv = eval(sourcecode); + let rv = eval(sourcecode); return rv; }, mkStdOptions$1(this.options, { dumpSourceCodeOnFailure: this.DEBUG, throwErrorOnCompileFailure: true - }), "parser"); + }), 'parser'); assert$1(typeof p === 'object'); assert$1(typeof p.parse === 'function'); assert$1(typeof p.parser === 'undefined'); @@ -35590,7 +35379,7 @@ generatorMixin.createParser = function createParser() { } p.sourceCode = sourceCodeDef; - var self = this; + let self = this; function bind(method) { return function () { self.lexer = p.lexer; @@ -35617,8 +35406,6 @@ parser$4.error = generator.error; // --- START parser Error class chunk --- const parseErrorSourceCode = ` function parseError(str, hash, ExceptionClass) { - "use strict"; - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -35643,7 +35430,7 @@ parser$4.parseError = lrGeneratorMixin.parseError = eval(parseErrorSourceCode + generatorMixin.createLexer = function createLexer(lexerSpec, input, tokens, options) { // TODO: construct options from generator options: // lexer_options = ... - var lexer = new RegExpLexer(lexerSpec, input, tokens, options); + let lexer = new RegExpLexer(lexerSpec, input, tokens, options); return lexer; }; @@ -35682,8 +35469,6 @@ const define_parser_APIs_1 = ` // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - "use strict"; - return '"' + id_str + '"'; }, @@ -35691,8 +35476,6 @@ const define_parser_APIs_1 = ` // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - "use strict"; - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -35704,8 +35487,8 @@ const define_parser_APIs_1 = ` // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -35718,15 +35501,13 @@ const define_parser_APIs_1 = ` // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - "use strict"; - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -35742,11 +35523,10 @@ const define_parser_APIs_1 = ` // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { - "use strict"; + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -35754,10 +35534,10 @@ const define_parser_APIs_1 = ` this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -35769,8 +35549,8 @@ const define_parser_APIs_1 = ` `; // --- END of define_parser_APIs_1 chunk --- -var api_set = (new Function('', 'return { ' + define_parser_APIs_1 + ' };'))(); -for (var api in api_set) { +const api_set = (new Function('', 'return { ' + define_parser_APIs_1 + ' };'))(); +for (let api in api_set) { parser$4[api] = api_set[api]; } @@ -35778,39 +35558,37 @@ for (var api in api_set) { // --- START parser kernel --- parser$4.parse = ` function parse(input, parseParams) { - "use strict"; - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - var tstack = []; // token stack (only used when \`%options token_stack\` support has been enabled) - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - var yytext; - var yylineno; - var yyleng; - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + let tstack = []; // token stack (only used when \`%options token_stack\` support has been enabled) + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + let yytext; + let yylineno; + let yyleng; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -35819,21 +35597,18 @@ function parse(input, parseParams) { post_parse: undefined, pre_lex: undefined, post_lex: undefined, - parseParamsAsMembers: parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - "use strict"; - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -35858,8 +35633,6 @@ function parse(input, parseParams) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - "use strict"; - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -35867,18 +35640,19 @@ function parse(input, parseParams) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -35886,26 +35660,19 @@ function parse(input, parseParams) { // - either the element does not yet exist in \`src\` // - or exists in \`src\` but is NULL or UNDEFINED there, while its value is non-NULL in \`dst\` function shallow_copy_noclobber(dst, src) { - "use strict"; - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - "use strict"; - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -35923,17 +35690,13 @@ function parse(input, parseParams) { this.copy_yytext = this.options.copy_yytext || sharedState_yy.copy_yytext || shallow_copy; this.copy_yylloc = this.options.copy_yylloc || sharedState_yy.copy_yylloc || copy_yylloc_native; - var yydebug = false; + let yydebug = false; if (this.options.debug) { yydebug = function yydebug_impl(msg, obj) { - "use strict"; - - var ref_list; - var ref_names; + let ref_list; + let ref_names; function deepClone(from, sub) { - "use strict"; - if (sub == null) { ref_list = []; ref_names = []; @@ -35945,15 +35708,15 @@ function parse(input, parseParams) { return from; } - var i = ref_list.indexOf(from); + let i = ref_list.indexOf(from); if (i >= 0) { return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference } ref_list.push(from); ref_names.push(sub); - var to = new from.constructor(); - for (var name in from) { + let to = new from.constructor(); + for (let name in from) { if (name === 'parser') continue; if (name === 'lexer') continue; to[name] = deepClone(from[name], name); @@ -35981,13 +35744,11 @@ function parse(input, parseParams) { // wrap try/catch in a function to help the V8 JIT compiler... function yydebug_cvt(obj) { - "use strict"; - - var js; + let js; try { - var re1; + let re1; if (typeof XRegExp === 'undefined') { - re1 = / \\"([a-z_][a-z_0-9. ]*)\\": /ig; + re1 = / {2}\\"([a-z_][a-z_0-9. ]*)\\": /ig; } else { re1 = new XRegExp(' \\"([\\\\p{Alphabetic}_][\\\\p{Alphabetic}\\\\p{Number}_. ]*)\\": ', 'g'); } @@ -36019,21 +35780,25 @@ function parse(input, parseParams) { // them up. Hence we MUST set them up at the start of every \`parse()\` run! if (this.yyError) { this.yyError = function yyError(str /*, ...args */) { - "use strict"; - - if (yydebug) yydebug('yyerror: ', { message: str, args: arguments, symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('yyerror: ', { + message: str, + args: arguments, + symbol, state, newState, recovering, action + }); + } //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); + let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -36054,13 +35819,13 @@ function parse(input, parseParams) { //_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, false); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, false); //_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -36073,18 +35838,14 @@ function parse(input, parseParams) { if (this.yyRecovering) { this.yyRecovering = function yyRecovering() { - "use strict"; - - if (yydebug) yydebug('yyrecovering: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) yydebug('yyrecovering: ', { symbol, state, newState, recovering, action }); return recovering; }; } if (this.yyErrOk) { this.yyErrOk = function yyErrOk() { - "use strict"; - - if (yydebug) yydebug('yyerrok: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) yydebug('yyerrok: ', { symbol, state, newState, recovering, action }); recovering = 0; // DO NOT reset/cleanup \`recoveringErrorInfo\` yet: userland code @@ -36106,9 +35867,7 @@ function parse(input, parseParams) { if (this.yyClearIn) { this.yyClearIn = function yyClearIn() { - "use strict"; - - if (yydebug) yydebug('yyclearin: ', { symbol: symbol, newState: newState, recovering: recovering, action: action, preErrorSymbol: preErrorSymbol }); + if (yydebug) yydebug('yyclearin: ', { symbol, newState, recovering, action, preErrorSymbol }); if (symbol === TERROR) { symbol = 0; yytext = null; @@ -36125,8 +35884,6 @@ function parse(input, parseParams) { // Does the shared state override the default \`parseError\` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -36139,8 +35896,6 @@ function parse(input, parseParams) { // Does the shared state override the default \`quoteName\` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - "use strict"; - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -36154,12 +35909,10 @@ function parse(input, parseParams) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your \`sharedState\`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - "use strict"; - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -36213,8 +35966,8 @@ function parse(input, parseParams) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -36223,8 +35976,8 @@ function parse(input, parseParams) { //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -36258,20 +36011,18 @@ function parse(input, parseParams) { // // Note: epsilon rule's yylloc situation is detected by passing both \`first_index\` and \`first_yylloc\` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - "use strict"; - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -36282,7 +36033,7 @@ function parse(input, parseParams) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -36295,7 +36046,7 @@ function parse(input, parseParams) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -36307,29 +36058,27 @@ function parse(input, parseParams) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or \`dont_look_back\` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -36337,7 +36086,7 @@ function parse(input, parseParams) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -36357,9 +36106,7 @@ function parse(input, parseParams) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your \`lexer\`, \`sharedState\`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - "use strict"; - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -36368,10 +36115,10 @@ function parse(input, parseParams) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -36379,7 +36126,7 @@ function parse(input, parseParams) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -36396,10 +36143,8 @@ function parse(input, parseParams) { // info.value = null; // info.value_stack = null; // ... - "use strict"; - - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -36415,9 +36160,7 @@ function parse(input, parseParams) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - "use strict"; - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -36486,11 +36229,14 @@ function parse(input, parseParams) { // - root_failure_pointer: // copy of the \`stack_pointer\`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -36501,9 +36247,7 @@ function parse(input, parseParams) { }; function getNonTerminalFromCode(symbol) { - "use strict"; - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -36513,22 +36257,20 @@ function parse(input, parseParams) { //_lexer_without_token_stack: function stdLex() { - "use strict"; - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36538,22 +36280,20 @@ function parse(input, parseParams) { } function fastLex() { - "use strict"; - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36562,15 +36302,13 @@ function parse(input, parseParams) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; //_lexer_with_token_stack: // lex function that supports token stacks function tokenStackLex() { - "use strict"; - - var token; + let token; token = tstack.pop() || lexer.lex() || EOF; // if token isn't its numeric value, convert if (typeof token !== 'number') { @@ -36589,13 +36327,13 @@ function parse(input, parseParams) { } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36606,33 +36344,37 @@ function parse(input, parseParams) { //_lexer_with_token_stack_end: - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - "use strict"; - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { // check for error recovery rule in this state - if (yydebug) yydebug('locateNearestErrorRecoveryRule #test#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); - var t = (table[state] && table[state][TERROR]) || NO_ACTION; + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #test#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } + const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we \`yyerrok()\` an error, we must @@ -36647,12 +36389,24 @@ function parse(input, parseParams) { // terminate the parse in a controlled fashion even when we have // very complex error/recovery code interplay in the core + user // action code blocks: - if (yydebug) yydebug('locateNearestErrorRecoveryRule #found#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #found#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { - if (yydebug) yydebug('locateNearestErrorRecoveryRule #skip#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #skip#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; @@ -36662,14 +36416,26 @@ function parse(input, parseParams) { return depth; } if (state === 0 /* $accept rule */ || stack_probe < 1) { - if (yydebug) yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; } - if (yydebug) yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } return -1; // No suitable error recovery rule available. } @@ -36686,7 +36452,7 @@ function parse(input, parseParams) { // whether we'll go with the standard, slower, lex() API or the // \`fast_lex()\` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -36732,17 +36498,23 @@ function parse(input, parseParams) { newState = t[1]; action = t[0]; - if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('after FETCH/LEX: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol], + state, newState, recovering, action + }); + } //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules // handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -36769,7 +36541,13 @@ function parse(input, parseParams) { // invoke the parser's cleanup API! recoveringErrorInfo = this.shallowCopyErrorInfo(p); - if (yydebug) yydebug('error recovery rule detected: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p }); + if (yydebug) { + yydebug('error recovery rule detected: ', { + error_rule_depth, + error: p.errStr, + error_hash: p + }); + } r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { @@ -36787,9 +36565,15 @@ function parse(input, parseParams) { } } - if (yydebug) yydebug('after ERROR DETECT: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p }); + if (yydebug) { + yydebug('after ERROR DETECT: ', { + error_rule_depth, + error: p.errStr, + error_hash: p + }); + } - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -36809,17 +36593,22 @@ function parse(input, parseParams) { preErrorSymbol = 0; symbol = lex(); - if (yydebug) yydebug('after ERROR RECOVERY-3: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol] }); + if (yydebug) { + yydebug('after ERROR RECOVERY-3: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol] + }); + } } // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -36866,20 +36655,18 @@ function parse(input, parseParams) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; - if (yydebug) yydebug('Error recovery process: pushed error info item on the info stack: ', { - item: vstack[sp], - sp, - esp, - vstack, - stack, - sstack, - combineState: NO_ACTION[1] - }); + if (yydebug) { + yydebug('Error recovery process: pushed error info item on the info stack: ', { + item: vstack[sp], + sp, esp, vstack, stack, sstack, + combineState: NO_ACTION[1] + }); + } } else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), @@ -36898,11 +36685,17 @@ function parse(input, parseParams) { yyrulelen = error_rule_depth; - if (yydebug) yydebug('Error recovery process: performAction: COMBINE: ', { - yyval, yytext, sp, pop_size: yyrulelen, vstack, stack, sstack, - combineState: NO_ACTION[1] - }); - r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, NO_ACTION[1], sp - 1, yyrulelen, vstack, lstack, stack, sstack); + let combineState = NO_ACTION[1]; + + if (yydebug) { + yydebug('Error recovery process: performAction: COMBINE: ', { + yyval, yytext, sp, + pop_size: yyrulelen, + vstack, stack, sstack, + combineState + }); + } + r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, combineState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof r !== 'undefined') { retval = r; @@ -36913,7 +36706,7 @@ function parse(input, parseParams) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -36940,7 +36733,7 @@ function parse(input, parseParams) { // allow N (default: 3) real symbols to be shifted before reporting a new error recovering = ERROR_RECOVERY_TOKEN_DISCARD_COUNT; - if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth: error_rule_depth, symbol: symbol, preErrorSymbol: preErrorSymbol }); + if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth, symbol, preErrorSymbol }); // Now duplicate the standard parse machine here, at least its initial // couple of rounds until the TERROR symbol is **pushed onto the parse stack**, @@ -36966,10 +36759,10 @@ function parse(input, parseParams) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -36997,14 +36790,20 @@ function parse(input, parseParams) { newState = t[1]; action = t[0]; - if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('after FETCH/LEX: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol], + state, newState, recovering, action + }); + } // encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { if (yydebug) yydebug('**NESTED ERROR DETECTED** while still recovering from previous error'); - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the \`continue;\` @@ -37018,15 +36817,26 @@ function parse(input, parseParams) { } } - if (yydebug) yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) { - "use strict"; - - if (!nt || !nt.states || !nt.rules) - return ''; - var rulename = nt.states[state]; - var rulespec = nt.rules[rulename][state]; - return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; - })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' + + (action === 1 ? + 'shift token ' + symbol + ' (then go to state ' + newState + ')' : + action === 2 ? + 'reduce by rule: ' + newState + (function __print_rule(nt, state) { + if (!nt || !nt.states || !nt.rules) { + return ''; + } + let rulename = nt.states[state]; + let rulespec = nt.rules[rulename][state]; + return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; + })(this.nonterminals_, newState) : + action === 3 ? + 'accept' : + '???unexpected???' + ), { + action, newState, recovering, symbol + }); + } switch (action) { // catch misc. parse failures: @@ -37050,12 +36860,12 @@ function parse(input, parseParams) { // Push a special value onto the stack when we're // shifting the \`error\` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -37064,7 +36874,7 @@ function parse(input, parseParams) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -37093,14 +36903,14 @@ function parse(input, parseParams) { if (recovering > 0) { recovering--; - if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering, symbol }); } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; - if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering, symbol }); // read action for current state and first input t = (table[newState] && table[newState][symbol]) || NO_ACTION; if (!t[0] || symbol === TERROR) { @@ -37112,7 +36922,7 @@ function parse(input, parseParams) { // recovery, for then this we would we idling (cycling) on the error forever. // Yes, this does not take into account the possibility that the *lexer* may have // produced a *new* TERROR token all by itself, but that would be a very peculiar grammar! - if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering, symbol }); symbol = 0; } } @@ -37128,7 +36938,7 @@ function parse(input, parseParams) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -37139,21 +36949,26 @@ function parse(input, parseParams) { this_production = this.productions_[newState - 1]; // \`this.productions_[]\` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; - if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('~~~ REDUCE: ', { + pop_size: yyrulelen, + newState, recovering, symbol + }); + } r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -37187,15 +37002,17 @@ function parse(input, parseParams) { sp -= yyrulelen; // don't overwrite the \`symbol\` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; - if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol }); + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol }); + } continue; // accept: @@ -37247,7 +37064,7 @@ function parse(input, parseParams) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the \`switch/default\` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -37257,9 +37074,9 @@ function parse(input, parseParams) { // handle parse error if (!action) { - var errStr; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let errStr; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); // Report error errStr = 'Parse error'; @@ -37290,15 +37107,26 @@ function parse(input, parseParams) { } - if (yydebug) yydebug('::: MAIN CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) { - "use strict"; - - if (!nt || !nt.states || !nt.rules) - return ''; - var rulename = nt.states[state]; - var rulespec = nt.rules[rulename][state]; - return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; - })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('::: MAIN CYCLE action: ' + + (action === 1 ? + 'shift token ' + symbol + ' (then go to state ' + newState + ')' : + action === 2 ? + 'reduce by rule: ' + newState + (function __print_rule(nt, state) { + if (!nt || !nt.states || !nt.rules) { + return ''; + } + let rulename = nt.states[state]; + let rulespec = nt.rules[rulename][state]; + return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; + })(this.nonterminals_, newState) : + action === 3 ? + 'accept' : + '???unexpected???' + ), { + action, newState, recovering, symbol + }); + } switch (action) { // catch misc. parse failures: @@ -37329,7 +37157,7 @@ function parse(input, parseParams) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -37346,8 +37174,8 @@ function parse(input, parseParams) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyleng = lexer.yyleng; @@ -37358,27 +37186,32 @@ function parse(input, parseParams) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // \`this.productions_[]\` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; - if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('~~~ REDUCE: ', { + pop_size: yyrulelen, + newState, recovering, symbol + }); + } r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -37409,15 +37242,17 @@ function parse(input, parseParams) { sp -= yyrulelen; // don't overwrite the \`symbol\` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; - if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol }); + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol }); + } continue; // accept: @@ -37470,8 +37305,7 @@ function parse(input, parseParams) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -37504,30 +37338,30 @@ function parse(input, parseParams) { * LR(0) Parser */ -var lr0 = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { +const lr0 = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LR(0)', afterconstructor: function lr0_afterconstructor() { this.buildTable(); } }); -var LR0Generator = Jison$1.LR0Generator = lr0.construct(); +const LR0Generator = Jison$1.LR0Generator = lr0.construct(); /* * Simple LALR(1) */ -var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { +const lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LALR(1)', afterconstructor: function lalr_afterconstructor() { - var self = this; + let self = this; if (this.DEBUG) { this.mix(lrGeneratorDebug, lalrGeneratorDebug); // mixin debug methods } - for (var round = 1; /* infinite loop if it weren't for the `break`s at the end */ ; round++) { + for (let round = 1; /* infinite loop if it weren't for the `break`s at the end */ ; round++) { this.states = this.canonicalCollection(); if (this.DEBUG || devDebug) { @@ -37538,13 +37372,13 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { this.terms_ = {}; - var newg = this.newg = typal.beget(lookaheadMixin, { + let newg = this.newg = typal.beget(lookaheadMixin, { oldg: this, trace: this.trace, nterms_: {}, DEBUG: false, go_: function (productionSymbol, productionHandle) { - var stateNum = productionSymbol.split(':')[0]; // grab state # + let stateNum = productionSymbol.split(':')[0]; // grab state # assert$1(stateNum == +stateNum); stateNum = +stateNum; productionHandle = productionHandle.map(function (rhsElem) { @@ -37581,8 +37415,8 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { // backprop `nullable` value for each nonterminal and production back to original grammar: each(newg.nonterminals, function (newg_nt, t) { // extract original symbol: - var sym; - var a = newg_nt.symbol.split(':'); + let sym; + let a = newg_nt.symbol.split(':'); if (a.length === 1 || a[0] === '') { sym = newg_nt.symbol; } else { @@ -37657,8 +37491,8 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { go: function LALR_go(stateNum, productionHandle, productionSymbol) { assert$1(typeof stateNum === 'number'); - var endStateNum = stateNum; - for (var i = 0; i < productionHandle.length; i++) { + let endStateNum = stateNum; + for (let i = 0; i < productionHandle.length; i++) { endStateNum = this.states.item(endStateNum).edges[productionHandle[i]] || endStateNum; } return endStateNum; @@ -37666,10 +37500,10 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { goPath: function LALR_goPath(stateNum, productionHandle, productionSymbol) { assert$1(typeof stateNum === 'number'); - var endStateNum = stateNum, - t, - path = []; - for (var i = 0; i < productionHandle.length; i++) { + let endStateNum = stateNum, + t, + path = []; + for (let i = 0; i < productionHandle.length; i++) { t = productionHandle[i] ? endStateNum + ':' + productionHandle[i] /* + ':' + productionSymbol */ : ''; if (t) { this.newg.nterms_[t] = endStateNum; @@ -37687,34 +37521,34 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { // every disjoint reduction of a nonterminal becomes a production in G' buildNewGrammar: function LALR_buildNewGrammar() { - var self = this, - newg = this.newg; + let self = this, + newg = this.newg; this.states.forEach(function (state, i) { i = +i; state.forEach(function LALR_buildNewHandle(item) { if (item.dotPosition === 0) { // new symbols are a combination of state and transition symbol - var symbol = i + ':' + item.production.symbol; + let symbol = i + ':' + item.production.symbol; assert$1(typeof self.terms_[symbol] === 'undefined' || self.terms_[symbol] === item.production.symbol); self.terms_[symbol] = item.production.symbol; newg.nterms_[symbol] = i; if (!newg.nonterminals[symbol]) { newg.nonterminals[symbol] = new Nonterminal(symbol); } - var pathInfo = self.goPath(i, item.production.handle, item.production.symbol); - var p = new Production(symbol, pathInfo.path, newg.productions.length); + let pathInfo = self.goPath(i, item.production.handle, item.production.symbol); + let p = new Production(symbol, pathInfo.path, newg.productions.length); newg.productions.push(p); newg.nonterminals[symbol].productions.push(p); // store the transition that gets 'backed up to' after reduction on path - var handle = item.production.handle.join(' '); + let handle = item.production.handle.join(' '); if (self.conflict_fixing_round && self.conflict_states_LU[i]) ; if (self.conflict_fixing_round && self.conflict_productions_LU[item.production.id]) { handle += ':P' + item.production.id; } - var goes = self.states.item(pathInfo.endState).goes; + let goes = self.states.item(pathInfo.endState).goes; if (!goes[handle]) { goes[handle] = []; } @@ -37728,22 +37562,22 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { }, unionLookaheads: function LALR_unionLookaheads() { - var self = this, - newg = this.newg; - // var states = !!this.onDemandLookahead ? this.inadequateStates : this.states; + let self = this, + newg = this.newg; + // let states = !!this.onDemandLookahead ? this.inadequateStates : this.states; - var these_states = this.states; + let these_states = this.states; these_states.forEach(function union_states_forEach(state, i) { i = +i; //assert(state.inadequate ? these_states.inadequate : true); - var treat_me = (self.onDemandLookahead ? these_states.inadequate || state.inadequate : true); + let treat_me = (self.onDemandLookahead ? these_states.inadequate || state.inadequate : true); if (state.reductions.length && treat_me) { state.reductions.forEach(function union_reduction_forEach(item) { - var follows = {}; - for (var k = 0; k < item.follows.length; k++) { + let follows = {}; + for (let k = 0; k < item.follows.length; k++) { follows[item.follows[k]] = true; } - var handle = item.production.handle.join(' '); + let handle = item.production.handle.join(' '); if (self.conflict_fixing_round && self.conflict_states_LU[i]) ; if (self.conflict_fixing_round && self.conflict_productions_LU[item.production.id]) { handle += ':P' + item.production.id; @@ -37754,7 +37588,7 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { state.goes[handle].forEach(function reduction_goes_forEach(symbol) { newg.nonterminals[symbol].follows.forEach(function goes_follows_forEach(symbol) { - var terminal = self.terms_[symbol]; + let terminal = self.terms_[symbol]; if (!follows[terminal]) { follows[terminal] = true; @@ -37768,11 +37602,11 @@ var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { } }); -var LALRGenerator = Jison$1.LALRGenerator = lalr.construct(); +const LALRGenerator = Jison$1.LALRGenerator = lalr.construct(); // LALR generator debug mixin -var lalrGeneratorDebug = { +const lalrGeneratorDebug = { beforebuildNewGrammar: function () { this.trace(this.states.size() + ' states.'); this.trace('Building lookahead grammar.'); @@ -37789,7 +37623,7 @@ var lalrGeneratorDebug = { aftercomputeLookaheads: function () { traceStates(this.trace, this.states, 'after LALR::computeLookaheads()'); }, - aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */ ) { + aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */) { traceStates(this.trace, states, 'as produced by LALR::canonicalCollection()'); } }; @@ -37799,7 +37633,7 @@ var lalrGeneratorDebug = { * * Define base type */ -var lrLookaheadGenerator = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { +const lrLookaheadGenerator = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { afterconstructor: function lr_aftercontructor() { this.computeLookaheads(); @@ -37816,7 +37650,7 @@ var lrLookaheadGenerator = generator.beget(lookaheadMixin, generatorMixin, lrGen /* * SLR Parser */ -var SLRGenerator = Jison$1.SLRGenerator = lrLookaheadGenerator.construct({ +const SLRGenerator = Jison$1.SLRGenerator = lrLookaheadGenerator.construct({ type: 'SLR(1)', lookAheads: function SLR_lookAhead(state, item) { @@ -37828,7 +37662,7 @@ var SLRGenerator = Jison$1.SLRGenerator = lrLookaheadGenerator.construct({ /* * LR(1) Parser */ -var lr1 = lrLookaheadGenerator.beget({ +const lr1 = lrLookaheadGenerator.beget({ type: 'Canonical LR(1)', lookAheads: function LR_lookAheads(state, item) { @@ -37845,28 +37679,26 @@ var lr1 = lrLookaheadGenerator.beget({ }), closureOperation: function LR_ClosureOperation(itemSet) { - var closureSet = new this.ItemSet(); - var self = this; + let closureSet = new this.ItemSet(); + let self = this; - var set = itemSet, - itemQueue; + let set = itemSet; do { - itemQueue = new Set(); + let itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function LR_AddItemToClosureSets(item) { - var symbol = item.markedSymbol; - var b, r; + let symbol = item.markedSymbol; // if token is a nonterminal, recursively add closures if (symbol && self.nonterminals[symbol]) { - r = item.remainingHandle(); - b = self.first(r); + let r = item.remainingHandle(); + let b = self.first(r); if (b.length === 0 || item.production.nullable || self.nullable(r)) { b = b.concat(item.follows); } self.nonterminals[symbol].productions.forEach(function (production) { - var newItem = new self.Item(production, 0, b); + let newItem = new self.Item(production, 0, b); if (!closureSet.contains(newItem) && !itemQueue.contains(newItem)) { itemQueue.push(newItem); } @@ -37878,18 +37710,18 @@ var lr1 = lrLookaheadGenerator.beget({ }); set = itemQueue; - } while (!itemQueue.isEmpty()); + } while (!set.isEmpty()); return closureSet; } }); -var LR1Generator = Jison$1.LR1Generator = lr1.construct(); +const LR1Generator = Jison$1.LR1Generator = lr1.construct(); /* * LL Parser */ -var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { +const ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LL(1)', afterconstructor: function ll_aftercontructor() { @@ -37912,13 +37744,13 @@ var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { }, parseTable: function ll_ParseTable(productions) { - var table = {}, - symbols_ = this.symbols_, - self = this; + let table = {}; + let symbols_ = this.symbols_; + let self = this; productions.forEach(function (production, i) { - var row = table[production.symbol] || {}; - var tokens = production.first; + let row = table[production.symbol] || {}; + let tokens = production.first; if (self.nullable(production.handle)) { tokens = union(tokens, self.nonterminals[production.symbol].follows); } @@ -37927,7 +37759,7 @@ var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { row[token].push(i); self.conflicts++; } else { - row[token] = [i]; + row[token] = [ i ]; } }); table[production.symbol] = row; @@ -37938,16 +37770,16 @@ var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { } }); -var LLGenerator = Jison$1.LLGenerator = ll.construct(); +const LLGenerator = Jison$1.LLGenerator = ll.construct(); Jison$1.Generator = function Jison_Generator(grammar, optionalLexerSection, options) { // pick the correct argument for the `options` for this call: if (!options && optionalLexerSection && typeof optionalLexerSection !== 'string') { - options = optionalLexerSection; - optionalLexerSection = null; + options = optionalLexerSection; + optionalLexerSection = null; } // and standardize it: - var preliminary_options = mkStdOptions$1(options); + let preliminary_options = mkStdOptions$1(options); // Provisionally parse the grammar, really only to obtain the *options.type* // specified within the grammar, if specified (via `%parser-type`). @@ -37969,7 +37801,7 @@ Jison$1.Generator = function Jison_Generator(grammar, optionalLexerSection, opti // // Anyway, API/CLI options **override** options coming in from the grammar spec. // - options = mkStdOptions$1("NODEFAULT", grammar.options, options); + options = mkStdOptions$1('NODEFAULT', grammar.options, options); switch (options.type || Jison$1.defaultJisonOptions.type) { case 'lr0': options.hasPartialLrUpgradeOnConflict = false; // kill this unsupported option @@ -37995,10 +37827,24 @@ Jison$1.Generator = function Jison_Generator(grammar, optionalLexerSection, opti }; function Parser$3(g, l, options) { - var gen = Jison$1.Generator(g, l, options); + let gen = Jison$1.Generator(g, l, options); return gen.createParser(); } Jison$1.Parser = Parser$3; +// exports for unit/system testing purposes: +Jison$1.TestExports = { + lookaheadMixin, generatorMixin, lrGeneratorMixin, + lalr, + lr0, + lr1, + ll, + parser: parser$4, + pickErrorHandlingChunk, + addOrRemoveTokenStack, + removeUnusedKernelFeatures, + expandParseArguments +}; + export default Jison$1; diff --git a/dist/jison-umd-es5.js b/dist/jison-umd-es5.js index 2ea92cf94..01c555673 100644 --- a/dist/jison-umd-es5.js +++ b/dist/jison-umd-es5.js @@ -1,7 +1,17 @@ "use strict"; +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 "]); + + _templateObject162 = function _templateObject162() { + return data; + }; + + return data; +} + function _templateObject161() { - var data = _taggedTemplateLiteral(["\n ", "\n\n var 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 var 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 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 "]); _templateObject161 = function _templateObject161() { return data; @@ -11,7 +21,7 @@ function _templateObject161() { } function _templateObject160() { - 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\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 "]); _templateObject160 = function _templateObject160() { return data; @@ -21,7 +31,7 @@ function _templateObject160() { } function _templateObject159() { - 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 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 "]); _templateObject159 = function _templateObject159() { return data; @@ -31,7 +41,7 @@ function _templateObject159() { } function _templateObject158() { - 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 // 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 "]); _templateObject158 = function _templateObject158() { return data; @@ -41,7 +51,7 @@ function _templateObject158() { } function _templateObject157() { - 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 ", "\n\n let yymain = ", ";\n\n function yyExecMain() {\n yymain(process.argv.slice(1));\n }\n "]); _templateObject157 = function _templateObject157() { return data; @@ -51,7 +61,7 @@ function _templateObject157() { } function _templateObject156() { - var data = _taggedTemplateLiteral(["\n\n ", "\n\n var yymain = ", ";\n\n function yyExecMain() {\n yymain(process.argv.slice(1));\n }\n "]); + var data = _taggedTemplateLiteral(["\n\n // START code section \"", "\"\n ", "\n // END code section \"", "\"\n\n "]); _templateObject156 = function _templateObject156() { return data; @@ -61,7 +71,7 @@ function _templateObject156() { } function _templateObject155() { - var data = _taggedTemplateLiteral(["\n\n // START code section \"", "\"\n ", "\n // END code section \"", "\"\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 "]); _templateObject155 = function _templateObject155() { return data; @@ -71,7 +81,7 @@ function _templateObject155() { } function _templateObject154() { - 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 %%\n\n "]); _templateObject154 = function _templateObject154() { return data; @@ -81,7 +91,7 @@ function _templateObject154() { } function _templateObject153() { - var data = _taggedTemplateLiteral(["\n\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 "]); _templateObject153 = function _templateObject153() { return data; @@ -91,7 +101,7 @@ function _templateObject153() { } function _templateObject152() { - 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 %%\n\n "]); _templateObject152 = function _templateObject152() { return data; @@ -101,7 +111,7 @@ function _templateObject152() { } function _templateObject151() { - var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); + var data = _taggedTemplateLiteral(["\n /*\n * Parser stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); _templateObject151 = function _templateObject151() { return data; @@ -111,7 +121,7 @@ function _templateObject151() { } function _templateObject150() { - var data = _taggedTemplateLiteral(["\n /*\n * Parser stuff that's unknown to the JISON prettyPrint service:\n *\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 "]); _templateObject150 = function _templateObject150() { return data; @@ -121,7 +131,7 @@ function _templateObject150() { } function _templateObject149() { - 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 // END of unknown declarations.\n "]); _templateObject149 = function _templateObject149() { return data; @@ -131,7 +141,7 @@ function _templateObject149() { } function _templateObject148() { - var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); + var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); _templateObject148 = function _templateObject148() { return data; @@ -141,7 +151,7 @@ function _templateObject148() { } function _templateObject147() { - var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); + var data = _taggedTemplateLiteral(["\n\n %%\n\n "]); _templateObject147 = function _templateObject147() { return data; @@ -161,7 +171,7 @@ function _templateObject146() { } function _templateObject145() { - 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 "]); _templateObject145 = function _templateObject145() { return data; @@ -171,7 +181,7 @@ function _templateObject145() { } function _templateObject144() { - var data = _taggedTemplateLiteral(["\n /*\n * Lexer stuff that's unknown to the JISON prettyPrint service:\n *\n * ", "\n */\n \n "]); + var data = _taggedTemplateLiteral(["\n // options:\n "]); _templateObject144 = function _templateObject144() { return data; @@ -181,7 +191,7 @@ function _templateObject144() { } function _templateObject143() { - var data = _taggedTemplateLiteral(["\n // options:\n "]); + var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); _templateObject143 = function _templateObject143() { return data; @@ -191,7 +201,7 @@ function _templateObject143() { } function _templateObject142() { - var data = _taggedTemplateLiteral(["\n // END of unknown declarations.\n "]); + var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); _templateObject142 = function _templateObject142() { return data; @@ -201,7 +211,7 @@ function _templateObject142() { } function _templateObject141() { - var data = _taggedTemplateLiteral(["\n // unknown declarations:\n "]); + var data = _taggedTemplateLiteral(["\n // END of the lexer macros.\n "]); _templateObject141 = function _templateObject141() { return data; @@ -211,7 +221,7 @@ function _templateObject141() { } function _templateObject140() { - var data = _taggedTemplateLiteral(["\n // END of the lexer macros.\n "]); + var data = _taggedTemplateLiteral(["\n // macros:\n "]); _templateObject140 = function _templateObject140() { return data; @@ -221,7 +231,7 @@ function _templateObject140() { } function _templateObject139() { - var data = _taggedTemplateLiteral(["\n // macros:\n "]); + var data = _taggedTemplateLiteral(["\n unsupported parser input: ", "\n while lexing in ", " state.\n \n Erroneous area:\n "]); _templateObject139 = function _templateObject139() { return data; @@ -231,7 +241,7 @@ function _templateObject139() { } function _templateObject138() { - 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 "]); _templateObject138 = function _templateObject138() { return data; @@ -261,7 +271,7 @@ function _templateObject136() { } function _templateObject135() { - 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 "]); _templateObject135 = function _templateObject135() { return data; @@ -291,7 +301,7 @@ function _templateObject133() { } function _templateObject132() { - 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 "]); _templateObject132 = function _templateObject132() { return data; @@ -321,7 +331,7 @@ function _templateObject130() { } function _templateObject129() { - 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 "]); _templateObject129 = function _templateObject129() { return data; @@ -331,7 +341,7 @@ function _templateObject129() { } function _templateObject128() { - var data = _taggedTemplateLiteral(["\n EBNF: ignoring unsupported parser option ", "\n while lexing in ", " state.\n\n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n module code declaration error?\n \n Erroneous area:\n "]); _templateObject128 = function _templateObject128() { return data; @@ -341,7 +351,7 @@ function _templateObject128() { } function _templateObject127() { - var data = _taggedTemplateLiteral(["\n module code declaration error?\n \n Erroneous area:\n "]); + var data = _taggedTemplateLiteral(["\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n "]); _templateObject127 = function _templateObject127() { return data; @@ -351,7 +361,7 @@ function _templateObject127() { } function _templateObject126() { - var data = _taggedTemplateLiteral(["\n %include MUST be followed by a valid file path.\n \n Erroneous path:\n "]); + var data = _taggedTemplateLiteral(["\n included action code file \"", "\" does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject126 = function _templateObject126() { return data; @@ -361,7 +371,7 @@ function _templateObject126() { } function _templateObject125() { - 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 match curly braces '{ ... }' in a parser rule action block.\n \n Erroneous area:\n ", "\n "]); _templateObject125 = function _templateObject125() { return data; @@ -371,7 +381,7 @@ function _templateObject125() { } function _templateObject124() { - 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 Seems you did not correctly bracket a parser rule action block in curly braces: '{ ... }'.\n \n Erroneous area:\n ", "\n "]); _templateObject124 = function _templateObject124() { return data; @@ -381,7 +391,7 @@ function _templateObject124() { } function _templateObject123() { - 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 %prec precedence override declaration error?\n \n Erroneous precedence declaration:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject123 = function _templateObject123() { return data; @@ -391,7 +401,7 @@ function _templateObject123() { } function _templateObject122() { - 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 Seems you did not correctly bracket a grammar rule sublist in '( ... )' brackets.\n \n Erroneous area:\n ", "\n "]); _templateObject122 = function _templateObject122() { return data; @@ -401,7 +411,7 @@ function _templateObject122() { } function _templateObject121() { - 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 rule action declaration error?\n \n Erroneous area:\n ", "\n "]); _templateObject121 = function _templateObject121() { return data; @@ -411,7 +421,7 @@ function _templateObject121() { } function _templateObject120() { - 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 "]); _templateObject120 = function _templateObject120() { return data; @@ -421,7 +431,7 @@ function _templateObject120() { } function _templateObject119() { - 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 "]); _templateObject119 = function _templateObject119() { return data; @@ -431,7 +441,7 @@ function _templateObject119() { } function _templateObject118() { - 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 action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject118 = function _templateObject118() { return data; @@ -441,7 +451,7 @@ function _templateObject118() { } function _templateObject117() { - var data = _taggedTemplateLiteral(["\n production rule action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n multiple alternative rule productions should be separated by a '|' pipe character, not a ':' colon!\n \n Erroneous area:\n ", "\n "]); _templateObject117 = function _templateObject117() { return data; @@ -451,7 +461,7 @@ function _templateObject117() { } function _templateObject116() { - var data = _taggedTemplateLiteral(["\n multiple alternative rule productions should be separated by a '|' pipe character, not a ':' colon!\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n rule alternative production declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject116 = function _templateObject116() { return data; @@ -461,7 +471,7 @@ function _templateObject116() { } function _templateObject115() { - var data = _taggedTemplateLiteral(["\n rule alternative production declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Production for rule '", "' is missing: arrows introduce action code in Jison.\n \n Jison does not support rule production definition using arrows (->, =>, \u2192) but expects\n colons (:) instead, so maybe you intended this:\n \n ", " : ", "\n \n while the user-defined action code block MAY be an arrow function, e.g.\n \n rule: math_production -> Math.min($math_production, 42);\n \n Erroneous area:\n ", "\n "]); _templateObject115 = function _templateObject115() { return data; @@ -471,7 +481,7 @@ function _templateObject115() { } function _templateObject114() { - var data = _taggedTemplateLiteral(["\n Production for rule '", "' is missing: arrows introduce action code in Jison.\n \n Jison does not support rule production definition using arrows (->, =>, \u2192) but expects\n colons (:) instead, so maybe you intended this:\n \n ", " : ", "\n \n while the user-defined action code block MAY be an arrow function, e.g.\n \n rule: math_production -> Math.min($math_production, 42);\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n rule id should be followed by a colon, but that one seems missing?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject114 = function _templateObject114() { return data; @@ -481,7 +491,7 @@ function _templateObject114() { } function _templateObject113() { - var data = _taggedTemplateLiteral(["\n rule id should be followed by a colon, but that one seems missing?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n rule production declaration error: did you terminate the rule production set with a semicolon?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject113 = function _templateObject113() { return data; @@ -491,7 +501,7 @@ function _templateObject113() { } function _templateObject112() { - var data = _taggedTemplateLiteral(["\n rule production declaration error: did you terminate the rule production set with a semicolon?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n rule production declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject112 = function _templateObject112() { return data; @@ -501,7 +511,7 @@ function _templateObject112() { } function _templateObject111() { - var data = _taggedTemplateLiteral(["\n rule production declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n operator token list error in an associativity statement?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject111 = function _templateObject111() { return data; @@ -511,7 +521,7 @@ function _templateObject111() { } function _templateObject110() { - var data = _taggedTemplateLiteral(["\n operator token list error in an associativity statement?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %parser-type declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject110 = function _templateObject110() { return data; @@ -521,7 +531,7 @@ function _templateObject110() { } function _templateObject109() { - var data = _taggedTemplateLiteral(["\n %parser-type declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %parse-params declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject109 = function _templateObject109() { return data; @@ -531,7 +541,7 @@ function _templateObject109() { } function _templateObject108() { - var data = _taggedTemplateLiteral(["\n %parse-params declaration error?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n named %option value assignment error?\n \n Erroneous area:\n ", "\n "]); _templateObject108 = function _templateObject108() { return data; @@ -541,7 +551,7 @@ function _templateObject108() { } function _templateObject107() { - var data = _taggedTemplateLiteral(["\n named %option value assignment error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n named %option value error for ", "?\n \n Erroneous area:\n ", "\n "]); _templateObject107 = function _templateObject107() { return data; @@ -551,7 +561,7 @@ function _templateObject107() { } function _templateObject106() { - var data = _taggedTemplateLiteral(["\n named %option value error for ", "?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %options don't seem terminated?\n \n Erroneous area:\n ", "\n "]); _templateObject106 = function _templateObject106() { return data; @@ -561,7 +571,7 @@ function _templateObject106() { } function _templateObject105() { - var data = _taggedTemplateLiteral(["\n %options don't seem terminated?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %options ill defined / error?\n \n Erroneous area:\n ", "\n "]); _templateObject105 = function _templateObject105() { return data; @@ -571,7 +581,7 @@ function _templateObject105() { } function _templateObject104() { - var data = _taggedTemplateLiteral(["\n %options ill defined / error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %import name or source filename missing maybe?\n \n Erroneous area:\n ", "\n "]); _templateObject104 = function _templateObject104() { return data; @@ -581,7 +591,7 @@ function _templateObject104() { } function _templateObject103() { - var data = _taggedTemplateLiteral(["\n %import name or source filename missing maybe?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %token definition list error?\n \n Erroneous area:\n ", "\n "]); _templateObject103 = function _templateObject103() { return data; @@ -591,7 +601,7 @@ function _templateObject103() { } function _templateObject102() { - var data = _taggedTemplateLiteral(["\n %token definition list error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %start token error?\n \n Erroneous area:\n ", "\n "]); _templateObject102 = function _templateObject102() { return data; @@ -601,7 +611,7 @@ function _templateObject102() { } function _templateObject101() { - var data = _taggedTemplateLiteral(["\n %start token error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Each '%code' initialization code section must be qualified by a name, e.g. 'required' before the action code itself:\n \n %code qualifier_name {action code}\n \n Erroneous area:\n ", "\n "]); _templateObject101 = function _templateObject101() { return data; @@ -611,7 +621,7 @@ function _templateObject101() { } function _templateObject100() { - var data = _taggedTemplateLiteral(["\n Each '%code' initialization code section must be qualified by a name, e.g. 'required' before the action code itself:\n \n %code qualifier_name {action code}\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n %code \"", "\" initialization section action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject100 = function _templateObject100() { return data; @@ -621,7 +631,7 @@ function _templateObject100() { } function _templateObject99() { - var data = _taggedTemplateLiteral(["\n %code \"", "\" initialization section action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Each '%import'-ed initialization code section must be qualified by a name, e.g. 'required' before the import path itself:\n \n %import qualifier_name file_path\n \n Erroneous area:\n ", "\n "]); _templateObject99 = function _templateObject99() { return data; @@ -631,7 +641,7 @@ function _templateObject99() { } function _templateObject98() { - var data = _taggedTemplateLiteral(["\n Each '%import'-ed initialization code section must be qualified by a name, e.g. 'required' before the import path itself:\n \n %import qualifier_name file_path\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n You did not specify a legal file path for the '%import' initialization code statement, which must have the format:\n \n %import qualifier_name file_path\n \n Erroneous area:\n ", "\n "]); _templateObject98 = function _templateObject98() { return data; @@ -641,7 +651,7 @@ function _templateObject98() { } function _templateObject97() { - var data = _taggedTemplateLiteral(["\n You did not specify a legal file path for the '%import' initialization code statement, which must have the format:\n \n %import qualifier_name file_path\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n action header code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject97 = function _templateObject97() { return data; @@ -651,7 +661,7 @@ function _templateObject97() { } function _templateObject96() { - var data = _taggedTemplateLiteral(["\n action header code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject96 = function _templateObject96() { return data; @@ -661,7 +671,7 @@ function _templateObject96() { } function _templateObject95() { - var data = _taggedTemplateLiteral(["\n action code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n declaration list error?\n \n Erroneous area:\n ", "\n "]); _templateObject95 = function _templateObject95() { return data; @@ -671,7 +681,7 @@ function _templateObject95() { } function _templateObject94() { - var data = _taggedTemplateLiteral(["\n declaration list error?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n action header code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject94 = function _templateObject94() { return data; @@ -681,7 +691,7 @@ function _templateObject94() { } function _templateObject93() { - var data = _taggedTemplateLiteral(["\n action header code block does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n The extra parser module code section (a.k.a. 'epilogue') does not compile: ", "\n \n Erroneous area:\n ", "\n "]); _templateObject93 = function _templateObject93() { return data; @@ -691,7 +701,7 @@ function _templateObject93() { } function _templateObject92() { - var data = _taggedTemplateLiteral(["\n The extra parser module code section (a.k.a. 'epilogue') does not compile: ", "\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n Maybe you did not correctly separate the parse 'header section' (token definitions, options, lexer spec, etc.) from the grammar rule set with a '%%' on an otherwise empty line?\n \n Erroneous area:\n ", "\n "]); _templateObject92 = function _templateObject92() { return data; @@ -701,7 +711,7 @@ function _templateObject92() { } function _templateObject91() { - var data = _taggedTemplateLiteral(["\n Maybe you did not correctly separate the parse 'header section' (token definitions, options, lexer spec, etc.) from the grammar rule set with a '%%' on an otherwise empty line?\n \n Erroneous area:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n illegal input in the parser grammar productions definition section.\n \n Maybe you did not correctly separate trailing code from the grammar rule set with a '%%' marker on an otherwise empty line?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); _templateObject91 = function _templateObject91() { return data; @@ -711,7 +721,7 @@ function _templateObject91() { } function _templateObject90() { - var data = _taggedTemplateLiteral(["\n illegal input in the parser grammar productions definition section.\n \n Maybe you did not correctly separate trailing code from the grammar rule set with a '%%' marker on an otherwise empty line?\n \n Erroneous area:\n ", "\n \n Technical error report:\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n ", "\n\n var ", " = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n\n if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\n exports.lexer = ", ";\n exports.lex = function () {\n return ", ".lex.apply(lexer, arguments);\n };\n }\n "]); _templateObject90 = function _templateObject90() { return data; @@ -721,7 +731,7 @@ function _templateObject90() { } function _templateObject89() { - var data = _taggedTemplateLiteral(["\n ", "\n\n var ", " = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n\n if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\n exports.lexer = ", ";\n exports.lex = function () {\n return ", ".lex.apply(lexer, arguments);\n };\n }\n "]); + var data = _taggedTemplateLiteral(["\n ", "\n\n const lexer = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n\n function yylex() {\n return lexer.lex.apply(lexer, arguments);\n }\n\n export {\n lexer,\n yylex as lex\n };\n "]); _templateObject89 = function _templateObject89() { return data; @@ -731,7 +741,7 @@ function _templateObject89() { } function _templateObject88() { - var data = _taggedTemplateLiteral(["\n ", "\n\n var lexer = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n\n function yylex() {\n return lexer.lex.apply(lexer, arguments);\n }\n\n export {\n lexer,\n yylex as lex\n };\n "]); + var data = _taggedTemplateLiteral(["\n ", "\n\n define([], function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n });\n "]); _templateObject88 = function _templateObject88() { return data; @@ -741,7 +751,7 @@ function _templateObject88() { } function _templateObject87() { - var data = _taggedTemplateLiteral(["\n ", "\n\n define([], function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n });\n "]); + var data = _taggedTemplateLiteral(["\n ", "\n\n var ", " = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n "]); _templateObject87 = function _templateObject87() { return data; @@ -751,7 +761,7 @@ function _templateObject87() { } function _templateObject86() { - var data = _taggedTemplateLiteral(["\n ", "\n\n var ", " = (function () {\n \"use strict\";\n\n ", "\n\n ", "\n\n ", "\n\n return lexer;\n })();\n "]); + var data = _taggedTemplateLiteral(["\n /* lexer generated by jison-lex ", " */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" `yy` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This \"shared context\" object was passed to the lexer by way of\n * the `lexer.setInput(str, yy)` API before you may use it.\n *\n * This \"shared context\" object is passed to the lexer action code in `performAction()`\n * so userland code in the lexer actions may communicate with the outside world\n * and/or other lexer rules' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall \"shared context\" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `lexer` instance.\n * `yy_` is an alias for `this` lexer instance reference used internally.\n *\n * - `yy` : a reference to the `yy` \"shared state\" object which was passed to the lexer\n * by way of the `lexer.setInput(str, yy)` API before.\n *\n * Note:\n * The extra arguments you specified in the `%parse-param` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - `yyrulenumber` : index of the matched lexer rule (regex), used internally.\n *\n * - `YY_START`: the current lexer \"start condition\" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.\n * See it's use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo('fail!', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the `lexer.setInput()` API.\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of the **lexer** grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Lexer's additional `args...` parameters (via lexer's `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the **parser** or the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.\n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (`yylloc`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a 'hash' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal \"shared state\" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while `this` will reference the current lexer instance.\n *\n * When `parseError` is invoked by the lexer, the default implementation will\n * attempt to invoke `yy.parser.parseError()`; when this callback is not provided\n * it will try to invoke `yy.parseError()` instead. When that callback is also not\n * provided, a `JisonLexerError` exception will be thrown containing the error\n * message and `hash`, as constructed by the `constructLexErrorInfo()` API.\n *\n * Note that the lexer's `JisonLexerError` error class is passed via the\n * `ExceptionClass` argument, which is invoked to construct the exception\n * instance to be thrown, so technically `parseError` will throw the object\n * produced by the `new ExceptionClass(str, hash)` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the `.options` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n *\n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are \"extended regex format\" requiring the\n * `XRegExp` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n "], ["\n /* lexer generated by jison-lex ", " */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" \\`yy\\` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This \"shared context\" object was passed to the lexer by way of\n * the \\`lexer.setInput(str, yy)\\` API before you may use it.\n *\n * This \"shared context\" object is passed to the lexer action code in \\`performAction()\\`\n * so userland code in the lexer actions may communicate with the outside world\n * and/or other lexer rules' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall \"shared context\" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and \\`this\\` have the following value/meaning:\n * - \\`this\\` : reference to the \\`lexer\\` instance.\n * \\`yy_\\` is an alias for \\`this\\` lexer instance reference used internally.\n *\n * - \\`yy\\` : a reference to the \\`yy\\` \"shared state\" object which was passed to the lexer\n * by way of the \\`lexer.setInput(str, yy)\\` API before.\n *\n * Note:\n * The extra arguments you specified in the \\`%parse-param\\` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - \\`yyrulenumber\\` : index of the matched lexer rule (regex), used internally.\n *\n * - \\`YY_START\\`: the current lexer \"start condition\" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo \\'hash object\\' which can be passed into \\`parseError()\\`.\n * See it\\'s use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo(\\'fail!\\', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the \\`lexer.setInput()\\` API.\n * You MAY use the additional \\`args...\\` parameters as per \\`%parse-param\\` spec of the **lexer** grammar:\n * these extra \\`args...\\` are added verbatim to the \\`yy\\` object reference as member variables.\n *\n * WARNING:\n * Lexer's additional \\`args...\\` parameters (via lexer's \\`%parse-param\\`) MAY conflict with\n * any attributes already added to \\`yy\\` by the **parser** or the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.\n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (\\`yylloc\\`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The \\`parseError\\` function receives a \\'hash\\' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal \"shared state\" \\`yy\\`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while \\`this\\` will reference the current lexer instance.\n *\n * When \\`parseError\\` is invoked by the lexer, the default implementation will\n * attempt to invoke \\`yy.parser.parseError()\\`; when this callback is not provided\n * it will try to invoke \\`yy.parseError()\\` instead. When that callback is also not\n * provided, a \\`JisonLexerError\\` exception will be thrown containing the error\n * message and \\`hash\\`, as constructed by the \\`constructLexErrorInfo()\\` API.\n *\n * Note that the lexer\\'s \\`JisonLexerError\\` error class is passed via the\n * \\`ExceptionClass\\` argument, which is invoked to construct the exception\n * instance to be thrown, so technically \\`parseError\\` will throw the object\n * produced by the \\`new ExceptionClass(str, hash)\\` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the \\`.options\\` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n *\n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default \\`parseError\\` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * \\`this\\` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token \\`token\\`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original \\`token\\`.\n * \\`this\\` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: \\`true\\` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: \\`true\\` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: \\`true\\` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: \\`true\\` ==> lexer rule regexes are \"extended regex format\" requiring the\n * \\`XRegExp\\` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n "]); _templateObject86 = function _templateObject86() { return data; @@ -761,7 +771,7 @@ function _templateObject86() { } function _templateObject85() { - var data = _taggedTemplateLiteral(["\n /* lexer generated by jison-lex ", " */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" `yy` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This \"shared context\" object was passed to the lexer by way of\n * the `lexer.setInput(str, yy)` API before you may use it.\n *\n * This \"shared context\" object is passed to the lexer action code in `performAction()`\n * so userland code in the lexer actions may communicate with the outside world\n * and/or other lexer rules' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall \"shared context\" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `lexer` instance.\n * `yy_` is an alias for `this` lexer instance reference used internally.\n *\n * - `yy` : a reference to the `yy` \"shared state\" object which was passed to the lexer\n * by way of the `lexer.setInput(str, yy)` API before.\n *\n * Note:\n * The extra arguments you specified in the `%parse-param` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - `yyrulenumber` : index of the matched lexer rule (regex), used internally.\n *\n * - `YY_START`: the current lexer \"start condition\" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.\n * See it's use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo('fail!', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the `lexer.setInput()` API.\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of the **lexer** grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Lexer's additional `args...` parameters (via lexer's `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the **parser** or the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.\n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (`yylloc`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a 'hash' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal \"shared state\" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while `this` will reference the current lexer instance.\n *\n * When `parseError` is invoked by the lexer, the default implementation will\n * attempt to invoke `yy.parser.parseError()`; when this callback is not provided\n * it will try to invoke `yy.parseError()` instead. When that callback is also not\n * provided, a `JisonLexerError` exception will be thrown containing the error\n * message and `hash`, as constructed by the `constructLexErrorInfo()` API.\n *\n * Note that the lexer's `JisonLexerError` error class is passed via the\n * `ExceptionClass` argument, which is invoked to construct the exception\n * instance to be thrown, so technically `parseError` will throw the object\n * produced by the `new ExceptionClass(str, hash)` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the `.options` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n *\n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are \"extended regex format\" requiring the\n * `XRegExp` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n "], ["\n /* lexer generated by jison-lex ", " */\n\n /*\n * Returns a Lexer object of the following structure:\n *\n * Lexer: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" \\`yy\\` passed around to\n * the rule actions, etc. is a direct reference!\n *\n * This \"shared context\" object was passed to the lexer by way of\n * the \\`lexer.setInput(str, yy)\\` API before you may use it.\n *\n * This \"shared context\" object is passed to the lexer action code in \\`performAction()\\`\n * so userland code in the lexer actions may communicate with the outside world\n * and/or other lexer rules' actions in more or less complex ways.\n *\n * }\n *\n * Lexer.prototype: {\n * EOF: 1,\n * ERROR: 2,\n *\n * yy: The overall \"shared context\" object reference.\n *\n * JisonLexerError: function(msg, hash),\n *\n * performAction: function lexer__performAction(yy, yyrulenumber, YY_START),\n *\n * The function parameters and \\`this\\` have the following value/meaning:\n * - \\`this\\` : reference to the \\`lexer\\` instance.\n * \\`yy_\\` is an alias for \\`this\\` lexer instance reference used internally.\n *\n * - \\`yy\\` : a reference to the \\`yy\\` \"shared state\" object which was passed to the lexer\n * by way of the \\`lexer.setInput(str, yy)\\` API before.\n *\n * Note:\n * The extra arguments you specified in the \\`%parse-param\\` statement in your\n * **parser** grammar definition file are passed to the lexer via this object\n * reference as member variables.\n *\n * - \\`yyrulenumber\\` : index of the matched lexer rule (regex), used internally.\n *\n * - \\`YY_START\\`: the current lexer \"start condition\" state.\n *\n * parseError: function(str, hash, ExceptionClass),\n *\n * constructLexErrorInfo: function(error_message, is_recoverable),\n * Helper function.\n * Produces a new errorInfo \\'hash object\\' which can be passed into \\`parseError()\\`.\n * See it\\'s use in this lexer kernel in many places; example usage:\n *\n * var infoObj = lexer.constructParseErrorInfo(\\'fail!\\', true);\n * var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);\n *\n * options: { ... lexer %options ... },\n *\n * lex: function(),\n * Produce one token of lexed input, which was passed in earlier via the \\`lexer.setInput()\\` API.\n * You MAY use the additional \\`args...\\` parameters as per \\`%parse-param\\` spec of the **lexer** grammar:\n * these extra \\`args...\\` are added verbatim to the \\`yy\\` object reference as member variables.\n *\n * WARNING:\n * Lexer's additional \\`args...\\` parameters (via lexer's \\`%parse-param\\`) MAY conflict with\n * any attributes already added to \\`yy\\` by the **parser** or the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * cleanupAfterLex: function(do_not_nuke_errorinfos),\n * Helper function.\n *\n * This helper API is invoked when the **parse process** has completed: it is the responsibility\n * of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.\n *\n * This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.\n *\n * setInput: function(input, [yy]),\n *\n *\n * input: function(),\n *\n *\n * unput: function(str),\n *\n *\n * more: function(),\n *\n *\n * reject: function(),\n *\n *\n * less: function(n),\n *\n *\n * pastInput: function(n),\n *\n *\n * upcomingInput: function(n),\n *\n *\n * showPosition: function(),\n *\n *\n * test_match: function(regex_match_array, rule_index),\n *\n *\n * next: function(),\n *\n *\n * begin: function(condition),\n *\n *\n * pushState: function(condition),\n *\n *\n * popState: function(),\n *\n *\n * topState: function(),\n *\n *\n * _currentRules: function(),\n *\n *\n * stateStackSize: function(),\n *\n *\n * performAction: function(yy, yy_, yyrulenumber, YY_START),\n *\n *\n * rules: [...],\n *\n *\n * conditions: {associative list: name ==> set},\n * }\n *\n *\n * token location info (\\`yylloc\\`): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The \\`parseError\\` function receives a \\'hash\\' object with these members for lexer errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * yy: (object: the current parser internal \"shared state\" \\`yy\\`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * }\n *\n * while \\`this\\` will reference the current lexer instance.\n *\n * When \\`parseError\\` is invoked by the lexer, the default implementation will\n * attempt to invoke \\`yy.parser.parseError()\\`; when this callback is not provided\n * it will try to invoke \\`yy.parseError()\\` instead. When that callback is also not\n * provided, a \\`JisonLexerError\\` exception will be thrown containing the error\n * message and \\`hash\\`, as constructed by the \\`constructLexErrorInfo()\\` API.\n *\n * Note that the lexer\\'s \\`JisonLexerError\\` error class is passed via the\n * \\`ExceptionClass\\` argument, which is invoked to construct the exception\n * instance to be thrown, so technically \\`parseError\\` will throw the object\n * produced by the \\`new ExceptionClass(str, hash)\\` JavaScript expression.\n *\n * ---\n *\n * You can specify lexer options by setting / modifying the \\`.options\\` object of your Lexer instance.\n * These options are available:\n *\n * (Options are permanent.)\n *\n * yy: {\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default \\`parseError\\` function.\n * }\n *\n * lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * \\`this\\` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token \\`token\\`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original \\`token\\`.\n * \\`this\\` refers to the Lexer object.\n *\n * WARNING: the next set of options are not meant to be changed. They echo the abilities of\n * the lexer as per when it was compiled!\n *\n * ranges: boolean\n * optional: \\`true\\` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: \\`true\\` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: \\`true\\` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: \\`true\\` ==> lexer rule regexes are \"extended regex format\" requiring the\n * \\`XRegExp\\` library. When this %option has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n "]); + var data = _taggedTemplateLiteral([",\n JisonLexerError: JisonLexerError,\n performAction: ", ",\n simpleCaseActionClusters: ", ",\n rules: [\n ", "\n ],\n conditions: ", "\n };\n "]); _templateObject85 = function _templateObject85() { return data; @@ -771,7 +781,7 @@ function _templateObject85() { } function _templateObject84() { - var data = _taggedTemplateLiteral([",\n JisonLexerError: JisonLexerError,\n performAction: ", ",\n simpleCaseActionClusters: ", ",\n rules: [\n ", "\n ],\n conditions: ", "\n };\n "]); + var data = _taggedTemplateLiteral(["\n const lexer = {\n "]); _templateObject84 = function _templateObject84() { return data; @@ -781,7 +791,7 @@ function _templateObject84() { } function _templateObject83() { - var data = _taggedTemplateLiteral(["\n var lexer = {\n "]); + var data = _taggedTemplateLiteral(["\n // Code Generator Information Report\n // ---------------------------------\n //\n // Options:\n //\n // backtracking: .................... ", "\n // location.ranges: ................. ", "\n // location line+column tracking: ... ", "\n //\n //\n // Forwarded Parser Analysis flags:\n //\n // uses yyleng: ..................... ", "\n // uses yylineno: ................... ", "\n // uses yytext: ..................... ", "\n // uses yylloc: ..................... ", "\n // uses lexer values: ............... ", " / ", "\n // location tracking: ............... ", "\n // location assignment: ............. ", "\n //\n //\n // Lexer Analysis flags:\n //\n // uses yyleng: ..................... ", "\n // uses yylineno: ................... ", "\n // uses yytext: ..................... ", "\n // uses yylloc: ..................... ", "\n // uses ParseError API: ............. ", "\n // uses yyerror: .................... ", "\n // uses location tracking & editing: ", "\n // uses more() API: ................. ", "\n // uses unput() API: ................ ", "\n // uses reject() API: ............... ", "\n // uses less() API: ................. ", "\n // uses display APIs pastInput(), upcomingInput(), showPosition():\n // ............................. ", "\n // uses describeYYLLOC() API: ....... ", "\n //\n // --------- END OF REPORT -----------\n\n "]); _templateObject83 = function _templateObject83() { return data; @@ -791,7 +801,7 @@ function _templateObject83() { } function _templateObject82() { - var data = _taggedTemplateLiteral(["\n // Code Generator Information Report\n // ---------------------------------\n //\n // Options:\n //\n // backtracking: .................... ", "\n // location.ranges: ................. ", "\n // location line+column tracking: ... ", "\n //\n //\n // Forwarded Parser Analysis flags:\n //\n // uses yyleng: ..................... ", "\n // uses yylineno: ................... ", "\n // uses yytext: ..................... ", "\n // uses yylloc: ..................... ", "\n // uses lexer values: ............... ", " / ", "\n // location tracking: ............... ", "\n // location assignment: ............. ", "\n //\n //\n // Lexer Analysis flags:\n //\n // uses yyleng: ..................... ", "\n // uses yylineno: ................... ", "\n // uses yytext: ..................... ", "\n // uses yylloc: ..................... ", "\n // uses ParseError API: ............. ", "\n // uses yyerror: .................... ", "\n // uses location tracking & editing: ", "\n // uses more() API: ................. ", "\n // uses unput() API: ................ ", "\n // uses reject() API: ............... ", "\n // uses less() API: ................. ", "\n // uses display APIs pastInput(), upcomingInput(), showPosition():\n // ............................. ", "\n // uses describeYYLLOC() API: ....... ", "\n //\n // --------- END OF REPORT -----------\n\n "]); + var data = _taggedTemplateLiteral(["\n stripUnusedLexerCode WARNING: \n\n JISON failed to reformat the generated lexer.\n Using the generated code as-is instead and pray it works in your final output!\n\n Internal error report:\n\n ", "\n\n The offending action code chunk as reported above:\n\n ", "\n "]); _templateObject82 = function _templateObject82() { return data; @@ -801,7 +811,7 @@ function _templateObject82() { } function _templateObject81() { - var data = _taggedTemplateLiteral(["\n stripUnusedLexerCode WARNING: \n\n JISON failed to reformat the generated lexer.\n Using the generated code as-is instead and pray it works in your final output!\n\n Internal error report:\n\n ", "\n\n The offending action code chunk as reported above:\n\n ", "\n "]); + var data = _taggedTemplateLiteral(["\n \"use strict\";\n\n return ", ";\n"]); _templateObject81 = function _templateObject81() { return data; @@ -811,7 +821,7 @@ function _templateObject81() { } function _templateObject80() { - var data = _taggedTemplateLiteral(["\n \"use strict\";\n\n return ", ";\n"]); + var data = _taggedTemplateLiteral(["\n // JISON INJECTED VALIDATION CODE\n // which attempts to ascertain you have defined a minimal viable lexer at least:\n if (typeof lexer === \"undefined\") {\n throw new SyntaxError(\"user-defined lexer does not define the required 'lexer' instance.\");\n }\n if (!lexer) {\n throw new SyntaxError(\"user-defined lexer does not define a non-NULL 'lexer' instance.\");\n }\n if (typeof lexer.setInput !== 'function') {\n throw new SyntaxError(\"user-defined lexer does not provide the mandatory 'lexer.setInput()' API function.\");\n }\n if (typeof lexer.lex !== 'function') {\n throw new SyntaxError(\"user-defined lexer does not provide the mandatory 'lexer.lex()' API function.\");\n }\n // END OF JISON INJECTED VALIDATION CODE\n "]); _templateObject80 = function _templateObject80() { return data; @@ -1614,11 +1624,17 @@ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice( function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } (function (global, factory) { - (typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('fs'), require('path'), require('@gerhobbelt/json5'), require('@gerhobbelt/xregexp'), require('recast'), require('@babel/core'), require('assert'), require('ast-util')) : typeof define === 'function' && define.amd ? define(['fs', 'path', '@gerhobbelt/json5', '@gerhobbelt/xregexp', 'recast', '@babel/core', 'assert', 'ast-util'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.jison = factory(global.fs, global.path$1, global.JSON5, global.XRegExp, global.recast, global.babel, global.assert$1, global.astUtils)); -})(void 0, function (fs, path$1, JSON5, XRegExp, recast, babel, assert$1, astUtils) { + (typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('fs'), require('path'), require('@gerhobbelt/json5'), require('mkdirp'), require('@gerhobbelt/xregexp'), require('recast'), require('@babel/core'), require('assert'), require('ast-util')) : typeof define === 'function' && define.amd ? define(['fs', 'path', '@gerhobbelt/json5', 'mkdirp', '@gerhobbelt/xregexp', 'recast', '@babel/core', 'assert', 'ast-util'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.jison = factory(global.fs, global.path$1, global.JSON5, global.mkdirp, global.XRegExp, global.recast, global.babel, global.assert$1, global.astUtils)); +})(void 0, function (fs, path$1, JSON5, mkdirp, XRegExp, recast, babel, assert$1, astUtils) { 'use strict'; function _interopDefaultLegacy(e) { @@ -1633,13 +1649,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); + var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); + var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); - var astUtils__default = /*#__PURE__*/_interopDefaultLegacy(astUtils); // Return TRUE if `src` starts with `searchString`. + var astUtils__default = /*#__PURE__*/_interopDefaultLegacy(astUtils); // Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { @@ -1662,7 +1680,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look @@ -1691,37 +1709,42 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); // Done removing common indentation. - // + { + var a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; // only correct indentation at start of line, i.e. only check for + var _a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { - if (startsWith(a[j], indent_str)) { - a[j] = a[j].substr(indent_str.length); + for (var j = 1, linecnt = _a.length; j < linecnt; j++) { + if (startsWith(_a[j], indent_str)) { + _a[j] = _a[j].substr(indent_str.length); } } } } // now merge everything to construct the template result: - var rv = []; + { + var rv = []; + var _i = 0; - for (var i = 0, len = arguments.length <= 1 ? 0 : arguments.length - 1; i < len; i++) { - rv.push(src[i].join('\n')); - rv.push(i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1]); - } // the last value is always followed by a last template string partial: + for (var _len = arguments.length <= 1 ? 0 : arguments.length - 1; _i < _len; _i++) { + rv.push(src[_i].join('\n')); + rv.push(_i + 1 < 1 || arguments.length <= _i + 1 ? undefined : arguments[_i + 1]); + } // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + rv.push(src[_i].join('\n')); + var sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` /** @public */ @@ -1741,14 +1764,36 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return rv; }); - } // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers + } // https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words + + + var reservedWords = function (list) { + var rv = new Set(); + + var _iterator = _createForOfIteratorHelper(list), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var w = _step.value; + //console.error('reserved word:', w); + rv.add(w); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + return rv; + }(['await', 'break', 'case', 'catch', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'enum', 'export', 'extends', 'finally', 'for', 'function', 'if', 'implements', 'import', 'in', 'instanceof', 'interface', 'new', 'package', 'private', 'protected', 'public', 'return', 'super', 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'yield']); // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + var rv = s // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { var c = match.charAt(1); @@ -1764,6 +1809,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi .replace(/^[^\w_]/, '_') // do not accept numerics at the leading position, despite those matching regex `\w`: .replace(/^\d/, '_').replace(/[^\w\d_]/g, '_') // and only accept multiple (double, not triple) underscores at start or end of identifier name: .replace(/^__+/, '#').replace(/__+$/, '#').replace(/_+/g, '_').replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + + return rv; } // Check if the start of the given input matches a regex expression. // Return the length of the regex expression or -1 if none was found. @@ -1799,13 +1850,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (ch === ']') { classMarker = false; } - } else { - if (ch === '/') { - terminated = true; - break; - } else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } @@ -1829,7 +1878,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function isLegalIdentifierInput(s) { - s = '' + s; // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + s = '' + s; // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` var ref = s.replace(/-\w/g, function (match) { @@ -1879,6 +1928,55 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi p = p || 2; var rv = '0000' + n; return rv.slice(-p); + } + + function convertExceptionToObject(ex) { + if (!ex) return ex; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + + var rv = Object.assign({}, ex); // - Set up the default fields which should ALWAYS be present: + + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + + if (Array.isArray(ex.errors)) { + rv.errors = []; + + var _iterator2 = _createForOfIteratorHelper(ex.errors), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var se = _step2.value; + rv.errors.push(convertExceptionToObject(se)); + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + } + + return rv; + } + + function find_suitable_app_dump_path() { + return process.cwd().replace(/\\/g, '/').replace(/\/node_modules\/.*$/, function (m) { + return '/___nm___/'; + }).replace(/(\/jison\/)(.*)$/, function (m, p1, p2) { + return p1 + '___' + p2.split('/').map(function (d) { + return d.charAt(0).toUpperCase(); + }).join('_'); + }); } // attempt to dump in one of several locations: first winner is *it*! @@ -1887,15 +1985,27 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi options = options || {}; try { - var dumpPaths = [options.outfile ? path__default['default'].dirname(options.outfile) : null, options.inputPath, process.cwd()]; + var dumpPaths = [options.outfile ? path__default['default'].dirname(options.outfile) : null, options.inputPath, find_suitable_app_dump_path()]; var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname).replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; + } // generate a stacktrace for the dump no matter what: + + + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } } err_id = err_id || 'XXX'; + err_id = err_id.replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); var ts = new Date(); var tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + '' + pad(ts.getUTCMinutes()) + '' + pad(ts.getUTCSeconds()) + '.' + pad(ts.getUTCMilliseconds(), 3) + 'Z'; dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; @@ -1906,21 +2016,34 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); var dump = { errname: errname, err_id: err_id, options: options, - ex: ex + ex: convertExceptionToObject(ex) }; - var d = JSON5__default['default'].stringify(dump, null, 2); // make sure each line is a comment line: + var d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + + return value; + }, + space: 2, + circularRefHandler: function circularRefHandler(value, circusPos, stack, keyStack, key, err) { + return '[!circular ref!]'; + } + }); // make sure each line is a comment line: d = d.split('\n').map(function (l) { return '// ' + l; }); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -1930,7 +2053,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -1961,25 +2084,36 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + var errname = '' + (title || 'exec_test'); + var err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + + var debug = options.debug || 0; + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + + if (debug > 1) { + console.warn("\n ######################## source code ##########################\n ".concat(sourcecode, "\n ######################## source code ##########################\n ")); } - var debug = 0; var p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + if (debug > 1) console.log('exec-and-diagnose options:', options); + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } @@ -1992,9 +2126,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return p; } - var code_exec = { + var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject: convertExceptionToObject }; // assert__default['default'](recast__default['default']); //var types = recast.types; @@ -2008,18 +2143,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! - var ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries + var ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: - var IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; // Determine which Unicode NonAsciiIdentifierStart characters + var IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; // Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. - // + // // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action - // code chunks. - // + // code chunks. + // // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -2031,37 +2166,37 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -2069,30 +2204,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -2103,58 +2238,58 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -2199,27 +2334,27 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return set[lsidx]; } - var escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: + var escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: - var typeIdCharSets = ["ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", + var typeIdCharSets = ['ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ"]; //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ']; //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - var reStr = escCharSet + typeIdCharSets.join(""); + var reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); var re = new RegExp("[".concat(reStr, "]"), 'g'); var hash = new Array(0xD800); @@ -2230,18 +2365,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi hash[i] = (hash[i] || 0) + 1; } // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -2252,64 +2387,64 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // var escChar = pickChar(escCharSet); var typeIdChar = []; - for (var _i = 0, l = typeIdCharSets.length; _i < l; _i++) { - typeIdChar[_i] = pickChar(typeIdCharSets[_i]); - } // produce a function set for encoding and decoding content, + for (var _i2 = 0, l = typeIdCharSets.length; _i2 < l; _i2++) { + typeIdChar[_i2] = pickChar(typeIdCharSets[_i2]); + } // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: @@ -2317,47 +2452,47 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return _ref = { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default']("#(".concat(ID_REGEX_BASE, ")#"), 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default']("$(".concat(ID_REGEX_BASE, ")|$([0-9]+)"), 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default']("@(".concat(ID_REGEX_BASE, ")|@([0-9]+)"), 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default']("#(".concat(ID_REGEX_BASE, ")|#([0-9]+)"), 'g'), // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default']("##(".concat(ID_REGEX_BASE, ")|##([0-9]+)"), 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4] - }, _defineProperty(_ref, "tokenValueReferenceRe", new XRegExp__default['default']("$-([0-9]+)", 'g')), _defineProperty(_ref, "tokenNegativeLocationStart", escChar + typeIdChar[5]), _defineProperty(_ref, "tokenNegativeLocationRe", new XRegExp__default['default']("@-([0-9]+)", 'g')), _defineProperty(_ref, "tokenNegativeStackIndexStart", escChar + typeIdChar[6]), _defineProperty(_ref, "tokenNegativeStackIndexRe", new XRegExp__default['default']("#-([0-9]+)", 'g')), _defineProperty(_ref, "tokenDetect4EncodeRe", new XRegExp__default['default']("([^$@#".concat(IN_ID_CHARSET, "])([$@#]|##)(").concat(ID_REGEX_BASE, "|[$]|-?[0-9]+)(#?)(?![$@#").concat(IN_ID_CHARSET, "])"), 'g')), _defineProperty(_ref, "tokenDetect4DecodeRe", new XRegExp__default['default']("([^$".concat(IN_ID_CHARSET, "])(").concat(escChar, "[").concat(typeIdChar.slice(0, 7).join(''), "])(").concat(ID_REGEX_BASE, "|[$]|[0-9]+)(?![$@#").concat(IN_ID_CHARSET, "])"), 'g')), _defineProperty(_ref, "encode", function encodeJisonTokens(src, locationOffsetSpec) { + }, _defineProperty(_ref, "tokenValueReferenceRe", new XRegExp__default['default']('$-([0-9]+)', 'g')), _defineProperty(_ref, "tokenNegativeLocationStart", escChar + typeIdChar[5]), _defineProperty(_ref, "tokenNegativeLocationRe", new XRegExp__default['default']('@-([0-9]+)', 'g')), _defineProperty(_ref, "tokenNegativeStackIndexStart", escChar + typeIdChar[6]), _defineProperty(_ref, "tokenNegativeStackIndexRe", new XRegExp__default['default']('#-([0-9]+)', 'g')), _defineProperty(_ref, "tokenDetect4EncodeRe", new XRegExp__default['default']("([^$@#".concat(IN_ID_CHARSET, "])([$@#]|##)(").concat(ID_REGEX_BASE, "|[$]|-?[0-9]+)(#?)(?![$@#").concat(IN_ID_CHARSET, "])"), 'g')), _defineProperty(_ref, "tokenDetect4DecodeRe", new XRegExp__default['default']("([^$".concat(IN_ID_CHARSET, "])(").concat(escChar, "[").concat(typeIdChar.slice(0, 7).join(''), "])(").concat(ID_REGEX_BASE, "|[$]|[0-9]+)(?![$@#").concat(IN_ID_CHARSET, "])"), 'g')), _defineProperty(_ref, "encode", function encodeJisonTokens(src, locationOffsetSpec) { var _this = this; var re = this.tokenDetect4EncodeRe; // reset regex @@ -2365,10 +2500,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -2452,10 +2587,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -2464,19 +2599,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // p1 is only serving as lookbehind emulation switch (p2) { case _this2.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case _this2.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case _this2.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case _this2.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case _this2.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case _this2.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -2532,13 +2667,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi sourceRoot: '.', sourceType: 'module', babelrc: false, - ignore: ["node_modules/**/*.js"], + ignore: ['node_modules/**/*.js'], compact: false, retainLines: false, - presets: [["@babel/preset-env", { + presets: [['@babel/preset-env', { targets: { - browsers: ["last 2 versions"], - node: "8.0" + browsers: ['last 2 versions'], + node: '8.0' } }]] }, options); @@ -2546,7 +2681,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } function prettyPrintAST(ast, options) { - var options = options || {}; + options = options || {}; var defaultOptions = { tabWidth: 2, quote: 'single', @@ -2569,8 +2704,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi .replace(/\uFFDA/g, '@').replace(/\uFFDB/g, '#'); return new_src; } // validate the given JISON+JavaScript snippet: does it compile? - // - // Return either the parsed AST (object) or an error message (string). + // + // Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { @@ -2590,16 +2725,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } // The rough-and-ready preprocessor for any action code block: // this one trims off any surplus whitespace and removes any // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. - // + // // Returns the trimmed sourcecode which was provided via `src`. - // + // // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -2607,7 +2742,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: - // + // // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -2616,12 +2751,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} - // + // // Of course the example would be 'ludicrous' action code but the - // key point here is that users will certainly be able to come up with + // key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! - // + // function trimActionCode(src, startMarker) { @@ -2698,16 +2833,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var funcRe = /^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/; var arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/; /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. - /// + /// /// Also supports ES6's Arrow Functions: - /// + /// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' - /// + /// /** @public */ @@ -2736,8 +2871,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -2763,12 +2898,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var stringifier = { printFunctionSourceCode: printFunctionSourceCode, printFunctionSourceCodeContainer: printFunctionSourceCodeContainer - }; // - // - // + }; // + // + // function detectIstanbulGlobal() { - var gcv = "__coverage__"; + var gcv = '__coverage__'; var globalvar = new Function('return this')(); var coverage = globalvar[gcv]; return coverage || false; @@ -2955,12 +3090,44 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } return src; - } + } // strip developer machine specific parts off any paths in a given stacktrace (string) + // to ease cross-platform comparison of these stacktraces. + function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: - msg = msg.replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)').replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + msg = msg.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; + } // strip off the line/position info from any stacktrace as a assert.deepEqual() on these + // will otherwise FAIL due to us running this stuff through both regular `node` and + // the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing + // exceptions and stacktraces which point completely somewhere else and this would b0rk + // our test rigs for the jison subpackages. + + + function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + var msg = obj.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + + var keys = Object.keys(obj); + + for (var i in keys) { + var key = keys[i]; + var el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + + return obj; } function trim_array_tail(arr) { @@ -3008,33 +3175,33 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi trim_array_tail(inf); for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + var _err = inf[key]; - if (err) { + if (_err) { path.push('[' + key + ']'); - err = treat_object(err); + _err = treat_object(_err); - if (_typeof(err) === 'object') { - if (err.lexer) { - err.lexer = '[lexer]'; + if (_typeof(_err) === 'object') { + if (_err.lexer) { + _err.lexer = '[lexer]'; } - if (err.parser) { - err.parser = '[parser]'; + if (_err.parser) { + _err.parser = '[parser]'; } - trim_array_tail(err.symbol_stack); - trim_array_tail(err.state_stack); - trim_array_tail(err.location_stack); + trim_array_tail(_err.symbol_stack); + trim_array_tail(_err.state_stack); + trim_array_tail(_err.location_stack); - if (err.value_stack) { + if (_err.value_stack) { path.push('value_stack'); - err.value_stack = treat_value_stack(err.value_stack); + _err.value_stack = treat_value_stack(_err.value_stack); path.pop(); } } - inf[key] = err; + inf[key] = _err; path.pop(); } } @@ -3181,7 +3348,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return e; } // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. - // + // // Internal use in the unit test rigs. @@ -3213,10 +3380,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi dquote: dquote$1, trimErrorForTestReporting: trimErrorForTestReporting, stripErrorStackPaths: stripErrorStackPaths, + cleanStackTrace4Comparison: cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, compileCodeToES5: parse2AST.compileCodeToES5, @@ -3304,7 +3473,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return this; } // Same as typal_mix but also camelCases every object member and 'standardizes' the key set of every input // argument through a caLLback function. - // + // // This is useful for processing options with dashes in their key, e.g. `token-stack` --> tokenStack. @@ -3338,7 +3507,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var nk = mkIdentifier$1(k); var match = k.match(position); var key = k.replace(position, ''); // This anticipates before/after members to be camelcased already, e.g. - // 'afterParse()' for layering 'parse()': + // 'afterParse()' for layering 'parse()': var alt_key = lcase0(key); @@ -3469,7 +3638,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return this._items.length === 0; }, copy: function copy() { - return new Set(this._items); + return new Set$1(this._items); }, toString: function toString() { return this._items.toString(); @@ -3483,11 +3652,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }); 'filter slice map'.split(' ').forEach(function (e, i) { setMixin[e] = function () { - return new Set(Array.prototype[e].apply(this._items, arguments), true); + return new Set$1(Array.prototype[e].apply(this._items, arguments), true); }; //setMixin[e].name = e; }); - var Set = typal.construct(setMixin); // See also: + var Set$1 = typal.construct(setMixin); // 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. @@ -3990,16 +4159,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi switch (yystate) { case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; - this._$ = yylstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4028,8 +4197,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { @@ -4046,17 +4215,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject(), yylexer.prettyPrintRange(yylstack[yysp - 1]), yyvstack[yysp - 1].errStr)); break; case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { rules: yyvstack[yysp] @@ -4065,17 +4234,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject2(), yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr)); break; case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { rules: [] @@ -4084,9 +4253,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; if (!yy.options) yy.options = {}; @@ -4125,8 +4294,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4176,8 +4345,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { macros: {}, @@ -4195,8 +4364,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` // macros here: @@ -4219,17 +4388,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject6(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4246,17 +4415,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject7(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4273,17 +4442,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject8(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4305,8 +4474,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. @@ -4315,8 +4484,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -4326,8 +4495,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -4337,8 +4506,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4351,17 +4520,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject12(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { type: 'unknown', @@ -4371,8 +4540,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4399,17 +4568,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject15(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 5, yysp); // END of default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -4443,9 +4612,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + 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 : ''; @@ -4455,36 +4624,36 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1(_templateObject20(), yylexer.prettyPrintRange(yylstack[yysp - 3], yylstack[yysp - 4]), yyvstack[yysp - 3].errStr)); break; case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject21(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1(_templateObject22(), yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = yyvstack[yysp]; @@ -4495,9 +4664,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; yy.__options_category_description__ = yyvstack[yysp]; @@ -4505,9 +4674,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; yy.__options_category_description__ = yyvstack[yysp]; @@ -4515,9 +4684,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = 'the inclusive lexer start conditions set (%s)'; @@ -4525,9 +4694,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = 'the exclusive lexer start conditions set (%x)'; @@ -4535,9 +4704,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; yy.__options_category_description__ = 'the <...> delimited set of lexer start conditions'; @@ -4545,9 +4714,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; yy.__options_category_description__ = 'the lexer rules definition section'; @@ -4555,9 +4724,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; yy.__options_category_description__ = 'the lexer epilogue section'; @@ -4565,24 +4734,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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].concat(yyvstack[yysp]); break; case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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].concat([yyvstack[yysp]]); break; case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4601,8 +4770,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. @@ -4611,8 +4780,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -4622,8 +4791,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4658,8 +4827,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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(_templateObject27(), yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp]))); this.$ = yyvstack[yysp - 1]; @@ -4670,16 +4839,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (yyvstack[yysp - 1]) { yyvstack[yysp].unshift(yyvstack[yysp - 1]); @@ -4690,8 +4859,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (yyvstack[yysp - 3]) { yyvstack[yysp - 1].forEach(function (d) { @@ -4704,35 +4873,35 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + 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$1(_templateObject28(), yyvstack[yysp - 3].join(','), yylexer.prettyPrintRange(yyparser.mergeLocationInfo(yysp - 3, yysp), yylstack[yysp - 3]), yyvstack[yysp - 1].errStr)); break; case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject29(), yyvstack[yysp - 2].join(','), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject30(), yyvstack[yysp - 2].join(','), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push(yyvstack[yysp]); @@ -4743,8 +4912,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -4758,8 +4927,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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. @@ -4790,8 +4959,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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(_templateObject33(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); @@ -4799,8 +4968,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO: REWRITE this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -4809,8 +4978,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO: REWRITE this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -4819,8 +4988,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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], yyvstack[yysp]]; yyparser.yyError(rmCommonWS$1(_templateObject36(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); @@ -4840,52 +5009,52 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + yyvstack[yysp]; break; case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '\n\n' + yyvstack[yysp] + '\n\n'; break; case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject37(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]))); break; case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject38(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]))); break; case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject39(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]))); break; case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject40(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 3]))); break; @@ -4895,16 +5064,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -4923,9 +5092,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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) { @@ -4936,8 +5105,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -5017,56 +5186,56 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; break; case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '|'; break; case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; break; case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '|'; break; case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + ')'; break; case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + ')'; break; @@ -5076,49 +5245,49 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject43(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '+'; break; case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '*'; break; case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '?'; break; case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + ')'; break; case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + ')'; break; @@ -5140,65 +5309,65 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '.'; break; case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '^'; break; case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '$'; break; case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); break; case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + yyvstack[yysp]; break; case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject44(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) && yyvstack[yysp].toUpperCase() !== yyvstack[yysp]) { // treat this as part of an XRegExp `\p{...}` Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories @@ -5212,8 +5381,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -5223,8 +5392,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -5232,8 +5401,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -5254,8 +5423,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -5268,24 +5437,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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], true]; break; case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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_VALUE) { @@ -5297,9 +5466,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... yyparser.yyError(rmCommonWS$1(_templateObject49(), $option, yy.__options_category_description__, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 4]), yyvstack[yysp].errStr)); @@ -5307,9 +5476,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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)'; @@ -5322,8 +5491,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -5349,8 +5518,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -5369,32 +5538,32 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = parseValue(yyvstack[yysp]); break; case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = ''; break; case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -5411,17 +5580,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject54(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$1(_templateObject55(), yylexer.prettyPrintRange(yylstack[yysp]), yyvstack[yysp].errStr)); @@ -5430,8 +5599,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -5451,8 +5620,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -5462,8 +5631,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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. @@ -5472,8 +5641,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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]; @@ -5508,9 +5677,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject61(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; @@ -5589,20 +5758,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + var ASSERT = typeof assert !== 'function' ? function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : assert; this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -5635,13 +5798,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + var _dst = {}; + shallow_copy_noclobber(_dst, src); + return _dst; + } } return src; @@ -5658,10 +5822,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (chk.call(src, k)) { dst[k] = src[k]; } - } else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -5830,11 +5992,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (var _i3 = this.__error_recovery_infos.length - 1; _i3 >= 0; _i3--) { + var _el = this.__error_recovery_infos[_i3]; - if (el && typeof el.destroy === 'function') { - el.destroy(); + if (_el && typeof _el.destroy === 'function') { + _el.destroy(); } } @@ -5862,10 +6024,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; + var i1 = first_index | 0; + var i2 = last_index | 0; + var l1 = first_yylloc; + var l2 = last_yylloc; var rv; // rules: // - first/last yylloc entries override first/last indexes @@ -5883,8 +6045,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { - l2 = lstack[i]; + for (var _i4 = i2; _i4 >= i1; _i4--) { + l2 = lstack[_i4]; if (l2) { break; @@ -5897,8 +6059,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 i = (i1 || sp) - 1; i >= 0; i--) { - l1 = lstack[i]; + for (var _i5 = (i1 || sp) - 1; _i5 >= 0; _i5--) { + l1 = lstack[_i5]; if (l1) { break; @@ -5911,30 +6073,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; - } + return null; + } // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + + rv = this.copy_yylloc(l2); return rv; + } // shallow-copy L1, then adjust first col/row 1 column past the end. + + + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; } + + return rv; } if (!l1) { @@ -5943,7 +6105,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... @@ -5993,6 +6155,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -6075,11 +6243,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty - } + { + var i; + + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty + } - rv.base_pointer = i; - rv.info_stack_pointer = i; + rv.base_pointer = i; + rv.info_stack_pointer = i; + } rv.root_failure_pointer = rv.stack_pointer; // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_recovery_infos.push(rv); @@ -6165,9 +6337,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi while (stack_probe >= 0) { // check for error recovery rule in this state - var t = table[state] && table[state][TERROR] || NO_ACTION; + var _t = table[state] && table[state][TERROR] || NO_ACTION; - if (t[0]) { + if (_t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must // prevent the core from running forever, @@ -6330,7 +6502,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: @@ -6386,7 +6558,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errSymbolDescr: errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -6405,7 +6577,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi yyval.$ = recoveringErrorInfo; yyval._$ = undefined; yyrulelen = error_rule_depth; - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + var combineState = NO_ACTION[1]; + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -6462,9 +6635,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); var errorSymbolFromParser = true; for (;;) { @@ -6497,7 +6670,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // and take it from there! if (!action) { - ASSERT(recoveringErrorInfo, "line 1087"); // Prep state variables so that upon breaking out of + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` // statement in the outer "fast parse loop" we redo // the exact same state table lookup as the one above @@ -6532,12 +6705,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -6579,7 +6752,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; // read action for current state and first input @@ -6609,7 +6782,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; @@ -6669,15 +6842,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -6731,7 +6906,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; @@ -6773,25 +6948,25 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + var _tokenName = this.getSymbolName(symbol || EOF); - if (!tokenName) { - tokenName = symbol; + if (!_tokenName) { + _tokenName = symbol; } Jison.parserDebugger.push({ action: 'shift', text: lexer.yytext, - terminal: tokenName, + terminal: _tokenName, terminal_id: symbol }); } ++sp; symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc = this.copy_yylloc(lexer.yylloc); @@ -6799,9 +6974,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... @@ -6809,25 +6984,28 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; + var _prereduceValue = vstack.slice(sp - yyrulelen, sp); - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); - debuggableProductions.push(debuggableProduction); + var _debuggableProductions = []; + + for (var _debugIdx = yyrulelen - 1; _debugIdx >= 0; _debugIdx--) { + var _debuggableProduction = getNonTerminalFromCode(stack[sp - _debugIdx]); + + _debuggableProductions.push(_debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + var _currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + + var _currentNonterminal = getNonTerminalFromCode(_currentNonterminalCode); - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', - nonterminal: currentNonterminal, - nonterminal_id: currentNonterminalCode, - prereduce: prereduceValue, + nonterminal: _currentNonterminal, + nonterminal_id: _currentNonterminalCode, + prereduce: _prereduceValue, result: r, - productions: debuggableProductions, + productions: _debuggableProductions, text: yyval.$ }); } @@ -6849,15 +7027,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var _ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = _ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][_ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -7366,6 +7546,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -7747,9 +7931,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -7759,8 +7943,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -7836,12 +8020,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi */ pastInput: function lexer_pastInput(maxSize, maxLines) { var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) maxSize = Infinity;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substr` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = Infinity; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: @@ -7858,8 +8052,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -7885,20 +8079,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { var next = this.match; var source = this._input || ''; - if (maxSize < 0) maxSize = next.length + source.length;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substring` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = next.length + source.length; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + if (next.length < maxSize * 2 + 2) { next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8 } // now that we have a significantly reduced string to process, transform the newlines @@ -8223,7 +8427,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + var backup; if (this.options.backtrack_lexer) { // save context @@ -8251,9 +8455,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + var match_str = match[0]; + var match_str_len = match_str.length; + var lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -8279,7 +8483,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] + var token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */ ); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -8325,8 +8529,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -8358,65 +8560,73 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; // 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! + { + var rule_ids = spec.rules; + var regexes = spec.__rule_regexes; + var len = spec.__rule_count; + var match; + var index; // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + for (var i = 1; i <= len; i++) { + var tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + var token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + var _token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + if (_token !== false) { + return _token; + } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + var _lineno_msg = 'Lexical error'; if (this.yylloc) { - lineno_msg += ' on line ' + (this.yylineno + 1); + _lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var _p = this.constructLexErrorInfo(_lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var pendingInput = this._input; var activeCondition = this.topState(); var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; - if (token === this.ERROR) { + var _token2 = this.parseError(_p.errStr, _p, this.JisonLexerError) || this.ERROR; + + if (_token2 === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: @@ -8428,7 +8638,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - return token; + return _token2; } }, @@ -8485,24 +8695,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -8529,24 +8739,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -8610,9 +8820,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -8628,9 +8838,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -8650,7 +8860,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -10277,9 +10487,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (x.length >= 1 && i <= 0xFFFF) { c = '0000' + x; return "\\u" + c.substr(c.length - 4); - } else { - return "\\u{" + x + '}'; } + + return "\\u{" + x + '}'; } return String.fromCharCode(i); @@ -10289,7 +10499,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var Pcodes_bitarray_cache = {}; - var Pcodes_bitarray_cache_test_order = []; // Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by + var Pcodes_bitarray_cache_test_order = []; // Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. var EscCode_bitarray_output_refs; // now initialize the EscCodes_... table above: @@ -10391,13 +10601,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi l[k] = cnt; } // now dig out the unique ones: only need one per pcode. - // + // // We ASSUME every \\p{NAME} 'pcode' has at least ONE character - // in it that is ONLY matched by that particular pcode. + // in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode - // won't be tested during optimization. - // + // won't be tested during optimization. + // // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to @@ -10452,11 +10662,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } // order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. - // + // // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more - // optimal minification of the regex set expression. - // + // optimal minification of the regex set expression. + // // This is a guestimate/heuristic only! @@ -10693,7 +10903,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi mark(v1); } // When we have marked all slots, '^' NEGATES the set, hence we flip all slots. - // + // // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. @@ -10770,9 +10980,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi break; } } - } // We're only interested in matches which actually cover some + } // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: @@ -10873,9 +11083,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi break; } } - } // We're only interested in matches which actually cover some + } // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: @@ -10971,10 +11181,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!c1) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"'); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -10991,10 +11200,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!inner) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"'); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -11010,10 +11218,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!c2) { // cope with illegal escape sequences too! return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; + if (c2 !== ']') { return new Error('regex set expression is broken in regex: ' + orig); } @@ -11101,10 +11309,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // inside a regex set: try { - var re; assert__default['default'](s); assert__default['default'](!(s instanceof Error)); - re = new XRegExp__default['default']('[' + s + ']'); + var re = new XRegExp__default['default']('[' + s + ']'); re.test(s[0]); // One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` // so we check for lingering UNESCAPED brackets in here as those cannot be: @@ -11124,7 +11331,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } return l; - } // Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` + } // Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! @@ -11136,13 +11343,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (s1.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s1; - } else { - s1 = '[' + s1 + ']'; - } // Now try to produce a minimum regex from the *inverted* bitarray via negation: + } + + s1 = '[' + s1 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s2 = bitarray2set(bitarr, true, true); if (s2[0] === '^') { @@ -11158,7 +11364,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi s2 = '[' + s2 + ']'; // Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: - // + // // First try to produce a minimum regex from the bitarray directly: var s3 = bitarray2set(bitarr, false, false); // and when the regex set turns out to match a single pcode/escape, then @@ -11167,13 +11373,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (s3.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s3; - } else { - s3 = '[' + s3 + ']'; - } // Now try to produce a minimum regex from the *inverted* bitarray via negation: + } + + s3 = '[' + s3 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s4 = bitarray2set(bitarr, true, false); if (s4[0] === '^') { @@ -11222,7 +11427,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var rmCommonWS$2 = helpers.rmCommonWS; var mkIdentifier$3 = helpers.mkIdentifier; - var code_exec$1 = helpers.exec; + var code_exec = helpers.exec; var version = '0.6.2-220'; // require('./package.json').version; function chkBugger$2(src) { @@ -11303,7 +11508,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var opts = {}; var args = [].concat.apply([], arguments); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(defaultJisonLexOptions); } else { args.shift(); @@ -11599,9 +11804,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function errinfo() { if (name) { return 'macro [[' + name + ']]'; - } else { - return 'regex [[' + orig + ']]'; } + + return 'regex [[' + orig + ']]'; } // propagate deferred exceptions = error reports. @@ -11620,10 +11825,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!c1) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -11641,10 +11845,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!inner) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -11660,10 +11863,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!c2) { // cope with illegal escape sequences too! return new Error(errinfo() + ': regex set expression is broken: "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; + if (c2 !== ']') { return new Error(errinfo() + ': regex set expression is broken: apparently unterminated'); } @@ -12178,7 +12381,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function generateErrorClass() { // --- START lexer error class --- - var prelude = "/**\n * See also:\n * http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n * but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n * with userland code which might access the derived class in a 'classic' way.\n *\n * @public\n * @constructor\n * @nocollapse\n */\nfunction JisonLexerError(msg, hash) {\n \"use strict\";\n\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'JisonLexerError'\n });\n\n if (msg == null) msg = '???';\n\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n var stacktrace;\n if (hash && hash.exception instanceof Error) {\n var ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty('captureStackTrace')) { // V8\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(JisonLexerError.prototype, Error.prototype);\n} else {\n JisonLexerError.prototype = Object.create(Error.prototype);\n}\nJisonLexerError.prototype.constructor = JisonLexerError;\nJisonLexerError.prototype.name = 'JisonLexerError';"; // --- END lexer error class --- + var prelude = "/**\n * See also:\n * http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n * but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n * with userland code which might access the derived class in a 'classic' way.\n *\n * @public\n * @constructor\n * @nocollapse\n */\nfunction JisonLexerError(msg, hash) {\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'JisonLexerError'\n });\n\n if (msg == null) msg = '???';\n\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n let stacktrace;\n if (hash && hash.exception instanceof Error) {\n const ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty('captureStackTrace')) { // V8\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(JisonLexerError.prototype, Error.prototype);\n} else {\n JisonLexerError.prototype = Object.create(Error.prototype);\n}\nJisonLexerError.prototype.constructor = JisonLexerError;\nJisonLexerError.prototype.name = 'JisonLexerError';"; // --- END lexer error class --- return prelude; } @@ -12214,36 +12417,39 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // The compiled code will look something like this: // // ``` - // var lexer; + // let lexer; // bla bla... // ``` // // or // // ``` - // var lexer = { bla... }; + // const lexer = { bla... }; // ``` - var testcode = ['// provide a local version for test purposes:', jisonLexerErrorDefinition, '', generateFakeXRegExpClassSrcCode(), '', source, '', 'return lexer;'].join('\n'); - var lexer = code_exec$1(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { + var testcode = ['// provide a local version for test purposes:', jisonLexerErrorDefinition, '', generateFakeXRegExpClassSrcCode(), '', source, '', rmCommonWS$2(_templateObject80()), 'return lexer;'].join('\n'); + + var _lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { //console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$2(sourcecode); var lexer_f = new Function('', sourcecode); return lexer_f(); - }, opts.options, "lexer"); + }, Object.assign({}, opts.options, { + throwErrorOnCompileFailure: true + }), 'lexer'); - if (!lexer) { + if (!_lexer) { throw new Error('no lexer defined *at all*?!'); } - if (_typeof(lexer.options) !== 'object' || lexer.options == null) { + if (_typeof(_lexer.options) !== 'object' || _lexer.options == null) { throw new Error('your lexer class MUST have an .options member object or it won\'t fly!'); } - if (typeof lexer.setInput !== 'function') { + if (typeof _lexer.setInput !== 'function') { throw new Error('your lexer class MUST have a .setInput function member or it won\'t fly!'); } - if (lexer.EOF !== 1 && lexer.ERROR !== 2) { + if (_lexer.EOF !== 1 && _lexer.ERROR !== 2) { throw new Error('your lexer class MUST have these constants defined: lexer.EOF = 1 and lexer.ERROR = 2 or it won\'t fly!'); } // When we do NOT crash, we found/killed the problem area just before this call! @@ -12264,23 +12470,23 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var post = opts.options.post_lex; // since JSON cannot encode functions, we'll have to do it manually now: if (typeof pre === 'function') { - lexer.options.pre_lex = pre; + _lexer.options.pre_lex = pre; } if (typeof post === 'function') { - lexer.options.post_lex = post; + _lexer.options.post_lex = post; } } if (opts.options.showSource) { if (typeof opts.options.showSource === 'function') { - opts.options.showSource(lexer, source, opts, RegExpLexer); + opts.options.showSource(_lexer, source, opts, RegExpLexer); } else { - console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n"); + console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n', source, '\n----------------------------------------\n'); } } - return lexer; + return _lexer; } catch (ex) { // if (src_exception) { // src_exception.message += '\n (' + description + ': ' + ex.message + ')'; @@ -12319,62 +12525,66 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi assert__default['default'](Array.isArray(opts.rules)); return opts.rules.length > 0 ? 'One or more of your lexer state names are possibly botched?' : 'Your custom lexer is somehow botched.'; }, ex, null)) { - var rulesSpecSize; - - if (!test_me(function () { - // store the parsed rule set size so we can use that info in case - // this attempt also fails: - assert__default['default'](Array.isArray(opts.rules)); - rulesSpecSize = opts.rules.length; // opts.conditions = []; - - opts.rules = []; - opts.showSource = false; - opts.__in_rules_failure_analysis_mode__ = true; - }, 'One or more of your lexer rules are possibly botched?', ex, null)) { - // kill each rule action block, one at a time and test again after each 'edit': - var rv = false; - - for (var i = 0, len = rulesSpecSize; i < len; i++) { - var lastEditedRuleSpec; - rv = test_me(function () { - assert__default['default'](Array.isArray(opts.rules)); - assert__default['default'](opts.rules.length === rulesSpecSize); // opts.conditions = []; - // opts.rules = []; - // opts.__in_rules_failure_analysis_mode__ = true; - // nuke all rules' actions up to and including rule numero `i`: - - for (var j = 0; j <= i; j++) { - // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; - // now we want to edit the *action* part: - var rule = opts.rules[j]; - assert__default['default'](Array.isArray(rule)); - assert__default['default'](rule.length === 2 || rule.length === 3); - rule.pop(); - rule.push('{ /* nada */ }'); - lastEditedRuleSpec = rule; - } - }, function () { - return 'Your lexer rule "' + lastEditedRuleSpec[0] + '" action code block is botched?'; - }, ex, null); + var i, len; + var lastEditedRuleSpec; + + (function () { + var rulesSpecSize; + + if (!test_me(function () { + // store the parsed rule set size so we can use that info in case + // this attempt also fails: + assert__default['default'](Array.isArray(opts.rules)); + rulesSpecSize = opts.rules.length; // opts.conditions = []; + + opts.rules = []; + opts.showSource = false; + opts.__in_rules_failure_analysis_mode__ = true; + }, 'One or more of your lexer rules are possibly botched?', ex, null)) { + // kill each rule action block, one at a time and test again after each 'edit': + var rv = false; + + for (i = 0, len = rulesSpecSize; i < len; i++) { + rv = test_me(function () { + assert__default['default'](Array.isArray(opts.rules)); + assert__default['default'](opts.rules.length === rulesSpecSize); // opts.conditions = []; + // opts.rules = []; + // opts.__in_rules_failure_analysis_mode__ = true; + // nuke all rules' actions up to and including rule numero `i`: + + for (var j = 0; j <= i; j++) { + // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; + // now we want to edit the *action* part: + var rule = opts.rules[j]; + assert__default['default'](Array.isArray(rule)); + assert__default['default'](rule.length === 2 || rule.length === 3); + rule.pop(); + rule.push('{ /* nada */ }'); + lastEditedRuleSpec = rule; + } + }, function () { + return 'Your lexer rule "' + lastEditedRuleSpec[0] + '" action code block is botched?'; + }, ex, null); - if (rv) { - break; + if (rv) { + break; + } } - } - if (!rv) { - test_me(function () { - opts.conditions = []; - opts.rules = []; - opts.performAction = 'null'; // opts.options = {}; - // opts.caseHelperInclude = '{}'; - - opts.showSource = false; - opts.__in_rules_failure_analysis_mode__ = true; - dump = false; - }, 'One or more of your lexer rule action code block(s) are possibly botched?', ex, null); + if (!rv) { + test_me(function () { + opts.conditions = []; + opts.rules = []; + opts.performAction = 'null'; // opts.options = {}; + // opts.caseHelperInclude = '{}'; + + opts.showSource = false; + opts.__in_rules_failure_analysis_mode__ = true; + dump = false; + }, 'One or more of your lexer rule action code block(s) are possibly botched?', ex, null); + } } - } + })(); } } @@ -12447,11 +12657,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function getRegExpLexerPrototype() { // --- START lexer kernel --- - return "{\n EOF: 1,\n ERROR: 2,\n\n // JisonLexerError: JisonLexerError, /// <-- injected by the code generator\n\n // options: {}, /// <-- injected by the code generator\n\n // yy: ..., /// <-- injected by setInput()\n\n __currentRuleSet__: null, /// INTERNAL USE ONLY: internal rule set cache for the current lexer state\n\n __error_infos: [], /// INTERNAL USE ONLY: the set of lexErrorInfo objects created since the last cleanup\n\n __decompressed: false, /// INTERNAL USE ONLY: mark whether the lexer instance has been 'unfolded' completely and is now ready for use\n\n done: false, /// INTERNAL USE ONLY\n _backtrack: false, /// INTERNAL USE ONLY\n _input: '', /// INTERNAL USE ONLY\n _more: false, /// INTERNAL USE ONLY\n _signaled_error_token: false, /// INTERNAL USE ONLY\n _clear_state: 0, /// INTERNAL USE ONLY; 0: clear to do, 1: clear done for lex()/next(); -1: clear done for inut()/unput()/...\n\n conditionStack: [], /// INTERNAL USE ONLY; managed via `pushState()`, `popState()`, `topState()` and `stateStackSize()`\n\n match: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction. `match` is identical to `yytext` except that this one still contains the matched input string after `lexer.performAction()` has been invoked, where userland code MAY have changed/replaced the `yytext` value entirely!\n matched: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks entire input which has been matched so far\n matches: false, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks RE match result for last (successful) match attempt\n yytext: '', /// ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction; this value is transferred to the parser as the 'token value' when the parser consumes the lexer token produced through a call to the `lex()` API.\n offset: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks the 'cursor position' in the input string, i.e. the number of characters matched so far. (**WARNING:** this value MAY be negative if you `unput()` more text than you have already lexed. This type of behaviour is generally observed for one kind of 'lexer/parser hack' where custom token-illiciting characters are pushed in front of the input stream to help simulate multiple-START-points in the parser. When this happens, `base_position` will be adjusted to help track the original input's starting point in the `_input` buffer.)\n base_position: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: index to the original starting point of the input; always ZERO(0) unless `unput()` has pushed content before the input: see the `offset` **WARNING** just above.\n yyleng: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: length of matched input for the token under construction (`yytext`)\n yylineno: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: 'line number' at which the token under construction is located\n yylloc: null, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks location info (lines + columns) for the token under construction\n CRLF_Re: /\\r\\n?|\\n/, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: regex used to split lines while tracking the lexer cursor position.\n\n /**\n * INTERNAL USE: construct a suitable error info hash object instance for `parseError`.\n *\n * @public\n * @this {RegExpLexer}\n */\n constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) {\n \"use strict\";\n \n msg = '' + msg;\n\n // heuristic to determine if the error message already contains a (partial) source code dump\n // as produced by either `showPosition()` or `prettyPrintRange()`:\n if (show_input_position == undefined) {\n show_input_position = !(msg.indexOf('\\n') > 0 && msg.indexOf('^') > 0);\n }\n if (this.yylloc && show_input_position) {\n if (typeof this.prettyPrintRange === 'function') {\n var pretty_src = this.prettyPrintRange(this.yylloc);\n\n if (!/\\n\\s*$/.test(msg)) {\n msg += '\\n';\n }\n msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc);\n } else if (typeof this.showPosition === 'function') {\n var pos_str = this.showPosition();\n if (pos_str) {\n if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') {\n msg += '\\n' + pos_str;\n } else {\n msg += pos_str;\n }\n }\n }\n }\n /** @constructor */\n var pei = {\n errStr: msg,\n recoverable: !!recoverable,\n text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'...\n token: null,\n line: this.yylineno,\n loc: this.yylloc,\n yy: this.yy, \n lexer: this,\n\n /**\n * and make sure the error info doesn't stay due to potential\n * ref cycle via userland code manipulations.\n * These would otherwise all be memory leak opportunities!\n *\n * Note that only array and object references are nuked as those\n * constitute the set of elements which can produce a cyclic ref.\n * The rest of the members is kept intact as they are harmless.\n *\n * @public\n * @this {LexErrorInfo}\n */\n destroy: function destructLexErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // ...\n \"use strict\";\n var rec = !!this.recoverable;\n for (var key in this) {\n if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n },\n\n /**\n * handler which is invoked when a lexer error occurs.\n *\n * @public\n * @this {RegExpLexer}\n */\n parseError: function lexer_parseError(str, hash, ExceptionClass) {\n \"use strict\";\n\n if (!ExceptionClass) {\n ExceptionClass = this.JisonLexerError;\n }\n if (this.yy) {\n if (this.yy.parser && typeof this.yy.parser.parseError === 'function') {\n return this.yy.parser.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n } else if (typeof this.yy.parseError === 'function') {\n return this.yy.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n }\n }\n throw new ExceptionClass(str, hash);\n },\n\n /**\n * method which implements `yyerror(str, ...args)` functionality for use inside lexer actions.\n *\n * @public\n * @this {RegExpLexer}\n */\n yyerror: function yyError(str /*, ...args */) {\n \"use strict\";\n\n var lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable);\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n var args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n p.extra_error_attributes = args;\n }\n\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n },\n\n /**\n * final cleanup function for when we have completed lexing the input;\n * make it an API so that external code can use this one once userland\n * code has decided it's time to destroy any lingering lexer error\n * hash object instances and the like: this function helps to clean\n * up these constructs, which *may* carry cyclic references which would\n * otherwise prevent the instances from being properly and timely\n * garbage-collected, i.e. this function helps prevent memory leaks!\n *\n * @public\n * @this {RegExpLexer}\n */\n cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) {\n \"use strict\";\n\n // prevent lingering circular references from causing memory leaks:\n this.setInput('', {});\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (var i = this.__error_infos.length - 1; i >= 0; i--) {\n var el = this.__error_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n }\n\n return this;\n },\n\n /**\n * clear the lexer token context; intended for internal use only\n *\n * @public\n * @this {RegExpLexer}\n */\n clear: function lexer_clear() {\n \"use strict\";\n\n this.yytext = '';\n this.yyleng = 0;\n this.match = '';\n // - DO NOT reset `this.matched`\n this.matches = false;\n\n this._more = false;\n this._backtrack = false;\n\n var col = this.yylloc.last_column;\n this.yylloc = {\n first_line: this.yylineno + 1,\n first_column: col,\n last_line: this.yylineno + 1,\n last_column: col,\n\n range: [this.offset, this.offset]\n };\n },\n\n /**\n * resets the lexer, sets new input\n *\n * @public\n * @this {RegExpLexer}\n */\n setInput: function lexer_setInput(input, yy) {\n \"use strict\";\n\n this.yy = yy || this.yy || {};\n\n // also check if we've fully initialized the lexer instance,\n // including expansion work to be done to go from a loaded\n // lexer to a usable lexer:\n if (!this.__decompressed) {\n // step 1: decompress the regex list:\n var rules = this.rules;\n for (var i = 0, len = rules.length; i < len; i++) {\n var rule_re = rules[i];\n\n // compression: is the RE an xref to another RE slot in the rules[] table?\n if (typeof rule_re === 'number') {\n rules[i] = rules[rule_re];\n }\n }\n\n // step 2: unfold the conditions[] set to make these ready for use:\n var conditions = this.conditions;\n for (var k in conditions) {\n var spec = conditions[k];\n\n var rule_ids = spec.rules;\n\n var len = rule_ids.length;\n var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple!\n var rule_new_ids = new Array(len + 1);\n\n for (var i = 0; i < len; i++) {\n var idx = rule_ids[i];\n var rule_re = rules[idx];\n rule_regexes[i + 1] = rule_re;\n rule_new_ids[i + 1] = idx;\n }\n\n spec.rules = rule_new_ids;\n spec.__rule_regexes = rule_regexes;\n spec.__rule_count = len;\n }\n\n this.__decompressed = true;\n }\n\n if (input && typeof input !== 'string') {\n input = '' + input;\n }\n this._input = input || '';\n this._clear_state = -1;\n this._signaled_error_token = false;\n this.done = false;\n this.yylineno = 0;\n this.matched = '';\n this.conditionStack = ['INITIAL'];\n this.__currentRuleSet__ = null;\n this.yylloc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [0, 0]\n };\n this.offset = 0;\n this.base_position = 0;\n // apply these bits of `this.clear()` as well:\n this.yytext = '';\n this.yyleng = 0;\n this.match = '';\n this.matches = false;\n\n this._more = false;\n this._backtrack = false;\n\n return this;\n },\n\n /**\n * edit the remaining input via user-specified callback.\n * This can be used to forward-adjust the input-to-parse,\n * e.g. inserting macro expansions and alike in the\n * input which has yet to be lexed.\n * The behaviour of this API contrasts the `unput()` et al\n * APIs as those act on the *consumed* input, while this\n * one allows one to manipulate the future, without impacting\n * the current `yyloc` cursor location or any history.\n *\n * Use this API to help implement C-preprocessor-like\n * `#include` statements, etc.\n *\n * The provided callback must be synchronous and is\n * expected to return the edited input (string).\n *\n * The `cpsArg` argument value is passed to the callback\n * as-is.\n *\n * `callback` interface:\n * `function callback(input, cpsArg)`\n *\n * - `input` will carry the remaining-input-to-lex string\n * from the lexer.\n * - `cpsArg` is `cpsArg` passed into this API.\n *\n * The `this` reference for the callback will be set to\n * reference this lexer instance so that userland code\n * in the callback can easily and quickly access any lexer\n * API.\n *\n * When the callback returns a non-string-type falsey value,\n * we assume the callback did not edit the input and we\n * will using the input as-is.\n *\n * When the callback returns a non-string-type value, it\n * is converted to a string for lexing via the `\"\" + retval`\n * operation. (See also why: http://2ality.com/2012/03/converting-to-string.html\n * -- that way any returned object's `toValue()` and `toString()`\n * methods will be invoked in a proper/desirable order.)\n *\n * @public\n * @this {RegExpLexer}\n */\n editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) {\n \"use strict\";\n\n var rv = callback.call(this, this._input, cpsArg);\n if (typeof rv !== 'string') {\n if (rv) {\n this._input = '' + rv;\n }\n // else: keep `this._input` as is.\n } else {\n this._input = rv;\n }\n return this;\n },\n\n /**\n * consumes and returns one char from the input\n *\n * @public\n * @this {RegExpLexer}\n */\n input: function lexer_input() {\n \"use strict\";\n\n if (!this._input) {\n //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*)\n return null;\n }\n if (!this._clear_state && !this._more) {\n this._clear_state = -1;\n this.clear();\n }\n var ch = this._input[0];\n this.yytext += ch;\n this.yyleng++;\n this.offset++;\n this.match += ch;\n this.matched += ch;\n // Count the linenumber up when we hit the LF (or a stand-alone CR).\n // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo\n // and we advance immediately past the LF as well, returning both together as if\n // it was all a single 'character' only.\n var slice_len = 1;\n var lines = false;\n if (ch === '\\n') {\n lines = true;\n } else if (ch === '\\r') {\n lines = true;\n var ch2 = this._input[1];\n if (ch2 === '\\n') {\n slice_len++;\n ch += ch2;\n this.yytext += ch2;\n this.yyleng++;\n this.offset++;\n this.match += ch2;\n this.matched += ch2;\n this.yylloc.range[1]++;\n }\n }\n if (lines) {\n this.yylineno++;\n this.yylloc.last_line++;\n this.yylloc.last_column = 0;\n } else {\n this.yylloc.last_column++;\n }\n this.yylloc.range[1]++;\n\n this._input = this._input.slice(slice_len);\n return ch;\n },\n\n /**\n * unshifts one char (or an entire string) into the input\n *\n * @public\n * @this {RegExpLexer}\n */\n unput: function lexer_unput(ch) {\n \"use strict\";\n\n var len = ch.length;\n var lines = ch.split(this.CRLF_Re);\n\n if (!this._clear_state && !this._more) {\n this._clear_state = -1;\n this.clear();\n }\n\n this._input = ch + this._input;\n this.yytext = this.yytext.substr(0, this.yytext.length - len);\n this.yyleng = this.yytext.length;\n this.offset -= len;\n // **WARNING:**\n // The `offset` value MAY be negative if you `unput()` more text than you have already lexed.\n // This type of behaviour is generally observed for one kind of 'lexer/parser hack'\n // where custom token-illiciting characters are pushed in front of the input stream to help\n // simulate multiple-START-points in the parser.\n // When this happens, `base_position` will be adjusted to help track the original input's\n // starting point in the `_input` buffer.\n if (-this.offset > this.base_position) {\n this.base_position = -this.offset;\n }\n this.match = this.match.substr(0, this.match.length - len);\n this.matched = this.matched.substr(0, this.matched.length - len);\n\n if (lines.length > 1) {\n this.yylineno -= lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n\n // Get last entirely matched line into the `pre_lines[]` array's\n // last index slot; we don't mind when other previously\n // matched lines end up in the array too.\n var pre = this.match;\n var pre_lines = pre.split(this.CRLF_Re);\n if (pre_lines.length === 1) {\n pre = this.matched;\n pre_lines = pre.split(this.CRLF_Re);\n }\n this.yylloc.last_column = pre_lines[pre_lines.length - 1].length;\n } else {\n this.yylloc.last_column -= len;\n }\n\n this.yylloc.range[1] = this.yylloc.range[0] + this.yyleng;\n\n this.done = false;\n return this;\n },\n\n /**\n * return the upcoming input *which has not been lexed yet*.\n * This can, for example, be used for custom look-ahead inspection code \n * in your lexer.\n * \n * The entire pending input string is returned.\n *\n * > ### NOTE ###\n * >\n * > When augmenting error reports and alike, you might want to\n * > look at the `upcomingInput()` API instead, which offers more\n * > features for limited input extraction and which includes the\n * > part of the input which has been lexed by the last token a.k.a.\n * > the *currently lexed* input.\n * > \n * \n * @public\n * @this {RegExpLexer}\n */\n lookAhead: function lexer_lookAhead() {\n \"use strict\";\n\n return this._input || '';\n },\n\n /**\n * cache matched text and append it on next action\n *\n * @public\n * @this {RegExpLexer}\n */\n more: function lexer_more() {\n \"use strict\";\n\n this._more = true;\n return this;\n },\n\n /**\n * signal the lexer that this rule fails to match the input, so the\n * next matching rule (regex) should be tested instead.\n *\n * @public\n * @this {RegExpLexer}\n */\n reject: function lexer_reject() {\n \"use strict\";\n\n if (this.options.backtrack_lexer) {\n this._backtrack = true;\n } else {\n // when the `parseError()` call returns, we MUST ensure that the error is registered.\n // We accomplish this by signaling an 'error' token to be produced for the current\n // `.lex()` run.\n var lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false);\n this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n return this;\n },\n\n /**\n * retain first n characters of the match\n *\n * @public\n * @this {RegExpLexer}\n */\n less: function lexer_less(n) {\n \"use strict\";\n\n return this.unput(this.match.slice(n));\n },\n\n /**\n * return (part of the) already matched input, i.e. for error\n * messages.\n *\n * Limit the returned string length to `maxSize` (default: 20).\n *\n * Limit the returned string to the `maxLines` number of lines of\n * input (default: 1).\n *\n * A negative `maxSize` limit value equals *unlimited*, i.e.\n * produce the entire input that has already been lexed.\n *\n * A negative `maxLines` limit value equals *unlimited*, i.e. limit the result\n * to the `maxSize` specified number of characters *only*.\n *\n * @public\n * @this {RegExpLexer}\n */\n pastInput: function lexer_pastInput(maxSize, maxLines) {\n \"use strict\";\n\n var past = this.matched.substring(0, this.matched.length - this.match.length);\n if (maxSize < 0)\n maxSize = Infinity;\n else if (!maxSize)\n maxSize = 20;\n if (maxLines < 0)\n maxLines = Infinity; // can't ever have more input lines than this!\n else if (!maxLines)\n maxLines = 1;\n // `substr` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we've transformed and limited the newLines in here:\n past = past.substr(-maxSize * 2 - 2);\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n var a = past.split(this.CRLF_Re);\n a = a.slice(-maxLines);\n past = a.join('\\n');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis prefix...\n if (past.length > maxSize) {\n past = '...' + past.substr(-maxSize);\n }\n return past;\n },\n\n /**\n * return (part of the) upcoming input *including* the input \n * matched by the last token (see also the NOTE below). \n * This can be used to augment error messages, for example.\n *\n * Limit the returned string length to `maxSize` (default: 20).\n *\n * Limit the returned string to the `maxLines` number of lines of input (default: 1).\n *\n * A negative `maxSize` limit value equals *unlimited*, i.e.\n * produce the entire input that is yet to be lexed.\n *\n * A negative `maxLines` limit value equals *unlimited*, i.e. limit the result\n * to the `maxSize` specified number of characters *only*.\n *\n * > ### NOTE ###\n * >\n * > *\"upcoming input\"* is defined as the whole of the both\n * > the *currently lexed* input, together with any remaining input\n * > following that. *\"currently lexed\"* input is the input\n * > already recognized by the lexer but not yet returned with\n * > the lexer token. This happens when you are invoking this API\n * > from inside any lexer rule action code block.\n * >\n * > When you want access to the 'upcoming input' in that you want access\n * > to the input *which has not been lexed yet* for look-ahead\n * > inspection or likewise purposes, please consider using the\n * > `lookAhead()` API instead.\n * > \n * \n * @public\n * @this {RegExpLexer}\n */\n upcomingInput: function lexer_upcomingInput(maxSize, maxLines) {\n \"use strict\";\n\n var next = this.match;\n var source = this._input || '';\n if (maxSize < 0)\n maxSize = next.length + source.length;\n else if (!maxSize)\n maxSize = 20;\n if (maxLines < 0)\n maxLines = maxSize; // can't ever have more input lines than this!\n else if (!maxLines)\n maxLines = 1;\n // `substring` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we've transformed and limited the newLines in here:\n if (next.length < maxSize * 2 + 2) {\n next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8\n }\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines.\n a = a.slice(0, maxLines);\n next = a.join('\\n');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis postfix...\n if (next.length > maxSize) {\n next = next.substring(0, maxSize) + '...';\n }\n return next;\n },\n\n /**\n * return a string which displays the character position where the\n * lexing error occurred, i.e. for error messages\n *\n * @public\n * @this {RegExpLexer}\n */\n showPosition: function lexer_showPosition(maxPrefix, maxPostfix) {\n \"use strict\";\n\n var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' ');\n var c = new Array(pre.length + 1).join('-');\n return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^';\n },\n\n /**\n * return an YYLLOC info object derived off the given context (actual, preceding, following, current).\n * Use this method when the given `actual` location is not guaranteed to exist (i.e. when\n * it MAY be NULL) and you MUST have a valid location info object anyway:\n * then we take the given context of the `preceding` and `following` locations, IFF those are available,\n * and reconstruct the `actual` location info from those.\n * If this fails, the heuristic is to take the `current` location, IFF available.\n * If this fails as well, we assume the sought location is at/around the current lexer position\n * and then produce that one as a response. DO NOTE that these heuristic/derived location info\n * values MAY be inaccurate!\n *\n * NOTE: `deriveLocationInfo()` ALWAYS produces a location info object *copy* of `actual`, not just\n * a *reference* hence all input location objects can be assumed to be 'constant' (function has no side-effects).\n *\n * @public\n * @this {RegExpLexer}\n */\n deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) {\n \"use strict\";\n\n var loc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [0, 0]\n };\n if (actual) {\n loc.first_line = actual.first_line | 0;\n loc.last_line = actual.last_line | 0;\n loc.first_column = actual.first_column | 0;\n loc.last_column = actual.last_column | 0;\n\n if (actual.range) {\n loc.range[0] = actual.range[0] | 0;\n loc.range[1] = actual.range[1] | 0;\n }\n }\n if (loc.first_line <= 0 || loc.last_line < loc.first_line) {\n // plan B: heuristic using preceding and following:\n if (loc.first_line <= 0 && preceding) {\n loc.first_line = preceding.last_line | 0;\n loc.first_column = preceding.last_column | 0;\n\n if (preceding.range) {\n loc.range[0] = actual.range[1] | 0;\n }\n }\n\n if ((loc.last_line <= 0 || loc.last_line < loc.first_line) && following) {\n loc.last_line = following.first_line | 0;\n loc.last_column = following.first_column | 0;\n\n if (following.range) {\n loc.range[1] = actual.range[0] | 0;\n }\n }\n\n // plan C?: see if the 'current' location is useful/sane too:\n if (loc.first_line <= 0 && current && (loc.last_line <= 0 || current.last_line <= loc.last_line)) {\n loc.first_line = current.first_line | 0;\n loc.first_column = current.first_column | 0;\n\n if (current.range) {\n loc.range[0] = current.range[0] | 0;\n }\n }\n\n if (loc.last_line <= 0 && current && (loc.first_line <= 0 || current.first_line >= loc.first_line)) {\n loc.last_line = current.last_line | 0;\n loc.last_column = current.last_column | 0;\n\n if (current.range) {\n loc.range[1] = current.range[1] | 0;\n }\n }\n }\n // sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter\n // or plan D heuristics to produce a 'sensible' last_line value:\n if (loc.last_line <= 0) {\n if (loc.first_line <= 0) {\n loc.first_line = this.yylloc.first_line;\n loc.last_line = this.yylloc.last_line;\n loc.first_column = this.yylloc.first_column;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[0] = this.yylloc.range[0];\n loc.range[1] = this.yylloc.range[1];\n } else {\n loc.last_line = this.yylloc.last_line;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[1] = this.yylloc.range[1];\n }\n }\n if (loc.first_line <= 0) {\n loc.first_line = loc.last_line;\n loc.first_column = 0; // loc.last_column;\n\n loc.range[1] = loc.range[0];\n }\n if (loc.first_column < 0) {\n loc.first_column = 0;\n }\n if (loc.last_column < 0) {\n loc.last_column = (loc.first_column > 0 ? loc.first_column : 80);\n }\n return loc;\n },\n\n /**\n * return a string which displays the lines & columns of input which are referenced\n * by the given location info range, plus a few lines of context.\n *\n * This function pretty-prints the indicated section of the input, with line numbers\n * and everything!\n *\n * This function is very useful to provide highly readable error reports, while\n * the location range may be specified in various flexible ways:\n *\n * - `loc` is the location info object which references the area which should be\n * displayed and 'marked up': these lines & columns of text are marked up by `^`\n * characters below each character in the entire input range.\n *\n * - `context_loc` is the *optional* location info object which instructs this\n * pretty-printer how much *leading* context should be displayed alongside\n * the area referenced by `loc`. This can help provide context for the displayed\n * error, etc.\n *\n * When this location info is not provided, a default context of 3 lines is\n * used.\n *\n * - `context_loc2` is another *optional* location info object, which serves\n * a similar purpose to `context_loc`: it specifies the amount of *trailing*\n * context lines to display in the pretty-print output.\n *\n * When this location info is not provided, a default context of 1 line only is\n * used.\n *\n * Special Notes:\n *\n * - when the `loc`-indicated range is very large (about 5 lines or more), then\n * only the first and last few lines of this block are printed while a\n * `...continued...` message will be printed between them.\n *\n * This serves the purpose of not printing a huge amount of text when the `loc`\n * range happens to be huge: this way a manageable & readable output results\n * for arbitrary large ranges.\n *\n * - this function can display lines of input which whave not yet been lexed.\n * `prettyPrintRange()` can access the entire input!\n *\n * @public\n * @this {RegExpLexer}\n */\n prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) {\n \"use strict\";\n\n loc = this.deriveLocationInfo(loc, context_loc, context_loc2);\n\n const CONTEXT = 3;\n const CONTEXT_TAIL = 1;\n const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2;\n var input = this.matched + (this._input || '');\n var lines = input.split('\\n');\n var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT));\n var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL));\n var lineno_display_width = (1 + Math.log10(l1 | 1) | 0);\n var ws_prefix = new Array(lineno_display_width).join(' ');\n var nonempty_line_indexes = [[], [], []];\n var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) {\n \"use strict\";\n\n var lno = index + l0;\n var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width);\n var rv = lno_pfx + ': ' + line;\n var errpfx = (new Array(lineno_display_width + 1)).join('^');\n var offset = 2 + 1;\n var len = 0;\n\n if (lno === loc.first_line) {\n offset += loc.first_column;\n\n len = Math.max(\n 2,\n ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1\n );\n } else if (lno === loc.last_line) {\n len = Math.max(2, loc.last_column + 1);\n } else if (lno > loc.first_line && lno < loc.last_line) {\n len = Math.max(2, line.length + 1);\n }\n\n var nli;\n if (len) {\n var lead = new Array(offset).join('.');\n var mark = new Array(len).join('^');\n rv += '\\n' + errpfx + lead + mark;\n\n nli = 1;\n } else if (lno < loc.first_line) {\n nli = 0;\n } else if (lno > loc.last_line) {\n nli = 2;\n }\n\n if (line.trim().length > 0) {\n nonempty_line_indexes[nli].push(index);\n }\n\n rv = rv.replace(/\\t/g, ' ');\n return rv;\n });\n\n // now make sure we don't print an overly large amount of lead/error/tail area: limit it\n // to the top and bottom line count:\n for (var i = 0; i <= 2; i++) {\n var line_arr = nonempty_line_indexes[i];\n if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) {\n var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1;\n var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1;\n\n var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)';\n if (i === 1) {\n intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)';\n }\n rv.splice(clip_start, clip_end - clip_start + 1, intermediate_line);\n }\n }\n\n return rv.join('\\n');\n },\n\n /**\n * helper function, used to produce a human readable description as a string, given\n * the input `yylloc` location object.\n *\n * Set `display_range_too` to TRUE to include the string character index position(s)\n * in the description if the `yylloc.range` is available.\n *\n * @public\n * @this {RegExpLexer}\n */\n describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) {\n \"use strict\";\n\n var l1 = yylloc.first_line;\n var l2 = yylloc.last_line;\n var c1 = yylloc.first_column;\n var c2 = yylloc.last_column;\n var dl = l2 - l1;\n var dc = c2 - c1;\n var rv;\n if (dl === 0) {\n rv = 'line ' + l1 + ', ';\n if (dc <= 1) {\n rv += 'column ' + c1;\n } else {\n rv += 'columns ' + c1 + ' .. ' + c2;\n }\n } else {\n rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')';\n }\n if (yylloc.range && display_range_too) {\n var r1 = yylloc.range[0];\n var r2 = yylloc.range[1] - 1;\n if (r2 <= r1) {\n rv += ' {String Offset: ' + r1 + '}';\n } else {\n rv += ' {String Offset range: ' + r1 + ' .. ' + r2 + '}';\n }\n }\n return rv;\n },\n\n /**\n * test the lexed token: return FALSE when not a match, otherwise return token.\n *\n * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]`\n * contains the actually matched text string.\n *\n * Also move the input cursor forward and update the match collectors:\n *\n * - `yytext`\n * - `yyleng`\n * - `match`\n * - `matches`\n * - `yylloc`\n * - `offset`\n *\n * @public\n * @this {RegExpLexer}\n */\n test_match: function lexer_test_match(match, indexed_rule) {\n \"use strict\";\n\n var token,\n lines,\n backup,\n match_str,\n match_str_len;\n\n if (this.options.backtrack_lexer) {\n // save context\n backup = {\n yylineno: this.yylineno,\n yylloc: {\n first_line: this.yylloc.first_line,\n last_line: this.yylloc.last_line,\n first_column: this.yylloc.first_column,\n last_column: this.yylloc.last_column,\n\n range: this.yylloc.range.slice()\n },\n yytext: this.yytext,\n match: this.match,\n matches: this.matches,\n matched: this.matched,\n yyleng: this.yyleng,\n offset: this.offset,\n _more: this._more,\n _input: this._input,\n //_signaled_error_token: this._signaled_error_token,\n yy: this.yy,\n conditionStack: this.conditionStack.slice(),\n done: this.done\n };\n }\n\n match_str = match[0];\n match_str_len = match_str.length;\n\n lines = match_str.split(this.CRLF_Re);\n if (lines.length > 1) {\n this.yylineno += lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n this.yylloc.last_column = lines[lines.length - 1].length;\n } else {\n this.yylloc.last_column += match_str_len;\n }\n\n this.yytext += match_str;\n this.match += match_str;\n this.matched += match_str;\n this.matches = match;\n this.yyleng = this.yytext.length;\n this.yylloc.range[1] += match_str_len;\n\n // previous lex rules MAY have invoked the `more()` API rather than producing a token:\n // those rules will already have moved this `offset` forward matching their match lengths,\n // hence we must only add our own match length now:\n this.offset += match_str_len;\n this._more = false;\n this._backtrack = false;\n this._input = this._input.slice(match_str_len);\n\n // calling this method:\n //\n // function lexer__performAction(yy, yyrulenumber, YY_START) {...}\n token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */);\n // otherwise, when the action codes are all simple return token statements:\n //token = this.simpleCaseActionClusters[indexed_rule];\n\n if (this.done && this._input) {\n this.done = false;\n }\n if (token) {\n return token;\n } else if (this._backtrack) {\n // recover context\n for (var k in backup) {\n this[k] = backup[k];\n }\n this.__currentRuleSet__ = null;\n return false; // rule action called reject() implying the next rule should be tested instead.\n } else if (this._signaled_error_token) {\n // produce one 'error' token as `.parseError()` in `reject()`\n // did not guarantee a failure signal by throwing an exception!\n token = this._signaled_error_token;\n this._signaled_error_token = false;\n return token;\n }\n return false;\n },\n\n /**\n * return next match in input\n *\n * @public\n * @this {RegExpLexer}\n */\n next: function lexer_next() {\n \"use strict\";\n\n if (this.done) {\n this.clear();\n return this.EOF;\n }\n if (!this._input) {\n this.done = true;\n }\n\n var token,\n match,\n tempMatch,\n index;\n if (!this._more) {\n if (!this._clear_state) {\n this._clear_state = 1;\n }\n this.clear();\n }\n var spec = this.__currentRuleSet__;\n if (!spec) {\n // Update the ruleset cache as we apparently encountered a state change or just started lexing.\n // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will\n // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps\n // speed up those activities a tiny bit.\n spec = this.__currentRuleSet__ = this._currentRules();\n // Check whether a *sane* condition has been pushed before: this makes the lexer robust against\n // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19\n if (!spec || !spec.rules) {\n var lineno_msg = '';\n if (this.yylloc) {\n lineno_msg = ' on line ' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name \"' + this.topState() + '\"; this is a fatal error and should be reported to the application programmer team!', false);\n // produce one 'error' token until this situation has been resolved, most probably by parse termination!\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n }\n\n var rule_ids = spec.rules;\n var regexes = spec.__rule_regexes;\n var len = spec.__rule_count;\n\n // Note: the arrays are 1-based, while `len` itself is a valid index,\n // hence the non-standard less-or-equal check in the next loop condition!\n for (var i = 1; i <= len; i++) {\n tempMatch = this._input.match(regexes[i]);\n if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n match = tempMatch;\n index = i;\n if (this.options.backtrack_lexer) {\n token = this.test_match(tempMatch, rule_ids[i]);\n if (token !== false) {\n return token;\n } else if (this._backtrack) {\n match = undefined;\n continue; // rule action called reject() implying a rule MISmatch.\n } else {\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n } else if (!this.options.flex) {\n break;\n }\n }\n }\n if (match) {\n token = this.test_match(match, rule_ids[index]);\n if (token !== false) {\n return token;\n }\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n if (!this._input) {\n this.done = true;\n this.clear();\n return this.EOF;\n } else {\n var lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable);\n\n var pendingInput = this._input;\n var activeCondition = this.topState();\n var conditionStackDepth = this.conditionStack.length;\n\n token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n if (token === this.ERROR) {\n // we can try to recover from a lexer error that `parseError()` did not 'recover' for us\n // by moving forward at least one character at a time IFF the (user-specified?) `parseError()`\n // has not consumed/modified any pending input or changed state in the error handler:\n if (!this.matches &&\n // and make sure the input has been modified/consumed ...\n pendingInput === this._input &&\n // ...or the lexer state has been modified significantly enough\n // to merit a non-consuming error handling action right now.\n activeCondition === this.topState() &&\n conditionStackDepth === this.conditionStack.length\n ) {\n this.input();\n }\n }\n return token;\n }\n },\n\n /**\n * return next match that has a token\n *\n * @public\n * @this {RegExpLexer}\n */\n lex: function lexer_lex() {\n \"use strict\";\n\n var r;\n\n //this._clear_state = 0;\n\n if (!this._more) {\n if (!this._clear_state) {\n this._clear_state = 1;\n }\n this.clear();\n }\n\n // allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer:\n if (typeof this.pre_lex === 'function') {\n r = this.pre_lex.call(this, 0);\n }\n if (typeof this.options.pre_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.pre_lex.call(this, r) || r;\n }\n if (this.yy && typeof this.yy.pre_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.pre_lex.call(this, r) || r;\n }\n\n while (!r) {\n r = this.next();\n }\n\n if (this.yy && typeof this.yy.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.post_lex.call(this, r) || r;\n }\n if (typeof this.options.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.post_lex.call(this, r) || r;\n }\n if (typeof this.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.post_lex.call(this, r) || r;\n }\n\n if (!this._more) {\n //\n // 1) make sure any outside interference is detected ASAP: \n // these attributes are to be treated as 'const' values\n // once the lexer has produced them with the token (return value `r`).\n // 2) make sure any subsequent `lex()` API invocation CANNOT\n // edit the `yytext`, etc. token attributes for the *current*\n // token, i.e. provide a degree of 'closure safety' so that\n // code like this:\n // \n // t1 = lexer.lex();\n // v = lexer.yytext;\n // l = lexer.yylloc;\n // t2 = lexer.lex();\n // assert(lexer.yytext !== v);\n // assert(lexer.yylloc !== l);\n // \n // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee*\n // these conditions.\n // \n this.yytext = Object.freeze(this.yytext);\n this.matches = Object.freeze(this.matches);\n this.yylloc.range = Object.freeze(this.yylloc.range);\n this.yylloc = Object.freeze(this.yylloc);\n\n this._clear_state = 0;\n }\n\n return r;\n },\n\n /**\n * return next match that has a token. Identical to the `lex()` API but does not invoke any of the\n * `pre_lex()` nor any of the `post_lex()` callbacks.\n *\n * @public\n * @this {RegExpLexer}\n */\n fastLex: function lexer_fastLex() {\n \"use strict\";\n\n var r;\n\n //this._clear_state = 0;\n\n while (!r) {\n r = this.next();\n }\n\n if (!this._more) {\n //\n // 1) make sure any outside interference is detected ASAP: \n // these attributes are to be treated as 'const' values\n // once the lexer has produced them with the token (return value `r`).\n // 2) make sure any subsequent `lex()` API invocation CANNOT\n // edit the `yytext`, etc. token attributes for the *current*\n // token, i.e. provide a degree of 'closure safety' so that\n // code like this:\n // \n // t1 = lexer.lex();\n // v = lexer.yytext;\n // l = lexer.yylloc;\n // t2 = lexer.lex();\n // assert(lexer.yytext !== v);\n // assert(lexer.yylloc !== l);\n // \n // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee*\n // these conditions.\n // \n this.yytext = Object.freeze(this.yytext);\n this.matches = Object.freeze(this.matches);\n this.yylloc.range = Object.freeze(this.yylloc.range);\n this.yylloc = Object.freeze(this.yylloc);\n\n this._clear_state = 0;\n }\n \n return r;\n },\n\n /**\n * return info about the lexer state that can help a parser or other lexer API user to use the\n * most efficient means available. This API is provided to aid run-time performance for larger\n * systems which employ this lexer.\n *\n * @public\n * @this {RegExpLexer}\n */\n canIUse: function lexer_canIUse() {\n \"use strict\";\n\n var rv = {\n fastLex: !(\n typeof this.pre_lex === 'function' ||\n typeof this.options.pre_lex === 'function' ||\n (this.yy && typeof this.yy.pre_lex === 'function') ||\n (this.yy && typeof this.yy.post_lex === 'function') ||\n typeof this.options.post_lex === 'function' ||\n typeof this.post_lex === 'function'\n ) && typeof this.fastLex === 'function',\n };\n return rv;\n },\n\n\n /**\n * backwards compatible alias for `pushState()`;\n * the latter is symmetrical with `popState()` and we advise to use\n * those APIs in any modern lexer code, rather than `begin()`.\n *\n * @public\n * @this {RegExpLexer}\n */\n begin: function lexer_begin(condition) {\n \"use strict\";\n\n return this.pushState(condition);\n },\n\n /**\n * activates a new lexer condition state (pushes the new lexer\n * condition state onto the condition stack)\n *\n * @public\n * @this {RegExpLexer}\n */\n pushState: function lexer_pushState(condition) {\n \"use strict\";\n\n this.conditionStack.push(condition);\n this.__currentRuleSet__ = null;\n return this;\n },\n\n /**\n * pop the previously active lexer condition state off the condition\n * stack\n *\n * @public\n * @this {RegExpLexer}\n */\n popState: function lexer_popState() {\n \"use strict\";\n\n var n = this.conditionStack.length - 1;\n if (n > 0) {\n this.__currentRuleSet__ = null;\n return this.conditionStack.pop();\n } else {\n return this.conditionStack[0];\n }\n },\n\n /**\n * return the currently active lexer condition state; when an index\n * argument is provided it produces the N-th previous condition state,\n * if available\n *\n * @public\n * @this {RegExpLexer}\n */\n topState: function lexer_topState(n) {\n \"use strict\";\n\n n = this.conditionStack.length - 1 - Math.abs(n || 0);\n if (n >= 0) {\n return this.conditionStack[n];\n } else {\n return 'INITIAL';\n }\n },\n\n /**\n * (internal) determine the lexer rule set which is active for the\n * currently active lexer condition state\n *\n * @public\n * @this {RegExpLexer}\n */\n _currentRules: function lexer__currentRules() {\n \"use strict\";\n\n var n = this.conditionStack.length - 1;\n var state;\n if (n >= 0) {\n state = this.conditionStack[n];\n } else {\n state = 'INITIAL';\n }\n return this.conditions[state] || this.conditions['INITIAL'];\n },\n\n /**\n * return the number of states currently on the stack\n *\n * @public\n * @this {RegExpLexer}\n */\n stateStackSize: function lexer_stateStackSize() {\n \"use strict\";\n\n return this.conditionStack.length;\n }\n}"; // --- END lexer kernel --- + return "{\n EOF: 1,\n ERROR: 2,\n\n // JisonLexerError: JisonLexerError, /// <-- injected by the code generator\n\n // options: {}, /// <-- injected by the code generator\n\n // yy: ..., /// <-- injected by setInput()\n\n __currentRuleSet__: null, /// INTERNAL USE ONLY: internal rule set cache for the current lexer state\n\n __error_infos: [], /// INTERNAL USE ONLY: the set of lexErrorInfo objects created since the last cleanup\n\n __decompressed: false, /// INTERNAL USE ONLY: mark whether the lexer instance has been 'unfolded' completely and is now ready for use\n\n done: false, /// INTERNAL USE ONLY\n _backtrack: false, /// INTERNAL USE ONLY\n _input: '', /// INTERNAL USE ONLY\n _more: false, /// INTERNAL USE ONLY\n _signaled_error_token: false, /// INTERNAL USE ONLY\n _clear_state: 0, /// INTERNAL USE ONLY; 0: clear to do, 1: clear done for lex()/next(); -1: clear done for inut()/unput()/...\n\n conditionStack: [], /// INTERNAL USE ONLY; managed via `pushState()`, `popState()`, `topState()` and `stateStackSize()`\n\n match: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction. `match` is identical to `yytext` except that this one still contains the matched input string after `lexer.performAction()` has been invoked, where userland code MAY have changed/replaced the `yytext` value entirely!\n matched: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks entire input which has been matched so far\n matches: false, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks RE match result for last (successful) match attempt\n yytext: '', /// ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction; this value is transferred to the parser as the 'token value' when the parser consumes the lexer token produced through a call to the `lex()` API.\n offset: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks the 'cursor position' in the input string, i.e. the number of characters matched so far. (**WARNING:** this value MAY be negative if you `unput()` more text than you have already lexed. This type of behaviour is generally observed for one kind of 'lexer/parser hack' where custom token-illiciting characters are pushed in front of the input stream to help simulate multiple-START-points in the parser. When this happens, `base_position` will be adjusted to help track the original input's starting point in the `_input` buffer.)\n base_position: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: index to the original starting point of the input; always ZERO(0) unless `unput()` has pushed content before the input: see the `offset` **WARNING** just above.\n yyleng: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: length of matched input for the token under construction (`yytext`)\n yylineno: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: 'line number' at which the token under construction is located\n yylloc: null, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks location info (lines + columns) for the token under construction\n CRLF_Re: /\\r\\n?|\\n/, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: regex used to split lines while tracking the lexer cursor position.\n\n /**\n * INTERNAL USE: construct a suitable error info hash object instance for `parseError`.\n *\n * @public\n * @this {RegExpLexer}\n */\n constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) {\n msg = '' + msg;\n\n // heuristic to determine if the error message already contains a (partial) source code dump\n // as produced by either `showPosition()` or `prettyPrintRange()`:\n if (show_input_position == undefined) {\n show_input_position = !(msg.indexOf('\\n') > 0 && msg.indexOf('^') > 0);\n }\n if (this.yylloc && show_input_position) {\n if (typeof this.prettyPrintRange === 'function') {\n const pretty_src = this.prettyPrintRange(this.yylloc);\n\n if (!/\\n\\s*$/.test(msg)) {\n msg += '\\n';\n }\n msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc);\n } else if (typeof this.showPosition === 'function') {\n const pos_str = this.showPosition();\n if (pos_str) {\n if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') {\n msg += '\\n' + pos_str;\n } else {\n msg += pos_str;\n }\n }\n }\n }\n /** @constructor */\n const pei = {\n errStr: msg,\n recoverable: !!recoverable,\n text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'...\n token: null,\n line: this.yylineno,\n loc: this.yylloc,\n yy: this.yy,\n lexer: this,\n\n /**\n * and make sure the error info doesn't stay due to potential\n * ref cycle via userland code manipulations.\n * These would otherwise all be memory leak opportunities!\n *\n * Note that only array and object references are nuked as those\n * constitute the set of elements which can produce a cyclic ref.\n * The rest of the members is kept intact as they are harmless.\n *\n * @public\n * @this {LexErrorInfo}\n */\n destroy: function destructLexErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // ...\n const rec = !!this.recoverable;\n for (let key in this) {\n if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n },\n\n /**\n * handler which is invoked when a lexer error occurs.\n *\n * @public\n * @this {RegExpLexer}\n */\n parseError: function lexer_parseError(str, hash, ExceptionClass) {\n if (!ExceptionClass) {\n ExceptionClass = this.JisonLexerError;\n }\n if (this.yy) {\n if (this.yy.parser && typeof this.yy.parser.parseError === 'function') {\n return this.yy.parser.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n } else if (typeof this.yy.parseError === 'function') {\n return this.yy.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;\n }\n }\n throw new ExceptionClass(str, hash);\n },\n\n /**\n * method which implements `yyerror(str, ...args)` functionality for use inside lexer actions.\n *\n * @public\n * @this {RegExpLexer}\n */\n yyerror: function yyError(str /*, ...args */) {\n let lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable);\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n let args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n p.extra_error_attributes = args;\n }\n\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n },\n\n /**\n * final cleanup function for when we have completed lexing the input;\n * make it an API so that external code can use this one once userland\n * code has decided it's time to destroy any lingering lexer error\n * hash object instances and the like: this function helps to clean\n * up these constructs, which *may* carry cyclic references which would\n * otherwise prevent the instances from being properly and timely\n * garbage-collected, i.e. this function helps prevent memory leaks!\n *\n * @public\n * @this {RegExpLexer}\n */\n cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) {\n // prevent lingering circular references from causing memory leaks:\n this.setInput('', {});\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (let i = this.__error_infos.length - 1; i >= 0; i--) {\n let el = this.__error_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n }\n\n return this;\n },\n\n /**\n * clear the lexer token context; intended for internal use only\n *\n * @public\n * @this {RegExpLexer}\n */\n clear: function lexer_clear() {\n this.yytext = '';\n this.yyleng = 0;\n this.match = '';\n // - DO NOT reset `this.matched`\n this.matches = false;\n\n this._more = false;\n this._backtrack = false;\n\n const col = this.yylloc.last_column;\n this.yylloc = {\n first_line: this.yylineno + 1,\n first_column: col,\n last_line: this.yylineno + 1,\n last_column: col,\n\n range: [ this.offset, this.offset ]\n };\n },\n\n /**\n * resets the lexer, sets new input\n *\n * @public\n * @this {RegExpLexer}\n */\n setInput: function lexer_setInput(input, yy) {\n this.yy = yy || this.yy || {};\n\n // also check if we've fully initialized the lexer instance,\n // including expansion work to be done to go from a loaded\n // lexer to a usable lexer:\n if (!this.__decompressed) {\n // step 1: decompress the regex list:\n let rules = this.rules;\n for (var i = 0, len = rules.length; i < len; i++) {\n var rule_re = rules[i];\n\n // compression: is the RE an xref to another RE slot in the rules[] table?\n if (typeof rule_re === 'number') {\n rules[i] = rules[rule_re];\n }\n }\n\n // step 2: unfold the conditions[] set to make these ready for use:\n let conditions = this.conditions;\n for (let k in conditions) {\n let spec = conditions[k];\n\n let rule_ids = spec.rules;\n\n var len = rule_ids.length;\n let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple!\n let rule_new_ids = new Array(len + 1);\n\n for (var i = 0; i < len; i++) {\n let idx = rule_ids[i];\n var rule_re = rules[idx];\n rule_regexes[i + 1] = rule_re;\n rule_new_ids[i + 1] = idx;\n }\n\n spec.rules = rule_new_ids;\n spec.__rule_regexes = rule_regexes;\n spec.__rule_count = len;\n }\n\n this.__decompressed = true;\n }\n\n if (input && typeof input !== 'string') {\n input = '' + input;\n }\n this._input = input || '';\n this._clear_state = -1;\n this._signaled_error_token = false;\n this.done = false;\n this.yylineno = 0;\n this.matched = '';\n this.conditionStack = [ 'INITIAL' ];\n this.__currentRuleSet__ = null;\n this.yylloc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [ 0, 0 ]\n };\n this.offset = 0;\n this.base_position = 0;\n // apply these bits of `this.clear()` as well:\n this.yytext = '';\n this.yyleng = 0;\n this.match = '';\n this.matches = false;\n\n this._more = false;\n this._backtrack = false;\n\n return this;\n },\n\n /**\n * edit the remaining input via user-specified callback.\n * This can be used to forward-adjust the input-to-parse,\n * e.g. inserting macro expansions and alike in the\n * input which has yet to be lexed.\n * The behaviour of this API contrasts the `unput()` et al\n * APIs as those act on the *consumed* input, while this\n * one allows one to manipulate the future, without impacting\n * the current `yyloc` cursor location or any history.\n *\n * Use this API to help implement C-preprocessor-like\n * `#include` statements, etc.\n *\n * The provided callback must be synchronous and is\n * expected to return the edited input (string).\n *\n * The `cpsArg` argument value is passed to the callback\n * as-is.\n *\n * `callback` interface:\n * `function callback(input, cpsArg)`\n *\n * - `input` will carry the remaining-input-to-lex string\n * from the lexer.\n * - `cpsArg` is `cpsArg` passed into this API.\n *\n * The `this` reference for the callback will be set to\n * reference this lexer instance so that userland code\n * in the callback can easily and quickly access any lexer\n * API.\n *\n * When the callback returns a non-string-type falsey value,\n * we assume the callback did not edit the input and we\n * will using the input as-is.\n *\n * When the callback returns a non-string-type value, it\n * is converted to a string for lexing via the `\"\" + retval`\n * operation. (See also why: http://2ality.com/2012/03/converting-to-string.html\n * -- that way any returned object's `toValue()` and `toString()`\n * methods will be invoked in a proper/desirable order.)\n *\n * @public\n * @this {RegExpLexer}\n */\n editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) {\n const rv = callback.call(this, this._input, cpsArg);\n if (typeof rv !== 'string') {\n if (rv) {\n this._input = '' + rv;\n }\n // else: keep `this._input` as is.\n } else {\n this._input = rv;\n }\n return this;\n },\n\n /**\n * consumes and returns one char from the input\n *\n * @public\n * @this {RegExpLexer}\n */\n input: function lexer_input() {\n if (!this._input) {\n //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*)\n return null;\n }\n if (!this._clear_state && !this._more) {\n this._clear_state = -1;\n this.clear();\n }\n let ch = this._input[0];\n this.yytext += ch;\n this.yyleng++;\n this.offset++;\n this.match += ch;\n this.matched += ch;\n // Count the linenumber up when we hit the LF (or a stand-alone CR).\n // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo\n // and we advance immediately past the LF as well, returning both together as if\n // it was all a single 'character' only.\n let slice_len = 1;\n let lines = false;\n if (ch === '\\n') {\n lines = true;\n } else if (ch === '\\r') {\n lines = true;\n const ch2 = this._input[1];\n if (ch2 === '\\n') {\n slice_len++;\n ch += ch2;\n this.yytext += ch2;\n this.yyleng++;\n this.offset++;\n this.match += ch2;\n this.matched += ch2;\n this.yylloc.range[1]++;\n }\n }\n if (lines) {\n this.yylineno++;\n this.yylloc.last_line++;\n this.yylloc.last_column = 0;\n } else {\n this.yylloc.last_column++;\n }\n this.yylloc.range[1]++;\n\n this._input = this._input.slice(slice_len);\n return ch;\n },\n\n /**\n * unshifts one char (or an entire string) into the input\n *\n * @public\n * @this {RegExpLexer}\n */\n unput: function lexer_unput(ch) {\n let len = ch.length;\n let lines = ch.split(this.CRLF_Re);\n\n if (!this._clear_state && !this._more) {\n this._clear_state = -1;\n this.clear();\n }\n\n this._input = ch + this._input;\n this.yytext = this.yytext.substr(0, this.yytext.length - len);\n this.yyleng = this.yytext.length;\n this.offset -= len;\n // **WARNING:**\n // The `offset` value MAY be negative if you `unput()` more text than you have already lexed.\n // This type of behaviour is generally observed for one kind of 'lexer/parser hack'\n // where custom token-illiciting characters are pushed in front of the input stream to help\n // simulate multiple-START-points in the parser.\n // When this happens, `base_position` will be adjusted to help track the original input's\n // starting point in the `_input` buffer.\n if (-this.offset > this.base_position) {\n this.base_position = -this.offset;\n }\n this.match = this.match.substr(0, this.match.length - len);\n this.matched = this.matched.substr(0, this.matched.length - len);\n\n if (lines.length > 1) {\n this.yylineno -= lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n\n // Get last entirely matched line into the `pre_lines[]` array's\n // last index slot; we don't mind when other previously\n // matched lines end up in the array too.\n let pre = this.match;\n let pre_lines = pre.split(this.CRLF_Re);\n if (pre_lines.length === 1) {\n pre = this.matched;\n pre_lines = pre.split(this.CRLF_Re);\n }\n this.yylloc.last_column = pre_lines[pre_lines.length - 1].length;\n } else {\n this.yylloc.last_column -= len;\n }\n\n this.yylloc.range[1] = this.yylloc.range[0] + this.yyleng;\n\n this.done = false;\n return this;\n },\n\n /**\n * return the upcoming input *which has not been lexed yet*.\n * This can, for example, be used for custom look-ahead inspection code\n * in your lexer.\n *\n * The entire pending input string is returned.\n *\n * > ### NOTE ###\n * >\n * > When augmenting error reports and alike, you might want to\n * > look at the `upcomingInput()` API instead, which offers more\n * > features for limited input extraction and which includes the\n * > part of the input which has been lexed by the last token a.k.a.\n * > the *currently lexed* input.\n * >\n *\n * @public\n * @this {RegExpLexer}\n */\n lookAhead: function lexer_lookAhead() {\n return this._input || '';\n },\n\n /**\n * cache matched text and append it on next action\n *\n * @public\n * @this {RegExpLexer}\n */\n more: function lexer_more() {\n this._more = true;\n return this;\n },\n\n /**\n * signal the lexer that this rule fails to match the input, so the\n * next matching rule (regex) should be tested instead.\n *\n * @public\n * @this {RegExpLexer}\n */\n reject: function lexer_reject() {\n if (this.options.backtrack_lexer) {\n this._backtrack = true;\n } else {\n // when the `parseError()` call returns, we MUST ensure that the error is registered.\n // We accomplish this by signaling an 'error' token to be produced for the current\n // `.lex()` run.\n let lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false);\n this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n return this;\n },\n\n /**\n * retain first n characters of the match\n *\n * @public\n * @this {RegExpLexer}\n */\n less: function lexer_less(n) {\n return this.unput(this.match.slice(n));\n },\n\n /**\n * return (part of the) already matched input, i.e. for error\n * messages.\n *\n * Limit the returned string length to `maxSize` (default: 20).\n *\n * Limit the returned string to the `maxLines` number of lines of\n * input (default: 1).\n *\n * A negative `maxSize` limit value equals *unlimited*, i.e.\n * produce the entire input that has already been lexed.\n *\n * A negative `maxLines` limit value equals *unlimited*, i.e. limit the result\n * to the `maxSize` specified number of characters *only*.\n *\n * @public\n * @this {RegExpLexer}\n */\n pastInput: function lexer_pastInput(maxSize, maxLines) {\n let past = this.matched.substring(0, this.matched.length - this.match.length);\n if (maxSize < 0) {\n maxSize = Infinity;\n } else if (!maxSize) {\n maxSize = 20;\n }\n if (maxLines < 0) {\n maxLines = Infinity; // can't ever have more input lines than this!\n } else if (!maxLines) {\n maxLines = 1;\n }\n // `substr` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we've transformed and limited the newLines in here:\n past = past.substr(-maxSize * 2 - 2);\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n let a = past.split(this.CRLF_Re);\n a = a.slice(-maxLines);\n past = a.join('\\n');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis prefix...\n if (past.length > maxSize) {\n past = '...' + past.substr(-maxSize);\n }\n return past;\n },\n\n /**\n * return (part of the) upcoming input *including* the input\n * matched by the last token (see also the NOTE below).\n * This can be used to augment error messages, for example.\n *\n * Limit the returned string length to `maxSize` (default: 20).\n *\n * Limit the returned string to the `maxLines` number of lines of input (default: 1).\n *\n * A negative `maxSize` limit value equals *unlimited*, i.e.\n * produce the entire input that is yet to be lexed.\n *\n * A negative `maxLines` limit value equals *unlimited*, i.e. limit the result\n * to the `maxSize` specified number of characters *only*.\n *\n * > ### NOTE ###\n * >\n * > *\"upcoming input\"* is defined as the whole of the both\n * > the *currently lexed* input, together with any remaining input\n * > following that. *\"currently lexed\"* input is the input\n * > already recognized by the lexer but not yet returned with\n * > the lexer token. This happens when you are invoking this API\n * > from inside any lexer rule action code block.\n * >\n * > When you want access to the 'upcoming input' in that you want access\n * > to the input *which has not been lexed yet* for look-ahead\n * > inspection or likewise purposes, please consider using the\n * > `lookAhead()` API instead.\n * >\n *\n * @public\n * @this {RegExpLexer}\n */\n upcomingInput: function lexer_upcomingInput(maxSize, maxLines) {\n let next = this.match;\n let source = this._input || '';\n if (maxSize < 0) {\n maxSize = next.length + source.length;\n } else if (!maxSize) {\n maxSize = 20;\n }\n\n if (maxLines < 0) {\n maxLines = maxSize; // can't ever have more input lines than this!\n } else if (!maxLines) {\n maxLines = 1;\n }\n // `substring` anticipation: treat \\r\\n as a single character and take a little\n // more than necessary so that we can still properly check against maxSize\n // after we've transformed and limited the newLines in here:\n if (next.length < maxSize * 2 + 2) {\n next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8\n }\n // now that we have a significantly reduced string to process, transform the newlines\n // and chop them, then limit them:\n let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines.\n a = a.slice(0, maxLines);\n next = a.join('\\n');\n // When, after limiting to maxLines, we still have too much to return,\n // do add an ellipsis postfix...\n if (next.length > maxSize) {\n next = next.substring(0, maxSize) + '...';\n }\n return next;\n },\n\n /**\n * return a string which displays the character position where the\n * lexing error occurred, i.e. for error messages\n *\n * @public\n * @this {RegExpLexer}\n */\n showPosition: function lexer_showPosition(maxPrefix, maxPostfix) {\n const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' ');\n let c = new Array(pre.length + 1).join('-');\n return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^';\n },\n\n /**\n * return an YYLLOC info object derived off the given context (actual, preceding, following, current).\n * Use this method when the given `actual` location is not guaranteed to exist (i.e. when\n * it MAY be NULL) and you MUST have a valid location info object anyway:\n * then we take the given context of the `preceding` and `following` locations, IFF those are available,\n * and reconstruct the `actual` location info from those.\n * If this fails, the heuristic is to take the `current` location, IFF available.\n * If this fails as well, we assume the sought location is at/around the current lexer position\n * and then produce that one as a response. DO NOTE that these heuristic/derived location info\n * values MAY be inaccurate!\n *\n * NOTE: `deriveLocationInfo()` ALWAYS produces a location info object *copy* of `actual`, not just\n * a *reference* hence all input location objects can be assumed to be 'constant' (function has no side-effects).\n *\n * @public\n * @this {RegExpLexer}\n */\n deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) {\n let loc = {\n first_line: 1,\n first_column: 0,\n last_line: 1,\n last_column: 0,\n\n range: [ 0, 0 ]\n };\n if (actual) {\n loc.first_line = actual.first_line | 0;\n loc.last_line = actual.last_line | 0;\n loc.first_column = actual.first_column | 0;\n loc.last_column = actual.last_column | 0;\n\n if (actual.range) {\n loc.range[0] = actual.range[0] | 0;\n loc.range[1] = actual.range[1] | 0;\n }\n }\n if (loc.first_line <= 0 || loc.last_line < loc.first_line) {\n // plan B: heuristic using preceding and following:\n if (loc.first_line <= 0 && preceding) {\n loc.first_line = preceding.last_line | 0;\n loc.first_column = preceding.last_column | 0;\n\n if (preceding.range) {\n loc.range[0] = actual.range[1] | 0;\n }\n }\n\n if ((loc.last_line <= 0 || loc.last_line < loc.first_line) && following) {\n loc.last_line = following.first_line | 0;\n loc.last_column = following.first_column | 0;\n\n if (following.range) {\n loc.range[1] = actual.range[0] | 0;\n }\n }\n\n // plan C?: see if the 'current' location is useful/sane too:\n if (loc.first_line <= 0 && current && (loc.last_line <= 0 || current.last_line <= loc.last_line)) {\n loc.first_line = current.first_line | 0;\n loc.first_column = current.first_column | 0;\n\n if (current.range) {\n loc.range[0] = current.range[0] | 0;\n }\n }\n\n if (loc.last_line <= 0 && current && (loc.first_line <= 0 || current.first_line >= loc.first_line)) {\n loc.last_line = current.last_line | 0;\n loc.last_column = current.last_column | 0;\n\n if (current.range) {\n loc.range[1] = current.range[1] | 0;\n }\n }\n }\n // sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter\n // or plan D heuristics to produce a 'sensible' last_line value:\n if (loc.last_line <= 0) {\n if (loc.first_line <= 0) {\n loc.first_line = this.yylloc.first_line;\n loc.last_line = this.yylloc.last_line;\n loc.first_column = this.yylloc.first_column;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[0] = this.yylloc.range[0];\n loc.range[1] = this.yylloc.range[1];\n } else {\n loc.last_line = this.yylloc.last_line;\n loc.last_column = this.yylloc.last_column;\n\n loc.range[1] = this.yylloc.range[1];\n }\n }\n if (loc.first_line <= 0) {\n loc.first_line = loc.last_line;\n loc.first_column = 0; // loc.last_column;\n\n loc.range[1] = loc.range[0];\n }\n if (loc.first_column < 0) {\n loc.first_column = 0;\n }\n if (loc.last_column < 0) {\n loc.last_column = (loc.first_column > 0 ? loc.first_column : 80);\n }\n return loc;\n },\n\n /**\n * return a string which displays the lines & columns of input which are referenced\n * by the given location info range, plus a few lines of context.\n *\n * This function pretty-prints the indicated section of the input, with line numbers\n * and everything!\n *\n * This function is very useful to provide highly readable error reports, while\n * the location range may be specified in various flexible ways:\n *\n * - `loc` is the location info object which references the area which should be\n * displayed and 'marked up': these lines & columns of text are marked up by `^`\n * characters below each character in the entire input range.\n *\n * - `context_loc` is the *optional* location info object which instructs this\n * pretty-printer how much *leading* context should be displayed alongside\n * the area referenced by `loc`. This can help provide context for the displayed\n * error, etc.\n *\n * When this location info is not provided, a default context of 3 lines is\n * used.\n *\n * - `context_loc2` is another *optional* location info object, which serves\n * a similar purpose to `context_loc`: it specifies the amount of *trailing*\n * context lines to display in the pretty-print output.\n *\n * When this location info is not provided, a default context of 1 line only is\n * used.\n *\n * Special Notes:\n *\n * - when the `loc`-indicated range is very large (about 5 lines or more), then\n * only the first and last few lines of this block are printed while a\n * `...continued...` message will be printed between them.\n *\n * This serves the purpose of not printing a huge amount of text when the `loc`\n * range happens to be huge: this way a manageable & readable output results\n * for arbitrary large ranges.\n *\n * - this function can display lines of input which whave not yet been lexed.\n * `prettyPrintRange()` can access the entire input!\n *\n * @public\n * @this {RegExpLexer}\n */\n prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) {\n loc = this.deriveLocationInfo(loc, context_loc, context_loc2);\n\n const CONTEXT = 3;\n const CONTEXT_TAIL = 1;\n const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2;\n let input = this.matched + (this._input || '');\n let lines = input.split('\\n');\n let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT));\n let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL));\n let lineno_display_width = (1 + Math.log10(l1 | 1) | 0);\n let ws_prefix = new Array(lineno_display_width).join(' ');\n let nonempty_line_indexes = [ [], [], [] ];\n let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) {\n let lno = index + l0;\n let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width);\n let rv = lno_pfx + ': ' + line;\n let errpfx = (new Array(lineno_display_width + 1)).join('^');\n let offset = 2 + 1;\n let len = 0;\n\n if (lno === loc.first_line) {\n offset += loc.first_column;\n\n len = Math.max(\n 2,\n ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1\n );\n } else if (lno === loc.last_line) {\n len = Math.max(2, loc.last_column + 1);\n } else if (lno > loc.first_line && lno < loc.last_line) {\n len = Math.max(2, line.length + 1);\n }\n\n let nli;\n if (len) {\n let lead = new Array(offset).join('.');\n let mark = new Array(len).join('^');\n rv += '\\n' + errpfx + lead + mark;\n\n nli = 1;\n } else if (lno < loc.first_line) {\n nli = 0;\n } else if (lno > loc.last_line) {\n nli = 2;\n }\n\n if (line.trim().length > 0) {\n nonempty_line_indexes[nli].push(index);\n }\n\n rv = rv.replace(/\\t/g, ' ');\n return rv;\n });\n\n // now make sure we don't print an overly large amount of lead/error/tail area: limit it\n // to the top and bottom line count:\n for (let i = 0; i <= 2; i++) {\n let line_arr = nonempty_line_indexes[i];\n if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) {\n let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1;\n let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1;\n\n let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)';\n if (i === 1) {\n intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)';\n }\n rv.splice(clip_start, clip_end - clip_start + 1, intermediate_line);\n }\n }\n\n return rv.join('\\n');\n },\n\n /**\n * helper function, used to produce a human readable description as a string, given\n * the input `yylloc` location object.\n *\n * Set `display_range_too` to TRUE to include the string character index position(s)\n * in the description if the `yylloc.range` is available.\n *\n * @public\n * @this {RegExpLexer}\n */\n describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) {\n let l1 = yylloc.first_line;\n let l2 = yylloc.last_line;\n let c1 = yylloc.first_column;\n let c2 = yylloc.last_column;\n let dl = l2 - l1;\n let dc = c2 - c1;\n let rv;\n if (dl === 0) {\n rv = 'line ' + l1 + ', ';\n if (dc <= 1) {\n rv += 'column ' + c1;\n } else {\n rv += 'columns ' + c1 + ' .. ' + c2;\n }\n } else {\n rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')';\n }\n if (yylloc.range && display_range_too) {\n let r1 = yylloc.range[0];\n let r2 = yylloc.range[1] - 1;\n if (r2 <= r1) {\n rv += ' {String Offset: ' + r1 + '}';\n } else {\n rv += ' {String Offset range: ' + r1 + ' .. ' + r2 + '}';\n }\n }\n return rv;\n },\n\n /**\n * test the lexed token: return FALSE when not a match, otherwise return token.\n *\n * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]`\n * contains the actually matched text string.\n *\n * Also move the input cursor forward and update the match collectors:\n *\n * - `yytext`\n * - `yyleng`\n * - `match`\n * - `matches`\n * - `yylloc`\n * - `offset`\n *\n * @public\n * @this {RegExpLexer}\n */\n test_match: function lexer_test_match(match, indexed_rule) {\n let backup;\n\n if (this.options.backtrack_lexer) {\n // save context\n backup = {\n yylineno: this.yylineno,\n yylloc: {\n first_line: this.yylloc.first_line,\n last_line: this.yylloc.last_line,\n first_column: this.yylloc.first_column,\n last_column: this.yylloc.last_column,\n\n range: this.yylloc.range.slice()\n },\n yytext: this.yytext,\n match: this.match,\n matches: this.matches,\n matched: this.matched,\n yyleng: this.yyleng,\n offset: this.offset,\n _more: this._more,\n _input: this._input,\n //_signaled_error_token: this._signaled_error_token,\n yy: this.yy,\n conditionStack: this.conditionStack.slice(),\n done: this.done\n };\n }\n\n let match_str = match[0];\n let match_str_len = match_str.length;\n\n let lines = match_str.split(this.CRLF_Re);\n if (lines.length > 1) {\n this.yylineno += lines.length - 1;\n\n this.yylloc.last_line = this.yylineno + 1;\n this.yylloc.last_column = lines[lines.length - 1].length;\n } else {\n this.yylloc.last_column += match_str_len;\n }\n\n this.yytext += match_str;\n this.match += match_str;\n this.matched += match_str;\n this.matches = match;\n this.yyleng = this.yytext.length;\n this.yylloc.range[1] += match_str_len;\n\n // previous lex rules MAY have invoked the `more()` API rather than producing a token:\n // those rules will already have moved this `offset` forward matching their match lengths,\n // hence we must only add our own match length now:\n this.offset += match_str_len;\n this._more = false;\n this._backtrack = false;\n this._input = this._input.slice(match_str_len);\n\n // calling this method:\n //\n // function lexer__performAction(yy, yyrulenumber, YY_START) {...}\n let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */);\n // otherwise, when the action codes are all simple return token statements:\n //token = this.simpleCaseActionClusters[indexed_rule];\n\n if (this.done && this._input) {\n this.done = false;\n }\n if (token) {\n return token;\n } else if (this._backtrack) {\n // recover context\n for (let k in backup) {\n this[k] = backup[k];\n }\n this.__currentRuleSet__ = null;\n return false; // rule action called reject() implying the next rule should be tested instead.\n } else if (this._signaled_error_token) {\n // produce one 'error' token as `.parseError()` in `reject()`\n // did not guarantee a failure signal by throwing an exception!\n token = this._signaled_error_token;\n this._signaled_error_token = false;\n return token;\n }\n return false;\n },\n\n /**\n * return next match in input\n *\n * @public\n * @this {RegExpLexer}\n */\n next: function lexer_next() {\n if (this.done) {\n this.clear();\n return this.EOF;\n }\n if (!this._input) {\n this.done = true;\n }\n\n if (!this._more) {\n if (!this._clear_state) {\n this._clear_state = 1;\n }\n this.clear();\n }\n let spec = this.__currentRuleSet__;\n if (!spec) {\n // Update the ruleset cache as we apparently encountered a state change or just started lexing.\n // The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will\n // invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps\n // speed up those activities a tiny bit.\n spec = this.__currentRuleSet__ = this._currentRules();\n // Check whether a *sane* condition has been pushed before: this makes the lexer robust against\n // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19\n if (!spec || !spec.rules) {\n let lineno_msg = '';\n if (this.yylloc) {\n lineno_msg = ' on line ' + (this.yylineno + 1);\n }\n const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name \"' + this.topState() + '\"; this is a fatal error and should be reported to the application programmer team!', false);\n // produce one 'error' token until this situation has been resolved, most probably by parse termination!\n return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n }\n }\n\n {\n let rule_ids = spec.rules;\n let regexes = spec.__rule_regexes;\n let len = spec.__rule_count;\n let match;\n let index;\n\n // Note: the arrays are 1-based, while `len` itself is a valid index,\n // hence the non-standard less-or-equal check in the next loop condition!\n for (let i = 1; i <= len; i++) {\n let tempMatch = this._input.match(regexes[i]);\n if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n match = tempMatch;\n index = i;\n if (this.options.backtrack_lexer) {\n let token = this.test_match(tempMatch, rule_ids[i]);\n if (token !== false) {\n return token;\n } else if (this._backtrack) {\n match = undefined;\n continue; // rule action called reject() implying a rule MISmatch.\n } else {\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n } else if (!this.options.flex) {\n break;\n }\n }\n }\n\n if (match) {\n let token = this.test_match(match, rule_ids[index]);\n if (token !== false) {\n return token;\n }\n // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n return false;\n }\n }\n\n if (!this._input) {\n this.done = true;\n this.clear();\n return this.EOF;\n }\n\n {\n let lineno_msg = 'Lexical error';\n if (this.yylloc) {\n lineno_msg += ' on line ' + (this.yylineno + 1);\n }\n const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable);\n\n let pendingInput = this._input;\n let activeCondition = this.topState();\n let conditionStackDepth = this.conditionStack.length;\n\n let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR);\n if (token === this.ERROR) {\n // we can try to recover from a lexer error that `parseError()` did not 'recover' for us\n // by moving forward at least one character at a time IFF the (user-specified?) `parseError()`\n // has not consumed/modified any pending input or changed state in the error handler:\n if (!this.matches &&\n // and make sure the input has been modified/consumed ...\n pendingInput === this._input &&\n // ...or the lexer state has been modified significantly enough\n // to merit a non-consuming error handling action right now.\n activeCondition === this.topState() &&\n conditionStackDepth === this.conditionStack.length\n ) {\n this.input();\n }\n }\n return token;\n }\n },\n\n /**\n * return next match that has a token\n *\n * @public\n * @this {RegExpLexer}\n */\n lex: function lexer_lex() {\n let r;\n\n //this._clear_state = 0;\n\n if (!this._more) {\n if (!this._clear_state) {\n this._clear_state = 1;\n }\n this.clear();\n }\n\n // allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer:\n if (typeof this.pre_lex === 'function') {\n r = this.pre_lex.call(this, 0);\n }\n if (typeof this.options.pre_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.pre_lex.call(this, r) || r;\n }\n if (this.yy && typeof this.yy.pre_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.pre_lex.call(this, r) || r;\n }\n\n while (!r) {\n r = this.next();\n }\n\n if (this.yy && typeof this.yy.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.yy.post_lex.call(this, r) || r;\n }\n if (typeof this.options.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.options.post_lex.call(this, r) || r;\n }\n if (typeof this.post_lex === 'function') {\n // (also account for a userdef function which does not return any value: keep the token as is)\n r = this.post_lex.call(this, r) || r;\n }\n\n if (!this._more) {\n //\n // 1) make sure any outside interference is detected ASAP:\n // these attributes are to be treated as 'const' values\n // once the lexer has produced them with the token (return value `r`).\n // 2) make sure any subsequent `lex()` API invocation CANNOT\n // edit the `yytext`, etc. token attributes for the *current*\n // token, i.e. provide a degree of 'closure safety' so that\n // code like this:\n //\n // t1 = lexer.lex();\n // v = lexer.yytext;\n // l = lexer.yylloc;\n // t2 = lexer.lex();\n // assert(lexer.yytext !== v);\n // assert(lexer.yylloc !== l);\n //\n // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee*\n // these conditions.\n //\n this.yytext = Object.freeze(this.yytext);\n this.matches = Object.freeze(this.matches);\n this.yylloc.range = Object.freeze(this.yylloc.range);\n this.yylloc = Object.freeze(this.yylloc);\n\n this._clear_state = 0;\n }\n\n return r;\n },\n\n /**\n * return next match that has a token. Identical to the `lex()` API but does not invoke any of the\n * `pre_lex()` nor any of the `post_lex()` callbacks.\n *\n * @public\n * @this {RegExpLexer}\n */\n fastLex: function lexer_fastLex() {\n let r;\n\n //this._clear_state = 0;\n\n while (!r) {\n r = this.next();\n }\n\n if (!this._more) {\n //\n // 1) make sure any outside interference is detected ASAP:\n // these attributes are to be treated as 'const' values\n // once the lexer has produced them with the token (return value `r`).\n // 2) make sure any subsequent `lex()` API invocation CANNOT\n // edit the `yytext`, etc. token attributes for the *current*\n // token, i.e. provide a degree of 'closure safety' so that\n // code like this:\n //\n // t1 = lexer.lex();\n // v = lexer.yytext;\n // l = lexer.yylloc;\n // t2 = lexer.lex();\n // assert(lexer.yytext !== v);\n // assert(lexer.yylloc !== l);\n //\n // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee*\n // these conditions.\n //\n this.yytext = Object.freeze(this.yytext);\n this.matches = Object.freeze(this.matches);\n this.yylloc.range = Object.freeze(this.yylloc.range);\n this.yylloc = Object.freeze(this.yylloc);\n\n this._clear_state = 0;\n }\n\n return r;\n },\n\n /**\n * return info about the lexer state that can help a parser or other lexer API user to use the\n * most efficient means available. This API is provided to aid run-time performance for larger\n * systems which employ this lexer.\n *\n * @public\n * @this {RegExpLexer}\n */\n canIUse: function lexer_canIUse() {\n const rv = {\n fastLex: !(\n typeof this.pre_lex === 'function' ||\n typeof this.options.pre_lex === 'function' ||\n (this.yy && typeof this.yy.pre_lex === 'function') ||\n (this.yy && typeof this.yy.post_lex === 'function') ||\n typeof this.options.post_lex === 'function' ||\n typeof this.post_lex === 'function'\n ) && typeof this.fastLex === 'function'\n };\n return rv;\n },\n\n\n /**\n * backwards compatible alias for `pushState()`;\n * the latter is symmetrical with `popState()` and we advise to use\n * those APIs in any modern lexer code, rather than `begin()`.\n *\n * @public\n * @this {RegExpLexer}\n */\n begin: function lexer_begin(condition) {\n return this.pushState(condition);\n },\n\n /**\n * activates a new lexer condition state (pushes the new lexer\n * condition state onto the condition stack)\n *\n * @public\n * @this {RegExpLexer}\n */\n pushState: function lexer_pushState(condition) {\n this.conditionStack.push(condition);\n this.__currentRuleSet__ = null;\n return this;\n },\n\n /**\n * pop the previously active lexer condition state off the condition\n * stack\n *\n * @public\n * @this {RegExpLexer}\n */\n popState: function lexer_popState() {\n const n = this.conditionStack.length - 1;\n if (n > 0) {\n this.__currentRuleSet__ = null;\n return this.conditionStack.pop();\n }\n return this.conditionStack[0];\n },\n\n /**\n * return the currently active lexer condition state; when an index\n * argument is provided it produces the N-th previous condition state,\n * if available\n *\n * @public\n * @this {RegExpLexer}\n */\n topState: function lexer_topState(n) {\n n = this.conditionStack.length - 1 - Math.abs(n || 0);\n if (n >= 0) {\n return this.conditionStack[n];\n }\n return 'INITIAL';\n },\n\n /**\n * (internal) determine the lexer rule set which is active for the\n * currently active lexer condition state\n *\n * @public\n * @this {RegExpLexer}\n */\n _currentRules: function lexer__currentRules() {\n const n = this.conditionStack.length - 1;\n let state;\n if (n >= 0) {\n state = this.conditionStack[n];\n } else {\n state = 'INITIAL';\n }\n return this.conditions[state] || this.conditions.INITIAL;\n },\n\n /**\n * return the number of states currently on the stack\n *\n * @public\n * @this {RegExpLexer}\n */\n stateStackSize: function lexer_stateStackSize() {\n return this.conditionStack.length;\n }\n}"; // --- END lexer kernel --- } chkBugger$2(getRegExpLexerPrototype()); - RegExpLexer.prototype = new Function(rmCommonWS$2(_templateObject80(), getRegExpLexerPrototype()))(); // The lexer code stripper, driven by optimization analysis settings and + RegExpLexer.prototype = new Function(rmCommonWS$2(_templateObject81(), getRegExpLexerPrototype()))(); // The lexer code stripper, driven by optimization analysis settings and // lexer options, which cannot be changed at run-time. function stripUnusedLexerCode(src, opt) { @@ -12480,15 +12690,15 @@ 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 _c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); var offendingChunk = ' ' + b.join('\n '); - console.error(rmCommonWS$2(_templateObject81(), ex, offendingChunk)); + console.error(rmCommonWS$2(_templateObject82(), ex, offendingChunk)); new_src = src; } // inject analysis report now: - new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2(_templateObject82(), opt.options.backtrack_lexer, opt.options.ranges, opt.options.trackPosition, opt.parseActionsUseYYLENG, opt.parseActionsUseYYLINENO, opt.parseActionsUseYYTEXT, opt.parseActionsUseYYLOC, opt.parseActionsUseValueTracking, opt.parseActionsUseValueAssignment, opt.parseActionsUseLocationTracking, opt.parseActionsUseLocationAssignment, opt.lexerActionsUseYYLENG, opt.lexerActionsUseYYLINENO, opt.lexerActionsUseYYTEXT, opt.lexerActionsUseYYLOC, opt.lexerActionsUseParseError, opt.lexerActionsUseYYERROR, opt.lexerActionsUseLocationTracking, opt.lexerActionsUseMore, opt.lexerActionsUseUnput, opt.lexerActionsUseReject, opt.lexerActionsUseLess, opt.lexerActionsUseDisplayAPIs, opt.lexerActionsUseDescribeYYLOC)); + new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2(_templateObject83(), opt.options.backtrack_lexer, opt.options.ranges, opt.options.trackPosition, opt.parseActionsUseYYLENG, opt.parseActionsUseYYLINENO, opt.parseActionsUseYYTEXT, opt.parseActionsUseYYLOC, opt.parseActionsUseValueTracking, opt.parseActionsUseValueAssignment, opt.parseActionsUseLocationTracking, opt.parseActionsUseLocationAssignment, opt.lexerActionsUseYYLENG, opt.lexerActionsUseYYLINENO, opt.lexerActionsUseYYTEXT, opt.lexerActionsUseYYLOC, opt.lexerActionsUseParseError, opt.lexerActionsUseYYERROR, opt.lexerActionsUseLocationTracking, opt.lexerActionsUseMore, opt.lexerActionsUseUnput, opt.lexerActionsUseReject, opt.lexerActionsUseLess, opt.lexerActionsUseDisplayAPIs, opt.lexerActionsUseDescribeYYLOC)); return new_src; } // generate lexer source from a grammar @@ -12625,9 +12835,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); return "/* ".concat(idx_str, ": */ new XRegExp(\"").concat(re_src, "\", \"").concat(re.xregexp.flags, "\")"); - } else { - return "/* ".concat(idx_str, ": */ ").concat(re); } + + return "/* ".concat(idx_str, ": */ ").concat(re); }); return b.join(',\n'); } @@ -12635,8 +12845,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function generateModuleBody(opt) { // make the JSON output look more like JavaScript: function cleanupJSON(str) { - str = str.replace(/ "rules": \[/g, ' rules: ['); - str = str.replace(/ "inclusive": /g, ' inclusive: '); + str = str.replace(/ {2}"rules": \[/g, ' rules: ['); + str = str.replace(/ {2}"inclusive": /g, ' inclusive: '); return str; } @@ -12747,7 +12957,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) { // we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. - var code = [rmCommonWS$2(_templateObject83()), '/*JISON-LEX-ANALYTICS-REPORT*/' + var code = [rmCommonWS$2(_templateObject84()), '/* JISON-LEX-ANALYTICS-REPORT */\n' /* slot #1: placeholder for analysis report further below */ ]; // get the RegExpLexer.prototype in source code form: @@ -12774,7 +12984,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var simpleCaseActionClustersCode = String(opt.caseHelperInclude); var rulesCode = generateRegexesInitTableCode(opt); var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); - code.push(rmCommonWS$2(_templateObject84(), performActionCode, simpleCaseActionClustersCode, rulesCode, conditionsCode)); + code.push(rmCommonWS$2(_templateObject85(), performActionCode, simpleCaseActionClustersCode, rulesCode, conditionsCode)); opt.is_custom_lexer = false; out = code.join(''); } else { @@ -12782,9 +12992,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // - // Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter + // Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. - out = 'var lexer;\n'; + out = '\n'; assert__default['default'](opt.regular_rule_count === 0); assert__default['default'](opt.simple_rule_count === 0); opt.is_custom_lexer = true; @@ -12795,8 +13005,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } // The output of this function is guaranteed to read something like this: // // ``` - // var lexer; - // // bla bla bla bla ... lotsa bla bla; // ``` // @@ -12807,7 +13015,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } function generateGenericHeaderComment() { - var out = rmCommonWS$2(_templateObject85(), version); + var out = rmCommonWS$2(_templateObject86(), version); return out; } @@ -12836,7 +13044,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function generateModule(opt) { opt = prepareOptions(opt); var modIncSrc = opt.moduleInclude ? opt.moduleInclude + ';' : ''; - var src = rmCommonWS$2(_templateObject86(), generateGenericHeaderComment(), opt.moduleName, jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); + var src = rmCommonWS$2(_templateObject87(), generateGenericHeaderComment(), opt.moduleName, jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); src = stripUnusedLexerCode(src, opt); opt.exportSourceCode.all = src; return src; @@ -12845,7 +13053,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function generateAMDModule(opt) { opt = prepareOptions(opt); var modIncSrc = opt.moduleInclude ? opt.moduleInclude + ';' : ''; - var src = rmCommonWS$2(_templateObject87(), generateGenericHeaderComment(), jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); + var src = rmCommonWS$2(_templateObject88(), generateGenericHeaderComment(), jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); src = stripUnusedLexerCode(src, opt); opt.exportSourceCode.all = src; return src; @@ -12854,7 +13062,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function generateESModule(opt) { opt = prepareOptions(opt); var modIncSrc = opt.moduleInclude ? opt.moduleInclude + ';' : ''; - var src = rmCommonWS$2(_templateObject88(), generateGenericHeaderComment(), jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); + var src = rmCommonWS$2(_templateObject89(), generateGenericHeaderComment(), jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc); src = stripUnusedLexerCode(src, opt); opt.exportSourceCode.all = src; return src; @@ -12863,7 +13071,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function generateCommonJSModule(opt) { opt = prepareOptions(opt); var modIncSrc = opt.moduleInclude ? opt.moduleInclude + ';' : ''; - var src = rmCommonWS$2(_templateObject89(), generateGenericHeaderComment(), opt.moduleName, jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc, opt.moduleName, opt.moduleName); + var src = rmCommonWS$2(_templateObject90(), generateGenericHeaderComment(), opt.moduleName, jisonLexerErrorDefinition, generateModuleBody(opt), modIncSrc, opt.moduleName, opt.moduleName); src = stripUnusedLexerCode(src, opt); opt.exportSourceCode.all = src; return src; @@ -13235,15 +13443,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi switch (yystate) { case 0: /*! Production:: $accept : production $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-): - this.$ = yyvstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-) + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-): + this.$ = yyvstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-) break; case 1: /*! Production:: production : handle EOF */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-): - this.$ = yyvstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-) + // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-): + this.$ = yyvstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-) return yyvstack[yysp - 1]; @@ -13391,20 +13599,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + var ASSERT = typeof assert !== 'function' ? function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : assert; this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -13433,13 +13635,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + var _dst2 = {}; + shallow_copy_noclobber(_dst2, src); + return _dst2; + } } return src; @@ -13456,10 +13659,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (chk.call(src, k)) { dst[k] = src[k]; } - } else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } // copy state @@ -13605,6 +13806,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -13746,7 +13953,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi action = t[0]; // handle parse error if (!action) { - var errStr; + var errStr = void 0; var errSymbolDescr = this.describeSymbol(symbol) || symbol; var expected = this.collect_expected_token_set(state); // Report error @@ -13880,14 +14087,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -14395,6 +14604,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -14776,9 +14989,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -14788,8 +15001,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -14865,12 +15078,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi */ pastInput: function lexer_pastInput(maxSize, maxLines) { var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) maxSize = Infinity;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substr` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = Infinity; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: @@ -14887,8 +15110,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -14914,20 +15137,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { var next = this.match; var source = this._input || ''; - if (maxSize < 0) maxSize = next.length + source.length;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substring` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = next.length + source.length; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + if (next.length < maxSize * 2 + 2) { next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8 } // now that we have a significantly reduced string to process, transform the newlines @@ -15252,7 +15485,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + var backup; if (this.options.backtrack_lexer) { // save context @@ -15280,9 +15513,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + var match_str = match[0]; + var match_str_len = match_str.length; + var lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -15308,7 +15541,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] + var token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */ ); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -15354,8 +15587,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -15387,65 +15618,73 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; // 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! + { + var rule_ids = spec.rules; + var regexes = spec.__rule_regexes; + var len = spec.__rule_count; + var match; + var index; // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + for (var i = 1; i <= len; i++) { + var tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + var token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + var _token3 = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + if (_token3 !== false) { + return _token3; + } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + var _lineno_msg2 = 'Lexical error'; if (this.yylloc) { - lineno_msg += ' on line ' + (this.yylineno + 1); + _lineno_msg2 += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var _p2 = this.constructLexErrorInfo(_lineno_msg2 + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var pendingInput = this._input; var activeCondition = this.topState(); var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; - if (token === this.ERROR) { + var _token4 = this.parseError(_p2.errStr, _p2, this.JisonLexerError) || this.ERROR; + + if (_token4 === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: @@ -15457,7 +15696,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - return token; + return _token4; } }, @@ -15514,24 +15753,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15558,24 +15797,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15639,9 +15878,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -15657,9 +15896,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -15679,7 +15918,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -15882,10 +16121,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } function transformExpression(e, opts, emit) { - var type = e[0], - value = e[1], - name = false, - has_transformed = 0; + var type = e[0]; + var value = e[1]; + var name = false; + var has_transformed = 0; var list, n; if (type === 'xalias') { @@ -16006,8 +16245,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function transformProduction(id, production, grammar) { var transform_opts = optsForProduction(id, grammar); return production.map(function (handle) { - var action = null, - opts = null; + var action = null; + var opts = null; var i, len, n; if (typeof handle !== 'string') { @@ -16101,7 +16340,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } // now scan the action for all named and numeric semantic values ($nonterminal / $1 / @1, ##1, ...) // // Note that `#name` are straight **static** symbol translations, which are okay as they don't - // require access to the parse stack: `#n` references can be resolved completely + // require access to the parse stack: `#n` references can be resolved completely // at grammar compile time. // @@ -16148,9 +16387,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (ret.length === 1) { return ret[0]; - } else { - return ret; } + + return ret; }); } @@ -16694,16 +16933,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi switch (yystate) { case 0: /*! Production:: $accept : spec $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; - this._$ = yylstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break; case 1: /*! Production:: spec : declaration_list "%%" grammar optional_end_block EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4]; @@ -16717,20 +16956,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 2: /*! Production:: spec : declaration_list "%%" grammar error EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) - yyparser.yyError(rmCommonWS$3(_templateObject90(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject91(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 3: /*! Production:: spec : declaration_list error EOF */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject91(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject92(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); break; case 4: @@ -16747,21 +16986,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 133: /*! Production:: optional_module_code_chunk : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject92(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject93(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); } this.$ = yyvstack[yysp]; @@ -16772,8 +17011,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 10: /*! Production:: declaration_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -16783,14 +17022,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 8: /*! Production:: optional_action_header_block : optional_action_header_block include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject93(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject94(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); } yy.addDeclaration(this.$, { @@ -16800,8 +17039,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 9: /*! Production:: declaration_list : declaration_list declaration */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -16809,18 +17048,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 11: /*! Production:: declaration_list : declaration_list error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject94(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject95(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 12: /*! Production:: declaration : START id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { start: yyvstack[yysp] @@ -16829,8 +17068,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 13: /*! Production:: declaration : LEX_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { lex: { @@ -16842,8 +17081,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 14: /*! Production:: declaration : operator */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { operator: yyvstack[yysp] @@ -16852,8 +17091,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 15: /*! Production:: declaration : TOKEN full_token_definitions */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { token_list: yyvstack[yysp] @@ -16862,13 +17101,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 16: /*! Production:: declaration : ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject95(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject96(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); } this.$ = { @@ -16878,13 +17117,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 17: /*! Production:: declaration : include_macro_code */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject96(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject97(), rv, yylexer.prettyPrintRange(yylstack[yysp]))); } this.$ = { @@ -16894,8 +17133,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 18: /*! Production:: declaration : parse_params */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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] @@ -16904,8 +17143,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 19: /*! Production:: declaration : parser_type */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { parserType: yyvstack[yysp] @@ -16914,8 +17153,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 20: /*! Production:: declaration : options */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { options: yyvstack[yysp] @@ -16924,8 +17163,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 21: /*! Production:: declaration : DEBUG */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { options: [['debug', true]] @@ -16934,8 +17173,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 22: /*! Production:: declaration : EBNF */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) ebnf = true; this.$ = { @@ -16945,8 +17184,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 23: /*! Production:: declaration : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { unknownDecl: yyvstack[yysp] @@ -16955,8 +17194,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 24: /*! Production:: declaration : IMPORT import_name import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { imports: { @@ -16968,31 +17207,31 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 25: /*! Production:: declaration : IMPORT import_name error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject97(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject98(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 26: /*! Production:: declaration : IMPORT error import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject98(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject99(), 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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(_templateObject99(), $init_code_name, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject100(), $init_code_name, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); } this.$ = { @@ -17005,41 +17244,41 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 28: /*! Production:: declaration : INIT_CODE error action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject100(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject101(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]))); break; case 29: /*! Production:: declaration : START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject101(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject102(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 30: /*! Production:: declaration : TOKEN error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject102(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject103(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 31: /*! Production:: declaration : IMPORT error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject103(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject104(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 32: @@ -17119,8 +17358,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 132: /*! Production:: optional_module_code_chunk : module_code_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -17130,30 +17369,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 111: /*! Production:: action_ne : "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1]; break; case 40: /*! Production:: options : OPTIONS error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject104(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]))); + yyparser.yyError(rmCommonWS$3(_templateObject105(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2], yylstack[yysp]))); break; case 41: /*! Production:: options : OPTIONS error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject105(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject106(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 42: @@ -17164,8 +17403,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 70: /*! Production:: id_list : id_list id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push(yyvstack[yysp]); @@ -17182,24 +17421,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 84: /*! Production:: handle_list : handle_action */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 44: /*! Production:: option : NAME */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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], true]; break; case 45: /*! Production:: option : NAME "=" OPTION_STRING_VALUE */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]]; break; @@ -17209,30 +17448,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 47: /*! Production:: option : NAME "=" NAME */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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], parseValue$1(yyvstack[yysp])]; break; case 48: /*! Production:: option : NAME "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject106(), yyvstack[yysp - 2], yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject107(), yyvstack[yysp - 2], yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 49: /*! Production:: option : NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject107(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject108(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 50: @@ -17240,36 +17479,36 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 52: /*! Production:: parser_type : PARSER_TYPE symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; break; case 51: /*! Production:: parse_params : PARSE_PARAM error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject108(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject109(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 53: /*! Production:: parser_type : PARSER_TYPE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject109(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject110(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 54: /*! Production:: operator : associativity token_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push.apply(this.$, yyvstack[yysp]); @@ -17277,42 +17516,42 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 55: /*! Production:: operator : associativity error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject110(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject111(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 56: /*! Production:: associativity : LEFT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = 'left'; break; case 57: /*! Production:: associativity : RIGHT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = 'right'; break; case 58: /*! Production:: associativity : NONASSOC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = 'nonassoc'; break; case 61: /*! Production:: full_token_definitions : optional_token_type id_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -17335,8 +17574,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 62: /*! Production:: full_token_definitions : optional_token_type one_full_token */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -17349,8 +17588,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 63: /*! Production:: one_full_token : id token_value token_description */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { id: yyvstack[yysp - 2], @@ -17361,8 +17600,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 64: /*! Production:: one_full_token : id token_description */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { id: yyvstack[yysp - 1], @@ -17372,8 +17611,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 65: /*! Production:: one_full_token : id token_value */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { id: yyvstack[yysp - 1], @@ -17383,16 +17622,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 66: /*! Production:: optional_token_type : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = false; break; case 72: /*! Production:: grammar : optional_action_header_block production_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.grammar = yyvstack[yysp]; @@ -17400,8 +17639,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 73: /*! Production:: production_list : production_list production */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -17415,8 +17654,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 74: /*! Production:: production_list : production */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = {}; this.$[yyvstack[yysp][0]] = yyvstack[yysp][1]; @@ -17424,36 +17663,36 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 75: /*! Production:: production : production_id handle_list ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1]]; break; case 76: /*! Production:: production : production_id error ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject111(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject112(), yylexer.prettyPrintRange(yylstack[yysp - 1], yylstack[yysp - 2]), yyvstack[yysp - 1].errStr)); break; case 77: /*! Production:: production : production_id error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject112(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject113(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 78: /*! Production:: production_id : id optional_production_description ":" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; // TODO: carry rule description support into the parser generator... @@ -17461,36 +17700,36 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 79: /*! Production:: production_id : id optional_production_description error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject113(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject114(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 80: /*! Production:: production_id : id optional_production_description ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject114(), $id, yyvstack[yysp - 2], yyvstack[yysp], yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject115(), $id, yyvstack[yysp - 2], yyvstack[yysp], yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 82: /*! Production:: optional_production_description : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) break; case 83: /*! Production:: handle_list : handle_list "|" handle_action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; this.$.push(yyvstack[yysp]); @@ -17498,28 +17737,28 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 85: /*! Production:: handle_list : handle_list "|" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject115(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject116(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]), yyvstack[yysp].errStr)); break; case 86: /*! Production:: handle_list : handle_list ":" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject116(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject117(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 87: /*! Production:: handle_action : handle prec action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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(' ') : '']; @@ -17527,7 +17766,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject117(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject118(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); } this.$.push(yyvstack[yysp]); @@ -17535,7 +17774,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (yyvstack[yysp - 1]) { if (yyvstack[yysp - 2].length === 0) { - yyparser.yyError(rmCommonWS$3(_templateObject118(), yylexer.prettyPrintRange(yylstack[yysp - 2], yylstack[yysp - 3], yylstack[yysp] + 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! */ ))); } @@ -17551,8 +17790,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 88: /*! Production:: handle_action : EPSILON action */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = ['']; @@ -17560,7 +17799,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var rv = checkActionBlock$2(yyvstack[yysp], yylstack[yysp]); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject119(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject120(), rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); } this.$.push(yyvstack[yysp]); @@ -17574,18 +17813,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 89: /*! Production:: handle_action : EPSILON error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject120(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject121(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); break; case 90: /*! Production:: handle : handle suffixed_expression */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push(yyvstack[yysp]); @@ -17593,16 +17832,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 91: /*! Production:: handle : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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 92: /*! Production:: handle_sublist : handle_sublist "|" handle */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; this.$.push(yyvstack[yysp].join(' ')); @@ -17610,16 +17849,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 93: /*! Production:: handle_sublist : handle */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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].join(' ')]; break; case 94: /*! Production:: suffixed_expression : expression suffix ALIAS */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + "[" + yyvstack[yysp] + "]"; break; @@ -17632,24 +17871,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 130: /*! Production:: module_code_chunk : module_code_chunk CODE */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + yyvstack[yysp]; break; case 97: /*! Production:: expression : EOF_ID */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '$end'; break; case 98: /*! Production:: expression : STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // Re-encode the string *anyway* as it will // be made part of the rule rhs a.k.a. production (type: *string*) again and we want // to be able to handle all tokens, including *significant space* @@ -17660,25 +17899,25 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 99: /*! Production:: expression : "(" handle_sublist ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1].join(' | ') + ')'; break; case 100: /*! Production:: expression : "(" handle_sublist error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject121(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject122(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 105: /*! Production:: prec : PREC symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { prec: yyvstack[yysp] @@ -17687,76 +17926,76 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 106: /*! Production:: prec : PREC error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject122(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); + yyparser.yyError(rmCommonWS$3(_templateObject123(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]), yyvstack[yysp].errStr)); break; case 107: /*! Production:: prec : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = null; break; case 112: /*! Production:: action_ne : "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject123(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject124(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 116: /*! Production:: action : ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 120: /*! Production:: action_body : action_body "{" action_body "}" action_comments_body */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4] + yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; break; case 121: /*! Production:: action_body : action_body "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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 - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; break; case 122: /*! Production:: action_body : action_body "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject124(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); + yyparser.yyError(rmCommonWS$3(_templateObject125(), yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 2]))); break; case 126: /*! Production:: extra_parser_module_code : optional_module_code_chunk include_macro_code extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + yyvstack[yysp]; break; case 127: /*! Production:: include_macro_code : INCLUDE PATH */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -17764,7 +18003,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var rv = checkActionBlock$2(fileContent); if (rv) { - yyparser.yyError(rmCommonWS$3(_templateObject125(), $PATH, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); + yyparser.yyError(rmCommonWS$3(_templateObject126(), $PATH, rv, yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1]))); } // And no, we don't support nested '%include': @@ -17773,21 +18012,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 128: /*! Production:: include_macro_code : INCLUDE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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(_templateObject126()) + yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])); + yyparser.yyError(rmCommonWS$3(_templateObject127()) + yylexer.prettyPrintRange(yylstack[yysp], yylstack[yysp - 1])); break; case 131: /*! Production:: module_code_chunk : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... - yyparser.yyError(rmCommonWS$3(_templateObject127()) + yylexer.prettyPrintRange(yylstack[yysp])); + yyparser.yyError(rmCommonWS$3(_templateObject128()) + yylexer.prettyPrintRange(yylstack[yysp])); break; } }, @@ -17864,20 +18103,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + var ASSERT = typeof assert !== 'function' ? function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : assert; this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -17910,13 +18143,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + var _dst3 = {}; + shallow_copy_noclobber(_dst3, src); + return _dst3; + } } return src; @@ -17933,10 +18167,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (chk.call(src, k)) { dst[k] = src[k]; } - } else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -18105,11 +18337,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (var _i6 = this.__error_recovery_infos.length - 1; _i6 >= 0; _i6--) { + var _el2 = this.__error_recovery_infos[_i6]; - if (el && typeof el.destroy === 'function') { - el.destroy(); + if (_el2 && typeof _el2.destroy === 'function') { + _el2.destroy(); } } @@ -18137,10 +18369,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; + var i1 = first_index | 0; + var i2 = last_index | 0; + var l1 = first_yylloc; + var l2 = last_yylloc; var rv; // rules: // - first/last yylloc entries override first/last indexes @@ -18158,8 +18390,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { - l2 = lstack[i]; + for (var _i7 = i2; _i7 >= i1; _i7--) { + l2 = lstack[_i7]; if (l2) { break; @@ -18172,8 +18404,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 i = (i1 || sp) - 1; i >= 0; i--) { - l1 = lstack[i]; + for (var _i8 = (i1 || sp) - 1; _i8 >= 0; _i8--) { + l1 = lstack[_i8]; if (l1) { break; @@ -18186,30 +18418,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; - } + return null; + } // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + + rv = this.copy_yylloc(l2); return rv; + } // shallow-copy L1, then adjust first col/row 1 column past the end. + + + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; } + + return rv; } if (!l1) { @@ -18218,7 +18450,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... @@ -18268,6 +18500,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -18350,11 +18588,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty - } + { + var i; + + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty + } - rv.base_pointer = i; - rv.info_stack_pointer = i; + rv.base_pointer = i; + rv.info_stack_pointer = i; + } rv.root_failure_pointer = rv.stack_pointer; // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_recovery_infos.push(rv); @@ -18440,9 +18682,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi while (stack_probe >= 0) { // check for error recovery rule in this state - var t = table[state] && table[state][TERROR] || NO_ACTION; + var _t2 = table[state] && table[state][TERROR] || NO_ACTION; - if (t[0]) { + if (_t2[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must // prevent the core from running forever, @@ -18605,7 +18847,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: @@ -18661,7 +18903,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errSymbolDescr: errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -18680,7 +18922,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi yyval.$ = recoveringErrorInfo; yyval._$ = undefined; yyrulelen = error_rule_depth; - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + var combineState = NO_ACTION[1]; + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -18737,9 +18980,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); var errorSymbolFromParser = true; for (;;) { @@ -18772,7 +19015,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // and take it from there! if (!action) { - ASSERT(recoveringErrorInfo, "line 1087"); // Prep state variables so that upon breaking out of + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` // statement in the outer "fast parse loop" we redo // the exact same state table lookup as the one above @@ -18807,12 +19050,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -18854,7 +19097,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; // read action for current state and first input @@ -18884,7 +19127,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; @@ -18944,15 +19187,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -19006,7 +19251,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; @@ -19048,25 +19293,25 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + var _tokenName2 = this.getSymbolName(symbol || EOF); - if (!tokenName) { - tokenName = symbol; + if (!_tokenName2) { + _tokenName2 = symbol; } Jison.parserDebugger.push({ action: 'shift', text: lexer.yytext, - terminal: tokenName, + terminal: _tokenName2, terminal_id: symbol }); } ++sp; symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc = this.copy_yylloc(lexer.yylloc); @@ -19074,9 +19319,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... @@ -19084,25 +19329,28 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; + var _prereduceValue2 = vstack.slice(sp - yyrulelen, sp); - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); - debuggableProductions.push(debuggableProduction); + var _debuggableProductions2 = []; + + for (var _debugIdx2 = yyrulelen - 1; _debugIdx2 >= 0; _debugIdx2--) { + var _debuggableProduction2 = getNonTerminalFromCode(stack[sp - _debugIdx2]); + + _debuggableProductions2.push(_debuggableProduction2); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + var _currentNonterminalCode2 = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + + var _currentNonterminal2 = getNonTerminalFromCode(_currentNonterminalCode2); - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', - nonterminal: currentNonterminal, - nonterminal_id: currentNonterminalCode, - prereduce: prereduceValue, + nonterminal: _currentNonterminal2, + nonterminal_id: _currentNonterminalCode2, + prereduce: _prereduceValue2, result: r, - productions: debuggableProductions, + productions: _debuggableProductions2, text: yyval.$ }); } @@ -19124,15 +19372,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + var _ntsymbol2 = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = _ntsymbol2; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][_ntsymbol2]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -19641,6 +19891,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... var rec = !!this.recoverable; for (var key in this) { @@ -20022,9 +20276,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -20034,8 +20288,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -20111,12 +20365,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi */ pastInput: function lexer_pastInput(maxSize, maxLines) { var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) maxSize = Infinity;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substr` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = Infinity; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: @@ -20133,8 +20397,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -20160,20 +20424,30 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { var next = this.match; var source = this._input || ''; - if (maxSize < 0) maxSize = next.length + source.length;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substring` anticipation: treat \r\n as a single character and take a little + + if (maxSize < 0) { + maxSize = next.length + source.length; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + if (next.length < maxSize * 2 + 2) { next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8 } // now that we have a significantly reduced string to process, transform the newlines @@ -20498,7 +20772,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + var backup; if (this.options.backtrack_lexer) { // save context @@ -20526,9 +20800,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + var match_str = match[0]; + var match_str_len = match_str.length; + var lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -20554,7 +20828,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] + var token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */ ); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -20600,8 +20874,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -20633,65 +20905,73 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; // 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! + { + var rule_ids = spec.rules; + var regexes = spec.__rule_regexes; + var len = spec.__rule_count; + var match; + var index; // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + for (var i = 1; i <= len; i++) { + var tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + var token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + var _token5 = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + if (_token5 !== false) { + return _token5; + } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + var _lineno_msg3 = 'Lexical error'; if (this.yylloc) { - lineno_msg += ' on line ' + (this.yylineno + 1); + _lineno_msg3 += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var _p3 = this.constructLexErrorInfo(_lineno_msg3 + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + var pendingInput = this._input; var activeCondition = this.topState(); var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; - if (token === this.ERROR) { + var _token6 = this.parseError(_p3.errStr, _p3, this.JisonLexerError) || this.ERROR; + + if (_token6 === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: @@ -20703,7 +20983,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - return token; + return _token6; } }, @@ -20760,24 +21040,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -20804,24 +21084,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -20885,9 +21165,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -20903,9 +21183,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -20925,7 +21205,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -21168,7 +21448,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Rule:: %{NAME}([^\r\n]*) */ /* ignore unrecognized decl */ - this.warn(rmCommonWS(_templateObject128(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); + this.warn(rmCommonWS(_templateObject129(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); yy_.yytext = [// {NAME} this.matches[1], // optional value/parameters this.matches[2].trim()]; @@ -21289,42 +21569,42 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Conditions:: action */ /*! Rule:: " */ - yy_.yyerror(rmCommonWS(_templateObject129()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject130()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 82: /*! Conditions:: action */ /*! Rule:: ' */ - yy_.yyerror(rmCommonWS(_templateObject130()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject131()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 83: /*! Conditions:: action */ /*! Rule:: ` */ - yy_.yyerror(rmCommonWS(_templateObject131()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject132()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 84: /*! Conditions:: option_values */ /*! Rule:: " */ - yy_.yyerror(rmCommonWS(_templateObject132()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject133()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 85: /*! Conditions:: option_values */ /*! Rule:: ' */ - yy_.yyerror(rmCommonWS(_templateObject133()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject134()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 86: /*! Conditions:: option_values */ /*! Rule:: ` */ - yy_.yyerror(rmCommonWS(_templateObject134()) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject135()) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 87: @@ -21332,7 +21612,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Rule:: " */ var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject135(), rules) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject136(), rules) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 88: @@ -21340,7 +21620,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Rule:: ' */ var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject136(), rules) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject137(), rules) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 89: @@ -21348,7 +21628,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Rule:: ` */ var rules = this.topState() === 'macro' ? 'macro\'s' : this.topState(); - yy_.yyerror(rmCommonWS(_templateObject137(), rules) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject138(), rules) + this.prettyPrintRange(yy_.yylloc)); return 'UNTERMINATED_STRING_ERROR'; case 90: @@ -21357,7 +21637,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /*! Rule:: . */ /* b0rk on bad characters */ - yy_.yyerror(rmCommonWS(_templateObject138(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); + yy_.yyerror(rmCommonWS(_templateObject139(), dquote(yy_.yytext), dquote(this.topState())) + this.prettyPrintRange(yy_.yylloc)); return 2; default: @@ -22094,8 +22374,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // which MAY get corrupted that way as their actual content would change then! // construct fake nesting levels to arrive at the intended start indent value: `num` var nesting_levels = num / 2; - var pre = '// **PRE**', - post = '// **POST**'; + var pre = '// **PRE**'; + var post = '// **POST**'; for (; nesting_levels > 0; nesting_levels--) { pre = 'function x() {\n' + pre; @@ -22133,8 +22413,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // Begin - var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - meta = { + var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; + var meta = { // table of character substitutions '\b': '\\b', '\t': '\\t', @@ -22202,134 +22482,140 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var lex_pre = []; var lex_rules = []; var lex_post = []; - var key, src; - src = raw.lex.macros; - delete raw.lex.macros; + { + var src = raw.lex.macros; + delete raw.lex.macros; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject139())); - var keylen = 0; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4(_templateObject140())); + var keylen = 0; - for (key in src) { - keylen = Math.max(keylen, key.length); - } + for (var key in src) { + keylen = Math.max(keylen, key.length); + } - console.log('macros keylen:', keylen); - keylen = (keylen / 4 | 0) * 4 + 4; - console.log('macros keylen B:', keylen); + console.log('macros keylen:', keylen); + keylen = (keylen / 4 | 0) * 4 + 4; + console.log('macros keylen B:', keylen); - for (key in src) { - lex_pre.push(padRight(key, keylen) + src[key]); - } + for (var _key in src) { + lex_pre.push(padRight(_key, keylen) + src[_key]); + } - lex_pre.push(rmCommonWS$4(_templateObject140())); + lex_pre.push(rmCommonWS$4(_templateObject141())); + } } + { + var _src = raw.lex.unknownDecls; + delete raw.lex.unknownDecls; - src = raw.lex.unknownDecls; - delete raw.lex.unknownDecls; + if (_src && !isEmptyObj(_src)) { + lex_pre.push(rmCommonWS$4(_templateObject142())); - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject141())); + for (var i = 0, len = _src.length; i < len; i++) { + var entry = _src[i]; + var _key2 = entry.name; + var value = entry.value; + lex_pre.push('%' + _key2 + ' ' + value); + } - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; - lex_pre.push('%' + key + ' ' + value); + lex_pre.push(rmCommonWS$4(_templateObject143())); } - - lex_pre.push(rmCommonWS$4(_templateObject142())); } + { + var _src2 = raw.lex.options; + delete raw.lex.options; - src = raw.lex.options; - delete raw.lex.options; - - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject143())); + if (_src2 && !isEmptyObj(_src2)) { + lex_pre.push(rmCommonWS$4(_templateObject144())); - for (key in src) { - var value = src[key]; + for (var _key3 in _src2) { + var _value = _src2[_key3]; - if (value) { - lex_pre.push('%options ' + key + '=' + value); - } else { - lex_pre.push('%options ' + key); + if (_value) { + lex_pre.push('%options ' + _key3 + '=' + _value); + } else { + lex_pre.push('%options ' + _key3); + } } } } + { + var _src3 = raw.lex.startConditions; + delete raw.lex.startConditions; - src = raw.lex.startConditions; - delete raw.lex.startConditions; - - if (src && !isEmptyObj(src)) { - for (key in src) { - var value = src[key]; - lex_pre.push((value ? '%x ' : '%s ') + key); + if (_src3 && !isEmptyObj(_src3)) { + for (var _key4 in _src3) { + var _value2 = _src3[_key4]; + lex_pre.push((_value2 ? '%x ' : '%s ') + _key4); + } } } + { + var _src4 = raw.lex.actionInclude; + delete raw.lex.actionInclude; - src = raw.lex.actionInclude; - delete raw.lex.actionInclude; - - if (src && src.trim()) { - lex_pre.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + if (_src4 && _src4.trim()) { + lex_pre.push('%{\n' + indentAction(_src4.trim(), 4) + '\n%}'); + } } + { + var _src5 = raw.lex.rules; + delete raw.lex.rules; - src = raw.lex.rules; - delete raw.lex.rules; - - if (src) { - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - key = entry[0]; - var action = indentAction(entry[1], 4); - var actionHasLF = /[\r\n]/.test(action); - console.log('indented action:', { - entry: entry[1], - action: action, - actionHasLF: actionHasLF - }); + if (_src5) { + for (var _i9 = 0, _len2 = _src5.length; _i9 < _len2; _i9++) { + var _entry = _src5[_i9]; + var _key5 = _entry[0]; + var action = indentAction(_entry[1], 4); + var actionHasLF = /[\r\n]/.test(action); + console.log('indented action:', { + entry: _entry[1], + action: action, + actionHasLF: actionHasLF + }); - if (key.length <= 12) { - if (!actionHasLF) { - lex_rules.push(padRight(key, 16) + indentAction(action, 16)); - } else { - lex_rules.push(padRight(key, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); - } - } else { - if (!actionHasLF) { - lex_rules.push(key, makeIndent(16) + indentAction(action, 16)); + if (_key5.length <= 12) { + if (!actionHasLF) { + lex_rules.push(padRight(_key5, 16) + indentAction(action, 16)); + } else { + lex_rules.push(padRight(_key5, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + } + } else if (!actionHasLF) { + lex_rules.push(_key5, makeIndent(16) + indentAction(action, 16)); } else { - lex_rules.push(key, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + lex_rules.push(_key5, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } } } + { + var _src6 = raw.lex.moduleInclude; + delete raw.lex.moduleInclude; - src = raw.lex.moduleInclude; - delete raw.lex.moduleInclude; - - if (src && src.trim()) { - lex_post.push(indentAction(src.trim(), 0)); + if (_src6 && _src6.trim()) { + lex_post.push(indentAction(_src6.trim(), 0)); + } } + { + var out = ''; - var out = ''; + 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, '*\\/')); + } - if (!isEmptyObj(raw.lex)) { - // dump the remainder as a comment: - var rem = JSON5__default['default'].stringify(raw.lex, null, 2); - out += rmCommonWS$4(_templateObject144(), rem.replace(/\*\//g, '*\\/')); - } + delete raw.lex; + out += lex_pre.join('\n') + '\n\n'; + out += rmCommonWS$4(_templateObject146()) + lex_rules.join('\n') + '\n\n'; - delete raw.lex; - out += lex_pre.join('\n') + '\n\n'; - out += rmCommonWS$4(_templateObject145()) + lex_rules.join('\n') + '\n\n'; + if (lex_post.length > 0) { + out += rmCommonWS$4(_templateObject147()) + lex_post.join('\n') + '\n\n'; + } - if (lex_post.length > 0) { - out += rmCommonWS$4(_templateObject146()) + lex_post.join('\n') + '\n\n'; + lex_out_str = out; } - - lex_out_str = out; } var grammar_pre = []; @@ -22337,7 +22623,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var ebnf_rules = []; var bnf_rules = []; var grammar_post = []; - var key, src; var fmtprod = function fmtprod(rule, prodset) { var backup = deepClone(prodset); @@ -22375,12 +22660,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } if (typeof prodset[1] === 'string') { - var action = prodset[1]; + var _action = prodset[1]; if (lead.length < 12 - 1) { - rule += makeIndent(12 - lead.length) + indentAction('{ ' + action + ' }', 12); + rule += makeIndent(12 - lead.length) + indentAction('{ ' + _action + ' }', 12); } else { - rule += '\n' + makeIndent(12) + indentAction('{ ' + action + ' }', 12); + rule += '\n' + makeIndent(12) + indentAction('{ ' + _action + ' }', 12); } delete prodset[1]; @@ -22396,72 +22681,71 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; var grammarfmt = function grammarfmt(src) { - var key; var dst = []; - for (key in src) { - var prodset = src[key]; - var rule; + for (var _key6 in src) { + var prodset = src[_key6]; + var rule = void 0; console.log('format one rule:', { - key: key, + key: _key6, prodset: prodset }); if (typeof prodset === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; - delete src[key]; + rule = fmtprod(_key6 + ' : ', [prodset]) + ';'; + delete src[_key6]; } else if (prodset instanceof Array) { if (prodset.length === 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; - delete src[key]; + rule = fmtprod(_key6 + ' : ', [prodset]) + ';'; + delete src[_key6]; } else if (prodset[0] instanceof Array) { - rule = fmtprod(key + ' : ', prodset[0]); + rule = fmtprod(_key6 + ' : ', prodset[0]); rule += '\n ;'; if (prodset[0].length === 0) { - delete src[key]; + delete src[_key6]; } } else { - rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; + rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } } else if (prodset.length > 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + '\n : ', [prodset[0]]); + rule = fmtprod(_key6 + '\n : ', [prodset[0]]); delete prodset[0]; } else if (prodset[0] instanceof Array) { - rule = fmtprod(key + '\n : ', prodset[0]); + rule = fmtprod(_key6 + '\n : ', prodset[0]); if (prodset[0].length === 0) { delete prodset[0]; } } else { - rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; + rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - for (var i = 1, len = prodset.length; i < len; i++) { - if (typeof prodset[i] === 'string') { - rule += fmtprod('\n | ', [prodset[i]]); - delete prodset[i]; - } else if (prodset[i] instanceof Array) { - rule += fmtprod('\n | ', prodset[i]); + 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]); - if (prodset[i].length === 0) { - delete prodset[i]; + if (prodset[_i10].length === 0) { + delete prodset[_i10]; } } else { - rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[i]; + rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[_i10]; } } rule += '\n ;'; if (isEmptyArr(prodset)) { - delete src[key]; + delete src[_key6]; } } } else { - rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; + rule = _key6 + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; } dst.push(rule); @@ -22470,313 +22754,333 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return dst; }; - src = raw.ebnf; + { + var _src7 = raw.ebnf; - if (src) { - ebnf_rules = grammarfmt(src); + if (_src7) { + ebnf_rules = grammarfmt(_src7); - if (isEmptyObj(src)) { - delete raw.ebnf; + if (isEmptyObj(_src7)) { + delete raw.ebnf; + } } } + { + var _src8 = raw.bnf; //delete raw.bnf; - src = raw.bnf; //delete raw.bnf; - - if (src) { - bnf_rules = grammarfmt(src); + if (_src8) { + bnf_rules = grammarfmt(_src8); - if (isEmptyObj(src)) { - delete raw.bnf; + if (isEmptyObj(_src8)) { + delete raw.bnf; + } } } + { + var _src9 = raw.unknownDecls; + delete raw.unknownDecls; - src = raw.unknownDecls; - delete raw.unknownDecls; + if (_src9 && !isEmptyObj(_src9)) { + lex_pre.push(rmCommonWS$4(_templateObject148())); - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4(_templateObject147())); + for (var _i11 = 0, _len4 = _src9.length; _i11 < _len4; _i11++) { + var _entry2 = _src9[_i11]; + var _key7 = _entry2.name; + var _value3 = _entry2.value; + lex_pre.push('%' + _key7 + ' ' + _value3); + } - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; - lex_pre.push('%' + key + ' ' + value); + lex_pre.push(rmCommonWS$4(_templateObject149())); } - - lex_pre.push(rmCommonWS$4(_templateObject148())); - } //src = raw.lex; + } //let src = raw.lex; //delete raw.lex; //if (src) { - if (lex_out_str.trim() && options.showLexer) { - grammar_pre.push(rmCommonWS$4(_templateObject149(), lex_out_str)); + grammar_pre.push(rmCommonWS$4(_templateObject150(), lex_out_str)); } - src = raw.options; - delete raw.options; + { + var _src10 = raw.options; + delete raw.options; - if (src && !isEmptyObj(src)) { - var a = []; + if (_src10 && !isEmptyObj(_src10)) { + var a = []; - for (key in src) { - var value = src[key]; + for (var _key8 in _src10) { + var _value4 = _src10[_key8]; - switch (key) { - default: - if (value !== true) { - a.push('options', '%options ' + key + '=' + value); - } else { - a.push('options', '%options ' + key); - } + switch (_key8) { + default: + if (_value4 !== true) { + a.push('options', '%options ' + _key8 + '=' + _value4); + } else { + a.push('options', '%options ' + _key8); + } - break; + break; - case 'ebnf': - if (value) { - a.push(key, '%ebnf'); - } + case 'ebnf': + if (_value4) { + a.push(_key8, '%ebnf'); + } - break; + break; - case 'type': - if (value) { - a.push(key, '%parser-type ' + value); - } + case 'type': + if (_value4) { + a.push(_key8, '%parser-type ' + _value4); + } - break; + break; - case 'debug': - if (typeof value !== 'boolean') { - a.push(key, '%debug ' + value); - } else if (value) { - a.push(key, '%debug'); - } + case 'debug': + if (typeof _value4 !== 'boolean') { + a.push(_key8, '%debug ' + _value4); + } else if (_value4) { + a.push(_key8, '%debug'); + } - break; + break; + } } - } - var type = null; + var type = null; - for (var i = 0, len = a.length; i < len; i += 2) { - var t = a[i]; - var line = a[i + 1]; + for (var _i12 = 0, _len5 = a.length; _i12 < _len5; _i12 += 2) { + var t = a[_i12]; + var line = a[_i12 + 1]; + + if (t !== type) { + type = t; + grammar_pre.push(''); + } - if (t !== type) { - type = t; - grammar_pre.push(''); + grammar_pre.push(line); } - grammar_pre.push(line); + grammar_pre.push(''); } - - grammar_pre.push(''); } + { + var _src11 = raw.imports; - src = raw.imports; - - if (src) { - var clean = true; + if (_src11) { + var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - grammar_pre.push('%import ' + entry.name + ' ' + entry.path); - delete entry.name; - delete entry.path; + for (var _i13 = 0, _len6 = _src11.length; _i13 < _len6; _i13++) { + var _entry3 = _src11[_i13]; + grammar_pre.push('%import ' + _entry3.name + ' ' + _entry3.path); + delete _entry3.name; + delete _entry3.path; - if (isEmptyObj(entry)) { - delete src[i]; - } else { - clean = false; + if (isEmptyObj(_entry3)) { + delete _src11[_i13]; + } else { + clean = false; + } } - } - if (clean) { - delete raw.imports; + if (clean) { + delete raw.imports; + } } } + { + var _src12 = raw.moduleInit; - src = raw.moduleInit; - - if (src) { - var clean = true; + if (_src12) { + var _clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - grammar_pre.push('%code ' + entry.qualifier + ' ' + entry.include); - delete entry.qualifier; - delete entry.include; + for (var _i14 = 0, _len7 = _src12.length; _i14 < _len7; _i14++) { + var _entry4 = _src12[_i14]; + grammar_pre.push('%code ' + _entry4.qualifier + ' ' + _entry4.include); + delete _entry4.qualifier; + delete _entry4.include; - if (isEmptyObj(entry)) { - delete src[i]; - } else { - clean = false; + if (isEmptyObj(_entry4)) { + delete _src12[_i14]; + } else { + _clean = false; + } } - } - if (clean) { - delete raw.moduleInit; + if (_clean) { + delete raw.moduleInit; + } } } + { + var _src13 = raw.operators; - src = raw.operators; + if (_src13) { + var _clean2 = true; - if (src) { - var clean = true; + for (var _i15 = 0, _len8 = _src13.length; _i15 < _len8; _i15++) { + var _entry5 = _src13[_i15]; + var tokens = _entry5[1]; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var tokens = entry[1]; - var line = '%' + entry[0] + ' '; + var _line = '%' + _entry5[0] + ' '; - for (var t = 0, tlen = tokens.length; t < tlen; t++) { - line += ' ' + tokens[t]; - } + for (var _t3 = 0, tlen = tokens.length; _t3 < tlen; _t3++) { + _line += ' ' + tokens[_t3]; + } - grammar_pre.push(line); + grammar_pre.push(_line); - if (entry.length === 2) { - delete src[i]; - } else { - clean = false; + if (_entry5.length === 2) { + delete _src13[_i15]; + } else { + _clean2 = false; + } } - } - if (clean) { - delete raw.operators; + if (_clean2) { + delete raw.operators; + } } } + { + var _src14 = raw.extra_tokens; - src = raw.extra_tokens; + if (_src14) { + var _clean3 = true; - if (src) { - var clean = true; + for (var _i16 = 0, _len9 = _src14.length; _i16 < _len9; _i16++) { + var _entry6 = _src14[_i16]; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var line = '%token ' + entry.id; + var _line2 = '%token ' + _entry6.id; - if (entry.type) { - line += ' <' + entry.type + '>'; - delete entry.type; - } + if (_entry6.type) { + _line2 += ' <' + _entry6.type + '>'; + delete _entry6.type; + } - if (entry.value) { - line += ' ' + entry.value; - delete entry.value; - } + if (_entry6.value) { + _line2 += ' ' + _entry6.value; + delete _entry6.value; + } - if (entry.description) { - line += ' ' + escapeString(entry.description); - delete entry.description; - } + if (_entry6.description) { + _line2 += ' ' + escapeString(_entry6.description); + delete _entry6.description; + } - grammar_pre.push(line); - delete entry.id; + grammar_pre.push(_line2); + delete _entry6.id; - if (isEmptyObj(entry)) { - delete src[i]; - } else { - clean = false; + if (isEmptyObj(_entry6)) { + delete _src14[_i16]; + } else { + _clean3 = false; + } } - } - if (clean) { - delete raw.extra_tokens; + if (_clean3) { + delete raw.extra_tokens; + } } } + { + var _src15 = raw.parseParams; + delete raw.parseParams; - src = raw.parseParams; - delete raw.parseParams; - - if (src) { - grammar_pre.push('%parse-param ' + src.join(' ')); + if (_src15) { + grammar_pre.push('%parse-param ' + _src15.join(' ')); + } } + { + var _src16 = raw.start; + delete raw.start; - src = raw.start; - delete raw.start; - - if (src) { - grammar_pre.push('%start ' + src); + if (_src16) { + grammar_pre.push('%start ' + _src16); + } } + { + var _src17 = raw.moduleInclude; + delete raw.moduleInclude; - src = raw.moduleInclude; - delete raw.moduleInclude; + if (_src17 && _src17.trim()) { + grammar_post.push(indentAction(_src17.trim(), 0)); + } + } + { + var _src18 = raw.actionInclude; + delete raw.actionInclude; - if (src && src.trim()) { - grammar_post.push(indentAction(src.trim(), 0)); + if (_src18 && _src18.trim()) { + grammar_mid.push('%{\n' + indentAction(_src18.trim(), 4) + '\n%}'); + } } + { + var _out = ''; - src = raw.actionInclude; - delete raw.actionInclude; + if (!isEmptyObj(raw)) { + // dump the remainder as a comment: + var _rem = JSON5__default['default'].stringify(raw, null, 2); - if (src && src.trim()) { - grammar_mid.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); - } + _out += rmCommonWS$4(_templateObject151(), _rem.replace(/\*\//g, '*\\/')); // delete raw; + } - var out = ''; + if (!options.showParser) { + _out += lex_out_str; + } else { + _out += grammar_pre.join('\n') + '\n\n'; + _out += rmCommonWS$4(_templateObject152()); - if (!isEmptyObj(raw)) { - // dump the remainder as a comment: - var rem = JSON5__default['default'].stringify(raw, null, 2); - out += rmCommonWS$4(_templateObject150(), rem.replace(/\*\//g, '*\\/')); // delete raw; - } + if (grammar_mid.length > 0) { + _out += grammar_mid.join('\n') + '\n\n'; + } - if (!options.showParser) { - out += lex_out_str; - } else { - out += grammar_pre.join('\n') + '\n\n'; - out += rmCommonWS$4(_templateObject151()); + if (ebnf_rules.length > 0) { + if (bnf_rules.length > 0) { + // dump the original EBNF grammar as source and dump the BNF derivative as COMMENT: + var bnf_deriv = bnf_rules.join('\n\n'); - if (grammar_mid.length > 0) { - out += grammar_mid.join('\n') + '\n\n'; - } + var _a2 = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - if (ebnf_rules.length > 0) { - if (bnf_rules.length > 0) { - // dump the original EBNF grammar as source and dump the BNF derivative as COMMENT: - var bnf_deriv = bnf_rules.join('\n\n'); - var a = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); - out += rmCommonWS$4(_templateObject152(), a.join('\n')); + _out += rmCommonWS$4(_templateObject153(), _a2.join('\n')); + } + + _out += ebnf_rules.join('\n\n') + '\n\n'; + } else if (bnf_rules.length > 0) { + _out += bnf_rules.join('\n\n') + '\n\n'; } - out += ebnf_rules.join('\n\n') + '\n\n'; - } else if (bnf_rules.length > 0) { - out += bnf_rules.join('\n\n') + '\n\n'; + if (grammar_post.length > 0) { + _out += rmCommonWS$4(_templateObject154()) + grammar_post.join('\n') + '\n\n'; + } } - if (grammar_post.length > 0) { - out += rmCommonWS$4(_templateObject153()) + grammar_post.join('\n') + '\n\n'; - } - } + if (options.format === 'json5') { + var _a3 = _out.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - if (options.format === 'json5') { - var a = out.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); - out = rmCommonWS$4(_templateObject154(), options.showParser ? 'grammar' : 'lexer', a.join('\n')); // process the original input once again: this time via JSON5 + _out = rmCommonWS$4(_templateObject155(), options.showParser ? 'grammar' : 'lexer', _a3.join('\n')); // process the original input once again: this time via JSON5 - raw = deepClone(originalInput); + raw = deepClone(originalInput); - if (!options.showLexer) { - delete raw.lex; - out += JSON5__default['default'].stringify(raw, null, 2); - } else if (!options.showParser) { - out += JSON5__default['default'].stringify(raw.lex, null, 2); + if (!options.showLexer) { + delete raw.lex; + _out += JSON5__default['default'].stringify(raw, null, 2); + } else if (!options.showParser) { + _out += JSON5__default['default'].stringify(raw.lex, null, 2); + } } - } - return out; + return _out; + } } // Jison, an LR(0), SLR(1), LARL(1), LR(1) Parser Generator var rmCommonWS$5 = helpers.rmCommonWS; var mkIdentifier$4 = helpers.mkIdentifier; - var code_exec$2 = helpers.exec; - var version$2 = '0.6.2-220'; + var code_exec$1 = helpers.exec; + var version$2 = '0.7.0-220'; var devDebug = 0; function chkBugger$3(src) { @@ -22808,9 +23112,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // 0, 1, 2 outputDebugTables: false, noDefaultResolve: false, - defaultActionMode: ["classic", "merge"], + defaultActionMode: ['classic', 'merge'], // {classic, ast, none, skip}, {classic, ast, merge, none, skip} - testCompileActionCode: "parser:*,lexer:*", + testCompileActionCode: 'parser:*,lexer:*', noTryCatch: false, hasPartialLrUpgradeOnConflict: true, errorRecoveryTokenDiscardCount: 3, @@ -22890,14 +23194,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function mkStdOptions$1() { var h = Object.prototype.hasOwnProperty; - var opts = {}; //var args = Array.prototype.concat.apply([], args); + var opts = {}; //let args = Array.prototype.concat.apply([], args); // clone defaults, so we do not modify those constants? - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + for (var _len10 = arguments.length, args = new Array(_len10), _key9 = 0; _key9 < _len10; _key9++) { + args[_key9] = arguments[_key9]; } - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(Jison$1.defaultJisonOptions); } else { args.shift(); @@ -23013,10 +23317,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } // now see if we have an overriding option here: - for (var p in o2) { - if (h.call(o2, p)) { - if (typeof o2[p] !== 'undefined') { - opts[p] = o2[p]; + for (var _p4 in o2) { + if (h.call(o2, _p4)) { + if (typeof o2[_p4] !== 'undefined') { + opts[_p4] = o2[_p4]; } } } @@ -23087,7 +23391,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // When both JSON5 and JISON input modes barf a hairball, assume the most important // error is the JISON one (show that one first!), while it MAY be a JSON5 format // error that triggered it (show that one last!). - // + // // Also check for common JISON errors which are obviously never triggered by any // odd JSON5 input format error: when we encounter such an error here, we don't // confuse matters and forget about the JSON5 fail as it's irrelevant: @@ -23204,7 +23508,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi Jison$1.Lexer = RegExpLexer; Jison$1.ebnfParser = ebnfParser; Jison$1.lexParser = lexParser; - Jison$1.codeExec = code_exec$2; + Jison$1.codeExec = code_exec$1; Jison$1.XRegExp = XRegExp__default['default']; Jison$1.recast = recast__default['default']; Jison$1.astUtils = astUtils__default['default']; //Jison.prettier = prettier; @@ -23280,7 +23584,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var Nonterminal = typal.construct({ constructor: function Nonterminal(symbol) { this.symbol = symbol; - this.productions = new Set(); + this.productions = new Set$1(); this.first = []; this.follows = []; this.nullable = false; @@ -23574,10 +23878,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; generator.processGrammar = function processGrammarDef(grammar) { - var bnf = grammar.bnf, - tokens = grammar.tokens, - nonterminals = this.nonterminals = {}, - productions = this.productions; + var bnf = grammar.bnf; + var tokens = grammar.tokens; + var nonterminals = this.nonterminals = {}; + var productions = this.productions; if (!grammar.bnf && grammar.ebnf) { bnf = grammar.bnf = ebnfParser.transform(grammar.ebnf); @@ -23633,11 +23937,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } // Make sure all predefined symbols are unique and *numeric* and do not include predefined tokens JISON already defines to a fixed ID on its own: - delete predefined_symbols['$accept']; - delete predefined_symbols['$end']; - delete predefined_symbols['error']; - delete predefined_symbols['$eof']; - delete predefined_symbols['EOF']; + delete predefined_symbols.$accept; + delete predefined_symbols.$end; + delete predefined_symbols.error; + delete predefined_symbols.$eof; + delete predefined_symbols.EOF; var symdef_uniq_check = {}; // Only these symbols are allowed to have the values 1 or 2: symdef_uniq_check[1] = 'EOF'; @@ -23649,21 +23953,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (typeof v !== 'number') { if (typeof v !== 'string' || v.length !== 1) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a non-numeric symbol ID value must be a single-character string.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a non-numeric symbol ID value must be a single-character string."); } v = v.charCodeAt(0); } - v = v | 0; + v |= 0; if (!v || v < 0) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a symbol ID value must be an integer value, 3 or greater.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a symbol ID value must be an integer value, 3 or greater."); } if (symdef_uniq_check[v]) { if (symdef_uniq_check[v] !== sym) { - throw new Error('Error: `%import symbols `: symbol table contains duplicate ID values for keys \'' + sym + '\' and \'' + symdef_uniq_check[v] + '\''); + throw new Error("Error: `%import symbols `: symbol table contains duplicate ID values for keys '" + sym + "' and '" + symdef_uniq_check[v] + "'"); } } @@ -23764,13 +24068,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi generator.signalUnusedProductions = function () { + var _this3 = this; + var mark = {}; var productions = this.productions; var nonterminals = this.nonterminals; - var i, len, nt, sym; - for (i = 0, len = nonterminals.length; i < len; i++) { - nt = nonterminals[i]; + for (var i = 0, len = nonterminals.length; i < len; i++) { + var nt = nonterminals[i]; assert__default['default'](nt.symbol); mark[nt.symbol] = false; } // scan & mark all visited productions @@ -23787,7 +24092,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi assert__default['default'](p.handle); var rhs = p.handle; - for (var j = 0, len = rhs.length; j < len; j++) { + for (var j = 0, _len11 = rhs.length; j < _len11; j++) { var sym = rhs[j]; assert__default['default'](!sym ? !nonterminals[sym] : true); @@ -23802,8 +24107,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi /* this.startSymbol */ ]); // now any production which is not yet marked is *unused*: - for (sym in mark) { - nt = nonterminals[sym]; + var _loop = function _loop(sym) { + var nt = nonterminals[sym]; assert__default['default'](nt); var prods = nt.productions; assert__default['default'](prods); @@ -23820,8 +24125,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!in_use) { // and kill the unused nonterminals: - delete this.nonterminals[sym]; + delete _this3.nonterminals[sym]; } + }; + + for (var sym in mark) { + _loop(sym); } this.unused_productions = productions.filter(function (p) { @@ -23888,7 +24197,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi generator.buildProductions = function buildProductions(bnf, productions, nonterminals, symbols, operators, predefined_symbols, descriptions) { var self = this; - var prods, symbol, symId; + var prods, symId; var productions_ = []; var symbols_ = {}; var descriptions_ = {}; @@ -23904,9 +24213,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.EOF = '$end'; symbols_.$accept = 0; symbols_[this.EOF] = 1; - symbols_['$eof'] = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.$eof = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! - symbols_['EOF'] = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.EOF = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! symbols[0] = '$accept'; symbols[1] = this.EOF; @@ -23916,7 +24225,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi symbols[2] = 'error'; if (predefined_symbols) { - for (symbol in predefined_symbols) { + for (var symbol in predefined_symbols) { symId = predefined_symbols[symbol]; if (symId === true) { @@ -23940,9 +24249,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi usedSymbolIdsLowIndex = (this.options.compressTables | 0) < 2 ? 32 : 3; - for (symbol in predefined_symbols) { - symId = predefined_symbols[symbol]; - addSymbol(symbol); + for (var _symbol in predefined_symbols) { + symId = predefined_symbols[_symbol]; + addSymbol(_symbol); } // reset ID low water mark: nonterminals etc. can be assigned any number, preferably a small/low one! @@ -24001,20 +24310,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function collectLiteralTokensInProduction(handle) { - var rhs, i, sym; + var rhs; try { if (devDebug) ; var maxlen = this.maxTokenLength || Infinity; if (handle.constructor === Array) { - var rhs_i; rhs = typeof handle[0] === 'string' ? splitStringIntoSymbols(handle[0]) : handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; // check for aliased names, e.g., id[alias] and strip them + for (var i = 0; i < rhs.length; i++) { + var sym = rhs[i]; // check for aliased names, e.g., id[alias] and strip them - rhs_i = sym.match(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]$"))); + var rhs_i = sym.match(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]$"))); if (rhs_i) { sym = sym.substr(0, sym.length - rhs_i[0].length); @@ -24029,18 +24337,16 @@ 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 (i = 0; i < rhs.length; i++) { - sym = rhs[i]; + for (var _i17 = 0; _i17 < rhs.length; _i17++) { + var _sym = rhs[_i17]; - if (!bnf[sym] && sym.length <= maxlen) { - addSymbol(sym); + if (!bnf[_sym] && _sym.length <= maxlen) { + addSymbol(_sym); } } } } catch (ex) { - console.error(ex, '\ncollectLiteralTokensInProduction: ', symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { - i: i, - sym: sym, + console.error(ex, '\ncollectLiteralTokensInProduction: ', this.symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { rhs: rhs }); throw ex; @@ -24053,33 +24359,35 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var prodsLUT = {}; - for (symbol in bnf) { - if (!bnf.hasOwnProperty(symbol)) continue; + for (var _symbol2 in bnf) { + if (!bnf.hasOwnProperty(_symbol2)) continue; - if (typeof bnf[symbol] === 'string') { - prods = bnf[symbol].split(/\s*\|\s*/g); + if (typeof bnf[_symbol2] === 'string') { + prods = bnf[_symbol2].split(/\s*\|\s*/g); } else { - prods = bnf[symbol].slice(0); + prods = bnf[_symbol2].slice(0); } - prodsLUT[symbol] = prods; + prodsLUT[_symbol2] = prods; } // First we collect all single-character literal tokens: - for (symbol in prodsLUT) { - if (!prodsLUT.hasOwnProperty(symbol)) continue; - prods = prodsLUT[symbol]; + for (var _symbol3 in prodsLUT) { + if (!prodsLUT.hasOwnProperty(_symbol3)) continue; + prods = prodsLUT[_symbol3]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: 1 + maxTokenLength: 1, + symbol: _symbol3 }); } // Next we collect all other literal tokens: - for (symbol in prodsLUT) { - if (!prodsLUT.hasOwnProperty(symbol)) continue; - prods = prodsLUT[symbol]; + for (var _symbol4 in prodsLUT) { + if (!prodsLUT.hasOwnProperty(_symbol4)) continue; + prods = prodsLUT[_symbol4]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: Infinity + maxTokenLength: Infinity, + symbol: _symbol4 }); } // and now go and process the entire grammar: // first collect all nonterminals in a symbol table, then build the productions @@ -24088,22 +24396,24 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // referenced: - for (symbol in bnf) { - if (!bnf.hasOwnProperty(symbol)) continue; - addSymbol(symbol); - nonterminals[symbol] = new Nonterminal(symbol); + for (var _symbol5 in bnf) { + if (!bnf.hasOwnProperty(_symbol5)) continue; + addSymbol(_symbol5); + nonterminals[_symbol5] = new Nonterminal(_symbol5); } // now that we have collected all nonterminals in our symbol table, it's finally // time to process the productions: - for (symbol in prodsLUT) { - if (!prodsLUT.hasOwnProperty(symbol)) continue; - prods = prodsLUT[symbol]; - prods.forEach(buildProduction); + for (var _symbol6 in prodsLUT) { + if (!prodsLUT.hasOwnProperty(_symbol6)) continue; + prods = prodsLUT[_symbol6]; + prods.forEach(buildProduction, { + symbol: _symbol6 + }); } - var terms = [], - terms_ = {}; + var terms = []; + var terms_ = {}; each(symbols_, function (id, sym) { // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number @@ -24128,9 +24438,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi chk_er_opt('parserErrorsAreRecoverable', 'parser-errors-are-recoverable feature/option'); // Hmmmm... why would lexer errors need to be NON-recoverable when there's no ERROR rules in the GRAMMAR?! chk_er_opt('lexerErrorsAreRecoverable', 'lexer-errors-are-recoverable feature/option'); - chk_er_opt('parseActionsUseYYRECOVERING', 'YYRECOVERING macro/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYERROK', 'yyerrok() function/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYCLEARIN', 'yyclearin() function/API in grammar rules\' action code'); + chk_er_opt('parseActionsUseYYRECOVERING', "YYRECOVERING macro/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYERROK', "yyerrok() function/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYCLEARIN', "yyclearin() function/API in grammar rules' action code"); } this.terminals = terms; @@ -24222,23 +24532,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } return tokens; - } + } // options object { symbol } is `this` for this functon/callback: + function buildProduction(handle) { - var r, - rhs, - i, - precedence_override, - aliased = [], - action = null; + var rhs; + var precedence_override = null; + var aliased = []; + var action = null; if (handle.constructor === Array) { - var rhs_i; rhs = typeof handle[0] === 'string' ? splitStringIntoSymbols(handle[0]) : handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { + for (var i = 0; i < rhs.length; i++) { // check for aliased names, e.g., id[alias] and strip them - rhs_i = rhs[i].match(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]$"))); + var rhs_i = rhs[i].match(new XRegExp__default['default']("\\[".concat(ID_REGEX_BASE$3, "\\]$"))); if (rhs_i) { rhs[i] = rhs[i].substr(0, rhs[i].length - rhs_i[0].length); @@ -24282,17 +24590,17 @@ 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 (i = 0; i < rhs.length; i++) { - if (rhs[i] === 'error') { + for (var _i18 = 0; _i18 < rhs.length; _i18++) { + if (rhs[_i18] === 'error') { hasErrorRecovery = true; } - assert__default['default'](bnf[rhs[i]] ? symbols_[rhs[i]] : true, 'all nonterminals must already exist in the symbol table'); - assert__default['default'](rhs[i] ? symbols_[rhs[i]] : true, 'all symbols (terminals and nonterminals) must already exist in the symbol table'); //addSymbol(rhs[i]); + 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]); } } - r = new Production(symbol, rhs, productions.length + 1, aliased, action); // set precedence + var r = new Production(this.symbol, rhs, productions.length + 1, aliased, action); // set precedence assert__default['default'](r.precedence === 0); @@ -24302,23 +24610,23 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var prec_symbols = []; var winning_symbol; - for (i = r.handle.length - 1; i >= 0; i--) { - if (!(r.handle[i] in nonterminals) && r.handle[i] in operators) { + for (var _i19 = r.handle.length - 1; _i19 >= 0; _i19--) { + if (!(r.handle[_i19] in nonterminals) && r.handle[_i19] in operators) { var old_prec = r.precedence; - var new_prec = operators[r.handle[i]].precedence; + var new_prec = operators[r.handle[_i19]].precedence; if (old_prec !== 0 && old_prec !== new_prec) { - prec_symbols.push(r.handle[i]); // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], symbol, handle[0]); + prec_symbols.push(r.handle[_i19]); // 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[i]; + winning_symbol = r.handle[_i19]; } else { // keep previously set precedence: new_prec = old_prec; } } else if (old_prec === 0) { - prec_symbols.push(r.handle[i]); - winning_symbol = r.handle[i]; // Jison.print('precedence set first time: ', old_prec, r.handle[i], symbol, handle[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]); } r.precedence = new_prec; @@ -24327,14 +24635,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (prec_symbols.length > 1) { if (self.DEBUG || 1) { - self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); + self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + this.symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); } } } productions.push(r); productions_.push([symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length]); - nonterminals[symbol].productions.push(r); + nonterminals[this.symbol].productions.push(r); } }; // Preprocess the action code block before we perform any `$n`, `@n` ,`##n` or `#n` expansions: // Any comment blocks in there should be kept intact (and not cause trouble either as those comments MAY @@ -24406,13 +24714,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // with our pants down in constructs like // `'"' + $$ + '"'` vs. `"'" + $$ + "'"` - var dqpos, - sqpos, - ccmtpos, - cppcmtpos, - first = -1; + var dqpos, sqpos, ccmtpos, cppcmtpos; + var first = -1; - for (var c = 0;; c++) { + for (var _c2 = 0;; _c2++) { first++; dqpos = s.indexOf('"', first); sqpos = s.indexOf("'", first); // also look for remaining comments which contain quotes of any kind, @@ -24446,7 +24751,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi s = s // multiline comment start markers: .replace(/\x01\x84/g, '/*').replace(/\x01\x85/g, '/*').replace(/\x01\x86/g, '//') // revert markers: .replace(/\x01\x81/g, '#').replace(/\x01\x82/g, '$').replace(/\x01\x83/g, '@') // and revert the string and regex markers: - .replace(/\x01\x87/g, '\'').replace(/\x01\x88/g, '\"').replace(/\x01\x89/g, '##').replace(/\x01\x90/g, '\\\\').replace(/\x01\x91/g, '\\\'').replace(/\x01\x92/g, '\\\"').replace(/\x01\x93/g, '\\\/').replace(/\x01\x94/g, 'YYABORT').replace(/\x01\x95/g, 'YYACCEPT').replace(/\x01\x96/g, 'yyvstack').replace(/\x01\x97/g, 'yylstack').replace(/\x01\x98/g, 'yyerror').replace(/\x01\x99/g, 'YYRECOVERING').replace(/\x01\x9A/g, 'yyerrok').replace(/\x01\x9B/g, 'yyclearin').replace(/\x01\x9C/g, 'yysp').replace(/\x01\x9D__/g, 'yy'); // And a final, minimal, fixup for the semicolon-lovers -- like me! ;-) + .replace(/\x01\x87/g, "'").replace(/\x01\x88/g, '\"').replace(/\x01\x89/g, '##').replace(/\x01\x90/g, '\\\\').replace(/\x01\x91/g, "\\'").replace(/\x01\x92/g, '\\\"').replace(/\x01\x93/g, '\\\/').replace(/\x01\x94/g, 'YYABORT').replace(/\x01\x95/g, 'YYACCEPT').replace(/\x01\x96/g, 'yyvstack').replace(/\x01\x97/g, 'yylstack').replace(/\x01\x98/g, 'yyerror').replace(/\x01\x99/g, 'YYRECOVERING').replace(/\x01\x9A/g, 'yyerrok').replace(/\x01\x9B/g, 'yyclearin').replace(/\x01\x9C/g, 'yysp').replace(/\x01\x9D__/g, 'yy'); // And a final, minimal, fixup for the semicolon-lovers -- like me! ;-) // // Make sure the last statement is properly semicolon-terminated 99.9% of the time: @@ -24485,11 +24790,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.productions_ = productions_; assert(this.productions === productions); */ - var productions = this.productions, - nonterminals = this.nonterminals, - symbols = this.symbols, - operators = this.operators, - self = this; // As a SIDE EFFECT of this call, we also fixup + var productions = this.productions; + var nonterminals = this.nonterminals; + var symbols = this.symbols; + var operators = this.operators; + var self = this; // As a SIDE EFFECT of this call, we also fixup // the other code chunks specified in the grammar file: // // Replace direct symbol references, e.g. #NUMBER# when there's a `%token NUMBER` for your grammar. @@ -24520,16 +24825,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi while (gen_hash !== prev_gen_hash) { var preludeCode = preprocessActionCode(this.actionInclude || ''); - var actions = ["\n /* this == yyval */\n\n // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code!\n var yy = this.yy;\n var yyparser = yy.parser;\n var yylexer = yy.lexer;\n\n ".concat(preludeCode, "\n\n switch (yystate) {")]; + var actions = ["\n /* this == yyval */\n\n // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code!\n let yy = this.yy;\n let yyparser = yy.parser;\n let yylexer = yy.lexer;\n\n ".concat(preludeCode, "\n\n switch (yystate) {")]; var actionGroups = {}; // used to combine identical actions into single instances: no use duplicating action code needlessly var actionGroupValue = {}; // stores the unaltered, expanded, user-defined action code for each action group. var stateHasAction = []; // marks which state IDs have an action, either user-specified or default. + // and now go and process the entire grammar: - var symbol; // and now go and process the entire grammar: - - productions.forEach(buildProductionAction); + productions.forEach(buildProductionAction, { + actionGroups: actionGroups, + actionGroupValue: actionGroupValue, + stateHasAction: stateHasAction + }); for (var hash in actionGroups) { actions.push([].concat.apply([], actionGroups[hash]).join('\n') + '\n\n' + actionGroupValue[hash] + '\n break;\n'); @@ -24554,10 +24862,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (missingActions.length) { if (this.DEBUG) { - this.warn("WARNING: missing actions for states: ", missingActions); + this.warn('WARNING: missing actions for states: ', missingActions); } - actions.push("default:\n // default action for all unlisted resolve states: ".concat(missingActions.join(', '), "\n\n // When we hit this entry, it's always a non-recoverable issue as this is a severe internal parser state failure:\n function __b0rk_on_internal_failure(str) {\n var hash = yyparser.constructParseErrorInfo(str, null, null, false);\n\n return yyparser.parseError(str, hash, yyparser.JisonParserError);\n }\n\n return __b0rk_on_internal_failure(\"internal parser failure: resolving unlisted state: \" + yystate);")); + actions.push("default:\n // default action for all unlisted resolve states: ".concat(missingActions.join(', '), "\n\n // When we hit this entry, it's always a non-recoverable issue as this is a severe internal parser state failure:\n function __b0rk_on_internal_failure(str) {\n let hash = yyparser.constructParseErrorInfo(str, null, null, false);\n\n return yyparser.parseError(str, hash, yyparser.JisonParserError);\n }\n\n return __b0rk_on_internal_failure(\"internal parser failure: resolving unlisted state: \" + yystate);")); } actions.push('}'); @@ -24727,9 +25035,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi this.actionsUseValueAssignment = true; break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": + case 'skip': // <-- this one injects *nothing* break; } @@ -24740,9 +25048,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi default: break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": + case 'skip': // <-- this one injects *nothing* break; } @@ -24814,7 +25122,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi moduleInit.getInitCodeSection = function getInitCodeSection(section) { var rv = []; - for (var i = 0, len = this.length; i < len; i++) { + for (var i = 0, _len12 = this.length; i < _len12; i++) { var m = this[i]; if (m.qualifier === section) { @@ -24832,11 +25140,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi moduleInit.getRemainingInitCodeSections = function getRemainingInitCodeSections() { var rv = []; - for (var i = 0, len = this.length; i < len; i++) { + for (var i = 0, _len13 = this.length; i < _len13; i++) { var m = this[i]; if (!this.__consumedInitCodeSlots__[i]) { - rv.push(rmCommonWS$5(_templateObject155(), m.qualifier, m.include, m.qualifier)); + rv.push(rmCommonWS$5(_templateObject156(), m.qualifier, m.include, m.qualifier)); this.__consumedInitCodeSlots__[i] = true; } } @@ -24913,12 +25221,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return ''; - } + } // options object { actionGroups, actionGroupValue, stateHasAction } is `this` for this function/callback: + function buildProductionAction(handle) { - var i; - var aliased = handle.aliases, - rhs_i; + var aliased = handle.aliases; var rhs = handle.handle; var named_token_re = new XRegExp__default['default']("^".concat(ID_REGEX_BASE$3, "$")); // semantic action specified @@ -24936,7 +25243,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var rule4msg = handle.symbol + ': ' + rhs.join(' '); assert__default['default'](typeof handle.id === 'number'); assert__default['default'](handle.id >= 0); - stateHasAction[handle.id] = true; // before anything else, replace direct symbol references, e.g. #NUMBER# when there's a %token NUMBER for your grammar. + this.stateHasAction[handle.id] = true; // before anything else, replace direct symbol references, e.g. #NUMBER# when there's a %token NUMBER for your grammar. // This is done to prevent incorrect expansions where tokens are used in rules as RHS elements: we allow these to // be referenced as both #TOKEN# and #TOKEN where the first is a literal token/symbol reference (unrelated to its use // in the rule) and the latter is a reference to the token/symbol being used in the rule. @@ -24948,9 +25255,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }); // replace named semantic values ($nonterminal) if (action.match(new XRegExp__default['default']("(?:[$@#]|##)".concat(ID_REGEX_BASE$3)))) { - var count = {}, - names = {}, - donotalias = {}; // When the rule is fitted with aliases it doesn't mean that the action code MUST use those: + var count = {}; + var names = {}; + var donotalias = {}; // When the rule is fitted with aliases it doesn't mean that the action code MUST use those: // we therefor allow access to both the original (non)terminal and the alias. // // Also note that each (non)terminal can also be uniquely addressed by [$@] @@ -24980,7 +25287,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // while `e2` would be ambiguous from the human perspective as he *might* then // expect `e2` and `e3`. - var addName = function addName(s) { + var addName = function addName(s, i) { var base = s.replace(/[0-9]+$/, ''); var dna = donotalias[base]; @@ -25012,9 +25319,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } }; - for (i = 0; i < rhs.length; i++) { + for (var i = 0; i < rhs.length; i++) { // mark both regular and aliased names, e.g., `id[alias1]` and `id1` - rhs_i = aliased[i]; + var rhs_i = aliased[i]; markBasename(rhs_i); if (rhs_i !== rhs[i]) { @@ -25022,13 +25329,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - for (i = 0; i < rhs.length; i++) { + for (var _i20 = 0; _i20 < rhs.length; _i20++) { // check for aliased names, e.g., id[alias] - rhs_i = aliased[i]; - addName(rhs_i); + var _rhs_i = aliased[_i20]; + addName(_rhs_i, _i20); - if (rhs_i !== rhs[i]) { - addName(rhs[i]); + if (_rhs_i !== rhs[_i20]) { + addName(rhs[_i20], _i20); } } @@ -25043,7 +25350,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi action = action // replace references to `$$` with `this.$`, `@$` with `this._$` and `#$` with the token ID of the current rule .replace(/\$\$/g, 'this.$').replace(/@\$/g, 'this._$').replace(/#\$/g, function (_) { - return provideSymbolAsSourcecode(symbol); + return provideSymbolAsSourcecode(handle.symbol); }) // replace semantic value references ($n) with stack value (stack[n]) .replace(/\$(-?\d+)\b/g, function (_, n) { return 'yyvstack[yysp' + indexToJsExpr(n, rhs.length, rule4msg) + ']'; @@ -25167,24 +25474,26 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // $@ = undefined; // - var vmode = !inject_default_value_action ? "skip" : self.options.defaultActionMode[0]; - var lmode = !inject_default_loc_action ? "skip" : self.options.defaultActionMode[1]; // check if there's no user action specified. Insert default action if it isn't. + var vmode = !inject_default_value_action ? 'skip' : self.options.defaultActionMode[0]; + var lmode = !inject_default_loc_action ? 'skip' : self.options.defaultActionMode[1]; // check if there's no user action specified. Insert default action if it isn't. // first determine the actual number of terms in the production: - var rhs = handle.handle.slice(0); + var rhs_reduced_length = rhs.length; var real_rhs_length = rhs.length; // strip away EOF terms at the end of the rule, ditto for epsilon terms: - if (rhs.length) { - switch (rhs[rhs.length - 1]) { + while (rhs_reduced_length) { + switch (rhs[rhs_reduced_length - 1]) { case '$end': - rhs.length--; - break; + rhs_reduced_length--; + continue; case '': // %epsilon - rhs.length--; - break; + rhs_reduced_length--; + continue; } + + break; } // then we can choose what to do, depending on the number of terms in the production. // // There are a few reasons *why* one would choose to inject the default action: @@ -25201,18 +25510,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // - switch (rhs.length) { + switch (rhs_reduced_length) { case 0: switch (vmode) { - case "classic": // $$ = $1; <-- but that would cause nondeterministic behaviour, so + case 'classic': // $$ = $1; <-- but that would cause nondeterministic behaviour, so // we fall back to the default here! - case "ast": - case "none": - default_action.push("this.$ = undefined;"); + case 'ast': + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25221,22 +25530,22 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // an empty production has no location as there are no terms parsed. // ergo: we produce a zero-width location which points at the tail // end of the previous content: // @$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);"); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25248,19 +25557,19 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi case 1: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; // // WARNING: be careful with the ACCEPT rule as that one's production has - // rhs.length === 1 **BUT** has real_rhs_length === 2 as we have discarded + // rhs_reduced_length === 1 **BUT** has real_rhs_length === 2 as we have discarded // the `$end` term at the end! // Here we need to account for that magick though! - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // As we're looking at a production which has one(1) useful term, we can simply // reference-copy that one intom a fresh array, instead of `slice()`-ing it out // of the vstack. @@ -25269,14 +25578,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // WARNING/NOTE: as above, and ditto BTW for rule productions which end with // `EOF` as a last term: as we now construct an entire AST, we DO NOT include // those 'values' here! - default_action.push("this.$ = [yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "]];"); + default_action.push('this.$ = [yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ']];'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25285,23 +25594,23 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: // as we have a production length of 1 only, we can simply ref-copy @1: // @$ = @1; // // WARNING: same as above for the value copying: we may have discarded an `EOF` or `$end` term! - default_action.push("this._$ = yylstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this._$ = yylstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25313,31 +25622,31 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi default: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // - // WARNING: as with the situation further above where rhs.length === 1 after we + // WARNING: as with the situation further above where rhs_reduced_length === 1 after we // have got rid of a possible `EOF` or `$end` at the end of the production, // we again have to account for our trickery earlier and compensate the // action above: again we DO NOT include the value of the EOF/$end token in the // resulting array 'AST', hence our `slice()` end index may vary by one(1): - var end_offset = 1 - real_rhs_length + rhs.length; - default_action.push("this.$ = yyvstack.slice(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp" + ( - /* CANNOT USE indexToJsExpr(rhs.length + 1, real_rhs_length, rule4msg) HERE! */ - end_offset === 0 ? "" : " + " + end_offset) + ");"); + var end_offset = 1 - real_rhs_length + rhs_reduced_length; + default_action.push('this.$ = yyvstack.slice(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp' + ( + /* CANNOT USE indexToJsExpr(rhs_reduced_length + 1, real_rhs_length, rule4msg) HERE! */ + end_offset === 0 ? '' : ' + ' + end_offset) + ');'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25346,20 +25655,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: - // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs.length - 1}, yysp); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp);"); + // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs_reduced_length - 1}, yysp); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -25373,7 +25682,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (default_action.length > 0) { - var flags = [rhs.length, self.actionsUseValueTracking ? "VT" : "-", self.actionsUseValueAssignment ? "VA" : "-", uses_$$ ? "VU" : "-", uses_$$_before_assignment ? "VUbA" : "-", self.actionsUseLocationTracking ? "LT" : "-", self.actionsUseLocationAssignment ? "LA" : "-", uses_$loc ? "LU" : "-", uses_$loc_before_assignment ? "LUbA" : "-"].join(','); + var flags = [rhs_reduced_length + '/' + real_rhs_length, self.actionsUseValueTracking ? 'VT' : '-', self.actionsUseValueAssignment ? 'VA' : '-', uses_$$ ? 'VU' : '-', uses_$$_before_assignment ? 'VUbA' : '-', self.actionsUseLocationTracking ? 'LT' : '-', self.actionsUseLocationAssignment ? 'LA' : '-', uses_$loc ? 'LU' : '-', uses_$loc_before_assignment ? 'LUbA' : '-'].join(','); default_action.unshift("// default action (generated by JISON mode ".concat(self.options.defaultActionMode[0], "/").concat(self.options.defaultActionMode[1], " :: ").concat(flags, "):")); default_action.push("// END of default action (generated by JISON mode ".concat(self.options.defaultActionMode[0], "/").concat(self.options.defaultActionMode[1], " :: ").concat(flags, ")")); @@ -25388,11 +25697,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var actionHash = mkHashIndex(action); // Delay running the postprocess (restore) process until we've done ALL macro expansions: //action = postprocessActionCode(action); - if (actionHash in actionGroups) { - actionGroups[actionHash].push(label); + if (actionHash in this.actionGroups) { + this.actionGroups[actionHash].push(label); } else { - actionGroups[actionHash] = [label]; - actionGroupValue[actionHash] = action; + this.actionGroups[actionHash] = [label]; + this.actionGroupValue[actionHash] = action; } } }; @@ -25498,7 +25807,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; // --- START of debugTraceSrc chunk --- - var debugTraceSrc = "\nfunction debug_trace() {\n \"use strict\";\n\n if (typeof Jison !== 'undefined' && Jison.print) {\n Jison.print.apply(null, arguments);\n } else if (typeof print !== 'undefined') {\n print.apply(null, arguments);\n } else if (typeof console !== 'undefined' && console.log) {\n var args = Array.prototype.slice.call(arguments, 0);\n args.unshift(''); // prevent `%.` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args\n console.log.apply(null, args);\n }\n}\n"; // --- END of debugTraceSrc chunk --- + var debugTraceSrc = "\nfunction debug_trace() {\n if (typeof Jison !== 'undefined' && Jison.print) {\n Jison.print.apply(null, arguments);\n } else if (typeof print !== 'undefined') {\n print.apply(null, arguments);\n } else if (typeof console !== 'undefined' && console.log) {\n let args = Array.prototype.slice.call(arguments, 0);\n args.unshift(''); // prevent `%.` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args\n console.log.apply(null, args);\n }\n}\n"; // --- END of debugTraceSrc chunk --- // Generator debug mixin var generatorDebug = { @@ -25565,10 +25874,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi lookaheadMixin.followSets = function followSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true; // loop until no further changes have been made + var productions = this.productions; + var nonterminals = this.nonterminals; + var self = this; + var cont = true; // loop until no further changes have been made while (cont) { cont = false; @@ -25585,7 +25894,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } var bool = !ctx || q === self.nterms_[t]; - var set; + var set = void 0; if (i === production.handle.length - 1 && bool) { set = nonterminals[production.symbol].follows; @@ -25634,25 +25943,25 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi firsts = union(firsts, this.nonterminals[t].first); } - if (!this.nullable(t)) break; + if (!this.nullable(t)) { + break; + } } return firsts; // terminal } else if (!this.nonterminals[symbol]) { return [symbol]; // nonterminal - } else { - return this.nonterminals[symbol].first; } + + return this.nonterminals[symbol].first; }; // fixed-point calculation of FIRST sets lookaheadMixin.firstSets = function firstSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true, - symbol, - firsts; // loop until no further changes have been made + var productions = this.productions; + var nonterminals = this.nonterminals; + var self = this; + var cont = true; // loop until no further changes have been made while (cont) { cont = false; @@ -25665,8 +25974,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } }); - for (symbol in nonterminals) { - firsts = []; + var _loop2 = function _loop2(symbol) { + var firsts = []; nonterminals[symbol].productions.forEach(function FirstSets_forEachNonTerm(production) { firsts = union(firsts, production.first); }); @@ -25675,22 +25984,29 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi nonterminals[symbol].first = firsts; cont = true; } + }; + + for (var symbol in nonterminals) { + _loop2(symbol); } } }; // fixed-point calculation of NULLABLE lookaheadMixin.nullableSets = function nullableSets() { - var nonterminals = this.nonterminals, - self = this, - cont = true; // loop until no further changes have been made + var nonterminals = this.nonterminals; + var self = this; + var cont = true; // loop until no further changes have been made while (cont) { cont = false; // check if each production is nullable this.productions.forEach(function isEachProductionNullable(production, k) { if (!production.nullable) { - for (var i = 0, n = 0, t; t = production.handle[i]; ++i) { + var i = 0; + var n = 0; + + for (var t; t = production.handle[i]; ++i) { if (self.nullable(t)) n++; } @@ -25728,9 +26044,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return true; // terminal } else if (!this.nonterminals[symbol]) { return false; // nonterminal - } else { - return this.nonterminals[symbol].nullable; } + + return this.nonterminals[symbol].nullable; }; // lookahead debug mixin @@ -25832,7 +26148,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return s; } }); - lrGeneratorMixin.ItemSet = Set.prototype.construct({ + lrGeneratorMixin.ItemSet = Set$1.prototype.construct({ afterconstructor: function afterconstructor() { this.reductions = []; this.goes = {}; @@ -25879,12 +26195,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi lrGeneratorMixin.closureOperation = function closureOperation(itemSet) { var closureSet = new this.ItemSet(); var self = this; - var set = itemSet, - itemQueue, - syms = {}; + var set = itemSet; + var itemQueue; + var syms = {}; do { - itemQueue = new Set(); + itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function CO_set_forEach(item) { var symbol = item.markedSymbol; // if token is a non-terminal, recursively add closures @@ -25917,8 +26233,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) { - var gotoSet = new this.ItemSet(), - self = this; + var gotoSet = new this.ItemSet(); + var self = this; itemSet.forEach(function goto_forEach(item, n) { if (item.markedSymbol === symbol) { gotoSet.push(new self.Item(item.production, item.dotPosition + 1, item.follows, n)); @@ -25933,13 +26249,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi lrGeneratorMixin.canonicalCollection = function canonicalCollection() { var item1 = new this.Item(this.productions[0], 0, [this.EOF]); - var firstStateNoClosure = new this.ItemSet(item1), - firstState = this.closureOperation(firstStateNoClosure), - states = new Set(firstState), - marked = 0, - self = this, - itemSet, - markedSymbols; + var firstStateNoClosure = new this.ItemSet(item1); + var firstState = this.closureOperation(firstStateNoClosure); + var states = new Set$1(firstState); + var marked = 0; + var self = this; + var itemSet; + var markedSymbols; states.has = {}; states.has[firstStateNoClosure.valueOf()] = 0; @@ -25960,8 +26276,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert(symbol, itemSet, states, stateNum) { - var g = this.gotoOperation(itemSet, symbol), - state = states.has[g.valueOf()]; + var g = this.gotoOperation(itemSet, symbol); + var state = states.has[g.valueOf()]; if (typeof state !== 'undefined') { itemSet.edges[symbol] = state; // store goto transition for table @@ -25986,12 +26302,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { - var states = [], - nonterminals = this.nonterminals, - operators = this.operators, - conflictedStates = {}, - // set of [state, token] tuples - self = this; // for each item set + var states = []; + var nonterminals = this.nonterminals; + var operators = this.operators; + var conflictedStates = {}; // set of [state, token] tuples + + var self = this; // for each item set itemSets.forEach(function parseTableItem(itemSet, k) { k = +k; @@ -26136,11 +26452,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function findDefaults(states, hasErrorRecovery) { var defaults = {}; states.forEach(function (state, k) { - var act, sym, st; + var act; var i = 0; var gotos = {}; - for (sym in state) { + for (var sym in state) { assert__default['default']({}.hasOwnProperty.call(state, sym)); // it this isn't true, the last part of this function won't work! // keep state rows where there's an error recovery state: @@ -26150,7 +26466,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return; } - st = state[sym]; + var st = state[sym]; if (typeof st !== 'number') { if (st[0] !== REDUCE) { @@ -26186,11 +26502,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // when there's no error recovery code included in the generated parser: if (!hasErrorRecovery) { - for (sym in state) { - st = state[sym]; + for (var _sym2 in state) { + var _st = state[_sym2]; - if (typeof st !== 'number') { - delete state[sym]; + if (typeof _st !== 'number') { + delete state[_sym2]; } } } @@ -26202,9 +26518,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function cleanupTable(table) { table.forEach(function (state, k) { - var symbol; - - for (symbol in state) { + for (var symbol in state) { if (state[symbol] === NONASSOC) { delete state[symbol]; } @@ -26290,7 +26604,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComment() { - var out = "\n/* parser generated by jison ".concat(version$2, " */\n\n/*\n * Returns a Parser object of the following structure:\n *\n * Parser: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" `yy` passed around to\n * the rule actions, etc. is a derivative/copy of this one,\n * not a direct reference!\n * }\n *\n * Parser.prototype: {\n * yy: {},\n * EOF: 1,\n * TERROR: 2,\n *\n * trace: function(errorMessage, ...),\n *\n * JisonParserError: function(msg, hash),\n *\n * quoteName: function(name),\n * Helper function which can be overridden by user code later on: put suitable\n * quotes around literal IDs in a description string.\n *\n * originalQuoteName: function(name),\n * The basic quoteName handler provided by JISON.\n * `cleanupAfterParse()` will clean up and reset `quoteName()` to reference this function\n * at the end of the `parse()`.\n *\n * describeSymbol: function(symbol),\n * Return a more-or-less human-readable description of the given symbol, when\n * available, or the symbol itself, serving as its own 'description' for lack\n * of something better to serve up.\n *\n * Return NULL when the symbol is unknown to the parser.\n *\n * symbols_: {associative list: name ==> number},\n * terminals_: {associative list: number ==> name},\n * nonterminals: {associative list: rule-name ==> {associative list: number ==> rule-alt}},\n * terminal_descriptions_: (if there are any) {associative list: number ==> description},\n * productions_: [...],\n *\n * performAction: function parser__performAction(yytext, yyleng, yylineno, yyloc, yystate, yysp, yyvstack, yylstack, yystack, yysstack),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `yyval` internal object, which has members (`$` and `_$`)\n * to store/reference the rule value `$$` and location info `@$`.\n *\n * One important thing to note about `this` a.k.a. `yyval`: every *reduce* action gets\n * to see the same object via the `this` reference, i.e. if you wish to carry custom\n * data from one reduce action through to the next within a single parse run, then you\n * may get nasty and use `yyval` a.k.a. `this` for storing you own semi-permanent data.\n *\n * `this.yy` is a direct reference to the `yy` shared state object.\n *\n * `%parse-param`-specified additional `parse()` arguments have been added to this `yy`\n * object at `parse()` start and are therefore available to the action code via the\n * same named `yy.xxxx` attributes (where `xxxx` represents a identifier name from\n * the %parse-param` list.\n *\n * - `yytext` : reference to the lexer value which belongs to the last lexer token used\n * to match this rule. This is *not* the look-ahead token, but the last token\n * that's actually part of this rule.\n *\n * Formulated another way, `yytext` is the value of the token immediately preceeding\n * the current look-ahead token.\n * Caveats apply for rules which don't require look-ahead, such as epsilon rules.\n *\n * - `yyleng` : ditto as `yytext`, only now for the lexer.yyleng value.\n *\n * - `yylineno`: ditto as `yytext`, only now for the lexer.yylineno value.\n *\n * - `yyloc` : ditto as `yytext`, only now for the lexer.yylloc lexer token location info.\n *\n * WARNING: since jison 0.4.18-186 this entry may be NULL/UNDEFINED instead\n * of an empty object when no suitable location info can be provided.\n *\n * - `yystate` : the current parser state number, used internally for dispatching and\n * executing the action code chunk matching the rule currently being reduced.\n *\n * - `yysp` : the current state stack position (a.k.a. 'stack pointer')\n *\n * This one comes in handy when you are going to do advanced things to the parser\n * stacks, all of which are accessible from your action code (see the next entries below).\n *\n * Also note that you can access this and other stack index values using the new double-hash\n * syntax, i.e. `##$ === ##0 === yysp`, while `##1` is the stack index for all things\n * related to the first rule term, just like you have `$1`, `@1` and `#1`.\n * This is made available to write very advanced grammar action rules, e.g. when you want\n * to investigate the parse state stack in your action code, which would, for example,\n * be relevant when you wish to implement error diagnostics and reporting schemes similar\n * to the work described here:\n *\n * + Pottier, F., 2016. Reachability and error diagnosis in LR(1) automata.\n * In Journ\xE9es Francophones des Languages Applicatifs.\n *\n * + Jeffery, C.L., 2003. Generating LR syntax error messages from examples.\n * ACM Transactions on Programming Languages and Systems (TOPLAS), 25(5), pp.631\u2013640.\n *\n * - `yyrulelength`: the current rule's term count, i.e. the number of entries occupied on the stack.\n *\n * This one comes in handy when you are going to do advanced things to the parser\n * stacks, all of which are accessible from your action code (see the next entries below).\n *\n * - `yyvstack`: reference to the parser value stack. Also accessed via the `$1` etc.\n * constructs.\n *\n * - `yylstack`: reference to the parser token location stack. Also accessed via\n * the `@1` etc. constructs.\n *\n * WARNING: since jison 0.4.18-186 this array MAY contain slots which are\n * UNDEFINED rather than an empty (location) object, when the lexer/parser\n * action code did not provide a suitable location info object when such a\n * slot was filled!\n *\n * - `yystack` : reference to the parser token id stack. Also accessed via the\n * `#1` etc. constructs.\n *\n * Note: this is a bit of a **white lie** as we can statically decode any `#n` reference to\n * its numeric token id value, hence that code wouldn't need the `yystack` but *you* might\n * want access this array for your own purposes, such as error analysis as mentioned above!\n *\n * Note that this stack stores the current stack of *tokens*, that is the sequence of\n * already parsed=reduced *nonterminals* (tokens representing rules) and *terminals*\n * (lexer tokens *shifted* onto the stack until the rule they belong to is found and\n * *reduced*.\n *\n * - `yysstack`: reference to the parser state stack. This one carries the internal parser\n * *states* such as the one in `yystate`, which are used to represent\n * the parser state machine in the *parse table*. *Very* *internal* stuff,\n * what can I say? If you access this one, you're clearly doing wicked things\n *\n * - `...` : the extra arguments you specified in the `%parse-param` statement in your\n * grammar definition file.\n *\n * table: [...],\n * State transition table\n * ----------------------\n *\n * index levels are:\n * - `state` --> hash table\n * - `symbol` --> action (number or array)\n *\n * If the `action` is an array, these are the elements' meaning:\n * - index [0]: 1 = shift, 2 = reduce, 3 = accept\n * - index [1]: GOTO `state`\n *\n * If the `action` is a number, it is the GOTO `state`\n *\n * defaultActions: {...},\n *\n * parseError: function(str, hash, ExceptionClass),\n * yyError: function(str, ...),\n * yyRecovering: function(),\n * yyErrOk: function(),\n * yyClearIn: function(),\n *\n * constructParseErrorInfo: function(error_message, exception_object, expected_token_set, is_recoverable),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.\n * See it's use in this parser kernel in many places; example usage:\n *\n * var infoObj = parser.constructParseErrorInfo('fail!', null,\n * parser.collect_expected_token_set(state), true);\n * var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError);\n *\n * originalParseError: function(str, hash, ExceptionClass),\n * The basic `parseError` handler provided by JISON.\n * `cleanupAfterParse()` will clean up and reset `parseError()` to reference this function\n * at the end of the `parse()`.\n *\n * options: { ... parser %options ... },\n *\n * parse: function(input[, args...]),\n * Parse the given `input` and return the parsed value (or `true` when none was provided by\n * the root action, in which case the parser is acting as a *matcher*).\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of this grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Parser's additional `args...` parameters (via `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * The lexer MAY add its own set of additional parameters (via the `%parse-param` line in\n * the lexer section of the grammar spec): these will be inserted in the `yy` shared state\n * object and any collision with those will be reported by the lexer via a thrown exception.\n *\n * cleanupAfterParse: function(resultValue, invoke_post_methods, do_not_nuke_errorinfos),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * This helper API is invoked at the end of the `parse()` call, unless an exception was thrown\n * and `%options no-try-catch` has been defined for this grammar: in that case this helper MAY\n * be invoked by calling user code to ensure the `post_parse` callbacks are invoked and\n * the internal parser gets properly garbage collected under these particular circumstances.\n *\n * yyMergeLocationInfo: function(first_index, last_index, first_yylloc, last_yylloc, dont_look_back),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * This helper API can be invoked to calculate a spanning `yylloc` location info object.\n *\n * Note: %epsilon rules MAY specify no `first_index` and `first_yylloc`, in which case\n * this function will attempt to obtain a suitable location marker by inspecting the location stack\n * backwards.\n *\n * For more info see the documentation comment further below, immediately above this function's\n * implementation.\n *\n * lexer: {\n * yy: {...}, A reference to the so-called \"shared state\" `yy` once\n * received via a call to the `.setInput(input, yy)` lexer API.\n * EOF: 1,\n * ERROR: 2,\n * JisonLexerError: function(msg, hash),\n * parseError: function(str, hash, ExceptionClass),\n * setInput: function(input, [yy]),\n * input: function(),\n * unput: function(str),\n * more: function(),\n * reject: function(),\n * less: function(n),\n * pastInput: function(n),\n * upcomingInput: function(n),\n * showPosition: function(),\n * test_match: function(regex_match_array, rule_index, ...),\n * next: function(...),\n * lex: function(...),\n * begin: function(condition),\n * pushState: function(condition),\n * popState: function(),\n * topState: function(),\n * _currentRules: function(),\n * stateStackSize: function(),\n * cleanupAfterLex: function()\n *\n * options: { ... lexer %options ... },\n *\n * performAction: function(yy, yy_, $avoiding_name_collisions, YY_START, ...),\n * rules: [...],\n * conditions: {associative list: name ==> set},\n * }\n * }\n *\n *\n * token location info (@$, _$, etc.): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a 'hash' object with these members for lexer and\n * parser errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * }\n *\n * parser (grammar) errors will also provide these additional members:\n *\n * {\n * expected: (array describing the set of expected tokens;\n * may be UNDEFINED when we cannot easily produce such a set)\n * state: (integer (or array when the table includes grammar collisions);\n * represents the current internal state of the parser kernel.\n * can, for example, be used to pass to the `collect_expected_token_set()`\n * API to obtain the expected token set)\n * action: (integer; represents the current internal action which will be executed)\n * new_state: (integer; represents the next/planned internal state, once the current\n * action has executed)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * state_stack: (array: the current parser LALR/LR internal state stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * value_stack: (array: the current parser LALR/LR internal `$$` value stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * location_stack: (array: the current parser LALR/LR internal location stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * yy: (object: the current parser internal \"shared state\" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * parser: (reference to the current parser instance)\n * }\n *\n * while `this` will reference the current parser instance.\n *\n * When `parseError` is invoked by the lexer, `this` will still reference the related *parser*\n * instance, while these additional `hash` fields will also be provided:\n *\n * {\n * lexer: (reference to the current lexer instance which reported the error)\n * }\n *\n * When `parseError` is invoked by the parser due to a **JavaScript exception** being fired\n * from either the parser or lexer, `this` will still reference the related *parser*\n * instance, while these additional `hash` fields will also be provided:\n *\n * {\n * exception: (reference to the exception thrown)\n * }\n *\n * Please do note that in the latter situation, the `expected` field will be omitted as\n * this type of failure is assumed not to be due to *parse errors* but rather due to user\n * action code in either parser or lexer failing unexpectedly.\n *\n * ---\n *\n * You can specify parser options by setting / modifying the `.yy` object of your Parser instance.\n * These options are available:\n *\n * ### options which are global for all parser instances\n *\n * Parser.pre_parse: function(yy)\n * optional: you can specify a pre_parse() function in the chunk following\n * the grammar, i.e. after the last `%%`.\n * Parser.post_parse: function(yy, retval, parseInfo) { return retval; }\n * optional: you can specify a post_parse() function in the chunk following\n * the grammar, i.e. after the last `%%`. When it does not return any value,\n * the parser will return the original `retval`.\n *\n * ### options which can be set up per parser instance\n *\n * yy: {\n * pre_parse: function(yy)\n * optional: is invoked before the parse cycle starts (and before the first\n * invocation of `lex()`) but immediately after the invocation of\n * `parser.pre_parse()`).\n * post_parse: function(yy, retval, parseInfo) { return retval; }\n * optional: is invoked when the parse terminates due to success ('accept')\n * or failure (even when exceptions are thrown).\n * `retval` contains the return value to be produced by `Parser.parse()`;\n * this function can override the return value by returning another.\n * When it does not return any value, the parser will return the original\n * `retval`.\n * This function is invoked immediately before `parser.post_parse()`.\n *\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * quoteName: function(name),\n * optional: overrides the default `quoteName` function.\n * }\n *\n * parser.lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean (\u214F \uC13C \u214A \u2056 \u2058 \u2059 \u205A \u205B \u205C \u205D \u205E \u2020 \u2021 \n a\u2BC8b\n \u2200 \u2201 \u2202 \u2203 \u2204 \u2205 \u2206 \u2207 \u2208 \u2209 \u220A \u220B \u220C \u220D \u220E \u220F\nU+221x \u2210 \u2211 \u2212 \u2213 \u2214 \u2215 \u2216 \u2217 \u2218 \u2219 \u221A \u221B \u221C \u221D \u221E \u221F\nU+222x \u2220 \u2221 \u2222 \u2223 \u2224 \u2225 \u2226 \u2227 \u2228 \u2229 \u222A \u222B \u222C \u222D \u222E \u222F\nU+223x \u2230 \u2231 \u2232 \u2233 \u2234 \u2235 \u2236 \u2237 \u2238 \u2239 \u223A \u223B \u223C \u223D \u223E \u223F\nU+224x \u2240 \u2241 \u2242 \u2243 \u2244 \u2245 \u2246 \u2247 \u2248 \u2249 \u224A \u224B \u224C \u224D \u224E \u224F\nU+225x \u2250 \u2251 \u2252 \u2253 \u2254 \u2255 \u2256 \u2257 \u2258 \u2259 \u225A \u225B \u225C \u225D \u225E \u225F\nU+226x \u2260 \u2261 \u2262 \u2263 \u2264 \u2265 \u2266 \u2267 \u2268 \u2269 \u226A \u226B \u226C \u226D \u226E \u226F\nU+227x \u2270 \u2271 \u2272 \u2273 \u2274 \u2275 \u2276 \u2277 \u2278 \u2279 \u227A \u227B \u227C \u227D \u227E \u227F\nU+228x \u2280 \u2281 \u2282 \u2283 \u2284 \u2285 \u2286 \u2287 \u2288 \u2289 \u228A \u228B \u228C \u228D \u228E \u228F\nU+229x \u2290 \u2291 \u2292 \u2293 \u2294 \u2295 \u2296 \u2297 \u2298 \u2299 \u229A \u229B \u229C \u229D \u229E \u229F\nU+22Ax \u22A0 \u22A1 \u22A2 \u22A3 \u22A4 \u22A5 \u22A6 \u22A7 \u22A8 \u22A9 \u22AA \u22AB \u22AC \u22AD \u22AE \u22AF\nU+22Bx \u22B0 \u22B1 \u22B2 \u22B3 \u22B4 \u22B5 \u22B6 \u22B7 \u22B8 \u22B9 \u22BA \u22BB \u22BC \u22BD \u22BE \u22BF\nU+22Cx \u22C0 \u22C1 \u22C2 \u22C3 \u22C4 \u22C5 \u22C6 \u22C7 \u22C8 \u22C9 \u22CA \u22CB \u22CC \u22CD \u22CE \u22CF\nU+22Dx \u22D0 \u22D1 \u22D2 \u22D3 \u22D4 \u22D5 \u22D6 \u22D7 \u22D8 \u22D9 \u22DA \u22DB \u22DC \u22DD \u22DE \u22DF\nU+22Ex \u22E0 \u22E1 \u22E2 \u22E3 \u22E4 \u22E5 \u22E6 \u22E7 \u22E8 \u22E9 \u22EA \u22EB \u22EC \u22ED \u22EE \u22EF\nU+22Fx \u22F0 \u22F1 \u22F2 \u22F3 \u22F4 \u22F5 \u22F6 \u22F7 \u22F8 \u22F9 \u22FA \u22FB \u22FC \u22FD \u22FE \u22FF)\nU+230x \u2300 \u2301 \u2302 \u2303 \u2304 \u2305 \u2306 \u2307 \u2308 \u2309 \u230A \u230B \u230C \u230D \u230E \u230F\nU+231x \u2310 \u2311 \u2312 \u2313 \u2314 \u2315 \u2316 \u2317 \u2318 \u2319 \u231A \u231B \u231C \u231D \u231E \u231F\nU+232x \u2320 \u2321 \u2322 \u2323 \u2324 \u2325 \u2326 \u2327 \u2328 \u2329 \u232A \u232B \u232C \u232D \u232E \u232F\nU+233x \u2330 \u2331 \u2332 \u2333 \u2334 \u2335 \u2336 \u2337 \u2338 \u2339 \u233A \u233B \u233C \u233D \u233E \u233F\nU+234x \u2340 \u2341 \u2342 \u2343 \u2344 \u2345 \u2346 \u2347 \u2348 \u2349 \u234A \u234B \u234C \u234D \u234E \u234F\nU+235x \u2350 \u2351 \u2352 \u2353 \u2354 \u2355 \u2356 \u2357 \u2358 \u2359 \u235A \u235B \u235C \u235D \u235E \u235F\nU+236x \u2360 \u2361 \u2362 \u2363 \u2364 \u2365 \u2366 \u2367 \u2368 \u2369 \u236A \u236B \u236C \u236D \u236E \u236F\nU+237x \u2370 \u2371 \u2372 \u2373 \u2374 \u2375 \u2376 \u2377 \u2378 \u2379 \u237A \u237B \u237C \u237D \u237E \u237F\nU+238x \u2380 \u2381 \u2382 \u2383 \u2384 \u2385 \u2386 \u2387 \u2388 \u2389 \u238A \u238B \u238C \u238D \u238E \u238F\nU+239x \u2390 \u2391 \u2392 \u2393 \u2394 \u2395 \u2396 \u2397 \u2398 \u2399 \u239A \u239B \u239C \u239D \u239E \u239F\nU+23Ax \u23A0 \u23A1 \u23A2 \u23A3 \u23A4 \u23A5 \u23A6 \u23A7 \u23A8 \u23A9 \u23AA \u23AB \u23AC \u23AD \u23AE \u23AF\nU+23Bx \u23B0 \u23B1 \u23B2 \u23B3 \u23B4 \u23B5 \u23B6 \u23B7 \u23B8 \u23B9 \u23BA \u23BB \u23BC \u23BD \u23BE \u23BF\nU+23Cx \u23C0 \u23C1 \u23C2 \u23C3 \u23C4 \u23C5 \u23C6 \u23C7 \u23C8 \u23C9 \u23CA \u23CB \u23CC \u23CD \u23CE \u23CF\nU+23Dx \u23D0 \u23D1 \u23D2 \u23D3 \u23D4 \u23D5 \u23D6 \u23D7 \u23D8 \u23D9 \u23DA \u23DB \u23DC \u23DD \u23DE \u23DF\nU+23Ex \u23E0 \u23E1 \u23E2 \u23E3 \u23E4 \u23E5 \u23E6 \u23E7 \u23E8 \u23E9 \u23EA \u23EB \u23EC \u23ED \u23EE \u23EF\nU+23Fx \u23F0 \u23F1 \u23F2 \u23F3 \u23F4 \u23F5 \u23F6 \u23F7 \u23F8 \u23F9 \u23FA \u23FB \u23FC \u23FD \u23FE \u23FF\n\nU+260x \u2600 \u2601 \u2602 \u2603 \u2604 \u2605 \u2606 \u2607 \u2608 \u2609 \u260A \u260B \u260C \u260D \u260E \u260F\nU+261x \u2610 \u2611 \u2612 \u2613 \u2614 \u2615 \u2616 \u2617 \u2618 \u2619 \u261A \u261B \u261C \u261D \u261E \u261F\nU+262x \u2620 \u2621 \u2622 \u2623 \u2624 \u2625 \u2626 \u2627 \u2628 \u2629 \u262A \u262B \u262C \u262D \u262E \u262F\nU+263x \u2630 \u2631 \u2632 \u2633 \u2634 \u2635 \u2636 \u2637 \u2638 \u2639 \u263A \u263B \u263C \u263D \u263E \u263F\nU+264x \u2640 \u2641 \u2642 \u2643 \u2644 \u2645 \u2646 \u2647 \u2648 \u2649 \u264A \u264B \u264C \u264D \u264E \u264F\nU+265x \u2650 \u2651 \u2652 \u2653 \u2654 \u2655 \u2656 \u2657 \u2658 \u2659 \u265A \u265B \u265C \u265D \u265E \u265F\nU+266x \u2660 \u2661 \u2662 \u2663 \u2664 \u2665 \u2666 \u2667 \u2668 \u2669 \u266A \u266B \u266C \u266D \u266E \u266F\nU+267x \u2670 \u2671 \u2672 \u2673 \u2674 \u2675 \u2676 \u2677 \u2678 \u2679 \u267A \u267B \u267C \u267D \u267E \u267F\nU+268x \u2680 \u2681 \u2682 \u2683 \u2684 \u2685 \u2686 \u2687 \u2688 \u2689 \u268A \u268B \u268C \u268D \u268E \u268F\nU+269x \u2690 \u2691 \u2692 \u2693 \u2694 \u2695 \u2696 \u2697 \u2698 \u2699 \u269A \u269B \u269C \u269D \u269E \u269F\nU+26Ax \u26A0 \u26A1 \u26A2 \u26A3 \u26A4 \u26A5 \u26A6 \u26A7 \u26A8 \u26A9 \u26AA \u26AB \u26AC \u26AD \u26AE \u26AF\nU+26Bx \u26B0 \u26B1 \u26B2 \u26B3 \u26B4 \u26B5 \u26B6 \u26B7 \u26B8 \u26B9 \u26BA \u26BB \u26BC \u26BD \u26BE \u26BF\nU+26Cx \u26C0 \u26C1 \u26C2 \u26C3 \u26C4 \u26C5 \u26C6 \u26C7 \u26C8 \u26C9 \u26CA \u26CB \u26CC \u26CD \u26CE \u26CF\nU+26Dx \u26D0 \u26D1 \u26D2 \u26D3 \u26D4 \u26D5 \u26D6 \u26D7 \u26D8 \u26D9 \u26DA \u26DB \u26DC \u26DD \u26DE \u26DF\nU+26Ex \u26E0 \u26E1 \u26E2 \u26E3 \u26E4 \u26E5 \u26E6 \u26E7 \u26E8 \u26E9 \u26EA \u26EB \u26EC \u26ED \u26EE \u26EF\nU+26Fx \u26F0 \u26F1 \u26F2 \u26F3 \u26F4 \u26F5 \u26F6 \u26F7 \u26F8 \u26F9 \u26FA \u26FB \u26FC \u26FD \u26FE \u26FF\n\n \u2701 \u2702 \u2703 \u2704 \u2705 \u2706 \u2707 \u2708 \u2709 \u261B \u261E \u270C \u270D \u270E \u270F\n\u2710 \u2711 \u2712 \u2713 \u2714 \u2715 \u2716 \u2717 \u2718 \u2719 \u271A \u271B \u271C \u271D \u271E \u271F\n\u2720 \u2721 \u2722 \u2723 \u2724 \u2725 \u2726 \u2727 \u2605 \u2729 \u272A \u272B \u272C \u272D \u272E \u272F\n\u2730 \u2731 \u2732 \u2733 \u2734 \u2735 \u2736 \u2737 \u2738 \u2739 \u273A \u273B \u273C \u273D \u273E \u273F\n\u2740 \u2741 \u2742 \u2743 \u2744 \u2745 \u2746 \u2747 \u2748 \u2749 \u274A \u274B \u25CF \u274D \u25A0 \u274F\n\u263A \u263B \u2665 \u2666 \u2663 \u2660 \u2022 \u25D8 \u25CB \u2750 \u2751 \u2752 \u25B2 \u25BC \u25C6 \u2756\n\u25D7 \u2758 \u2759 \u275A \u275B \u275C \u275D \u275E \n\nU+270x \u2700 \u2701 \u2702 \u2703 \u2704 \u2705 \u2706 \u2707 \u2708 \u2709 \u270A \u270B \u270C \u270D \u270E \u270F\nU+271x \u2710 \u2711 \u2712 \u2713 \u2714 \u2715 \u2716 \u2717 \u2718 \u2719 \u271A \u271B \u271C \u271D \u271E \u271F\nU+272x \u2720 \u2721 \u2722 \u2723 a\u2724b a\u2725b a\u2726b a\u2727b \u2728 \u2729 \u272A \u272B \u272C \u272D \u272E \u272F\nU+273x \u2730 \u2731 \u2732 \u2733 \u2734 \u2735 \u2736 \u2737 \u2738 \u2739 \u273A \u273B \u273C \u273D \u273E \u273F\nU+274x \u2740 \u2741 \u2742 \u2743 \u2744 \u2745 \u2746 \u2747 \u2748 \u2749 \u274A \u274B \u274C \u274D \u274E \u274F\nU+275x \u2750 \u2751 \u2752 \u2753 \u2754 \u2755 \u2756 \u2757 \u2758 \u2759 \u275A \u275B \u275C \u275D \u275E \u275F\nU+276x \u2760 \u2761 \u2762 \u2763 \u2764 \u2765 \u2766 \u2767 \u2768 \u2769 \u276A \u276B \u276C \u276D \u276E a\u276Fb\nU+277x \u2770 \u2771 \u2772 \u2773 \u2774 \u2775 \u2776 \u2777 \u2778 \u2779 \u277A \u277B \u277C \u277D \u277E \u277F\nU+278x \u2780 \u2781 \u2782 \u2783 \u2784 \u2785 \u2786 \u2787 \u2788 \u2789 \u278A \u278B \u278C \u278D \u278E \u278F\nU+279x \u2790 \u2791 \u2792 \u2793 \u2794 \u2795 \u2796 \u2797 \u2798 \u2799 \u279A \u279B \u279C \u279D \u279E \u279F\nU+27Ax \u27A0 \u27A1 \u27A2 \u27A3 \u27A4 \u27A5 \u27A6 \u27A7 a\u27A8b \u27A9 \u27AA \u27AB \u27AC \u27AD \u27AE \u27AF\nU+27Bx \u27B0 a\u27B1b \u27B2 \u27B3 \u27B4 \u27B5 \u27B6 \u27B7 \u27B8 \u27B9 \u27BA \u27BB \u27BC \u27BD \u27BE \u27BF\n\nU+2580 \u2580 Upper half block\nU+2581 \u2581 Lower one eighth block\nU+2582 \u2582 Lower one quarter block\nU+2583 \u2583 Lower three eighths block\nU+2584 \u2584 Lower half block\nU+2585 \u2585 Lower five eighths block\nU+2586 \u2586 Lower three quarters block\nU+2587 \u2587 Lower seven eighths block\nU+2588 \u2588 Full block\nU+2589 \u2589 Left seven eighths block\nU+258A \u258A Left three quarters block\nU+258B \u258B Left five eighths block\nU+258C \u258C Left half block\nU+258D \u258D Left three eighths block\nU+258E \u258E Left one quarter block\nU+258F \u258F Left one eighth block\nU+2590 \u2590 Right half block\nU+2591 \u2591 Light shade\nU+2592 \u2592 Medium shade\nU+2593 \u2593 Dark shade\nU+2594 \u2594 Upper one eighth block\nU+2595 \u2595 Right one eighth block\nU+2596 \u2596 Quadrant lower left\nU+2597 \u2597 Quadrant lower right\nU+2598 \u2598 Quadrant upper left\nU+2599 \u2599 Quadrant upper left and lower left and lower right\nU+259A \u259A Quadrant upper left and lower right\nU+259B \u259B Quadrant upper left and upper right and lower left\nU+259C \u259C Quadrant upper left and upper right and lower right\nU+259D \u259D Quadrant upper right\nU+259E \u259E Quadrant upper right and lower left\nU+259F \u259F Quadrant upper right and lower left and lower right\nGeometric Shapes\nMain articles: Geometric Shapes (Unicode block) and Geometric Shapes Extended (Unicode block)\n[hide]Code Glyph Description\nU+25A0 \u25A0 Black square\nU+25A1 \u25A1 White square\nU+25A2 \u25A2 White square with rounded corners\nU+25A3 \u25A3 White square containing small black square\nU+25A4 \u25A4 Square with horizontal fill\nU+25A5 \u25A5 Square with vertical fill\nU+25A6 \u25A6 Square with orthogonal crosshatch fill\nU+25A7 \u25A7 Square with upper left to lower right fill\nU+25A8 \u25A8 Square with upper right to lower left fill\nU+25A9 \u25A9 Square with diagonal crosshatch fill\nU+25AA \u25AA Black small square\nU+25AB \u25AB White small square\nU+25AC \u25AC Black rectangle\nU+25AD \u25AD White rectangle\nU+25AE \u25AE Black vertical rectangle\nU+25AF \u25AF White vertical rectangle\nU+25B0 \u25B0 Black parallelogram\nU+25B1 \u25B1 White parallelogram\nU+25B2 \u25B2 Black up-pointing triangle\nU+25B3 \u25B3 White up-pointing triangle\nU+25B4 \u25B4 Black up-pointing small triangle\nU+25B5 \u25B5 White up-pointing small triangle\nU+25B6 \u25B6 Black right-pointing triangle\nU+25B7 \u25B7 White right-pointing triangle\nU+25B8 \u25B8 Black right-pointing small triangle\nU+25B9 \u25B9 White right-pointing small triangle\nU+25BA \u25BA Black right-pointing pointer\nU+25BB \u25BB White right-pointing pointer\nU+25BC \u25BC Black down-pointing triangle\nU+25BD \u25BD White down-pointing triangle\nU+25BE \u25BE Black down-pointing small triangle\nU+25BF \u25BF White down-pointing small triangle\nU+25C0 \u25C0 Black left-pointing triangle\nU+25C1 \u25C1 White left-pointing triangle\nU+25C2 \u25C2 Black left-pointing small triangle\nU+25C3 \u25C3 White left-pointing small triangle\nU+25C4 \u25C4 Black left-pointing pointer\nU+25C5 \u25C5 White left-pointing pointer\nU+25C6 \u25C6 Black diamond\nU+25C7 \u25C7 White diamond\nU+25C8 \u25C8 White diamond containing small black diamond\nU+25C9 \u25C9 Fisheye\nU+25CA \u25CA Lozenge\nU+25CB \u25CB White circle\nU+25CC \u25CC Dotted circle\nU+25CD \u25CD Circle with vertical fill\nU+25CE \u25CE Bullseye\nU+25CF \u25CF Black circle\nU+25D0 \u25D0 Circle with left half black\nU+25D1 \u25D1 Circle with right half black\nU+25D2 \u25D2 Circle with lower half black\nU+25D3 \u25D3 Circle with upper half black\nU+25D4 \u25D4 Circle with upper right quadrant black\nU+25D5 \u25D5 Circle with all but upper left quadrant black\nU+25D6 \u25D6 Left half circle black\nU+25D7 \u25D7 Right half black circle\nU+25D8 \u25D8 Inverse bullet\nU+25D9 \u25D9 Inverse white circle\nU+25DA \u25DA Upper half inverse white circle\nU+25DB \u25DB Lower half inverse white circle\nU+25DC \u25DC Upper left quadrant circular arc\nU+25DD \u25DD Upper right quadrant circular arc\nU+25DE \u25DE Lower right quadrant circular arc\nU+25DF \u25DF Lower left quadrant circular arc\nU+25E0 \u25E0 Upper half circle\nU+25E1 \u25E1 Lower half circle\nU+25E2 \u25E2 Black lower right triangle\nU+25E3 \u25E3 Black lower left triangle\nU+25E4 \u25E4 Black upper left triangle\nU+25E5 \u25E5 Black upper right triangle\nU+25E6 \u25E6 White bullet\nU+25E7 \u25E7 Square with left half black\nU+25E8 \u25E8 Square with right half black\nU+25E9 \u25E9 Square with upper left diagonal half black\nU+25EA \u25EA Square with lower right diagonal half black\nU+25EB \u25EB White square with vertical bisecting line\nU+25EC \u25EC White up-pointing triangle with dot\nU+25ED \u25ED Up-pointing triangle with left half black\nU+25EE \u25EE Up-pointing triangle with right half black\nU+25EF \u25EF Large circle\nU+25F0 \u25F0 White square with upper left quadrant\nU+25F1 \u25F1 White square with lower left quadrant\nU+25F2 \u25F2 White square with lower right quadrant\nU+25F3 \u25F3 White square with upper right quadrant\nU+25F4 \u25F4 White circle with upper left quadrant\nU+25F5 \u25F5 White circle with lower left quadrant\nU+25F6 \u25F6 White circle with lower right quadrant\nU+25F7 \u25F7 White circle with upper right quadrant\nU+25F8 \u25F8 Upper left triangle\nU+25F9 \u25F9 Upper right triangle\nU+25FA \u25FA Lower-left triangle\nU+25FB \u25FB White medium square\nU+25FC \u25FC Black medium square\nU+25FD \u25FD White medium small square\nU+25FE \u25FE Black medium small square\nU+25FF \u25FF Lower right triangle\n\n\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are \"extended regex format\" requiring the\n * `XRegExp` library. When this `%option` has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n"); + var out = "\n/* parser generated by jison ".concat(version$2, " */\n\n/*\n * Returns a Parser object of the following structure:\n *\n * Parser: {\n * yy: {} The so-called \"shared state\" or rather the *source* of it;\n * the real \"shared state\" `yy` passed around to\n * the rule actions, etc. is a derivative/copy of this one,\n * not a direct reference!\n * }\n *\n * Parser.prototype: {\n * yy: {},\n * EOF: 1,\n * TERROR: 2,\n *\n * trace: function(errorMessage, ...),\n *\n * JisonParserError: function(msg, hash),\n *\n * quoteName: function(name),\n * Helper function which can be overridden by user code later on: put suitable\n * quotes around literal IDs in a description string.\n *\n * originalQuoteName: function(name),\n * The basic quoteName handler provided by JISON.\n * `cleanupAfterParse()` will clean up and reset `quoteName()` to reference this function\n * at the end of the `parse()`.\n *\n * describeSymbol: function(symbol),\n * Return a more-or-less human-readable description of the given symbol, when\n * available, or the symbol itself, serving as its own 'description' for lack\n * of something better to serve up.\n *\n * Return NULL when the symbol is unknown to the parser.\n *\n * symbols_: {associative list: name ==> number},\n * terminals_: {associative list: number ==> name},\n * nonterminals: {associative list: rule-name ==> {associative list: number ==> rule-alt}},\n * terminal_descriptions_: (if there are any) {associative list: number ==> description},\n * productions_: [...],\n *\n * performAction: function parser__performAction(yytext, yyleng, yylineno, yyloc, yystate, yysp, yyvstack, yylstack, yystack, yysstack),\n *\n * The function parameters and `this` have the following value/meaning:\n * - `this` : reference to the `yyval` internal object, which has members (`$` and `_$`)\n * to store/reference the rule value `$$` and location info `@$`.\n *\n * One important thing to note about `this` a.k.a. `yyval`: every *reduce* action gets\n * to see the same object via the `this` reference, i.e. if you wish to carry custom\n * data from one reduce action through to the next within a single parse run, then you\n * may get nasty and use `yyval` a.k.a. `this` for storing you own semi-permanent data.\n *\n * `this.yy` is a direct reference to the `yy` shared state object.\n *\n * `%parse-param`-specified additional `parse()` arguments have been added to this `yy`\n * object at `parse()` start and are therefore available to the action code via the\n * same named `yy.xxxx` attributes (where `xxxx` represents a identifier name from\n * the %parse-param` list.\n *\n * - `yytext` : reference to the lexer value which belongs to the last lexer token used\n * to match this rule. This is *not* the look-ahead token, but the last token\n * that's actually part of this rule.\n *\n * Formulated another way, `yytext` is the value of the token immediately preceeding\n * the current look-ahead token.\n * Caveats apply for rules which don't require look-ahead, such as epsilon rules.\n *\n * - `yyleng` : ditto as `yytext`, only now for the lexer.yyleng value.\n *\n * - `yylineno`: ditto as `yytext`, only now for the lexer.yylineno value.\n *\n * - `yyloc` : ditto as `yytext`, only now for the lexer.yylloc lexer token location info.\n *\n * WARNING: since jison 0.4.18-186 this entry may be NULL/UNDEFINED instead\n * of an empty object when no suitable location info can be provided.\n *\n * - `yystate` : the current parser state number, used internally for dispatching and\n * executing the action code chunk matching the rule currently being reduced.\n *\n * - `yysp` : the current state stack position (a.k.a. 'stack pointer')\n *\n * This one comes in handy when you are going to do advanced things to the parser\n * stacks, all of which are accessible from your action code (see the next entries below).\n *\n * Also note that you can access this and other stack index values using the new double-hash\n * syntax, i.e. `##$ === ##0 === yysp`, while `##1` is the stack index for all things\n * related to the first rule term, just like you have `$1`, `@1` and `#1`.\n * This is made available to write very advanced grammar action rules, e.g. when you want\n * to investigate the parse state stack in your action code, which would, for example,\n * be relevant when you wish to implement error diagnostics and reporting schemes similar\n * to the work described here:\n *\n * + Pottier, F., 2016. Reachability and error diagnosis in LR(1) automata.\n * In Journ\xE9es Francophones des Languages Applicatifs.\n *\n * + Jeffery, C.L., 2003. Generating LR syntax error messages from examples.\n * ACM Transactions on Programming Languages and Systems (TOPLAS), 25(5), pp.631\u2013640.\n *\n * - `yyrulelength`: the current rule's term count, i.e. the number of entries occupied on the stack.\n *\n * This one comes in handy when you are going to do advanced things to the parser\n * stacks, all of which are accessible from your action code (see the next entries below).\n *\n * - `yyvstack`: reference to the parser value stack. Also accessed via the `$1` etc.\n * constructs.\n *\n * - `yylstack`: reference to the parser token location stack. Also accessed via\n * the `@1` etc. constructs.\n *\n * WARNING: since jison 0.4.18-186 this array MAY contain slots which are\n * UNDEFINED rather than an empty (location) object, when the lexer/parser\n * action code did not provide a suitable location info object when such a\n * slot was filled!\n *\n * - `yystack` : reference to the parser token id stack. Also accessed via the\n * `#1` etc. constructs.\n *\n * Note: this is a bit of a **white lie** as we can statically decode any `#n` reference to\n * its numeric token id value, hence that code wouldn't need the `yystack` but *you* might\n * want access this array for your own purposes, such as error analysis as mentioned above!\n *\n * Note that this stack stores the current stack of *tokens*, that is the sequence of\n * already parsed=reduced *nonterminals* (tokens representing rules) and *terminals*\n * (lexer tokens *shifted* onto the stack until the rule they belong to is found and\n * *reduced*.\n *\n * - `yysstack`: reference to the parser state stack. This one carries the internal parser\n * *states* such as the one in `yystate`, which are used to represent\n * the parser state machine in the *parse table*. *Very* *internal* stuff,\n * what can I say? If you access this one, you're clearly doing wicked things\n *\n * - `...` : the extra arguments you specified in the `%parse-param` statement in your\n * grammar definition file.\n *\n * table: [...],\n * State transition table\n * ----------------------\n *\n * index levels are:\n * - `state` --> hash table\n * - `symbol` --> action (number or array)\n *\n * If the `action` is an array, these are the elements' meaning:\n * - index [0]: 1 = shift, 2 = reduce, 3 = accept\n * - index [1]: GOTO `state`\n *\n * If the `action` is a number, it is the GOTO `state`\n *\n * defaultActions: {...},\n *\n * parseError: function(str, hash, ExceptionClass),\n * yyError: function(str, ...),\n * yyRecovering: function(),\n * yyErrOk: function(),\n * yyClearIn: function(),\n *\n * constructParseErrorInfo: function(error_message, exception_object, expected_token_set, is_recoverable),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * Produces a new errorInfo 'hash object' which can be passed into `parseError()`.\n * See it's use in this parser kernel in many places; example usage:\n *\n * let infoObj = parser.constructParseErrorInfo('fail!', null,\n * parser.collect_expected_token_set(state), true);\n * let retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError);\n *\n * originalParseError: function(str, hash, ExceptionClass),\n * The basic `parseError` handler provided by JISON.\n * `cleanupAfterParse()` will clean up and reset `parseError()` to reference this function\n * at the end of the `parse()`.\n *\n * options: { ... parser %options ... },\n *\n * parse: function(input[, args...]),\n * Parse the given `input` and return the parsed value (or `true` when none was provided by\n * the root action, in which case the parser is acting as a *matcher*).\n * You MAY use the additional `args...` parameters as per `%parse-param` spec of this grammar:\n * these extra `args...` are added verbatim to the `yy` object reference as member variables.\n *\n * WARNING:\n * Parser's additional `args...` parameters (via `%parse-param`) MAY conflict with\n * any attributes already added to `yy` by the jison run-time;\n * when such a collision is detected an exception is thrown to prevent the generated run-time\n * from silently accepting this confusing and potentially hazardous situation!\n *\n * The lexer MAY add its own set of additional parameters (via the `%parse-param` line in\n * the lexer section of the grammar spec): these will be inserted in the `yy` shared state\n * object and any collision with those will be reported by the lexer via a thrown exception.\n *\n * cleanupAfterParse: function(resultValue, invoke_post_methods, do_not_nuke_errorinfos),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * This helper API is invoked at the end of the `parse()` call, unless an exception was thrown\n * and `%options no-try-catch` has been defined for this grammar: in that case this helper MAY\n * be invoked by calling user code to ensure the `post_parse` callbacks are invoked and\n * the internal parser gets properly garbage collected under these particular circumstances.\n *\n * yyMergeLocationInfo: function(first_index, last_index, first_yylloc, last_yylloc, dont_look_back),\n * Helper function **which will be set up during the first invocation of the `parse()` method**.\n * This helper API can be invoked to calculate a spanning `yylloc` location info object.\n *\n * Note: %epsilon rules MAY specify no `first_index` and `first_yylloc`, in which case\n * this function will attempt to obtain a suitable location marker by inspecting the location stack\n * backwards.\n *\n * For more info see the documentation comment further below, immediately above this function's\n * implementation.\n *\n * lexer: {\n * yy: {...}, A reference to the so-called \"shared state\" `yy` once\n * received via a call to the `.setInput(input, yy)` lexer API.\n * EOF: 1,\n * ERROR: 2,\n * JisonLexerError: function(msg, hash),\n * parseError: function(str, hash, ExceptionClass),\n * setInput: function(input, [yy]),\n * input: function(),\n * unput: function(str),\n * more: function(),\n * reject: function(),\n * less: function(n),\n * pastInput: function(n),\n * upcomingInput: function(n),\n * showPosition: function(),\n * test_match: function(regex_match_array, rule_index, ...),\n * next: function(...),\n * lex: function(...),\n * begin: function(condition),\n * pushState: function(condition),\n * popState: function(),\n * topState: function(),\n * _currentRules: function(),\n * stateStackSize: function(),\n * cleanupAfterLex: function()\n *\n * options: { ... lexer %options ... },\n *\n * performAction: function(yy, yy_, $avoiding_name_collisions, YY_START, ...),\n * rules: [...],\n * conditions: {associative list: name ==> set},\n * }\n * }\n *\n *\n * token location info (@$, _$, etc.): {\n * first_line: n,\n * last_line: n,\n * first_column: n,\n * last_column: n,\n * range: [start_number, end_number]\n * (where the numbers are indexes into the input string, zero-based)\n * }\n *\n * ---\n *\n * The `parseError` function receives a 'hash' object with these members for lexer and\n * parser errors:\n *\n * {\n * text: (matched text)\n * token: (the produced terminal token, if any)\n * token_id: (the produced terminal token numeric ID, if any)\n * line: (yylineno)\n * loc: (yylloc)\n * }\n *\n * parser (grammar) errors will also provide these additional members:\n *\n * {\n * expected: (array describing the set of expected tokens;\n * may be UNDEFINED when we cannot easily produce such a set)\n * state: (integer (or array when the table includes grammar collisions);\n * represents the current internal state of the parser kernel.\n * can, for example, be used to pass to the `collect_expected_token_set()`\n * API to obtain the expected token set)\n * action: (integer; represents the current internal action which will be executed)\n * new_state: (integer; represents the next/planned internal state, once the current\n * action has executed)\n * recoverable: (boolean: TRUE when the parser MAY have an error recovery rule\n * available for this particular error)\n * state_stack: (array: the current parser LALR/LR internal state stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * value_stack: (array: the current parser LALR/LR internal `$$` value stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * location_stack: (array: the current parser LALR/LR internal location stack; this can be used,\n * for instance, for advanced error analysis and reporting)\n * yy: (object: the current parser internal \"shared state\" `yy`\n * as is also available in the rule actions; this can be used,\n * for instance, for advanced error analysis and reporting)\n * lexer: (reference to the current lexer instance used by the parser)\n * parser: (reference to the current parser instance)\n * }\n *\n * while `this` will reference the current parser instance.\n *\n * When `parseError` is invoked by the lexer, `this` will still reference the related *parser*\n * instance, while these additional `hash` fields will also be provided:\n *\n * {\n * lexer: (reference to the current lexer instance which reported the error)\n * }\n *\n * When `parseError` is invoked by the parser due to a **JavaScript exception** being fired\n * from either the parser or lexer, `this` will still reference the related *parser*\n * instance, while these additional `hash` fields will also be provided:\n *\n * {\n * exception: (reference to the exception thrown)\n * }\n *\n * Please do note that in the latter situation, the `expected` field will be omitted as\n * this type of failure is assumed not to be due to *parse errors* but rather due to user\n * action code in either parser or lexer failing unexpectedly.\n *\n * ---\n *\n * You can specify parser options by setting / modifying the `.yy` object of your Parser instance.\n * These options are available:\n *\n * ### options which are global for all parser instances\n *\n * Parser.pre_parse: function(yy)\n * optional: you can specify a pre_parse() function in the chunk following\n * the grammar, i.e. after the last `%%`.\n * Parser.post_parse: function(yy, retval, parseInfo) { return retval; }\n * optional: you can specify a post_parse() function in the chunk following\n * the grammar, i.e. after the last `%%`. When it does not return any value,\n * the parser will return the original `retval`.\n *\n * ### options which can be set up per parser instance\n *\n * yy: {\n * pre_parse: function(yy)\n * optional: is invoked before the parse cycle starts (and before the first\n * invocation of `lex()`) but immediately after the invocation of\n * `parser.pre_parse()`).\n * post_parse: function(yy, retval, parseInfo) { return retval; }\n * optional: is invoked when the parse terminates due to success ('accept')\n * or failure (even when exceptions are thrown).\n * `retval` contains the return value to be produced by `Parser.parse()`;\n * this function can override the return value by returning another.\n * When it does not return any value, the parser will return the original\n * `retval`.\n * This function is invoked immediately before `parser.post_parse()`.\n *\n * parseError: function(str, hash, ExceptionClass)\n * optional: overrides the default `parseError` function.\n * quoteName: function(name),\n * optional: overrides the default `quoteName` function.\n * }\n *\n * parser.lexer.options: {\n * pre_lex: function()\n * optional: is invoked before the lexer is invoked to produce another token.\n * `this` refers to the Lexer object.\n * post_lex: function(token) { return token; }\n * optional: is invoked when the lexer has produced a token `token`;\n * this function can override the returned token value by returning another.\n * When it does not return any (truthy) value, the lexer will return\n * the original `token`.\n * `this` refers to the Lexer object.\n *\n * ranges: boolean\n * optional: `true` ==> token location info will include a .range[] member.\n * flex: boolean\n * optional: `true` ==> flex-like lexing behaviour where the rules are tested\n * exhaustively to find the longest match.\n * backtrack_lexer: boolean\n * optional: `true` ==> lexer regexes are tested in order and for invoked;\n * the lexer terminates the scan when a token is returned by the action code.\n * xregexp: boolean\n * optional: `true` ==> lexer rule regexes are \"extended regex format\" requiring the\n * `XRegExp` library. When this `%option` has not been specified at compile time, all lexer\n * rule regexes have been written as standard JavaScript RegExp expressions.\n * }\n */\n"); return out; }; @@ -26325,7 +26639,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi generatorMixin.generateAMDModule = function generateAMDModule(opt) { opt = this.__prepareOptions(opt); var module = this.generateModule_(); - var out = [this.generateGenericHeaderComment(), '', 'define(function (require) {', module.initCode, module.commonCode, '', 'var parser = ' + module.moduleCode, module.modulePostlude]; + var out = [this.generateGenericHeaderComment(), '', 'define(function (require) {', module.initCode, module.commonCode, '', 'let parser = ' + module.moduleCode, module.modulePostlude]; if (this.lexer && this.lexer.generateModule) { var lexSrc = this.lexer.generateModule(); @@ -26344,7 +26658,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi lrGeneratorMixin.generateESModule = function generateESModule(opt) { opt = this.__prepareOptions(opt); var module = this.generateModule_(); - var out = [this.generateGenericHeaderComment(), '', module.initCode, module.commonCode, '', 'var parser = ' + module.moduleCode, module.modulePostlude]; + var out = [this.generateGenericHeaderComment(), '', module.initCode, module.commonCode, '', 'let parser = ' + module.moduleCode, module.modulePostlude]; if (this.lexer && this.lexer.generateModule) { var lexSrc = this.lexer.generateModule(); @@ -26360,12 +26674,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(_templateObject156(), moduleImportsAsCode, moduleNameAsCode.trim())); + out.push(rmCommonWS$5(_templateObject157(), moduleImportsAsCode, moduleNameAsCode.trim())); exportMain = 'main: yyExecMain,'; - invokeMain = rmCommonWS$5(_templateObject157()); + invokeMain = rmCommonWS$5(_templateObject158()); } - out.push(rmCommonWS$5(_templateObject158(), invokeMain, exportMain)); + out.push(rmCommonWS$5(_templateObject159(), invokeMain, exportMain)); var src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; @@ -26379,10 +26693,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(_templateObject159(), moduleImportsAsCode, moduleNameAsCode.trim()); + main = rmCommonWS$5(_templateObject160(), moduleImportsAsCode, moduleNameAsCode.trim()); } - var out = this.generateModule(opt) + rmCommonWS$5(_templateObject160(), moduleName, moduleName, moduleName, moduleName, main); + var out = this.generateModule(opt) + rmCommonWS$5(_templateObject161(), moduleName, moduleName, moduleName, moduleName, main); opt.exportSourceCode.all = out; return out; }; @@ -26397,13 +26711,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var subModuleName = namespaces.shift(); if (subModuleName != null) { - var moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; + var _moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; if (namespaces.length > 0) { - return 'var ' + subModuleName + ';\n' + '(function (' + subModuleName + ') {\n' + _generateNamespace(namespaces, subModuleName, callback) + '\n})(' + subModuleName + (previousNamespace == null ? '' : ' = ' + moduleName) + ' || (' + moduleName + ' = {}));\n'; + return '(function (' + subModuleName + ') {\n' + _generateNamespace(namespaces, subModuleName, callback) + '\n})(' + subModuleName + (previousNamespace == null ? '' : ' = ' + _moduleName) + ' || (' + _moduleName + ' = {}));\n'; } - return callback(moduleName); + return callback(_moduleName); } return ''; @@ -26412,7 +26726,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var sourceCodeDef = self.generateModuleExpr(); out += "\n ".concat(sourceCodeDef.init, "\n "); out += _generateNamespace(moduleName.split('.'), null, function _generateNamespace_cb(moduleName) { - var name = moduleName.match(/\./) ? moduleName : 'var ' + moduleName; + var name = moduleName.match(/\./) ? moduleName : 'let ' + moduleName; return "\n ".concat(name, " = ").concat(sourceCodeDef.src, "\n "); }); opt.exportSourceCode.all = out; @@ -26420,12 +26734,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }; generatorMixin.generateModuleExpr = function generateModuleExpr() { - var out; - var opt = this.__prepareOptions(); var module = this.generateModule_(); - out = ['(function () {', module.commonCode, '', 'var parser = ' + module.moduleCode, module.modulePostlude]; + var out = ['(function () {', module.commonCode, '', 'let parser = ' + module.moduleCode, module.modulePostlude]; if (this.lexer && this.lexer.generateModule) { var lexSrc = this.lexer.generateModule(); @@ -26474,7 +26786,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // if (typeof lexer.yyleng === 'undefined') { // lexer.yyleng = 0; // } - // var yyleng; + // let yyleng; // ... parseFn = parseFn.replace(/, yyleng\b/g, '').replace(/^.*?\bvar yyleng\b.*?$/gm, '').replace(/\s+if\b.*?\.yyleng\b.*?\{[^}]+\}/g, '\n').replace(/^.*?\byyleng = .+$/gm, '').replace(/^.*?\byyleng\b.*?=.*?\byyleng\b.*?$/gm, ''); @@ -26485,7 +26797,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // so we can kill the local var and its usage at least: actionFn = actionFn.replace(/, yylineno\b/g, ''); // remove: // - // var yylineno; + // let yylineno; // ... parseFn = parseFn.replace(/\bvar yylineno\b.*?$/gm, '').replace(/, yylineno\b/g, '').replace(/^.*?\byylineno\b.*?=.*?\byylineno\b.*?$/gm, ''); @@ -26520,7 +26832,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!info.actionsUseLocationTracking) { actionFn = actionFn.replace(/\byyloc, (.*?), yylstack\b/g, '$1'); // remove: // - // var yyloc = lexer.yylloc; + // let yyloc = lexer.yylloc; // lstack[sp] = yyloc; // ... // lstack[sp] = copy_yylloc(lexer.yylloc); @@ -26545,11 +26857,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // } // // and - // + // // if (sp >= 0 && typeof vstack[sp] !== 'undefined') { // retval = vstack[sp]; // } - // + // // but keep the yyval declaration as either location tracking MAY // still be employed by the grammar OR the grammar uses advanced // code which uses `yyval` as a run-time store which carries data @@ -26588,12 +26900,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (info.actionsAreAllDefault) { // remove // - // var yyval = { + // let yyval = { // $: true, // _$: undefined, // yy: sharedState_yy // }; - parseFn = parseFn.replace(/\s+var yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); + parseFn = parseFn.replace(/\s+let yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); } } @@ -26607,10 +26919,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // option set or by invoking JISON with the debug flag `-t`. // remove: // - // var yydebug = false; + // let yydebug = false; // ... and delete yydebug function definition ... // ... // if (yydebug) yydebug(...); + // ... + // if (yydebug) { + // yydebug(...); + // } // // and // @@ -26618,9 +26934,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // if (sharedState_yy.yydebug === false) { // yydebug = undefined; // } - parseFn = parseFn.replace(/\s+var yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') // strip multi-line `if (debug) yydebug(..., {...});` statements + parseFn = parseFn.replace(/\s+let yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') // strip multi-line `if (debug) { yydebug(..., {...}); }` statements // also strip simple yet possibly multi-line `if (debug) yydebug('...');` statements - .replace(/\n\s+if\s+\(yydebug\)\s+yydebug\([^]+?['}]\);[^\r\n]*?/g, '\n\n\n\n\n\n\n\n\n') // strip single-line `yydebug(...);` statements + .replace(/\n\s+if\s+\(yydebug\)\s+\{[\r\n]+\s+yydebug\([^]+?}\);[\s\r\n]+}\s*/g, '\n\n\n\n\n\n\n\n\n').replace(/\n\s+if\s+\(yydebug\)\s+yydebug\([^]+?['}]\);[^\r\n]*?/g, '\n\n\n\n\n\n\n\n\n') // strip single-line `yydebug(...);` statements .replace(/^.*?\byydebug\b[^;]+?\);[^\r\n]*?$/gm, '') // strip `if (sharedState_yy.yydebug) {...}` chunk .replace(/\n\s+\/\/\s*disable\s*debugging.*?[\r\n]+\s+if\s+\(sharedState_yy\.yydebug[^]+?\}/g, '\n\n\n\n'); } @@ -26696,8 +27012,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi * ... __reentrant_call_depth ... */ parseFn = parseFn.replace(/\s+try \{([\s\r\n]+this\.__reentrant_call_depth[\s\S]+?)\} catch \(ex\) \{[\s\S]+?\} finally \{([^]+?)\}\s+\/\/\s+\/finally/, function replace_noTryCatch(m, p1, p2) { - p1 = p1.replace(/^ /mg, ' '); - p2 = p2.replace(/^ /mg, ' '); + p1 = p1.replace(/^ {8}/mg, ' '); + p2 = p2.replace(/^ {8}/mg, ' '); return '\n' + p1 + '\n // ... AND FINALLY ...\n' + p2; }).replace(/^[^\n]+\b__reentrant_call_depth\b[^\n]+$/gm, '\n'); } @@ -26754,11 +27070,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!arglist || arglist.length === 0) { parseFn = parseFn.replace(/, parseParams\b/g, ''); parseFn = parseFn.replace(/\bparseParams\b/g, ''); - parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers:\s+parseParamsAsMembers\b/g, ''); + parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers\b/g, ''); } else { parseFn = parseFn.replace(/, parseParams\b/g, ', ' + arglist.join(', ')); parseFn = parseFn.replace(/\bparseParams\b/g, arglist.join(', ')); - parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers:\s+parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { + parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { var s = ','; // determine longest name of the bunch (for formatting the generated code) var max_k_len = 0; @@ -26770,9 +27086,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 i = 0, len = arglist.length; i < len; i++) { - var k = arglist[i]; - s += '\n' + ws + k + ': ' + k + (i < len - 1 ? ',' + wsi2.substr(0, max_k_len - k.length - 1) : wsi2.substr(0, max_k_len - k.length)) + ' // parseParams::' + k; + 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; } return s; @@ -26809,11 +27125,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // // if (wantTokenStack) { // try { - // var ast = esprima.parse(parseFn); - // var stackAst = esprima.parse(String(tokenStackLex)).body[0]; + // let ast = esprima.parse(parseFn); + // let stackAst = esprima.parse(String(tokenStackLex)).body[0]; // stackAst.id.name = 'lex'; // - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); // // labeled[0].body = stackAst; // @@ -26823,7 +27139,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // } // } else { // // remove the line: - // // var tstack = []; // token stack + // // let tstack = []; // token stack // parseFn = parseFn.replace(/tstack = .*$/m, ''); // return parseFn; // } @@ -26833,11 +27149,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (wantTokenStack) { // And rename the `tokenStackLex` function to become the new `lex`: return parseFn.replace(/\btokenStackLex\b/g, 'lex'); - } else { - // Also nuke the support declaration statement: - // var tstack = []; - return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); - } + } // Also nuke the support declaration statement: + // let tstack = []; + + + return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); } // returns parse function with/without error recovery code @@ -26845,8 +27161,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var parseFn = fn; // We don't use the Esprima+Escodegen toolchain as those loose the code comments easily; // instead we just chop the code using labels as sentinels for our chopping-it-up regexes: // try { - // var ast = esprima.parse(parseFn); - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("' + + // let ast = esprima.parse(parseFn); + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("' + // (!hasErrorRecovery ? '_handle_error_with_recovery' : '_handle_error_no_recovery') + // '"))', ast); // Jison.print('labeled: ', labeled); @@ -26862,7 +27178,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (!hasErrorRecovery) { // Also nuke the support declaration statement: - // var recovering = 0; + // let recovering = 0; // and the recovery support statements: // if (recovering > 0) { // recovering--; @@ -26870,15 +27186,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // and these yydebug particles: // , recovering: recovering // ASSERT(recovering === 0); - parseFn = parseFn.replace(/^\s*var recovering.*$/gm, '').replace(/, recovering: recovering/g, '').replace(/^.*?recovering =.*$/gm, '').replace(/^\s+recovering[,]?\s*$/gm, '').replace(/[ \t]*if \(recovering[^\)]+\) \{[^\0]+?\}\n/g, '\n\n\n\n\n') // And nuke the preErrorSymbol code as it is unused when there's no error recovery + parseFn = parseFn.replace(/^\s*let recovering.*$/gm, '').replace(/, recovering: recovering/g, '').replace(/^.*?recovering =.*$/gm, '').replace(/^\s+recovering[,]?\s*$/gm, '').replace(/[ \t]*if \(recovering[^\)]+\) \{[^\0]+?\}\n/g, '\n\n\n\n\n') // And nuke the preErrorSymbol code as it is unused when there's no error recovery // if (!preErrorSymbol) { // ... keep this chunk ... // } else { // ... KILL this chunk ... // } - .replace(/\s+if[^a-z]+preErrorSymbol.*?\{\s*\/\/[^\n]+([\s\S]+?)\} else \{[\s\S]+?\}\n\s+\}\n/g, '\n$1\n\n\n\n').replace(/^\s+(?:var )?preErrorSymbol = .*$/gm, '').replace(/^.*?\bpreErrorSymbol =.*$/gm, '') // And nuke the support declaration statement: - // var lastEofErrorStateDepth = 0; - .replace(/^\s*var lastEofErrorStateDepth.*$/gm, ''); + .replace(/\s+if[^a-z]+preErrorSymbol.*?\{\s*\/\/[^\n]+([\s\S]+?)\} else \{[\s\S]+?\}\n\s+\}\n/g, '\n$1\n\n\n\n').replace(/^\s+(?:let )?preErrorSymbol = .*$/gm, '').replace(/^.*?\bpreErrorSymbol =.*$/gm, '') // And nuke the support declaration statement: + // let lastEofErrorStateDepth = 0; + .replace(/^\s*let lastEofErrorStateDepth.*$/gm, ''); } return parseFn; @@ -26900,8 +27216,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi exportDest.parseTable = this.table; exportDest.defaultParseActions = this.defaultActions; exportDest.parseProductions = this.productions_; - var exportSourceCode = this.options.exportSourceCode; - assert__default['default'](exportSourceCode); var tableCode; switch (this.options.compressTables | 0) { @@ -26936,10 +27250,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var a = Object.keys(tbl); a.sort(); var nt = {}; - var k; for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); + var k = a[i]; // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number // and we do not want `$eof`/`EOF` to show up in the symbol tables of generated parsers // as we use `$end` for that one! @@ -26956,11 +27269,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function produceTerminalTable(tbl) { var a = Object.keys(tbl); var nt = {}; - var k, v; for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; - v = tbl[k]; + var k = a[i]; + var v = tbl[k]; nt[v] = +k; // convert numeric key back to number type; all terminals have numeric keys } @@ -27103,11 +27415,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi reachable: production.reachable }; // Determine state for given production, if it's not a production that's listed as part of a state: - var chk, idx; var lst = prods.rules[nonterm]; - chk = rv.symbol + ' : ' + rv.handle; + var chk = rv.symbol + ' : ' + rv.handle; - for (idx in lst) { + for (var idx in lst) { idx = +idx; var p = lst[idx]; @@ -27126,8 +27437,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (base && base.rules) { var pr = base.rules[rv.base_symbol]; - for (idx in pr) { - var bprod = pr[idx]; + for (var _idx in pr) { + var bprod = pr[_idx]; if (bprod.symbol + ' : ' + bprod.handle === chk) { assert__default['default'](rv.base_state === -1); @@ -27209,9 +27520,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } var nt = tbl; - var sbn; - for (sbn in nt) { + for (var sbn in nt) { var orig_symbol = get_orig_symbol(sbn); var item = nt[sbn]; var firsts = item.first; @@ -27234,12 +27544,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } } - for (sbn in prods.first) { - prods.first[sbn] = get_orig_symbol_set(prods.first[sbn]); + for (var _sbn in prods.first) { + prods.first[_sbn] = get_orig_symbol_set(prods.first[_sbn]); } - for (sbn in prods.follows) { - prods.follows[sbn] = get_orig_symbol_set(prods.follows[sbn]); + for (var _sbn2 in prods.follows) { + prods.follows[_sbn2] = get_orig_symbol_set(prods.follows[_sbn2]); } if (this.newg) { @@ -27395,7 +27705,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi lrGeneratorMixin.generateErrorClass = function () { // --- START parser error class --- - var prelude = "\n// See also:\n// http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n// but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n// with userland code which might access the derived class in a 'classic' way.\nfunction JisonParserError(msg, hash) {\n \"use strict\";\n\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'JisonParserError'\n });\n\n if (msg == null) msg = '???';\n\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n var stacktrace;\n if (hash && hash.exception instanceof Error) {\n var ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty('captureStackTrace')) { // V8/Chrome engine\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(JisonParserError.prototype, Error.prototype);\n} else {\n JisonParserError.prototype = Object.create(Error.prototype);\n}\nJisonParserError.prototype.constructor = JisonParserError;\nJisonParserError.prototype.name = 'JisonParserError';\n"; // --- END parser error class --- + var prelude = "\n// See also:\n// http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508\n// but we keep the prototype.constructor and prototype.name assignment lines too for compatibility\n// with userland code which might access the derived class in a 'classic' way.\nfunction JisonParserError(msg, hash) {\n Object.defineProperty(this, 'name', {\n enumerable: false,\n writable: false,\n value: 'JisonParserError'\n });\n\n if (msg == null) msg = '???';\n\n Object.defineProperty(this, 'message', {\n enumerable: false,\n writable: true,\n value: msg\n });\n\n this.hash = hash;\n\n let stacktrace;\n if (hash && hash.exception instanceof Error) {\n let ex2 = hash.exception;\n this.message = ex2.message || msg;\n stacktrace = ex2.stack;\n }\n if (!stacktrace) {\n if (Error.hasOwnProperty('captureStackTrace')) { // V8/Chrome engine\n Error.captureStackTrace(this, this.constructor);\n } else {\n stacktrace = (new Error(msg)).stack;\n }\n }\n if (stacktrace) {\n Object.defineProperty(this, 'stack', {\n enumerable: false,\n writable: false,\n value: stacktrace\n });\n }\n}\n\nif (typeof Object.setPrototypeOf === 'function') {\n Object.setPrototypeOf(JisonParserError.prototype, Error.prototype);\n} else {\n JisonParserError.prototype = Object.create(Error.prototype);\n}\nJisonParserError.prototype.constructor = JisonParserError;\nJisonParserError.prototype.name = 'JisonParserError';\n"; // --- END parser error class --- return { commonCode: '', @@ -27422,7 +27732,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // e.g., x([1, 3, 4], [6, 7], { x: 1, y: 2 }) = { 1: [6, 7]; 3: [6, 7], 4: [6, 7], x: 1, y: 2 } - var compressor1ObjectCode = "\nfunction x(k, v, o) {\n o = o || {};\n for (var l = k.length; l--; ) {\n o[k[l]] = v;\n }\n return o;\n}\n"; // Generate code that represents the specified parser table + var compressor1ObjectCode = "\nfunction x(k, v, o) {\n o = o || {};\n for (let l = k.length; l--; ) {\n o[k[l]] = v;\n }\n return o;\n}\n"; // Generate code that represents the specified parser table lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productions) { var tableCode = JSON.stringify(table, null, 2); @@ -27435,21 +27745,18 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi tableCode = tableCode.replace(/\{[\s\r\n]*\d+:[^\}]+,[\s\r\n]*\d+:[^\}]+\}/g, function (object) { // Find the value that occurs with the highest number of keys - var value, - frequentValue, - key, - keys = {}, - keyCount, - maxKeyCount = 0, - keyValue, - keyValues = [], - keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; + var frequentValue; + var keys = {}; + var maxKeyCount = 0; + var keyValue; + var keyValues = []; + var keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; while (keyValue = keyValueMatcher.exec(object)) { // For each value, store the keys where that value occurs - key = keyValue[1]; - value = keyValue[2].trim(); - keyCount = 1; + var key = keyValue[1]; + var value = keyValue[2].trim(); + var keyCount = 1; if (!(value in keys)) { keys[value] = [key]; @@ -27467,10 +27774,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi if (maxKeyCount > 1) { // Collect all non-frequent values into a remainder object - for (value in keys) { - if (value !== frequentValue) { - for (var k = keys[value], i = 0, l = k.length; i < l; i++) { - keyValues.push(k[i] + ':' + value); + for (var _value5 in keys) { + if (_value5 !== frequentValue) { + for (var k = keys[_value5], i = 0, l = k.length; i < l; i++) { + keyValues.push(k[i] + ':' + _value5); } } } @@ -27519,7 +27826,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } if (frequentLists.length > 0) { - prelude.push('var u = [\n ' + frequentLists.join(',\n ') + '\n];'); + prelude.push('let u = [\n ' + frequentLists.join(',\n ') + '\n];'); prelude.push(''); } // Return the variable initialization code and the table code @@ -27566,11 +27873,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); function reportColumnsForCompression(def_arr) { - var i, key, len; var report = []; - len = 0; + var len = 0; - for (key in def_arr) { + for (var key in def_arr) { len = Math.max(len, def_arr[key].length); } @@ -27584,48 +27890,52 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } var track_prev4delta = {}; - var c, delta, val, delta_val; var line = []; line.push('║'); - for (c in def_arr) { - key = clip(c, col_width); - delta = clip('∆', col_delta_width); - line.push(key); + for (var _c3 in def_arr) { + var _key10 = clip(_c3, col_width); + + var delta = clip('∆', col_delta_width); + line.push(_key10); line.push('┊'); line.push(delta); line.push('║'); - track_prev4delta[c] = 10000000; + track_prev4delta[_c3] = 10000000; } report.push(line.join('')); - for (i = 0; i < len; i++) { + for (var i = 0; i < len; i++) { line = []; line.push('║'); - for (c in def_arr) { - var tbl = def_arr[c]; + for (var _c4 in def_arr) { + var val = void 0, + delta_val = void 0; + var tbl = def_arr[_c4]; if (tbl.length > i) { val = tbl[i] || 0; - delta_val = val - track_prev4delta[c]; // negative deltas are jumps: don't treat those as delta but as absolute value, sign-flipped: + delta_val = val - track_prev4delta[_c4]; // 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[c] = val; + track_prev4delta[_c4] = val; } else { val = '.'; delta_val = '.'; } - key = clip(val, col_width); - delta = clip(delta_val, col_delta_width); - line.push(key); + var _key11 = clip(val, col_width); + + var _delta = clip(delta_val, col_delta_width); + + line.push(_key11); line.push('┊'); - line.push(delta); + line.push(_delta); line.push('║'); } @@ -27658,9 +27968,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } var def_arr = { - 'len': len_col, - 'pop': pop_col, - 'rule': rule_col + len: len_col, + pop: pop_col, + rule: rule_col }; return def_arr; } // table is hash of 1/2-len arrays: @@ -27683,8 +27993,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } var def_arr = { - 'idx': idx_col, - 'goto': goto_col + idx: idx_col, + goto: goto_col }; return def_arr; } @@ -27702,16 +28012,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var mode_col = []; // column: symbol hash entry goto state value if array slot type: var goto_col = []; // // column: merged: state_col + goto_col: - // var next_col = []; + // let next_col = []; var row_count = table.length; for (var state = 0; state < row_count; state++) { var hashtable = table[state]; var count = 0; - var symbol; - for (symbol in hashtable) { + for (var symbol in hashtable) { symbol = +symbol; symbol_col.push(symbol); var slot = hashtable[symbol]; @@ -27745,12 +28054,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } var def_arr = { - 'len': len_col, - 'symbol': symbol_col, - 'type': type_col, - 'state': state_col, - 'mode': mode_col, - 'goto': goto_col //'next': next_col, + len: len_col, + symbol: symbol_col, + type: type_col, + state: state_col, + mode: mode_col, + goto: goto_col //'next': next_col, }; return def_arr; @@ -27760,11 +28069,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi function generateColumn(name, col) { var rv = []; - var i, j, len, l; - for (i = 0, len = col.length; i < len; i++) { + for (var i = 0, len = col.length; i < len; i++) { // try basic run-length encoding first: var v = col[i]; + var j = void 0; for (j = i + 1; j < len; j++) { if (col[j] !== v) { @@ -27794,6 +28103,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var upper_bound = i - 2; for (j = 0; j < upper_bound; j++) { + var l = void 0; + for (l = 0; col[j + l] === col[i + l]; l++) {// No need to check for: // if (j + l === i) break; // because we know how the c() helper function will regenerate @@ -27862,10 +28173,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi var tableDef = analyzeGotoTableForCompression(table); var defaultActionsDef = analyzeSetForCompression(defaultActions); var productionsDef = analyzeTableForCompression(productions); - var bp_code_container = "\n // helper: reconstruct the productions[] table\n function bp(s) {\n var rv = [];\n var p = s.pop;\n var r = s.rule;\n for (var i = 0, l = p.length; i < l; i++) {\n rv.push([\n p[i],\n r[i]\n ]);\n }\n return rv;\n }\n "; - var bda_code_container = "\n // helper: reconstruct the defaultActions[] table\n function bda(s) {\n var rv = {};\n var d = s.idx;\n var g = s.goto;\n for (var i = 0, l = d.length; i < l; i++) {\n var j = d[i];\n rv[j] = g[i];\n }\n return rv;\n }\n "; - var bt_code_container = "\n // helper: reconstruct the 'goto' table\n function bt(s) {\n var rv = [];\n var d = s.len;\n var y = s.symbol;\n var t = s.type;\n var a = s.state;\n var m = s.mode;\n var g = s.goto;\n for (var i = 0, l = d.length; i < l; i++) {\n var n = d[i];\n var q = {};\n for (var j = 0; j < n; j++) {\n var z = y.shift();\n switch (t.shift()) {\n case 2:\n q[z] = [\n m.shift(),\n g.shift()\n ];\n break;\n\n case 0:\n q[z] = a.shift();\n break;\n\n default:\n // type === 1: accept\n q[z] = [\n 3\n ];\n }\n }\n rv.push(q);\n }\n return rv;\n }\n "; - var c_s_u_code_container = "\n // helper: runlength encoding with increment step: code, length: step (default step = 0)\n // `this` references an array\n function s(c, l, a) {\n a = a || 0;\n for (var i = 0; i < l; i++) {\n this.push(c);\n c += a;\n }\n }\n\n // helper: duplicate sequence from *relative* offset and length.\n // `this` references an array\n function c(i, l) {\n i = this.length - i;\n for (l += i; i < l; i++) {\n this.push(this[i]);\n }\n }\n\n // helper: unpack an array using helpers and data, all passed in an array argument 'a'.\n function u(a) {\n var rv = [];\n for (var i = 0, l = a.length; i < l; i++) {\n var e = a[i];\n // Is this entry a helper function?\n if (typeof e === 'function') {\n i++;\n e.apply(rv, a[i]);\n } else {\n rv.push(e);\n }\n }\n return rv;\n }\n "; + var bp_code_container = "\n // helper: reconstruct the productions[] table\n function bp(s) {\n let rv = [];\n let p = s.pop;\n let r = s.rule;\n for (let i = 0, l = p.length; i < l; i++) {\n rv.push([\n p[i],\n r[i]\n ]);\n }\n return rv;\n }\n "; + var bda_code_container = "\n // helper: reconstruct the defaultActions[] table\n function bda(s) {\n let rv = {};\n let d = s.idx;\n let g = s.goto;\n for (let i = 0, l = d.length; i < l; i++) {\n let j = d[i];\n rv[j] = g[i];\n }\n return rv;\n }\n "; + var bt_code_container = "\n // helper: reconstruct the 'goto' table\n function bt(s) {\n let rv = [];\n let d = s.len;\n let y = s.symbol;\n let t = s.type;\n let a = s.state;\n let m = s.mode;\n let g = s.goto;\n for (let i = 0, l = d.length; i < l; i++) {\n let n = d[i];\n let q = {};\n for (let j = 0; j < n; j++) {\n let z = y.shift();\n switch (t.shift()) {\n case 2:\n q[z] = [\n m.shift(),\n g.shift()\n ];\n break;\n\n case 0:\n q[z] = a.shift();\n break;\n\n default:\n // type === 1: accept\n q[z] = [\n 3\n ];\n }\n }\n rv.push(q);\n }\n return rv;\n }\n "; + var c_s_u_code_container = "\n // helper: runlength encoding with increment step: code, length: step (default step = 0)\n // `this` references an array\n function s(c, l, a) {\n a = a || 0;\n for (let i = 0; i < l; i++) {\n this.push(c);\n c += a;\n }\n }\n\n // helper: duplicate sequence from *relative* offset and length.\n // `this` references an array\n function c(i, l) {\n i = this.length - i;\n for (l += i; i < l; i++) {\n this.push(this[i]);\n }\n }\n\n // helper: unpack an array using helpers and data, all passed in an array argument 'a'.\n function u(a) {\n let rv = [];\n for (let i = 0, l = a.length; i < l; i++) {\n let e = a[i];\n // Is this entry a helper function?\n if (typeof e === 'function') {\n i++;\n e.apply(rv, a[i]);\n } else {\n rv.push(e);\n }\n }\n return rv;\n }\n "; has_compressed_a_table = false; var tc = generateCompressedGotoTable(tableDef); var compressGotoTable = has_compressed_a_table; @@ -27893,13 +28204,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi productionsCode: productionsCode }; }; // --- START of commonJsMain chunk --- - // + // // default main method for generated commonjs modules - var commonJsMain = "\nfunction (args) {\n \"use strict\";\n\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 var source = fs.readFileSync(path.normalize(args[1]), 'utf8');\n var 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 var 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 = "\nvar fs = require('fs');\nvar path = require('path');\n"; // debug mixin for LR parser generators + var commonJsMainImports = "\nconst fs = require('fs');\nconst path = require('path');\n"; // debug mixin for LR parser generators function printAction(a, gen) { var s = a[0] === SHIFT ? 'shift token (then go to state ' + a[1] + ')' : a[0] === REDUCE ? 'reduce by rule: ' + gen.productions[a[1]] : a[0] === ACCEPT ? 'accept' : 'UNDEFINED ACTION: ' + a[0]; @@ -27945,8 +28256,8 @@ 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(_templateObject161(), sourceCodeDef.init, sourceCodeDef.src); - var p = code_exec$2(sourcecode, function generated_code_exec_wrapper_jison(sourcecode) { + var sourcecode = rmCommonWS$5(_templateObject162(), 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); var rv = eval(sourcecode); @@ -27954,7 +28265,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }, mkStdOptions$1(this.options, { dumpSourceCodeOnFailure: this.DEBUG, throwErrorOnCompileFailure: true - }), "parser"); + }), 'parser'); assert__default['default'](_typeof(p) === 'object'); assert__default['default'](typeof p.parse === 'function'); assert__default['default'](typeof p.parser === 'undefined'); @@ -28021,7 +28332,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi parser$4.warn = generator.warn; parser$4.error = generator.error; // --- START parser Error class chunk --- - var parseErrorSourceCode = "\nfunction parseError(str, hash, ExceptionClass) {\n \"use strict\";\n\n if (hash.recoverable) {\n if (typeof this.trace === 'function') {\n this.trace(str);\n }\n hash.destroy(); // destroy... well, *almost*!\n } else {\n if (typeof this.trace === 'function') {\n this.trace(str);\n }\n if (!ExceptionClass) {\n ExceptionClass = this.JisonParserError;\n }\n throw new ExceptionClass(str, hash);\n }\n}\n"; // --- END of parseErrorSourceCode chunk --- + var parseErrorSourceCode = "\nfunction parseError(str, hash, ExceptionClass) {\n if (hash.recoverable) {\n if (typeof this.trace === 'function') {\n this.trace(str);\n }\n hash.destroy(); // destroy... well, *almost*!\n } else {\n if (typeof this.trace === 'function') {\n this.trace(str);\n }\n if (!ExceptionClass) {\n ExceptionClass = this.JisonParserError;\n }\n throw new ExceptionClass(str, hash);\n }\n}\n"; // --- END of parseErrorSourceCode chunk --- chkBugger$3(parseErrorSourceCode); parser$4.parseError = lrGeneratorMixin.parseError = eval(parseErrorSourceCode + '\n\nparseError;'); @@ -28037,7 +28348,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // in the generated code: - var define_parser_APIs_1 = "\n TERROR: 2,\n EOF: 1,\n\n // internals: defined here so the object *structure* doesn't get modified by parse() et al,\n // thus helping JIT compilers like Chrome V8.\n originalQuoteName: null,\n originalParseError: null,\n cleanupAfterParse: null,\n constructParseErrorInfo: null,\n yyMergeLocationInfo: null,\n copy_yytext: null,\n copy_yylloc: null,\n\n __reentrant_call_depth: 0, // INTERNAL USE ONLY\n __error_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup\n __error_recovery_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup\n\n // APIs which will be set up depending on user action code analysis:\n //yyRecovering: 0,\n //yyErrOk: 0,\n //yyClearIn: 0,\n\n // Helper APIs\n // -----------\n\n // Helper function which can be overridden by user code later on: put suitable quotes around\n // literal IDs in a description string.\n quoteName: function parser_quoteName(id_str) {\n \"use strict\";\n\n return '\"' + id_str + '\"';\n },\n\n // Return the name of the given symbol (terminal or non-terminal) as a string, when available.\n //\n // Return NULL when the symbol is unknown to the parser.\n getSymbolName: function parser_getSymbolName(symbol) {\n \"use strict\";\n\n if (this.terminals_[symbol]) {\n return this.terminals_[symbol];\n }\n\n // Otherwise... this might refer to a RULE token i.e. a non-terminal: see if we can dig that one up.\n //\n // An example of this may be where a rule's action code contains a call like this:\n //\n // parser.getSymbolName(#$)\n //\n // to obtain a human-readable name of the current grammar rule.\n var s = this.symbols_;\n for (var key in s) {\n if (s[key] === symbol) {\n return key;\n }\n }\n return null;\n },\n\n // Return a more-or-less human-readable description of the given symbol, when available,\n // or the symbol itself, serving as its own 'description' for lack of something better to serve up.\n //\n // Return NULL when the symbol is unknown to the parser.\n describeSymbol: function parser_describeSymbol(symbol) {\n \"use strict\";\n\n if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) {\n return this.terminal_descriptions_[symbol];\n }\n else if (symbol === this.EOF) {\n return 'end of input';\n }\n var id = this.getSymbolName(symbol);\n if (id) {\n return this.quoteName(id);\n }\n return null;\n },\n\n // Produce a (more or less) human-readable list of expected tokens at the point of failure.\n //\n // The produced list may contain token or token set descriptions instead of the tokens\n // themselves to help turning this output into something that easier to read by humans\n // unless `do_not_describe` parameter is set, in which case a list of the raw, *numeric*,\n // expected terminals and nonterminals is produced.\n //\n // The returned list (array) will not contain any duplicate entries.\n collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) {\n \"use strict\";\n\n var TERROR = this.TERROR;\n var tokenset = [];\n var check = {};\n // Has this (error?) state been outfitted with a custom expectations description text for human consumption?\n // If so, use that one instead of the less palatable token set.\n if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) {\n return [\n this.state_descriptions_[state]\n ];\n }\n for (var p in this.table[state]) {\n p = +p;\n if (p !== TERROR) {\n var d = do_not_describe ? p : this.describeSymbol(p);\n if (d && !check[d]) {\n tokenset.push(d);\n check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries.\n }\n }\n }\n return tokenset;\n }\n"; // --- END of define_parser_APIs_1 chunk --- + var define_parser_APIs_1 = "\n TERROR: 2,\n EOF: 1,\n\n // internals: defined here so the object *structure* doesn't get modified by parse() et al,\n // thus helping JIT compilers like Chrome V8.\n originalQuoteName: null,\n originalParseError: null,\n cleanupAfterParse: null,\n constructParseErrorInfo: null,\n yyMergeLocationInfo: null,\n copy_yytext: null,\n copy_yylloc: null,\n\n __reentrant_call_depth: 0, // INTERNAL USE ONLY\n __error_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup\n __error_recovery_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup\n\n // APIs which will be set up depending on user action code analysis:\n //yyRecovering: 0,\n //yyErrOk: 0,\n //yyClearIn: 0,\n\n // Helper APIs\n // -----------\n\n // Helper function which can be overridden by user code later on: put suitable quotes around\n // literal IDs in a description string.\n quoteName: function parser_quoteName(id_str) {\n return '\"' + id_str + '\"';\n },\n\n // Return the name of the given symbol (terminal or non-terminal) as a string, when available.\n //\n // Return NULL when the symbol is unknown to the parser.\n getSymbolName: function parser_getSymbolName(symbol) {\n if (this.terminals_[symbol]) {\n return this.terminals_[symbol];\n }\n\n // Otherwise... this might refer to a RULE token i.e. a non-terminal: see if we can dig that one up.\n //\n // An example of this may be where a rule's action code contains a call like this:\n //\n // parser.getSymbolName(#$)\n //\n // to obtain a human-readable name of the current grammar rule.\n const s = this.symbols_;\n for (let key in s) {\n if (s[key] === symbol) {\n return key;\n }\n }\n return null;\n },\n\n // Return a more-or-less human-readable description of the given symbol, when available,\n // or the symbol itself, serving as its own 'description' for lack of something better to serve up.\n //\n // Return NULL when the symbol is unknown to the parser.\n describeSymbol: function parser_describeSymbol(symbol) {\n if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) {\n return this.terminal_descriptions_[symbol];\n } else if (symbol === this.EOF) {\n return 'end of input';\n }\n\n let id = this.getSymbolName(symbol);\n if (id) {\n return this.quoteName(id);\n }\n return null;\n },\n\n // Produce a (more or less) human-readable list of expected tokens at the point of failure.\n //\n // The produced list may contain token or token set descriptions instead of the tokens\n // themselves to help turning this output into something that easier to read by humans\n // unless `do_not_describe` parameter is set, in which case a list of the raw, *numeric*,\n // expected terminals and nonterminals is produced.\n //\n // The returned list (array) will not contain any duplicate entries.\n collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) {\n const TERROR = this.TERROR;\n let tokenset = [];\n let check = {};\n\n // Has this (error?) state been outfitted with a custom expectations description text for human consumption?\n // If so, use that one instead of the less palatable token set.\n if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) {\n return [\n this.state_descriptions_[state]\n ];\n }\n for (let p in this.table[state]) {\n p = +p;\n if (p !== TERROR) {\n let d = do_not_describe ? p : this.describeSymbol(p);\n if (d && !check[d]) {\n tokenset.push(d);\n check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries.\n }\n }\n }\n return tokenset;\n }\n"; // --- END of define_parser_APIs_1 chunk --- var api_set = new Function('', 'return { ' + define_parser_APIs_1 + ' };')(); @@ -28046,7 +28357,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } // --- START parser kernel --- - parser$4.parse = "\nfunction parse(input, parseParams) {\n \"use strict\";\n\n var self = this;\n var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage)\n var sstack = new Array(128); // state stack: stores states (column storage)\n var tstack = []; // token stack (only used when `%options token_stack` support has been enabled)\n var vstack = new Array(128); // semantic value stack\n var lstack = new Array(128); // location stack\n var table = this.table;\n var sp = 0; // 'stack pointer': index into the stacks\n var yyloc;\n var yytext;\n var yylineno;\n var yyleng;\n\n var symbol = 0;\n var preErrorSymbol = 0;\n var lastEofErrorStateDepth = Infinity;\n var recoveringErrorInfo = null;\n var recovering = 0; // (only used when the grammar contains error recovery rules)\n var TERROR = this.TERROR;\n var EOF = this.EOF;\n var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3;\n var NO_ACTION = [0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */];\n\n var lexer;\n if (this.__lexer__) {\n lexer = this.__lexer__;\n } else {\n lexer = this.__lexer__ = Object.create(this.lexer);\n }\n\n var sharedState_yy = {\n parseError: undefined,\n quoteName: undefined,\n lexer: undefined,\n parser: undefined,\n pre_parse: undefined,\n post_parse: undefined,\n pre_lex: undefined,\n post_lex: undefined,\n parseParamsAsMembers: parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes!\n };\n\n var ASSERT;\n if (typeof assert !== 'function') {\n ASSERT = function JisonAssert(cond, msg) {\n \"use strict\";\n\n if (!cond) {\n throw new Error('assertion failed: ' + (msg || '***'));\n }\n };\n } else {\n ASSERT = assert;\n }\n\n this.yyGetSharedState = function yyGetSharedState() {\n return sharedState_yy;\n };\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n this.yyGetErrorInfoTrack = function yyGetErrorInfoTrack() {\n return recoveringErrorInfo;\n };\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // shallow clone objects & arrays, straight copy of simple `src` values\n // e.g. `lexer.yytext` MAY be a complex value object,\n // rather than a simple string/value.\n //\n // https://jsperf.com/new-array-vs-splice-vs-slice/72\n // https://jsperf.com/instanceof-vs-typeof/20\n // benchmark:: http://127.0.0.1:8080/example/jsperf/#testfile=test0020-typeof-instanceof-isArray.json5\n // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5\n //\n function shallow_copy(src) {\n \"use strict\";\n\n if (src && typeof src === 'object') {\n // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned\n // using their constructor:\n if (src.constructor !== Object) {\n if (Array.isArray(src)) {\n return src.slice();\n }\n var dst = new src.constructor(src);\n\n // and make sure all custom attributes are added to the clone:\n shallow_copy_noclobber(dst, src);\n return dst;\n }\n // native objects must be cloned a different way:\n //\n //return Object.assign({}, src);\n var dst = {};\n shallow_copy_noclobber(dst, src);\n return dst;\n }\n return src;\n }\n // add elements from `src` to `dst` when:\n // - either the element does not yet exist in `src`\n // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst`\n function shallow_copy_noclobber(dst, src) {\n \"use strict\";\n\n const chk = Object.prototype.hasOwnProperty;\n for (var k in src) {\n if (!(k in dst)) {\n if (chk.call(src, k)) {\n dst[k] = src[k];\n }\n }\n else {\n if (src[k] != null && dst[k] == null && chk.call(src, k)) {\n dst[k] = src[k];\n }\n }\n }\n }\n function copy_yylloc_native(loc) {\n \"use strict\";\n\n var rv = shallow_copy(loc);\n // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries:\n if (rv) {\n rv.range = rv.range.slice();\n }\n return rv;\n }\n\n // copy state\n shallow_copy_noclobber(sharedState_yy, this.yy);\n\n sharedState_yy.lexer = lexer;\n sharedState_yy.parser = this;\n\n // allow userland code to override the yytext and yylloc copy/clone functions:\n this.copy_yytext = this.options.copy_yytext || sharedState_yy.copy_yytext || shallow_copy;\n this.copy_yylloc = this.options.copy_yylloc || sharedState_yy.copy_yylloc || copy_yylloc_native;\n\n var yydebug = false;\n if (this.options.debug) {\n yydebug = function yydebug_impl(msg, obj) {\n \"use strict\";\n\n var ref_list;\n var ref_names;\n\n function deepClone(from, sub) {\n \"use strict\";\n\n if (sub == null) {\n ref_list = [];\n ref_names = [];\n sub = 'root';\n }\n if (typeof from === 'function') return '[Function]';\n if (from == null || typeof from !== 'object') return from;\n if (from.constructor !== Object && from.constructor !== Array) {\n return from;\n }\n\n var i = ref_list.indexOf(from);\n if (i >= 0) {\n return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference\n }\n ref_list.push(from);\n ref_names.push(sub);\n\n var to = new from.constructor();\n for (var name in from) {\n if (name === 'parser') continue;\n if (name === 'lexer') continue;\n to[name] = deepClone(from[name], name);\n }\n return to;\n }\n\n obj = obj || {};\n if (obj.symbol) {\n obj.local_yytext = yytext;\n obj.lexer_yytext = lexer.yytext;\n obj.lexer_yylloc = lexer.yylloc;\n obj.lexer_yyllineno = lexer.yyllineno;\n }\n\n // warning: here we fetch from closure (stack et al)\n obj.symbol_stack = stack;\n obj.state_stack = sstack;\n obj.value_stack = vstack;\n obj.location_stack = lstack;\n obj.stack_pointer = sp;\n\n // ready the object for printing:\n obj = deepClone(obj);\n\n // wrap try/catch in a function to help the V8 JIT compiler...\n function yydebug_cvt(obj) {\n \"use strict\";\n\n var js;\n try {\n var re1;\n if (typeof XRegExp === 'undefined') {\n re1 = / \\\"([a-z_][a-z_0-9. ]*)\\\": /ig;\n } else {\n re1 = new XRegExp(' \\\"([\\\\p{Alphabetic}_][\\\\p{Alphabetic}\\\\p{Number}_. ]*)\\\": ', 'g');\n }\n js = JSON.stringify(obj, null, 2)\n .replace(re1, ' $1: ')\n .replace(/[\\n\\s]+/g, ' ')\n // shorten yylloc object dumps too:\n .replace(/\\{ first_line: (\\d+), first_column: (\\d+), last_line: (\\d+), last_column: (\\d+)/g, '{L/C: ($1,$2)..($3,$4)');\n } catch (ex) {\n js = String(obj);\n }\n return js;\n }\n\n self.trace(msg, yydebug_cvt(obj), '\\n');\n };\n }\n\n // disable debugging at run-time ANYWAY when you've *explicitly* set \"yy.yydebug = false\":\n if (sharedState_yy.yydebug === false) {\n yydebug = undefined;\n }\n\n // *Always* setup `yyError`, `YYRECOVERING`, `yyErrOk` and `yyClearIn` functions as it is paramount\n // to have *their* closure match ours -- if we only set them up once,\n // any subsequent `parse()` runs will fail in very obscure ways when\n // these functions are invoked in the user action code block(s) as\n // their closure will still refer to the `parse()` instance which set\n // them up. Hence we MUST set them up at the start of every `parse()` run!\n if (this.yyError) {\n this.yyError = function yyError(str /*, ...args */) {\n \"use strict\";\n\n if (yydebug) yydebug('yyerror: ', { message: str, args: arguments, symbol: symbol, state: state, newState: newState, recovering: recovering, action: action });\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1);\n var expected = this.collect_expected_token_set(state);\n var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0));\n // append to the old one?\n if (recoveringErrorInfo) {\n var esp = recoveringErrorInfo.info_stack_pointer;\n\n recoveringErrorInfo.symbol_stack[esp] = symbol;\n var v = this.shallowCopyErrorInfo(hash);\n v.yyError = true;\n v.errorRuleDepth = error_rule_depth;\n v.recovering = recovering;\n // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH;\n\n recoveringErrorInfo.value_stack[esp] = v;\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc);\n recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n } else {\n recoveringErrorInfo = this.shallowCopyErrorInfo(hash);\n recoveringErrorInfo.yyError = true;\n recoveringErrorInfo.errorRuleDepth = error_rule_depth;\n recoveringErrorInfo.recovering = recovering;\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n\n var expected = this.collect_expected_token_set(state);\n var hash = this.constructParseErrorInfo(str, null, expected, false);\n\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n var args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n hash.extra_error_attributes = args;\n }\n\n return this.parseError(str, hash, this.JisonParserError);\n };\n }\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n if (this.yyRecovering) {\n this.yyRecovering = function yyRecovering() {\n \"use strict\";\n\n if (yydebug) yydebug('yyrecovering: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action });\n return recovering;\n };\n }\n\n if (this.yyErrOk) {\n this.yyErrOk = function yyErrOk() {\n \"use strict\";\n\n if (yydebug) yydebug('yyerrok: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action });\n recovering = 0;\n\n // DO NOT reset/cleanup `recoveringErrorInfo` yet: userland code\n // MAY invoke this API before the error is actually fully\n // recovered, in which case the parser recovery code won't be able\n // to append the skipped tokens to this info object.\n //\n // The rest of the kernel code is safe enough that it won't inadvertedly\n // re-use an old `recoveringErrorInfo` chunk so we'ld better wait\n // with destruction/cleanup until the end of the parse or until another\n // fresh parse error rears its ugly head...\n //\n // if (recoveringErrorInfo && typeof recoveringErrorInfo.destroy === 'function') {\n // recoveringErrorInfo.destroy();\n // recoveringErrorInfo = undefined;\n // }\n };\n }\n\n if (this.yyClearIn) {\n this.yyClearIn = function yyClearIn() {\n \"use strict\";\n\n if (yydebug) yydebug('yyclearin: ', { symbol: symbol, newState: newState, recovering: recovering, action: action, preErrorSymbol: preErrorSymbol });\n if (symbol === TERROR) {\n symbol = 0;\n yytext = null;\n yyleng = 0;\n yyloc = undefined;\n }\n preErrorSymbol = 0;\n };\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // Does the shared state override the default `parseError` that already comes with this instance?\n if (typeof sharedState_yy.parseError === 'function') {\n this.parseError = function parseErrorAlt(str, hash, ExceptionClass) {\n \"use strict\";\n\n if (!ExceptionClass) {\n ExceptionClass = this.JisonParserError;\n }\n return sharedState_yy.parseError.call(this, str, hash, ExceptionClass);\n };\n } else {\n this.parseError = this.originalParseError;\n }\n\n // Does the shared state override the default `quoteName` that already comes with this instance?\n if (typeof sharedState_yy.quoteName === 'function') {\n this.quoteName = function quoteNameAlt(id_str) {\n \"use strict\";\n\n return sharedState_yy.quoteName.call(this, id_str);\n };\n } else {\n this.quoteName = this.originalQuoteName;\n }\n\n // set up the cleanup function; make it an API so that external code can re-use this one in case of\n // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which\n // case this parse() API method doesn't come with a `finally { ... }` block any more!\n //\n // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,\n // or else your `sharedState`, etc. references will be *wrong*!\n this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) {\n \"use strict\";\n\n var rv;\n\n if (invoke_post_methods) {\n var hash;\n\n if (sharedState_yy.post_parse || this.post_parse) {\n // create an error hash info instance: we re-use this API in a **non-error situation**\n // as this one delivers all parser internals ready for access by userland code.\n hash = this.constructParseErrorInfo(null /* no error! */, null /* no exception! */, null, false);\n }\n\n if (sharedState_yy.post_parse) {\n rv = sharedState_yy.post_parse.call(this, sharedState_yy, resultValue, hash);\n if (typeof rv !== 'undefined') resultValue = rv;\n }\n if (this.post_parse) {\n rv = this.post_parse.call(this, sharedState_yy, resultValue, hash);\n if (typeof rv !== 'undefined') resultValue = rv;\n }\n\n // cleanup:\n if (hash && hash.destroy) {\n hash.destroy();\n }\n }\n\n if (this.__reentrant_call_depth > 1) return resultValue; // do not (yet) kill the sharedState when this is a reentrant run.\n\n // clean up the lingering lexer structures as well:\n if (lexer.cleanupAfterLex) {\n lexer.cleanupAfterLex(do_not_nuke_errorinfos);\n }\n\n // prevent lingering circular references from causing memory leaks:\n if (sharedState_yy) {\n sharedState_yy.lexer = undefined;\n sharedState_yy.parser = undefined;\n if (lexer.yy === sharedState_yy) {\n lexer.yy = undefined;\n }\n }\n sharedState_yy = undefined;\n this.parseError = this.originalParseError;\n this.quoteName = this.originalQuoteName;\n\n // nuke the vstack[] array at least as that one will still reference obsoleted user values.\n // To be safe, we nuke the other internal stack columns as well...\n stack.length = 0; // fastest way to nuke an array without overly bothering the GC\n sstack.length = 0;\n lstack.length = 0;\n vstack.length = 0;\n sp = 0;\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (var i = this.__error_infos.length - 1; i >= 0; i--) {\n var el = this.__error_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) {\n var el = this.__error_recovery_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_recovery_infos.length = 0;\n\n // `recoveringErrorInfo` is also part of the `__error_recovery_infos` array,\n // hence has been destroyed already: no need to do that *twice*.\n if (recoveringErrorInfo) {\n recoveringErrorInfo = undefined;\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n }\n\n return resultValue;\n };\n\n // merge yylloc info into a new yylloc instance.\n //\n // `first_index` and `last_index` MAY be UNDEFINED/NULL or these are indexes into the `lstack[]` location stack array.\n //\n // `first_yylloc` and `last_yylloc` MAY be UNDEFINED/NULL or explicit (custom or regular) `yylloc` instances, in which\n // case these override the corresponding first/last indexes.\n //\n // `dont_look_back` is an optional flag (default: FALSE), which instructs this merge operation NOT to search\n // through the parse location stack for a location, which would otherwise be used to construct the new (epsilon!)\n // yylloc info.\n //\n // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL.\n this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) {\n \"use strict\";\n\n var i1 = first_index | 0,\n i2 = last_index | 0;\n var l1 = first_yylloc,\n l2 = last_yylloc;\n var rv;\n\n // rules:\n // - first/last yylloc entries override first/last indexes\n\n if (!l1) {\n if (first_index != null) {\n for (var i = i1; i <= i2; i++) {\n l1 = lstack[i];\n if (l1) {\n break;\n }\n }\n }\n }\n\n if (!l2) {\n if (last_index != null) {\n for (var i = i2; i >= i1; i--) {\n l2 = lstack[i];\n if (l2) {\n break;\n }\n }\n }\n }\n\n // - detect if an epsilon rule is being processed and act accordingly:\n if (!l1 && first_index == null) {\n // epsilon rule span merger. With optional look-ahead in l2.\n if (!dont_look_back) {\n for (var i = (i1 || sp) - 1; i >= 0; i--) {\n l1 = lstack[i];\n if (l1) {\n break;\n }\n }\n }\n if (!l1) {\n if (!l2) {\n // when we still don't have any valid yylloc info, we're looking at an epsilon rule\n // without look-ahead and no preceding terms and/or `dont_look_back` set:\n // in that case we ca do nothing but return NULL/UNDEFINED:\n return undefined;\n } else {\n // shallow-copy L2: after all, we MAY be looking\n // at unconventional yylloc info objects...\n rv = this.copy_yylloc(l2);\n return rv;\n }\n } else {\n // shallow-copy L1, then adjust first col/row 1 column past the end.\n rv = this.copy_yylloc(l1);\n rv.first_line = rv.last_line;\n rv.first_column = rv.last_column;\n rv.range[0] = rv.range[1];\n\n if (l2) {\n // shallow-mixin L2, then adjust last col/row accordingly.\n shallow_copy_noclobber(rv, l2);\n rv.last_line = l2.last_line;\n rv.last_column = l2.last_column;\n rv.range[1] = l2.range[1];\n }\n return rv;\n }\n }\n\n if (!l1) {\n l1 = l2;\n l2 = null;\n }\n if (!l1) {\n return undefined;\n }\n\n // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking\n // at unconventional yylloc info objects...\n rv = this.copy_yylloc(l1);\n\n if (l2) {\n shallow_copy_noclobber(rv, l2);\n rv.last_line = l2.last_line;\n rv.last_column = l2.last_column;\n rv.range[1] = l2.range[1];\n }\n\n return rv;\n };\n\n // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,\n // or else your `lexer`, `sharedState`, etc. references will be *wrong*!\n this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) {\n \"use strict\";\n\n var pei = {\n errStr: msg,\n exception: ex,\n text: lexer.match,\n value: this.copy_yytext(lexer.yytext),\n token: this.describeSymbol(symbol) || symbol,\n token_id: symbol,\n line: lexer.yylineno,\n loc: this.copy_yylloc(lexer.yylloc),\n expected: expected,\n recoverable: recoverable,\n state: state,\n action: action,\n new_state: newState,\n symbol_stack: stack,\n state_stack: sstack,\n value_stack: vstack,\n location_stack: lstack,\n stack_pointer: sp,\n yy: sharedState_yy,\n lexer: lexer,\n parser: this,\n\n // and make sure the error info doesn't stay due to potential\n // ref cycle via userland code manipulations.\n // These would otherwise all be memory leak opportunities!\n //\n // Note that only array and object references are nuked as those\n // constitute the set of elements which can produce a cyclic ref.\n // The rest of the members is kept intact as they are harmless.\n destroy: function destructParseErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // info.value = null;\n // info.value_stack = null;\n // ...\n \"use strict\";\n\n var rec = !!this.recoverable;\n for (var key in this) {\n if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n };\n\n // clone some parts of the (possibly enhanced!) errorInfo object\n // to give them some persistence.\n this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) {\n \"use strict\";\n\n var rv = shallow_copy(p);\n\n // remove the large parts which can only cause cyclic references\n // and are otherwise available from the parser kernel anyway.\n delete rv.sharedState_yy;\n delete rv.parser;\n delete rv.lexer;\n\n // lexer.yytext MAY be a complex value object, rather than a simple string/value:\n rv.value = this.copy_yytext(rv.value);\n\n // yylloc info:\n rv.loc = this.copy_yylloc(rv.loc);\n\n // the 'expected' set won't be modified, so no need to clone it:\n //rv.expected = rv.expected.slice();\n\n // symbol stack is a simple array:\n rv.symbol_stack = rv.symbol_stack.slice();\n // ditto for state stack:\n rv.state_stack = rv.state_stack.slice();\n // clone the yylloc's in the location stack?:\n rv.location_stack = rv.location_stack.map(this.copy_yylloc);\n // and the value stack may carry both simple and complex values:\n // shallow-copy the latter.\n rv.value_stack = rv.value_stack.map(this.copy_yytext);\n\n // and we don't bother with the sharedState_yy reference:\n //delete rv.yy;\n\n // now we prepare for tracking the COMBINE actions\n // in the error recovery code path:\n //\n // as we want to keep the maximum error info context, we\n // *scan* the state stack to find the first *empty* slot.\n // This position will surely be AT OR ABOVE the current\n // stack pointer, but we want to keep the 'used but discarded'\n // part of the parse stacks *intact* as those slots carry\n // error context that may be useful when you want to produce\n // very detailed error diagnostic reports.\n //\n // ### Purpose of each stack pointer:\n //\n // - stack_pointer: points at the top of the parse stack\n // **as it existed at the time of the error\n // occurrence, i.e. at the time the stack\n // snapshot was taken and copied into the\n // errorInfo object.**\n // - base_pointer: the bottom of the **empty part** of the\n // stack, i.e. **the start of the rest of\n // the stack space /above/ the existing\n // parse stack. This section will be filled\n // by the error recovery process as it\n // travels the parse state machine to\n // arrive at the resolving error recovery rule.**\n // - info_stack_pointer:\n // this stack pointer points to the **top of\n // the error recovery tracking stack space**, i.e.\n // this stack pointer takes up the role of\n // the `stack_pointer` for the error recovery\n // process. Any mutations in the **parse stack**\n // are **copy-appended** to this part of the\n // stack space, keeping the bottom part of the\n // stack (the 'snapshot' part where the parse\n // state at the time of error occurrence was kept)\n // intact.\n // - root_failure_pointer:\n // copy of the `stack_pointer`...\n //\n for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) {\n // empty\n }\n rv.base_pointer = i;\n rv.info_stack_pointer = i;\n\n rv.root_failure_pointer = rv.stack_pointer;\n\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_recovery_infos.push(rv);\n\n return rv;\n };\n\n function getNonTerminalFromCode(symbol) {\n \"use strict\";\n\n var tokenName = self.getSymbolName(symbol);\n if (!tokenName) {\n tokenName = symbol;\n }\n return tokenName;\n }\n\n//_lexer_without_token_stack:\n\n function stdLex() {\n \"use strict\";\n\n var token = lexer.lex();\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n var tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName: tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n function fastLex() {\n \"use strict\";\n\n var token = lexer.fastLex();\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n var tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName: tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n var lex = stdLex;\n\n//_lexer_with_token_stack:\n\n // lex function that supports token stacks\n function tokenStackLex() {\n \"use strict\";\n\n var token;\n token = tstack.pop() || lexer.lex() || EOF;\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n if (token instanceof Array) {\n // tokenstack CANNOT be nested, i.e. an 'array'-type token\n // now means the `tstack` is empty as this array of tokens\n // could only have originated from the `lexer.lex()`\n // call:\n tstack = token;\n token = tstack.pop();\n }\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n var tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName: tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n//_lexer_with_token_stack_end:\n\n var state, action, r, t;\n var yyval = {\n $: true,\n _$: undefined,\n yy: sharedState_yy\n };\n var p;\n var yyrulelen;\n var this_production;\n var newState;\n var retval = false;\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n // Return the rule stack depth where the nearest error rule can be found.\n // Return -1 when no error recovery rule was found.\n function locateNearestErrorRecoveryRule(state) {\n \"use strict\";\n\n var stack_probe = sp - 1;\n var depth = 0;\n\n // try to recover from error\n while (stack_probe >= 0) {\n // check for error recovery rule in this state\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #test#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n var t = (table[state] && table[state][TERROR]) || NO_ACTION;\n if (t[0]) {\n // We need to make sure we're not cycling forever:\n // once we hit EOF, even when we `yyerrok()` an error, we must\n // prevent the core from running forever,\n // e.g. when parent rules are still expecting certain input to\n // follow after this, for example when you handle an error inside a set\n // of braces which are matched by a parent rule in your grammar.\n //\n // Hence we require that every error handling/recovery attempt\n // *after we've hit EOF* has a diminishing state stack: this means\n // we will ultimately have unwound the state stack entirely and thus\n // terminate the parse in a controlled fashion even when we have\n // very complex error/recovery code interplay in the core + user\n // action code blocks:\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #found#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n if (symbol === EOF) {\n if (lastEofErrorStateDepth > sp - 1 - depth) {\n lastEofErrorStateDepth = sp - 1 - depth;\n } else {\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #skip#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n --stack_probe; // popStack(1): [symbol, action]\n state = sstack[stack_probe];\n ++depth;\n continue;\n }\n }\n return depth;\n }\n if (state === 0 /* $accept rule */ || stack_probe < 1) {\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n return -1; // No suitable error recovery rule available.\n }\n --stack_probe; // popStack(1): [symbol, action]\n state = sstack[stack_probe];\n ++depth;\n }\n if (yydebug) yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth });\n return -1; // No suitable error recovery rule available.\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n try {\n this.__reentrant_call_depth++;\n\n lexer.setInput(input, sharedState_yy);\n\n // NOTE: we *assume* no lexer pre/post handlers are set up *after*\n // this initial `setInput()` call: hence we can now check and decide\n // whether we'll go with the standard, slower, lex() API or the\n // `fast_lex()` one:\n if (typeof lexer.canIUse === 'function') {\n var lexerInfo = lexer.canIUse();\n if (lexerInfo.fastLex && typeof fastLex === 'function') {\n lex = fastLex;\n }\n }\n\n yyloc = this.copy_yylloc(lexer.yylloc);\n lstack[sp] = yyloc;\n vstack[sp] = null;\n sstack[sp] = 0;\n stack[sp] = 0;\n ++sp;\n\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyleng = lexer.yyleng;\n\n if (this.pre_parse) {\n this.pre_parse.call(this, sharedState_yy);\n }\n if (sharedState_yy.pre_parse) {\n sharedState_yy.pre_parse.call(this, sharedState_yy);\n }\n\n newState = sstack[sp - 1];\n for (;;) {\n // retrieve state number from top of stack\n state = newState; // sstack[sp - 1];\n\n // use default actions if available\n if (this.defaultActions[state]) {\n action = 2;\n newState = this.defaultActions[state];\n } else {\n // The single `==` condition below covers both these `===` comparisons in a single\n // operation:\n //\n // if (symbol === null || typeof symbol === 'undefined') ...\n if (!symbol) {\n symbol = lex();\n }\n // read action for current state and first input\n t = (table[state] && table[state][symbol]) || NO_ACTION;\n newState = t[1];\n action = t[0];\n\n if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action });\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n // handle parse error\n if (!action) {\n // first see if there's any chance at hitting an error recovery rule:\n var error_rule_depth = locateNearestErrorRecoveryRule(state);\n var errStr = null;\n var errSymbolDescr = (this.describeSymbol(symbol) || symbol);\n var expected = this.collect_expected_token_set(state);\n\n if (!recovering) {\n // Report error\n errStr = 'Parse error';\n if (typeof lexer.yylineno === 'number') {\n errStr += ' on line ' + (lexer.yylineno + 1);\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += ':\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n } else {\n errStr += ': ';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n\n p = this.constructParseErrorInfo(errStr, null, expected, (error_rule_depth >= 0));\n\n // DO NOT cleanup the old one before we start the new error info track:\n // the old one will *linger* on the error stack and stay alive until we\n // invoke the parser's cleanup API!\n recoveringErrorInfo = this.shallowCopyErrorInfo(p);\n\n if (yydebug) yydebug('error recovery rule detected: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p });\n\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n break;\n }\n\n // Protect against overly blunt userland `parseError` code which *sets*\n // the `recoverable` flag without properly checking first:\n // we always terminate the parse when there's no recovery rule available anyhow!\n if (!p.recoverable || error_rule_depth < 0) {\n break;\n } else {\n // TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process...\n }\n }\n\n if (yydebug) yydebug('after ERROR DETECT: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p });\n\n var esp = recoveringErrorInfo.info_stack_pointer;\n\n // just recovered from another error\n if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) {\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = this.copy_yytext(lexer.yytext);\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n\n // SHIFT current lookahead and grab another\n recoveringErrorInfo.symbol_stack[esp] = symbol;\n recoveringErrorInfo.value_stack[esp] = yytext;\n recoveringErrorInfo.location_stack[esp] = yyloc;\n recoveringErrorInfo.state_stack[esp] = newState; // push state\n ++esp;\n\n preErrorSymbol = 0;\n symbol = lex();\n\n if (yydebug) yydebug('after ERROR RECOVERY-3: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol] });\n }\n\n // try to recover from error\n if (error_rule_depth < 0) {\n ASSERT(recovering > 0, \"line 897\");\n recoveringErrorInfo.info_stack_pointer = esp;\n\n // barf a fatal hairball when we're out of look-ahead symbols and none hit a match\n // while we are still busy recovering from another error:\n var po = this.__error_infos[this.__error_infos.length - 1];\n\n // Report error\n if (typeof lexer.yylineno === 'number') {\n errStr = 'Parsing halted on line ' + (lexer.yylineno + 1) + ' while starting to recover from another error';\n } else {\n errStr = 'Parsing halted while starting to recover from another error';\n }\n\n if (po) {\n errStr += ' -- previous error which resulted in this fatal result: ' + po.errStr;\n } else {\n errStr += ': ';\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += '\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n\n p = this.constructParseErrorInfo(errStr, null, expected, false);\n if (po) {\n p.extra_error_attributes = po;\n }\n\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n\n preErrorSymbol = (symbol === TERROR ? 0 : symbol); // save the lookahead token\n symbol = TERROR; // insert generic error symbol as new lookahead\n\n const EXTRA_STACK_SAMPLE_DEPTH = 3;\n\n // REDUCE/COMBINE the pushed terms/tokens to a new ERROR token:\n recoveringErrorInfo.symbol_stack[esp] = preErrorSymbol;\n if (errStr) {\n recoveringErrorInfo.value_stack[esp] = {\n yytext: this.copy_yytext(lexer.yytext),\n errorRuleDepth: error_rule_depth,\n errStr: errStr,\n errorSymbolDescr: errSymbolDescr,\n expectedStr: expected,\n stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH\n };\n if (yydebug) yydebug('Error recovery process: pushed error info item on the info stack: ', {\n item: vstack[sp],\n sp,\n esp,\n vstack,\n stack,\n sstack,\n combineState: NO_ACTION[1]\n });\n } else {\n recoveringErrorInfo.value_stack[esp] = {\n yytext: this.copy_yytext(lexer.yytext),\n errorRuleDepth: error_rule_depth,\n stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH\n };\n }\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc);\n recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n\n yyval.$ = recoveringErrorInfo;\n yyval._$ = undefined;\n\n yyrulelen = error_rule_depth;\n\n if (yydebug) yydebug('Error recovery process: performAction: COMBINE: ', {\n yyval, yytext, sp, pop_size: yyrulelen, vstack, stack, sstack,\n combineState: NO_ACTION[1]\n });\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, NO_ACTION[1], sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof r !== 'undefined') {\n retval = r;\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // and move the top entries + discarded part of the parse stacks onto the error info stack:\n for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) {\n recoveringErrorInfo.symbol_stack[esp] = stack[idx];\n recoveringErrorInfo.value_stack[esp] = vstack[idx];\n recoveringErrorInfo.location_stack[esp] = lstack[idx];\n recoveringErrorInfo.state_stack[esp] = sstack[idx];\n }\n\n recoveringErrorInfo.symbol_stack[esp] = TERROR;\n recoveringErrorInfo.value_stack[esp] = this.copy_yytext(yyval.$);\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(yyval._$);\n\n // goto new state = table[STATE][NONTERMINAL]\n newState = sstack[sp - 1];\n\n if (this.defaultActions[newState]) {\n recoveringErrorInfo.state_stack[esp] = this.defaultActions[newState];\n } else {\n t = (table[newState] && table[newState][symbol]) || NO_ACTION;\n recoveringErrorInfo.state_stack[esp] = t[1];\n }\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n\n // allow N (default: 3) real symbols to be shifted before reporting a new error\n recovering = ERROR_RECOVERY_TOKEN_DISCARD_COUNT;\n\n if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth: error_rule_depth, symbol: symbol, preErrorSymbol: preErrorSymbol });\n\n // Now duplicate the standard parse machine here, at least its initial\n // couple of rounds until the TERROR symbol is **pushed onto the parse stack**,\n // as we wish to push something special then!\n //\n // Run the state machine in this copy of the parser state machine\n // until we *either* consume the error symbol (and its related information)\n // *or* we run into another error while recovering from this one\n // *or* we execute a `reduce` action which outputs a final parse\n // result (yes, that MAY happen!).\n //\n // We stay in this secondary parse loop until we have completed\n // the *error recovery phase* as the main parse loop (further below)\n // is optimized for regular parse operation and DOES NOT cope with\n // error recovery *at all*.\n //\n // We call the secondary parse loop just below the \"slow parse loop\",\n // while the main parse loop, which is an almost-duplicate of this one,\n // yet optimized for regular parse operation, is called the \"fast\n // parse loop\".\n //\n // Compare this to `bison` & (vanilla) `jison`, both of which have\n // only a single parse loop, which handles everything. Our goal is\n // to eke out every drop of performance in the main parse loop...\n\n ASSERT(recoveringErrorInfo, \"line 1049\");\n ASSERT(symbol === TERROR, \"line 1050\");\n ASSERT(!action, \"line 1051\");\n var errorSymbolFromParser = true;\n for (;;) {\n // retrieve state number from top of stack\n state = newState; // sstack[sp - 1];\n\n // use default actions if available\n if (this.defaultActions[state]) {\n action = 2;\n newState = this.defaultActions[state];\n } else {\n // The single `==` condition below covers both these `===` comparisons in a single\n // operation:\n //\n // if (symbol === null || typeof symbol === 'undefined') ...\n if (!symbol) {\n symbol = lex();\n // **Warning: Edge Case**: the *lexer* may produce\n // TERROR tokens of its own volition: *those* TERROR\n // tokens should be treated like *regular tokens*\n // i.e. tokens which have a lexer-provided `yyvalue`\n // and `yylloc`:\n errorSymbolFromParser = false;\n }\n // read action for current state and first input\n t = (table[state] && table[state][symbol]) || NO_ACTION;\n newState = t[1];\n action = t[0];\n\n if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action });\n\n // encountered another parse error? If so, break out to main loop\n // and take it from there!\n if (!action) {\n if (yydebug) yydebug('**NESTED ERROR DETECTED** while still recovering from previous error');\n\n ASSERT(recoveringErrorInfo, \"line 1087\");\n\n // Prep state variables so that upon breaking out of\n // this \"slow parse loop\" and hitting the `continue;`\n // statement in the outer \"fast parse loop\" we redo\n // the exact same state table lookup as the one above\n // so that the outer=main loop will also correctly\n // detect the 'parse error' state (`!action`) we have\n // just encountered above.\n newState = state;\n break;\n }\n }\n\n if (yydebug) yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) {\n \"use strict\";\n\n if (!nt || !nt.states || !nt.rules)\n return '';\n var rulename = nt.states[state];\n var rulespec = nt.rules[rulename][state];\n return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')';\n })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol });\n\n switch (action) {\n // catch misc. parse failures:\n default:\n // this shouldn't happen, unless resolve defaults are off\n //\n // SILENTLY SIGNAL that the outer \"fast parse loop\" should\n // take care of this internal error condition:\n // prevent useless code duplication now/here.\n break;\n\n // shift:\n case 1:\n stack[sp] = symbol;\n // ### Note/Warning ###\n //\n // The *lexer* may also produce TERROR tokens on its own,\n // so we specifically test for the TERROR we did set up\n // in the error recovery logic further above!\n if (symbol === TERROR && errorSymbolFromParser) {\n // Push a special value onto the stack when we're\n // shifting the `error` symbol that is related to the\n // error we're recovering from.\n ASSERT(recoveringErrorInfo, \"line 1131\");\n vstack[sp] = recoveringErrorInfo;\n lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true);\n } else {\n ASSERT(symbol !== 0, \"line 1135\");\n ASSERT(preErrorSymbol === 0, \"line 1136\");\n vstack[sp] = lexer.yytext;\n lstack[sp] = this.copy_yylloc(lexer.yylloc);\n }\n sstack[sp] = newState; // push state\n\n ++sp;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n var tokenName = this.getSymbolName(symbol || EOF);\n if (!tokenName) {\n tokenName = symbol;\n }\n\n Jison.parserDebugger.push({\n action: 'shift',\n text: lexer.yytext,\n terminal: tokenName,\n terminal_id: symbol\n });\n }\n\n symbol = 0;\n // **Warning: Edge Case**: the *lexer* may have produced\n // TERROR tokens of its own volition: *those* TERROR\n // tokens should be treated like *regular tokens*\n // i.e. tokens which have a lexer-provided `yyvalue`\n // and `yylloc`:\n errorSymbolFromParser = false;\n if (!preErrorSymbol) { // normal execution / no error\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n\n if (recovering > 0) {\n recovering--;\n if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering: recovering, symbol: symbol });\n }\n } else {\n // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode:\n ASSERT(recovering > 0, \"line 1163\");\n symbol = preErrorSymbol;\n preErrorSymbol = 0;\n if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering: recovering, symbol: symbol });\n // read action for current state and first input\n t = (table[newState] && table[newState][symbol]) || NO_ACTION;\n if (!t[0] || symbol === TERROR) {\n // forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where\n // (simple) stuff might have been missing before the token which caused the error we're\n // recovering from now...\n //\n // Also check if the LookAhead symbol isn't the ERROR token we set as part of the error\n // recovery, for then this we would we idling (cycling) on the error forever.\n // Yes, this does not take into account the possibility that the *lexer* may have\n // produced a *new* TERROR token all by itself, but that would be a very peculiar grammar!\n if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering: recovering, symbol: symbol });\n symbol = 0;\n }\n }\n\n // once we have pushed the special ERROR token value,\n // we REMAIN in this inner, \"slow parse loop\" until\n // the entire error recovery phase has completed.\n //\n // ### Note About Edge Case ###\n //\n // Userland action code MAY already have 'reset' the\n // error recovery phase marker `recovering` to ZERO(0)\n // while the error symbol hasn't been shifted onto\n // the stack yet. Hence we only exit this \"slow parse loop\"\n // when *both* conditions are met!\n ASSERT(preErrorSymbol === 0, \"line 1194\");\n if (recovering === 0) {\n break;\n }\n continue;\n\n // reduce:\n case 2:\n this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...\n yyrulelen = this_production[1];\n\n if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol });\n\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n var prereduceValue = vstack.slice(sp - yyrulelen, sp);\n var debuggableProductions = [];\n for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) {\n var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]);\n debuggableProductions.push(debuggableProduction);\n }\n\n // find the current nonterminal name (- nolan)\n var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0];\n var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode);\n\n Jison.parserDebugger.push({\n action: 'reduce',\n nonterminal: currentNonterminal,\n nonterminal_id: currentNonterminalCode,\n prereduce: prereduceValue,\n result: r,\n productions: debuggableProductions,\n text: yyval.$\n });\n }\n\n if (typeof r !== 'undefined') {\n // signal end of error recovery loop AND end of outer parse loop\n action = 3;\n retval = r;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n sp = -2; // magic number: signal outer \"fast parse loop\" ACCEPT state that we already have a properly set up `retval` parser return value.\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // don't overwrite the `symbol` variable: use a local var to speed things up:\n var ntsymbol = this_production[0]; // push nonterminal (reduce)\n stack[sp] = ntsymbol;\n vstack[sp] = yyval.$;\n lstack[sp] = yyval._$;\n // goto new state = table[STATE][NONTERMINAL]\n newState = table[sstack[sp - 1]][ntsymbol];\n sstack[sp] = newState;\n ++sp;\n if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol });\n continue;\n\n // accept:\n case 3:\n retval = true;\n // Return the `$accept` rule's `$$` result, if available.\n //\n // Also note that JISON always adds this top-most `$accept` rule (with implicit,\n // default, action):\n //\n // $accept: $end\n // %{ $$ = $1; @$ = @1; %}\n //\n // which, combined with the parse kernel's `$accept` state behaviour coded below,\n // will produce the `$$` value output of the rule as the parse result,\n // IFF that result is *not* `undefined`. (See also the parser kernel code.)\n //\n // In code:\n //\n // %{\n // @$ = @1; // if location tracking support is included\n // if (typeof $1 !== 'undefined')\n // return $1;\n // else\n // return true; // the default parse result if the rule actions don't produce anything\n // %}\n sp--;\n if (sp >= 0 && typeof vstack[sp] !== 'undefined') {\n retval = vstack[sp];\n }\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n sp = -2; // magic number: signal outer \"fast parse loop\" ACCEPT state that we already have a properly set up `retval` parser return value.\n break;\n }\n\n // break out of loop: we accept or fail with error\n break;\n }\n\n // should we also break out of the regular/outer parse loop,\n // i.e. did the parser already produce a parse result in here?!\n // *or* did we hit an unsupported parse state, to be handled\n // in the `switch/default` code further below?\n ASSERT(action !== 2, \"line 1272\");\n if (!action || action === 1) {\n continue;\n }\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n\n // handle parse error\n if (!action) {\n var errStr;\n var errSymbolDescr = (this.describeSymbol(symbol) || symbol);\n var expected = this.collect_expected_token_set(state);\n\n // Report error\n errStr = 'Parse error';\n if (typeof lexer.yylineno === 'number') {\n errStr += ' on line ' + (lexer.yylineno + 1);\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += ':\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n } else {\n errStr += ': ';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n // we cannot recover from the error!\n p = this.constructParseErrorInfo(errStr, null, expected, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n }\n\n if (yydebug) yydebug('::: MAIN CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) {\n \"use strict\";\n\n if (!nt || !nt.states || !nt.rules)\n return '';\n var rulename = nt.states[state];\n var rulespec = nt.rules[rulename][state];\n return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')';\n })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol });\n\n switch (action) {\n // catch misc. parse failures:\n default:\n // this shouldn't happen, unless resolve defaults are off\n if (action instanceof Array) {\n p = this.constructParseErrorInfo('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol, null, null, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n // Another case of better safe than sorry: in case state transitions come out of another error recovery process\n // or a buggy LUT (LookUp Table):\n p = this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.', null, null, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n\n // shift:\n case 1:\n stack[sp] = symbol;\n vstack[sp] = lexer.yytext;\n lstack[sp] = this.copy_yylloc(lexer.yylloc);\n sstack[sp] = newState; // push state\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n var tokenName = this.getSymbolName(symbol || EOF);\n if (!tokenName) {\n tokenName = symbol;\n }\n\n Jison.parserDebugger.push({\n action: 'shift',\n text: lexer.yytext,\n terminal: tokenName,\n terminal_id: symbol\n });\n }\n\n ++sp;\n\n symbol = 0;\n\n ASSERT(preErrorSymbol === 0, \"line 1352\"); // normal execution / no error\n ASSERT(recovering === 0, \"line 1353\"); // normal execution / no error\n\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n continue;\n\n // reduce:\n case 2:\n ASSERT(preErrorSymbol === 0, \"line 1364\"); // normal execution / no error\n ASSERT(recovering === 0, \"line 1365\"); // normal execution / no error\n\n this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...\n yyrulelen = this_production[1];\n\n if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol });\n\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n var prereduceValue = vstack.slice(sp - yyrulelen, sp);\n var debuggableProductions = [];\n for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) {\n var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]);\n debuggableProductions.push(debuggableProduction);\n }\n\n // find the current nonterminal name (- nolan)\n var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0];\n var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode);\n\n Jison.parserDebugger.push({\n action: 'reduce',\n nonterminal: currentNonterminal,\n nonterminal_id: currentNonterminalCode,\n prereduce: prereduceValue,\n result: r,\n productions: debuggableProductions,\n text: yyval.$\n });\n }\n\n if (typeof r !== 'undefined') {\n retval = r;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // don't overwrite the `symbol` variable: use a local var to speed things up:\n var ntsymbol = this_production[0]; // push nonterminal (reduce)\n stack[sp] = ntsymbol;\n vstack[sp] = yyval.$;\n lstack[sp] = yyval._$;\n // goto new state = table[STATE][NONTERMINAL]\n newState = table[sstack[sp - 1]][ntsymbol];\n sstack[sp] = newState;\n ++sp;\n if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol });\n continue;\n\n // accept:\n case 3:\n if (sp !== -2) {\n retval = true;\n // Return the `$accept` rule's `$$` result, if available.\n //\n // Also note that JISON always adds this top-most `$accept` rule (with implicit,\n // default, action):\n //\n // $accept: $end\n // %{ $$ = $1; @$ = @1; %}\n //\n // which, combined with the parse kernel's `$accept` state behaviour coded below,\n // will produce the `$$` value output of the rule as the parse result,\n // IFF that result is *not* `undefined`. (See also the parser kernel code.)\n //\n // In code:\n //\n // %{\n // @$ = @1; // if location tracking support is included\n // if (typeof $1 !== 'undefined')\n // return $1;\n // else\n // return true; // the default parse result if the rule actions don't produce anything\n // %}\n sp--;\n if (typeof vstack[sp] !== 'undefined') {\n retval = vstack[sp];\n }\n }\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n break;\n }\n\n // break out of loop: we accept or fail with error\n break;\n }\n } catch (ex) {\n // report exceptions through the parseError callback too, but keep the exception intact\n // if it is a known parser or lexer error which has been thrown by parseError() already:\n if (ex instanceof this.JisonParserError) {\n throw ex;\n }\n else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) {\n throw ex;\n }\n\n p = this.constructParseErrorInfo('Parsing aborted due to exception.', ex, null, false);\n retval = false;\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n } finally {\n retval = this.cleanupAfterParse(retval, true, true);\n this.__reentrant_call_depth--;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'return',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n } // /finally\n\n return retval;\n}\n"; // --- END parser kernel --- + parser$4.parse = "\nfunction parse(input, parseParams) {\n let self = this;\n let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage)\n let sstack = new Array(128); // state stack: stores states (column storage)\n let tstack = []; // token stack (only used when `%options token_stack` support has been enabled)\n let vstack = new Array(128); // semantic value stack\n let lstack = new Array(128); // location stack\n let table = this.table;\n let sp = 0; // 'stack pointer': index into the stacks\n let yyloc;\n let yytext;\n let yylineno;\n let yyleng;\n\n let symbol = 0;\n let preErrorSymbol = 0;\n let lastEofErrorStateDepth = Infinity;\n let recoveringErrorInfo = null;\n let recovering = 0; // (only used when the grammar contains error recovery rules)\n const TERROR = this.TERROR;\n const EOF = this.EOF;\n const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3;\n const NO_ACTION = [ 0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */];\n\n let lexer;\n if (this.__lexer__) {\n lexer = this.__lexer__;\n } else {\n lexer = this.__lexer__ = Object.create(this.lexer);\n }\n\n let sharedState_yy = {\n parseError: undefined,\n quoteName: undefined,\n lexer: undefined,\n parser: undefined,\n pre_parse: undefined,\n post_parse: undefined,\n pre_lex: undefined,\n post_lex: undefined,\n parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly!\n };\n\n const ASSERT = (\n typeof assert !== 'function' ?\n function JisonAssert(cond, msg) {\n if (!cond) {\n throw new Error('assertion failed: ' + (msg || '***'));\n }\n } :\n assert\n );\n\n this.yyGetSharedState = function yyGetSharedState() {\n return sharedState_yy;\n };\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n this.yyGetErrorInfoTrack = function yyGetErrorInfoTrack() {\n return recoveringErrorInfo;\n };\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // shallow clone objects & arrays, straight copy of simple `src` values\n // e.g. `lexer.yytext` MAY be a complex value object,\n // rather than a simple string/value.\n //\n // https://jsperf.com/new-array-vs-splice-vs-slice/72\n // https://jsperf.com/instanceof-vs-typeof/20\n // benchmark:: http://127.0.0.1:8080/example/jsperf/#testfile=test0020-typeof-instanceof-isArray.json5\n // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5\n //\n function shallow_copy(src) {\n if (src && typeof src === 'object') {\n // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned\n // using their constructor:\n if (src.constructor !== Object) {\n if (Array.isArray(src)) {\n return src.slice();\n }\n let dst = new src.constructor(src);\n\n // and make sure all custom attributes are added to the clone:\n shallow_copy_noclobber(dst, src);\n return dst;\n }\n // native objects must be cloned a different way:\n {\n //return Object.assign({}, src);\n let dst = {};\n shallow_copy_noclobber(dst, src);\n return dst;\n }\n }\n return src;\n }\n // add elements from `src` to `dst` when:\n // - either the element does not yet exist in `src`\n // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst`\n function shallow_copy_noclobber(dst, src) {\n const chk = Object.prototype.hasOwnProperty;\n for (let k in src) {\n if (!(k in dst)) {\n if (chk.call(src, k)) {\n dst[k] = src[k];\n }\n } else if (src[k] != null && dst[k] == null && chk.call(src, k)) {\n dst[k] = src[k];\n }\n }\n }\n function copy_yylloc_native(loc) {\n let rv = shallow_copy(loc);\n // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries:\n if (rv) {\n rv.range = rv.range.slice();\n }\n return rv;\n }\n\n // copy state\n shallow_copy_noclobber(sharedState_yy, this.yy);\n\n sharedState_yy.lexer = lexer;\n sharedState_yy.parser = this;\n\n // allow userland code to override the yytext and yylloc copy/clone functions:\n this.copy_yytext = this.options.copy_yytext || sharedState_yy.copy_yytext || shallow_copy;\n this.copy_yylloc = this.options.copy_yylloc || sharedState_yy.copy_yylloc || copy_yylloc_native;\n\n let yydebug = false;\n if (this.options.debug) {\n yydebug = function yydebug_impl(msg, obj) {\n let ref_list;\n let ref_names;\n\n function deepClone(from, sub) {\n if (sub == null) {\n ref_list = [];\n ref_names = [];\n sub = 'root';\n }\n if (typeof from === 'function') return '[Function]';\n if (from == null || typeof from !== 'object') return from;\n if (from.constructor !== Object && from.constructor !== Array) {\n return from;\n }\n\n let i = ref_list.indexOf(from);\n if (i >= 0) {\n return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference\n }\n ref_list.push(from);\n ref_names.push(sub);\n\n let to = new from.constructor();\n for (let name in from) {\n if (name === 'parser') continue;\n if (name === 'lexer') continue;\n to[name] = deepClone(from[name], name);\n }\n return to;\n }\n\n obj = obj || {};\n if (obj.symbol) {\n obj.local_yytext = yytext;\n obj.lexer_yytext = lexer.yytext;\n obj.lexer_yylloc = lexer.yylloc;\n obj.lexer_yyllineno = lexer.yyllineno;\n }\n\n // warning: here we fetch from closure (stack et al)\n obj.symbol_stack = stack;\n obj.state_stack = sstack;\n obj.value_stack = vstack;\n obj.location_stack = lstack;\n obj.stack_pointer = sp;\n\n // ready the object for printing:\n obj = deepClone(obj);\n\n // wrap try/catch in a function to help the V8 JIT compiler...\n function yydebug_cvt(obj) {\n let js;\n try {\n let re1;\n if (typeof XRegExp === 'undefined') {\n re1 = / {2}\\\"([a-z_][a-z_0-9. ]*)\\\": /ig;\n } else {\n re1 = new XRegExp(' \\\"([\\\\p{Alphabetic}_][\\\\p{Alphabetic}\\\\p{Number}_. ]*)\\\": ', 'g');\n }\n js = JSON.stringify(obj, null, 2)\n .replace(re1, ' $1: ')\n .replace(/[\\n\\s]+/g, ' ')\n // shorten yylloc object dumps too:\n .replace(/\\{ first_line: (\\d+), first_column: (\\d+), last_line: (\\d+), last_column: (\\d+)/g, '{L/C: ($1,$2)..($3,$4)');\n } catch (ex) {\n js = String(obj);\n }\n return js;\n }\n\n self.trace(msg, yydebug_cvt(obj), '\\n');\n };\n }\n\n // disable debugging at run-time ANYWAY when you've *explicitly* set \"yy.yydebug = false\":\n if (sharedState_yy.yydebug === false) {\n yydebug = undefined;\n }\n\n // *Always* setup `yyError`, `YYRECOVERING`, `yyErrOk` and `yyClearIn` functions as it is paramount\n // to have *their* closure match ours -- if we only set them up once,\n // any subsequent `parse()` runs will fail in very obscure ways when\n // these functions are invoked in the user action code block(s) as\n // their closure will still refer to the `parse()` instance which set\n // them up. Hence we MUST set them up at the start of every `parse()` run!\n if (this.yyError) {\n this.yyError = function yyError(str /*, ...args */) {\n if (yydebug) {\n yydebug('yyerror: ', {\n message: str,\n args: arguments,\n symbol, state, newState, recovering, action\n });\n }\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1);\n let expected = this.collect_expected_token_set(state);\n let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0));\n // append to the old one?\n if (recoveringErrorInfo) {\n let esp = recoveringErrorInfo.info_stack_pointer;\n\n recoveringErrorInfo.symbol_stack[esp] = symbol;\n let v = this.shallowCopyErrorInfo(hash);\n v.yyError = true;\n v.errorRuleDepth = error_rule_depth;\n v.recovering = recovering;\n // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH;\n\n recoveringErrorInfo.value_stack[esp] = v;\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc);\n recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n } else {\n recoveringErrorInfo = this.shallowCopyErrorInfo(hash);\n recoveringErrorInfo.yyError = true;\n recoveringErrorInfo.errorRuleDepth = error_rule_depth;\n recoveringErrorInfo.recovering = recovering;\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n\n let expected = this.collect_expected_token_set(state);\n let hash = this.constructParseErrorInfo(str, null, expected, false);\n\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // Add any extra args to the hash under the name `extra_error_attributes`:\n let args = Array.prototype.slice.call(arguments, 1);\n if (args.length) {\n hash.extra_error_attributes = args;\n }\n\n return this.parseError(str, hash, this.JisonParserError);\n };\n }\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n if (this.yyRecovering) {\n this.yyRecovering = function yyRecovering() {\n if (yydebug) yydebug('yyrecovering: ', { symbol, state, newState, recovering, action });\n return recovering;\n };\n }\n\n if (this.yyErrOk) {\n this.yyErrOk = function yyErrOk() {\n if (yydebug) yydebug('yyerrok: ', { symbol, state, newState, recovering, action });\n recovering = 0;\n\n // DO NOT reset/cleanup `recoveringErrorInfo` yet: userland code\n // MAY invoke this API before the error is actually fully\n // recovered, in which case the parser recovery code won't be able\n // to append the skipped tokens to this info object.\n //\n // The rest of the kernel code is safe enough that it won't inadvertedly\n // re-use an old `recoveringErrorInfo` chunk so we'ld better wait\n // with destruction/cleanup until the end of the parse or until another\n // fresh parse error rears its ugly head...\n //\n // if (recoveringErrorInfo && typeof recoveringErrorInfo.destroy === 'function') {\n // recoveringErrorInfo.destroy();\n // recoveringErrorInfo = undefined;\n // }\n };\n }\n\n if (this.yyClearIn) {\n this.yyClearIn = function yyClearIn() {\n if (yydebug) yydebug('yyclearin: ', { symbol, newState, recovering, action, preErrorSymbol });\n if (symbol === TERROR) {\n symbol = 0;\n yytext = null;\n yyleng = 0;\n yyloc = undefined;\n }\n preErrorSymbol = 0;\n };\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n // Does the shared state override the default `parseError` that already comes with this instance?\n if (typeof sharedState_yy.parseError === 'function') {\n this.parseError = function parseErrorAlt(str, hash, ExceptionClass) {\n if (!ExceptionClass) {\n ExceptionClass = this.JisonParserError;\n }\n return sharedState_yy.parseError.call(this, str, hash, ExceptionClass);\n };\n } else {\n this.parseError = this.originalParseError;\n }\n\n // Does the shared state override the default `quoteName` that already comes with this instance?\n if (typeof sharedState_yy.quoteName === 'function') {\n this.quoteName = function quoteNameAlt(id_str) {\n return sharedState_yy.quoteName.call(this, id_str);\n };\n } else {\n this.quoteName = this.originalQuoteName;\n }\n\n // set up the cleanup function; make it an API so that external code can re-use this one in case of\n // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which\n // case this parse() API method doesn't come with a `finally { ... }` block any more!\n //\n // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,\n // or else your `sharedState`, etc. references will be *wrong*!\n this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) {\n let rv;\n\n if (invoke_post_methods) {\n let hash;\n\n if (sharedState_yy.post_parse || this.post_parse) {\n // create an error hash info instance: we re-use this API in a **non-error situation**\n // as this one delivers all parser internals ready for access by userland code.\n hash = this.constructParseErrorInfo(null /* no error! */, null /* no exception! */, null, false);\n }\n\n if (sharedState_yy.post_parse) {\n rv = sharedState_yy.post_parse.call(this, sharedState_yy, resultValue, hash);\n if (typeof rv !== 'undefined') resultValue = rv;\n }\n if (this.post_parse) {\n rv = this.post_parse.call(this, sharedState_yy, resultValue, hash);\n if (typeof rv !== 'undefined') resultValue = rv;\n }\n\n // cleanup:\n if (hash && hash.destroy) {\n hash.destroy();\n }\n }\n\n if (this.__reentrant_call_depth > 1) return resultValue; // do not (yet) kill the sharedState when this is a reentrant run.\n\n // clean up the lingering lexer structures as well:\n if (lexer.cleanupAfterLex) {\n lexer.cleanupAfterLex(do_not_nuke_errorinfos);\n }\n\n // prevent lingering circular references from causing memory leaks:\n if (sharedState_yy) {\n sharedState_yy.lexer = undefined;\n sharedState_yy.parser = undefined;\n if (lexer.yy === sharedState_yy) {\n lexer.yy = undefined;\n }\n }\n sharedState_yy = undefined;\n this.parseError = this.originalParseError;\n this.quoteName = this.originalQuoteName;\n\n // nuke the vstack[] array at least as that one will still reference obsoleted user values.\n // To be safe, we nuke the other internal stack columns as well...\n stack.length = 0; // fastest way to nuke an array without overly bothering the GC\n sstack.length = 0;\n lstack.length = 0;\n vstack.length = 0;\n sp = 0;\n\n // nuke the error hash info instances created during this run.\n // Userland code must COPY any data/references\n // in the error hash instance(s) it is more permanently interested in.\n if (!do_not_nuke_errorinfos) {\n for (let i = this.__error_infos.length - 1; i >= 0; i--) {\n let el = this.__error_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_infos.length = 0;\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) {\n let el = this.__error_recovery_infos[i];\n if (el && typeof el.destroy === 'function') {\n el.destroy();\n }\n }\n this.__error_recovery_infos.length = 0;\n\n // `recoveringErrorInfo` is also part of the `__error_recovery_infos` array,\n // hence has been destroyed already: no need to do that *twice*.\n if (recoveringErrorInfo) {\n recoveringErrorInfo = undefined;\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n }\n\n return resultValue;\n };\n\n // merge yylloc info into a new yylloc instance.\n //\n // `first_index` and `last_index` MAY be UNDEFINED/NULL or these are indexes into the `lstack[]` location stack array.\n //\n // `first_yylloc` and `last_yylloc` MAY be UNDEFINED/NULL or explicit (custom or regular) `yylloc` instances, in which\n // case these override the corresponding first/last indexes.\n //\n // `dont_look_back` is an optional flag (default: FALSE), which instructs this merge operation NOT to search\n // through the parse location stack for a location, which would otherwise be used to construct the new (epsilon!)\n // yylloc info.\n //\n // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL.\n this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) {\n let i1 = first_index | 0;\n let i2 = last_index | 0;\n let l1 = first_yylloc;\n let l2 = last_yylloc;\n let rv;\n\n // rules:\n // - first/last yylloc entries override first/last indexes\n\n if (!l1) {\n if (first_index != null) {\n for (let i = i1; i <= i2; i++) {\n l1 = lstack[i];\n if (l1) {\n break;\n }\n }\n }\n }\n\n if (!l2) {\n if (last_index != null) {\n for (let i = i2; i >= i1; i--) {\n l2 = lstack[i];\n if (l2) {\n break;\n }\n }\n }\n }\n\n // - detect if an epsilon rule is being processed and act accordingly:\n if (!l1 && first_index == null) {\n // epsilon rule span merger. With optional look-ahead in l2.\n if (!dont_look_back) {\n for (let i = (i1 || sp) - 1; i >= 0; i--) {\n l1 = lstack[i];\n if (l1) {\n break;\n }\n }\n }\n if (!l1) {\n if (!l2) {\n // when we still don't have any valid yylloc info, we're looking at an epsilon rule\n // without look-ahead and no preceding terms and/or `dont_look_back` set:\n // in that case we ca do nothing but return NULL/UNDEFINED:\n return null;\n }\n // shallow-copy L2: after all, we MAY be looking\n // at unconventional yylloc info objects...\n rv = this.copy_yylloc(l2);\n return rv;\n }\n // shallow-copy L1, then adjust first col/row 1 column past the end.\n rv = this.copy_yylloc(l1);\n rv.first_line = rv.last_line;\n rv.first_column = rv.last_column;\n rv.range[0] = rv.range[1];\n\n if (l2) {\n // shallow-mixin L2, then adjust last col/row accordingly.\n shallow_copy_noclobber(rv, l2);\n rv.last_line = l2.last_line;\n rv.last_column = l2.last_column;\n rv.range[1] = l2.range[1];\n }\n return rv;\n }\n\n if (!l1) {\n l1 = l2;\n l2 = null;\n }\n if (!l1) {\n return null;\n }\n\n // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking\n // at unconventional yylloc info objects...\n rv = this.copy_yylloc(l1);\n\n if (l2) {\n shallow_copy_noclobber(rv, l2);\n rv.last_line = l2.last_line;\n rv.last_column = l2.last_column;\n rv.range[1] = l2.range[1];\n }\n\n return rv;\n };\n\n // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,\n // or else your `lexer`, `sharedState`, etc. references will be *wrong*!\n this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) {\n const pei = {\n errStr: msg,\n exception: ex,\n text: lexer.match,\n value: this.copy_yytext(lexer.yytext),\n token: this.describeSymbol(symbol) || symbol,\n token_id: symbol,\n line: lexer.yylineno,\n loc: this.copy_yylloc(lexer.yylloc),\n expected,\n recoverable,\n state,\n action,\n new_state: newState,\n symbol_stack: stack,\n state_stack: sstack,\n value_stack: vstack,\n location_stack: lstack,\n stack_pointer: sp,\n yy: sharedState_yy,\n lexer,\n parser: this,\n\n // and make sure the error info doesn't stay due to potential\n // ref cycle via userland code manipulations.\n // These would otherwise all be memory leak opportunities!\n //\n // Note that only array and object references are nuked as those\n // constitute the set of elements which can produce a cyclic ref.\n // The rest of the members is kept intact as they are harmless.\n destroy: function destructParseErrorInfo() {\n // remove cyclic references added to error info:\n // info.yy = null;\n // info.lexer = null;\n // info.value = null;\n // info.value_stack = null;\n // ...\n const rec = !!this.recoverable;\n for (let key in this) {\n if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') {\n this[key] = undefined;\n }\n }\n this.recoverable = rec;\n }\n };\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_infos.push(pei);\n return pei;\n };\n\n // clone some parts of the (possibly enhanced!) errorInfo object\n // to give them some persistence.\n this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) {\n let rv = shallow_copy(p);\n\n // remove the large parts which can only cause cyclic references\n // and are otherwise available from the parser kernel anyway.\n delete rv.sharedState_yy;\n delete rv.parser;\n delete rv.lexer;\n\n // lexer.yytext MAY be a complex value object, rather than a simple string/value:\n rv.value = this.copy_yytext(rv.value);\n\n // yylloc info:\n rv.loc = this.copy_yylloc(rv.loc);\n\n // the 'expected' set won't be modified, so no need to clone it:\n //rv.expected = rv.expected.slice();\n\n // symbol stack is a simple array:\n rv.symbol_stack = rv.symbol_stack.slice();\n // ditto for state stack:\n rv.state_stack = rv.state_stack.slice();\n // clone the yylloc's in the location stack?:\n rv.location_stack = rv.location_stack.map(this.copy_yylloc);\n // and the value stack may carry both simple and complex values:\n // shallow-copy the latter.\n rv.value_stack = rv.value_stack.map(this.copy_yytext);\n\n // and we don't bother with the sharedState_yy reference:\n //delete rv.yy;\n\n // now we prepare for tracking the COMBINE actions\n // in the error recovery code path:\n //\n // as we want to keep the maximum error info context, we\n // *scan* the state stack to find the first *empty* slot.\n // This position will surely be AT OR ABOVE the current\n // stack pointer, but we want to keep the 'used but discarded'\n // part of the parse stacks *intact* as those slots carry\n // error context that may be useful when you want to produce\n // very detailed error diagnostic reports.\n //\n // ### Purpose of each stack pointer:\n //\n // - stack_pointer: points at the top of the parse stack\n // **as it existed at the time of the error\n // occurrence, i.e. at the time the stack\n // snapshot was taken and copied into the\n // errorInfo object.**\n // - base_pointer: the bottom of the **empty part** of the\n // stack, i.e. **the start of the rest of\n // the stack space /above/ the existing\n // parse stack. This section will be filled\n // by the error recovery process as it\n // travels the parse state machine to\n // arrive at the resolving error recovery rule.**\n // - info_stack_pointer:\n // this stack pointer points to the **top of\n // the error recovery tracking stack space**, i.e.\n // this stack pointer takes up the role of\n // the `stack_pointer` for the error recovery\n // process. Any mutations in the **parse stack**\n // are **copy-appended** to this part of the\n // stack space, keeping the bottom part of the\n // stack (the 'snapshot' part where the parse\n // state at the time of error occurrence was kept)\n // intact.\n // - root_failure_pointer:\n // copy of the `stack_pointer`...\n //\n {\n let i;\n for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) {\n // empty\n }\n rv.base_pointer = i;\n rv.info_stack_pointer = i;\n }\n\n rv.root_failure_pointer = rv.stack_pointer;\n\n // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!\n this.__error_recovery_infos.push(rv);\n\n return rv;\n };\n\n function getNonTerminalFromCode(symbol) {\n let tokenName = self.getSymbolName(symbol);\n if (!tokenName) {\n tokenName = symbol;\n }\n return tokenName;\n }\n\n//_lexer_without_token_stack:\n\n function stdLex() {\n let token = lexer.lex();\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n let tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n function fastLex() {\n let token = lexer.fastLex();\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n let tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n let lex = stdLex;\n\n//_lexer_with_token_stack:\n\n // lex function that supports token stacks\n function tokenStackLex() {\n let token;\n token = tstack.pop() || lexer.lex() || EOF;\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n if (token instanceof Array) {\n // tokenstack CANNOT be nested, i.e. an 'array'-type token\n // now means the `tstack` is empty as this array of tokens\n // could only have originated from the `lexer.lex()`\n // call:\n tstack = token;\n token = tstack.pop();\n }\n // if token isn't its numeric value, convert\n if (typeof token !== 'number') {\n token = self.symbols_[token] || token;\n }\n }\n\n if (typeof Jison !== 'undefined' && Jison.lexDebugger) {\n let tokenName = self.getSymbolName(token || EOF);\n if (!tokenName) {\n tokenName = token;\n }\n\n Jison.lexDebugger.push({\n tokenName,\n tokenText: lexer.match,\n tokenValue: lexer.yytext\n });\n }\n\n return token || EOF;\n }\n\n//_lexer_with_token_stack_end:\n\n let state, action, r, t;\n let yyval = {\n $: true,\n _$: undefined,\n yy: sharedState_yy\n };\n let p;\n let yyrulelen;\n let this_production;\n let newState;\n let retval = false;\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n // Return the rule stack depth where the nearest error rule can be found.\n // Return -1 when no error recovery rule was found.\n function locateNearestErrorRecoveryRule(state) {\n let stack_probe = sp - 1;\n let depth = 0;\n\n // try to recover from error\n while (stack_probe >= 0) {\n // check for error recovery rule in this state\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #test#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n const t = (table[state] && table[state][TERROR]) || NO_ACTION;\n if (t[0]) {\n // We need to make sure we're not cycling forever:\n // once we hit EOF, even when we `yyerrok()` an error, we must\n // prevent the core from running forever,\n // e.g. when parent rules are still expecting certain input to\n // follow after this, for example when you handle an error inside a set\n // of braces which are matched by a parent rule in your grammar.\n //\n // Hence we require that every error handling/recovery attempt\n // *after we've hit EOF* has a diminishing state stack: this means\n // we will ultimately have unwound the state stack entirely and thus\n // terminate the parse in a controlled fashion even when we have\n // very complex error/recovery code interplay in the core + user\n // action code blocks:\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #found#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n if (symbol === EOF) {\n if (lastEofErrorStateDepth > sp - 1 - depth) {\n lastEofErrorStateDepth = sp - 1 - depth;\n } else {\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #skip#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n --stack_probe; // popStack(1): [symbol, action]\n state = sstack[stack_probe];\n ++depth;\n continue;\n }\n }\n return depth;\n }\n if (state === 0 /* $accept rule */ || stack_probe < 1) {\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n return -1; // No suitable error recovery rule available.\n }\n --stack_probe; // popStack(1): [symbol, action]\n state = sstack[stack_probe];\n ++depth;\n }\n if (yydebug) {\n yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', {\n symbol, state, depth,\n stackidx: sp - 1 - depth,\n lastidx: lastEofErrorStateDepth\n });\n }\n return -1; // No suitable error recovery rule available.\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n try {\n this.__reentrant_call_depth++;\n\n lexer.setInput(input, sharedState_yy);\n\n // NOTE: we *assume* no lexer pre/post handlers are set up *after*\n // this initial `setInput()` call: hence we can now check and decide\n // whether we'll go with the standard, slower, lex() API or the\n // `fast_lex()` one:\n if (typeof lexer.canIUse === 'function') {\n let lexerInfo = lexer.canIUse();\n if (lexerInfo.fastLex && typeof fastLex === 'function') {\n lex = fastLex;\n }\n }\n\n yyloc = this.copy_yylloc(lexer.yylloc);\n lstack[sp] = yyloc;\n vstack[sp] = null;\n sstack[sp] = 0;\n stack[sp] = 0;\n ++sp;\n\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyleng = lexer.yyleng;\n\n if (this.pre_parse) {\n this.pre_parse.call(this, sharedState_yy);\n }\n if (sharedState_yy.pre_parse) {\n sharedState_yy.pre_parse.call(this, sharedState_yy);\n }\n\n newState = sstack[sp - 1];\n for (;;) {\n // retrieve state number from top of stack\n state = newState; // sstack[sp - 1];\n\n // use default actions if available\n if (this.defaultActions[state]) {\n action = 2;\n newState = this.defaultActions[state];\n } else {\n // The single `==` condition below covers both these `===` comparisons in a single\n // operation:\n //\n // if (symbol === null || typeof symbol === 'undefined') ...\n if (!symbol) {\n symbol = lex();\n }\n // read action for current state and first input\n t = (table[state] && table[state][symbol]) || NO_ACTION;\n newState = t[1];\n action = t[0];\n\n if (yydebug) {\n yydebug('after FETCH/LEX: ', {\n symbol,\n symbolID: this.terminals_ && this.terminals_[symbol],\n state, newState, recovering, action\n });\n }\n\n//_handle_error_with_recovery: // run this code when the grammar includes error recovery rules\n\n // handle parse error\n if (!action) {\n // first see if there's any chance at hitting an error recovery rule:\n let error_rule_depth = locateNearestErrorRecoveryRule(state);\n let errStr = null;\n let errSymbolDescr = (this.describeSymbol(symbol) || symbol);\n let expected = this.collect_expected_token_set(state);\n\n if (!recovering) {\n // Report error\n errStr = 'Parse error';\n if (typeof lexer.yylineno === 'number') {\n errStr += ' on line ' + (lexer.yylineno + 1);\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += ':\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n } else {\n errStr += ': ';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n\n p = this.constructParseErrorInfo(errStr, null, expected, (error_rule_depth >= 0));\n\n // DO NOT cleanup the old one before we start the new error info track:\n // the old one will *linger* on the error stack and stay alive until we\n // invoke the parser's cleanup API!\n recoveringErrorInfo = this.shallowCopyErrorInfo(p);\n\n if (yydebug) {\n yydebug('error recovery rule detected: ', {\n error_rule_depth,\n error: p.errStr,\n error_hash: p\n });\n }\n\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n break;\n }\n\n // Protect against overly blunt userland `parseError` code which *sets*\n // the `recoverable` flag without properly checking first:\n // we always terminate the parse when there's no recovery rule available anyhow!\n if (!p.recoverable || error_rule_depth < 0) {\n break;\n } else {\n // TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process...\n }\n }\n\n if (yydebug) {\n yydebug('after ERROR DETECT: ', {\n error_rule_depth,\n error: p.errStr,\n error_hash: p\n });\n }\n\n let esp = recoveringErrorInfo.info_stack_pointer;\n\n // just recovered from another error\n if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) {\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = this.copy_yytext(lexer.yytext);\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n\n // SHIFT current lookahead and grab another\n recoveringErrorInfo.symbol_stack[esp] = symbol;\n recoveringErrorInfo.value_stack[esp] = yytext;\n recoveringErrorInfo.location_stack[esp] = yyloc;\n recoveringErrorInfo.state_stack[esp] = newState; // push state\n ++esp;\n\n preErrorSymbol = 0;\n symbol = lex();\n\n if (yydebug) {\n yydebug('after ERROR RECOVERY-3: ', {\n symbol,\n symbolID: this.terminals_ && this.terminals_[symbol]\n });\n }\n }\n\n // try to recover from error\n if (error_rule_depth < 0) {\n ASSERT(recovering > 0, 'Line 1048');\n recoveringErrorInfo.info_stack_pointer = esp;\n\n // barf a fatal hairball when we're out of look-ahead symbols and none hit a match\n // while we are still busy recovering from another error:\n let po = this.__error_infos[this.__error_infos.length - 1];\n\n // Report error\n if (typeof lexer.yylineno === 'number') {\n errStr = 'Parsing halted on line ' + (lexer.yylineno + 1) + ' while starting to recover from another error';\n } else {\n errStr = 'Parsing halted while starting to recover from another error';\n }\n\n if (po) {\n errStr += ' -- previous error which resulted in this fatal result: ' + po.errStr;\n } else {\n errStr += ': ';\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += '\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n\n p = this.constructParseErrorInfo(errStr, null, expected, false);\n if (po) {\n p.extra_error_attributes = po;\n }\n\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n\n preErrorSymbol = (symbol === TERROR ? 0 : symbol); // save the lookahead token\n symbol = TERROR; // insert generic error symbol as new lookahead\n\n const EXTRA_STACK_SAMPLE_DEPTH = 3;\n\n // REDUCE/COMBINE the pushed terms/tokens to a new ERROR token:\n recoveringErrorInfo.symbol_stack[esp] = preErrorSymbol;\n if (errStr) {\n recoveringErrorInfo.value_stack[esp] = {\n yytext: this.copy_yytext(lexer.yytext),\n errorRuleDepth: error_rule_depth,\n errStr,\n errSymbolDescr,\n expectedStr: expected,\n stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH\n };\n if (yydebug) {\n yydebug('Error recovery process: pushed error info item on the info stack: ', {\n item: vstack[sp],\n sp, esp, vstack, stack, sstack,\n combineState: NO_ACTION[1]\n });\n }\n } else {\n recoveringErrorInfo.value_stack[esp] = {\n yytext: this.copy_yytext(lexer.yytext),\n errorRuleDepth: error_rule_depth,\n stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH\n };\n }\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(lexer.yylloc);\n recoveringErrorInfo.state_stack[esp] = newState || NO_ACTION[1];\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n\n yyval.$ = recoveringErrorInfo;\n yyval._$ = undefined;\n\n yyrulelen = error_rule_depth;\n\n let combineState = NO_ACTION[1];\n\n if (yydebug) {\n yydebug('Error recovery process: performAction: COMBINE: ', {\n yyval, yytext, sp,\n pop_size: yyrulelen,\n vstack, stack, sstack,\n combineState\n });\n }\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, combineState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof r !== 'undefined') {\n retval = r;\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // and move the top entries + discarded part of the parse stacks onto the error info stack:\n for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) {\n recoveringErrorInfo.symbol_stack[esp] = stack[idx];\n recoveringErrorInfo.value_stack[esp] = vstack[idx];\n recoveringErrorInfo.location_stack[esp] = lstack[idx];\n recoveringErrorInfo.state_stack[esp] = sstack[idx];\n }\n\n recoveringErrorInfo.symbol_stack[esp] = TERROR;\n recoveringErrorInfo.value_stack[esp] = this.copy_yytext(yyval.$);\n recoveringErrorInfo.location_stack[esp] = this.copy_yylloc(yyval._$);\n\n // goto new state = table[STATE][NONTERMINAL]\n newState = sstack[sp - 1];\n\n if (this.defaultActions[newState]) {\n recoveringErrorInfo.state_stack[esp] = this.defaultActions[newState];\n } else {\n t = (table[newState] && table[newState][symbol]) || NO_ACTION;\n recoveringErrorInfo.state_stack[esp] = t[1];\n }\n\n ++esp;\n recoveringErrorInfo.info_stack_pointer = esp;\n\n // allow N (default: 3) real symbols to be shifted before reporting a new error\n recovering = ERROR_RECOVERY_TOKEN_DISCARD_COUNT;\n\n if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth, symbol, preErrorSymbol });\n\n // Now duplicate the standard parse machine here, at least its initial\n // couple of rounds until the TERROR symbol is **pushed onto the parse stack**,\n // as we wish to push something special then!\n //\n // Run the state machine in this copy of the parser state machine\n // until we *either* consume the error symbol (and its related information)\n // *or* we run into another error while recovering from this one\n // *or* we execute a `reduce` action which outputs a final parse\n // result (yes, that MAY happen!).\n //\n // We stay in this secondary parse loop until we have completed\n // the *error recovery phase* as the main parse loop (further below)\n // is optimized for regular parse operation and DOES NOT cope with\n // error recovery *at all*.\n //\n // We call the secondary parse loop just below the \"slow parse loop\",\n // while the main parse loop, which is an almost-duplicate of this one,\n // yet optimized for regular parse operation, is called the \"fast\n // parse loop\".\n //\n // Compare this to `bison` & (vanilla) `jison`, both of which have\n // only a single parse loop, which handles everything. Our goal is\n // to eke out every drop of performance in the main parse loop...\n\n ASSERT(recoveringErrorInfo, 'Line 1204');\n ASSERT(symbol === TERROR, 'Line 1205');\n ASSERT(!action, 'Line 1206');\n let errorSymbolFromParser = true;\n for (;;) {\n // retrieve state number from top of stack\n state = newState; // sstack[sp - 1];\n\n // use default actions if available\n if (this.defaultActions[state]) {\n action = 2;\n newState = this.defaultActions[state];\n } else {\n // The single `==` condition below covers both these `===` comparisons in a single\n // operation:\n //\n // if (symbol === null || typeof symbol === 'undefined') ...\n if (!symbol) {\n symbol = lex();\n // **Warning: Edge Case**: the *lexer* may produce\n // TERROR tokens of its own volition: *those* TERROR\n // tokens should be treated like *regular tokens*\n // i.e. tokens which have a lexer-provided `yyvalue`\n // and `yylloc`:\n errorSymbolFromParser = false;\n }\n // read action for current state and first input\n t = (table[state] && table[state][symbol]) || NO_ACTION;\n newState = t[1];\n action = t[0];\n\n if (yydebug) {\n yydebug('after FETCH/LEX: ', {\n symbol,\n symbolID: this.terminals_ && this.terminals_[symbol],\n state, newState, recovering, action\n });\n }\n\n // encountered another parse error? If so, break out to main loop\n // and take it from there!\n if (!action) {\n if (yydebug) yydebug('**NESTED ERROR DETECTED** while still recovering from previous error');\n\n ASSERT(recoveringErrorInfo, 'Line 1248');\n\n // Prep state variables so that upon breaking out of\n // this \"slow parse loop\" and hitting the `continue;`\n // statement in the outer \"fast parse loop\" we redo\n // the exact same state table lookup as the one above\n // so that the outer=main loop will also correctly\n // detect the 'parse error' state (`!action`) we have\n // just encountered above.\n newState = state;\n break;\n }\n }\n\n if (yydebug) {\n yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' +\n (action === 1 ?\n 'shift token ' + symbol + ' (then go to state ' + newState + ')' :\n action === 2 ?\n 'reduce by rule: ' + newState + (function __print_rule(nt, state) {\n if (!nt || !nt.states || !nt.rules) {\n return '';\n }\n let rulename = nt.states[state];\n let rulespec = nt.rules[rulename][state];\n return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')';\n })(this.nonterminals_, newState) :\n action === 3 ?\n 'accept' :\n '???unexpected???'\n ), {\n action, newState, recovering, symbol\n });\n }\n\n switch (action) {\n // catch misc. parse failures:\n default:\n // this shouldn't happen, unless resolve defaults are off\n //\n // SILENTLY SIGNAL that the outer \"fast parse loop\" should\n // take care of this internal error condition:\n // prevent useless code duplication now/here.\n break;\n\n // shift:\n case 1:\n stack[sp] = symbol;\n // ### Note/Warning ###\n //\n // The *lexer* may also produce TERROR tokens on its own,\n // so we specifically test for the TERROR we did set up\n // in the error recovery logic further above!\n if (symbol === TERROR && errorSymbolFromParser) {\n // Push a special value onto the stack when we're\n // shifting the `error` symbol that is related to the\n // error we're recovering from.\n ASSERT(recoveringErrorInfo, 'Line 1305');\n vstack[sp] = recoveringErrorInfo;\n lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true);\n } else {\n ASSERT(symbol !== 0, 'Line 1309');\n ASSERT(preErrorSymbol === 0, 'Line 1310');\n vstack[sp] = lexer.yytext;\n lstack[sp] = this.copy_yylloc(lexer.yylloc);\n }\n sstack[sp] = newState; // push state\n\n ++sp;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n let tokenName = this.getSymbolName(symbol || EOF);\n if (!tokenName) {\n tokenName = symbol;\n }\n\n Jison.parserDebugger.push({\n action: 'shift',\n text: lexer.yytext,\n terminal: tokenName,\n terminal_id: symbol\n });\n }\n\n symbol = 0;\n // **Warning: Edge Case**: the *lexer* may have produced\n // TERROR tokens of its own volition: *those* TERROR\n // tokens should be treated like *regular tokens*\n // i.e. tokens which have a lexer-provided `yyvalue`\n // and `yylloc`:\n errorSymbolFromParser = false;\n if (!preErrorSymbol) { // normal execution / no error\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n\n if (recovering > 0) {\n recovering--;\n if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering, symbol });\n }\n } else {\n // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode:\n ASSERT(recovering > 0, 'Line 1352');\n symbol = preErrorSymbol;\n preErrorSymbol = 0;\n if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering, symbol });\n // read action for current state and first input\n t = (table[newState] && table[newState][symbol]) || NO_ACTION;\n if (!t[0] || symbol === TERROR) {\n // forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where\n // (simple) stuff might have been missing before the token which caused the error we're\n // recovering from now...\n //\n // Also check if the LookAhead symbol isn't the ERROR token we set as part of the error\n // recovery, for then this we would we idling (cycling) on the error forever.\n // Yes, this does not take into account the possibility that the *lexer* may have\n // produced a *new* TERROR token all by itself, but that would be a very peculiar grammar!\n if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering, symbol });\n symbol = 0;\n }\n }\n\n // once we have pushed the special ERROR token value,\n // we REMAIN in this inner, \"slow parse loop\" until\n // the entire error recovery phase has completed.\n //\n // ### Note About Edge Case ###\n //\n // Userland action code MAY already have 'reset' the\n // error recovery phase marker `recovering` to ZERO(0)\n // while the error symbol hasn't been shifted onto\n // the stack yet. Hence we only exit this \"slow parse loop\"\n // when *both* conditions are met!\n ASSERT(preErrorSymbol === 0, 'Line 1383');\n if (recovering === 0) {\n break;\n }\n continue;\n\n // reduce:\n case 2:\n this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...\n yyrulelen = this_production[1];\n\n if (yydebug) {\n yydebug('~~~ REDUCE: ', {\n pop_size: yyrulelen,\n newState, recovering, symbol\n });\n }\n\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n let prereduceValue = vstack.slice(sp - yyrulelen, sp);\n let debuggableProductions = [];\n for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) {\n let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]);\n debuggableProductions.push(debuggableProduction);\n }\n\n // find the current nonterminal name (- nolan)\n let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0];\n let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode);\n\n Jison.parserDebugger.push({\n action: 'reduce',\n nonterminal: currentNonterminal,\n nonterminal_id: currentNonterminalCode,\n prereduce: prereduceValue,\n result: r,\n productions: debuggableProductions,\n text: yyval.$\n });\n }\n\n if (typeof r !== 'undefined') {\n // signal end of error recovery loop AND end of outer parse loop\n action = 3;\n retval = r;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n sp = -2; // magic number: signal outer \"fast parse loop\" ACCEPT state that we already have a properly set up `retval` parser return value.\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // don't overwrite the `symbol` variable: use a local var to speed things up:\n {\n let ntsymbol = this_production[0]; // push nonterminal (reduce)\n stack[sp] = ntsymbol;\n vstack[sp] = yyval.$;\n lstack[sp] = yyval._$;\n // goto new state = table[STATE][NONTERMINAL]\n newState = table[sstack[sp - 1]][ntsymbol];\n sstack[sp] = newState;\n ++sp;\n if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol });\n }\n continue;\n\n // accept:\n case 3:\n retval = true;\n // Return the `$accept` rule's `$$` result, if available.\n //\n // Also note that JISON always adds this top-most `$accept` rule (with implicit,\n // default, action):\n //\n // $accept: $end\n // %{ $$ = $1; @$ = @1; %}\n //\n // which, combined with the parse kernel's `$accept` state behaviour coded below,\n // will produce the `$$` value output of the rule as the parse result,\n // IFF that result is *not* `undefined`. (See also the parser kernel code.)\n //\n // In code:\n //\n // %{\n // @$ = @1; // if location tracking support is included\n // if (typeof $1 !== 'undefined')\n // return $1;\n // else\n // return true; // the default parse result if the rule actions don't produce anything\n // %}\n sp--;\n if (sp >= 0 && typeof vstack[sp] !== 'undefined') {\n retval = vstack[sp];\n }\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n sp = -2; // magic number: signal outer \"fast parse loop\" ACCEPT state that we already have a properly set up `retval` parser return value.\n break;\n }\n\n // break out of loop: we accept or fail with error\n break;\n }\n\n // should we also break out of the regular/outer parse loop,\n // i.e. did the parser already produce a parse result in here?!\n // *or* did we hit an unsupported parse state, to be handled\n // in the `switch/default` code further below?\n ASSERT(action !== 2, 'Line 1509');\n if (!action || action === 1) {\n continue;\n }\n }\n\n//_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules\n\n // handle parse error\n if (!action) {\n let errStr;\n let errSymbolDescr = (this.describeSymbol(symbol) || symbol);\n let expected = this.collect_expected_token_set(state);\n\n // Report error\n errStr = 'Parse error';\n if (typeof lexer.yylineno === 'number') {\n errStr += ' on line ' + (lexer.yylineno + 1);\n }\n\n if (typeof lexer.showPosition === 'function') {\n errStr += ':\\n' + lexer.showPosition(79 - 10, 10) + '\\n';\n } else {\n errStr += ': ';\n }\n if (expected.length) {\n errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;\n } else {\n errStr += 'Unexpected ' + errSymbolDescr;\n }\n // we cannot recover from the error!\n p = this.constructParseErrorInfo(errStr, null, expected, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n\n//_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above\n\n }\n\n if (yydebug) {\n yydebug('::: MAIN CYCLE action: ' +\n (action === 1 ?\n 'shift token ' + symbol + ' (then go to state ' + newState + ')' :\n action === 2 ?\n 'reduce by rule: ' + newState + (function __print_rule(nt, state) {\n if (!nt || !nt.states || !nt.rules) {\n return '';\n }\n let rulename = nt.states[state];\n let rulespec = nt.rules[rulename][state];\n return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')';\n })(this.nonterminals_, newState) :\n action === 3 ?\n 'accept' :\n '???unexpected???'\n ), {\n action, newState, recovering, symbol\n });\n }\n\n switch (action) {\n // catch misc. parse failures:\n default:\n // this shouldn't happen, unless resolve defaults are off\n if (action instanceof Array) {\n p = this.constructParseErrorInfo('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol, null, null, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n }\n // Another case of better safe than sorry: in case state transitions come out of another error recovery process\n // or a buggy LUT (LookUp Table):\n p = this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.', null, null, false);\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n break;\n\n // shift:\n case 1:\n stack[sp] = symbol;\n vstack[sp] = lexer.yytext;\n lstack[sp] = this.copy_yylloc(lexer.yylloc);\n sstack[sp] = newState; // push state\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n let tokenName = this.getSymbolName(symbol || EOF);\n if (!tokenName) {\n tokenName = symbol;\n }\n\n Jison.parserDebugger.push({\n action: 'shift',\n text: lexer.yytext,\n terminal: tokenName,\n terminal_id: symbol\n });\n }\n\n ++sp;\n\n symbol = 0;\n\n ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error\n ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error\n\n // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:\n yyleng = lexer.yyleng;\n yytext = lexer.yytext;\n yylineno = lexer.yylineno;\n yyloc = this.copy_yylloc(lexer.yylloc);\n continue;\n\n // reduce:\n case 2:\n ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error\n ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error\n\n this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...\n yyrulelen = this_production[1];\n\n if (yydebug) {\n yydebug('~~~ REDUCE: ', {\n pop_size: yyrulelen,\n newState, recovering, symbol\n });\n }\n\n r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack);\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n let prereduceValue = vstack.slice(sp - yyrulelen, sp);\n let debuggableProductions = [];\n for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) {\n let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]);\n debuggableProductions.push(debuggableProduction);\n }\n\n // find the current nonterminal name (- nolan)\n let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0];\n let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode);\n\n Jison.parserDebugger.push({\n action: 'reduce',\n nonterminal: currentNonterminal,\n nonterminal_id: currentNonterminalCode,\n prereduce: prereduceValue,\n result: r,\n productions: debuggableProductions,\n text: yyval.$\n });\n }\n\n if (typeof r !== 'undefined') {\n retval = r;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n break;\n }\n\n // pop off stack\n sp -= yyrulelen;\n\n // don't overwrite the `symbol` variable: use a local var to speed things up:\n {\n let ntsymbol = this_production[0]; // push nonterminal (reduce)\n stack[sp] = ntsymbol;\n vstack[sp] = yyval.$;\n lstack[sp] = yyval._$;\n // goto new state = table[STATE][NONTERMINAL]\n newState = table[sstack[sp - 1]][ntsymbol];\n sstack[sp] = newState;\n ++sp;\n if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol });\n }\n continue;\n\n // accept:\n case 3:\n if (sp !== -2) {\n retval = true;\n // Return the `$accept` rule's `$$` result, if available.\n //\n // Also note that JISON always adds this top-most `$accept` rule (with implicit,\n // default, action):\n //\n // $accept: $end\n // %{ $$ = $1; @$ = @1; %}\n //\n // which, combined with the parse kernel's `$accept` state behaviour coded below,\n // will produce the `$$` value output of the rule as the parse result,\n // IFF that result is *not* `undefined`. (See also the parser kernel code.)\n //\n // In code:\n //\n // %{\n // @$ = @1; // if location tracking support is included\n // if (typeof $1 !== 'undefined')\n // return $1;\n // else\n // return true; // the default parse result if the rule actions don't produce anything\n // %}\n sp--;\n if (typeof vstack[sp] !== 'undefined') {\n retval = vstack[sp];\n }\n }\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'accept',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n\n break;\n }\n\n // break out of loop: we accept or fail with error\n break;\n }\n } catch (ex) {\n // report exceptions through the parseError callback too, but keep the exception intact\n // if it is a known parser or lexer error which has been thrown by parseError() already:\n if (ex instanceof this.JisonParserError) {\n throw ex;\n } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) {\n throw ex;\n }\n\n p = this.constructParseErrorInfo('Parsing aborted due to exception.', ex, null, false);\n retval = false;\n r = this.parseError(p.errStr, p, this.JisonParserError);\n if (typeof r !== 'undefined') {\n retval = r;\n }\n } finally {\n retval = this.cleanupAfterParse(retval, true, true);\n this.__reentrant_call_depth--;\n\n if (typeof Jison !== 'undefined' && Jison.parserDebugger) {\n Jison.parserDebugger.push({\n action: 'return',\n text: retval\n });\n console.log(Jison.parserDebugger[Jison.parserDebugger.length - 1]);\n }\n } // /finally\n\n return retval;\n}\n"; // --- END parser kernel --- /* * LR(0) Parser @@ -28271,7 +28582,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi }, unionLookaheads: function LALR_unionLookaheads() { var self = this, - newg = this.newg; // var states = !!this.onDemandLookahead ? this.inadequateStates : this.states; + newg = this.newg; // let states = !!this.onDemandLookahead ? this.inadequateStates : this.states; var these_states = this.states; these_states.forEach(function union_states_forEach(state, i) { @@ -28387,19 +28698,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi closureOperation: function LR_ClosureOperation(itemSet) { var closureSet = new this.ItemSet(); var self = this; - var set = itemSet, - itemQueue; + var set = itemSet; - do { - itemQueue = new Set(); + var _loop3 = function _loop3() { + var itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function LR_AddItemToClosureSets(item) { - var symbol = item.markedSymbol; - var b, r; // if token is a nonterminal, recursively add closures + var symbol = item.markedSymbol; // if token is a nonterminal, recursively add closures if (symbol && self.nonterminals[symbol]) { - r = item.remainingHandle(); - b = self.first(r); + var r = item.remainingHandle(); + var b = self.first(r); if (b.length === 0 || item.production.nullable || self.nullable(r)) { b = b.concat(item.follows); @@ -28418,7 +28727,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi } }); set = itemQueue; - } while (!itemQueue.isEmpty()); + }; + + do { + _loop3(); + } while (!set.isEmpty()); return closureSet; } @@ -28449,9 +28762,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi //cleanupTable(this.table); }, parseTable: function ll_ParseTable(productions) { - var table = {}, - symbols_ = this.symbols_, - self = this; + var table = {}; + var symbols_ = this.symbols_; + var self = this; productions.forEach(function (production, i) { var row = table[production.symbol] || {}; var tokens = production.first; @@ -28504,7 +28817,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi // Anyway, API/CLI options **override** options coming in from the grammar spec. // - options = mkStdOptions$1("NODEFAULT", grammar.options, options); + options = mkStdOptions$1('NODEFAULT', grammar.options, options); switch (options.type || Jison$1.defaultJisonOptions.type) { case 'lr0': @@ -28544,6 +28857,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi return gen.createParser(); } - Jison$1.Parser = Parser$3; + Jison$1.Parser = Parser$3; // exports for unit/system testing purposes: + + Jison$1.TestExports = { + lookaheadMixin: lookaheadMixin, + generatorMixin: generatorMixin, + lrGeneratorMixin: lrGeneratorMixin, + lalr: lalr, + lr0: lr0, + lr1: lr1, + ll: ll, + parser: parser$4, + pickErrorHandlingChunk: pickErrorHandlingChunk, + addOrRemoveTokenStack: addOrRemoveTokenStack, + removeUnusedKernelFeatures: removeUnusedKernelFeatures, + expandParseArguments: expandParseArguments + }; return Jison$1; }); diff --git a/dist/jison-umd.js b/dist/jison-umd.js index 54de7c52a..483b14991 100644 --- a/dist/jison-umd.js +++ b/dist/jison-umd.js @@ -1,20 +1,21 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('fs'), require('path'), require('@gerhobbelt/json5'), require('@gerhobbelt/xregexp'), require('recast'), require('@babel/core'), require('assert'), require('ast-util')) : - typeof define === 'function' && define.amd ? define(['fs', 'path', '@gerhobbelt/json5', '@gerhobbelt/xregexp', 'recast', '@babel/core', 'assert', 'ast-util'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.jison = factory(global.fs, global.path$1, global.JSON5, global.XRegExp, global.recast, global.babel, global.assert$1, global.astUtils)); -}(this, (function (fs, path$1, JSON5, XRegExp, recast, babel, assert$1, astUtils) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('fs'), require('path'), require('@gerhobbelt/json5'), require('mkdirp'), require('@gerhobbelt/xregexp'), require('recast'), require('@babel/core'), require('assert'), require('ast-util')) : + typeof define === 'function' && define.amd ? define(['fs', 'path', '@gerhobbelt/json5', 'mkdirp', '@gerhobbelt/xregexp', 'recast', '@babel/core', 'assert', 'ast-util'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.jison = factory(global.fs, global.path$1, global.JSON5, global.mkdirp, global.XRegExp, global.recast, global.babel, global.assert$1, global.astUtils)); +}(this, (function (fs, path$1, JSON5, mkdirp, XRegExp, recast, babel, assert$1, astUtils) { 'use strict'; function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); + var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); var astUtils__default = /*#__PURE__*/_interopDefaultLegacy(astUtils); - // Return TRUE if `src` starts with `searchString`. + // Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -37,19 +38,19 @@ // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -68,19 +69,21 @@ // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -89,16 +92,19 @@ } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -109,27 +115,79 @@ return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } + // https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words + const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; + })([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' + ]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -147,6 +205,11 @@ .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -155,13 +218,13 @@ function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -172,23 +235,17 @@ break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -211,34 +268,33 @@ /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote$1(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -261,28 +317,76 @@ // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } + function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; + } + + + function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); + } + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -293,27 +397,37 @@ dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -323,7 +437,7 @@ } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -331,7 +445,7 @@ ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -357,27 +471,43 @@ // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -390,9 +520,10 @@ - var code_exec = { + var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -414,22 +545,22 @@ // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; - // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries + // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; - // Determine which Unicode NonAsciiIdentifierStart characters + // Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. - // + // // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action - // code chunks. - // + // code chunks. + // // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -437,40 +568,40 @@ function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -478,30 +609,30 @@ // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -512,59 +643,59 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -606,38 +737,38 @@ return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -649,18 +780,18 @@ // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -671,56 +802,56 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -728,97 +859,97 @@ typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -826,7 +957,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -839,7 +970,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -852,7 +983,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -865,7 +996,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -884,37 +1015,37 @@ let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -946,7 +1077,7 @@ // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -963,37 +1094,37 @@ .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return babel.transformSync(src, options); // => { code, map, ast } @@ -1001,8 +1132,8 @@ function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1011,7 +1142,7 @@ // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1034,25 +1165,25 @@ // validate the given JISON+JavaScript snippet: does it compile? - // - // Return either the parsed AST (object) or an error message (string). + // + // Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1063,9 +1194,9 @@ // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. - // + // // Returns the trimmed sourcecode which was provided via `src`. - // + // // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1073,7 +1204,7 @@ // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: - // + // // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1082,14 +1213,14 @@ // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} - // + // // Of course the example would be 'ludicrous' action code but the - // key point here is that users will certainly be able to come up with + // key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! - // + // function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1143,7 +1274,7 @@ trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1157,7 +1288,7 @@ /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1169,24 +1300,24 @@ /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. - /// + /// /// Also supports ES6's Arrow Functions: - /// + /// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' - /// + /// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1203,8 +1334,8 @@ if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1215,14 +1346,14 @@ action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1233,17 +1364,17 @@ var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; - // - // - // + // + // + // function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1269,7 +1400,7 @@ // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1317,7 +1448,7 @@ // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1380,13 +1511,13 @@ getRegExpInfo: getRegExpInfo }; - var cycleref = []; - var cyclerefpath = []; + let cycleref = []; + let cyclerefpath = []; - var linkref = []; - var linkrefpath = []; + let linkref = []; + let linkrefpath = []; - var path = []; + let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1394,14 +1525,14 @@ return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1414,11 +1545,11 @@ function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1431,9 +1562,9 @@ dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1448,16 +1579,52 @@ } + // strip developer machine specific parts off any paths in a given stacktrace (string) + // to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } + // strip off the line/position info from any stacktrace as a assert.deepEqual() on these + // will otherwise FAIL due to us running this stuff through both regular `node` and + // the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing + // exceptions and stacktraces which point completely somewhere else and this would b0rk + // our test rigs for the jison subpackages. + function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; + } + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1472,7 +1639,7 @@ function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1498,10 +1665,10 @@ } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1599,7 +1766,7 @@ function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1616,7 +1783,7 @@ path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1644,7 +1811,7 @@ function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1660,7 +1827,7 @@ linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1672,14 +1839,14 @@ // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. - // + // // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1689,7 +1856,7 @@ cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1703,12 +1870,14 @@ dquote: dquote$1, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1723,7 +1892,7 @@ printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; /* @@ -1733,23 +1902,23 @@ * By Zachary Carter * MIT Licensed */ - var mkIdentifier$1 = helpers.mkIdentifier; + let mkIdentifier$1 = helpers.mkIdentifier; - var create = Object.create || function (o) { - function F(){} - F.prototype = o; - return new F(); + let create = Object.create || function (o) { + function F() {} + F.prototype = o; + return new F(); }; - var position = /^(before|after)/; + let position = /^(before|after)/; // basic method layering // always returns original method's return value function layerMethod(pos, key, prop, fun) { if (pos === 'after') { return function () { - var ret = prop.apply(this, arguments); - var args = [].slice.call(arguments); + let ret = prop.apply(this, arguments); + let args = [].slice.call(arguments); args.splice(0, 0, ret); fun.apply(this, args); return ret; @@ -1757,7 +1926,7 @@ } else if (pos === 'before') { return function () { fun.apply(this, arguments); - var ret = prop.apply(this, arguments); + let ret = prop.apply(this, arguments); return ret; }; } @@ -1768,7 +1937,7 @@ // overwriting them or layering them. i.e. an object method 'meth' is // layered by mixin methods 'beforemeth' or 'aftermeth' function typal_mix() { - var i, o, k; + let i, o, k; for (i = 0; i < arguments.length; i++) { o = arguments[i]; if (!o) continue; @@ -1780,8 +1949,8 @@ } for (k in o) { if (Object.prototype.hasOwnProperty.call(o, k)) { - var match = k.match(position); - var key = k.replace(position, ''); + let match = k.match(position); + let key = k.replace(position, ''); if (match && typeof this[key] === 'function') { this[key] = layerMethod(match[0], key, this[key], o[k]); } else { @@ -1795,15 +1964,15 @@ // Same as typal_mix but also camelCases every object member and 'standardizes' the key set of every input // argument through a caLLback function. - // + // // This is useful for processing options with dashes in their key, e.g. `token-stack` --> tokenStack. function typal_camel_mix(cb) { - var i, o, k; + let i, o, k; // Convert first character to lowercase function lcase0(s) { - return s.replace(/^\w/, function (match) { - return match.toLowerCase(); + return s.replace(/^\w/, function (match) { + return match.toLowerCase(); }); } @@ -1821,16 +1990,15 @@ } for (k in o) { if (Object.prototype.hasOwnProperty.call(o, k)) { - var nk = mkIdentifier$1(k); - var match = k.match(position); - var key = k.replace(position, ''); + let nk = mkIdentifier$1(k); + let match = k.match(position); + let key = k.replace(position, ''); // This anticipates before/after members to be camelcased already, e.g. - // 'afterParse()' for layering 'parse()': - var alt_key = lcase0(key); + // 'afterParse()' for layering 'parse()': + let alt_key = lcase0(key); if (match && typeof this[key] === 'function') { this[key] = layerMethod(match[0], key, this[key], o[k]); - } - else if (match && typeof this[alt_key] === 'function') { + } else if (match && typeof this[alt_key] === 'function') { this[alt_key] = layerMethod(match[0], alt_key, this[alt_key], o[k]); } else { this[nk] = o[k]; @@ -1841,7 +2009,7 @@ return this; } - var typal = { + let typal = { // extend object with own properties of each argument mix: typal_mix, @@ -1856,9 +2024,9 @@ // Creates a new Class function based on an object with a constructor method construct: function typal_construct() { - var o = typal_mix.apply(create(this), arguments); - var constructor = o.constructor; - var Klass = o.constructor = function () { return constructor.apply(this, arguments); }; + let o = typal_mix.apply(create(this), arguments); + let constructor = o.constructor; + let Klass = o.constructor = function () { return constructor.apply(this, arguments); }; Klass.prototype = o; Klass.mix = typal_mix; // allow for easy singleton property extension return Klass; @@ -1870,13 +2038,12 @@ // Set class to wrap arrays - var setMixin = { + let setMixin = { constructor: function Set_constructor(set, raw) { this._items = []; if (set && set.constructor === Array) { - this._items = raw ? set: set.slice(0); - } - else if (arguments.length) { + this._items = raw ? set : set.slice(0); + } else if (arguments.length) { this._items = [].slice.call(arguments, 0); } }, @@ -1889,7 +2056,7 @@ }, indexOf: function indexOf(item) { if (item && item.eq) { - for (var k = 0; k < this._items.length; k++) { + for (let k = 0; k < this._items.length; k++) { if (item.eq(this._items[k])) { return k; } @@ -1904,14 +2071,14 @@ }); }, complement: function complement(set) { - var that = this; + let that = this; return set.filter(function sub_complement(elm) { return !that.contains(elm); }); }, subset: function subset(set) { - var cont = true; - for (var i = 0; i < this._items.length && cont; i++) { + let cont = true; + for (let i = 0; i < this._items.length && cont; i++) { cont = cont && set.contains(this._items[i]); } return cont; @@ -1922,60 +2089,59 @@ joinSet: function joinSet(set) { return this.concat(this.complement(set)); }, - contains: function contains(item) { - return this.indexOf(item) !== -1; + contains: function contains(item) { + return this.indexOf(item) !== -1; }, - item: function item(v) { - return this._items[v]; + item: function item(v) { + return this._items[v]; }, - i: function i(v) { - return this._items[v]; + i: function i(v) { + return this._items[v]; }, - assign: function assign(index, value) { + assign: function assign(index, value) { this._items[index] = value; - return this; + return this; }, - first: function first() { - return this._items[0]; + first: function first() { + return this._items[0]; }, - last: function last() { - return this._items[this._items.length - 1]; + last: function last() { + return this._items[this._items.length - 1]; }, - size: function size() { - return this._items.length; + size: function size() { + return this._items.length; }, - isEmpty: function isEmpty() { - return this._items.length === 0; + isEmpty: function isEmpty() { + return this._items.length === 0; }, - copy: function copy() { - return new Set(this._items); + copy: function copy() { + return new Set$1(this._items); }, - toString: function toString() { - return this._items.toString(); + toString: function toString() { + return this._items.toString(); } }; 'push shift unshift forEach some every join sort'.split(' ').forEach(function (e, i) { - setMixin[e] = function () { - return Array.prototype[e].apply(this._items, arguments); + setMixin[e] = function () { + return Array.prototype[e].apply(this._items, arguments); }; //setMixin[e].name = e; }); 'filter slice map'.split(' ').forEach(function (e, i) { - setMixin[e] = function () { - return new Set(Array.prototype[e].apply(this._items, arguments), true); + setMixin[e] = function () { + return new Set$1(Array.prototype[e].apply(this._items, arguments), true); }; //setMixin[e].name = e; }); - var Set = typal.construct(setMixin); + var Set$1 = typal.construct(setMixin); // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1992,9 +2158,9 @@ this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -2027,10 +2193,10 @@ // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -2043,11 +2209,11 @@ // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -2057,18 +2223,18 @@ // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -2099,7 +2265,7 @@ // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -2116,9 +2282,9 @@ // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -2131,7 +2297,7 @@ } - var parser = { + let parser = { // Code Generator Information Report // --------------------------------- // @@ -2381,7 +2547,6 @@ // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2389,7 +2554,6 @@ // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2401,8 +2565,8 @@ // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2415,14 +2579,13 @@ // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2438,10 +2601,10 @@ // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2449,10 +2612,10 @@ this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2607,9 +2770,9 @@ /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -2621,18 +2784,18 @@ case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2662,9 +2825,9 @@ case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -2677,10 +2840,10 @@ case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2707,9 +2870,9 @@ case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -2718,10 +2881,10 @@ case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2749,9 +2912,9 @@ case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -2760,10 +2923,10 @@ case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -2802,9 +2965,9 @@ case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2869,9 +3032,9 @@ case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2886,9 +3049,9 @@ case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -2923,10 +3086,10 @@ case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2943,9 +3106,9 @@ case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2962,10 +3125,10 @@ case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2982,9 +3145,9 @@ case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -3001,10 +3164,10 @@ case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3021,9 +3184,9 @@ case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3047,9 +3210,9 @@ case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3060,9 +3223,9 @@ case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3082,9 +3245,9 @@ case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3108,9 +3271,9 @@ case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -3123,10 +3286,10 @@ case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3143,9 +3306,9 @@ case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -3157,9 +3320,9 @@ case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -3199,10 +3362,10 @@ case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3222,9 +3385,9 @@ case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3274,10 +3437,10 @@ case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -3301,10 +3464,10 @@ case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3324,10 +3487,10 @@ case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3351,10 +3514,10 @@ case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3375,10 +3538,10 @@ case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3390,10 +3553,10 @@ case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3403,10 +3566,10 @@ case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3416,10 +3579,10 @@ case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3429,10 +3592,10 @@ case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3442,10 +3605,10 @@ case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -3455,10 +3618,10 @@ case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3468,10 +3631,10 @@ case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3481,9 +3644,9 @@ case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -3492,9 +3655,9 @@ case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -3503,9 +3666,9 @@ case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3527,9 +3690,9 @@ case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3540,9 +3703,9 @@ case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3562,9 +3725,9 @@ case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3618,9 +3781,9 @@ case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3640,9 +3803,9 @@ case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -3651,9 +3814,9 @@ case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -3665,9 +3828,9 @@ case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -3681,10 +3844,10 @@ case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3704,10 +3867,10 @@ case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3727,10 +3890,10 @@ case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3750,9 +3913,9 @@ case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3763,9 +3926,9 @@ case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3784,9 +3947,9 @@ case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -3827,9 +3990,9 @@ case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3853,9 +4016,9 @@ case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3881,9 +4044,9 @@ case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3928,9 +4091,9 @@ case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -3956,9 +4119,9 @@ case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -3967,9 +4130,9 @@ case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -3978,10 +4141,10 @@ case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3995,10 +4158,10 @@ case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4012,10 +4175,10 @@ case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4029,10 +4192,10 @@ case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4051,9 +4214,9 @@ case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4062,9 +4225,9 @@ case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -4102,10 +4265,10 @@ case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -4129,9 +4292,9 @@ case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -4210,9 +4373,9 @@ case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -4221,9 +4384,9 @@ case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -4232,9 +4395,9 @@ case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -4243,9 +4406,9 @@ case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -4254,9 +4417,9 @@ case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -4265,9 +4428,9 @@ case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -4276,9 +4439,9 @@ case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -4289,10 +4452,10 @@ case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4309,9 +4472,9 @@ case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -4320,9 +4483,9 @@ case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -4331,9 +4494,9 @@ case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -4342,9 +4505,9 @@ case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -4353,9 +4516,9 @@ case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -4374,18 +4537,18 @@ case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -4394,9 +4557,9 @@ case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -4405,9 +4568,9 @@ case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -4416,9 +4579,9 @@ case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -4427,9 +4590,9 @@ case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -4438,10 +4601,10 @@ case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4458,9 +4621,9 @@ case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -4477,9 +4640,9 @@ case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -4491,9 +4654,9 @@ case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -4503,9 +4666,9 @@ case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4540,9 +4703,9 @@ case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4561,9 +4724,9 @@ case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -4572,9 +4735,9 @@ case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -4583,9 +4746,9 @@ case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4603,10 +4766,10 @@ case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -4624,10 +4787,10 @@ case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -4648,9 +4811,9 @@ case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4683,9 +4846,9 @@ case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4711,9 +4874,9 @@ case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5__default['default'].parse(yyvstack[yysp]); @@ -4722,9 +4885,9 @@ case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue(yyvstack[yysp]); @@ -4733,9 +4896,9 @@ case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4744,9 +4907,9 @@ case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -4767,10 +4930,10 @@ case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4787,9 +4950,9 @@ case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -4808,9 +4971,9 @@ case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4834,9 +4997,9 @@ case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -4856,9 +5019,9 @@ case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4869,9 +5032,9 @@ case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -4927,10 +5090,10 @@ case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6533,7 +6696,6 @@ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -6550,38 +6712,34 @@ } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -6589,20 +6747,18 @@ pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -6624,7 +6780,6 @@ // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -6632,18 +6787,19 @@ if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -6651,24 +6807,19 @@ // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -6706,18 +6857,15 @@ - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); + let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -6738,7 +6886,7 @@ // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -6756,7 +6904,6 @@ // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -6769,7 +6916,6 @@ // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -6783,11 +6929,10 @@ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -6841,8 +6986,8 @@ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6850,8 +6995,8 @@ this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6883,19 +7028,18 @@ // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -6906,7 +7050,7 @@ if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -6919,7 +7063,7 @@ if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -6931,29 +7075,27 @@ // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -6961,7 +7103,7 @@ l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -6981,8 +7123,7 @@ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -6991,10 +7132,10 @@ token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -7002,7 +7143,7 @@ location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -7013,9 +7154,14 @@ // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -7031,8 +7177,7 @@ // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -7101,11 +7246,14 @@ // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -7116,8 +7264,7 @@ }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -7126,21 +7273,20 @@ function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -7150,21 +7296,20 @@ } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -7173,28 +7318,27 @@ return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -7207,8 +7351,7 @@ - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; + const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -7231,8 +7374,7 @@ - - if (symbol === EOF) { + if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -7244,8 +7386,7 @@ - - --stack_probe; // popStack(1): [symbol, action] + --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -7262,8 +7403,7 @@ - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -7277,8 +7417,7 @@ - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } @@ -7292,7 +7431,7 @@ // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -7345,16 +7484,13 @@ - - - - // handle parse error + // handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -7388,9 +7524,7 @@ - - - r = this.parseError(p.errStr, p, this.JisonParserError); + r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -7413,9 +7547,7 @@ - - - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -7442,17 +7574,16 @@ - - } + } // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -7499,8 +7630,8 @@ recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -7512,8 +7643,7 @@ - - } else { + } else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -7531,6 +7661,7 @@ yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -7539,7 +7670,7 @@ - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -7550,7 +7681,7 @@ sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -7610,10 +7741,10 @@ // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -7648,9 +7779,7 @@ - - - // encountered another parse error? If so, break out to main loop + // encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -7663,7 +7792,7 @@ - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -7684,9 +7813,7 @@ - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7708,12 +7835,12 @@ // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -7722,7 +7849,7 @@ ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7763,7 +7890,7 @@ } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -7810,7 +7937,7 @@ // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -7828,21 +7955,19 @@ - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7876,14 +8001,15 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7893,6 +8019,7 @@ + } continue; // accept: @@ -7944,7 +8071,7 @@ // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -7960,9 +8087,7 @@ - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7991,7 +8116,7 @@ sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -8008,8 +8133,8 @@ symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -8020,8 +8145,8 @@ // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -8033,21 +8158,19 @@ - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -8078,14 +8201,15 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -8095,6 +8219,7 @@ + } continue; // accept: @@ -8147,8 +8272,7 @@ // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -8409,7 +8533,6 @@ * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -8426,10 +8549,10 @@ }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -8461,7 +8584,7 @@ JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -8503,7 +8626,9 @@ // // --------- END OF REPORT ----------- - EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -8589,7 +8714,7 @@ if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -8597,7 +8722,7 @@ msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -8610,7 +8735,7 @@ } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -8636,10 +8761,13 @@ * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -8662,7 +8790,6 @@ * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -8685,16 +8812,16 @@ * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -8716,7 +8843,6 @@ * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -8724,8 +8850,8 @@ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -8754,7 +8880,7 @@ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -8779,7 +8905,7 @@ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -8791,17 +8917,17 @@ } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -8895,7 +9021,7 @@ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -8916,7 +9042,6 @@ * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -8927,7 +9052,7 @@ this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -8938,15 +9063,15 @@ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -8980,8 +9105,8 @@ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -9014,9 +9139,9 @@ // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -9035,9 +9160,9 @@ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -9047,8 +9172,8 @@ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -9075,20 +9200,19 @@ * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -9128,17 +9252,19 @@ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -9147,7 +9273,7 @@ // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -9162,8 +9288,8 @@ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -9189,24 +9315,26 @@ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -9217,7 +9345,7 @@ // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -9239,8 +9367,8 @@ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -9262,8 +9390,7 @@ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -9407,21 +9534,21 @@ const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -9436,11 +9563,11 @@ len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -9459,13 +9586,13 @@ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -9489,13 +9616,13 @@ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -9510,8 +9637,8 @@ } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -9542,7 +9669,7 @@ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -9574,9 +9701,9 @@ }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -9605,7 +9732,7 @@ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -9623,7 +9750,7 @@ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -9648,7 +9775,6 @@ * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -9658,8 +9784,6 @@ this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -9668,7 +9792,7 @@ this.clear(); } - 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. @@ -9680,13 +9804,13 @@ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -9696,68 +9820,74 @@ } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -9782,7 +9912,7 @@ * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -9830,24 +9960,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9867,7 +9997,7 @@ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -9877,24 +10007,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9915,8 +10045,7 @@ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -9956,14 +10085,14 @@ * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -9979,9 +10108,9 @@ if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -9992,8 +10121,8 @@ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -10001,7 +10130,7 @@ state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -11691,7 +11820,7 @@ // The expanded regex sets which are equivalent to the given `\\{c}` escapes: // // `/\s/`: - const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; + const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; // `/\d/`: const DIGIT_SETSTR = '0-9'; // `/\w/`: @@ -11703,7 +11832,7 @@ // Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex function i2c(i) { - var c, x; + let c, x; switch (i) { case 10: @@ -11743,7 +11872,7 @@ || i > 0xFFF0 /* Unicode Specials, also in UTF16 */ || (i >= 0xD800 && i <= 0xDFFF) /* Unicode Supplementary Planes; we're TOAST in JavaScript as we're NOT UTF-16 but UCS-2! */ || String.fromCharCode(i).match(/[\u2028\u2029]/) /* Code compilation via `new Function()` does not like to see these, or rather: treats them as just another form of CRLF, which breaks your generated regex code! */ - ) { + ) { // Detail about a detail: // U+2028 and U+2029 are part of the `\s` regex escape code (`\s` and `[\s]` match either of these) and when placed in a JavaScript // source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report @@ -11751,11 +11880,10 @@ // Hence we MUST escape these buggers everywhere we go... x = i.toString(16); if (x.length >= 1 && i <= 0xFFFF) { - c = '0000' + x; - return '\\u' + c.substr(c.length - 4); - } else { - return '\\u{' + x + '}'; + c = '0000' + x; + return '\\u' + c.substr(c.length - 4); } + return '\\u{' + x + '}'; } return String.fromCharCode(i); } @@ -11764,18 +11892,18 @@ // Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating // this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a // `\\p{NAME}` shorthand to represent [part of] the bitarray: - var Pcodes_bitarray_cache = {}; - var Pcodes_bitarray_cache_test_order = []; + let Pcodes_bitarray_cache = {}; + let Pcodes_bitarray_cache_test_order = []; - // Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by + // Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. - var EscCode_bitarray_output_refs; + let EscCode_bitarray_output_refs; // now initialize the EscCodes_... table above: init_EscCode_lookup_table(); function init_EscCode_lookup_table() { - var s, bitarr, set2esc = {}, esc2bitarr = {}; + let s, bitarr, set2esc = {}, esc2bitarr = {}; // patch global lookup tables for the time being, while we calculate their *real* content in this function: EscCode_bitarray_output_refs = { @@ -11844,13 +11972,13 @@ }; updatePcodesBitarrayCacheTestOrder(); - } + } function updatePcodesBitarrayCacheTestOrder(opts) { - var t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var l = {}; - var user_has_xregexp = opts && opts.options && opts.options.xregexp; - var i, j, k, ba; + let t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let l = {}; + let user_has_xregexp = opts && opts.options && opts.options.xregexp; + let i, j, k, ba; // mark every character with which regex pcodes they are part of: for (k in Pcodes_bitarray_cache) { @@ -11860,12 +11988,12 @@ continue; } - var cnt = 0; + let cnt = 0; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { cnt++; if (!t[i]) { - t[i] = [k]; + t[i] = [ k ]; } else { t[i].push(k); } @@ -11875,27 +12003,27 @@ } // now dig out the unique ones: only need one per pcode. - // + // // We ASSUME every \\p{NAME} 'pcode' has at least ONE character - // in it that is ONLY matched by that particular pcode. + // in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode - // won't be tested during optimization. - // + // won't be tested during optimization. + // // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to // look for markers which match multiple escapes/pcodes for those // ones where a unique item isn't available... - var lut = []; - var done = {}; - var keys = Object.keys(Pcodes_bitarray_cache); + let lut = []; + let done = {}; + let keys = Object.keys(Pcodes_bitarray_cache); for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { k = t[i][0]; if (t[i].length === 1 && !done[k]) { assert__default['default'](l[k] > 0); - lut.push([i, k]); + lut.push([ i, k ]); done[k] = true; } } @@ -11906,19 +12034,19 @@ if (!user_has_xregexp && k.indexOf('\\p{') >= 0) { continue; } - + if (!done[k]) { assert__default['default'](l[k] > 0); // find a minimum span character to mark this one: - var w = Infinity; + let w = Infinity; var rv; ba = Pcodes_bitarray_cache[k]; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { - var tl = t[i].length; + let tl = t[i].length; if (tl > 1 && tl < w) { assert__default['default'](l[k] > 0); - rv = [i, k]; + rv = [ i, k ]; w = tl; } } @@ -11932,16 +12060,16 @@ // order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. - // + // // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more - // optimal minification of the regex set expression. - // + // optimal minification of the regex set expression. + // // This is a guestimate/heuristic only! lut.sort(function (a, b) { - var k1 = a[1]; - var k2 = b[1]; - var ld = l[k2] - l[k1]; + let k1 = a[1]; + let k2 = b[1]; + let ld = l[k2] - l[k1]; if (ld) { return ld; } @@ -11959,19 +12087,19 @@ // 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set. function set2bitarray(bitarr, s, opts) { - var orig = s; - var set_is_inverted = false; - var bitarr_orig; + let orig = s; + let set_is_inverted = false; + let bitarr_orig; function mark(d1, d2) { if (d2 == null) d2 = d1; - for (var i = d1; i <= d2; i++) { + for (let i = d1; i <= d2; i++) { bitarr[i] = true; } } function add2bitarray(dst, src) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (src[i]) { dst[i] = true; } @@ -11979,10 +12107,10 @@ } function eval_escaped_code(s) { - var c; + let c; // decode escaped code? If none, just take the character as-is if (s.indexOf('\\') === 0) { - var l = s.substr(0, 2); + let l = s.substr(0, 2); switch (l) { case '\\c': c = s.charCodeAt(2) - 'A'.charCodeAt(0) + 1; @@ -12000,7 +12128,7 @@ } c = parseInt(s, 16); if (c >= 0x10000) { - return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); + return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); } return String.fromCharCode(c); @@ -12044,7 +12172,7 @@ } if (s && s.length) { - var c1, c2; + let c1, c2; // inverted set? if (s[0] === '^') { @@ -12075,13 +12203,13 @@ c2 = c2[0]; s = s.substr(c2.length); // do we have this one cached already? - var pex = c1 + c2; - var ba4p = Pcodes_bitarray_cache[pex]; + let pex = c1 + c2; + let ba4p = Pcodes_bitarray_cache[pex]; if (!ba4p) { // expand escape: - var xr = new XRegExp__default['default']('[' + pex + ']'); // TODO: case-insensitive grammar??? + let xr = new XRegExp__default['default']('[' + pex + ']'); // TODO: case-insensitive grammar??? // rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`: - var xs = '' + xr; + let xs = '' + xr; // remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: xs = xs.substr(1, xs.length - 2); @@ -12116,7 +12244,7 @@ break; } } - var v1 = eval_escaped_code(c1); + let v1 = eval_escaped_code(c1); // propagate deferred exceptions = error reports. if (v1 instanceof Error) { return v1; @@ -12134,7 +12262,7 @@ } else { c2 = c2[0]; } - var v2 = eval_escaped_code(c2); + let v2 = eval_escaped_code(c2); // propagate deferred exceptions = error reports. if (v2 instanceof Error) { return v1; @@ -12157,12 +12285,12 @@ } // When we have marked all slots, '^' NEGATES the set, hence we flip all slots. - // + // // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. if (set_is_inverted) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (!bitarr[i]) { bitarr_orig[i] = true; } @@ -12181,10 +12309,10 @@ // below can be simple and fast: l[UNICODE_BASE_PLANE_MAX_CP + 1] = 1; // now reconstruct the regex set: - var rv = []; - var i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; - var bitarr_is_cloned = false; - var l_orig = l; + let rv = []; + let i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; + let bitarr_is_cloned = false; + let l_orig = l; if (output_inverted_variant) { // generate the inverted set, hence all unmarked slots are part of the output range: @@ -12198,8 +12326,7 @@ // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. // BUT... since we output the INVERTED set, we output the match-all set instead: return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` // BUT... since we output the INVERTED set, we output the match-nothing set instead: @@ -12231,9 +12358,9 @@ } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12260,7 +12387,7 @@ } } } - + i = 0; while (i <= UNICODE_BASE_PLANE_MAX_CP) { // find first character not in original set: @@ -12291,8 +12418,7 @@ // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. return '^\\S\\s'; } @@ -12322,9 +12448,9 @@ } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12376,11 +12502,11 @@ } assert__default['default'](rv.length); - var s = rv.join(''); + let s = rv.join(''); assert__default['default'](s); // Check if the set is better represented by one of the regex escapes: - var esc4s = EscCode_bitarray_output_refs.set2esc[s]; + let esc4s = EscCode_bitarray_output_refs.set2esc[s]; if (esc4s) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return '\\' + esc4s; @@ -12395,25 +12521,24 @@ // Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there; // ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`. function reduceRegexToSetBitArray(s, name, opts) { - var orig = s; + let orig = s; // propagate deferred exceptions = error reports. if (s instanceof Error) { return s; } - var l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var internal_state = 0; - var derr; + let l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let internal_state = 0; + let derr; while (s.length) { - var c1 = s.match(CHR_RE); + let c1 = s.match(CHR_RE); if (!c1) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"'); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12421,15 +12546,14 @@ // this is starting a set within the regex: scan until end of set! var set_content = []; while (s.length) { - var inner = s.match(SET_PART_RE); + let inner = s.match(SET_PART_RE); if (!inner) { inner = s.match(CHR_RE); if (!inner) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"'); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12443,9 +12567,8 @@ if (!c2) { // cope with illegal escape sequences too! return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error('regex set expression is broken in regex: ' + orig); } @@ -12529,10 +12652,9 @@ // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; assert__default['default'](s); assert__default['default'](!(s instanceof Error)); - re = new XRegExp__default['default']('[' + s + ']'); + let re = new XRegExp__default['default']('[' + s + ']'); re.test(s[0]); // One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` @@ -12557,25 +12679,24 @@ - // Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` + // Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! function produceOptimizedRegex4Set(bitarr) { // First try to produce a minimum regex from the bitarray directly: - var s1 = bitarray2set(bitarr, false, true); + let s1 = bitarray2set(bitarr, false, true); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s1.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s1; - } else { - s1 = '[' + s1 + ']'; } + s1 = '[' + s1 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s2 = bitarray2set(bitarr, true, true); + let s2 = bitarray2set(bitarr, true, true); if (s2[0] === '^') { s2 = s2.substr(1); @@ -12590,23 +12711,22 @@ // Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: - // + // // First try to produce a minimum regex from the bitarray directly: - var s3 = bitarray2set(bitarr, false, false); + let s3 = bitarray2set(bitarr, false, false); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s3.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s3; - } else { - s3 = '[' + s3 + ']'; } + s3 = '[' + s3 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s4 = bitarray2set(bitarr, true, false); + let s4 = bitarray2set(bitarr, true, false); if (s4[0] === '^') { s4 = s4.substr(1); @@ -12638,30 +12758,30 @@ var setmgmt = { - XREGEXP_UNICODE_ESCAPE_RE, - CHR_RE, - SET_PART_RE, - NOTHING_SPECIAL_RE, - SET_IS_SINGLE_PCODE_RE, - - UNICODE_BASE_PLANE_MAX_CP, - - WHITESPACE_SETSTR, - DIGIT_SETSTR, - WORDCHAR_SETSTR, - - set2bitarray, - bitarray2set, - produceOptimizedRegex4Set, - reduceRegexToSetBitArray, + XREGEXP_UNICODE_ESCAPE_RE, + CHR_RE, + SET_PART_RE, + NOTHING_SPECIAL_RE, + SET_IS_SINGLE_PCODE_RE, + + UNICODE_BASE_PLANE_MAX_CP, + + WHITESPACE_SETSTR, + DIGIT_SETSTR, + WORDCHAR_SETSTR, + + set2bitarray, + bitarray2set, + produceOptimizedRegex4Set, + reduceRegexToSetBitArray }; // Basic Lexer implemented using JavaScript regular expressions - var rmCommonWS$2 = helpers.rmCommonWS; - var mkIdentifier$3 = helpers.mkIdentifier; - var code_exec$1 = helpers.exec; + const rmCommonWS$2 = helpers.rmCommonWS; + const mkIdentifier$3 = helpers.mkIdentifier; + const code_exec = helpers.exec; - var version = '0.6.2-220'; // require('./package.json').version; + const version = '0.6.2-220'; // require('./package.json').version; @@ -12722,7 +12842,7 @@ exportAST: false, prettyCfg: true, pre_lex: undefined, - post_lex: undefined, + post_lex: undefined }; @@ -12740,23 +12860,23 @@ // Return a fresh set of options. /** @public */ function mkStdOptions(/*...args*/) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - var args = [].concat.apply([], arguments); + let opts = {}; + let args = [].concat.apply([], arguments); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(defaultJisonLexOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; for (var p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { @@ -12794,7 +12914,7 @@ function prepExportStructures(options) { // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -12815,8 +12935,8 @@ // Otherwise return the *parsed* lexer spec as it has // been processed through LexParser. function autodetectAndConvertToJSONformat(lexerSpec, options) { - var chk_l = null; - var ex1, err; + let chk_l = null; + let ex1, err; if (typeof lexerSpec === 'string') { if (options.json) { @@ -12868,9 +12988,9 @@ /should be separated/, /an error in one or more of your lexer regex rules/, /an error in your lexer epilogue/, - /unsupported definition type/, + /unsupported definition type/ ]; - var cmnerr = commonErrors.filter(function check(re) { + let cmnerr = commonErrors.filter(function check(re) { return e.message.match(re); }); if (cmnerr.length > 0) { @@ -12899,14 +13019,14 @@ // expand macros and convert matchers to RegExp's function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) { - var m, i, k, rule, action, conditions; - var active_conditions; + let m, i, k, rule, action, conditions; + let active_conditions; assert__default['default'](Array.isArray(dict.rules)); - var rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! - var newRules = []; - var macros = {}; - var regular_rule_count = 0; - var simple_rule_count = 0; + let rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! + let newRules = []; + let macros = {}; + let regular_rule_count = 0; + let simple_rule_count = 0; // Assure all options are camelCased: assert__default['default'](typeof opts.options['case-insensitive'] === 'undefined'); @@ -12916,7 +13036,7 @@ } if (opts.options.flex && rules.length > 0) { - rules.push(['.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']); + rules.push([ '.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */' ]); } // Depending on the location within the regex we need different expansions of the macros: @@ -12940,7 +13060,7 @@ return str; } - var routingCode = ['switch(yyrulenumber) {']; + let routingCode = [ 'switch(yyrulenumber) {' ]; for (i = 0; i < rules.length; i++) { rule = rules[i].slice(0); // shallow copy: do not modify input rules @@ -12994,7 +13114,7 @@ action = action.replace(/return\s*\(?'((?:\\'|[^']+)+)'\)?/g, tokenNumberReplacement); action = action.replace(/return\s*\(?"((?:\\"|[^"]+)+)"\)?/g, tokenNumberReplacement); - var code = ['\n/*! Conditions::']; + let code = [ '\n/*! Conditions::' ]; code.push(postprocessComment(active_conditions)); code.push('*/', '\n/*! Rule:: '); code.push(postprocessComment(rule[0])); @@ -13015,7 +13135,7 @@ // 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'. - var match_nr = /^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim()); + 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 ')); @@ -13042,7 +13162,7 @@ macros: macros, regular_rule_count: regular_rule_count, - simple_rule_count: simple_rule_count, + simple_rule_count: simple_rule_count }; } @@ -13055,14 +13175,13 @@ // 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. function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElsewhere_cb) { - var orig = s; + let orig = s; function errinfo() { if (name) { return 'macro [[' + name + ']]'; - } else { - return 'regex [[' + orig + ']]'; } + return 'regex [[' + orig + ']]'; } // propagate deferred exceptions = error reports. @@ -13070,19 +13189,18 @@ return s; } - var c1, c2; - var rv = []; - var derr; - var se; + let c1, c2; + let rv = []; + let derr; + let se; while (s.length) { c1 = s.match(CHR_RE$1); if (!c1) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -13092,15 +13210,14 @@ var l = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1); while (s.length) { - var inner = s.match(SET_PART_RE$1); + let inner = s.match(SET_PART_RE$1); if (!inner) { inner = s.match(CHR_RE$1); if (!inner) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -13114,9 +13231,8 @@ if (!c2) { // cope with illegal escape sequences too! return new Error(errinfo() + ': regex set expression is broken: "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error(errinfo() + ': regex set expression is broken: apparently unterminated'); } @@ -13177,7 +13293,7 @@ c2 = c2[0]; s = s.substr(c2.length); - var c3 = s[0]; + let c3 = s[0]; s = s.substr(c3.length); if (c3 === '}') { // possibly a macro name in there... Expand if possible: @@ -13230,7 +13346,7 @@ // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; + let re; re = new XRegExp__default['default'](s); re.test(s[0]); } catch (ex) { @@ -13246,11 +13362,11 @@ // expand macros within macros and cache the result function prepareMacros(dict_macros, opts) { - var macros = {}; + let macros = {}; // expand a `{NAME}` macro which exists inside a `[...]` set: function expandMacroInSet(i) { - var k, a, m; + let k, a, m; if (!macros[i]) { m = dict_macros[i]; @@ -13284,7 +13400,7 @@ a = m.split('{' + k + '}'); if (a.length > 1) { - var x = expandMacroInSet(k); + let x = expandMacroInSet(k); assert__default['default'](x); if (x instanceof Error) { m = x; @@ -13296,9 +13412,9 @@ } } - var mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); + let mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); - var s1; + let s1; // propagate deferred exceptions = error reports. if (mba instanceof Error) { @@ -13332,7 +13448,7 @@ } function expandMacroElsewhere(i) { - var m; + let m; if (macros[i].elsewhere == null) { m = dict_macros[i]; @@ -13367,13 +13483,13 @@ } function expandAllMacrosInSet(s) { - var i, x; + let i, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { for (i in macros) { if (macros.hasOwnProperty(i)) { - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroInSet(i); assert__default['default'](x); @@ -13395,7 +13511,7 @@ } function expandAllMacrosElsewhere(s) { - var i, x; + let i, x; // When we process the remaining macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13410,7 +13526,7 @@ for (i in macros) { if (macros.hasOwnProperty(i)) { // These are all submacro expansions, hence non-capturing grouping is applied: - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroElsewhere(i); assert__default['default'](x); @@ -13432,7 +13548,7 @@ } - var i; + let i; if (opts.debug) console.log('\n############## RAW macros: ', dict_macros); @@ -13463,13 +13579,13 @@ // expand macros in a regex; expands them recursively function expandMacros(src, macros, opts) { - var expansion_count = 0; + let expansion_count = 0; // By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! // Hence things should be easy in there: function expandAllMacrosInSet(s) { - var i, m, x; + let i, m, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { @@ -13477,7 +13593,7 @@ if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = m.in_set; @@ -13508,7 +13624,7 @@ } function expandAllMacrosElsewhere(s) { - var i, m, x; + let i, m, x; // When we process the main macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13524,7 +13640,7 @@ if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { // These are all main macro expansions, hence CAPTURING grouping is applied: x = m.elsewhere; @@ -13560,7 +13676,7 @@ // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! - var s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); + let s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); // propagate deferred exceptions = error reports. if (s2 instanceof Error) { throw s2; @@ -13585,8 +13701,8 @@ } function prepareStartConditions(conditions) { - var sc; - var hash = {}; + let sc; + let hash = {}; for (sc in conditions) { if (conditions.hasOwnProperty(sc)) { @@ -13600,22 +13716,22 @@ } function buildActions(dict, tokens, opts) { - var actions = [dict.actionInclude || '', 'var YYSTATE = YY_START;']; - var tok; - var toks = {}; - var caseHelper = []; + let actions = [ dict.actionInclude || '', 'var YYSTATE = YY_START;' ]; + let tok; + let toks = {}; + let caseHelper = []; // tokens: map/array of token numbers to token names for (tok in tokens) { - var idx = parseInt(tok); + let idx = parseInt(tok); if (idx && idx > 0) { toks[tokens[tok]] = idx; } } - var gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); + let gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); - var code = actions.join('\n'); + let code = actions.join('\n'); 'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function (yy) { code = code.replace(new RegExp('\\b(' + yy + ')\\b', 'g'), 'yy_.$1'); }); @@ -13633,7 +13749,7 @@ macros: gen.macros, // propagate these for debugging/diagnostic purposes regular_rule_count: gen.regular_rule_count, - simple_rule_count: gen.simple_rule_count, + simple_rule_count: gen.simple_rule_count }; } @@ -13644,7 +13760,7 @@ function generateErrorClass() { // --- START lexer error class --- - var prelude = `/** + const prelude = `/** * 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 @@ -13655,8 +13771,6 @@ * @nocollapse */ function JisonLexerError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -13673,9 +13787,9 @@ function JisonLexerError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -13736,8 +13850,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /** @constructor */ function RegExpLexer(dict, input, tokens, build_options) { - var opts; - var dump = false; + let opts; + let dump = false; function test_me(tweak_cb, description, src_exception, ex_callback) { opts = processGrammar(dict, tokens, build_options); @@ -13747,7 +13861,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (tweak_cb) { tweak_cb(); } - var source = generateModuleBody(opts); + let source = generateModuleBody(opts); try { // The generated code will always have the `lexer` variable declared at local scope // as `eval()` will use the local scope. @@ -13755,16 +13869,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // The compiled code will look something like this: // // ``` - // var lexer; + // let lexer; // bla bla... // ``` // // or // // ``` - // var lexer = { bla... }; + // const lexer = { bla... }; // ``` - var testcode = [ + let testcode = [ '// provide a local version for test purposes:', jisonLexerErrorDefinition, '', @@ -13772,14 +13886,33 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; '', source, '', + rmCommonWS$2` + // JISON INJECTED VALIDATION CODE + // which attempts to ascertain you have defined a minimal viable lexer at least: + if (typeof lexer === "undefined") { + throw new SyntaxError("user-defined lexer does not define the required 'lexer' instance."); + } + if (!lexer) { + throw new SyntaxError("user-defined lexer does not define a non-NULL 'lexer' instance."); + } + if (typeof lexer.setInput !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.setInput()' API function."); + } + if (typeof lexer.lex !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.lex()' API function."); + } + // END OF JISON INJECTED VALIDATION CODE + `, 'return lexer;' ].join('\n'); - var lexer = code_exec$1(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { + let lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { //console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$2(sourcecode); - var lexer_f = new Function('', sourcecode); + let lexer_f = new Function('', sourcecode); return lexer_f(); - }, opts.options, "lexer"); + }, Object.assign({}, opts.options, { + throwErrorOnCompileFailure: true + }), 'lexer'); if (!lexer) { throw new Error('no lexer defined *at all*?!'); @@ -13796,7 +13929,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // When we do NOT crash, we found/killed the problem area just before this call! if (src_exception && description) { - var msg = description; + let msg = description; if (typeof description === 'function') { msg = description(); } @@ -13805,8 +13938,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // patch the pre and post handlers in there, now that we have some live code to work with: if (opts.options) { - var pre = opts.options.pre_lex; - var post = opts.options.post_lex; + let pre = opts.options.pre_lex; + let post = opts.options.post_lex; // since JSON cannot encode functions, we'll have to do it manually now: if (typeof pre === 'function') { lexer.options.pre_lex = pre; @@ -13820,7 +13953,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (typeof opts.options.showSource === 'function') { opts.options.showSource(lexer, source, opts, RegExpLexer); } else { - console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n"); + console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n', source, '\n----------------------------------------\n'); } } return lexer; @@ -13839,13 +13972,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } /** @constructor */ - var lexer = test_me(null, null, null, function (ex) { + let lexer = test_me(null, null, null, function (ex) { // When we get an exception here, it means some part of the user-specified lexer is botched. // // Now we go and try to narrow down the problem area/category: assert__default['default'](opts.options); assert__default['default'](opts.options.xregexp !== undefined); - var orig_xregexp_opt = !!opts.options.xregexp; + let orig_xregexp_opt = !!opts.options.xregexp; if (!test_me(function () { assert__default['default'](opts.options.xregexp !== undefined); opts.options.xregexp = false; @@ -13864,7 +13997,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; 'Your custom lexer is somehow botched.' ); }, ex, null)) { - var rulesSpecSize; + let rulesSpecSize; if (!test_me(function () { // store the parsed rule set size so we can use that info in case // this attempt also fails: @@ -13877,7 +14010,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; opts.__in_rules_failure_analysis_mode__ = true; }, 'One or more of your lexer rules are possibly botched?', ex, null)) { // kill each rule action block, one at a time and test again after each 'edit': - var rv = false; + let rv = false; for (var i = 0, len = rulesSpecSize; i < len; i++) { var lastEditedRuleSpec; rv = test_me(function () { @@ -13889,10 +14022,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // opts.__in_rules_failure_analysis_mode__ = true; // nuke all rules' actions up to and including rule numero `i`: - for (var j = 0; j <= i; j++) { + for (let j = 0; j <= i; j++) { // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; // now we want to edit the *action* part: - var rule = opts.rules[j]; + let rule = opts.rules[j]; assert__default['default'](Array.isArray(rule)); assert__default['default'](rule.length === 2 || rule.length === 3); rule.pop(); @@ -14026,8 +14159,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -14037,14 +14168,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\\n\\s*$/.test(msg)) { msg += '\\n'; } msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') { msg += '\\n' + pos_str; @@ -14055,14 +14186,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the \`upcomingInput\` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -14082,9 +14213,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -14104,8 +14234,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -14126,16 +14254,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -14156,8 +14282,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -14165,8 +14289,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -14184,8 +14308,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -14195,14 +14317,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -14213,8 +14335,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -14222,40 +14342,40 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -14267,7 +14387,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -14275,7 +14395,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -14336,9 +14456,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -14357,8 +14475,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set \`done\` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -14367,7 +14483,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -14377,13 +14493,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\\n') { lines = true; } else if (ch === '\\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\\n') { slice_len++; ch += ch2; @@ -14415,10 +14531,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -14450,8 +14564,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Get last entirely matched line into the \`pre_lines[]\` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -14469,9 +14583,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -14481,14 +14595,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -14499,8 +14611,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -14513,19 +14623,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the \`parseError()\` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // \`.lex()\` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -14538,8 +14646,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -14562,24 +14668,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substr\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14591,8 +14697,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to \`maxSize\` (default: 20). @@ -14618,24 +14724,25 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > \`lookAhead()\` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substring\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -14644,7 +14751,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14663,10 +14770,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^'; }, @@ -14688,15 +14793,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -14827,58 +14930,54 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\\t/g, ' '); @@ -14887,13 +14986,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -14915,15 +15014,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -14935,8 +15032,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -14965,13 +15062,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -15000,10 +15091,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -15031,7 +15122,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -15042,7 +15133,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -15064,8 +15155,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -15074,17 +15163,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -15094,67 +15179,75 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that \`parseError()\` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) \`parseError()\` @@ -15181,9 +15274,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15226,24 +15317,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15263,9 +15354,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15275,24 +15364,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15300,7 +15389,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this._clear_state = 0; } - + return r; }, @@ -15313,9 +15402,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -15323,7 +15410,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -15338,8 +15425,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -15351,8 +15436,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -15366,15 +15449,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -15386,14 +15466,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -15404,16 +15481,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -15423,8 +15498,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; } }`; @@ -15456,18 +15529,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // ............................. ${opt.lexerActionsUseDisplayAPIs} // uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC} - var new_src; + let new_src; try { - var ast = helpers.parseCodeChunkToAST(src, opt); + let ast = helpers.parseCodeChunkToAST(src, opt); new_src = helpers.prettyPrintAST(ast, opt); - } - catch (ex) { + } catch (ex) { let line = ex.lineNumber || 0; let a = src.split(/\r?\n/g); let len = a.length; let minl = Math.max(0, line - 10); let b = a.slice(minl, line + 10); - let c = b.splice(line - minl, 0, "", "^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", ""); + let c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); let offendingChunk = ' ' + b.join('\n '); console.error(rmCommonWS$2` stripUnusedLexerCode WARNING: @@ -15483,17 +15555,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; ${offendingChunk} `); - + new_src = src; } - - - - - - // inject analysis report now: new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2` // Code Generator Information Report @@ -15548,7 +15614,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // generate lexer source from a grammar /** @public */ function generate(dict, tokens, build_options) { - var opt = processGrammar(dict, tokens, build_options); + let opt = processGrammar(dict, tokens, build_options); return generateFromOpts(opt); } @@ -15557,7 +15623,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /** @public */ function processGrammar(dict, tokens, build_options) { build_options = build_options || {}; - var opts = { + let opts = { // include the knowledge passed through `build_options` about which lexer // features will actually be *used* by the environment (which in 99.9% // of cases is a jison *parser*): @@ -15597,7 +15663,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; lexerActionsUseReject: '???', lexerActionsUseLess: '???', lexerActionsUseDisplayAPIs: '???', - lexerActionsUseDescribeYYLOC: '???', + lexerActionsUseDescribeYYLOC: '???' }; dict = autodetectAndConvertToJSONformat(dict, build_options) || {}; @@ -15622,7 +15688,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // only produce rule action code blocks when there are any rules at all; // a "custom lexer" has ZERO rules and must be defined entirely in // other code blocks: - var code = (dict.rules ? buildActions(dict, tokens, opts) : {}); + let code = (dict.rules ? buildActions(dict, tokens, opts) : {}); opts.performAction = code.actions; opts.caseHelperInclude = code.caseHelperInclude; opts.rules = code.rules || []; @@ -15631,7 +15697,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; opts.regular_rule_count = code.regular_rule_count; opts.simple_rule_count = code.simple_rule_count; - opts.conditionStack = ['INITIAL']; + opts.conditionStack = [ 'INITIAL' ]; opts.actionInclude = (dict.actionInclude || ''); opts.moduleInclude = (opts.moduleInclude || '') + (dict.moduleInclude || '').trim(); @@ -15642,7 +15708,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Assemble the final source from the processed grammar /** @public */ function generateFromOpts(opt) { - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -15665,12 +15731,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function generateRegexesInitTableCode(opt) { - var a = opt.rules; - var print_xregexp = opt.options && opt.options.xregexp; - var id_display_width = (1 + Math.log10(a.length | 1) | 0); - var ws_prefix = new Array(id_display_width).join(' '); - var b = a.map(function generateXRegExpInitCode(re, idx) { - var idx_str = (ws_prefix + idx).substr(-id_display_width); + let a = opt.rules; + let print_xregexp = opt.options && opt.options.xregexp; + let id_display_width = (1 + Math.log10(a.length | 1) | 0); + let ws_prefix = new Array(id_display_width).join(' '); + let b = a.map(function generateXRegExpInitCode(re, idx) { + let idx_str = (ws_prefix + idx).substr(-id_display_width); if (re instanceof XRegExp__default['default']) { // When we don't need the special XRegExp sauce at run-time, we do with the original @@ -15680,11 +15746,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // And make sure to escape the regex to make it suitable for placement inside a *string* // as it is passed as a string argument to the XRegExp constructor here. - var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); + let re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); return `/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`; - } else { - return `/* ${idx_str}: */ ${re}`; } + return `/* ${idx_str}: */ ${re}`; + }); return b.join(',\n'); } @@ -15692,77 +15758,77 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateModuleBody(opt) { // make the JSON output look more like JavaScript: function cleanupJSON(str) { - str = str.replace(/ "rules": \[/g, ' rules: ['); - str = str.replace(/ "inclusive": /g, ' inclusive: '); + str = str.replace(/ {2}"rules": \[/g, ' rules: ['); + str = str.replace(/ {2}"inclusive": /g, ' inclusive: '); return str; } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - json: 1, - _: 1, - noMain: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - lexerErrorsAreRecoverable: 0, - flex: 0, - backtrack_lexer: 0, - caseInsensitive: 0, - showSource: 1, - exportAST: 1, - exportAllTables: 1, - exportSourceCode: 1, - prettyCfg: 1, - parseActionsUseYYLENG: 1, - parseActionsUseYYLINENO: 1, - parseActionsUseYYTEXT: 1, - parseActionsUseYYLOC: 1, - parseActionsUseParseError: 1, - parseActionsUseYYERROR: 1, - parseActionsUseYYRECOVERING: 1, - parseActionsUseYYERROK: 1, - parseActionsUseYYCLEARIN: 1, - parseActionsUseValueTracking: 1, - parseActionsUseValueAssignment: 1, - parseActionsUseLocationTracking: 1, - parseActionsUseLocationAssignment: 1, - parseActionsUseYYSTACK: 1, - parseActionsUseYYSSTACK: 1, - parseActionsUseYYSTACKPOINTER: 1, - parseActionsUseYYRULELENGTH: 1, - parseActionsUseYYMERGELOCATIONINFO: 1, - parserHasErrorRecovery: 1, - parserHasErrorReporting: 1, - lexerActionsUseYYLENG: 1, - lexerActionsUseYYLINENO: 1, - lexerActionsUseYYTEXT: 1, - lexerActionsUseYYLOC: 1, - lexerActionsUseParseError: 1, - lexerActionsUseYYERROR: 1, - lexerActionsUseLocationTracking: 1, - lexerActionsUseMore: 1, - lexerActionsUseUnput: 1, - lexerActionsUseReject: 1, - lexerActionsUseLess: 1, - lexerActionsUseDisplayAPIs: 1, - lexerActionsUseDescribeYYLOC: 1, + let obj = {}; + const do_not_pass = { + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + json: 1, + _: 1, + noMain: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + lexerErrorsAreRecoverable: 0, + flex: 0, + backtrack_lexer: 0, + caseInsensitive: 0, + showSource: 1, + exportAST: 1, + exportAllTables: 1, + exportSourceCode: 1, + prettyCfg: 1, + parseActionsUseYYLENG: 1, + parseActionsUseYYLINENO: 1, + parseActionsUseYYTEXT: 1, + parseActionsUseYYLOC: 1, + parseActionsUseParseError: 1, + parseActionsUseYYERROR: 1, + parseActionsUseYYRECOVERING: 1, + parseActionsUseYYERROK: 1, + parseActionsUseYYCLEARIN: 1, + parseActionsUseValueTracking: 1, + parseActionsUseValueAssignment: 1, + parseActionsUseLocationTracking: 1, + parseActionsUseLocationAssignment: 1, + parseActionsUseYYSTACK: 1, + parseActionsUseYYSSTACK: 1, + parseActionsUseYYSTACKPOINTER: 1, + parseActionsUseYYRULELENGTH: 1, + parseActionsUseYYMERGELOCATIONINFO: 1, + parserHasErrorRecovery: 1, + parserHasErrorReporting: 1, + lexerActionsUseYYLENG: 1, + lexerActionsUseYYLINENO: 1, + lexerActionsUseYYTEXT: 1, + lexerActionsUseYYLOC: 1, + lexerActionsUseParseError: 1, + lexerActionsUseYYERROR: 1, + lexerActionsUseLocationTracking: 1, + lexerActionsUseMore: 1, + lexerActionsUseUnput: 1, + lexerActionsUseReject: 1, + lexerActionsUseLess: 1, + lexerActionsUseDisplayAPIs: 1, + lexerActionsUseDescribeYYLOC: 1 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -15773,8 +15839,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // And now some options which should receive some special processing: - var pre = obj.pre_lex; - var post = obj.post_lex; + let pre = obj.pre_lex; + let post = obj.post_lex; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_lex = true; @@ -15783,7 +15849,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; obj.post_lex = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$1})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_lex: true(,)?$/gm, function (m, ls, tc) { @@ -15796,17 +15862,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } - var out; + let out; if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) { // we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. - var code = [rmCommonWS$2` - var lexer = { - `, '/*JISON-LEX-ANALYTICS-REPORT*/' /* slot #1: placeholder for analysis report further below */ + let code = [ rmCommonWS$2` + const lexer = { + `, '/* JISON-LEX-ANALYTICS-REPORT */\n' /* slot #1: placeholder for analysis report further below */ ]; // get the RegExpLexer.prototype in source code form: - var protosrc = getRegExpLexerPrototype(); + let protosrc = getRegExpLexerPrototype(); // and strip off the surrounding bits we don't want: protosrc = protosrc .replace(/^[\s\r\n]*\{/, '') @@ -15833,10 +15899,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } */ - var performActionCode = String(opt.performAction); - var simpleCaseActionClustersCode = String(opt.caseHelperInclude); - var rulesCode = generateRegexesInitTableCode(opt); - var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); + let performActionCode = String(opt.performAction); + let simpleCaseActionClustersCode = String(opt.caseHelperInclude); + let rulesCode = generateRegexesInitTableCode(opt); + let conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); code.push(rmCommonWS$2`, JisonLexerError: JisonLexerError, performAction: ${performActionCode}, @@ -15856,9 +15922,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // - // Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter + // Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. - out = 'var lexer;\n'; + out = '\n'; assert__default['default'](opt.regular_rule_count === 0); assert__default['default'](opt.simple_rule_count === 0); @@ -15872,8 +15938,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // The output of this function is guaranteed to read something like this: // // ``` - // var lexer; - // // bla bla bla bla ... lotsa bla bla; // ``` // @@ -15882,7 +15946,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function generateGenericHeaderComment() { - var out = rmCommonWS$2` + let out = rmCommonWS$2` /* lexer generated by jison-lex ${version} */ /* @@ -16111,7 +16175,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else { @@ -16129,9 +16193,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -16154,9 +16218,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateAMDModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} define([], function () { @@ -16179,12 +16243,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateESModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} - var lexer = (function () { + const lexer = (function () { "use strict"; ${jisonLexerErrorDefinition} @@ -16213,9 +16277,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateCommonJSModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -16257,7 +16321,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // 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. function JisonParserError$1(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -16274,9 +16337,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -16309,10 +16372,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // helper: reconstruct the productions[] table function bp$1(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -16327,18 +16390,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // helper: reconstruct the 'goto' table function bt$1(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -16369,7 +16432,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // `this` references an array function s$1(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -16386,9 +16449,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$1(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -16401,7 +16464,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } - var parser$1 = { + let parser$1 = { // Code Generator Information Report // --------------------------------- // @@ -16527,7 +16590,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -16535,7 +16597,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -16547,8 +16608,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -16561,14 +16622,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -16584,10 +16644,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -16595,10 +16655,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -16642,9 +16702,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; @@ -16652,17 +16712,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 0: /*! Production:: $accept : production $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-) break; case 1: /*! Production:: production : handle EOF */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-) return yyvstack[yysp - 1]; @@ -16898,7 +16958,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; 19: 3 }, parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -16915,37 +16974,32 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } }, parse: function parse(input) { + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks + let vstack = new Array(128); // semantic value stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks - - + let symbol = 0; - var symbol = 0; + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -16953,20 +17007,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -16983,7 +17035,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -16991,18 +17042,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -17010,18 +17062,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -17043,7 +17091,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -17056,7 +17103,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -17070,11 +17116,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -17128,8 +17173,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -17278,8 +17323,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -17288,10 +17332,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; token_id: symbol, line: lexer.yylineno, - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -17299,7 +17343,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -17310,9 +17354,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -17338,8 +17387,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -17348,21 +17396,20 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -17372,21 +17419,20 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -17395,20 +17441,20 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; try { @@ -17421,7 +17467,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -17474,14 +17520,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - - // handle parse error + // handle parse error if (!action) { - var errStr; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let errStr; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); // Report error errStr = 'Parse error'; @@ -17518,9 +17561,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -17549,7 +17590,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -17591,21 +17632,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - r = this.performAction.call(yyval, newState, sp - 1, vstack); + r = this.performAction.call(yyval, newState, sp - 1, vstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -17636,14 +17675,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -17653,6 +17693,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; + } continue; // accept: @@ -17705,8 +17746,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -17966,7 +18006,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -17983,10 +18022,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -18018,7 +18057,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -18060,7 +18099,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // --------- END OF REPORT ----------- - EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -18146,7 +18187,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -18154,7 +18195,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -18167,7 +18208,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -18193,10 +18234,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -18219,7 +18263,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -18242,16 +18285,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -18273,7 +18316,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -18281,8 +18323,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -18311,7 +18353,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -18336,7 +18378,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -18348,17 +18390,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -18452,7 +18494,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -18473,7 +18515,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -18484,7 +18525,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -18495,15 +18536,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -18537,8 +18578,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -18571,9 +18612,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -18592,9 +18633,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -18604,8 +18645,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -18632,20 +18673,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -18685,17 +18725,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -18704,7 +18746,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -18719,8 +18761,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -18746,24 +18788,26 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -18774,7 +18818,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -18796,8 +18840,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -18819,8 +18863,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -18964,21 +19007,21 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -18993,11 +19036,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -19016,13 +19059,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -19046,13 +19089,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -19067,8 +19110,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -19099,7 +19142,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -19131,9 +19174,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -19162,7 +19205,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -19180,7 +19223,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -19205,7 +19248,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -19215,8 +19257,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -19225,7 +19265,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.clear(); } - 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. @@ -19237,13 +19277,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -19253,68 +19293,74 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -19339,7 +19385,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -19387,24 +19433,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -19424,7 +19470,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -19434,24 +19480,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -19472,8 +19518,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -19513,14 +19558,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -19536,9 +19581,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -19549,8 +19594,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -19558,7 +19603,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -19711,9 +19756,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // guaranteed not to collide with previously generated / already existing // rules (~ symbols). function generateUniqueSymbol(id, postfix, opts) { - var sym = id + postfix; + let sym = id + postfix; if (opts.grammar[sym]) { - var i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. + let i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. do { sym = id + postfix + i; i++; @@ -19723,8 +19768,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function generatePushAction(handle, offset) { - var terms = handle.terms; - var rv = []; + const terms = handle.terms; + let rv = []; for (var i = 0, len = terms.length; i < len; i++) { rv.push('$' + (i + offset)); @@ -19740,11 +19785,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function transformExpression(e, opts, emit) { - var type = e[0], - value = e[1], - name = false, - has_transformed = 0; - var list, n; + let type = e[0]; + let value = e[1]; + let name = false; + let has_transformed = 0; + let list, n; if (type === 'xalias') { type = e[1]; @@ -19771,7 +19816,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ list.fragment, @@ -19791,7 +19836,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ '', @@ -19811,7 +19856,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); // you want to be able to check if 0 or 1 occurrences were recognized: since jison // by default *copies* the lexer token value, i.e. `$$ = $1` is the (optional) default action, // we will need to set the action up explicitly in case of the 0-count match: @@ -19847,7 +19892,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; opts = optsForProduction(name, opts.grammar); opts.grammar[name] = value.map(function (handle) { - var list = transformExpressionList(handle, opts); + let list = transformExpressionList(handle, opts); return [ list.fragment, '$$ = ' + generatePushAction(list, 1) + ';' @@ -19860,11 +19905,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function transformExpressionList(list, opts) { - var first_transformed_term_index = false; - var terms = list.reduce(function (tot, e) { - var ci = tot.length; + let first_transformed_term_index = false; + let terms = list.reduce(function (tot, e) { + let ci = tot.length; - var has_transformed = transformExpression(e, opts, function (name) { + let has_transformed = transformExpression(e, opts, function (name) { if (name.terms) { tot.push.apply(tot, name.terms); } else { @@ -19893,42 +19938,42 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function transformProduction(id, production, grammar) { - var transform_opts = optsForProduction(id, grammar); + let transform_opts = optsForProduction(id, grammar); return production.map(function (handle) { - var action = null, - opts = null; - var i, len, n; + let action = null; + let opts = null; + let i, len, n; if (typeof handle !== 'string') { action = handle[1]; opts = handle[2]; handle = handle[0]; } - var expressions = handle; + let expressions = handle; if (typeof expressions === 'string') { expressions = parser$2.parse(handle); } - var list = transformExpressionList(expressions, transform_opts); + let list = transformExpressionList(expressions, transform_opts); - var ret = [list.fragment]; + let ret = [ list.fragment ]; if (action) { // make sure the action doesn't address any inner items. if (list.first_transformed_term_index) { // seek out all names and aliases; strip out literal tokens first as those cannot serve as $names: - var alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); + let alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); - var alias_re = new XRegExp__default['default'](`\\[${ID_REGEX_BASE$2}\\]`); - var term_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$2}$`); + let alias_re = new XRegExp__default['default'](`\\[${ID_REGEX_BASE$2}\\]`); + let term_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$2}$`); // and collect the PERMITTED aliases: the names of the terms and all the remaining aliases - var good_aliases = {}; - var alias_cnt = {}; - var donotalias = {}; + let good_aliases = {}; + let alias_cnt = {}; + let donotalias = {}; // WARNING: this replicates the knowledge/code of jison.js::addName() - var addName = function addNameEBNF(s, i) { - var base = s.replace(/[0-9]+$/, ''); - var dna = donotalias[base]; + let addName = function addNameEBNF(s, i) { + let base = s.replace(/[0-9]+$/, ''); + let dna = donotalias[base]; if (good_aliases[s]) { alias_cnt[s]++; @@ -19947,7 +19992,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; // WARNING: this replicates the knowledge/code of jison.js::markBasename() - var markBasename = function markBasenameEBNF(s) { + let markBasename = function markBasenameEBNF(s) { if (/[0-9]$/.test(s)) { s = s.replace(/[0-9]+$/, ''); donotalias[s] = true; @@ -19984,13 +20029,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now scan the action for all named and numeric semantic values ($nonterminal / $1 / @1, ##1, ...) // // Note that `#name` are straight **static** symbol translations, which are okay as they don't - // require access to the parse stack: `#n` references can be resolved completely + // require access to the parse stack: `#n` references can be resolved completely // at grammar compile time. // - var nameref_re = new XRegExp__default['default'](`(?:[$@]|##)${ID_REGEX_BASE$2}`, 'g'); - var named_spots = nameref_re.exec(action); - var numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); - var max_term_index = list.terms.length; + let nameref_re = new XRegExp__default['default'](`(?:[$@]|##)${ID_REGEX_BASE$2}`, 'g'); + let named_spots = nameref_re.exec(action); + let numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); + let max_term_index = list.terms.length; // loop through the XRegExp alias regex matches in `action` while (named_spots) { @@ -20020,7 +20065,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; for (i = 0, len = numbered_spots.length; i < len; i++) { n = parseInt(numbered_spots[i].replace(/^(?:[$@]|##)/, '')); if (n > max_term_index) { - /* @const */ var n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; + /* @const */ let n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; throw new Error('The action block references the ' + n + n_suffixes[Math.max(0, Math.min(3, n - 1))] + ' term, ' + 'which is not available in production "' + handle + '"; ' + 'Be reminded that you cannot reference sub-elements within EBNF */+/? groups, ' + @@ -20038,13 +20083,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (ret.length === 1) { return ret[0]; - } else { - return ret; } + return ret; + }); } - var ref_list; - var ref_names; + + let ref_list; + let ref_names; // create a deep copy of the input, so we will keep the input constant. function deepClone(from, sub) { @@ -20059,7 +20105,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return from; } - var idx = ref_list.indexOf(from); + let idx = ref_list.indexOf(from); if (idx >= 0) { throw new Error('[Circular/Xref:' + ref_names[i] + ']'); // circular or cross reference } @@ -20075,7 +20121,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; sub += '.'; var to = new from.constructor(); - for (var name in from) { + for (let name in from) { to[name] = deepClone(from[name], sub + name); } } @@ -20091,8 +20137,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return grammar; } + function transform(ebnf) { - var rv = transformGrammar(ebnf); + let rv = transformGrammar(ebnf); return rv; } @@ -20102,7 +20149,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // 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. function JisonParserError$2(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -20119,9 +20165,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -20154,10 +20200,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // helper: reconstruct the productions[] table function bp$2(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -20170,11 +20216,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // helper: reconstruct the defaultActions[] table function bda$1(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -20184,18 +20230,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // helper: reconstruct the 'goto' table function bt$2(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -20226,7 +20272,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // `this` references an array function s$2(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -20243,9 +20289,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$2(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -20258,7 +20304,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } - var parser$3 = { + let parser$3 = { // Code Generator Information Report // --------------------------------- // @@ -20494,7 +20540,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -20502,7 +20547,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -20514,8 +20558,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -20528,14 +20572,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -20551,10 +20594,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -20562,10 +20605,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -20746,26 +20789,26 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; switch (yystate) { case 0: /*! Production:: $accept : spec $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break; case 1: /*! Production:: spec : declaration_list "%%" grammar optional_end_block EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4]; @@ -20777,10 +20820,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 2: /*! Production:: spec : declaration_list "%%" grammar error EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -20799,10 +20842,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 3: /*! Production:: spec : declaration_list error EOF */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -20824,9 +20867,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 133: /*! Production:: optional_module_code_chunk : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -20835,9 +20878,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 5: /*! Production:: optional_end_block : "%%" extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20857,9 +20900,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 10: /*! Production:: declaration_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; @@ -20870,9 +20913,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 8: /*! Production:: optional_action_header_block : optional_action_header_block include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -20891,9 +20934,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 9: /*! Production:: declaration_list : declaration_list declaration */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20902,10 +20945,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 11: /*! Production:: declaration_list : declaration_list error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -20920,9 +20963,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 12: /*! Production:: declaration : START id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {start: yyvstack[yysp]}; @@ -20931,9 +20974,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 13: /*! Production:: declaration : LEX_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {lex: {text: yyvstack[yysp], position: yylstack[yysp]}}; @@ -20942,9 +20985,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 14: /*! Production:: declaration : operator */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {operator: yyvstack[yysp]}; @@ -20953,9 +20996,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 15: /*! Production:: declaration : TOKEN full_token_definitions */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {token_list: yyvstack[yysp]}; @@ -20964,9 +21007,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 16: /*! Production:: declaration : ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -20984,9 +21027,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 17: /*! Production:: declaration : include_macro_code */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21004,9 +21047,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 18: /*! Production:: declaration : parse_params */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parseParams: yyvstack[yysp]}; @@ -21015,9 +21058,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 19: /*! Production:: declaration : parser_type */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parserType: yyvstack[yysp]}; @@ -21026,9 +21069,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 20: /*! Production:: declaration : options */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: yyvstack[yysp]}; @@ -21037,9 +21080,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 21: /*! Production:: declaration : DEBUG */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: [['debug', true]]}; @@ -21048,9 +21091,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 22: /*! Production:: declaration : EBNF */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) ebnf = true; @@ -21060,9 +21103,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 23: /*! Production:: declaration : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {unknownDecl: yyvstack[yysp]}; @@ -21071,9 +21114,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 24: /*! Production:: declaration : IMPORT import_name import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = {imports: {name: yyvstack[yysp - 1], path: yyvstack[yysp]}}; @@ -21082,10 +21125,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 25: /*! Production:: declaration : IMPORT import_name error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21101,10 +21144,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 26: /*! Production:: declaration : IMPORT error import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21120,9 +21163,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 27: /*! Production:: declaration : INIT_CODE init_code_name action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21145,10 +21188,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 28: /*! Production:: declaration : INIT_CODE error action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -21164,10 +21207,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 29: /*! Production:: declaration : START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21182,10 +21225,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 30: /*! Production:: declaration : TOKEN error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21200,10 +21243,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 31: /*! Production:: declaration : IMPORT error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21268,9 +21311,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 132: /*! Production:: optional_module_code_chunk : module_code_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -21281,9 +21324,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 111: /*! Production:: action_ne : "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21292,10 +21335,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 40: /*! Production:: options : OPTIONS error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21310,10 +21353,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 41: /*! Production:: options : OPTIONS error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21332,9 +21375,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 70: /*! Production:: id_list : id_list id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -21349,9 +21392,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 84: /*! Production:: handle_list : handle_action */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -21360,9 +21403,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 44: /*! Production:: option : NAME */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -21371,9 +21414,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 45: /*! Production:: option : NAME "=" OPTION_STRING_VALUE */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -21384,9 +21427,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 47: /*! Production:: option : NAME "=" NAME */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], parseValue$1(yyvstack[yysp])]; @@ -21395,10 +21438,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 48: /*! Production:: option : NAME "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21413,10 +21456,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 49: /*! Production:: option : NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21433,9 +21476,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 52: /*! Production:: parser_type : PARSER_TYPE symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -21444,10 +21487,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 51: /*! Production:: parse_params : PARSE_PARAM error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21465,10 +21508,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 53: /*! Production:: parser_type : PARSER_TYPE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21486,9 +21529,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 54: /*! Production:: operator : associativity token_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1]]; this.$.push.apply(this.$, yyvstack[yysp]); @@ -21497,10 +21540,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 55: /*! Production:: operator : associativity error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21518,9 +21561,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 56: /*! Production:: associativity : LEFT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'left'; @@ -21529,9 +21572,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 57: /*! Production:: associativity : RIGHT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'right'; @@ -21540,9 +21583,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 58: /*! Production:: associativity : NONASSOC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'nonassoc'; @@ -21551,9 +21594,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 61: /*! Production:: full_token_definitions : optional_token_type id_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var rv = []; @@ -21572,9 +21615,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 62: /*! Production:: full_token_definitions : optional_token_type one_full_token */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var m = yyvstack[yysp]; @@ -21587,9 +21630,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 63: /*! Production:: one_full_token : id token_value token_description */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21602,9 +21645,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 64: /*! Production:: one_full_token : id token_description */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21616,9 +21659,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 65: /*! Production:: one_full_token : id token_value */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -21630,9 +21673,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 66: /*! Production:: optional_token_type : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = false; @@ -21641,9 +21684,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 72: /*! Production:: grammar : optional_action_header_block production_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21653,9 +21696,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 73: /*! Production:: production_list : production_list production */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21669,9 +21712,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 74: /*! Production:: production_list : production */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; this.$[yyvstack[yysp][0]] = yyvstack[yysp][1]; @@ -21680,9 +21723,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 75: /*! Production:: production : production_id handle_list ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp - 1]]; @@ -21691,10 +21734,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 76: /*! Production:: production : production_id error ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21712,10 +21755,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 77: /*! Production:: production : production_id error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21733,9 +21776,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 78: /*! Production:: production_id : id optional_production_description ":" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21746,10 +21789,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 79: /*! Production:: production_id : id optional_production_description error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21767,10 +21810,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 80: /*! Production:: production_id : id optional_production_description ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21794,18 +21837,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 82: /*! Production:: optional_production_description : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) break; case 83: /*! Production:: handle_list : handle_list "|" handle_action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21815,10 +21858,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 85: /*! Production:: handle_list : handle_list "|" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21836,10 +21879,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 86: /*! Production:: handle_list : handle_list ":" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21854,9 +21897,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 87: /*! Production:: handle_action : handle prec action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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(' ') : '')]; @@ -21891,9 +21934,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 88: /*! Production:: handle_action : EPSILON action */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = ['']; @@ -21917,10 +21960,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 89: /*! Production:: handle_action : EPSILON error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -21935,9 +21978,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 90: /*! Production:: handle : handle suffixed_expression */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -21947,9 +21990,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 91: /*! Production:: handle : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -21958,9 +22001,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 92: /*! Production:: handle_sublist : handle_sublist "|" handle */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -21970,9 +22013,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 93: /*! Production:: handle_sublist : handle */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp].join(' ')]; @@ -21981,9 +22024,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 94: /*! Production:: suffixed_expression : expression suffix ALIAS */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + "[" + yyvstack[yysp] + "]"; @@ -21996,9 +22039,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 130: /*! Production:: module_code_chunk : module_code_chunk CODE */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22007,9 +22050,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 97: /*! Production:: expression : EOF_ID */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$end'; @@ -22018,9 +22061,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 98: /*! Production:: expression : STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // Re-encode the string *anyway* as it will @@ -22033,9 +22076,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 99: /*! Production:: expression : "(" handle_sublist ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1].join(' | ') + ')'; @@ -22044,10 +22087,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 100: /*! Production:: expression : "(" handle_sublist error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22061,9 +22104,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 105: /*! Production:: prec : PREC symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { prec: yyvstack[yysp] }; @@ -22072,10 +22115,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 106: /*! Production:: prec : PREC error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -22093,9 +22136,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 107: /*! Production:: prec : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = null; @@ -22104,10 +22147,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 112: /*! Production:: action_ne : "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22121,9 +22164,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 116: /*! Production:: action : ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$$ = (' + yyvstack[yysp] + ');'; @@ -22132,9 +22175,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 120: /*! Production:: action_body : action_body "{" action_body "}" action_comments_body */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4] + yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22143,9 +22186,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 121: /*! Production:: action_body : action_body "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22154,10 +22197,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 122: /*! Production:: action_body : action_body "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22171,9 +22214,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 126: /*! Production:: extra_parser_module_code : optional_module_code_chunk include_macro_code extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -22182,9 +22225,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 127: /*! Production:: include_macro_code : INCLUDE PATH */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' }); @@ -22204,10 +22247,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 128: /*! Production:: include_macro_code : INCLUDE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$3` @@ -22220,10 +22263,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 131: /*! Production:: module_code_chunk : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -23616,7 +23659,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -23633,38 +23675,34 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -23672,20 +23710,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -23707,7 +23743,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -23715,18 +23750,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -23734,24 +23770,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -23789,18 +23820,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); + let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -23821,7 +23849,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -23839,7 +23867,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -23852,7 +23879,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -23866,11 +23892,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -23924,8 +23949,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -23933,8 +23958,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -23966,19 +23991,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -23989,7 +24013,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -24002,7 +24026,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -24014,29 +24038,27 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -24044,7 +24066,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -24064,8 +24086,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -24074,10 +24095,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -24085,7 +24106,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -24096,9 +24117,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -24114,8 +24140,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -24184,11 +24209,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -24199,8 +24227,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -24209,21 +24236,20 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -24233,21 +24259,20 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -24256,28 +24281,27 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -24290,8 +24314,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; + const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -24314,8 +24337,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - if (symbol === EOF) { + if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -24327,8 +24349,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - --stack_probe; // popStack(1): [symbol, action] + --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -24345,8 +24366,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -24360,8 +24380,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } @@ -24375,7 +24394,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -24428,16 +24447,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - - // handle parse error + // handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -24471,9 +24487,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - r = this.parseError(p.errStr, p, this.JisonParserError); + r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -24496,9 +24510,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -24525,17 +24537,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - } + } // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -24582,8 +24593,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -24595,8 +24606,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - } else { + } else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -24614,6 +24624,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -24622,7 +24633,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -24633,7 +24644,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -24693,10 +24704,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -24731,9 +24742,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - // encountered another parse error? If so, break out to main loop + // encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -24746,7 +24755,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -24767,9 +24776,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -24791,12 +24798,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -24805,7 +24812,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -24846,7 +24853,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -24893,7 +24900,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -24911,21 +24918,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -24959,14 +24964,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -24976,6 +24982,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; + } continue; // accept: @@ -25027,7 +25034,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -25043,9 +25050,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -25074,7 +25079,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -25091,8 +25096,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -25103,8 +25108,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -25116,21 +25121,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -25161,14 +25164,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -25178,6 +25182,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; + } continue; // accept: @@ -25230,8 +25235,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -25492,7 +25496,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -25509,10 +25512,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -25544,7 +25547,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -25586,7 +25589,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // --------- END OF REPORT ----------- - EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -25672,7 +25677,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -25680,7 +25685,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -25693,7 +25698,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -25719,10 +25724,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -25745,7 +25753,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -25768,16 +25775,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -25799,7 +25806,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -25807,8 +25813,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -25837,7 +25843,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -25862,7 +25868,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -25874,17 +25880,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -25978,7 +25984,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -25999,7 +26005,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -26010,7 +26015,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -26021,15 +26026,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -26063,8 +26068,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -26097,9 +26102,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -26118,9 +26123,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -26130,8 +26135,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -26158,20 +26163,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -26211,17 +26215,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -26230,7 +26236,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -26245,8 +26251,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -26272,24 +26278,26 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -26300,7 +26308,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -26322,8 +26330,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -26345,8 +26353,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -26490,21 +26497,21 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -26519,11 +26526,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -26542,13 +26549,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -26572,13 +26579,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -26593,8 +26600,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -26625,7 +26632,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -26657,9 +26664,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -26688,7 +26695,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -26706,7 +26713,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -26731,7 +26738,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -26741,8 +26747,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -26751,7 +26755,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.clear(); } - 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. @@ -26763,13 +26767,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -26779,68 +26783,74 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -26865,7 +26875,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -26913,24 +26923,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -26950,7 +26960,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -26960,24 +26970,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -26998,8 +27008,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -27039,14 +27048,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -27062,9 +27071,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -27075,8 +27084,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -27084,7 +27093,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -28129,7 +28138,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; - var version$1 = '0.6.2-220'; // require('./package.json').version; + const version$1 = '0.6.2-220'; // require('./package.json').version; function parse(grammar) { return bnf.parser.parse(grammar); @@ -28195,7 +28204,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (decl.options) { if (!grammar.options) grammar.options = {}; // last occurrence of `%options` wins: - for (var i = 0; i < decl.options.length; i++) { + for (let i = 0; i < decl.options.length; i++) { grammar.options[decl.options[i][0]] = decl.options[i][1]; } } @@ -28235,9 +28244,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // which matches the original input file: position = position || {}; position.range = position.range || []; - var l = position.first_line | 0; - var c = position.range[0] | 0; - var prelude = ''; + let l = position.first_line | 0; + let c = position.range[0] | 0; + let prelude = ''; if (l > 1) { prelude += (new Array(l)).join('\n'); c -= prelude.length; @@ -28262,10 +28271,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; ebnf_parser, bnf_lexer: lexParser, - version: version$1, + version: version$1 }; - var rmCommonWS$4 = helpers.rmCommonWS; + const rmCommonWS$4 = helpers.rmCommonWS; /** @@ -28291,14 +28300,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 'json5': options.format = 'json5'; break; - + case '.y': case '.yacc': options.format = 'jison'; options.showLexer = false; options.showParser = true; break; - + case '.l': case '.lex': options.format = 'jison'; @@ -28320,20 +28329,20 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // which MAY get corrupted that way as their actual content would change then! // construct fake nesting levels to arrive at the intended start indent value: `num` - var nesting_levels = num / 2; - var pre = '// **PRE**', - post = '// **POST**'; - for ( ; nesting_levels > 0; nesting_levels--) { + let nesting_levels = num / 2; + let pre = '// **PRE**'; + let post = '// **POST**'; + for (; nesting_levels > 0; nesting_levels--) { pre = 'function x() {\n' + pre; post += '\n}'; } - src = '\n' + pre + '\n' + src + '\n' + post + '\n'; + src = '\n' + pre + '\n' + src + '\n' + post + '\n'; - var ast = helpers.parseCodeChunkToAST(src, options); - var new_src = helpers.prettyPrintAST(ast, options); + let ast = helpers.parseCodeChunkToAST(src, options); + let new_src = helpers.prettyPrintAST(ast, options); - var start = new_src.indexOf('// **PRE**'); - var end = new_src.lastIndexOf('// **POST**'); + let start = new_src.indexOf('// **PRE**'); + let end = new_src.lastIndexOf('// **POST**'); new_src = new_src .substring(start + 10, end) .trim(); @@ -28342,13 +28351,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function isEmptyObj(obj) { - var keys = obj && typeof obj === 'object' && Object.keys(obj); + let keys = obj && typeof obj === 'object' && Object.keys(obj); return keys && keys.length === 0; } function isEmptyArr(arr) { if (arr && arr instanceof Array) { - for (var i = 0, len = arr.length; i < len; i++) { + for (let i = 0, len = arr.length; i < len; i++) { if (arr[i] !== undefined) { return false; } @@ -28361,8 +28370,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Copied from Crokford's implementation of JSON // See https://github.com/douglascrockford/JSON-js/blob/e39db4b7e6249f04a195e7dd0840e610cc9e941e/json2.js#L195 // Begin - var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - meta = { // table of character substitutions + let escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; + let meta = { // table of character substitutions '\b': '\\b', '\t': '\\t', '\n': '\\n', @@ -28379,15 +28388,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // sequences. escapable.lastIndex = 0; return escapable.test(string) ? '"' + string.replace(escapable, function (a) { - var c = meta[a]; + let c = meta[a]; return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }) + '"' : '"' + string + '"'; } - var ref_list; - var ref_names; + let ref_list; + let ref_names; // create a deep copy of the input, so we can delete the parts we converted and dump the remainder // so that we always output the entire thing, even when we don't know all the details about the @@ -28404,7 +28413,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return from; } - for (var i = 0, len = ref_list.length; i < len; i++) { + for (let i = 0, len = ref_list.length; i < len; i++) { if (ref_list[i] === from) { return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference } @@ -28413,204 +28422,211 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; ref_names.push(sub); sub += '.'; - var to = new from.constructor(); - for (var name in from) { + let to = new from.constructor(); + for (let name in from) { to[name] = deepClone(from[name], sub + name); } return to; } - var originalInput = raw; + let originalInput = raw; raw = deepClone(raw); - var lex_out_str = ''; + let lex_out_str = ''; if (raw.lex) { var lex_pre = []; - var lex_rules = []; - var lex_post = []; - var key, src; + let lex_rules = []; + let lex_post = []; + + { + let src = raw.lex.macros; + delete raw.lex.macros; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // macros: + `); - src = raw.lex.macros; - delete raw.lex.macros; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // macros: - `); + let keylen = 0; + for (let key in src) { + keylen = Math.max(keylen, key.length); + } + console.log('macros keylen:', keylen); + keylen = ((keylen / 4) | 0) * 4 + 4; + console.log('macros keylen B:', keylen); + for (let key in src) { + lex_pre.push(padRight(key, keylen) + src[key]); + } - var keylen = 0; - for (key in src) { - keylen = Math.max(keylen, key.length); - } - console.log('macros keylen:', keylen); - keylen = ((keylen / 4) | 0) * 4 + 4; - console.log('macros keylen B:', keylen); - for (key in src) { - lex_pre.push(padRight(key, keylen) + src[key]); + lex_pre.push(rmCommonWS$4` + // END of the lexer macros. + `); } - - lex_pre.push(rmCommonWS$4` - // END of the lexer macros. - `); } - src = raw.lex.unknownDecls; - delete raw.lex.unknownDecls; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // unknown declarations: - `); + { + let src = raw.lex.unknownDecls; + delete raw.lex.unknownDecls; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // unknown declarations: + `); - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry.name; + let value = entry.value; - lex_pre.push('%' + key + ' ' + value); - } + lex_pre.push('%' + key + ' ' + value); + } - lex_pre.push(rmCommonWS$4` - // END of unknown declarations. - `); + lex_pre.push(rmCommonWS$4` + // END of unknown declarations. + `); + } } - src = raw.lex.options; - delete raw.lex.options; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // options: - `); + { + let src = raw.lex.options; + delete raw.lex.options; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // options: + `); - for (key in src) { - var value = src[key]; - if (value) { - lex_pre.push('%options ' + key + '=' + value); - } - else { - lex_pre.push('%options ' + key); + for (let key in src) { + let value = src[key]; + if (value) { + lex_pre.push('%options ' + key + '=' + value); + } else { + lex_pre.push('%options ' + key); + } } } } - src = raw.lex.startConditions; - delete raw.lex.startConditions; - if (src && !isEmptyObj(src)) { - for (key in src) { - var value = src[key]; + { + let src = raw.lex.startConditions; + delete raw.lex.startConditions; + if (src && !isEmptyObj(src)) { + for (let key in src) { + let value = src[key]; - lex_pre.push((value ? '%x ' : '%s ') + key); + lex_pre.push((value ? '%x ' : '%s ') + key); + } } } - src = raw.lex.actionInclude; - delete raw.lex.actionInclude; - if (src && src.trim()) { - lex_pre.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + { + let src = raw.lex.actionInclude; + delete raw.lex.actionInclude; + if (src && src.trim()) { + lex_pre.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + } } - src = raw.lex.rules; - delete raw.lex.rules; - if (src) { - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - key = entry[0]; - var action = indentAction(entry[1], 4); - - var actionHasLF = /[\r\n]/.test(action); - console.log('indented action:', { - entry: entry[1], - action, - actionHasLF - }); - if (key.length <= 12) { - if (!actionHasLF) { - lex_rules.push(padRight(key, 16) + indentAction(action, 16)); - } - else { - lex_rules.push(padRight(key, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); - } - } - else { - if (!actionHasLF) { + { + let src = raw.lex.rules; + delete raw.lex.rules; + if (src) { + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry[0]; + let action = indentAction(entry[1], 4); + + let actionHasLF = /[\r\n]/.test(action); + console.log('indented action:', { + entry: entry[1], + action, + actionHasLF + }); + if (key.length <= 12) { + if (!actionHasLF) { + lex_rules.push(padRight(key, 16) + indentAction(action, 16)); + } else { + lex_rules.push(padRight(key, 16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); + } + } else if (!actionHasLF) { lex_rules.push(key, makeIndent(16) + indentAction(action, 16)); - } - else { + } else { lex_rules.push(key, makeIndent(16) + '%' + indentAction('{ ' + action + ' }', 16) + '%'); } } } } - src = raw.lex.moduleInclude; - delete raw.lex.moduleInclude; - if (src && src.trim()) { - lex_post.push(indentAction(src.trim(), 0)); + { + let src = raw.lex.moduleInclude; + delete raw.lex.moduleInclude; + if (src && src.trim()) { + lex_post.push(indentAction(src.trim(), 0)); + } } - var out = ''; + { + let out = ''; - if (!isEmptyObj(raw.lex)) { - // dump the remainder as a comment: - var rem = JSON5__default['default'].stringify(raw.lex, null, 2); - out += rmCommonWS$4` - /* - * Lexer stuff that's unknown to the JISON prettyPrint service: - * - * ${rem.replace(/\*\//g, '*\\/')} - */ + if (!isEmptyObj(raw.lex)) { + // dump the remainder as a comment: + let rem = JSON5__default['default'].stringify(raw.lex, null, 2); + out += rmCommonWS$4` + /* + * Lexer stuff that's unknown to the JISON prettyPrint service: + * + * ${rem.replace(/\*\//g, '*\\/')} + */ - `; - } - delete raw.lex; - - out += lex_pre.join('\n') + '\n\n'; - out += rmCommonWS$4` - - %% + `; + } + delete raw.lex; - ` + lex_rules.join('\n') + '\n\n'; - if (lex_post.length > 0) { + out += lex_pre.join('\n') + '\n\n'; out += rmCommonWS$4` %% - ` + lex_post.join('\n') + '\n\n'; + ` + lex_rules.join('\n') + '\n\n'; + if (lex_post.length > 0) { + out += rmCommonWS$4` + + %% + + ` + lex_post.join('\n') + '\n\n'; + } + lex_out_str = out; } - lex_out_str = out; } - var grammar_pre = []; - var grammar_mid = []; - var ebnf_rules = []; - var bnf_rules = []; - var grammar_post = []; - var key, src; + let grammar_pre = []; + let grammar_mid = []; + let ebnf_rules = []; + let bnf_rules = []; + let grammar_post = []; - var fmtprod = function fmtprod(rule, prodset) { - var backup = deepClone(prodset); + let fmtprod = function fmtprod(rule, prodset) { + let backup = deepClone(prodset); rule += prodset[0] ? prodset[0] : '%epsilon'; - var prec = null; - var lead = rule.split(/\r\n\|\n|\r/).pop(); + let prec = null; + let lead = rule.split(/\r\n\|\n|\r/).pop(); delete prodset[0]; if (prodset.length === 3 && typeof prodset[2] === 'object') { prec = '%prec ' + prodset[2].prec; if (lead.length < 12) { rule += makeIndent(12 - lead.length); - } + } rule += ' ' + prec; delete prodset[2].prec; if (isEmptyObj(prodset[2])) { delete prodset[2]; } - } - else if (prodset.length === 2 && typeof prodset[1] === 'object') { + } else if (prodset.length === 2 && typeof prodset[1] === 'object') { prec = '%prec ' + prodset[1].prec; if (lead.length < 12) { rule += makeIndent(12 - lead.length); - } + } rule += ' ' + prec; delete prodset[1].prec; @@ -28619,84 +28635,73 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } if (typeof prodset[1] === 'string') { - var action = prodset[1]; + let action = prodset[1]; if (lead.length < 12 - 1) { - rule += makeIndent(12 - lead.length) + indentAction('{ ' + action + ' }', 12); - } - else { - rule += '\n' + makeIndent(12) + indentAction('{ ' + action + ' }', 12); + rule += makeIndent(12 - lead.length) + indentAction('{ ' + action + ' }', 12); + } else { + rule += '\n' + makeIndent(12) + indentAction('{ ' + action + ' }', 12); } delete prodset[1]; } if (isEmptyArr(prodset)) { prodset.length = 0; - } - else { + } else { prodset = backup; } return rule; }; - var grammarfmt = function grammarfmt(src) { - var key; - var dst = []; + let grammarfmt = function grammarfmt(src) { + let dst = []; - for (key in src) { - var prodset = src[key]; - var rule; + for (let key in src) { + let prodset = src[key]; + let rule; console.log('format one rule:', { - key, + key, prodset }); if (typeof prodset === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; + rule = fmtprod(key + ' : ', [ prodset ]) + ';'; delete src[key]; - } - else if (prodset instanceof Array) { + } else if (prodset instanceof Array) { if (prodset.length === 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + ' : ', [prodset]) + ';'; + rule = fmtprod(key + ' : ', [ prodset ]) + ';'; delete src[key]; - } - else if (prodset[0] instanceof Array) { + } else if (prodset[0] instanceof Array) { rule = fmtprod(key + ' : ', prodset[0]); rule += '\n ;'; if (prodset[0].length === 0) { delete src[key]; } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - } - else if (prodset.length > 1) { + } else if (prodset.length > 1) { if (typeof prodset[0] === 'string') { - rule = fmtprod(key + '\n : ', [prodset[0]]); + rule = fmtprod(key + '\n : ', [ prodset[0] ]); delete prodset[0]; - } - else if (prodset[0] instanceof Array) { + } else if (prodset[0] instanceof Array) { rule = fmtprod(key + '\n : ', prodset[0]); if (prodset[0].length === 0) { delete prodset[0]; } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[0]; } - for (var i = 1, len = prodset.length; i < len; i++) { + for (let i = 1, len = prodset.length; i < len; i++) { if (typeof prodset[i] === 'string') { - rule += fmtprod('\n | ', [prodset[i]]); + rule += fmtprod('\n | ', [ prodset[i] ]); delete prodset[i]; - } - else if (prodset[i] instanceof Array) { + } else if (prodset[i] instanceof Array) { rule += fmtprod('\n | ', prodset[i]); if (prodset[i].length === 0) { delete prodset[i]; } - } - else { + } else { rule += '\n | **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset[i]; } } @@ -28706,8 +28711,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; delete src[key]; } } - } - else { + } else { rule = key + '\n : **ERRONEOUS PRODUCTION** (see the dump for more): ' + prodset; } dst.push(rule); @@ -28716,46 +28720,52 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return dst; }; - src = raw.ebnf; - if (src) { - ebnf_rules = grammarfmt(src); + { + let src = raw.ebnf; + if (src) { + ebnf_rules = grammarfmt(src); - if (isEmptyObj(src)) { - delete raw.ebnf; + if (isEmptyObj(src)) { + delete raw.ebnf; + } } } - src = raw.bnf; - //delete raw.bnf; - if (src) { - bnf_rules = grammarfmt(src); + { + let src = raw.bnf; + //delete raw.bnf; + if (src) { + bnf_rules = grammarfmt(src); - if (isEmptyObj(src)) { - delete raw.bnf; + if (isEmptyObj(src)) { + delete raw.bnf; + } } } - src = raw.unknownDecls; - delete raw.unknownDecls; - if (src && !isEmptyObj(src)) { - lex_pre.push(rmCommonWS$4` - // unknown declarations: - `); + { + let src = raw.unknownDecls; + delete raw.unknownDecls; + if (src && !isEmptyObj(src)) { + lex_pre.push(rmCommonWS$4` + // unknown declarations: + `); - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var key = entry.name; - var value = entry.value; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let key = entry.name; + let value = entry.value; - lex_pre.push('%' + key + ' ' + value); - } + lex_pre.push('%' + key + ' ' + value); + } - lex_pre.push(rmCommonWS$4` - // END of unknown declarations. - `); + lex_pre.push(rmCommonWS$4` + // END of unknown declarations. + `); + } } - //src = raw.lex; + //let src = raw.lex; //delete raw.lex; //if (src) { if (lex_out_str.trim() && options.showLexer) { @@ -28773,294 +28783,305 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; `); } - src = raw.options; - delete raw.options; - if (src && !isEmptyObj(src)) { - var a = []; - for (key in src) { - var value = src[key]; - switch (key) { - default: - if (value !== true) { - a.push('options', '%options ' + key + '=' + value); - } - else { - a.push('options', '%options ' + key); - } - break; + { + let src = raw.options; + delete raw.options; + if (src && !isEmptyObj(src)) { + let a = []; + for (let key in src) { + let value = src[key]; + switch (key) { + default: + if (value !== true) { + a.push('options', '%options ' + key + '=' + value); + } else { + a.push('options', '%options ' + key); + } + break; - case 'ebnf': - if (value) { - a.push(key, '%ebnf'); - } - break; + case 'ebnf': + if (value) { + a.push(key, '%ebnf'); + } + break; - case 'type': - if (value) { - a.push(key, '%parser-type ' + value); - } - break; + case 'type': + if (value) { + a.push(key, '%parser-type ' + value); + } + break; - case 'debug': - if (typeof value !== 'boolean') { - a.push(key, '%debug ' + value); - } - else if (value) { - a.push(key, '%debug'); + case 'debug': + if (typeof value !== 'boolean') { + a.push(key, '%debug ' + value); + } else if (value) { + a.push(key, '%debug'); + } + break; } - break; } - } - var type = null; - for (var i = 0, len = a.length; i < len; i += 2) { - var t = a[i]; - var line = a[i + 1]; - if (t !== type) { - type = t; - grammar_pre.push(''); + let type = null; + for (let i = 0, len = a.length; i < len; i += 2) { + let t = a[i]; + let line = a[i + 1]; + if (t !== type) { + type = t; + grammar_pre.push(''); + } + grammar_pre.push(line); } - grammar_pre.push(line); + grammar_pre.push(''); } - grammar_pre.push(''); } - src = raw.imports; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - - grammar_pre.push('%import ' + entry.name + ' ' + entry.path); - delete entry.name; - delete entry.path; - if (isEmptyObj(entry)) { - delete src[i]; + { + let src = raw.imports; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + + grammar_pre.push('%import ' + entry.name + ' ' + entry.path); + delete entry.name; + delete entry.path; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } + } + if (clean) { + delete raw.imports; } - else { - clean = false; - } - } - if (clean) { - delete raw.imports; } } - src = raw.moduleInit; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - - grammar_pre.push('%code ' + entry.qualifier + ' ' + entry.include); - delete entry.qualifier; - delete entry.include; - if (isEmptyObj(entry)) { - delete src[i]; + { + let src = raw.moduleInit; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + + grammar_pre.push('%code ' + entry.qualifier + ' ' + entry.include); + delete entry.qualifier; + delete entry.include; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } + } + if (clean) { + delete raw.moduleInit; } - else { - clean = false; - } - } - if (clean) { - delete raw.moduleInit; } } - src = raw.operators; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var tokens = entry[1]; - var line = '%' + entry[0] + ' '; - - for (var t = 0, tlen = tokens.length; t < tlen; t++) { - line += ' ' + tokens[t]; - } + { + let src = raw.operators; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let tokens = entry[1]; + let line = '%' + entry[0] + ' '; + + for (let t = 0, tlen = tokens.length; t < tlen; t++) { + line += ' ' + tokens[t]; + } - grammar_pre.push(line); + grammar_pre.push(line); - if (entry.length === 2) { - delete src[i]; + if (entry.length === 2) { + delete src[i]; + } else { + clean = false; + } } - else { - clean = false; + if (clean) { + delete raw.operators; } } - if (clean) { - delete raw.operators; - } } - src = raw.extra_tokens; - if (src) { - var clean = true; - for (var i = 0, len = src.length; i < len; i++) { - var entry = src[i]; - var line = '%token ' + entry.id; - - if (entry.type) { - line += ' <' + entry.type + '>'; - delete entry.type; - } - if (entry.value) { - line += ' ' + entry.value; - delete entry.value; - } - if (entry.description) { - line += ' ' + escapeString(entry.description); - delete entry.description; - } + { + let src = raw.extra_tokens; + if (src) { + let clean = true; + for (let i = 0, len = src.length; i < len; i++) { + let entry = src[i]; + let line = '%token ' + entry.id; + + if (entry.type) { + line += ' <' + entry.type + '>'; + delete entry.type; + } + if (entry.value) { + line += ' ' + entry.value; + delete entry.value; + } + if (entry.description) { + line += ' ' + escapeString(entry.description); + delete entry.description; + } - grammar_pre.push(line); + grammar_pre.push(line); - delete entry.id; - if (isEmptyObj(entry)) { - delete src[i]; + delete entry.id; + if (isEmptyObj(entry)) { + delete src[i]; + } else { + clean = false; + } } - else { - clean = false; + if (clean) { + delete raw.extra_tokens; } } - if (clean) { - delete raw.extra_tokens; - } } - src = raw.parseParams; - delete raw.parseParams; - if (src) { - grammar_pre.push('%parse-param ' + src.join(' ')); + { + let src = raw.parseParams; + delete raw.parseParams; + if (src) { + grammar_pre.push('%parse-param ' + src.join(' ')); + } } - src = raw.start; - delete raw.start; - if (src) { - grammar_pre.push('%start ' + src); + { + let src = raw.start; + delete raw.start; + if (src) { + grammar_pre.push('%start ' + src); + } } - src = raw.moduleInclude; - delete raw.moduleInclude; - if (src && src.trim()) { - grammar_post.push(indentAction(src.trim(), 0)); + { + let src = raw.moduleInclude; + delete raw.moduleInclude; + if (src && src.trim()) { + grammar_post.push(indentAction(src.trim(), 0)); + } } - src = raw.actionInclude; - delete raw.actionInclude; - if (src && src.trim()) { - grammar_mid.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + { + let src = raw.actionInclude; + delete raw.actionInclude; + if (src && src.trim()) { + grammar_mid.push('%{\n' + indentAction(src.trim(), 4) + '\n%}'); + } } - var out = ''; + { + let out = ''; - if (!isEmptyObj(raw)) { - // dump the remainder as a comment: - var rem = JSON5__default['default'].stringify(raw, null, 2); - out += rmCommonWS$4` - /* - * Parser stuff that's unknown to the JISON prettyPrint service: - * - * ${rem.replace(/\*\//g, '*\\/')} - */ + if (!isEmptyObj(raw)) { + // dump the remainder as a comment: + let rem = JSON5__default['default'].stringify(raw, null, 2); + out += rmCommonWS$4` + /* + * Parser stuff that's unknown to the JISON prettyPrint service: + * + * ${rem.replace(/\*\//g, '*\\/')} + */ - `; - // delete raw; - } + `; + // delete raw; + } - if (!options.showParser) { - out += lex_out_str; - } - else { - out += grammar_pre.join('\n') + '\n\n'; - out += rmCommonWS$4` + if (!options.showParser) { + out += lex_out_str; + } else { + out += grammar_pre.join('\n') + '\n\n'; + out += rmCommonWS$4` - %% + %% - `; - if (grammar_mid.length > 0) { - out += grammar_mid.join('\n') + '\n\n'; - } - if (ebnf_rules.length > 0) { - if (bnf_rules.length > 0) { + `; + if (grammar_mid.length > 0) { + out += grammar_mid.join('\n') + '\n\n'; + } + if (ebnf_rules.length > 0) { + if (bnf_rules.length > 0) { // dump the original EBNF grammar as source and dump the BNF derivative as COMMENT: - var bnf_deriv = bnf_rules.join('\n\n'); - var a = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); + let bnf_deriv = bnf_rules.join('\n\n'); + let a = bnf_deriv.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - out += rmCommonWS$4` - // - // JISON says: - // - // This is a EBNF grammar. The resulting **BNF** grammar has been - // reproduced here for your convenience: - // - // ---------------------------- START --------------------------- - ${a.join('\n')} - // ---------------------------- END OF BNF grammar -------------- - // + out += rmCommonWS$4` + // + // JISON says: + // + // This is a EBNF grammar. The resulting **BNF** grammar has been + // reproduced here for your convenience: + // + // ---------------------------- START --------------------------- + ${a.join('\n')} + // ---------------------------- END OF BNF grammar -------------- + // - `; + `; + } + out += ebnf_rules.join('\n\n') + '\n\n'; + } else if (bnf_rules.length > 0) { + out += bnf_rules.join('\n\n') + '\n\n'; } - out += ebnf_rules.join('\n\n') + '\n\n'; - } - else if (bnf_rules.length > 0) { - out += bnf_rules.join('\n\n') + '\n\n'; - } - if (grammar_post.length > 0) { - out += rmCommonWS$4` + if (grammar_post.length > 0) { + out += rmCommonWS$4` - %% + %% - ` + grammar_post.join('\n') + '\n\n'; + ` + grammar_post.join('\n') + '\n\n'; + } } - } - if (options.format === 'json5') { - var a = out.split(/\r\n|\n|\r/).map(function (line) { - return '// ' + line; - }); + if (options.format === 'json5') { + let a = out.split(/\r\n|\n|\r/).map(function (line) { + return '// ' + line; + }); - out = rmCommonWS$4` - // - // JISON says: - // - // The JISON ${options.showParser ? 'grammar' : 'lexer'} has been - // reproduced here for your convenience: - // - // ---------------------------- START --------------------------- - ${a.join('\n')} - // ---------------------------- END ----------------------------- - // + out = rmCommonWS$4` + // + // JISON says: + // + // The JISON ${options.showParser ? 'grammar' : 'lexer'} has been + // reproduced here for your convenience: + // + // ---------------------------- START --------------------------- + ${a.join('\n')} + // ---------------------------- END ----------------------------- + // - `; + `; - // process the original input once again: this time via JSON5 - raw = deepClone(originalInput); + // process the original input once again: this time via JSON5 + raw = deepClone(originalInput); - if (!options.showLexer) { - delete raw.lex; - out += JSON5__default['default'].stringify(raw, null, 2); - } - else if (!options.showParser) { - out += JSON5__default['default'].stringify(raw.lex, null, 2); + if (!options.showLexer) { + delete raw.lex; + out += JSON5__default['default'].stringify(raw, null, 2); + } else if (!options.showParser) { + out += JSON5__default['default'].stringify(raw.lex, null, 2); + } } - } - return out; + return out; + } } // Jison, an LR(0), SLR(1), LARL(1), LR(1) Parser Generator - var rmCommonWS$5 = helpers.rmCommonWS; - var mkIdentifier$4 = helpers.mkIdentifier; - var code_exec$2 = helpers.exec; + const rmCommonWS$5 = helpers.rmCommonWS; + const mkIdentifier$4 = helpers.mkIdentifier; + const code_exec$1 = helpers.exec; - var version$2 = '0.6.2-220'; + const version$2 = '0.7.0-220'; - var devDebug = 0; + let devDebug = 0; function chkBugger$3(src) { src = '' + src; @@ -29076,7 +29097,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE$3 = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; - var Jison$1 = { + let Jison$1 = { version: version$2 }; @@ -29091,8 +29112,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; compressTables: 2, // 0, 1, 2 outputDebugTables: false, noDefaultResolve: false, - defaultActionMode: ["classic", "merge"], // {classic, ast, none, skip}, {classic, ast, merge, none, skip} - testCompileActionCode: "parser:*,lexer:*", + defaultActionMode: [ 'classic', 'merge' ], // {classic, ast, none, skip}, {classic, ast, merge, none, skip} + testCompileActionCode: 'parser:*,lexer:*', noTryCatch: false, hasPartialLrUpgradeOnConflict: true, errorRecoveryTokenDiscardCount: 3, @@ -29150,7 +29171,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; actionsUseYYSTACKPOINTER: false, actionsUseYYTEXT: false, hasErrorRecovery: false, - hasErrorReporting: false, + hasErrorReporting: false }; Jison$1.defaultJisonOptions = defaultJisonOptions; @@ -29171,25 +29192,25 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Return a fresh set of options. /** @public */ function mkStdOptions$1(...args) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - //var args = Array.prototype.concat.apply([], args); + let opts = {}; + //let args = Array.prototype.concat.apply([], args); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(Jison$1.defaultJisonOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; - for (var p in o) { + for (let p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { o2[mkIdentifier$4(p)] = o[p]; } @@ -29221,7 +29242,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // fall through case 'string': - var a = String(o2.defaultActionMode).split(',').map(function (m) { + let a = String(o2.defaultActionMode).split(',').map(function (m) { return m.trim(); }); if (a.length === 1) { @@ -29285,7 +29306,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // now see if we have an overriding option here: - for (var p in o2) { + for (let p in o2) { if (h.call(o2, p)) { if (typeof o2[p] !== 'undefined') { opts[p] = o2[p]; @@ -29301,7 +29322,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function prepExportStructures$1(options) { // set up the 'option' `exportAllTables` as a hash object for returning // all generated tables to the caller - var exportDest = options.exportAllTables; + let exportDest = options.exportAllTables; if (!exportDest || typeof exportDest !== 'object') { exportDest = { enabled: !!exportDest @@ -29313,7 +29334,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -29334,128 +29355,128 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Otherwise return the *parsed* grammar and optional lexer specs as they have // been processed through EBNFParser and LEXParser respectively. function autodetectAndConvertToJSONformat$1(grammar, optionalLexerSection, options) { - var chk_g = null; - var chk_l = null; - var ex1, err; + let chk_g = null; + let chk_l = null; + let ex1, err; if (typeof grammar === 'string') { - if (options.json) { - try { - chk_g = JSON5__default['default'].parse(grammar); + if (options.json) { + try { + chk_g = JSON5__default['default'].parse(grammar); - // When JSON5-based parsing of the grammar succeeds, this implies the grammar is specified in `JSON mode` - // *OR* there's a JSON/JSON5 format error in the input: - } catch (e) { - ex1 = e; + // When JSON5-based parsing of the grammar succeeds, this implies the grammar is specified in `JSON mode` + // *OR* there's a JSON/JSON5 format error in the input: + } catch (e) { + ex1 = e; + } } - } - if (!chk_g) { - try { - chk_g = ebnfParser.parse(grammar); - } catch (e) { - if (options.json) { - // When both JSON5 and JISON input modes barf a hairball, assume the most important - // error is the JISON one (show that one first!), while it MAY be a JSON5 format - // error that triggered it (show that one last!). - // - // Also check for common JISON errors which are obviously never triggered by any - // odd JSON5 input format error: when we encounter such an error here, we don't - // confuse matters and forget about the JSON5 fail as it's irrelevant: - const commonErrors = [ - /does not compile/, - /you did not correctly separate trailing code/, - /You did not specify/, - /You cannot specify/, - /must be qualified/, - /%start/, - /%token/, - /%import/, - /%include/, - /%options/, - /%parse-params/, - /%parser-type/, - /%epsilon/, - /definition list error/, - /token list error/, - /declaration error/, - /should be followed/, - /should be separated/, - /an error in one or more of your lexer regex rules/, - /an error in your lexer epilogue/, - /unsupported definition type/, - ]; - var cmnerr = commonErrors.filter(function check(re) { - return e.message.match(re); - }); - if (cmnerr.length > 0) { - err = e; + if (!chk_g) { + try { + chk_g = ebnfParser.parse(grammar); + } catch (e) { + if (options.json) { + // When both JSON5 and JISON input modes barf a hairball, assume the most important + // error is the JISON one (show that one first!), while it MAY be a JSON5 format + // error that triggered it (show that one last!). + // + // Also check for common JISON errors which are obviously never triggered by any + // odd JSON5 input format error: when we encounter such an error here, we don't + // confuse matters and forget about the JSON5 fail as it's irrelevant: + const commonErrors = [ + /does not compile/, + /you did not correctly separate trailing code/, + /You did not specify/, + /You cannot specify/, + /must be qualified/, + /%start/, + /%token/, + /%import/, + /%include/, + /%options/, + /%parse-params/, + /%parser-type/, + /%epsilon/, + /definition list error/, + /token list error/, + /declaration error/, + /should be followed/, + /should be separated/, + /an error in one or more of your lexer regex rules/, + /an error in your lexer epilogue/, + /unsupported definition type/ + ]; + let cmnerr = commonErrors.filter(function check(re) { + return e.message.match(re); + }); + if (cmnerr.length > 0) { + err = e; + } else { + err = new Error('Could not parse jison grammar in JSON AUTODETECT mode:\nin JISON Mode we get Error: ' + e.message + '\nwhile JSON5 Mode produces Error: ' + ex1.message); + err.secondary_exception = e; + err.stack = ex1.stack; + } } else { - err = new Error('Could not parse jison grammar in JSON AUTODETECT mode:\nin JISON Mode we get Error: ' + e.message + '\nwhile JSON5 Mode produces Error: ' + ex1.message); - err.secondary_exception = e; - err.stack = ex1.stack; + err = new Error('Could not parse jison grammar\nError: ' + e.message); + err.stack = e.stack; } - } else { - err = new Error('Could not parse jison grammar\nError: ' + e.message); - err.stack = e.stack; + throw err; } - throw err; } - } - // Save time! Don't reparse the entire grammar *again* inside the code generators when that's not necessary: - // if (chk_g) { - // grammar = chk_g; - // } + // Save time! Don't reparse the entire grammar *again* inside the code generators when that's not necessary: + // if (chk_g) { + // grammar = chk_g; + // } } else { chk_g = grammar; } // Now the same treatment for the lexer: if (chk_g && optionalLexerSection) { - if (chk_g.lex) { - throw new Error('Cannot invoke with both a lexer section in the grammar input and a separate lexer input at the same time!'); - } + if (chk_g.lex) { + throw new Error('Cannot invoke with both a lexer section in the grammar input and a separate lexer input at the same time!'); + } - if (typeof optionalLexerSection === 'string') { - if (options.json) { - try { - chk_l = JSON5__default['default'].parse(optionalLexerSection); + if (typeof optionalLexerSection === 'string') { + if (options.json) { + try { + chk_l = JSON5__default['default'].parse(optionalLexerSection); - // When JSON5-based parsing of the lexer spec succeeds, this implies the lexer spec is specified in `JSON mode` - // *OR* there's a JSON/JSON5 format error in the input: - } catch (e) { - ex1 = e; - } - } - if (!chk_l) { - // // WARNING: the lexer may receive options specified in the **grammar spec file**, - // // hence we should mix the options to ensure the lexParser always - // // receives the full set! - // // - // // make sure all options are 'standardized' before we go and mix them together: - // options = mkStdOptions(grammar.options, options); - try { - chk_l = lexParser.parse(optionalLexerSection); - } catch (e) { - if (options.json) { - err = new Error('Could not parse lexer spec in JSON AUTODETECT mode\nError: ' + ex1.message + ' (' + e.message + ')'); - err.secondary_exception = e; - err.stack = ex1.stack; - } else { - err = new Error('Could not parse lexer spec\nError: ' + e.message); - err.stack = e.stack; - } - throw err; - } + // When JSON5-based parsing of the lexer spec succeeds, this implies the lexer spec is specified in `JSON mode` + // *OR* there's a JSON/JSON5 format error in the input: + } catch (e) { + ex1 = e; + } + } + if (!chk_l) { + // // WARNING: the lexer may receive options specified in the **grammar spec file**, + // // hence we should mix the options to ensure the lexParser always + // // receives the full set! + // // + // // make sure all options are 'standardized' before we go and mix them together: + // options = mkStdOptions(grammar.options, options); + try { + chk_l = lexParser.parse(optionalLexerSection); + } catch (e) { + if (options.json) { + err = new Error('Could not parse lexer spec in JSON AUTODETECT mode\nError: ' + ex1.message + ' (' + e.message + ')'); + err.secondary_exception = e; + err.stack = ex1.stack; + } else { + err = new Error('Could not parse lexer spec\nError: ' + e.message); + err.stack = e.stack; + } + throw err; + } + } + } else { + chk_l = optionalLexerSection; } - } else { - chk_l = optionalLexerSection; - } - // Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: - if (chk_l) { - chk_g.lex = chk_l; - } + // Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: + if (chk_l) { + chk_g.lex = chk_l; + } } return chk_g; @@ -29472,7 +29493,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // wrap console.log to prevent 'Illegal Invocation' exceptions when Jison.print() is used, e.g. // in the web tryout pages where this code is employed. Jison$1.print = function console_log(/* ... */) { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); args.unshift(''); // prevent `%.` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args console.log.apply(console, args); }; @@ -29493,7 +29514,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; Jison$1.Lexer = RegExpLexer; Jison$1.ebnfParser = ebnfParser; Jison$1.lexParser = lexParser; - Jison$1.codeExec = code_exec$2; + Jison$1.codeExec = code_exec$1; Jison$1.XRegExp = XRegExp__default['default']; Jison$1.recast = recast__default['default']; Jison$1.astUtils = astUtils__default['default']; @@ -29508,7 +29529,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (typeof obj.forEach === 'function') { obj.forEach(func); } else { - var p; + let p; for (p in obj) { if (obj.hasOwnProperty(p)) { func.call(obj, obj[p], p, obj); @@ -29538,10 +29559,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // site for this jscore grammar as the naive scan consistently // outperformed the old smarter hash-object code for smaller // thresholds (10, 20, 32, 42!) - var k, len; + let k, len; if (a.length > 52) { - var ar = {}; + let ar = {}; for (k = 0, len = a.length; k < len; k++) { ar[a[k]] = true; } @@ -29551,7 +29572,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } } else { - var bn = []; + let bn = []; for (k = 0, len = b.length; k < len; k++) { if (a.indexOf(b[k]) < 0) { bn.push(b[k]); @@ -29562,17 +29583,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return a; } - var Nonterminal = typal.construct({ + let Nonterminal = typal.construct({ constructor: function Nonterminal(symbol) { this.symbol = symbol; - this.productions = new Set(); + this.productions = new Set$1(); this.first = []; this.follows = []; this.nullable = false; }, toString: function Nonterminal_toString() { - var str = this.symbol; - var attr_str = []; + let str = this.symbol; + let attr_str = []; if (this.nullable) { attr_str.push('nullable'); @@ -29589,7 +29610,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } }); - var Production = typal.construct({ + let Production = typal.construct({ constructor: function Production(symbol, handle, id, handle_aliases, handle_action) { this.symbol = symbol; this.handle = handle; @@ -29603,9 +29624,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.reachable = false; }, toString: function Production_toString() { - var str = this.symbol; + let str = this.symbol; - var attr_str = []; + let attr_str = []; if (this.nullable) { attr_str.push('~'); @@ -29625,9 +29646,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return str; }, describe: function Production_describe() { - var str = this.symbol; + let str = this.symbol; - var attr_str = []; + let attr_str = []; if (this.nullable) { attr_str.push('nullable'); @@ -29648,7 +29669,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; - var generator = typal.beget(); + let generator = typal.beget(); // `optionalLexerSection` is an optional {String} argument, specifying the lexer rules. // May only be specified when the specified `grammar` also is a yet-unparsed @@ -29723,11 +29744,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; generator.constructor = function Jison_Generator(grammar, optionalLexerSection, options) { // pick the correct argument for the `options` for this call: if (!options && optionalLexerSection && typeof optionalLexerSection !== 'string') { - options = optionalLexerSection; - optionalLexerSection = null; + options = optionalLexerSection; + optionalLexerSection = null; } // and standardize it: - var preliminary_options = mkStdOptions$1(options); + let preliminary_options = mkStdOptions$1(options); grammar = autodetectAndConvertToJSONformat$1(grammar, optionalLexerSection, preliminary_options); @@ -29775,7 +29796,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // } // calculate the input path; if none is specified, it's the present working directory - var inpath = options.file || options.outfile || './dummy'; + let inpath = options.file || options.outfile || './dummy'; inpath = path__default['default'].normalize(inpath); options.inputPath = path__default['default'].dirname(inpath); options.inputFilename = path__default['default'].basename(inpath); @@ -29806,7 +29827,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.processGrammar(grammar); if (grammar.lex) { - var lexer_options = { + let lexer_options = { // include the knowledge about which parser/lexer // features will actually be *used* by the environment: // @@ -29861,7 +29882,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; exportAST: this.options.exportAST, prettyCfg: this.options.prettyCfg, pre_lex: this.options.pre_lex, - post_lex: this.options.post_lex, + post_lex: this.options.post_lex }; this.lexer = new RegExpLexer(grammar.lex, null, this.terminals_, lexer_options); @@ -29869,10 +29890,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; generator.processGrammar = function processGrammarDef(grammar) { - var bnf = grammar.bnf, - tokens = grammar.tokens, - nonterminals = this.nonterminals = {}, - productions = this.productions; + let bnf = grammar.bnf; + let tokens = grammar.tokens; + let nonterminals = this.nonterminals = {}; + let productions = this.productions; if (!grammar.bnf && grammar.ebnf) { bnf = grammar.bnf = ebnfParser.transform(grammar.ebnf); @@ -29888,18 +29909,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // did the grammar user also provide a predefined set of symbols to be (re)used with this grammar? // (This is used when you want to generate multiple lexers and parsers which share a common symbol set // so as to make the parsers and lexers mutually interchangeable.) - var predefined_symbols = null; + let predefined_symbols = null; if (grammar.imports) { - var symbols_import = grammar.imports.find(function (el, idx) { + let symbols_import = grammar.imports.find(function (el, idx) { if (el.name === 'symbols') { return el; } return false; }); if (symbols_import) { - var filepath = path__default['default'].resolve(symbols_import.path); + let filepath = path__default['default'].resolve(symbols_import.path); - var source = fs__default['default'].readFileSync(filepath, 'utf8'); + let source = fs__default['default'].readFileSync(filepath, 'utf8'); // It's either a JSON file or a JISON generated output file: // // symbols_: { @@ -29909,7 +29930,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; predefined_symbols = JSON5__default['default'].parse(source); } catch (ex) { try { - var m = /[\r\n]\s*symbols_:\s*(\{[\s\S]*?\}),\s*[\r\n]/.exec(source); + let m = /[\r\n]\s*symbols_:\s*(\{[\s\S]*?\}),\s*[\r\n]/.exec(source); if (m && m[1]) { source = m[1]; predefined_symbols = JSON5__default['default'].parse(source); @@ -29924,18 +29945,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // Make sure all predefined symbols are unique and *numeric* and do not include predefined tokens JISON already defines to a fixed ID on its own: - delete predefined_symbols['$accept']; - delete predefined_symbols['$end']; - delete predefined_symbols['error']; - delete predefined_symbols['$eof']; - delete predefined_symbols['EOF']; + delete predefined_symbols.$accept; + delete predefined_symbols.$end; + delete predefined_symbols.error; + delete predefined_symbols.$eof; + delete predefined_symbols.EOF; - var symdef_uniq_check = {}; + let symdef_uniq_check = {}; // Only these symbols are allowed to have the values 1 or 2: symdef_uniq_check[1] = 'EOF'; symdef_uniq_check[2] = 'error'; Object.keys(predefined_symbols).forEach(function cvt_symbol_id_to_numeric(sym) { - var v = predefined_symbols[sym]; + let v = predefined_symbols[sym]; // Symbol value may be defined as boolean TRUE, in which case we let JISON pick the value for us: if (v === true) return; @@ -29943,17 +29964,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Symbol value may be defined as a one-character string: if (typeof v !== 'number') { if (typeof v !== 'string' || v.length !== 1) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a non-numeric symbol ID value must be a single-character string.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a non-numeric symbol ID value must be a single-character string."); } v = v.charCodeAt(0); } - v = v | 0; + v |= 0; if (!v || v < 0) { - throw new Error('Error: `%import symbols `: symbol table contains invalid entry at key \'' + sym + '\': a symbol ID value must be an integer value, 3 or greater.'); + throw new Error("Error: `%import symbols `: symbol table contains invalid entry at key '" + sym + "': a symbol ID value must be an integer value, 3 or greater."); } if (symdef_uniq_check[v]) { if (symdef_uniq_check[v] !== sym) { - throw new Error('Error: `%import symbols `: symbol table contains duplicate ID values for keys \'' + sym + '\' and \'' + symdef_uniq_check[v] + '\''); + throw new Error("Error: `%import symbols `: symbol table contains duplicate ID values for keys '" + sym + "' and '" + symdef_uniq_check[v] + "'"); } } symdef_uniq_check[v] = sym; @@ -29962,15 +29983,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } - var symbols = this.symbols = []; + let symbols = this.symbols = []; // calculate precedence of operators - var operators = this.operators = processOperators(grammar.operators); + let operators = this.operators = processOperators(grammar.operators); // build productions from CFG and calculate the symbol sets (terminals and nonterminals) and their name-to-ID mappings this.buildProductions(bnf, productions, nonterminals, symbols, operators, predefined_symbols, grammar.extra_tokens); if (tokens) { - var termset = this.terminals.filter(function (t) { + let termset = this.terminals.filter(function (t) { switch (t) { case 'EOF': case 'error': @@ -29982,7 +30003,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return true; } }); - var diffset = termset.filter(function (t) { + let diffset = termset.filter(function (t) { return tokens.indexOf(t) === -1; }); diffset = diffset.concat(tokens.filter(function (t) { @@ -30039,7 +30060,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // return true; // the default parse result if the rule actions don't produce anything // %} // - var acceptProduction = new Production('$accept', [this.startSymbol, '$end'], 0); + let acceptProduction = new Production('$accept', [ this.startSymbol, '$end' ], 0); this.productions.unshift(acceptProduction); // prepend parser tokens // moved to generator.buildProductions() @@ -30058,14 +30079,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Mark unused productions generator.signalUnusedProductions = function () { - var mark = {}; + let mark = {}; - var productions = this.productions; - var nonterminals = this.nonterminals; - var i, len, nt, sym; + let productions = this.productions; + let nonterminals = this.nonterminals; - for (i = 0, len = nonterminals.length; i < len; i++) { - nt = nonterminals[i]; + for (let i = 0, len = nonterminals.length; i < len; i++) { + let nt = nonterminals[i]; assert__default['default'](nt.symbol); mark[nt.symbol] = false; } @@ -30076,15 +30096,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; assert__default['default'](nt.symbol); mark[nt.symbol] = true; - var prods = nt.productions; + let prods = nt.productions; assert__default['default'](prods); prods.forEach(function (p) { assert__default['default'](p.symbol === nt.symbol); assert__default['default'](p.handle); - var rhs = p.handle; + let rhs = p.handle; - for (var j = 0, len = rhs.length; j < len; j++) { - var sym = rhs[j]; + for (let j = 0, len = rhs.length; j < len; j++) { + let sym = rhs[j]; assert__default['default'](!sym ? !nonterminals[sym] : true); if (nonterminals[sym] && !mark[sym]) { traverseGrammar(nonterminals[sym]); @@ -30093,15 +30113,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }); } - traverseGrammar(nonterminals['$accept' /* this.startSymbol */ ]); + traverseGrammar(nonterminals['$accept' /* this.startSymbol */]); // now any production which is not yet marked is *unused*: - for (sym in mark) { - nt = nonterminals[sym]; + for (let sym in mark) { + let nt = nonterminals[sym]; assert__default['default'](nt); - var prods = nt.productions; + let prods = nt.productions; assert__default['default'](prods); - var in_use = mark[sym]; + let in_use = mark[sym]; prods.forEach(function (p) { assert__default['default'](p); if (in_use) { @@ -30130,8 +30150,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // set precedence and associativity of operators function processOperators(ops) { if (!ops) return {}; - var operators = {}; - for (var i = 0, k, prec; (prec = ops[i]); i++) { + let operators = {}; + for (let i = 0, k, prec; (prec = ops[i]); i++) { for (k = 1; k < prec.length; k++) { operators[prec[k]] = { precedence: i + 1, @@ -30146,8 +30166,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // Note that the first line doesn't count as the chunk is very probably trimmed! function reindentCodeBlock(action, indent_level) { - var width = 0; - var lines = action + let width = 0; + let lines = action .trim() .split('\n') // measure the indent: @@ -30164,7 +30184,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return s.replace(/\t/g, ' '); }); - var m = /^[ ]+/.exec(line); + let m = /^[ ]+/.exec(line); if (m) { width = Math.min(m[0].length, width); } @@ -30175,8 +30195,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; .map(function checkIndentation(line, idx) { line = line .replace(/^[ ]*/, function adjustIndent(s) { - var l = Math.max(s.length - width, 0) + indent_level; - var shift = (new Array(l + 1)).join(' '); + let l = Math.max(s.length - width, 0) + indent_level; + let shift = (new Array(l + 1)).join(' '); return shift; }); return line; @@ -30187,21 +30207,21 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; generator.buildProductions = function buildProductions(bnf, productions, nonterminals, symbols, operators, predefined_symbols, descriptions) { - var self = this; - var prods, symbol, symId; - var productions_ = []; - var symbols_ = {}; - var descriptions_ = {}; - var usedSymbolIds = [/* $accept = 0 */ true, /* $end = 1 */ true, /* error = 2 */ true]; - var usedSymbolIdsLowIndex = 3; + let self = this; + let prods, symId; + let productions_ = []; + let symbols_ = {}; + let descriptions_ = {}; + let usedSymbolIds = [/* $accept = 0 */ true, /* $end = 1 */ true, /* error = 2 */ true ]; + let usedSymbolIdsLowIndex = 3; // set up the required symbols `$accept` and `$end` (a.k.a. EOF) and make sure they occupy the expected slots: this.EOF = '$end'; symbols_.$accept = 0; symbols_[this.EOF] = 1; - symbols_['$eof'] = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! - symbols_['EOF'] = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.$eof = 1; // `$eof` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! + symbols_.EOF = 1; // `EOF` is a synonym of `$end` for bison compatibility; this is the only place where two symbol names may map to a single symbol ID number! symbols[0] = '$accept'; symbols[1] = this.EOF; @@ -30212,7 +30232,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; symbols[2] = 'error'; if (predefined_symbols) { - for (symbol in predefined_symbols) { + for (let symbol in predefined_symbols) { symId = predefined_symbols[symbol]; if (symId === true) { // add symbol to queue which must be assigned a value by JISON; after all the other predefined symbols have been processed. @@ -30235,7 +30255,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // preferably assign readable ASCII-range token IDs to tokens added from the predefined list // but only when maximum table compression isn't demanded: usedSymbolIdsLowIndex = ((this.options.compressTables | 0) < 2 ? 32 : 3); - for (symbol in predefined_symbols) { + for (let symbol in predefined_symbols) { symId = predefined_symbols[symbol]; addSymbol(symbol); } @@ -30255,11 +30275,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } - var hasErrorRecovery = false; // has error recovery + let hasErrorRecovery = false; // has error recovery // Produce the next available unique symbolID: function getNextSymbolId() { - for (var i = usedSymbolIdsLowIndex; ; i++) { + for (let i = usedSymbolIdsLowIndex; ; i++) { if (!usedSymbolIds[i]) { usedSymbolIds[i] = true; usedSymbolIdsLowIndex = i + 1; @@ -30270,7 +30290,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function addSymbol(s) { if (s && !symbols_[s]) { - var i; + let i; // assign the Unicode codepoint index to single-character symbols, // but only when maximum table compression isn't demanded: @@ -30294,46 +30314,45 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // `this` is options object with `maxTokenLength` option to guide us which literal tokens we want to process: function collectLiteralTokensInProduction(handle) { - var rhs, i, sym; + let rhs; - try{ - if (devDebug) ; + try { + if (devDebug) ; - var maxlen = this.maxTokenLength || Infinity; + let maxlen = this.maxTokenLength || Infinity; - if (handle.constructor === Array) { - var rhs_i; - rhs = (typeof handle[0] === 'string') ? - splitStringIntoSymbols(handle[0]) : - handle[0].slice(0); + if (handle.constructor === Array) { + rhs = (typeof handle[0] === 'string') ? + splitStringIntoSymbols(handle[0]) : + handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; - // check for aliased names, e.g., id[alias] and strip them - rhs_i = sym.match(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]$`)); - if (rhs_i) { - sym = sym.substr(0, sym.length - rhs_i[0].length); - } + for (let i = 0; i < rhs.length; i++) { + let sym = rhs[i]; + // check for aliased names, e.g., id[alias] and strip them + let rhs_i = sym.match(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]$`)); + if (rhs_i) { + sym = sym.substr(0, sym.length - rhs_i[0].length); + } - if (!bnf[sym] && sym.length <= maxlen) { - addSymbol(sym); + if (!bnf[sym] && sym.length <= maxlen) { + addSymbol(sym); + } } - } - } else { - // no action -> don't care about aliases; strip them. - handle = handle.replace(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); - rhs = splitStringIntoSymbols(handle); - for (i = 0; i < rhs.length; i++) { - sym = rhs[i]; - if (!bnf[sym] && sym.length <= maxlen) { - addSymbol(sym); + } else { + // no action -> don't care about aliases; strip them. + handle = handle.replace(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); + rhs = splitStringIntoSymbols(handle); + for (let i = 0; i < rhs.length; i++) { + let sym = rhs[i]; + if (!bnf[sym] && sym.length <= maxlen) { + addSymbol(sym); + } } } + } catch (ex) { + console.error(ex, '\ncollectLiteralTokensInProduction: ', this.symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { rhs }); + throw ex; } - }catch (ex) { - console.error(ex, '\ncollectLiteralTokensInProduction: ', symbol, ':', JSON.stringify(handle, null, 2), ' @ options: ', this, { i, sym, rhs }); - throw ex; - } } // Before we go process the grammar for real, we collect the 'literal' non-terminals and add them to the symbol table @@ -30341,8 +30360,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // which helps debugging/diagnosis of generated grammars. // (This is why previously we had set `usedSymbolIdsLowIndex` to 127 instead of 3!) - var prodsLUT = {}; - for (symbol in bnf) { + let prodsLUT = {}; + for (let symbol in bnf) { if (!bnf.hasOwnProperty(symbol)) continue; if (typeof bnf[symbol] === 'string') { @@ -30355,21 +30374,23 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // First we collect all single-character literal tokens: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: 1 + maxTokenLength: 1, + symbol }); } // Next we collect all other literal tokens: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; prods.forEach(collectLiteralTokensInProduction, { - maxTokenLength: Infinity + maxTokenLength: Infinity, + symbol }); } @@ -30378,7 +30399,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // for each of those: nonterminals should all have IDs assigned before they // should be processed as part of a *production* rule, where these MAY be // referenced: - for (symbol in bnf) { + for (let symbol in bnf) { if (!bnf.hasOwnProperty(symbol)) continue; addSymbol(symbol); @@ -30387,15 +30408,15 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now that we have collected all nonterminals in our symbol table, it's finally // time to process the productions: - for (symbol in prodsLUT) { + for (let symbol in prodsLUT) { if (!prodsLUT.hasOwnProperty(symbol)) continue; prods = prodsLUT[symbol]; - prods.forEach(buildProduction); + prods.forEach(buildProduction, { symbol }); } - var terms = [], - terms_ = {}; + let terms = []; + let terms_ = {}; each(symbols_, function (id, sym) { // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number @@ -30411,7 +30432,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // fix error recovery related options now that we know whether we actually have any recovery // rules at all: if (!this.hasErrorRecovery) { - var chk_er_opt = function check_error_recovery_option(opt, label) { + let chk_er_opt = function check_error_recovery_option(opt, label) { if (self.options[opt]) { self.options[opt] = false; self.warn('The grammar does not have any error recovery rules, so using the ' + label + ' is rather useless.'); @@ -30423,9 +30444,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Hmmmm... why would lexer errors need to be NON-recoverable when there's no ERROR rules in the GRAMMAR?! chk_er_opt('lexerErrorsAreRecoverable', 'lexer-errors-are-recoverable feature/option'); - chk_er_opt('parseActionsUseYYRECOVERING', 'YYRECOVERING macro/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYERROK', 'yyerrok() function/API in grammar rules\' action code'); - chk_er_opt('parseActionsUseYYCLEARIN', 'yyclearin() function/API in grammar rules\' action code'); + chk_er_opt('parseActionsUseYYRECOVERING', "YYRECOVERING macro/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYERROK', "yyerrok() function/API in grammar rules' action code"); + chk_er_opt('parseActionsUseYYCLEARIN', "yyclearin() function/API in grammar rules' action code"); } this.terminals = terms; @@ -30444,8 +30465,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function splitStringIntoSymbols(rhs) { // when there's no literal tokens in there, we can fast-track this baby: rhs = rhs.trim(); - var pos1 = rhs.indexOf("'"); - var pos2 = rhs.indexOf('"'); + let pos1 = rhs.indexOf("'"); + let pos2 = rhs.indexOf('"'); if (pos1 < 0 && pos2 < 0) { return rhs.split(' '); } @@ -30453,10 +30474,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // rhs has at least one literal: we will need to parse the rhs into tokens // with a little more effort now. - var tokens = []; + let tokens = []; while (pos1 >= 0 || pos2 >= 0) { - var pos = pos1; - var marker = "'"; + let pos = pos1; + let marker = "'"; if (pos < 0) { assert__default['default'](pos2 >= 0); pos = pos2; @@ -30465,7 +30486,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; pos = pos2; marker = '"'; } - var ls = rhs.substr(0, pos).trim(); + let ls = rhs.substr(0, pos).trim(); if (ls.length > 0) { tokens.push.apply(tokens, ls.split(' ')); } @@ -30474,7 +30495,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // Edge case: token MAY include the ESCAPED MARKER... or other escapes! // Hence we need to skip over ALL escapes inside the token! - var pos3 = rhs.indexOf('\\'); + let pos3 = rhs.indexOf('\\'); pos = rhs.indexOf(marker); ls = ''; while (pos3 >= 0 && pos3 < pos) { @@ -30489,7 +30510,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; ls += rhs.substr(0, pos); // check for aliased literals, e.g., `'>'[gt]` and keep it and the alias together rhs = rhs.substr(pos + 1); - var alias = rhs.match(new XRegExp__default['default'](`^\\[${ID_REGEX_BASE$3}\\]`)); + let alias = rhs.match(new XRegExp__default['default'](`^\\[${ID_REGEX_BASE$3}\\]`)); if (alias) { ls += alias[0]; rhs = rhs.substr(alias[0].length); @@ -30509,22 +30530,21 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return tokens; } + // options object { symbol } is `this` for this functon/callback: function buildProduction(handle) { - var r, rhs, i, - precedence_override, - aliased = [], - action = null; + let rhs; + let precedence_override = null; + let aliased = []; + let action = null; if (handle.constructor === Array) { - var rhs_i; - rhs = (typeof handle[0] === 'string') ? - splitStringIntoSymbols(handle[0]) : - handle[0].slice(0); + splitStringIntoSymbols(handle[0]) : + handle[0].slice(0); - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // check for aliased names, e.g., id[alias] and strip them - rhs_i = rhs[i].match(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]$`)); + let rhs_i = rhs[i].match(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]$`)); if (rhs_i) { rhs[i] = rhs[i].substr(0, rhs[i].length - rhs_i[0].length); rhs_i = rhs_i[0].substr(1, rhs_i[0].length - 2); @@ -30566,7 +30586,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // no action -> don't care about aliases; strip them. handle = handle.replace(new XRegExp__default['default'](`\\[${ID_REGEX_BASE$3}\\]`, 'g'), ''); rhs = splitStringIntoSymbols(handle); - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { if (rhs[i] === 'error') { hasErrorRecovery = true; } @@ -30576,35 +30596,33 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } - r = new Production(symbol, rhs, productions.length + 1, aliased, action); + let r = new Production(this.symbol, rhs, productions.length + 1, aliased, action); // set precedence assert__default['default'](r.precedence === 0); if (precedence_override) { r.precedence = precedence_override.spec.precedence; - } - else { - var prec_symbols = []; - var winning_symbol; + } else { + let prec_symbols = []; + let winning_symbol; - for (i = r.handle.length - 1; i >= 0; i--) { + for (let i = r.handle.length - 1; i >= 0; i--) { if (!(r.handle[i] in nonterminals) && r.handle[i] in operators) { - var old_prec = r.precedence; - var new_prec = operators[r.handle[i]].precedence; + let old_prec = r.precedence; + let new_prec = operators[r.handle[i]].precedence; if (old_prec !== 0 && old_prec !== new_prec) { prec_symbols.push(r.handle[i]); - // Jison.print('precedence set twice: ', old_prec, new_prec, r.handle[i], symbol, handle[0]); + // 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[i]; - } - else { + } else { // keep previously set precedence: new_prec = old_prec; } } else if (old_prec === 0) { prec_symbols.push(r.handle[i]); winning_symbol = r.handle[i]; - // Jison.print('precedence set first time: ', old_prec, r.handle[i], symbol, handle[0]); + // Jison.print('precedence set first time: ', old_prec, r.handle[i], this.symbol, handle[0]); } r.precedence = new_prec; } @@ -30612,14 +30630,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (prec_symbols.length > 1) { if (self.DEBUG || 1) { - self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); + self.warn('Ambiguous rule precedence in grammar: picking the (highest) precedence from operator "' + winning_symbol + '" for rule "' + this.symbol + ': ' + r.handle.join(' ') + '" which contains multiple operators with different precedences: {' + prec_symbols.join(', ') + '}'); } } } productions.push(r); - productions_.push([symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length]); - nonterminals[symbol].productions.push(r); + productions_.push([ symbols_[r.symbol], r.handle[0] === '' ? 0 : r.handle.length ]); + nonterminals[this.symbol].productions.push(r); } }; @@ -30724,8 +30742,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // with our pants down in constructs like // `'"' + $$ + '"'` vs. `"'" + $$ + "'"` - var dqpos, sqpos, ccmtpos, cppcmtpos, first = -1; - for (var c = 0;; c++) { + let dqpos, sqpos, ccmtpos, cppcmtpos; + let first = -1; + for (let c = 0; ; c++) { first++; dqpos = s.indexOf('"', first); sqpos = s.indexOf("'", first); @@ -30769,11 +30788,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; .replace(/\x01\x82/g, '$') .replace(/\x01\x83/g, '@') // and revert the string and regex markers: - .replace(/\x01\x87/g, '\'') + .replace(/\x01\x87/g, "'") .replace(/\x01\x88/g, '\"') .replace(/\x01\x89/g, '##') .replace(/\x01\x90/g, '\\\\') - .replace(/\x01\x91/g, '\\\'') + .replace(/\x01\x91/g, "\\'") .replace(/\x01\x92/g, '\\\"') .replace(/\x01\x93/g, '\\\/') .replace(/\x01\x94/g, 'YYABORT') @@ -30806,7 +30825,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function analyzeFeatureUsage(sourcecode, feature, threshold) { - var found = sourcecode.match(feature); + let found = sourcecode.match(feature); return !!(found && found.length > threshold); } @@ -30814,7 +30833,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function mkParserFeatureHash(self) { assert__default['default'](self.options.exportAllTables); // check that this function isn't called too early in the process or the hash will be bogus assert__default['default'](self.options.exportSourceCode); - var h = [ + let h = [ self.actionsAreAllDefault, self.actionsUseLocationAssignment, self.actionsUseLocationTracking, @@ -30863,7 +30882,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; self.options.prettyCfg, '======================================', self.performAction, - '======================================', + '======================================' ]; return JSON.stringify(h); } @@ -30878,23 +30897,23 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.productions_ = productions_; assert(this.productions === productions); */ - var productions = this.productions, - nonterminals = this.nonterminals, - symbols = this.symbols, - operators = this.operators, - self = this; + let productions = this.productions; + let nonterminals = this.nonterminals; + let symbols = this.symbols; + let operators = this.operators; + let self = this; // As a SIDE EFFECT of this call, we also fixup // the other code chunks specified in the grammar file: // // Replace direct symbol references, e.g. #NUMBER# when there's a `%token NUMBER` for your grammar. // We allow these tokens to be referenced anywhere in your code as #TOKEN#. - var moduleInclude = preprocessActionCode(this.moduleInclude) + let moduleInclude = preprocessActionCode(this.moduleInclude) .replace(new XRegExp__default['default'](`#(${ID_REGEX_BASE$3})#`, 'g'), function (_, sym) { return provideSymbolAsSourcecode(sym); }); // and COPY the `moduleInit` array, after preprocessing the individual COPIES: - var moduleInit = this.moduleInit.map(function (chunk) { + let moduleInit = this.moduleInit.map(function (chunk) { assert__default['default'](chunk.qualifier); assert__default['default'](typeof chunk.include === 'string'); return { @@ -30910,39 +30929,38 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // We potentially need multiple (2+) rounds to produce the correct actions // as userland action code determines whether the default actions should // include location tracking or not: - var gen_level = 0; - var prev_gen_hash = 'n'; - var gen_hash = 'y'; + let gen_level = 0; + let prev_gen_hash = 'n'; + let gen_hash = 'y'; this.performAction = null; while (gen_hash !== prev_gen_hash) { - var preludeCode = preprocessActionCode(this.actionInclude || ''); - var actions = [` + let preludeCode = preprocessActionCode(this.actionInclude || ''); + let actions = [ ` /* this == yyval */ // the JS engine itself can go and remove these statements when \`yy\` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; ${preludeCode} switch (yystate) {` ]; - var actionGroups = {}; // used to combine identical actions into single instances: no use duplicating action code needlessly - var actionGroupValue = {}; // stores the unaltered, expanded, user-defined action code for each action group. - var stateHasAction = []; // marks which state IDs have an action, either user-specified or default. - var symbol; + let actionGroups = {}; // used to combine identical actions into single instances: no use duplicating action code needlessly + let actionGroupValue = {}; // stores the unaltered, expanded, user-defined action code for each action group. + let stateHasAction = []; // marks which state IDs have an action, either user-specified or default. // and now go and process the entire grammar: - productions.forEach(buildProductionAction); + productions.forEach(buildProductionAction, { actionGroups, actionGroupValue, stateHasAction }); - for (var hash in actionGroups) { + for (let hash in actionGroups) { actions.push([].concat.apply([], actionGroups[hash]).join('\n') + '\n\n' + actionGroupValue[hash] + '\n break;\n'); } // add the special error recovery reduction action: if (this.hasErrorRecovery) { - var userland_err_recov_redux_code = ''; + let userland_err_recov_redux_code = ''; actions.push(`case YY_ERROR_RECOVERY_COMBINE_ID: // === NO_ACTION[1] :: ensures that anyone (but us) using this new state will fail dramatically! // error recovery reduction action (action generated by jison, @@ -30955,16 +30973,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // check if all IDs have an action now: - var missingActions = []; - for (var idx = 0, len = stateHasAction.length; idx < len; idx++) { + let missingActions = []; + for (let idx = 0, len = stateHasAction.length; idx < len; idx++) { if (!stateHasAction[idx]) { missingActions.push(idx); } } - this.missingActions = missingActions; + this.missingActions = missingActions; if (missingActions.length) { if ( this.DEBUG) { - this.warn("WARNING: missing actions for states: ", missingActions); + this.warn('WARNING: missing actions for states: ', missingActions); } actions.push(`default: @@ -30972,7 +30990,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // When we hit this entry, it's always a non-recoverable issue as this is a severe internal parser state failure: function __b0rk_on_internal_failure(str) { - var hash = yyparser.constructParseErrorInfo(str, null, null, false); + let hash = yyparser.constructParseErrorInfo(str, null, null, false); return yyparser.parseError(str, hash, yyparser.JisonParserError); } @@ -30982,7 +31000,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } actions.push('}'); - var parameters = 'yytext, yyleng, yylineno, yyloc, yystate /* action[1] */, yysp, yyrulelength, yyvstack, yylstack, yystack, yysstack'; + let parameters = 'yytext, yyleng, yylineno, yyloc, yystate /* action[1] */, yysp, yyrulelength, yyvstack, yylstack, yystack, yysstack'; this.performAction = [].concat( 'function parser__PerformAction(' + parameters + ') {', @@ -31101,7 +31119,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; moduleInit.forEach(function (chunk) { assert__default['default'](chunk.qualifier); assert__default['default'](typeof chunk.include === 'string'); - var moduleInclude = chunk.include; + let moduleInclude = chunk.include; //self.actionsUseYYLENG = self.actionsUseYYLENG || analyzeFeatureUsage(moduleInclude, /\byyleng\b/g, 0); //self.actionsUseYYLINENO = self.actionsUseYYLINENO || analyzeFeatureUsage(moduleInclude, /\byylineno\b/g, 0); @@ -31169,8 +31187,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.actionsUseValueAssignment = true; break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": // <-- this one injects *nothing* + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'skip': // <-- this one injects *nothing* break; } this.actionsUseValueTracking = this.actionsUseValueTracking || this.actionsUseYYLENG || this.actionsUseYYTEXT || this.actionsUseValueAssignment; @@ -31179,8 +31197,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; default: break; - case "none": // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. - case "skip": // <-- this one injects *nothing* + case 'none': // <-- this one injects "$$ = undefined;", which doesn't count as 'non-trivial code' on its own. + case 'skip': // <-- this one injects *nothing* break; } this.actionsUseLocationTracking = this.actionsUseLocationTracking || this.actionsUseYYLINENO || this.actionsUseYYLOC || this.actionsUseLocationAssignment || this.actionsUseYYMERGELOCATIONINFO; @@ -31201,7 +31219,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; gen_hash = null; // create check hash of the new generated code: - var new_hash = mkParserFeatureHash(this); + let new_hash = mkParserFeatureHash(this); if ( this.DEBUG) { Jison$1.print('Optimization analysis:\n', { @@ -31230,7 +31248,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; hasErrorReporting: this.hasErrorReporting, defaultActionMode: this.options.defaultActionMode, testCompileActionCode: this.options.testCompileActionCode, - noTryCatch: this.options.noTryCatch, + noTryCatch: this.options.noTryCatch }); } @@ -31253,9 +31271,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; moduleInit.__consumedInitCodeSlots__ = []; moduleInit.getInitCodeSection = function getInitCodeSection(section) { - var rv = []; - for (var i = 0, len = this.length; i < len; i++) { - var m = this[i]; + let rv = []; + for (let i = 0, len = this.length; i < len; i++) { + let m = this[i]; if (m.qualifier === section) { if (m.include.trim()) { rv.push(m.include); @@ -31267,9 +31285,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; moduleInit.getRemainingInitCodeSections = function getRemainingInitCodeSections() { - var rv = []; - for (var i = 0, len = this.length; i < len; i++) { - var m = this[i]; + let rv = []; + for (let i = 0, len = this.length; i < len; i++) { + let m = this[i]; if (!this.__consumedInitCodeSlots__[i]) { rv.push(rmCommonWS$5` @@ -31285,8 +31303,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; - - // make sure a comment does not contain any embedded '*/' end-of-comment marker // as that would break the generated code function postprocessComment(str) { @@ -31310,13 +31326,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function provideSymbolAsSourcecode(sym) { - var ss = String(sym); + let ss = String(sym); return ' /* ' + postprocessComment(ss) + ' */ ' + getSymbolId(sym); } // helper: convert index string/number to proper JS add/subtract expression function indexToJsExpr(n, len, rule4msg) { - var v = parseInt(n, 10); + let v = parseInt(n, 10); // the usual situation: `$3`; MUST reference an rhs[] element or it will be considered an ERROR: if (v > 0) { if (v > len) { @@ -31346,35 +31362,33 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return ''; } + // options object { actionGroups, actionGroupValue, stateHasAction } is `this` for this function/callback: function buildProductionAction(handle) { - var i; - var aliased = handle.aliases, - rhs_i; + let aliased = handle.aliases; - var rhs = handle.handle; - var named_token_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$3}$`); + let rhs = handle.handle; + let named_token_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$3}$`); // semantic action specified - var label = [ + let label = [ 'case ', handle.id, ':', '\n /*! Production:: ', postprocessComment(handle.symbol), ' : ' ].concat(postprocessComment(rhs.map(function (sym) { // check if the symbol is a literal terminal, and if it is, quote it: if (sym && !self.nonterminals[sym] && !named_token_re.test(sym) && sym !== self.EOF) { return '"' + sym.replace(/["]/g, '\\"') + '"'; - } - else if (!sym) { + } else if (!sym) { sym = '%epsilon'; } return sym; })), ' */').join(''); - var action = preprocessActionCode(handle.action || ''); - var rule4msg = handle.symbol + ': ' + rhs.join(' '); + let action = preprocessActionCode(handle.action || ''); + let rule4msg = handle.symbol + ': ' + rhs.join(' '); assert__default['default'](typeof handle.id === 'number'); assert__default['default'](handle.id >= 0); - stateHasAction[handle.id] = true; + this.stateHasAction[handle.id] = true; // before anything else, replace direct symbol references, e.g. #NUMBER# when there's a %token NUMBER for your grammar. // This is done to prevent incorrect expansions where tokens are used in rules as RHS elements: we allow these to @@ -31389,9 +31403,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // replace named semantic values ($nonterminal) if (action.match(new XRegExp__default['default'](`(?:[$@#]|##)${ID_REGEX_BASE$3}`))) { - var count = {}, - names = {}, - donotalias = {}; + let count = {}; + let names = {}; + let donotalias = {}; // When the rule is fitted with aliases it doesn't mean that the action code MUST use those: // we therefor allow access to both the original (non)terminal and the alias. @@ -31422,9 +31436,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // as an explicit alias: adding auto-alias `e1` would then break the system, // while `e2` would be ambiguous from the human perspective as he *might* then // expect `e2` and `e3`. - var addName = function addName(s) { - var base = s.replace(/[0-9]+$/, ''); - var dna = donotalias[base]; + let addName = function addName(s, i) { + let base = s.replace(/[0-9]+$/, ''); + let dna = donotalias[base]; if (names[s]) { count[s]++; @@ -31445,28 +31459,28 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // register the alias/rule name when the real one ends with a number, e.g. `rule5` as // *blocking* the auto-aliasing process for the term of the same base, e.g. `rule`. // This will catch the `WORD[e1]` example above too, via `e1` --> `donotalias['e']` - var markBasename = function markBasename(s) { + let markBasename = function markBasename(s) { if (/[0-9]$/.test(s)) { s = s.replace(/[0-9]+$/, ''); donotalias[s] = true; } }; - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // mark both regular and aliased names, e.g., `id[alias1]` and `id1` - rhs_i = aliased[i]; + let rhs_i = aliased[i]; markBasename(rhs_i); if (rhs_i !== rhs[i]) { markBasename(rhs[i]); } } - for (i = 0; i < rhs.length; i++) { + for (let i = 0; i < rhs.length; i++) { // check for aliased names, e.g., id[alias] - rhs_i = aliased[i]; - addName(rhs_i); + let rhs_i = aliased[i]; + addName(rhs_i, i); if (rhs_i !== rhs[i]) { - addName(rhs[i]); + addName(rhs[i], i); } } action = action.replace( @@ -31483,7 +31497,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; .replace(/\$\$/g, 'this.$') .replace(/@\$/g, 'this._$') .replace(/#\$/g, function (_) { - return provideSymbolAsSourcecode(symbol); + return provideSymbolAsSourcecode(handle.symbol); }) // replace semantic value references ($n) with stack value (stack[n]) .replace(/\$(-?\d+)\b/g, function (_, n) { @@ -31502,7 +31516,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }) // same as above for token ID references (#n) .replace(/#(-?\d+)\b/g, function (_, n) { - var i = parseInt(n, 10) - 1; + let i = parseInt(n, 10) - 1; if (!rhs[i]) { throw new Error(`invalid token location reference in action code for rule: "${rule4msg}" - location reference: "${_}"`); } @@ -31546,7 +31560,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // the action code: if some Smart Alec decides to code `this.$` instead of // `$$` it SHOULD NOT confuse the code analysis here! - var uses_$$ = analyzeFeatureUsage(action, /\bthis\.\$[^\w]/g, 0); // use includes assignment, not just read accesses! + let uses_$$ = analyzeFeatureUsage(action, /\bthis\.\$[^\w]/g, 0); // use includes assignment, not just read accesses! // the next check is very rough; we need the AST of the code to do better than this. function analyzeFeatureAssignmentBeforeUse(source, assignment_re, access_re) { @@ -31555,8 +31569,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // If no assignment can be found at all, we're probably looking at access-only // OR weird constructs we don't yet understand, in which case we play it safe. - var prelude = source; - var m = source.match(assignment_re); + let prelude = source; + let m = source.match(assignment_re); if (m) { // check the closure exists in the regex: m[1] is filled with its content: assert__default['default'](m[1] != null); @@ -31586,21 +31600,21 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return false; // assignment before access (or no usage and assignments at all!) } - var uses_$$_before_assignment = uses_$$ && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\.\$\s*=[^=>]/, /\bthis\.\$[^\w]/g); + let uses_$$_before_assignment = uses_$$ && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\.\$\s*=[^=>]/, /\bthis\.\$[^\w]/g); // ditto for location tracking, but only iff we use it at all: - var uses_$loc = false; - var uses_$loc_before_assignment = false; + let uses_$loc = false; + let uses_$loc_before_assignment = false; if (self.actionsUseLocationTracking) { uses_$loc = analyzeFeatureUsage(action, /\bthis\._\$[^\w]/g, 0); uses_$loc_before_assignment = uses_$loc && analyzeFeatureAssignmentBeforeUse(action, /^([^]*?)\bthis\._\$\s*=[^=>]/, /\bthis\._\$[^\w]/g); } - var inject_default_value_action = (uses_$$_before_assignment || (self.actionsUseValueTracking && !uses_$$)); - var inject_default_loc_action = (uses_$loc_before_assignment || (self.actionsUseLocationTracking && !uses_$loc)); + let inject_default_value_action = (uses_$$_before_assignment || (self.actionsUseValueTracking && !uses_$$)); + let inject_default_loc_action = (uses_$loc_before_assignment || (self.actionsUseLocationTracking && !uses_$loc)); - var default_action = []; + let default_action = []; // Note: // @@ -31611,26 +31625,27 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // $$ = undefined; // $@ = undefined; // - var vmode = !inject_default_value_action ? "skip" : self.options.defaultActionMode[0]; - var lmode = !inject_default_loc_action ? "skip" : self.options.defaultActionMode[1]; + let vmode = !inject_default_value_action ? 'skip' : self.options.defaultActionMode[0]; + let lmode = !inject_default_loc_action ? 'skip' : self.options.defaultActionMode[1]; // check if there's no user action specified. Insert default action if it isn't. // first determine the actual number of terms in the production: - var rhs = handle.handle.slice(0); - var real_rhs_length = rhs.length; + let rhs_reduced_length = rhs.length; + let real_rhs_length = rhs.length; // strip away EOF terms at the end of the rule, ditto for epsilon terms: - if (rhs.length) { - switch (rhs[rhs.length - 1]) { + while (rhs_reduced_length) { + switch (rhs[rhs_reduced_length - 1]) { case '$end': - rhs.length--; - break; + rhs_reduced_length--; + continue; case '': // %epsilon - rhs.length--; - break; + rhs_reduced_length--; + continue; } + break; } // then we can choose what to do, depending on the number of terms in the production. @@ -31647,18 +31662,18 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // Ditto for location tracking default actions... // - switch (rhs.length) { + switch (rhs_reduced_length) { case 0: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; <-- but that would cause nondeterministic behaviour, so // we fall back to the default here! - case "ast": - case "none": - default_action.push("this.$ = undefined;"); + case 'ast': + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31667,22 +31682,22 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // an empty production has no location as there are no terms parsed. // ergo: we produce a zero-width location which points at the tail // end of the previous content: // @$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);"); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31693,19 +31708,19 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; case 1: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; // // WARNING: be careful with the ACCEPT rule as that one's production has - // rhs.length === 1 **BUT** has real_rhs_length === 2 as we have discarded + // rhs_reduced_length === 1 **BUT** has real_rhs_length === 2 as we have discarded // the `$end` term at the end! // Here we need to account for that magick though! - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // As we're looking at a production which has one(1) useful term, we can simply // reference-copy that one intom a fresh array, instead of `slice()`-ing it out // of the vstack. @@ -31714,14 +31729,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // WARNING/NOTE: as above, and ditto BTW for rule productions which end with // `EOF` as a last term: as we now construct an entire AST, we DO NOT include // those 'values' here! - default_action.push("this.$ = [yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "]];"); + default_action.push('this.$ = [yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ']];'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31730,23 +31745,23 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: // as we have a production length of 1 only, we can simply ref-copy @1: // @$ = @1; // // WARNING: same as above for the value copying: we may have discarded an `EOF` or `$end` term! - default_action.push("this._$ = yylstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this._$ = yylstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31757,29 +31772,29 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; default: switch (vmode) { - case "classic": + case 'classic': // $$ = $1; - default_action.push("this.$ = yyvstack[yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + "];"); + default_action.push('this.$ = yyvstack[yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + '];'); break; - case "ast": + case 'ast': // bundle all production terms in an array: - // $$ = yyvstack.slice(yysp - ${rhs.length - 1}, yysp + 1); + // $$ = yyvstack.slice(yysp - ${rhs_reduced_length - 1}, yysp + 1); // - // WARNING: as with the situation further above where rhs.length === 1 after we + // WARNING: as with the situation further above where rhs_reduced_length === 1 after we // have got rid of a possible `EOF` or `$end` at the end of the production, // we again have to account for our trickery earlier and compensate the // action above: again we DO NOT include the value of the EOF/$end token in the // resulting array 'AST', hence our `slice()` end index may vary by one(1): - var end_offset = 1 - real_rhs_length + rhs.length; - default_action.push("this.$ = yyvstack.slice(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp" + /* CANNOT USE indexToJsExpr(rhs.length + 1, real_rhs_length, rule4msg) HERE! */ (end_offset === 0 ? "" : " + " + end_offset) + ");"); + let end_offset = 1 - real_rhs_length + rhs_reduced_length; + default_action.push('this.$ = yyvstack.slice(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp' + /* CANNOT USE indexToJsExpr(rhs_reduced_length + 1, real_rhs_length, rule4msg) HERE! */ (end_offset === 0 ? '' : ' + ' + end_offset) + ');'); break; - case "none": - default_action.push("this.$ = undefined;"); + case 'none': + default_action.push('this.$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31788,20 +31803,20 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } switch (lmode) { - case "classic": - case "ast": - case "merge": + case 'classic': + case 'ast': + case 'merge': // merge all production terms' locations into a single range: - // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs.length - 1}, yysp); - default_action.push("this._$ = yyparser.yyMergeLocationInfo(yysp" + indexToJsExpr(1, real_rhs_length, rule4msg) + ", yysp);"); + // @$ = yyparser.yyMergeLocationInfo(yysp - ${rhs_reduced_length - 1}, yysp); + default_action.push('this._$ = yyparser.yyMergeLocationInfo(yysp' + indexToJsExpr(1, real_rhs_length, rule4msg) + ', yysp);'); break; - case "none": + case 'none': // @$ = undefined; - default_action.push("this._$ = undefined;"); + default_action.push('this._$ = undefined;'); break; - case "skip": + case 'skip': // nothing to inject break; @@ -31814,16 +31829,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // comment/mark the default action chunk, if any, so we can simply observe // what is user code and what is generated by us in the final product: if (default_action.length > 0) { - var flags = [ - rhs.length, - self.actionsUseValueTracking ? "VT" : "-", - self.actionsUseValueAssignment ? "VA" : "-", - uses_$$ ? "VU" : "-", - uses_$$_before_assignment ? "VUbA" : "-", - self.actionsUseLocationTracking ? "LT" : "-", - self.actionsUseLocationAssignment ? "LA" : "-", - uses_$loc ? "LU" : "-", - uses_$loc_before_assignment ? "LUbA" : "-", + let flags = [ + rhs_reduced_length + '/' + real_rhs_length, + self.actionsUseValueTracking ? 'VT' : '-', + self.actionsUseValueAssignment ? 'VA' : '-', + uses_$$ ? 'VU' : '-', + uses_$$_before_assignment ? 'VUbA' : '-', + self.actionsUseLocationTracking ? 'LT' : '-', + self.actionsUseLocationAssignment ? 'LA' : '-', + uses_$loc ? 'LU' : '-', + uses_$loc_before_assignment ? 'LUbA' : '-' ].join(','); default_action.unshift(`// default action (generated by JISON mode ${self.options.defaultActionMode[0]}/${self.options.defaultActionMode[1]} :: ${flags}):`); @@ -31837,16 +31852,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; action = reindentCodeBlock(action, 4); - var actionHash = mkHashIndex(action); + let actionHash = mkHashIndex(action); // Delay running the postprocess (restore) process until we've done ALL macro expansions: //action = postprocessActionCode(action); - if (actionHash in actionGroups) { - actionGroups[actionHash].push(label); + if (actionHash in this.actionGroups) { + this.actionGroups[actionHash].push(label); } else { - actionGroups[actionHash] = [label]; - actionGroupValue[actionHash] = action; + this.actionGroups[actionHash] = [ label ]; + this.actionGroupValue[actionHash] = action; } } }; @@ -31866,7 +31881,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; //generator.trace.name = 'no_op_trace'; generator.warn = function warn() { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); Jison$1.print.call(null, args.join('')); }; @@ -31913,9 +31928,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // LR specific mixin class later on, so that we can have another // implementation/report for LL and PEG type grammars. - var rows = 0, cols = 0; - var colmarks = {}; - var i, j, len; + let rows = 0, cols = 0; + let colmarks = {}; + let i, j, len; for (i = 0, len = this.table.length; i < len; i++) { rows++; @@ -31926,8 +31941,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } } - var defrows = 0; - var rowmarks = {}; + let defrows = 0; + let rowmarks = {}; for (j in this.defaultActions) { if (!rowmarks[j]) { rowmarks[j] = true; @@ -31935,8 +31950,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } - var ntc = 0; - for (var nt in this.nonterminals) { + let ntc = 0; + for (let nt in this.nonterminals) { ntc++; } @@ -31955,14 +31970,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // --- START of debugTraceSrc chunk --- const debugTraceSrc = ` function debug_trace() { - "use strict"; - if (typeof Jison !== 'undefined' && Jison.print) { Jison.print.apply(null, arguments); } else if (typeof print !== 'undefined') { print.apply(null, arguments); } else if (typeof console !== 'undefined' && console.log) { - var args = Array.prototype.slice.call(arguments, 0); + let args = Array.prototype.slice.call(arguments, 0); args.unshift(''); // prevent \`%.\` printf-style expansions; see https://nodejs.org/api/console.html#console_console_log_data_args console.log.apply(null, args); } @@ -31972,14 +31985,14 @@ function debug_trace() { // Generator debug mixin - var generatorDebug = { + const generatorDebug = { trace: (new Function('', debugTraceSrc + ` return debug_trace;`))(), beforeprocessGrammar: function () { this.trace('Processing grammar.'); }, afteraugmentGrammar: function () { - var trace = this.trace; + let trace = this.trace; trace('\nSymbols:\n'); each(this.symbols, function (sym, i) { trace(sym + '(' + i + ')'); @@ -31993,7 +32006,7 @@ function debug_trace() { /* * Mixin for common behaviors of lookahead parsers */ - var lookaheadMixin = {}; + let lookaheadMixin = {}; lookaheadMixin.computeLookaheads = function computeLookaheads() { if (this.DEBUG) { @@ -32007,11 +32020,11 @@ function debug_trace() { }; lookaheadMixin.displayFollowSets = function displayFollowSets() { - var self = this; - var symfollowdbg = {}; + let self = this; + let symfollowdbg = {}; this.productions.forEach(function Follow_prod_forEach_debugOut(production, k) { - var key = ['prod-', k, ': ', production.symbol, ' := ', production.handle.join(' ')].join(''); - var flw = '[' + self.nonterminals[production.symbol].follows.join('] [') + ']'; + let key = [ 'prod-', k, ': ', production.symbol, ' := ', production.handle.join(' ') ].join(''); + let flw = '[' + self.nonterminals[production.symbol].follows.join('] [') + ']'; if (!symfollowdbg[flw]) { symfollowdbg[flw] = {}; } @@ -32022,9 +32035,9 @@ function debug_trace() { symfollowdbg[flw][key]++; } }); - for (var l in symfollowdbg) { - var lst = []; - for (var k in symfollowdbg[l]) { + for (let l in symfollowdbg) { + let lst = []; + for (let k in symfollowdbg[l]) { lst.push(k); } self.trace('Symbol/Follows:\n ', lst.join('\n '), ' -->\n ', l); @@ -32033,10 +32046,10 @@ function debug_trace() { // calculate follow sets based on first and nullable lookaheadMixin.followSets = function followSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true; + let productions = this.productions; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { @@ -32045,23 +32058,23 @@ function debug_trace() { productions.forEach(function Follow_prod_forEach(production, k) { // q is used in Simple LALR algorithm determine follows in context - var q; - var ctx = !!self.go_; + let q; + let ctx = !!self.go_; - for (var i = 0, t; (t = production.handle[i]); ++i) { + for (let i = 0, t; (t = production.handle[i]); ++i) { if (!nonterminals[t]) continue; // for Simple LALR algorithm, self.go_ checks if if (ctx) { q = self.go_(production.symbol, production.handle.slice(0, i)); } - var bool = (!ctx || q === self.nterms_[t]); - var set; + let bool = (!ctx || q === self.nterms_[t]); + let set; if (i === production.handle.length - 1 && bool) { set = nonterminals[production.symbol].follows; } else { - var part = production.handle.slice(i + 1); + let part = production.handle.slice(i + 1); set = self.first(part); if (self.nullable(part) && bool) { @@ -32069,8 +32082,8 @@ function debug_trace() { set.push.apply(set, nonterminals[production.symbol].follows); } } - var follows = nonterminals[t].follows; - var oldcount = follows.length; + let follows = nonterminals[t].follows; + let oldcount = follows.length; follows = union(follows, set); if (oldcount !== follows.length) { cont = true; @@ -32092,8 +32105,8 @@ function debug_trace() { return []; // RHS } else if (symbol instanceof Array) { - var firsts = []; - for (var i = 0, t; (t = symbol[i]); ++i) { + let firsts = []; + for (let i = 0, t; (t = symbol[i]); ++i) { if (!this.nonterminals[t]) { if (firsts.indexOf(t) === -1) { firsts.push(t); @@ -32101,41 +32114,39 @@ function debug_trace() { } else { firsts = union(firsts, this.nonterminals[t].first); } - if (!this.nullable(t)) - break; + if (!this.nullable(t)) { break; } } return firsts; // terminal } else if (!this.nonterminals[symbol]) { - return [symbol]; + return [ symbol ]; // nonterminal - } else { - return this.nonterminals[symbol].first; } + return this.nonterminals[symbol].first; + }; // fixed-point calculation of FIRST sets lookaheadMixin.firstSets = function firstSets() { - var productions = this.productions, - nonterminals = this.nonterminals, - self = this, - cont = true, - symbol, firsts; + let productions = this.productions; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { cont = false; productions.forEach(function FirstSets_forEach(production, k) { - var firsts = self.first(production.handle); + let firsts = self.first(production.handle); if (firsts.length !== production.first.length) { production.first = firsts; cont = true; } }); - for (symbol in nonterminals) { - firsts = []; + for (let symbol in nonterminals) { + let firsts = []; nonterminals[symbol].productions.forEach(function FirstSets_forEachNonTerm(production) { firsts = union(firsts, production.first); }); @@ -32149,9 +32160,9 @@ function debug_trace() { // fixed-point calculation of NULLABLE lookaheadMixin.nullableSets = function nullableSets() { - var nonterminals = this.nonterminals, - self = this, - cont = true; + let nonterminals = this.nonterminals; + let self = this; + let cont = true; // loop until no further changes have been made while (cont) { @@ -32160,7 +32171,9 @@ function debug_trace() { // check if each production is nullable this.productions.forEach(function isEachProductionNullable(production, k) { if (!production.nullable) { - for (var i = 0, n = 0, t; (t = production.handle[i]); ++i) { + let i = 0; + let n = 0; + for (let t; (t = production.handle[i]); ++i) { if (self.nullable(t)) n++; } if (n === i) { // production is nullable if all tokens are nullable @@ -32170,9 +32183,9 @@ function debug_trace() { }); // check if each symbol is nullable - for (var symbol in nonterminals) { + for (let symbol in nonterminals) { if (!this.nullable(symbol)) { - for (var i = 0, production; (production = nonterminals[symbol].productions.item(i)); i++) { + for (let i = 0, production; (production = nonterminals[symbol].productions.item(i)); i++) { if (production.nullable) { nonterminals[symbol].nullable = cont = true; } @@ -32189,7 +32202,7 @@ function debug_trace() { return true; // RHS } else if (symbol instanceof Array) { - for (var i = 0, t; (t = symbol[i]); ++i) { + for (let i = 0, t; (t = symbol[i]); ++i) { if (!this.nullable(t)) { return false; } @@ -32199,14 +32212,14 @@ function debug_trace() { } else if (!this.nonterminals[symbol]) { return false; // nonterminal - } else { - return this.nonterminals[symbol].nullable; } + return this.nonterminals[symbol].nullable; + }; // lookahead debug mixin - var lookaheadDebug = { + const lookaheadDebug = { beforenullableSets: function () { this.trace('Computing Nullable sets.'); }, @@ -32217,7 +32230,7 @@ function debug_trace() { this.trace('Computing Follow sets.'); }, afterfollowSets: function () { - var trace = this.trace; + let trace = this.trace; trace('\nNonterminals:\n'); each(this.nonterminals, function (nt, t) { trace(nt.toString(), '\n'); @@ -32229,7 +32242,7 @@ function debug_trace() { /* * Mixin for common LR parser behavior */ - var lrGeneratorMixin = {}; + let lrGeneratorMixin = {}; // LR state machine actions: @@ -32282,16 +32295,16 @@ function debug_trace() { return e.id === this.id; }, handleToString: function () { - var handle = this.production.handle.slice(0); + let handle = this.production.handle.slice(0); handle[this.dotPosition] = '.' + (handle[this.dotPosition] || ''); return handle.join(' '); }, toString: function () { - var temp = this.production.handle.slice(0); + let temp = this.production.handle.slice(0); temp[this.dotPosition] = '.' + (temp[this.dotPosition] || ''); - var s = this.production.symbol + ' -> ' + temp.join(' '); - var padlen = Math.max(4, 40 - s.length); - var pad = new Array(padlen); + let s = this.production.symbol + ' -> ' + temp.join(' '); + let padlen = Math.max(4, 40 - s.length); + let pad = new Array(padlen); if (this.follows.length) { s += pad.join(' ') + '#lookaheads= [' + this.follows.join('] [') + ']'; pad = new Array(2); @@ -32304,7 +32317,7 @@ function debug_trace() { } }); - lrGeneratorMixin.ItemSet = Set.prototype.construct({ + lrGeneratorMixin.ItemSet = Set$1.prototype.construct({ afterconstructor: function () { this.reductions = []; this.goes = {}; @@ -32312,13 +32325,13 @@ function debug_trace() { this.shifts = false; this.inadequate = false; this.hash_ = {}; - for (var i = this._items.length - 1; i >= 0; i--) { + for (let i = this._items.length - 1; i >= 0; i--) { this.hash_[this._items[i].id] = true; //i; } }, concat: function concat(set) { - var a = set._items || set; - for (var i = a.length - 1; i >= 0; i--) { + let a = set._items || set; + for (let i = a.length - 1; i >= 0; i--) { this.hash_[a[i].id] = true; } this._items.push.apply(this._items, a); @@ -32332,31 +32345,31 @@ function debug_trace() { return this.hash_[item.id]; }, valueOf: function toValue() { - var v = this._items.map(function (a) { return a.id; }).sort().join('|'); + let v = this._items.map(function (a) { return a.id; }).sort().join('|'); this.valueOf = function valueOf_inner() { return v; }; return v; } }); lrGeneratorMixin.closureOperation = function closureOperation(itemSet) { - var closureSet = new this.ItemSet(); - var self = this; + let closureSet = new this.ItemSet(); + let self = this; - var set = itemSet, - itemQueue, - syms = {}; + let set = itemSet; + let itemQueue; + let syms = {}; do { - itemQueue = new Set(); + itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function CO_set_forEach(item) { - var symbol = item.markedSymbol; + let symbol = item.markedSymbol; // if token is a non-terminal, recursively add closures if (symbol && self.nonterminals[symbol]) { if (!syms[symbol]) { self.nonterminals[symbol].productions.forEach(function CO_nt_forEach(production) { - var newItem = new self.Item(production, 0); + let newItem = new self.Item(production, 0); if (!closureSet.contains(newItem)) { itemQueue.push(newItem); } @@ -32381,8 +32394,8 @@ function debug_trace() { }; lrGeneratorMixin.gotoOperation = function gotoOperation(itemSet, symbol) { - var gotoSet = new this.ItemSet(), - self = this; + let gotoSet = new this.ItemSet(); + let self = this; itemSet.forEach(function goto_forEach(item, n) { if (item.markedSymbol === symbol) { @@ -32397,14 +32410,14 @@ function debug_trace() { * Create unique set of item sets */ lrGeneratorMixin.canonicalCollection = function canonicalCollection() { - var item1 = new this.Item(this.productions[0], 0, [this.EOF]); - var firstStateNoClosure = new this.ItemSet(item1), - firstState = this.closureOperation(firstStateNoClosure), - states = new Set(firstState), - marked = 0, - self = this, - itemSet, - markedSymbols; + let item1 = new this.Item(this.productions[0], 0, [ this.EOF ]); + let firstStateNoClosure = new this.ItemSet(item1); + let firstState = this.closureOperation(firstStateNoClosure); + let states = new Set$1(firstState); + let marked = 0; + let self = this; + let itemSet; + let markedSymbols; states.has = {}; states.has[firstStateNoClosure.valueOf()] = 0; @@ -32426,8 +32439,8 @@ function debug_trace() { // Pushes a unique state into the queue. Some parsing algorithms may perform additional operations lrGeneratorMixin.canonicalCollectionInsert = function canonicalCollectionInsert(symbol, itemSet, states, stateNum) { - var g = this.gotoOperation(itemSet, symbol), - state = states.has[g.valueOf()]; + let g = this.gotoOperation(itemSet, symbol); + let state = states.has[g.valueOf()]; if (typeof state !== 'undefined') { itemSet.edges[symbol] = state; // store goto transition for table @@ -32442,36 +32455,36 @@ function debug_trace() { } itemSet.edges[symbol] = states.size(); // store goto transition for table states.push(g); - g.predecessors[symbol] = [stateNum]; + g.predecessors[symbol] = [ stateNum ]; } } }; lrGeneratorMixin.parseTable = function lrParseTable(itemSets) { - var states = [], - nonterminals = this.nonterminals, - operators = this.operators, - conflictedStates = {}, // set of [state, token] tuples - self = this; + let states = []; + let nonterminals = this.nonterminals; + let operators = this.operators; + let conflictedStates = {}; // set of [state, token] tuples + let self = this; // for each item set itemSets.forEach(function parseTableItem(itemSet, k) { k = +k; - var state = states[k] = {}; - var action, stackSymbol; + let state = states[k] = {}; + let action, stackSymbol; // set shift and goto actions for (stackSymbol in itemSet.edges) { itemSet.forEach(function findShiftAndGotoActions(item, j) { // find shift and goto actions if (item.markedSymbol === stackSymbol) { - var gotoState = itemSet.edges[stackSymbol]; + let gotoState = itemSet.edges[stackSymbol]; assert__default['default'](gotoState); if (nonterminals[stackSymbol]) { // store state to go to after a reduce state[self.symbols_[stackSymbol]] = gotoState; } else { - state[self.symbols_[stackSymbol]] = [SHIFT, gotoState]; + state[self.symbols_[stackSymbol]] = [ SHIFT, gotoState ]; } } }); @@ -32481,25 +32494,25 @@ function debug_trace() { itemSet.forEach(function setAcceptAction(item, j) { if (item.markedSymbol === self.EOF) { // accept - state[self.symbols_[self.EOF]] = [ACCEPT]; + state[self.symbols_[self.EOF]] = [ ACCEPT ]; } }); - var allterms = self.lookAheads ? false : self.terminals; + let allterms = self.lookAheads ? false : self.terminals; // set reductions and resolve potential conflicts itemSet.reductions.forEach(function calcReduction(item, j) { // if parser uses lookahead, only enumerate those terminals - var terminals = allterms || self.lookAheads(itemSet, item); + let terminals = allterms || self.lookAheads(itemSet, item); terminals.forEach(function (stackSymbol) { action = state[self.symbols_[stackSymbol]]; - var op = operators[stackSymbol]; + let op = operators[stackSymbol]; // Reading a terminal and current position is at the end of a production, try to reduce if (action) { - var sol = resolveConflict(item.production, op, [REDUCE, item.production.id], action[0] instanceof Array ? action[0] : action); - self.resolutions.push([k, stackSymbol, sol]); + let sol = resolveConflict(item.production, op, [ REDUCE, item.production.id ], action[0] instanceof Array ? action[0] : action); + self.resolutions.push([ k, stackSymbol, sol ]); if (sol.bydefault) { self.conflicts++; @@ -32537,7 +32550,7 @@ function debug_trace() { if (self.options.noDefaultResolve) { if (!(action[0] instanceof Array)) { - action = [action]; + action = [ action ]; } action.push(sol.r); } @@ -32545,7 +32558,7 @@ function debug_trace() { action = sol.action; } } else { - action = [REDUCE, item.production.id]; + action = [ REDUCE, item.production.id ]; } if (action && action.length) { state[self.symbols_[stackSymbol]] = action; @@ -32596,25 +32609,25 @@ function debug_trace() { // only this time we are careful about the TERROR symbol as a state carrying that one // is an explicitly encoded error recovery rule and should remain as-is. function findDefaults(states, hasErrorRecovery) { - var defaults = {}; + let defaults = {}; states.forEach(function (state, k) { - var act, sym, st; - var i = 0; - var gotos = {}; + let act; + let i = 0; + let gotos = {}; - for (sym in state) { + for (let sym in state) { assert__default['default']({}.hasOwnProperty.call(state, sym)); // it this isn't true, the last part of this function won't work! // keep state rows where there's an error recovery state: if (sym === 2 /* TERROR */) { return; } - st = state[sym]; + let st = state[sym]; if (typeof st !== 'number') { if (st[0] !== REDUCE) { // not a reduce action: forget about this row! return; } - var go = st[1]; + let go = st[1]; if (!gotos[go]) { gotos[go] = true; i++; @@ -32642,8 +32655,8 @@ function debug_trace() { // ... hence we only nuke these table entries (as that makes for a smaller table --> smaller parser file) // when there's no error recovery code included in the generated parser: if (!hasErrorRecovery) { - for (sym in state) { - st = state[sym]; + for (let sym in state) { + let st = state[sym]; if (typeof st !== 'number') { delete state[sym]; } @@ -32658,9 +32671,7 @@ function debug_trace() { // Remove all NONASSOC state transitions from the generated table now that we don't need them any longer function cleanupTable(table) { table.forEach(function (state, k) { - var symbol; - - for (symbol in state) { + for (let symbol in state) { if (state[symbol] === NONASSOC) { delete state[symbol]; } @@ -32670,16 +32681,16 @@ function debug_trace() { // resolves shift-reduce and reduce-reduce conflicts function resolveConflict(production, op, reduce, shift) { - var sln = { - production: production, - operator: op, - r: reduce, - s: shift, - - msg: null, - action: null, - bydefault: false - }; + let sln = { + production: production, + operator: op, + r: reduce, + s: shift, + + msg: null, + action: null, + bydefault: false + }; if (shift[0] === REDUCE) { sln.msg = 'Resolved R/R conflict: use first production declared in grammar.'; @@ -32717,7 +32728,7 @@ function debug_trace() { /* * Mixin for common LR/LL/*any* parser behavior */ - var generatorMixin = {}; + let generatorMixin = {}; // internal helper function: generatorMixin.__prepareOptions = function parser___prepare_Options(opt) { @@ -32731,7 +32742,7 @@ function debug_trace() { // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*?[a-zA-Z0-9_$]$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "parser" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "parser" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else if (opt.warn_cb) { @@ -32747,7 +32758,7 @@ function debug_trace() { }; generatorMixin.generateGenericHeaderComment = function generateGenericHeaderComment() { - var out = ` + let out = ` /* parser generated by jison ${version$2} */ /* @@ -32911,9 +32922,9 @@ function debug_trace() { * Produces a new errorInfo 'hash object' which can be passed into \`parseError()\`. * See it's use in this parser kernel in many places; example usage: * - * var infoObj = parser.constructParseErrorInfo('fail!', null, + * let infoObj = parser.constructParseErrorInfo('fail!', null, * parser.collect_expected_token_set(state), true); - * var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); + * let retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); * * originalParseError: function(str, hash, ExceptionClass), * The basic \`parseError\` handler provided by JISON. @@ -33115,212 +33126,7 @@ function debug_trace() { * flex: boolean * optional: \`true\` ==> flex-like lexing behaviour where the rules are tested * exhaustively to find the longest match. - * backtrack_lexer: boolean (⅏ 센 ⅊ ⁖ ⁘ ⁙ ⁚ ⁛ ⁜ ⁝ ⁞ † ‡ - a⯈b - ∀ ∁ ∂ ∃ ∄ ∅ ∆ ∇ ∈ ∉ ∊ ∋ ∌ ∍ ∎ ∏ -U+221x ∐ ∑ − ∓ ∔ ∕ ∖ ∗ ∘ ∙ √ ∛ ∜ ∝ ∞ ∟ -U+222x ∠ ∡ ∢ ∣ ∤ ∥ ∦ ∧ ∨ ∩ ∪ ∫ ∬ ∭ ∮ ∯ -U+223x ∰ ∱ ∲ ∳ ∴ ∵ ∶ ∷ ∸ ∹ ∺ ∻ ∼ ∽ ∾ ∿ -U+224x ≀ ≁ ≂ ≃ ≄ ≅ ≆ ≇ ≈ ≉ ≊ ≋ ≌ ≍ ≎ ≏ -U+225x ≐ ≑ ≒ ≓ ≔ ≕ ≖ ≗ ≘ ≙ ≚ ≛ ≜ ≝ ≞ ≟ -U+226x ≠ ≡ ≢ ≣ ≤ ≥ ≦ ≧ ≨ ≩ ≪ ≫ ≬ ≭ ≮ ≯ -U+227x ≰ ≱ ≲ ≳ ≴ ≵ ≶ ≷ ≸ ≹ ≺ ≻ ≼ ≽ ≾ ≿ -U+228x ⊀ ⊁ ⊂ ⊃ ⊄ ⊅ ⊆ ⊇ ⊈ ⊉ ⊊ ⊋ ⊌ ⊍ ⊎ ⊏ -U+229x ⊐ ⊑ ⊒ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊜ ⊝ ⊞ ⊟ -U+22Ax ⊠ ⊡ ⊢ ⊣ ⊤ ⊥ ⊦ ⊧ ⊨ ⊩ ⊪ ⊫ ⊬ ⊭ ⊮ ⊯ -U+22Bx ⊰ ⊱ ⊲ ⊳ ⊴ ⊵ ⊶ ⊷ ⊸ ⊹ ⊺ ⊻ ⊼ ⊽ ⊾ ⊿ -U+22Cx ⋀ ⋁ ⋂ ⋃ ⋄ ⋅ ⋆ ⋇ ⋈ ⋉ ⋊ ⋋ ⋌ ⋍ ⋎ ⋏ -U+22Dx ⋐ ⋑ ⋒ ⋓ ⋔ ⋕ ⋖ ⋗ ⋘ ⋙ ⋚ ⋛ ⋜ ⋝ ⋞ ⋟ -U+22Ex ⋠ ⋡ ⋢ ⋣ ⋤ ⋥ ⋦ ⋧ ⋨ ⋩ ⋪ ⋫ ⋬ ⋭ ⋮ ⋯ -U+22Fx ⋰ ⋱ ⋲ ⋳ ⋴ ⋵ ⋶ ⋷ ⋸ ⋹ ⋺ ⋻ ⋼ ⋽ ⋾ ⋿) -U+230x ⌀ ⌁ ⌂ ⌃ ⌄ ⌅ ⌆ ⌇ ⌈ ⌉ ⌊ ⌋ ⌌ ⌍ ⌎ ⌏ -U+231x ⌐ ⌑ ⌒ ⌓ ⌔ ⌕ ⌖ ⌗ ⌘ ⌙ ⌚ ⌛ ⌜ ⌝ ⌞ ⌟ -U+232x ⌠ ⌡ ⌢ ⌣ ⌤ ⌥ ⌦ ⌧ ⌨ 〈 〉 ⌫ ⌬ ⌭ ⌮ ⌯ -U+233x ⌰ ⌱ ⌲ ⌳ ⌴ ⌵ ⌶ ⌷ ⌸ ⌹ ⌺ ⌻ ⌼ ⌽ ⌾ ⌿ -U+234x ⍀ ⍁ ⍂ ⍃ ⍄ ⍅ ⍆ ⍇ ⍈ ⍉ ⍊ ⍋ ⍌ ⍍ ⍎ ⍏ -U+235x ⍐ ⍑ ⍒ ⍓ ⍔ ⍕ ⍖ ⍗ ⍘ ⍙ ⍚ ⍛ ⍜ ⍝ ⍞ ⍟ -U+236x ⍠ ⍡ ⍢ ⍣ ⍤ ⍥ ⍦ ⍧ ⍨ ⍩ ⍪ ⍫ ⍬ ⍭ ⍮ ⍯ -U+237x ⍰ ⍱ ⍲ ⍳ ⍴ ⍵ ⍶ ⍷ ⍸ ⍹ ⍺ ⍻ ⍼ ⍽ ⍾ ⍿ -U+238x ⎀ ⎁ ⎂ ⎃ ⎄ ⎅ ⎆ ⎇ ⎈ ⎉ ⎊ ⎋ ⎌ ⎍ ⎎ ⎏ -U+239x ⎐ ⎑ ⎒ ⎓ ⎔ ⎕ ⎖ ⎗ ⎘ ⎙ ⎚ ⎛ ⎜ ⎝ ⎞ ⎟ -U+23Ax ⎠ ⎡ ⎢ ⎣ ⎤ ⎥ ⎦ ⎧ ⎨ ⎩ ⎪ ⎫ ⎬ ⎭ ⎮ ⎯ -U+23Bx ⎰ ⎱ ⎲ ⎳ ⎴ ⎵ ⎶ ⎷ ⎸ ⎹ ⎺ ⎻ ⎼ ⎽ ⎾ ⎿ -U+23Cx ⏀ ⏁ ⏂ ⏃ ⏄ ⏅ ⏆ ⏇ ⏈ ⏉ ⏊ ⏋ ⏌ ⏍ ⏎ ⏏ -U+23Dx ⏐ ⏑ ⏒ ⏓ ⏔ ⏕ ⏖ ⏗ ⏘ ⏙ ⏚ ⏛ ⏜ ⏝ ⏞ ⏟ -U+23Ex ⏠ ⏡ ⏢ ⏣ ⏤ ⏥ ⏦ ⏧ ⏨ ⏩ ⏪ ⏫ ⏬ ⏭ ⏮ ⏯ -U+23Fx ⏰ ⏱ ⏲ ⏳ ⏴ ⏵ ⏶ ⏷ ⏸ ⏹ ⏺ ⏻ ⏼ ⏽ ⏾ ⏿ - -U+260x ☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☎ ☏ -U+261x ☐ ☑ ☒ ☓ ☔ ☕ ☖ ☗ ☘ ☙ ☚ ☛ ☜ ☝ ☞ ☟ -U+262x ☠ ☡ ☢ ☣ ☤ ☥ ☦ ☧ ☨ ☩ ☪ ☫ ☬ ☭ ☮ ☯ -U+263x ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷ ☸ ☹ ☺ ☻ ☼ ☽ ☾ ☿ -U+264x ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇ ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ -U+265x ♐ ♑ ♒ ♓ ♔ ♕ ♖ ♗ ♘ ♙ ♚ ♛ ♜ ♝ ♞ ♟ -U+266x ♠ ♡ ♢ ♣ ♤ ♥ ♦ ♧ ♨ ♩ ♪ ♫ ♬ ♭ ♮ ♯ -U+267x ♰ ♱ ♲ ♳ ♴ ♵ ♶ ♷ ♸ ♹ ♺ ♻ ♼ ♽ ♾ ♿ -U+268x ⚀ ⚁ ⚂ ⚃ ⚄ ⚅ ⚆ ⚇ ⚈ ⚉ ⚊ ⚋ ⚌ ⚍ ⚎ ⚏ -U+269x ⚐ ⚑ ⚒ ⚓ ⚔ ⚕ ⚖ ⚗ ⚘ ⚙ ⚚ ⚛ ⚜ ⚝ ⚞ ⚟ -U+26Ax ⚠ ⚡ ⚢ ⚣ ⚤ ⚥ ⚦ ⚧ ⚨ ⚩ ⚪ ⚫ ⚬ ⚭ ⚮ ⚯ -U+26Bx ⚰ ⚱ ⚲ ⚳ ⚴ ⚵ ⚶ ⚷ ⚸ ⚹ ⚺ ⚻ ⚼ ⚽ ⚾ ⚿ -U+26Cx ⛀ ⛁ ⛂ ⛃ ⛄ ⛅ ⛆ ⛇ ⛈ ⛉ ⛊ ⛋ ⛌ ⛍ ⛎ ⛏ -U+26Dx ⛐ ⛑ ⛒ ⛓ ⛔ ⛕ ⛖ ⛗ ⛘ ⛙ ⛚ ⛛ ⛜ ⛝ ⛞ ⛟ -U+26Ex ⛠ ⛡ ⛢ ⛣ ⛤ ⛥ ⛦ ⛧ ⛨ ⛩ ⛪ ⛫ ⛬ ⛭ ⛮ ⛯ -U+26Fx ⛰ ⛱ ⛲ ⛳ ⛴ ⛵ ⛶ ⛷ ⛸ ⛹ ⛺ ⛻ ⛼ ⛽ ⛾ ⛿ - - ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ☛ ☞ ✌ ✍ ✎ ✏ -✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -✠ ✡ ✢ ✣ ✤ ✥ ✦ ✧ ★ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ● ❍ ■ ❏ -☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ❐ ❑ ❒ ▲ ▼ ◆ ❖ -◗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ - -U+270x ✀ ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ✊ ✋ ✌ ✍ ✎ ✏ -U+271x ✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -U+272x ✠ ✡ ✢ ✣ a✤b a✥b a✦b a✧b ✨ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -U+273x ✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -U+274x ❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ❌ ❍ ❎ ❏ -U+275x ❐ ❑ ❒ ❓ ❔ ❕ ❖ ❗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ ❟ -U+276x ❠ ❡ ❢ ❣ ❤ ❥ ❦ ❧ ❨ ❩ ❪ ❫ ❬ ❭ ❮ a❯b -U+277x ❰ ❱ ❲ ❳ ❴ ❵ ❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ ❾ ❿ -U+278x ➀ ➁ ➂ ➃ ➄ ➅ ➆ ➇ ➈ ➉ ➊ ➋ ➌ ➍ ➎ ➏ -U+279x ➐ ➑ ➒ ➓ ➔ ➕ ➖ ➗ ➘ ➙ ➚ ➛ ➜ ➝ ➞ ➟ -U+27Ax ➠ ➡ ➢ ➣ ➤ ➥ ➦ ➧ a➨b ➩ ➪ ➫ ➬ ➭ ➮ ➯ -U+27Bx ➰ a➱b ➲ ➳ ➴ ➵ ➶ ➷ ➸ ➹ ➺ ➻ ➼ ➽ ➾ ➿ - -U+2580 ▀ Upper half block -U+2581 ▁ Lower one eighth block -U+2582 ▂ Lower one quarter block -U+2583 ▃ Lower three eighths block -U+2584 ▄ Lower half block -U+2585 ▅ Lower five eighths block -U+2586 ▆ Lower three quarters block -U+2587 ▇ Lower seven eighths block -U+2588 █ Full block -U+2589 ▉ Left seven eighths block -U+258A ▊ Left three quarters block -U+258B ▋ Left five eighths block -U+258C ▌ Left half block -U+258D ▍ Left three eighths block -U+258E ▎ Left one quarter block -U+258F ▏ Left one eighth block -U+2590 ▐ Right half block -U+2591 ░ Light shade -U+2592 ▒ Medium shade -U+2593 ▓ Dark shade -U+2594 ▔ Upper one eighth block -U+2595 ▕ Right one eighth block -U+2596 ▖ Quadrant lower left -U+2597 ▗ Quadrant lower right -U+2598 ▘ Quadrant upper left -U+2599 ▙ Quadrant upper left and lower left and lower right -U+259A ▚ Quadrant upper left and lower right -U+259B ▛ Quadrant upper left and upper right and lower left -U+259C ▜ Quadrant upper left and upper right and lower right -U+259D ▝ Quadrant upper right -U+259E ▞ Quadrant upper right and lower left -U+259F ▟ Quadrant upper right and lower left and lower right -Geometric Shapes -Main articles: Geometric Shapes (Unicode block) and Geometric Shapes Extended (Unicode block) -[hide]Code Glyph Description -U+25A0 ■ Black square -U+25A1 □ White square -U+25A2 ▢ White square with rounded corners -U+25A3 ▣ White square containing small black square -U+25A4 ▤ Square with horizontal fill -U+25A5 ▥ Square with vertical fill -U+25A6 ▦ Square with orthogonal crosshatch fill -U+25A7 ▧ Square with upper left to lower right fill -U+25A8 ▨ Square with upper right to lower left fill -U+25A9 ▩ Square with diagonal crosshatch fill -U+25AA ▪ Black small square -U+25AB ▫ White small square -U+25AC ▬ Black rectangle -U+25AD ▭ White rectangle -U+25AE ▮ Black vertical rectangle -U+25AF ▯ White vertical rectangle -U+25B0 ▰ Black parallelogram -U+25B1 ▱ White parallelogram -U+25B2 ▲ Black up-pointing triangle -U+25B3 △ White up-pointing triangle -U+25B4 ▴ Black up-pointing small triangle -U+25B5 ▵ White up-pointing small triangle -U+25B6 ▶ Black right-pointing triangle -U+25B7 ▷ White right-pointing triangle -U+25B8 ▸ Black right-pointing small triangle -U+25B9 ▹ White right-pointing small triangle -U+25BA ► Black right-pointing pointer -U+25BB ▻ White right-pointing pointer -U+25BC ▼ Black down-pointing triangle -U+25BD ▽ White down-pointing triangle -U+25BE ▾ Black down-pointing small triangle -U+25BF ▿ White down-pointing small triangle -U+25C0 ◀ Black left-pointing triangle -U+25C1 ◁ White left-pointing triangle -U+25C2 ◂ Black left-pointing small triangle -U+25C3 ◃ White left-pointing small triangle -U+25C4 ◄ Black left-pointing pointer -U+25C5 ◅ White left-pointing pointer -U+25C6 ◆ Black diamond -U+25C7 ◇ White diamond -U+25C8 ◈ White diamond containing small black diamond -U+25C9 ◉ Fisheye -U+25CA ◊ Lozenge -U+25CB ○ White circle -U+25CC ◌ Dotted circle -U+25CD ◍ Circle with vertical fill -U+25CE ◎ Bullseye -U+25CF ● Black circle -U+25D0 ◐ Circle with left half black -U+25D1 ◑ Circle with right half black -U+25D2 ◒ Circle with lower half black -U+25D3 ◓ Circle with upper half black -U+25D4 ◔ Circle with upper right quadrant black -U+25D5 ◕ Circle with all but upper left quadrant black -U+25D6 ◖ Left half circle black -U+25D7 ◗ Right half black circle -U+25D8 ◘ Inverse bullet -U+25D9 ◙ Inverse white circle -U+25DA ◚ Upper half inverse white circle -U+25DB ◛ Lower half inverse white circle -U+25DC ◜ Upper left quadrant circular arc -U+25DD ◝ Upper right quadrant circular arc -U+25DE ◞ Lower right quadrant circular arc -U+25DF ◟ Lower left quadrant circular arc -U+25E0 ◠ Upper half circle -U+25E1 ◡ Lower half circle -U+25E2 ◢ Black lower right triangle -U+25E3 ◣ Black lower left triangle -U+25E4 ◤ Black upper left triangle -U+25E5 ◥ Black upper right triangle -U+25E6 ◦ White bullet -U+25E7 ◧ Square with left half black -U+25E8 ◨ Square with right half black -U+25E9 ◩ Square with upper left diagonal half black -U+25EA ◪ Square with lower right diagonal half black -U+25EB ◫ White square with vertical bisecting line -U+25EC ◬ White up-pointing triangle with dot -U+25ED ◭ Up-pointing triangle with left half black -U+25EE ◮ Up-pointing triangle with right half black -U+25EF ◯ Large circle -U+25F0 ◰ White square with upper left quadrant -U+25F1 ◱ White square with lower left quadrant -U+25F2 ◲ White square with lower right quadrant -U+25F3 ◳ White square with upper right quadrant -U+25F4 ◴ White circle with upper left quadrant -U+25F5 ◵ White circle with lower left quadrant -U+25F6 ◶ White circle with lower right quadrant -U+25F7 ◷ White circle with upper right quadrant -U+25F8 ◸ Upper left triangle -U+25F9 ◹ Upper right triangle -U+25FA ◺ Lower-left triangle -U+25FB ◻ White medium square -U+25FC ◼ Black medium square -U+25FD ◽ White medium small square -U+25FE ◾ Black medium small square -U+25FF ◿ Lower right triangle - - + * backtrack_lexer: boolean * optional: \`true\` ==> lexer regexes are tested in order and for invoked; * the lexer terminates the scan when a token is returned by the action code. * xregexp: boolean @@ -33337,7 +33143,7 @@ U+25FF ◿ Lower right triangle generatorMixin.generate = function parser_generate(opt) { opt = this.__prepareOptions(opt); - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -33363,19 +33169,19 @@ U+25FF ◿ Lower right triangle generatorMixin.generateAMDModule = function generateAMDModule(opt) { opt = this.__prepareOptions(opt); - var module = this.generateModule_(); - var out = [ + let module = this.generateModule_(); + let out = [ this.generateGenericHeaderComment(), '', 'define(function (require) {', module.initCode, module.commonCode, '', - 'var parser = ' + module.moduleCode, + 'let parser = ' + module.moduleCode, module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(lexSrc); out.push('parser.lexer = lexer;'); @@ -33383,7 +33189,7 @@ U+25FF ◿ Lower right triangle out.push('', module.moduleInclude, '', 'return parser;'); out.push('});'); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; }; @@ -33391,35 +33197,35 @@ U+25FF ◿ Lower right triangle lrGeneratorMixin.generateESModule = function generateESModule(opt) { opt = this.__prepareOptions(opt); - var module = this.generateModule_(); - var out = [ + let module = this.generateModule_(); + let out = [ this.generateGenericHeaderComment(), '', module.initCode, module.commonCode, '', - 'var parser = ' + module.moduleCode, - module.modulePostlude, + 'let parser = ' + module.moduleCode, + module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(this.lexer.generateModule()); out.push('parser.lexer = lexer;'); } out.push('', module.moduleInclude, ''); - var exportMain = ''; - var invokeMain = ''; + let exportMain = ''; + let invokeMain = ''; if (!opt.noMain) { - var moduleNameAsCode = String(opt.moduleMain || commonJsMain); - var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); + let moduleNameAsCode = String(opt.moduleMain || commonJsMain); + let moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); out.push(rmCommonWS$5` ${moduleImportsAsCode} - var yymain = ${moduleNameAsCode.trim()}; + let yymain = ${moduleNameAsCode.trim()}; function yyExecMain() { yymain(process.argv.slice(1)); @@ -33455,7 +33261,7 @@ U+25FF ◿ Lower right triangle }; `); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return src; }; @@ -33463,11 +33269,11 @@ U+25FF ◿ Lower right triangle generatorMixin.generateCommonJSModule = function generateCommonJSModule(opt) { opt = this.__prepareOptions(opt); - var moduleName = opt.moduleName; - var main = ''; + let moduleName = opt.moduleName; + let main = ''; if (!opt.noMain) { - var moduleNameAsCode = String(opt.moduleMain || commonJsMain); - var moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); + let moduleNameAsCode = String(opt.moduleMain || commonJsMain); + let moduleImportsAsCode = String(opt.moduleMainImports || commonJsMainImports); main = rmCommonWS$5` @@ -33482,7 +33288,7 @@ U+25FF ◿ Lower right triangle } `; } - var out = this.generateModule(opt) + + let out = this.generateModule(opt) + rmCommonWS$5` @@ -33503,17 +33309,16 @@ U+25FF ◿ Lower right triangle generatorMixin.generateModule = function generateModule(opt) { opt = this.__prepareOptions(opt); - var moduleName = opt.moduleName; - var out = this.generateGenericHeaderComment(); + let moduleName = opt.moduleName; + let out = this.generateGenericHeaderComment(); - var self = this; + let self = this; function _generateNamespace(namespaces, previousNamespace, callback) { - var subModuleName = namespaces.shift(); + let subModuleName = namespaces.shift(); if (subModuleName != null) { - var moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; + let moduleName = previousNamespace == null ? subModuleName : previousNamespace + '.' + subModuleName; if (namespaces.length > 0) { - return 'var ' + subModuleName + ';\n' - + '(function (' + subModuleName + ') {\n' + return '(function (' + subModuleName + ') {\n' + _generateNamespace(namespaces, subModuleName, callback) + '\n})(' + subModuleName + (previousNamespace == null ? '' : ' = ' + moduleName) + ' || (' + moduleName + ' = {}));\n'; } @@ -33522,14 +33327,14 @@ U+25FF ◿ Lower right triangle return ''; } - var sourceCodeDef = self.generateModuleExpr(); + let sourceCodeDef = self.generateModuleExpr(); out += ` ${sourceCodeDef.init} `; out += _generateNamespace(moduleName.split('.'), null, function _generateNamespace_cb(moduleName) { - var name = (moduleName.match(/\./) ? moduleName : 'var ' + moduleName); + let name = (moduleName.match(/\./) ? moduleName : 'let ' + moduleName); return ` ${name} = ${sourceCodeDef.src} `; @@ -33541,24 +33346,23 @@ U+25FF ◿ Lower right triangle generatorMixin.generateModuleExpr = function generateModuleExpr() { - var out; - var opt = this.__prepareOptions(); - var module = this.generateModule_(); + let opt = this.__prepareOptions(); + let module = this.generateModule_(); - out = [ + let out = [ '(function () {', module.commonCode, '', - 'var parser = ' + module.moduleCode, - module.modulePostlude, + 'let parser = ' + module.moduleCode, + module.modulePostlude ]; if (this.lexer && this.lexer.generateModule) { - var lexSrc = this.lexer.generateModule(); + let lexSrc = this.lexer.generateModule(); opt.exportSourceCode.lexer = lexSrc; out.push(lexSrc); out.push('parser.lexer = lexer;'); } - out = out.concat(['', + out = out.concat([ '', module.moduleInclude, '', 'function Parser() {', @@ -33571,7 +33375,7 @@ U+25FF ◿ Lower right triangle '})();' ]); - var src = out.join('\n') + '\n'; + let src = out.join('\n') + '\n'; opt.exportSourceCode.all = src; return { @@ -33581,7 +33385,7 @@ U+25FF ◿ Lower right triangle }; function removeUnusedKernelFeatures(parseFn, info) { - var actionFn = info.performAction; + let actionFn = info.performAction; if (info.actionsAreAllDefault) { // in this case, there's no need to call the parseAction function at all: @@ -33623,7 +33427,7 @@ U+25FF ◿ Lower right triangle // if (typeof lexer.yyleng === 'undefined') { // lexer.yyleng = 0; // } - // var yyleng; + // let yyleng; // ... parseFn = parseFn @@ -33642,7 +33446,7 @@ U+25FF ◿ Lower right triangle // remove: // - // var yylineno; + // let yylineno; // ... parseFn = parseFn @@ -33697,7 +33501,7 @@ U+25FF ◿ Lower right triangle // remove: // - // var yyloc = lexer.yylloc; + // let yyloc = lexer.yylloc; // lstack[sp] = yyloc; // ... // lstack[sp] = copy_yylloc(lexer.yylloc); @@ -33737,11 +33541,11 @@ U+25FF ◿ Lower right triangle // } // // and - // + // // if (sp >= 0 && typeof vstack[sp] !== 'undefined') { // retval = vstack[sp]; // } - // + // // but keep the yyval declaration as either location tracking MAY // still be employed by the grammar OR the grammar uses advanced // code which uses `yyval` as a run-time store which carries data @@ -33787,13 +33591,13 @@ U+25FF ◿ Lower right triangle if (info.actionsAreAllDefault) { // remove // - // var yyval = { + // let yyval = { // $: true, // _$: undefined, // yy: sharedState_yy // }; parseFn = parseFn - .replace(/\s+var yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); + .replace(/\s+let yyval =[\s\S]+?\};[^\n]*\n/g, '\n\n\n\n\n\n'); } } @@ -33808,10 +33612,14 @@ U+25FF ◿ Lower right triangle // remove: // - // var yydebug = false; + // let yydebug = false; // ... and delete yydebug function definition ... // ... // if (yydebug) yydebug(...); + // ... + // if (yydebug) { + // yydebug(...); + // } // // and // @@ -33822,9 +33630,10 @@ U+25FF ◿ Lower right triangle parseFn = parseFn - .replace(/\s+var yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') - // strip multi-line `if (debug) yydebug(..., {...});` statements + .replace(/\s+let yydebug = [\s\S]+?self\.trace[\s\S]+?};[^}]+}/g, '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n') + // strip multi-line `if (debug) { yydebug(..., {...}); }` statements // also strip simple yet possibly multi-line `if (debug) yydebug('...');` statements + .replace(/\n\s+if\s+\(yydebug\)\s+\{[\r\n]+\s+yydebug\([^]+?}\);[\s\r\n]+}\s*/g, '\n\n\n\n\n\n\n\n\n') .replace(/\n\s+if\s+\(yydebug\)\s+yydebug\([^]+?['}]\);[^\r\n]*?/g, '\n\n\n\n\n\n\n\n\n') // strip single-line `yydebug(...);` statements .replace(/^.*?\byydebug\b[^;]+?\);[^\r\n]*?$/gm, '') @@ -33909,8 +33718,8 @@ U+25FF ◿ Lower right triangle */ parseFn = parseFn .replace(/\s+try \{([\s\r\n]+this\.__reentrant_call_depth[\s\S]+?)\} catch \(ex\) \{[\s\S]+?\} finally \{([^]+?)\}\s+\/\/\s+\/finally/, function replace_noTryCatch(m, p1, p2) { - p1 = p1.replace(/^ /mg, ' '); - p2 = p2.replace(/^ /mg, ' '); + p1 = p1.replace(/^ {8}/mg, ' '); + p2 = p2.replace(/^ {8}/mg, ' '); return '\n' + p1 + '\n // ... AND FINALLY ...\n' + p2; }) .replace(/^[^\n]+\b__reentrant_call_depth\b[^\n]+$/gm, '\n'); @@ -33968,29 +33777,29 @@ U+25FF ◿ Lower right triangle // // https://github.com/zaach/jison/pull/332 function expandParseArguments(parseFn, self) { - var arglist = self.parseParams; + let arglist = self.parseParams; if (!arglist || arglist.length === 0) { parseFn = parseFn.replace(/, parseParams\b/g, ''); parseFn = parseFn.replace(/\bparseParams\b/g, ''); - parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers:\s+parseParamsAsMembers\b/g, ''); + parseFn = parseFn.replace(/,\s*[\r\n]+\s*parseParamsAsMembers\b/g, ''); } else { parseFn = parseFn.replace(/, parseParams\b/g, ', ' + arglist.join(', ')); parseFn = parseFn.replace(/\bparseParams\b/g, arglist.join(', ')); - parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers:\s+parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { - var s = ','; + parseFn = parseFn.replace(/,\s*[\r\n]+(\s*)parseParamsAsMembers\b/g, function parseParamsReplF(m, ws) { + let s = ','; // determine longest name of the bunch (for formatting the generated code) - var max_k_len = 0; - for (var i = 0, len = arglist.length; i < len; i++) { - var k = arglist[i]; + let max_k_len = 0; + for (let i = 0, len = arglist.length; i < len; i++) { + let k = arglist[i]; max_k_len = Math.max(max_k_len, k.length); } - var wsi2 = (new Array(max_k_len + 1)).join(' '); + let 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 i = 0, len = arglist.length; i < len; i++) { - var k = arglist[i]; + for (let i = 0, len = arglist.length; i < len; i++) { + let k = arglist[i]; s += '\n' + ws + k + ': ' + k + (i < len - 1 ? ',' + wsi2.substr(0, max_k_len - k.length - 1) : wsi2.substr(0, max_k_len - k.length)) + ' // parseParams::' + k; } return s; @@ -34025,17 +33834,17 @@ U+25FF ◿ Lower right triangle } function addOrRemoveTokenStack(fn, wantTokenStack) { - var parseFn = fn; + let parseFn = fn; // We don't use the Esprima+Escodegen toolchain as those loose the code comments easily; // instead we just chop the code using labels as sentinels for our chopping-it-up regexes: // // if (wantTokenStack) { // try { - // var ast = esprima.parse(parseFn); - // var stackAst = esprima.parse(String(tokenStackLex)).body[0]; + // let ast = esprima.parse(parseFn); + // let stackAst = esprima.parse(String(tokenStackLex)).body[0]; // stackAst.id.name = 'lex'; // - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("_token_stack"))', ast); // // labeled[0].body = stackAst; // @@ -34045,7 +33854,7 @@ U+25FF ◿ Lower right triangle // } // } else { // // remove the line: - // // var tstack = []; // token stack + // // let tstack = []; // token stack // parseFn = parseFn.replace(/tstack = .*$/m, ''); // return parseFn; // } @@ -34054,23 +33863,23 @@ U+25FF ◿ Lower right triangle if (wantTokenStack) { // And rename the `tokenStackLex` function to become the new `lex`: return parseFn.replace(/\btokenStackLex\b/g, 'lex'); - } else { - // Also nuke the support declaration statement: - // var tstack = []; - return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); } + // Also nuke the support declaration statement: + // let tstack = []; + return parseFn.replace(/^.*?\btstack\b.*$/gm, ''); + } // returns parse function with/without error recovery code function pickErrorHandlingChunk(fn, hasErrorRecovery) { - var parseFn = fn; + let parseFn = fn; // We don't use the Esprima+Escodegen toolchain as those loose the code comments easily; // instead we just chop the code using labels as sentinels for our chopping-it-up regexes: // try { - // var ast = esprima.parse(parseFn); + // let ast = esprima.parse(parseFn); - // var labeled = JSONSelect.match(':has(:root > .label > .name:val("' + + // let labeled = JSONSelect.match(':has(:root > .label > .name:val("' + // (!hasErrorRecovery ? '_handle_error_with_recovery' : '_handle_error_no_recovery') + // '"))', ast); // Jison.print('labeled: ', labeled); @@ -34086,7 +33895,7 @@ U+25FF ◿ Lower right triangle // and some post-coital touch-ups: if (!hasErrorRecovery) { // Also nuke the support declaration statement: - // var recovering = 0; + // let recovering = 0; // and the recovery support statements: // if (recovering > 0) { // recovering--; @@ -34095,7 +33904,7 @@ U+25FF ◿ Lower right triangle // , recovering: recovering // ASSERT(recovering === 0); parseFn = parseFn - .replace(/^\s*var recovering.*$/gm, '') + .replace(/^\s*let recovering.*$/gm, '') .replace(/, recovering: recovering/g, '') .replace(/^.*?recovering =.*$/gm, '') .replace(/^\s+recovering[,]?\s*$/gm, '') @@ -34107,11 +33916,11 @@ U+25FF ◿ Lower right triangle // ... KILL this chunk ... // } .replace(/\s+if[^a-z]+preErrorSymbol.*?\{\s*\/\/[^\n]+([\s\S]+?)\} else \{[\s\S]+?\}\n\s+\}\n/g, '\n$1\n\n\n\n') - .replace(/^\s+(?:var )?preErrorSymbol = .*$/gm, '') + .replace(/^\s+(?:let )?preErrorSymbol = .*$/gm, '') .replace(/^.*?\bpreErrorSymbol =.*$/gm, '') // And nuke the support declaration statement: - // var lastEofErrorStateDepth = 0; - .replace(/^\s*var lastEofErrorStateDepth.*$/gm, ''); + // let lastEofErrorStateDepth = 0; + .replace(/^\s*let lastEofErrorStateDepth.*$/gm, ''); } return parseFn; } @@ -34120,7 +33929,7 @@ U+25FF ◿ Lower right triangle // - module.commonCode: initialization code that should be placed before the module // - module.moduleCode: code that creates the module object lrGeneratorMixin.generateModule_ = function generateModule_() { - var parseFn = String(parser$4.parse); + let parseFn = String(parser$4.parse); parseFn = pickErrorHandlingChunk(parseFn, this.hasErrorRecovery); parseFn = addOrRemoveTokenStack(parseFn, this.options.tokenStack); @@ -34129,9 +33938,9 @@ U+25FF ◿ Lower right triangle parseFn = expandParseArguments(parseFn, this); - var errorClassCode = this.generateErrorClass(); + let errorClassCode = this.generateErrorClass(); - var exportDest = this.options.exportAllTables; + let exportDest = this.options.exportAllTables; assert__default['default'](exportDest); // store the parse tables: @@ -34139,10 +33948,7 @@ U+25FF ◿ Lower right triangle exportDest.defaultParseActions = this.defaultActions; exportDest.parseProductions = this.productions_; - var exportSourceCode = this.options.exportSourceCode; - assert__default['default'](exportSourceCode); - - var tableCode; + let tableCode; switch (this.options.compressTables | 0) { case 0: // no compression tableCode = this.generateTableCode0(this.table, this.defaultActions, this.productions_); @@ -34165,29 +33971,27 @@ U+25FF ◿ Lower right triangle // Generate the initialization code - var initCode = [].concat( + let initCode = [].concat( this.moduleInit.getInitCodeSection('imports'), this.moduleInit.getInitCodeSection('init') ); - var commonCode = [].concat( + let commonCode = [].concat( this.moduleInit.getInitCodeSection('required'), errorClassCode.commonCode, errorClassCode.moduleCode, - ['\nYY_REMAINING_INIT_CODE_SECTIONS_GO_HERE\n'], + [ '\nYY_REMAINING_INIT_CODE_SECTIONS_GO_HERE\n' ], tableCode.commonCode ); - // sort hash table by key to produce a nicer output: function produceSymbolTable(tbl) { - var a = Object.keys(tbl); + let a = Object.keys(tbl); a.sort(); - var nt = {}; - var k; - for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; + let nt = {}; + for (let i = 0, len = a.length; i < len; i++) { + let k = a[i]; // `$eof` and `EOF` are synonyms of `$end` (`$eof` is for bison compatibility); // this is the only place where two symbol names may map to a single symbol ID number // and we do not want `$eof`/`EOF` to show up in the symbol tables of generated parsers @@ -34201,12 +34005,11 @@ U+25FF ◿ Lower right triangle // swap key and value and then sort hash table by key to produce a nicer output: function produceTerminalTable(tbl) { - var a = Object.keys(tbl); - var nt = {}; - var k, v; - for (var i = 0, len = a.length; i < len; i++) { - k = a[i]; - v = tbl[k]; + let a = Object.keys(tbl); + let nt = {}; + for (let i = 0, len = a.length; i < len; i++) { + let k = a[i]; + let v = tbl[k]; nt[v] = +k; // convert numeric key back to number type; all terminals have numeric keys } return produceSymbolTable(nt); @@ -34214,71 +34017,71 @@ U+25FF ◿ Lower right triangle function produceProductionsForDebugging(options, symbols, base) { function get_orig_symbol(s) { - var a = s.split(':'); + let a = s.split(':'); if (a.length === 1 || a[0] === '') { return { state: -1, symbol: s }; } - var state = a[0]; + let state = a[0]; a.shift(); return { state: +state, - symbol: a.join(':'), + symbol: a.join(':') }; } function get_orig_symbol_set(arr) { - var rv = {}; - for (var i = 0, len = arr.length; i < len; i++) { - var item = arr[i]; - var symbol = get_orig_symbol(item); + let rv = {}; + for (let i = 0, len = arr.length; i < len; i++) { + let item = arr[i]; + let symbol = get_orig_symbol(item); rv[symbol.symbol] = symbol.state; } return Object.keys(rv); } - var tbl = this.nonterminals; - var sym = this.symbols_ || symbols; + let tbl = this.nonterminals; + let sym = this.symbols_ || symbols; if (!options.outputDebugTables && !options.exportAllTables.enabled) { return undefined; } - var prods = { + let prods = { ids: {}, states: {}, rules: {}, nonterminals: {}, symbols: {}, first: {}, - follows: {}, + follows: {} }; - var self = this; + let self = this; this.productions.forEach(function Follow_prod_forEach_genDebugTable(production, k) { - var nonterm = production.symbol; + let nonterm = production.symbol; prods.states[k] = nonterm; prods.ids[nonterm] = sym[nonterm]; - var lst = prods.rules[nonterm] || {}; + let lst = prods.rules[nonterm] || {}; lst[k] = gen_lalr_states_production(production, k, false, k, true); prods.rules[nonterm] = lst; }); function gen_nonterminal(nt) { - var l = nt.productions._items; - var lst = l.map(function (p, i) { + let l = nt.productions._items; + let lst = l.map(function (p, i) { return gen_lalr_states_production(p, i, false, false, false); }); - var rv = { + let rv = { symbol: nt.symbol, productions: lst, first: nt.first, base_first: get_orig_symbol_set(nt.first), follows: nt.follows, base_follows: get_orig_symbol_set(nt.follows), - nullable: nt.nullable, + nullable: nt.nullable }; // clean up structure: ditch superfluous elements: @@ -34292,7 +34095,7 @@ U+25FF ◿ Lower right triangle return rv; } - for (var key in tbl) { + for (let key in tbl) { prods.nonterminals[key] = gen_nonterminal(tbl[key]); } @@ -34301,9 +34104,9 @@ U+25FF ◿ Lower right triangle } function gen_lalr_states_production(production, index, dotPosition, state, patch_base) { - var nonterm = production.symbol; - var hlen = production.handle.length; - var rulestr = production.handle.map(function (t, idx) { + let nonterm = production.symbol; + let hlen = production.handle.length; + let rulestr = production.handle.map(function (t, idx) { if (!t) { t = '%epsilon'; } @@ -34317,7 +34120,7 @@ U+25FF ◿ Lower right triangle rulestr += ' ⬤'; } - var base_rulestr = production.handle.map(function (t) { + let base_rulestr = production.handle.map(function (t) { if (!t) { t = '%epsilon'; } @@ -34325,7 +34128,7 @@ U+25FF ◿ Lower right triangle return t; }).join(' '); - var rv = { + let rv = { symbol: nonterm, base_symbol: get_orig_symbol(nonterm).symbol, handle: rulestr, @@ -34344,12 +34147,11 @@ U+25FF ◿ Lower right triangle }; // Determine state for given production, if it's not a production that's listed as part of a state: - var chk, idx; - var lst = prods.rules[nonterm]; - chk = rv.symbol + ' : ' + rv.handle; - for (idx in lst) { + let lst = prods.rules[nonterm]; + let chk = rv.symbol + ' : ' + rv.handle; + for (let idx in lst) { idx = +idx; - var p = lst[idx]; + let p = lst[idx]; if (p) { if (p.symbol + ' : ' + p.handle === chk) { assert__default['default'](rv.state === -1); @@ -34362,9 +34164,9 @@ U+25FF ◿ Lower right triangle // Try to reference base productions from newg child productions and vice versa: chk = rv.base_symbol + ' : ' + rv.base_handle; if (base && base.rules) { - var pr = base.rules[rv.base_symbol]; - for (idx in pr) { - var bprod = pr[idx]; + let pr = base.rules[rv.base_symbol]; + for (let idx in pr) { + let bprod = pr[idx]; if (bprod.symbol + ' : ' + bprod.handle === chk) { assert__default['default'](rv.base_state === -1); rv.base_state = bprod.state; @@ -34398,13 +34200,13 @@ U+25FF ◿ Lower right triangle if (this.states) { prods.lalr_states = []; - var these_states = this.states; + let these_states = this.states; these_states.forEach(function traverse_states(state, i) { //assert(state.inadequate ? these_states.inadequate : true); state.forEach(function traverse_state(item, j) { // is this a REDUCE state? - var nterm_first = self.nonterminals[item.production.symbol].first; - var rv = { + let nterm_first = self.nonterminals[item.production.symbol].first; + let rv = { state: i, item_index: j, is_reduce_state: (item.dotPosition === item.production.handle.length), @@ -34417,7 +34219,7 @@ U+25FF ◿ Lower right triangle nterm_first: nterm_first, base_nterm_first: get_orig_symbol_set(nterm_first), prod_first: item.production.first, - base_prod_first: get_orig_symbol_set(item.production.first), + base_prod_first: get_orig_symbol_set(item.production.first) }; // clean up structure: ditch superfluous elements: @@ -34436,13 +34238,12 @@ U+25FF ◿ Lower right triangle }); } - var nt = tbl; - var sbn; - for (sbn in nt) { - var orig_symbol = get_orig_symbol(sbn); - var item = nt[sbn]; - var firsts = item.first; - var follows = item.follows; + let nt = tbl; + for (let sbn in nt) { + let orig_symbol = get_orig_symbol(sbn); + let item = nt[sbn]; + let firsts = item.first; + let follows = item.follows; if (!prods.symbols[orig_symbol.symbol]) { prods.symbols[orig_symbol.symbol] = orig_symbol.state; } @@ -34457,10 +34258,10 @@ U+25FF ◿ Lower right triangle prods.follows[orig_symbol.symbol] = prods.follows[orig_symbol.symbol].concat(follows); } } - for (sbn in prods.first) { + for (let sbn in prods.first) { prods.first[sbn] = get_orig_symbol_set(prods.first[sbn]); } - for (sbn in prods.follows) { + for (let sbn in prods.follows) { prods.follows[sbn] = get_orig_symbol_set(prods.follows[sbn]); } @@ -34471,11 +34272,11 @@ U+25FF ◿ Lower right triangle } function produceTerminalDescriptions(tbl, sym) { - var rv = {}; - var count = 0; - for (var k in tbl) { - var descr = tbl[k]; - var id = sym[k]; + let rv = {}; + let count = 0; + for (let k in tbl) { + let descr = tbl[k]; + let id = sym[k]; if (id && descr && descr !== id) { rv[id] = descr; count++; @@ -34485,56 +34286,56 @@ U+25FF ◿ Lower right triangle } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - type: 0, // CLI: --parserType option - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - numExpectedConflictStates: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - json: 1, - _: 1, - noMain: 1, - moduleMain: 1, - moduleMainImports: 1, - noDefaultResolve: 1, - defaultActionMode: 1, - testCompileActionCode: 1, - noTryCatch: 1, - hasPartialLrUpgradeOnConflict: 0, - compressTables: 1, - outputDebugTables: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - lexfile: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - exportAllTables: 1, - exportSourceCode: 1, - tokenStack: 0, - parserErrorsAreRecoverable: 0, - lexerErrorsAreRecoverable: 1, - showSource: 1, - exportAST: 1, - prettyCfg: 1, - - errorRecoveryTokenDiscardCount: 0, - - warn_cb: 0, // function(msg) | true (= use Jison.Print) | false (= throw Exception) - - parseParams: 1, - ranges: 0, + let obj = {}; + let do_not_pass = { + type: 0, // CLI: --parserType option + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + numExpectedConflictStates: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + json: 1, + _: 1, + noMain: 1, + moduleMain: 1, + moduleMainImports: 1, + noDefaultResolve: 1, + defaultActionMode: 1, + testCompileActionCode: 1, + noTryCatch: 1, + hasPartialLrUpgradeOnConflict: 0, + compressTables: 1, + outputDebugTables: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + lexfile: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + exportAllTables: 1, + exportSourceCode: 1, + tokenStack: 0, + parserErrorsAreRecoverable: 0, + lexerErrorsAreRecoverable: 1, + showSource: 1, + exportAST: 1, + prettyCfg: 1, + + errorRecoveryTokenDiscardCount: 0, + + warn_cb: 0, // function(msg) | true (= use Jison.Print) | false (= throw Exception) + + parseParams: 1, + ranges: 0 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -34546,12 +34347,12 @@ U+25FF ◿ Lower right triangle // And now some options which should receive some special processing: if (!obj.hasPartialLrUpgradeOnConflict) { - // only list this option when it's actually TRUE: - delete obj.hasPartialLrUpgradeOnConflict; + // only list this option when it's actually TRUE: + delete obj.hasPartialLrUpgradeOnConflict; } - var pre = obj.pre_parse; - var post = obj.post_parse; + let pre = obj.pre_parse; + let post = obj.post_parse; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_parse = true; @@ -34560,7 +34361,7 @@ U+25FF ◿ Lower right triangle obj.post_parse = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$3})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_parse: true(,)?$/gm, function (m, ls, tc) { @@ -34574,27 +34375,27 @@ U+25FF ◿ Lower right triangle // Generate the module creation code - var termDescrs = produceTerminalDescriptions(this.descriptions_, this.symbols_); + let termDescrs = produceTerminalDescriptions(this.descriptions_, this.symbols_); exportDest.terminalDescriptions = termDescrs; - var descrLst = JSON.stringify(termDescrs, null, 2); + let descrLst = JSON.stringify(termDescrs, null, 2); if (descrLst) { descrLst = descrLst.replace(/"([0-9]+)":/g, '$1:'); } - var rules4Dbg = produceProductionsForDebugging.call(this, this.options); + let rules4Dbg = produceProductionsForDebugging.call(this, this.options); exportDest.parseRules = rules4Dbg; - var rulesLst = ((this.options.outputDebugTables || this.options.exportAllTables.enabled) ? JSON.stringify(rules4Dbg, null, 2) : undefined); + let rulesLst = ((this.options.outputDebugTables || this.options.exportAllTables.enabled) ? JSON.stringify(rules4Dbg, null, 2) : undefined); if (rulesLst) { rulesLst = rulesLst.replace(/"([0-9]+)":/g, '$1:').replace(/^(\s+)"([a-z_][a-z_0-9]*)":/gmi, '$1$2:'); } - var symbolTable = produceSymbolTable(this.symbols_); + let symbolTable = produceSymbolTable(this.symbols_); exportDest.symbolTable = symbolTable; // produce a hash lookup table from the terminal set exportDest.terminalTable = produceTerminalTable(this.terminals_); - var moduleCode = `{ + let moduleCode = `{ // Code Generator Information Report // --------------------------------- // @@ -34658,22 +34459,22 @@ U+25FF ◿ Lower right triangle 'yy: {}', 'options: ' + produceOptions(this.options), 'symbols_: ' + JSON.stringify(symbolTable, null, 2), - 'terminals_: ' + JSON.stringify(this.terminals_, null, 2).replace(/"([0-9]+)":/g, '$1:'), + 'terminals_: ' + JSON.stringify(this.terminals_, null, 2).replace(/"([0-9]+)":/g, '$1:') ].concat( rulesLst ? - 'nonterminals_: ' + rulesLst : - [] + 'nonterminals_: ' + rulesLst : + [] ).concat( descrLst ? - 'terminal_descriptions_: ' + descrLst : - [] + 'terminal_descriptions_: ' + descrLst : + [] ).concat([ define_parser_APIs_1.trim(), 'productions_: ' + tableCode.productionsCode ]).concat( String(this.performAction).trim() !== '' ? - 'performAction: ' + String(this.performAction) : - [] + 'performAction: ' + String(this.performAction) : + [] ).concat([ 'table: ' + tableCode.tableCode, 'defaultActions: ' + tableCode.defaultActionsCode, @@ -34681,24 +34482,24 @@ U+25FF ◿ Lower right triangle 'parse: ' + parseFn.trim() ]).concat( this.actionsUseYYERROR ? - 'yyError: 1' : - [] + 'yyError: 1' : + [] ).concat( this.actionsUseYYRECOVERING ? - 'yyRecovering: 1' : - [] + 'yyRecovering: 1' : + [] ).concat( this.actionsUseYYERROK ? - 'yyErrOk: 1' : - [] + 'yyErrOk: 1' : + [] ).concat( this.actionsUseYYCLEARIN ? - 'yyClearIn: 1' : - [] + 'yyClearIn: 1' : + [] ).join(',\n'); moduleCode += '\n};'; - var exportSourceCode = this.options.exportSourceCode; + const exportSourceCode = this.options.exportSourceCode; assert__default['default'](exportSourceCode); exportSourceCode.parserChunks = { initCode: expandConstantsInGeneratedCode(initCode.join('\n'), this), @@ -34706,8 +34507,8 @@ U+25FF ◿ Lower right triangle moduleCode: expandConstantsInGeneratedCode(moduleCode, this), modulePostlude: [ 'parser.originalParseError = parser.parseError;', - 'parser.originalQuoteName = parser.quoteName;', - ].join('\n'), + 'parser.originalQuoteName = parser.quoteName;' + ].join('\n'), moduleInclude: expandConstantsInGeneratedCode(this.moduleInclude, this) }; return exportSourceCode.parserChunks; @@ -34721,8 +34522,6 @@ U+25FF ◿ Lower right triangle // 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. function JisonParserError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -34739,9 +34538,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -34779,14 +34578,14 @@ JisonParserError.prototype.name = 'JisonParserError'; // Generate code that represents the specified parser table lrGeneratorMixin.generateTableCode0 = function (table, defaultActions, productions) { - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); // Don't surround numerical property name numbers in quotes tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); - var prelude = []; + let prelude = []; // Return the variable initialization code and the table code return { @@ -34799,10 +34598,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // Function that extends an object with the given value for all given keys // e.g., x([1, 3, 4], [6, 7], { x: 1, y: 2 }) = { 1: [6, 7]; 3: [6, 7], 4: [6, 7], x: 1, y: 2 } - var compressor1ObjectCode = ` + let compressor1ObjectCode = ` function x(k, v, o) { o = o || {}; - for (var l = k.length; l--; ) { + for (let l = k.length; l--; ) { o[k[l]] = v; } return o; @@ -34811,10 +34610,10 @@ function x(k, v, o) { // Generate code that represents the specified parser table lrGeneratorMixin.generateTableCode1 = function (table, defaultActions, productions) { - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); - var usesCompressor = false; + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); + let usesCompressor = false; // Don't surround numerical property name numbers in quotes tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); @@ -34823,22 +34622,21 @@ function x(k, v, o) { // e.g., { 1: [6, 7]; 3: [6, 7], 4: [6, 7], 5: 8 } = x([1, 3, 4], [6, 7], { 5: 8 }) tableCode = tableCode.replace(/\{[\s\r\n]*\d+:[^\}]+,[\s\r\n]*\d+:[^\}]+\}/g, function (object) { // Find the value that occurs with the highest number of keys - var value, frequentValue, key, - keys = {}, - keyCount, - maxKeyCount = 0, - keyValue, - keyValues = [], - keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; + let frequentValue; + let keys = {}; + let maxKeyCount = 0; + let keyValue; + let keyValues = []; + let keyValueMatcher = /(\d+):[\s\r\n]*([^:\}]+)(?=,[\s\r\n]*\d+:|\})/g; while ((keyValue = keyValueMatcher.exec(object))) { // For each value, store the keys where that value occurs - key = keyValue[1]; - value = keyValue[2].trim(); - keyCount = 1; + let key = keyValue[1]; + let value = keyValue[2].trim(); + let keyCount = 1; if (!(value in keys)) { - keys[value] = [key]; + keys[value] = [ key ]; } else { keyCount = keys[value].push(key); } @@ -34851,9 +34649,9 @@ function x(k, v, o) { // Construct the object with a function call if the most frequent value occurs multiple times if (maxKeyCount > 1) { // Collect all non-frequent values into a remainder object - for (value in keys) { + for (let value in keys) { if (value !== frequentValue) { - for (var k = keys[value], i = 0, l = k.length; i < l; i++) { + for (let k = keys[value], i = 0, l = k.length; i < l; i++) { keyValues.push(k[i] + ':' + value); } } @@ -34867,10 +34665,10 @@ function x(k, v, o) { }); // Count occurrences of number lists - var list; - var lists = {}; - var listMatcher = /\[[0-9,]+\]/g; - var frequentLists = []; + let list; + let lists = {}; + let listMatcher = /\[[0-9,]+\]/g; + let frequentLists = []; while ((list = listMatcher.exec(tableCode))) { lists[list] = (lists[list] || 0) + 1; @@ -34878,7 +34676,7 @@ function x(k, v, o) { // Replace frequently occurring number lists with variables tableCode = tableCode.replace(listMatcher, function (list) { - var listId = lists[list]; + let listId = lists[list]; // If listId is a number, it represents the list's occurrence frequency if (typeof listId === 'number') { // If the list does not occur frequently, represent it by the list @@ -34893,7 +34691,7 @@ function x(k, v, o) { return listId; }); - var prelude = []; + let prelude = []; // Only include the expander function when it's actually used // (tiny grammars don't have much state duplication, so this shaves off @@ -34904,7 +34702,7 @@ function x(k, v, o) { } if (frequentLists.length > 0) { - prelude.push('var u = [\n ' + frequentLists.join(',\n ') + '\n];'); + prelude.push('let u = [\n ' + frequentLists.join(',\n ') + '\n];'); prelude.push(''); } @@ -34923,9 +34721,9 @@ function x(k, v, o) { throw new Error("Table Compression mode 2 corrupts the table when the 'noDefaultResolve' option is turned on and one or more conflicts occur. Please use a different compression mode and/or disable this option."); } - var tableCode = JSON.stringify(table, null, 2); - var defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); - var productionsCode = JSON.stringify(productions, null, 2); + let tableCode = JSON.stringify(table, null, 2); + let defaultActionsCode = JSON.stringify(defaultActions, null, 2).replace(/"([0-9]+)":/g, '$1:'); + let productionsCode = JSON.stringify(productions, null, 2); // We know a couple of things about the parse table: // @@ -34953,33 +34751,29 @@ function x(k, v, o) { tableCode = tableCode.replace(/"([0-9]+)"(?=:)/g, '$1'); - - function reportColumnsForCompression(def_arr) { - var i, key, len; - var report = []; + let report = []; - len = 0; - for (key in def_arr) { + let len = 0; + for (let key in def_arr) { len = Math.max(len, def_arr[key].length); } - var col_width = 6; - var col_delta_width = 4; + let col_width = 6; + let col_delta_width = 4; function clip(val, width) { - var s = ' ' + val; + let s = ' ' + val; s = s.substr(s.length - width); return s; } - var track_prev4delta = {}; - var c, delta, val, delta_val; - var line = []; + let track_prev4delta = {}; + let line = []; line.push('║'); - for (c in def_arr) { - key = clip(c, col_width); - delta = clip('∆', col_delta_width); + for (let c in def_arr) { + let key = clip(c, col_width); + let delta = clip('∆', col_delta_width); line.push(key); line.push('┊'); line.push(delta); @@ -34989,12 +34783,13 @@ function x(k, v, o) { } report.push(line.join('')); - for (i = 0; i < len; i++) { + for (let i = 0; i < len; i++) { line = []; line.push('║'); - for (c in def_arr) { - var tbl = def_arr[c]; + for (let c in def_arr) { + let val, delta_val; + let tbl = def_arr[c]; if (tbl.length > i) { val = tbl[i] || 0; @@ -35009,8 +34804,8 @@ function x(k, v, o) { delta_val = '.'; } - key = clip(val, col_width); - delta = clip(delta_val, col_delta_width); + let key = clip(val, col_width); + let delta = clip(delta_val, col_delta_width); line.push(key); line.push('┊'); line.push(delta); @@ -35026,16 +34821,16 @@ function x(k, v, o) { // table is array of 1/2-len arrays: function analyzeTableForCompression(table) { // column: productions' row length - var len_col = []; + let len_col = []; // column: productions' shift size / action column - var pop_col = []; + let pop_col = []; // column: rule number for each slot ('rule'): - var rule_col = []; + let rule_col = []; - var i; - var row_count = table.length; + let i; + let row_count = table.length; for (i = 0; i < row_count; i++) { - var prod = table[i]; + let prod = table[i]; len_col.push(prod.length); assert__default['default'](prod.length <= 2); @@ -35046,10 +34841,10 @@ function x(k, v, o) { rule_col.push(prod[1]); } - var def_arr = { - 'len': len_col, - 'pop': pop_col, - 'rule': rule_col, + let def_arr = { + len: len_col, + pop: pop_col, + rule: rule_col }; return def_arr; } @@ -35060,14 +34855,14 @@ function x(k, v, o) { // table is hash of 1/2-len arrays: function analyzeSetForCompression(table) { // column: row index - var idx_col = []; + let idx_col = []; // column: REDUCE productions' goto column - var goto_col = []; + let goto_col = []; - var i; + let i; for (i in table) { i = +i; - var prod = table[i]; + let prod = table[i]; idx_col.push(i); // and the special knowledge about the defaultActions[] table: @@ -35075,9 +34870,9 @@ function x(k, v, o) { goto_col.push(prod); } - var def_arr = { - 'idx': idx_col, - 'goto': goto_col, + let def_arr = { + idx: idx_col, + goto: goto_col }; return def_arr; } @@ -35086,30 +34881,29 @@ function x(k, v, o) { function analyzeGotoTableForCompression(table) { // column: number of symbol hash entries per state slot ('length'): - var len_col = []; + let len_col = []; // column: symbol hash entry key for each slot ('symbol'): - var symbol_col = []; + let symbol_col = []; // column: symbol hash entry value type: number (0) or array (array.length) ('type'): - var type_col = []; + let type_col = []; // column: symbol hash entry value if single GOTO state number ('state'): - var state_col = []; + let state_col = []; // column: symbol hash entry mode value if array slot type (reduce/shift/accept): - var mode_col = []; + let mode_col = []; // column: symbol hash entry goto state value if array slot type: - var goto_col = []; + let goto_col = []; // // column: merged: state_col + goto_col: - // var next_col = []; - - var row_count = table.length; - for (var state = 0; state < row_count; state++) { - var hashtable = table[state]; - var count = 0; - var symbol; - for (symbol in hashtable) { + // let next_col = []; + + let row_count = table.length; + for (let state = 0; state < row_count; state++) { + let hashtable = table[state]; + let count = 0; + for (let symbol in hashtable) { symbol = +symbol; symbol_col.push(symbol); - var slot = hashtable[symbol]; + let slot = hashtable[symbol]; if (slot && slot.length) { // array type slot: assert__default['default'](slot.length === 2 || slot.length === 1); @@ -35136,40 +34930,40 @@ function x(k, v, o) { len_col.push(count); } - var def_arr = { - 'len': len_col, - 'symbol': symbol_col, - 'type': type_col, - 'state': state_col, - 'mode': mode_col, - 'goto': goto_col, + let def_arr = { + len: len_col, + symbol: symbol_col, + type: type_col, + state: state_col, + mode: mode_col, + goto: goto_col //'next': next_col, }; return def_arr; } - var has_compressed_a_table = false; + let has_compressed_a_table = false; function generateColumn(name, col) { - var rv = []; - var i, j, len, l; + let rv = []; - for (i = 0, len = col.length; i < len; i++) { + for (let i = 0, len = col.length; i < len; i++) { // try basic run-length encoding first: - var v = col[i]; + let v = col[i]; + let j; for (j = i + 1; j < len; j++) { if (col[j] !== v) { break; } } - var runlength = j - i; + let runlength = j - i; // try stepped run-length encoding next: - var delta = col[i + 1] - v; - var steplength = 0; + let delta = col[i + 1] - v; + let steplength = 0; // we don't want to replicate the runlength result, so only look for a match // when delta !== 0: @@ -35183,10 +34977,11 @@ function x(k, v, o) { } // try to match the pattern in history: - var best_pos = 0; - var best_len = 0; - var upper_bound = i - 2; + let best_pos = 0; + let best_len = 0; + let upper_bound = i - 2; for (j = 0; j < upper_bound; j++) { + let l; for (l = 0; col[j + l] === col[i + l]; l++) { // No need to check for: // if (j + l === i) break; @@ -35210,28 +35005,24 @@ function x(k, v, o) { } // weight our options now: - var gain = [ + let gain = [ runlength - 2, steplength - 3, best_len - 2 ]; - var optimum_gain = Math.max.apply(null, gain); + let optimum_gain = Math.max.apply(null, gain); if (optimum_gain <= 0) { rv.push(v); - } - else if (optimum_gain === gain[0]) { + } else if (optimum_gain === gain[0]) { rv.push('s', '[' + v + ', ' + runlength + ']'); i += runlength - 1; - } - else if (optimum_gain === gain[1]) { + } else if (optimum_gain === gain[1]) { rv.push('s', '[' + v + ', ' + steplength + ', ' + delta + ']'); i += steplength - 1; - } - else if (optimum_gain === gain[2]) { + } else if (optimum_gain === gain[2]) { rv.push('c', '[' + best_pos + ', ' + best_len + ']'); i += best_len - 1; - } - else { + } else { rv.push(v); //assert(0); // should never get here! } @@ -35241,11 +35032,11 @@ function x(k, v, o) { } } - var code = [ + let code = [ ' ', name, ': ', 'u([', '\n ', - rv.join(',\n '), // JSON.stringify(col, null, 2), + rv.join(',\n '), // JSON.stringify(col, null, 2), '\n', '])' ].join(''); @@ -35254,7 +35045,7 @@ function x(k, v, o) { function generateCompressedTable(def_arr) { - var code = [ + let code = [ 'bp({', generateColumn('pop', def_arr.pop) + ',', generateColumn('rule', def_arr.rule), @@ -35265,7 +35056,7 @@ function x(k, v, o) { function generateCompressedSet(def_arr) { - var code = [ + let code = [ 'bda({', generateColumn('idx', def_arr.idx) + ',', generateColumn('goto', def_arr.goto), @@ -35276,7 +35067,7 @@ function x(k, v, o) { function generateCompressedGotoTable(def_arr) { - var code = [ + let code = [ 'bt({', generateColumn('len', def_arr.len) + ',', generateColumn('symbol', def_arr.symbol) + ',', @@ -35290,18 +35081,18 @@ function x(k, v, o) { } - var tableDef = analyzeGotoTableForCompression(table); - var defaultActionsDef = analyzeSetForCompression(defaultActions); - var productionsDef = analyzeTableForCompression(productions); + let tableDef = analyzeGotoTableForCompression(table); + let defaultActionsDef = analyzeSetForCompression(defaultActions); + let productionsDef = analyzeTableForCompression(productions); const bp_code_container = ` // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -35314,11 +35105,11 @@ function x(k, v, o) { const bda_code_container = ` // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -35328,18 +35119,18 @@ function x(k, v, o) { const bt_code_container = ` // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -35370,7 +35161,7 @@ function x(k, v, o) { // \`this\` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -35387,9 +35178,9 @@ function x(k, v, o) { // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -35403,25 +35194,25 @@ function x(k, v, o) { `; has_compressed_a_table = false; - var tc = generateCompressedGotoTable(tableDef); - var compressGotoTable = has_compressed_a_table; + let tc = generateCompressedGotoTable(tableDef); + let compressGotoTable = has_compressed_a_table; has_compressed_a_table = false; - var dac = generateCompressedSet(defaultActionsDef); - var compressDefaultActions = has_compressed_a_table; + let dac = generateCompressedSet(defaultActionsDef); + let compressDefaultActions = has_compressed_a_table; has_compressed_a_table = false; - var pc = generateCompressedTable(productionsDef); - var compressProductions = has_compressed_a_table; + let pc = generateCompressedTable(productionsDef); + let compressProductions = has_compressed_a_table; - var compressAnything = (compressProductions || compressDefaultActions || compressGotoTable); + let compressAnything = (compressProductions || compressDefaultActions || compressGotoTable); tableCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(tableDef) : '') + (compressGotoTable ? tc : tableCode); defaultActionsCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(defaultActionsDef) : '') + (compressDefaultActions ? dac : defaultActionsCode); productionsCode = ((this.DEBUG || devDebug) ? reportColumnsForCompression(productionsDef) : '') + (compressProductions ? pc : productionsCode); - var prelude = [ + let prelude = [ '', compressProductions ? bp_code_container : '', '', @@ -35429,7 +35220,7 @@ function x(k, v, o) { '', compressGotoTable ? bt_code_container : '', '', - c_s_u_code_container, + c_s_u_code_container ]; if (!compressAnything) { prelude = []; @@ -35445,31 +35236,29 @@ function x(k, v, o) { }; // --- START of commonJsMain chunk --- - // + // // default main method for generated commonjs modules const commonJsMain = ` -function (args) { - "use strict"; - +function __jison_default_main__(args) { // When the parser comes with its own \`main\` function, then use that one: if (typeof exports.parser.main === 'function') { - return exports.parser.main(args); + return exports.parser.main(args); } if (!args[1]) { console.log('Usage:', path.basename(args[0]) + ' FILE'); process.exit(1); } - var source = fs.readFileSync(path.normalize(args[1]), 'utf8'); - var dst = exports.parser.parse(source); + const source = fs.readFileSync(path.normalize(args[1]), 'utf8'); + const dst = exports.parser.parse(source); console.log('parser output:\\n\\n', { type: typeof dst, value: dst }); try { - console.log("\\n\\nor as JSON:\\n", JSON.stringify(dst, null, 2)); + 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... */ } - var rv = 0; + let rv = 0; if (typeof dst === 'number' || typeof dst === 'boolean') { rv = dst; } @@ -35479,16 +35268,16 @@ function (args) { // --- END of commonJsMain chunk --- const commonJsMainImports = ` -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); `; // debug mixin for LR parser generators function printAction(a, gen) { - var s = a[0] === SHIFT ? 'shift token (then go to state ' + a[1] + ')' : + let s = a[0] === SHIFT ? 'shift token (then go to state ' + a[1] + ')' : a[0] === REDUCE ? 'reduce by rule: ' + gen.productions[a[1]] : - a[0] === ACCEPT ? 'accept' : 'UNDEFINED ACTION: ' + a[0]; + a[0] === ACCEPT ? 'accept' : 'UNDEFINED ACTION: ' + a[0]; return s; } @@ -35502,13 +35291,13 @@ var path = require('path'); trace('\n'); } - var lrGeneratorDebug = { + const lrGeneratorDebug = { beforeparseTable: function () { this.trace('Building parse table.'); }, afterparseTable: function () { - var trace = this.trace; - var self = this; + let trace = this.trace; + let self = this; if (this.conflicts > 0) { trace('\nConflicts:\n'); this.resolutions.forEach(function (r, i) { @@ -35520,21 +35309,21 @@ var path = require('path'); } trace('Done.\n'); }, - aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */ ) { + aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */) { traceStates(this.trace, states, 'as produced by LR::canonicalCollection()'); } }; - var parser$4 = typal.beget(); + const parser$4 = typal.beget(); generatorMixin.createParser = function createParser() { - var sourceCodeDef = this.generateModuleExpr(); + let sourceCodeDef = this.generateModuleExpr(); // produce a chunk of sourcecode that's suitable for evaluation through `eval()`: - var sourcecode = rmCommonWS$5` + let sourcecode = rmCommonWS$5` ${sourceCodeDef.init} - var yy__parser = ${sourceCodeDef.src}; + let yy__parser = ${sourceCodeDef.src}; // produce the generated parser function/class as the last value // in this chunk of code so that we can be sure to produce *that* @@ -35545,15 +35334,15 @@ var path = require('path'); yy__parser; `; - var p = code_exec$2(sourcecode, function generated_code_exec_wrapper_jison(sourcecode) { + let 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); - var rv = eval(sourcecode); + let rv = eval(sourcecode); return rv; }, mkStdOptions$1(this.options, { dumpSourceCodeOnFailure: this.DEBUG, throwErrorOnCompileFailure: true - }), "parser"); + }), 'parser'); assert__default['default'](typeof p === 'object'); assert__default['default'](typeof p.parse === 'function'); assert__default['default'](typeof p.parser === 'undefined'); @@ -35597,7 +35386,7 @@ var path = require('path'); } p.sourceCode = sourceCodeDef; - var self = this; + let self = this; function bind(method) { return function () { self.lexer = p.lexer; @@ -35624,8 +35413,6 @@ var path = require('path'); // --- START parser Error class chunk --- const parseErrorSourceCode = ` function parseError(str, hash, ExceptionClass) { - "use strict"; - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -35650,7 +35437,7 @@ function parseError(str, hash, ExceptionClass) { generatorMixin.createLexer = function createLexer(lexerSpec, input, tokens, options) { // TODO: construct options from generator options: // lexer_options = ... - var lexer = new RegExpLexer(lexerSpec, input, tokens, options); + let lexer = new RegExpLexer(lexerSpec, input, tokens, options); return lexer; }; @@ -35689,8 +35476,6 @@ function parseError(str, hash, ExceptionClass) { // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - "use strict"; - return '"' + id_str + '"'; }, @@ -35698,8 +35483,6 @@ function parseError(str, hash, ExceptionClass) { // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - "use strict"; - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -35711,8 +35494,8 @@ function parseError(str, hash, ExceptionClass) { // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -35725,15 +35508,13 @@ function parseError(str, hash, ExceptionClass) { // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - "use strict"; - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -35749,11 +35530,10 @@ function parseError(str, hash, ExceptionClass) { // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { - "use strict"; + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -35761,10 +35541,10 @@ function parseError(str, hash, ExceptionClass) { this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -35776,8 +35556,8 @@ function parseError(str, hash, ExceptionClass) { `; // --- END of define_parser_APIs_1 chunk --- - var api_set = (new Function('', 'return { ' + define_parser_APIs_1 + ' };'))(); - for (var api in api_set) { + const api_set = (new Function('', 'return { ' + define_parser_APIs_1 + ' };'))(); + for (let api in api_set) { parser$4[api] = api_set[api]; } @@ -35785,39 +35565,37 @@ function parseError(str, hash, ExceptionClass) { // --- START parser kernel --- parser$4.parse = ` function parse(input, parseParams) { - "use strict"; - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - var tstack = []; // token stack (only used when \`%options token_stack\` support has been enabled) - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - var yytext; - var yylineno; - var yyleng; - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + let tstack = []; // token stack (only used when \`%options token_stack\` support has been enabled) + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + let yytext; + let yylineno; + let yyleng; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, YY_ERROR_RECOVERY_COMBINE_ID /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -35826,21 +35604,18 @@ function parse(input, parseParams) { post_parse: undefined, pre_lex: undefined, post_lex: undefined, - parseParamsAsMembers: parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + parseParamsAsMembers // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - "use strict"; - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -35865,8 +35640,6 @@ function parse(input, parseParams) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - "use strict"; - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -35874,18 +35647,19 @@ function parse(input, parseParams) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -35893,26 +35667,19 @@ function parse(input, parseParams) { // - either the element does not yet exist in \`src\` // - or exists in \`src\` but is NULL or UNDEFINED there, while its value is non-NULL in \`dst\` function shallow_copy_noclobber(dst, src) { - "use strict"; - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - "use strict"; - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -35930,17 +35697,13 @@ function parse(input, parseParams) { this.copy_yytext = this.options.copy_yytext || sharedState_yy.copy_yytext || shallow_copy; this.copy_yylloc = this.options.copy_yylloc || sharedState_yy.copy_yylloc || copy_yylloc_native; - var yydebug = false; + let yydebug = false; if (this.options.debug) { yydebug = function yydebug_impl(msg, obj) { - "use strict"; - - var ref_list; - var ref_names; + let ref_list; + let ref_names; function deepClone(from, sub) { - "use strict"; - if (sub == null) { ref_list = []; ref_names = []; @@ -35952,15 +35715,15 @@ function parse(input, parseParams) { return from; } - var i = ref_list.indexOf(from); + let i = ref_list.indexOf(from); if (i >= 0) { return '[Circular/Xref:' + ref_names[i] + ']'; // circular or cross reference } ref_list.push(from); ref_names.push(sub); - var to = new from.constructor(); - for (var name in from) { + let to = new from.constructor(); + for (let name in from) { if (name === 'parser') continue; if (name === 'lexer') continue; to[name] = deepClone(from[name], name); @@ -35988,13 +35751,11 @@ function parse(input, parseParams) { // wrap try/catch in a function to help the V8 JIT compiler... function yydebug_cvt(obj) { - "use strict"; - - var js; + let js; try { - var re1; + let re1; if (typeof XRegExp === 'undefined') { - re1 = / \\"([a-z_][a-z_0-9. ]*)\\": /ig; + re1 = / {2}\\"([a-z_][a-z_0-9. ]*)\\": /ig; } else { re1 = new XRegExp(' \\"([\\\\p{Alphabetic}_][\\\\p{Alphabetic}\\\\p{Number}_. ]*)\\": ', 'g'); } @@ -36026,21 +35787,25 @@ function parse(input, parseParams) { // them up. Hence we MUST set them up at the start of every \`parse()\` run! if (this.yyError) { this.yyError = function yyError(str /*, ...args */) { - "use strict"; - - if (yydebug) yydebug('yyerror: ', { message: str, args: arguments, symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('yyerror: ', { + message: str, + args: arguments, + symbol, state, newState, recovering, action + }); + } //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); + let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -36061,13 +35826,13 @@ function parse(input, parseParams) { //_handle_error_no_recovery: // run this code when the grammar does not include any error recovery rules - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, false); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, false); //_handle_error_end_of_section: // this concludes the error recovery / no error recovery code section choice above // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -36080,18 +35845,14 @@ function parse(input, parseParams) { if (this.yyRecovering) { this.yyRecovering = function yyRecovering() { - "use strict"; - - if (yydebug) yydebug('yyrecovering: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) yydebug('yyrecovering: ', { symbol, state, newState, recovering, action }); return recovering; }; } if (this.yyErrOk) { this.yyErrOk = function yyErrOk() { - "use strict"; - - if (yydebug) yydebug('yyerrok: ', { symbol: symbol, state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) yydebug('yyerrok: ', { symbol, state, newState, recovering, action }); recovering = 0; // DO NOT reset/cleanup \`recoveringErrorInfo\` yet: userland code @@ -36113,9 +35874,7 @@ function parse(input, parseParams) { if (this.yyClearIn) { this.yyClearIn = function yyClearIn() { - "use strict"; - - if (yydebug) yydebug('yyclearin: ', { symbol: symbol, newState: newState, recovering: recovering, action: action, preErrorSymbol: preErrorSymbol }); + if (yydebug) yydebug('yyclearin: ', { symbol, newState, recovering, action, preErrorSymbol }); if (symbol === TERROR) { symbol = 0; yytext = null; @@ -36132,8 +35891,6 @@ function parse(input, parseParams) { // Does the shared state override the default \`parseError\` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -36146,8 +35903,6 @@ function parse(input, parseParams) { // Does the shared state override the default \`quoteName\` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - "use strict"; - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -36161,12 +35916,10 @@ function parse(input, parseParams) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your \`sharedState\`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - "use strict"; - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -36220,8 +35973,8 @@ function parse(input, parseParams) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -36230,8 +35983,8 @@ function parse(input, parseParams) { //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -36265,20 +36018,18 @@ function parse(input, parseParams) { // // Note: epsilon rule's yylloc situation is detected by passing both \`first_index\` and \`first_yylloc\` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - "use strict"; - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -36289,7 +36040,7 @@ function parse(input, parseParams) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -36302,7 +36053,7 @@ function parse(input, parseParams) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -36314,29 +36065,27 @@ function parse(input, parseParams) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or \`dont_look_back\` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -36344,7 +36093,7 @@ function parse(input, parseParams) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -36364,9 +36113,7 @@ function parse(input, parseParams) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your \`lexer\`, \`sharedState\`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - "use strict"; - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -36375,10 +36122,10 @@ function parse(input, parseParams) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -36386,7 +36133,7 @@ function parse(input, parseParams) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -36403,10 +36150,8 @@ function parse(input, parseParams) { // info.value = null; // info.value_stack = null; // ... - "use strict"; - - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -36422,9 +36167,7 @@ function parse(input, parseParams) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - "use strict"; - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -36493,11 +36236,14 @@ function parse(input, parseParams) { // - root_failure_pointer: // copy of the \`stack_pointer\`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -36508,9 +36254,7 @@ function parse(input, parseParams) { }; function getNonTerminalFromCode(symbol) { - "use strict"; - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -36520,22 +36264,20 @@ function parse(input, parseParams) { //_lexer_without_token_stack: function stdLex() { - "use strict"; - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36545,22 +36287,20 @@ function parse(input, parseParams) { } function fastLex() { - "use strict"; - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36569,15 +36309,13 @@ function parse(input, parseParams) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; //_lexer_with_token_stack: // lex function that supports token stacks function tokenStackLex() { - "use strict"; - - var token; + let token; token = tstack.pop() || lexer.lex() || EOF; // if token isn't its numeric value, convert if (typeof token !== 'number') { @@ -36596,13 +36334,13 @@ function parse(input, parseParams) { } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -36613,33 +36351,37 @@ function parse(input, parseParams) { //_lexer_with_token_stack_end: - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - "use strict"; - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { // check for error recovery rule in this state - if (yydebug) yydebug('locateNearestErrorRecoveryRule #test#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); - var t = (table[state] && table[state][TERROR]) || NO_ACTION; + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #test#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } + const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we \`yyerrok()\` an error, we must @@ -36654,12 +36396,24 @@ function parse(input, parseParams) { // terminate the parse in a controlled fashion even when we have // very complex error/recovery code interplay in the core + user // action code blocks: - if (yydebug) yydebug('locateNearestErrorRecoveryRule #found#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #found#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { - if (yydebug) yydebug('locateNearestErrorRecoveryRule #skip#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #skip#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; @@ -36669,14 +36423,26 @@ function parse(input, parseParams) { return depth; } if (state === 0 /* $accept rule */ || stack_probe < 1) { - if (yydebug) yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #end=NIL#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; } - if (yydebug) yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', { symbol: symbol, state: state, depth: depth, stackidx: sp - 1 - depth, lastidx: lastEofErrorStateDepth }); + if (yydebug) { + yydebug('locateNearestErrorRecoveryRule #EMPTY#: ', { + symbol, state, depth, + stackidx: sp - 1 - depth, + lastidx: lastEofErrorStateDepth + }); + } return -1; // No suitable error recovery rule available. } @@ -36693,7 +36459,7 @@ function parse(input, parseParams) { // whether we'll go with the standard, slower, lex() API or the // \`fast_lex()\` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -36739,17 +36505,23 @@ function parse(input, parseParams) { newState = t[1]; action = t[0]; - if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('after FETCH/LEX: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol], + state, newState, recovering, action + }); + } //_handle_error_with_recovery: // run this code when the grammar includes error recovery rules // handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -36776,7 +36548,13 @@ function parse(input, parseParams) { // invoke the parser's cleanup API! recoveringErrorInfo = this.shallowCopyErrorInfo(p); - if (yydebug) yydebug('error recovery rule detected: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p }); + if (yydebug) { + yydebug('error recovery rule detected: ', { + error_rule_depth, + error: p.errStr, + error_hash: p + }); + } r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { @@ -36794,9 +36572,15 @@ function parse(input, parseParams) { } } - if (yydebug) yydebug('after ERROR DETECT: ', { error_rule_depth: error_rule_depth, error: p.errStr, error_hash: p }); + if (yydebug) { + yydebug('after ERROR DETECT: ', { + error_rule_depth, + error: p.errStr, + error_hash: p + }); + } - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -36816,17 +36600,22 @@ function parse(input, parseParams) { preErrorSymbol = 0; symbol = lex(); - if (yydebug) yydebug('after ERROR RECOVERY-3: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol] }); + if (yydebug) { + yydebug('after ERROR RECOVERY-3: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol] + }); + } } // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -36873,20 +36662,18 @@ function parse(input, parseParams) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; - if (yydebug) yydebug('Error recovery process: pushed error info item on the info stack: ', { - item: vstack[sp], - sp, - esp, - vstack, - stack, - sstack, - combineState: NO_ACTION[1] - }); + if (yydebug) { + yydebug('Error recovery process: pushed error info item on the info stack: ', { + item: vstack[sp], + sp, esp, vstack, stack, sstack, + combineState: NO_ACTION[1] + }); + } } else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), @@ -36905,11 +36692,17 @@ function parse(input, parseParams) { yyrulelen = error_rule_depth; - if (yydebug) yydebug('Error recovery process: performAction: COMBINE: ', { - yyval, yytext, sp, pop_size: yyrulelen, vstack, stack, sstack, - combineState: NO_ACTION[1] - }); - r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, NO_ACTION[1], sp - 1, yyrulelen, vstack, lstack, stack, sstack); + let combineState = NO_ACTION[1]; + + if (yydebug) { + yydebug('Error recovery process: performAction: COMBINE: ', { + yyval, yytext, sp, + pop_size: yyrulelen, + vstack, stack, sstack, + combineState + }); + } + r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, combineState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof r !== 'undefined') { retval = r; @@ -36920,7 +36713,7 @@ function parse(input, parseParams) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -36947,7 +36740,7 @@ function parse(input, parseParams) { // allow N (default: 3) real symbols to be shifted before reporting a new error recovering = ERROR_RECOVERY_TOKEN_DISCARD_COUNT; - if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth: error_rule_depth, symbol: symbol, preErrorSymbol: preErrorSymbol }); + if (yydebug) yydebug('after ERROR POP: ', { error_rule_depth, symbol, preErrorSymbol }); // Now duplicate the standard parse machine here, at least its initial // couple of rounds until the TERROR symbol is **pushed onto the parse stack**, @@ -36973,10 +36766,10 @@ function parse(input, parseParams) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -37004,14 +36797,20 @@ function parse(input, parseParams) { newState = t[1]; action = t[0]; - if (yydebug) yydebug('after FETCH/LEX: ', { symbol: symbol, symbolID: this.terminals_ && this.terminals_[symbol], state: state, newState: newState, recovering: recovering, action: action }); + if (yydebug) { + yydebug('after FETCH/LEX: ', { + symbol, + symbolID: this.terminals_ && this.terminals_[symbol], + state, newState, recovering, action + }); + } // encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { if (yydebug) yydebug('**NESTED ERROR DETECTED** while still recovering from previous error'); - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the \`continue;\` @@ -37025,15 +36824,26 @@ function parse(input, parseParams) { } } - if (yydebug) yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) { - "use strict"; - - if (!nt || !nt.states || !nt.rules) - return ''; - var rulename = nt.states[state]; - var rulespec = nt.rules[rulename][state]; - return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; - })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('::: SLOW ERROR RECOVERY PHASE CYCLE action: ' + + (action === 1 ? + 'shift token ' + symbol + ' (then go to state ' + newState + ')' : + action === 2 ? + 'reduce by rule: ' + newState + (function __print_rule(nt, state) { + if (!nt || !nt.states || !nt.rules) { + return ''; + } + let rulename = nt.states[state]; + let rulespec = nt.rules[rulename][state]; + return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; + })(this.nonterminals_, newState) : + action === 3 ? + 'accept' : + '???unexpected???' + ), { + action, newState, recovering, symbol + }); + } switch (action) { // catch misc. parse failures: @@ -37057,12 +36867,12 @@ function parse(input, parseParams) { // Push a special value onto the stack when we're // shifting the \`error\` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -37071,7 +36881,7 @@ function parse(input, parseParams) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -37100,14 +36910,14 @@ function parse(input, parseParams) { if (recovering > 0) { recovering--; - if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error rule matching: ', { recovering, symbol }); } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; - if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error recovery: ', { recovering, symbol }); // read action for current state and first input t = (table[newState] && table[newState][symbol]) || NO_ACTION; if (!t[0] || symbol === TERROR) { @@ -37119,7 +36929,7 @@ function parse(input, parseParams) { // recovery, for then this we would we idling (cycling) on the error forever. // Yes, this does not take into account the possibility that the *lexer* may have // produced a *new* TERROR token all by itself, but that would be a very peculiar grammar! - if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering: recovering, symbol: symbol }); + if (yydebug) yydebug('... SHIFT:error recovery: re-application of old symbol doesn\\'t work: instead, we\\'re moving forward now. ', { recovering, symbol }); symbol = 0; } } @@ -37135,7 +36945,7 @@ function parse(input, parseParams) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -37146,21 +36956,26 @@ function parse(input, parseParams) { this_production = this.productions_[newState - 1]; // \`this.productions_[]\` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; - if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('~~~ REDUCE: ', { + pop_size: yyrulelen, + newState, recovering, symbol + }); + } r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -37194,15 +37009,17 @@ function parse(input, parseParams) { sp -= yyrulelen; // don't overwrite the \`symbol\` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; - if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol }); + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol }); + } continue; // accept: @@ -37254,7 +37071,7 @@ function parse(input, parseParams) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the \`switch/default\` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -37264,9 +37081,9 @@ function parse(input, parseParams) { // handle parse error if (!action) { - var errStr; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let errStr; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); // Report error errStr = 'Parse error'; @@ -37297,15 +37114,26 @@ function parse(input, parseParams) { } - if (yydebug) yydebug('::: MAIN CYCLE action: ' + (action === 1 ? 'shift token ' + symbol + ' (then go to state ' + newState + ')' : action === 2 ? 'reduce by rule: ' + newState + (function __print_rule(nt, state) { - "use strict"; - - if (!nt || !nt.states || !nt.rules) - return ''; - var rulename = nt.states[state]; - var rulespec = nt.rules[rulename][state]; - return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; - })(this.nonterminals_, newState) : action === 3 ? 'accept' : '???unexpected???'), { action: action, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('::: MAIN CYCLE action: ' + + (action === 1 ? + 'shift token ' + symbol + ' (then go to state ' + newState + ')' : + action === 2 ? + 'reduce by rule: ' + newState + (function __print_rule(nt, state) { + if (!nt || !nt.states || !nt.rules) { + return ''; + } + let rulename = nt.states[state]; + let rulespec = nt.rules[rulename][state]; + return ' (' + rulespec.symbol + ' := ' + rulespec.handle + ')'; + })(this.nonterminals_, newState) : + action === 3 ? + 'accept' : + '???unexpected???' + ), { + action, newState, recovering, symbol + }); + } switch (action) { // catch misc. parse failures: @@ -37336,7 +37164,7 @@ function parse(input, parseParams) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -37353,8 +37181,8 @@ function parse(input, parseParams) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyleng = lexer.yyleng; @@ -37365,27 +37193,32 @@ function parse(input, parseParams) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // \`this.productions_[]\` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; - if (yydebug) yydebug('~~~ REDUCE: ', { pop_size: yyrulelen, newState: newState, recovering: recovering, symbol: symbol }); + if (yydebug) { + yydebug('~~~ REDUCE: ', { + pop_size: yyrulelen, + newState, recovering, symbol + }); + } r = this.performAction.call(yyval, yytext, yyleng, yylineno, yyloc, newState, sp - 1, yyrulelen, vstack, lstack, stack, sstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -37416,15 +37249,17 @@ function parse(input, parseParams) { sp -= yyrulelen; // don't overwrite the \`symbol\` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; - if (yydebug) yydebug('REDUCED: ', { newState: newState, recovering: recovering, symbol: symbol }); + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + if (yydebug) yydebug('REDUCED: ', { newState, recovering, symbol }); + } continue; // accept: @@ -37477,8 +37312,7 @@ function parse(input, parseParams) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -37511,30 +37345,30 @@ function parse(input, parseParams) { * LR(0) Parser */ - var lr0 = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { + const lr0 = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LR(0)', afterconstructor: function lr0_afterconstructor() { this.buildTable(); } }); - var LR0Generator = Jison$1.LR0Generator = lr0.construct(); + const LR0Generator = Jison$1.LR0Generator = lr0.construct(); /* * Simple LALR(1) */ - var lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { + const lalr = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LALR(1)', afterconstructor: function lalr_afterconstructor() { - var self = this; + let self = this; if (this.DEBUG) { this.mix(lrGeneratorDebug, lalrGeneratorDebug); // mixin debug methods } - for (var round = 1; /* infinite loop if it weren't for the `break`s at the end */ ; round++) { + for (let round = 1; /* infinite loop if it weren't for the `break`s at the end */ ; round++) { this.states = this.canonicalCollection(); if (this.DEBUG || devDebug) { @@ -37545,13 +37379,13 @@ function parse(input, parseParams) { this.terms_ = {}; - var newg = this.newg = typal.beget(lookaheadMixin, { + let newg = this.newg = typal.beget(lookaheadMixin, { oldg: this, trace: this.trace, nterms_: {}, DEBUG: false, go_: function (productionSymbol, productionHandle) { - var stateNum = productionSymbol.split(':')[0]; // grab state # + let stateNum = productionSymbol.split(':')[0]; // grab state # assert__default['default'](stateNum == +stateNum); stateNum = +stateNum; productionHandle = productionHandle.map(function (rhsElem) { @@ -37588,8 +37422,8 @@ function parse(input, parseParams) { // backprop `nullable` value for each nonterminal and production back to original grammar: each(newg.nonterminals, function (newg_nt, t) { // extract original symbol: - var sym; - var a = newg_nt.symbol.split(':'); + let sym; + let a = newg_nt.symbol.split(':'); if (a.length === 1 || a[0] === '') { sym = newg_nt.symbol; } else { @@ -37664,8 +37498,8 @@ function parse(input, parseParams) { go: function LALR_go(stateNum, productionHandle, productionSymbol) { assert__default['default'](typeof stateNum === 'number'); - var endStateNum = stateNum; - for (var i = 0; i < productionHandle.length; i++) { + let endStateNum = stateNum; + for (let i = 0; i < productionHandle.length; i++) { endStateNum = this.states.item(endStateNum).edges[productionHandle[i]] || endStateNum; } return endStateNum; @@ -37673,10 +37507,10 @@ function parse(input, parseParams) { goPath: function LALR_goPath(stateNum, productionHandle, productionSymbol) { assert__default['default'](typeof stateNum === 'number'); - var endStateNum = stateNum, - t, - path = []; - for (var i = 0; i < productionHandle.length; i++) { + let endStateNum = stateNum, + t, + path = []; + for (let i = 0; i < productionHandle.length; i++) { t = productionHandle[i] ? endStateNum + ':' + productionHandle[i] /* + ':' + productionSymbol */ : ''; if (t) { this.newg.nterms_[t] = endStateNum; @@ -37694,34 +37528,34 @@ function parse(input, parseParams) { // every disjoint reduction of a nonterminal becomes a production in G' buildNewGrammar: function LALR_buildNewGrammar() { - var self = this, - newg = this.newg; + let self = this, + newg = this.newg; this.states.forEach(function (state, i) { i = +i; state.forEach(function LALR_buildNewHandle(item) { if (item.dotPosition === 0) { // new symbols are a combination of state and transition symbol - var symbol = i + ':' + item.production.symbol; + let symbol = i + ':' + item.production.symbol; assert__default['default'](typeof self.terms_[symbol] === 'undefined' || self.terms_[symbol] === item.production.symbol); self.terms_[symbol] = item.production.symbol; newg.nterms_[symbol] = i; if (!newg.nonterminals[symbol]) { newg.nonterminals[symbol] = new Nonterminal(symbol); } - var pathInfo = self.goPath(i, item.production.handle, item.production.symbol); - var p = new Production(symbol, pathInfo.path, newg.productions.length); + let pathInfo = self.goPath(i, item.production.handle, item.production.symbol); + let p = new Production(symbol, pathInfo.path, newg.productions.length); newg.productions.push(p); newg.nonterminals[symbol].productions.push(p); // store the transition that gets 'backed up to' after reduction on path - var handle = item.production.handle.join(' '); + let handle = item.production.handle.join(' '); if (self.conflict_fixing_round && self.conflict_states_LU[i]) ; if (self.conflict_fixing_round && self.conflict_productions_LU[item.production.id]) { handle += ':P' + item.production.id; } - var goes = self.states.item(pathInfo.endState).goes; + let goes = self.states.item(pathInfo.endState).goes; if (!goes[handle]) { goes[handle] = []; } @@ -37735,22 +37569,22 @@ function parse(input, parseParams) { }, unionLookaheads: function LALR_unionLookaheads() { - var self = this, - newg = this.newg; - // var states = !!this.onDemandLookahead ? this.inadequateStates : this.states; + let self = this, + newg = this.newg; + // let states = !!this.onDemandLookahead ? this.inadequateStates : this.states; - var these_states = this.states; + let these_states = this.states; these_states.forEach(function union_states_forEach(state, i) { i = +i; //assert(state.inadequate ? these_states.inadequate : true); - var treat_me = (self.onDemandLookahead ? these_states.inadequate || state.inadequate : true); + let treat_me = (self.onDemandLookahead ? these_states.inadequate || state.inadequate : true); if (state.reductions.length && treat_me) { state.reductions.forEach(function union_reduction_forEach(item) { - var follows = {}; - for (var k = 0; k < item.follows.length; k++) { + let follows = {}; + for (let k = 0; k < item.follows.length; k++) { follows[item.follows[k]] = true; } - var handle = item.production.handle.join(' '); + let handle = item.production.handle.join(' '); if (self.conflict_fixing_round && self.conflict_states_LU[i]) ; if (self.conflict_fixing_round && self.conflict_productions_LU[item.production.id]) { handle += ':P' + item.production.id; @@ -37761,7 +37595,7 @@ function parse(input, parseParams) { state.goes[handle].forEach(function reduction_goes_forEach(symbol) { newg.nonterminals[symbol].follows.forEach(function goes_follows_forEach(symbol) { - var terminal = self.terms_[symbol]; + let terminal = self.terms_[symbol]; if (!follows[terminal]) { follows[terminal] = true; @@ -37775,11 +37609,11 @@ function parse(input, parseParams) { } }); - var LALRGenerator = Jison$1.LALRGenerator = lalr.construct(); + const LALRGenerator = Jison$1.LALRGenerator = lalr.construct(); // LALR generator debug mixin - var lalrGeneratorDebug = { + const lalrGeneratorDebug = { beforebuildNewGrammar: function () { this.trace(this.states.size() + ' states.'); this.trace('Building lookahead grammar.'); @@ -37796,7 +37630,7 @@ function parse(input, parseParams) { aftercomputeLookaheads: function () { traceStates(this.trace, this.states, 'after LALR::computeLookaheads()'); }, - aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */ ) { + aftercanonicalCollection: function (states /* as produced by `this.canonicalCollection()` */) { traceStates(this.trace, states, 'as produced by LALR::canonicalCollection()'); } }; @@ -37806,7 +37640,7 @@ function parse(input, parseParams) { * * Define base type */ - var lrLookaheadGenerator = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { + const lrLookaheadGenerator = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { afterconstructor: function lr_aftercontructor() { this.computeLookaheads(); @@ -37823,7 +37657,7 @@ function parse(input, parseParams) { /* * SLR Parser */ - var SLRGenerator = Jison$1.SLRGenerator = lrLookaheadGenerator.construct({ + const SLRGenerator = Jison$1.SLRGenerator = lrLookaheadGenerator.construct({ type: 'SLR(1)', lookAheads: function SLR_lookAhead(state, item) { @@ -37835,7 +37669,7 @@ function parse(input, parseParams) { /* * LR(1) Parser */ - var lr1 = lrLookaheadGenerator.beget({ + const lr1 = lrLookaheadGenerator.beget({ type: 'Canonical LR(1)', lookAheads: function LR_lookAheads(state, item) { @@ -37852,28 +37686,26 @@ function parse(input, parseParams) { }), closureOperation: function LR_ClosureOperation(itemSet) { - var closureSet = new this.ItemSet(); - var self = this; + let closureSet = new this.ItemSet(); + let self = this; - var set = itemSet, - itemQueue; + let set = itemSet; do { - itemQueue = new Set(); + let itemQueue = new Set$1(); closureSet = closureSet.concat(set); set.forEach(function LR_AddItemToClosureSets(item) { - var symbol = item.markedSymbol; - var b, r; + let symbol = item.markedSymbol; // if token is a nonterminal, recursively add closures if (symbol && self.nonterminals[symbol]) { - r = item.remainingHandle(); - b = self.first(r); + let r = item.remainingHandle(); + let b = self.first(r); if (b.length === 0 || item.production.nullable || self.nullable(r)) { b = b.concat(item.follows); } self.nonterminals[symbol].productions.forEach(function (production) { - var newItem = new self.Item(production, 0, b); + let newItem = new self.Item(production, 0, b); if (!closureSet.contains(newItem) && !itemQueue.contains(newItem)) { itemQueue.push(newItem); } @@ -37885,18 +37717,18 @@ function parse(input, parseParams) { }); set = itemQueue; - } while (!itemQueue.isEmpty()); + } while (!set.isEmpty()); return closureSet; } }); - var LR1Generator = Jison$1.LR1Generator = lr1.construct(); + const LR1Generator = Jison$1.LR1Generator = lr1.construct(); /* * LL Parser */ - var ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { + const ll = generator.beget(lookaheadMixin, generatorMixin, lrGeneratorMixin, { type: 'LL(1)', afterconstructor: function ll_aftercontructor() { @@ -37919,13 +37751,13 @@ function parse(input, parseParams) { }, parseTable: function ll_ParseTable(productions) { - var table = {}, - symbols_ = this.symbols_, - self = this; + let table = {}; + let symbols_ = this.symbols_; + let self = this; productions.forEach(function (production, i) { - var row = table[production.symbol] || {}; - var tokens = production.first; + let row = table[production.symbol] || {}; + let tokens = production.first; if (self.nullable(production.handle)) { tokens = union(tokens, self.nonterminals[production.symbol].follows); } @@ -37934,7 +37766,7 @@ function parse(input, parseParams) { row[token].push(i); self.conflicts++; } else { - row[token] = [i]; + row[token] = [ i ]; } }); table[production.symbol] = row; @@ -37945,16 +37777,16 @@ function parse(input, parseParams) { } }); - var LLGenerator = Jison$1.LLGenerator = ll.construct(); + const LLGenerator = Jison$1.LLGenerator = ll.construct(); Jison$1.Generator = function Jison_Generator(grammar, optionalLexerSection, options) { // pick the correct argument for the `options` for this call: if (!options && optionalLexerSection && typeof optionalLexerSection !== 'string') { - options = optionalLexerSection; - optionalLexerSection = null; + options = optionalLexerSection; + optionalLexerSection = null; } // and standardize it: - var preliminary_options = mkStdOptions$1(options); + let preliminary_options = mkStdOptions$1(options); // Provisionally parse the grammar, really only to obtain the *options.type* // specified within the grammar, if specified (via `%parser-type`). @@ -37976,7 +37808,7 @@ function parse(input, parseParams) { // // Anyway, API/CLI options **override** options coming in from the grammar spec. // - options = mkStdOptions$1("NODEFAULT", grammar.options, options); + options = mkStdOptions$1('NODEFAULT', grammar.options, options); switch (options.type || Jison$1.defaultJisonOptions.type) { case 'lr0': options.hasPartialLrUpgradeOnConflict = false; // kill this unsupported option @@ -38002,12 +37834,26 @@ function parse(input, parseParams) { }; function Parser$3(g, l, options) { - var gen = Jison$1.Generator(g, l, options); + let gen = Jison$1.Generator(g, l, options); return gen.createParser(); } Jison$1.Parser = Parser$3; + // exports for unit/system testing purposes: + Jison$1.TestExports = { + lookaheadMixin, generatorMixin, lrGeneratorMixin, + lalr, + lr0, + lr1, + ll, + parser: parser$4, + pickErrorHandlingChunk, + addOrRemoveTokenStack, + removeUnusedKernelFeatures, + expandParseArguments + }; + return Jison$1; }))); diff --git a/packages/ebnf-parser/dist/ebnf-parser-cjs-es5.js b/packages/ebnf-parser/dist/ebnf-parser-cjs-es5.js index f61dfaeaf..f61b0016d 100644 --- a/packages/ebnf-parser/dist/ebnf-parser-cjs-es5.js +++ b/packages/ebnf-parser/dist/ebnf-parser-cjs-es5.js @@ -1,4 +1,4 @@ -'use strict';var XRegExp=require('@gerhobbelt/xregexp');var fs=require('fs');var path$1=require('path');var JSON5=require('@gerhobbelt/json5');var recast=require('recast');var babel=require('@babel/core');var assert$1=require('assert');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e};}var XRegExp__default=/*#__PURE__*/_interopDefaultLegacy(XRegExp);var fs__default=/*#__PURE__*/_interopDefaultLegacy(fs);var path__default=/*#__PURE__*/_interopDefaultLegacy(path$1);var JSON5__default=/*#__PURE__*/_interopDefaultLegacy(JSON5);var recast__default=/*#__PURE__*/_interopDefaultLegacy(recast);var assert__default=/*#__PURE__*/_interopDefaultLegacy(assert$1);// Return TRUE if `src` starts with `searchString`. +'use strict';var XRegExp=require('@gerhobbelt/xregexp');var fs=require('fs');var path$1=require('path');var JSON5=require('@gerhobbelt/json5');var mkdirp=require('mkdirp');var recast=require('recast');var babel=require('@babel/core');var assert$1=require('assert');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e};}var XRegExp__default=/*#__PURE__*/_interopDefaultLegacy(XRegExp);var fs__default=/*#__PURE__*/_interopDefaultLegacy(fs);var path__default=/*#__PURE__*/_interopDefaultLegacy(path$1);var JSON5__default=/*#__PURE__*/_interopDefaultLegacy(JSON5);var mkdirp__default=/*#__PURE__*/_interopDefaultLegacy(mkdirp);var recast__default=/*#__PURE__*/_interopDefaultLegacy(recast);var assert__default=/*#__PURE__*/_interopDefaultLegacy(assert$1);// Return TRUE if `src` starts with `searchString`. function startsWith(src,searchString){return src.substr(0,searchString.length)===searchString;}// tagged template string helper which removes the indentation common to all // non-empty lines: that indentation was added as part of the source code // formatting of this lexer spec file and must be removed to produce what @@ -14,62 +14,72 @@ function startsWith(src,searchString){return src.substr(0,searchString.length)== function rmCommonWS(strings,...values){// As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. -// +// // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. -var indent_str=null;var src=strings.map(function splitIntoLines(s){var a=s.split('\n');indent_str=a.reduce(function analyzeLine(indent_str,line,index){// only check indentation of parts which follow a NEWLINE: -if(index!==0){var m=/^(\s*)\S/.exec(line);// only non-empty ~ content-carrying lines matter re common indent calculus: +let indent_str=null;let src=strings.map(function splitIntoLines(s){let a=s.split('\n');indent_str=a.reduce(function analyzeLine(indent_str,line,index){// only check indentation of parts which follow a NEWLINE: +if(index!==0){let m=/^(\s*)\S/.exec(line);// only non-empty ~ content-carrying lines matter re common indent calculus: if(m){if(indent_str==null){indent_str=m[1];}else if(m[1].length start at j=1 rather than j=0 -for(var j=1,linecnt=a.length;j `'camelsHaveOneHump'` +for(let j=1,linecnt=a.length;j `'camelsHaveOneHump'` /** @public */function camelCase(s){// Convert first character to lowercase -return s.replace(/^\w/,function(match){return match.toLowerCase();}).replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// do not mutate 'a-2' to 'a2': -if(c===rv&&c.match(/\d/)){return match;}return rv;});}// Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers -/** @public */function mkIdentifier(s){s=''+s;return s// Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), +return s.replace(/^\w/,function(match){return match.toLowerCase();}).replace(/-\w/g,function(match){const c=match.charAt(1);const rv=c.toUpperCase();// do not mutate 'a-2' to 'a2': +if(c===rv&&c.match(/\d/)){return match;}return rv;});}// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords=(list=>{let rv=new Set();for(let w of list){//console.error('reserved word:', w); +rv.add(w);}return rv;})(['await','break','case','catch','class','const','continue','debugger','default','delete','do','else','enum','export','extends','finally','for','function','if','implements','import','in','instanceof','interface','new','package','private','protected','public','return','super','switch','this','throw','try','typeof','var','void','while','with','yield']);// Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers +/** @public */function mkIdentifier(s){s=''+s;let rv=s// Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` -.replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// mutate 'a-2' to 'a_2': +.replace(/-\w/g,function(match){let c=match.charAt(1);let rv=c.toUpperCase();// mutate 'a-2' to 'a_2': if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;})// cleanup: replace any non-suitable character series to a single underscore: .replace(/^([\d])/,'_$1')// where leading numbers are prefixed by an underscore: '1' --> '_1' .replace(/^[^\w_]/,'_')// do not accept numerics at the leading position, despite those matching regex `\w`: .replace(/^\d/,'_').replace(/[^\w\d_]/g,'_')// and only accept multiple (double, not triple) underscores at start or end of identifier name: -.replace(/^__+/,'#').replace(/__+$/,'#').replace(/_+/g,'_').replace(/#/g,'__');}// Check if the start of the given input matches a regex expression. +.replace(/^__+/,'#').replace(/__+$/,'#').replace(/_+/g,'_').replace(/#/g,'__');if(reservedWords.has(rv)){rv='_'+rv;}return rv;}// Check if the start of the given input matches a regex expression. // Return the length of the regex expression or -1 if none was found. /** @public */function scanRegExp(s){s=''+s;// code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` -var index=0;var length=s.length;var ch=s[index];//assert.assert(ch === '/', 'Regular expression literal must start with a slash'); -var str=s[index++];var classMarker=false;var terminated=false;while(index `'camelsHaveOneHump'` -let ref=s.replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// mutate 'a-2' to 'a_2': -if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;});var alt=mkIdentifier(s);return alt===ref;}// properly quote and escape the given input string -function dquote(s){var sq=s.indexOf('\'')>=0;var dq=s.indexOf('"')>=0;if(sq&&dq){s=s.replace(/"/g,'\\"');dq=false;}if(dq){s='\''+s+'\'';}else{s='"'+s+'"';}return s;}// +let ref=s.replace(/-\w/g,function(match){let c=match.charAt(1);let rv=c.toUpperCase();// mutate 'a-2' to 'a_2': +if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;});let alt=mkIdentifier(s);return alt===ref;}// properly quote and escape the given input string +function dquote(s){let sq=s.indexOf('\'')>=0;let dq=s.indexOf('"')>=0;if(sq&&dq){s=s.replace(/"/g,'\\"');dq=false;}if(dq){s='\''+s+'\'';}else{s='"'+s+'"';}return s;}// function chkBugger(src){src=String(src);if(src.match(/\bcov_\w+/)){console.error('### ISTANBUL COVERAGE CODE DETECTED ###\n',src);}}// Helper function: pad number with leading zeroes -function pad(n,p){p=p||2;var rv='0000'+n;return rv.slice(-p);}// attempt to dump in one of several locations: first winner is *it*! -function dumpSourceToFile(sourcecode,errname,err_id,options,ex){var dumpfile;options=options||{};try{var dumpPaths=[options.outfile?path__default['default'].dirname(options.outfile):null,options.inputPath,process.cwd()];var dumpName=path__default['default'].basename(options.inputFilename||options.moduleName||(options.outfile?path__default['default'].dirname(options.outfile):null)||options.defaultModuleName||errname).replace(/\.[a-z]{1,5}$/i,'')// remove extension .y, .yacc, .jison, ...whatever -.replace(/[^a-z0-9_]/ig,'_');// make sure it's legal in the destination filesystem: the least common denominator. -if(dumpName===''||dumpName==='_'){dumpName='__bugger__';}err_id=err_id||'XXX';var ts=new Date();var tm=ts.getUTCFullYear()+'_'+pad(ts.getUTCMonth()+1)+'_'+pad(ts.getUTCDate())+'T'+pad(ts.getUTCHours())+''+pad(ts.getUTCMinutes())+''+pad(ts.getUTCSeconds())+'.'+pad(ts.getUTCMilliseconds(),3)+'Z';dumpName+='.fatal_'+err_id+'_dump_'+tm+'.js';for(var i=0,l=dumpPaths.length;i'// '+l);d=d.join('\n');fs__default['default'].writeFileSync(dumpfile,sourcecode+'\n\n\n'+d,'utf8');console.error("****** offending generated "+errname+" source code dumped into file: ",dumpfile);break;// abort loop once a dump action was successful! +function pad(n,p){p=p||2;let rv='0000'+n;return rv.slice(-p);}function convertExceptionToObject(ex){if(!ex)return ex;// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error +// +// - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) +let rv=Object.assign({},ex);// - Set up the default fields which should ALWAYS be present: +rv.message=ex.message;rv.name=ex.name;rv.stack=ex.stack;// this assignment stringifies the stack trace in ex.stack. +// - Set the optional fields: +if(ex.code!==undefined)rv.code=ex.code;if(ex.type!==undefined)rv.type=ex.type;if(ex.fileName!==undefined)rv.fileName=ex.fileName;if(ex.lineNumber!==undefined)rv.lineNumber=ex.lineNumber;if(ex.columnNumber!==undefined)rv.columnNumber=ex.columnNumber;if(Array.isArray(ex.errors)){rv.errors=[];for(let se of ex.errors){rv.errors.push(convertExceptionToObject(se));}}return rv;}function find_suitable_app_dump_path(){return process.cwd().replace(/\\/g,'/').replace(/\/node_modules\/.*$/,m=>'/___nm___/').replace(/(\/jison\/)(.*)$/,(m,p1,p2)=>p1+'___'+p2.split('/').map(d=>d.charAt(0).toUpperCase()).join('_'));}// attempt to dump in one of several locations: first winner is *it*! +function dumpSourceToFile(sourcecode,errname,err_id,options,ex){let dumpfile;options=options||{};try{const dumpPaths=[options.outfile?path__default['default'].dirname(options.outfile):null,options.inputPath,find_suitable_app_dump_path()];let dumpName=path__default['default'].basename(options.inputFilename||options.moduleName||(options.outfile?path__default['default'].dirname(options.outfile):null)||options.defaultModuleName||errname).replace(/\.[a-z]{1,5}$/i,'')// remove extension .y, .yacc, .jison, ...whatever +.replace(/[^a-z0-9_]/ig,'_')// make sure it's legal in the destination filesystem: the least common denominator. +.substr(0,100);if(dumpName===''||dumpName==='_'){dumpName='__bugger__';}// generate a stacktrace for the dump no matter what: +if(!ex){try{throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this.");}catch(ex2){ex=ex2;}}err_id=err_id||'XXX';err_id=err_id.replace(/[^a-z0-9_]/ig,'_')// make sure it's legal in the destination filesystem: the least common denominator. +.substr(0,50);const ts=new Date();const tm=ts.getUTCFullYear()+'_'+pad(ts.getUTCMonth()+1)+'_'+pad(ts.getUTCDate())+'T'+pad(ts.getUTCHours())+''+pad(ts.getUTCMinutes())+''+pad(ts.getUTCSeconds())+'.'+pad(ts.getUTCMilliseconds(),3)+'Z';dumpName+='.fatal_'+err_id+'_dump_'+tm+'.js';for(let i=0,l=dumpPaths.length;i'[!circular ref!]'});// make sure each line is a comment line: +d=d.split('\n').map(l=>'// '+l);d=d.join('\n');mkdirp__default['default'](path__default['default'].dirname(dumpfile));fs__default['default'].writeFileSync(dumpfile,sourcecode+'\n\n\n'+d,'utf8');console.error('****** offending generated '+errname+' source code dumped into file: ',dumpfile);break;// abort loop once a dump action was successful! }catch(ex3){//console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); -if(i===l-1){throw ex3;}}}}catch(ex2){console.error("generated "+errname+" source code fatal DUMPING error: ",ex2.message," -- while attempting to dump into file: ",dumpfile,"\n",ex2.stack);}// augment the exception info, when available: +if(i===l-1){throw ex3;}}}}catch(ex2){console.error('generated '+errname+' source code fatal DUMPING error: ',ex2.message,' -- while attempting to dump into file: ',dumpfile,'\n',ex2.stack);}// augment the exception info, when available: if(ex){ex.offending_source_code=sourcecode;ex.offending_source_title=errname;ex.offending_source_dumpfile=dumpfile;}}// // `code_execution_rig` is a function which gets executed, while it is fed the `sourcecode` as a parameter. // When the `code_execution_rig` crashes, its failure is caught and (using the `options`) the sourcecode @@ -88,8 +98,12 @@ if(ex){ex.offending_source_code=sourcecode;ex.offending_source_title=errname;ex. // - options.moduleName // - options.defaultModuleName // -function exec_and_diagnose_this_stuff(sourcecode,code_execution_rig,options,title){options=options||{};var errname=""+(title||"exec_test");var err_id=errname.replace(/[^a-z0-9_]/ig,"_");if(err_id.length===0){err_id="exec_crash";}const debug=0;var p;try{// p = eval(sourcecode); -if(typeof code_execution_rig!=='function'){throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function");}chkBugger(sourcecode);p=code_execution_rig.call(this,sourcecode,options,errname,debug);}catch(ex){if(options.dumpSourceCodeOnFailure||1){dumpSourceToFile(sourcecode,errname,err_id,options,ex);}if(options.throwErrorOnCompileFailure){throw ex;}}return p;}var code_exec={exec:exec_and_diagnose_this_stuff,dump:dumpSourceToFile};// +function exec_and_diagnose_this_stuff(sourcecode,code_execution_rig,options,title){options=options||{};let errname=''+(title||'exec_test');let err_id=errname.replace(/[^a-z0-9_]/ig,'_');if(err_id.length===0){err_id='exec_crash';}const debug=options.debug||0;if(debug)console.warn('generated '+errname+' code under EXEC TEST.');if(debug>1){console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `);}let p;try{// p = eval(sourcecode); +if(typeof code_execution_rig!=='function'){throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function');}chkBugger(sourcecode);p=code_execution_rig.call(this,sourcecode,options,errname,debug);}catch(ex){if(debug>1)console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@');if(debug)console.log('generated '+errname+' source code fatal error: ',ex.message);if(debug>1)console.log('exec-and-diagnose options:',options);if(debug>1)console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@');if(options.dumpSourceCodeOnFailure||1){dumpSourceToFile(sourcecode,errname,err_id,options,ex);}if(options.throwErrorOnCompileFailure){throw ex;}}return p;}var exec={exec:exec_and_diagnose_this_stuff,dump:dumpSourceToFile,convertExceptionToObject};// assert__default['default'](recast__default['default']);//var types = recast.types; //assert(types); //var namedTypes = types.namedTypes; @@ -100,17 +114,17 @@ assert__default['default'](recast__default['default']);//var types = recast.type // WARNING: this regex MUST match the regex for `ID` in ebnf-parser::bnf.l jison language lexer spec! (`ID = [{ALPHA}]{ALNUM}*`) // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! -const ID_REGEX_BASE='[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*';// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +const ID_REGEX_BASE='[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*';// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: -const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode NonAsciiIdentifierStart characters +const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -118,37 +132,37 @@ const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode Non function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); -// As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode +// As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: -// +// // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything -// between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is +// between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. -// +// // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. -// +// // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: -// +// // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A -// +// // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. -// -// To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to +// +// To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the -// first character is fixed and the second character is chosen such that the escape code -// DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input +// first character is fixed and the second character is chosen such that the escape code +// DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: -// -// - the first character is ဩ which is highly visible and allows us to quickly search through a +// +// - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -156,30 +170,30 @@ function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only wan // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will -// pick a different base shape from that CANADIAN SYLLABICS charset. -// - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to +// pick a different base shape from that CANADIAN SYLLABICS charset. +// - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ -// - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered +// - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: -// +// // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 -// - 1489-14A0: ᒉ 5 -// - 14A3-14BA: ᒣ 6 -// - 14C0-14CF: ᓀ +// - 1489-14A0: ᒉ 5 +// - 14A3-14BA: ᒣ 6 +// - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 -// - 1526-153D: ᔦ +// - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -190,58 +204,58 @@ function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only wan // - 1622-162D: ᘢ // // ## JISON identifier formats ## -// +// // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. -// +// // -> (1+2) start-# + end-# -// +// // - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ -// +// // - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# -// +// // - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# -// +// // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - result location reference `@$` -// +// // -> (6) single-@ -// +// // - rule id number `#$` -// +// // -> (3) single-# -// +// // - result stack index `##$` -// +// // -> (4) double-# -// +// // - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -// +// // - 'negative index' location reference, e.g. `@-2` -// +// // -> (7) single-negative-@ -// +// // - 'negative index' stack indexes, e.g. `##-2` -// +// // -> (5) double-negative-# -// +// // count the number of occurrences of ch in src: -// +// // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -258,38 +272,38 @@ function countOccurrences(ch,src){let i=ch.codePointAt(0);return hash[i]||0;}// // Preferrably has ZERO occurrences in the given `input`, but otherwise // deliver the one with the least number of occurrences. function pickChar(set,input){// strip out the spaces: -set=set.replace(/\s+/g,'');assert__default['default'](set.length>=1);let lsidx=0;let lsfreq=Infinity;for(let i=0,l=set.length;i=1);let lsidx=0;let lsfreq=Infinity;for(let i=0,l=set.length;i (1+2) start-# + end-# -// +// // - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ -// +// // - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# -// +// // - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# -// +// // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - result location reference `@$` -// +// // -> (6) single-@ -// +// // - rule id number `#$` -// +// // -> (3) single-# -// +// // - result stack index `##$` -// +// // -> (4) double-# -// +// // - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -// +// // - 'negative index' location reference, e.g. `@-2` -// +// // -> (7) single-negative-@ -// +// // - 'negative index' stack indexes, e.g. `##-2` -// +// // -> (5) double-negative-# -// -const escChar=pickChar(escCharSet);let typeIdChar=[];for(let i=0,l=typeIdCharSets.length;i (1) start-# tokenDirectIdentifierStart:escChar+typeIdChar[0],tokenDirectIdentifierRe:new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`,'g'),// - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart:'$',tokenValueReferenceRe:new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`,'g'),// - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ // - result location reference `@$` -// +// // -> (6) single-@ tokenLocationStart:escChar+typeIdChar[1],tokenLocationRe:new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`,'g'),// - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# // - rule id number `#$` -// +// // -> (3) single-# tokenIdentifierStart:escChar+typeIdChar[2],tokenIdentifierRe:new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`,'g'),// - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# // - result stack index `##$` -// +// // -> (4) double-# tokenStackIndexStart:escChar+typeIdChar[3],tokenStackIndexRe:new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`,'g'),// - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -tokenNegativeValueReferenceStart:escChar+typeIdChar[4],tokenValueReferenceRe:new XRegExp__default['default'](`$-([0-9]+)`,'g'),// - 'negative index' location reference, e.g. `@-2` -// +tokenNegativeValueReferenceStart:escChar+typeIdChar[4],tokenValueReferenceRe:new XRegExp__default['default']('$-([0-9]+)','g'),// - 'negative index' location reference, e.g. `@-2` +// // -> (7) single-negative-@ -tokenNegativeLocationStart:escChar+typeIdChar[5],tokenNegativeLocationRe:new XRegExp__default['default'](`@-([0-9]+)`,'g'),// - 'negative index' stack indexes, e.g. `##-2` -// +tokenNegativeLocationStart:escChar+typeIdChar[5],tokenNegativeLocationRe:new XRegExp__default['default']('@-([0-9]+)','g'),// - 'negative index' stack indexes, e.g. `##-2` +// // -> (5) double-negative-# -tokenNegativeStackIndexStart:escChar+typeIdChar[6],tokenNegativeStackIndexRe:new XRegExp__default['default'](`#-([0-9]+)`,'g'),// combined regex for encoding direction +tokenNegativeStackIndexStart:escChar+typeIdChar[6],tokenNegativeStackIndexRe:new XRegExp__default['default']('#-([0-9]+)','g'),// combined regex for encoding direction tokenDetect4EncodeRe:new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`,'g'),// combined regex for decoding direction tokenDetect4DecodeRe:new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`,'g'),encode:function encodeJisonTokens(src,locationOffsetSpec){let re=this.tokenDetect4EncodeRe;// reset regex re.lastIndex=0;// patch `src` for the lookbehind emulation in the main regex used: src=' '+src;// Perform the encoding, one token at a time via callback function. -// +// // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. -// This is a tad sub-optimal as we won't be able to report errors early +// This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -412,35 +426,35 @@ if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax return src.substring(1);},decode:function decodeJisonTokens(src,locationOffsetSpec){let re=this.tokenDetect4DecodeRe;// reset regex re.lastIndex=0;// patch `src` for the lookbehind emulation in the main regex used: src=' '+src;// Perform the encoding, one token at a time via callback function. -// +// // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. -// This is a tad sub-optimal as we won't be able to report errors early +// This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src=src.replace(re,(m,p1,p2,p3,offset)=>{// p1 is only serving as lookbehind emulation -switch(p2){case this.tokenNegativeValueReferenceStart:return p1+"$-"+p3;case this.tokenNegativeStackIndexStart:return p1+"##-"+p3;case this.tokenStackIndexStart:return p1+"##"+p3;case this.tokenNegativeLocationStart:return p1+"@-"+p3;case this.tokenLocationStart:return p1+"@"+p3;case this.tokenDirectIdentifierStart:// p3 CANNOT be a negative value or token ID +switch(p2){case this.tokenNegativeValueReferenceStart:return p1+'$-'+p3;case this.tokenNegativeStackIndexStart:return p1+'##-'+p3;case this.tokenStackIndexStart:return p1+'##'+p3;case this.tokenNegativeLocationStart:return p1+'@-'+p3;case this.tokenLocationStart:return p1+'@'+p3;case this.tokenDirectIdentifierStart:// p3 CANNOT be a negative value or token ID if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: ${p2+p3+p4} is an illegal negative reference type`,src,offset+p1.length+p2.length);}return p1+p2+p3;}return p1+'#'+p3+'#';case this.tokenIdentifierStart:// p3 CANNOT be a negative value or token ID if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: ${p2+p3+p4} is an illegal negative reference type`,src,offset+p1.length+p2.length);}return p1+p2+p3;}return p1+'#'+p3;default:if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: unexpected jison token sentinel escape ${p2} at ${p2+p3}`,src,offset+p1.length);}return p1+p2+p3;}});// and remove the added prefix which was used for lookbehind emulation: -return src.substring(1);}};}function parseCodeChunkToAST(src,options){src=src.replace(/@/g,'\uFFDA').replace(/#/g,'\uFFDB');var ast=recast__default['default'].parse(src);return ast;}function compileCodeToES5(src,options){options=Object.assign({},{ast:true,code:true,sourceMaps:true,comments:true,filename:'compileCodeToES5.js',sourceFileName:'compileCodeToES5.js',sourceRoot:'.',sourceType:'module',babelrc:false,ignore:["node_modules/**/*.js"],compact:false,retainLines:false,presets:[["@babel/preset-env",{targets:{browsers:["last 2 versions"],node:"8.0"}}]]},options);return babel.transformSync(src,options);// => { code, map, ast } -}function prettyPrintAST(ast,options){var options=options||{};const defaultOptions={tabWidth:2,quote:'single',arrowParensAlways:true,// Do not reuse whitespace (or anything else, for that matter) +return src.substring(1);}};}function parseCodeChunkToAST(src,options){src=src.replace(/@/g,'\uFFDA').replace(/#/g,'\uFFDB');const ast=recast__default['default'].parse(src);return ast;}function compileCodeToES5(src,options){options=Object.assign({},{ast:true,code:true,sourceMaps:true,comments:true,filename:'compileCodeToES5.js',sourceFileName:'compileCodeToES5.js',sourceRoot:'.',sourceType:'module',babelrc:false,ignore:['node_modules/**/*.js'],compact:false,retainLines:false,presets:[['@babel/preset-env',{targets:{browsers:['last 2 versions'],node:'8.0'}}]]},options);return babel.transformSync(src,options);// => { code, map, ast } +}function prettyPrintAST(ast,options){options=options||{};const defaultOptions={tabWidth:2,quote:'single',arrowParensAlways:true,// Do not reuse whitespace (or anything else, for that matter) // when printing generically. -reuseWhitespace:false};for(var key in defaultOptions){if(options[key]===undefined){options[key]=defaultOptions[key];}}let s=recast__default['default'].prettyPrint(ast,defaultOptions);let new_src=s.code;new_src=new_src.replace(/\r\n|\n|\r/g,'\n')// platform dependent EOL fixup +reuseWhitespace:false};for(let key in defaultOptions){if(options[key]===undefined){options[key]=defaultOptions[key];}}let s=recast__default['default'].prettyPrint(ast,defaultOptions);let new_src=s.code;new_src=new_src.replace(/\r\n|\n|\r/g,'\n')// platform dependent EOL fixup // backpatch possible jison variables extant in the prettified code: .replace(/\uFFDA/g,'@').replace(/\uFFDB/g,'#');return new_src;}// validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src,yylloc,options){// make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: -if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cnt);src=lines.join('\n')+src;}if(!src.trim()){return false;}try{var rv=parseCodeChunkToAST(src,options);return false;}catch(ex){return ex.message||"code snippet cannot be parsed";}}// The rough-and-ready preprocessor for any action code block: +if(yylloc&&yylloc.first_line>0){let cnt=yylloc.first_line;let lines=new Array(cnt);src=lines.join('\n')+src;}if(!src.trim()){return false;}try{let rv=parseCodeChunkToAST(src,options);return false;}catch(ex){return ex.message||'code snippet cannot be parsed';}}// The rough-and-ready preprocessor for any action code block: // this one trims off any surplus whitespace and removes any // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -448,7 +462,7 @@ if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cn // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -457,13 +471,13 @@ if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cn // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// -function trimActionCode(src,startMarker){var s=src.trim();// remove outermost set of braces UNLESS there's +// +function trimActionCode(src,startMarker){let s=src.trim();// remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated // code analyzer to simplify the code! @@ -495,34 +509,34 @@ s=s.replace(/^\{([^]*?)\}$/,'$1').trim();}else{// code may not be wrapped or oth // wrapping braces when we can guarantee they're the only ones there, // i.e. only exist as outer wrapping. s=s.replace(/^\{([^}]*)\}$/,'$1').trim();}s=s.replace(/;+$/,'').trim();return s;}var parse2AST={generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST,compileCodeToES5,prettyPrintAST,checkActionBlock,trimActionCode,ID_REGEX_BASE,IN_ID_CHARSET};function chkBugger$1(src){src=String(src);if(src.match(/\bcov_\w+/)){console.error('### ISTANBUL COVERAGE CODE DETECTED ###\n',src);}}/// HELPER FUNCTION: print the function in source code form, properly indented. -/** @public */function printFunctionSourceCode(f){var src=String(f);chkBugger$1(src);return src;}const funcRe=/^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/;const arrowFuncRe=/^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/;/// HELPER FUNCTION: print the function **content** in source code form, properly indented, +/** @public */function printFunctionSourceCode(f){const src=String(f);chkBugger$1(src);return src;}const funcRe=/^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/;const arrowFuncRe=/^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/;/// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// -/** @public */function printFunctionSourceCodeContainer(f){var action=printFunctionSourceCode(f).trim();var args;// Also cope with Arrow Functions (and inline those as well?). +/// +/** @public */function printFunctionSourceCodeContainer(f){let action=printFunctionSourceCode(f).trim();let args;// Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 -var m=funcRe.exec(action);if(m){args=m[1].trim();action=m[2].trim();}else{m=arrowFuncRe.exec(action);if(m){if(m[2]){// non-bracketed arguments: +let m=funcRe.exec(action);if(m){args=m[1].trim();action=m[2].trim();}else{m=arrowFuncRe.exec(action);if(m){if(m[2]){// non-bracketed arguments: args=m[2].trim();}else{// bracketed arguments: may be empty args list! args=m[1].trim();}if(m[5]){// non-bracketed version: implicit `return` statement! // -// Q: Must we make sure we have extra braces around the return value -// to prevent JavaScript from inserting implit EOS (End Of Statement) +// Q: Must we make sure we have extra braces around the return value +// to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already // have formatted the code correctly. -action=m[4].trim();action='return '+action+';';}else{action=m[3].trim();}}else{var e=new Error('Cannot extract code from function');e.subject=action;throw e;}}return{args:args,code:action};}var stringifier={printFunctionSourceCode,printFunctionSourceCodeContainer};// -// -// -function detectIstanbulGlobal(){const gcv="__coverage__";const globalvar=new Function('return this')();var coverage=globalvar[gcv];return coverage||false;}// +action=m[4].trim();action='return '+action+';';}else{action=m[3].trim();}}else{const e=new Error('Cannot extract code from function');e.subject=action;throw e;}}return{args:args,code:action};}var stringifier={printFunctionSourceCode,printFunctionSourceCodeContainer};// +// +// +function detectIstanbulGlobal(){const gcv='__coverage__';const globalvar=new Function('return this')();const coverage=globalvar[gcv];return coverage||false;}// // Helper library for safe code execution/compilation // // MIT Licensed @@ -540,7 +554,7 @@ function detectIstanbulGlobal(){const gcv="__coverage__";const globalvar=new Fun // The default assumed is the standard JavaScript `RegExp` class. // // Return FALSE when there's no failure, otherwise return an `Error` info object. -function checkRegExp(re_src,re_flags,XRegExp){var re;// were we fed a RegExp object or a string? +function checkRegExp(re_src,re_flags,XRegExp){let re;// were we fed a RegExp object or a string? if(re_src&&typeof re_src.source==='string'&&typeof re_src.flags==='string'&&typeof re_src.toString==='function'&&typeof re_src.test==='function'&&typeof re_src.exec==='function'){// we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member // and the `.toString()` method to produce something that's compileable by XRegExp // at least... @@ -554,7 +568,7 @@ if(re_src==null){return new Error('invalid regular expression source: '+re_src); // The default assumed is the standard JavaScript `RegExp` class. // // Return FALSE when the input is not a legal regex. -function getRegExpInfo(re_src,re_flags,XRegExp){var re1,re2,m1,m2;// were we fed a RegExp object or a string? +function getRegExpInfo(re_src,re_flags,XRegExp){let re1,re2,m1,m2;// were we fed a RegExp object or a string? if(re_src&&typeof re_src.source==='string'&&typeof re_src.flags==='string'&&typeof re_src.toString==='function'&&typeof re_src.test==='function'&&typeof re_src.exec==='function'){// we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member // and the `.toString()` method to produce something that's compileable by XRegExp // at least... @@ -566,32 +580,41 @@ return false;}else{re_src=''+re_src;if(re_flags==null){re_flags=undefined;// `ne // wrap it and append `(?:)` to ensure it matches // the empty string, then match it against it to // obtain the `match` array. -re1=new XRegExp(re_src,re_flags);re2=new XRegExp('(?:'+re_src+')|(?:)',re_flags);m1=re1.exec('');m2=re2.exec('');return{acceptsEmptyString:!!m1,captureCount:m2.length-1};}catch(ex){return false;}}var reHelpers={checkRegExp:checkRegExp,getRegExpInfo:getRegExpInfo};var cycleref=[];var cyclerefpath=[];var linkref=[];var linkrefpath=[];var path=[];function shallow_copy(src){if(typeof src==='object'){if(src instanceof Array){return src.slice();}var dst={};if(src instanceof Error){dst.name=src.name;dst.message=src.message;dst.stack=src.stack;}for(var k in src){if(Object.prototype.hasOwnProperty.call(src,k)){dst[k]=src[k];}}return dst;}return src;}function shallow_copy_and_strip_depth(src,parentKey){if(typeof src==='object'){var dst;if(src instanceof Array){dst=src.slice();for(var i=0,len=dst.length;i '+parentKey+'.'+k+']';}else{dst[k]=src[k];}}}}return dst;}return src;}function stripErrorStackPaths(msg){// strip away devbox-specific paths in error stack traces in the output: -msg=msg.replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi,'at $1(/$2)').replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi,'at /$1');return msg;}function trim_array_tail(arr){if(arr instanceof Array){for(var len=arr.length;len>0;len--){if(arr[len-1]!=null){break;}}arr.length=len;}}function treat_value_stack(v){if(v instanceof Array){var idx=cycleref.indexOf(v);if(idx>=0){v='[cyclic reference to parent array --> '+cyclerefpath[idx]+']';}else{idx=linkref.indexOf(v);if(idx>=0){v='[reference to sibling array --> '+linkrefpath[idx]+', length = '+v.length+']';}else{cycleref.push(v);cyclerefpath.push(path.join('.'));linkref.push(v);linkrefpath.push(path.join('.'));v=treat_error_infos_array(v);cycleref.pop();cyclerefpath.pop();}}}else if(v){v=treat_object(v);}return v;}function treat_error_infos_array(arr){var inf=arr.slice();trim_array_tail(inf);for(var key=0,len=inf.length;key '+parentKey+'.'+k+']';}else{dst[k]=src[k];}}}}return dst;}return src;}// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. +function stripErrorStackPaths(msg){// strip away devbox-specific paths in error stack traces in the output: +// and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': +msg=msg.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi,'at $1(/$2:$3)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi,'at /$1:$2');return msg;}// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj){if(typeof obj==='string'){// and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': +let msg=obj.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi,'at $1(/$2)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi,'at /$1');return msg;}if(obj){if(obj.stack){obj.stack=cleanStackTrace4Comparison(obj.stack);}let keys=Object.keys(obj);for(let i in keys){let key=keys[i];let el=obj[key];cleanStackTrace4Comparison(el);}}return obj;}function trim_array_tail(arr){if(arr instanceof Array){for(var len=arr.length;len>0;len--){if(arr[len-1]!=null){break;}}arr.length=len;}}function treat_value_stack(v){if(v instanceof Array){let idx=cycleref.indexOf(v);if(idx>=0){v='[cyclic reference to parent array --> '+cyclerefpath[idx]+']';}else{idx=linkref.indexOf(v);if(idx>=0){v='[reference to sibling array --> '+linkrefpath[idx]+', length = '+v.length+']';}else{cycleref.push(v);cyclerefpath.push(path.join('.'));linkref.push(v);linkrefpath.push(path.join('.'));v=treat_error_infos_array(v);cycleref.pop();cyclerefpath.pop();}}}else if(v){v=treat_object(v);}return v;}function treat_error_infos_array(arr){let inf=arr.slice();trim_array_tail(inf);for(let key=0,len=inf.length;key=0){// cyclic reference, most probably an error instance. +e=shallow_copy(e);if(e&&e.hash){path.push('hash');e.hash=treat_hash(e.hash);path.pop();}if(e.parser){path.push('parser');e.parser=treat_parser(e.parser);path.pop();}if(e.lexer){path.push('lexer');e.lexer=treat_lexer(e.lexer);path.pop();}if(e.__error_infos){path.push('__error_infos');e.__error_infos=treat_value_stack(e.__error_infos);path.pop();}if(e.__error_recovery_infos){path.push('__error_recovery_infos');e.__error_recovery_infos=treat_value_stack(e.__error_recovery_infos);path.pop();}trim_array_tail(e.symbol_stack);trim_array_tail(e.state_stack);trim_array_tail(e.location_stack);if(e.value_stack){path.push('value_stack');e.value_stack=treat_value_stack(e.value_stack);path.pop();}return e;}function treat_object(e){if(e&&typeof e==='object'){let idx=cycleref.indexOf(e);if(idx>=0){// cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: e=shallow_copy_and_strip_depth(e,cyclerefpath[idx]);}else{idx=linkref.indexOf(e);if(idx>=0){e='[reference to sibling --> '+linkrefpath[idx]+']';}else{cycleref.push(e);cyclerefpath.push(path.join('.'));linkref.push(e);linkrefpath.push(path.join('.'));e=treat_error_report_info(e);cycleref.pop();cyclerefpath.pop();}}}return e;}// strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. -function trimErrorForTestReporting(e){cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];if(e){e=treat_object(e);}cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];return e;}var helpers={rmCommonWS,camelCase,mkIdentifier,isLegalIdentifierInput,scanRegExp,dquote,trimErrorForTestReporting,stripErrorStackPaths,checkRegExp:reHelpers.checkRegExp,getRegExpInfo:reHelpers.getRegExpInfo,exec:code_exec.exec,dump:code_exec.dump,generateMapper4JisonGrammarIdentifiers:parse2AST.generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST:parse2AST.parseCodeChunkToAST,compileCodeToES5:parse2AST.compileCodeToES5,prettyPrintAST:parse2AST.prettyPrintAST,checkActionBlock:parse2AST.checkActionBlock,trimActionCode:parse2AST.trimActionCode,ID_REGEX_BASE:parse2AST.ID_REGEX_BASE,IN_ID_CHARSET:parse2AST.IN_ID_CHARSET,printFunctionSourceCode:stringifier.printFunctionSourceCode,printFunctionSourceCodeContainer:stringifier.printFunctionSourceCodeContainer,detectIstanbulGlobal};// See also: +function trimErrorForTestReporting(e){cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];if(e){e=treat_object(e);}cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];return e;}var helpers={rmCommonWS,camelCase,mkIdentifier,isLegalIdentifierInput,scanRegExp,dquote,trimErrorForTestReporting,stripErrorStackPaths,cleanStackTrace4Comparison,checkRegExp:reHelpers.checkRegExp,getRegExpInfo:reHelpers.getRegExpInfo,exec:exec.exec,dump:exec.dump,convertExceptionToObject:exec.convertExceptionToObject,generateMapper4JisonGrammarIdentifiers:parse2AST.generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST:parse2AST.parseCodeChunkToAST,compileCodeToES5:parse2AST.compileCodeToES5,prettyPrintAST:parse2AST.prettyPrintAST,checkActionBlock:parse2AST.checkActionBlock,trimActionCode:parse2AST.trimActionCode,ID_REGEX_BASE:parse2AST.ID_REGEX_BASE,IN_ID_CHARSET:parse2AST.IN_ID_CHARSET,printFunctionSourceCode:stringifier.printFunctionSourceCode,printFunctionSourceCodeContainer:stringifier.printFunctionSourceCodeContainer,detectIstanbulGlobal};// 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. -function JisonParserError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonParserError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8/Chrome engine +function JisonParserError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonParserError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){let ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8/Chrome engine Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonParserError.prototype,Error.prototype);}else{JisonParserError.prototype=Object.create(Error.prototype);}JisonParserError.prototype.constructor=JisonParserError;JisonParserError.prototype.name='JisonParserError';// helper: reconstruct the productions[] table -function bp(s){var rv=[];var p=s.pop;var r=s.rule;for(var i=0,l=p.length;i1)return resultValue;// do not (yet) kill the sharedState when this is a reentrant run. @@ -734,23 +756,29 @@ stack.length=0;// fastest way to nuke an array without overly bothering the GC sstack.length=0;vstack.length=0;sp=0;// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return resultValue;};// NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return resultValue;};// NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! -this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){var pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,expected:expected,recoverable:recoverable,state:state,action:action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,stack_pointer:sp,yy:sharedState_yy,lexer:lexer,parser:this,// and make sure the error info doesn't stay due to potential +this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){const pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,expected,recoverable,state,action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,stack_pointer:sp,yy:sharedState_yy,lexer,parser:this,// and make sure the error info doesn't stay due to potential // ref cycle via userland code manipulations. // These would otherwise all be memory leak opportunities! // // Note that only array and object references are nuked as those // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. -destroy:function destructParseErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! -this.__error_infos.push(pei);return pei;};function getNonTerminalFromCode(symbol){var tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){var token=lexer.lex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){var token=lexer.fastLex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}var lex=stdLex;var state,action,r,t;var yyval={$:true,_$:undefined,yy:sharedState_yy};var p;var yyrulelen;var this_production;var newState;var retval=false;try{this.__reentrant_call_depth++;lexer.setInput(input,sharedState_yy);// NOTE: we *assume* no lexer pre/post handlers are set up *after* +destroy:function destructParseErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// info.value = null; +// info.value_stack = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +this.__error_infos.push(pei);return pei;};function getNonTerminalFromCode(symbol){let tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){let token=lexer.lex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){let token=lexer.fastLex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}let lex=stdLex;let state,action,r,t;let yyval={$:true,_$:undefined,yy:sharedState_yy};let p;let yyrulelen;let this_production;let newState;let retval=false;try{this.__reentrant_call_depth++;lexer.setInput(input,sharedState_yy);// NOTE: we *assume* no lexer pre/post handlers are set up *after* // this initial `setInput()` call: hence we can now check and decide // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: -if(typeof lexer.canIUse==='function'){var lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack +if(typeof lexer.canIUse==='function'){let lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack state=newState;// sstack[sp - 1]; // use default actions if available if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}else{// The single `==` condition below covers both these `===` comparisons in a single @@ -759,7 +787,7 @@ if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}els // if (symbol === null || typeof symbol === 'undefined') ... if(!symbol){symbol=lex();}// read action for current state and first input t=table[state]&&table[state][symbol]||NO_ACTION;newState=t[1];action=t[0];// handle parse error -if(!action){var errStr;var errSymbolDescr=this.describeSymbol(symbol)||symbol;var expected=this.collect_expected_token_set(state);// Report error +if(!action){let errStr;let errSymbolDescr=this.describeSymbol(symbol)||symbol;let expected=this.collect_expected_token_set(state);// Report error errStr='Parse error';if(typeof lexer.yylineno==='number'){errStr+=' on line '+(lexer.yylineno+1);}if(typeof lexer.showPosition==='function'){errStr+=':\n'+lexer.showPosition(79-10,10)+'\n';}else{errStr+=': ';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}// we cannot recover from the error! p=this.constructParseErrorInfo(errStr,null,expected,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}}switch(action){// catch misc. parse failures: default:// this shouldn't happen, unless resolve defaults are off @@ -767,16 +795,16 @@ if(action instanceof Array){p=this.constructParseErrorInfo('Parse Error: multipl // or a buggy LUT (LookUp Table): p=this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.',null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;// shift: case 1:stack[sp]=symbol;vstack[sp]=lexer.yytext;sstack[sp]=newState;// push state -if(typeof Jison!=='undefined'&&Jison.parserDebugger){var tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;// Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: +if(typeof Jison!=='undefined'&&Jison.parserDebugger){let tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;// Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: continue;// reduce: case 2:this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,newState,sp-1,vstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack +yyrulelen=this_production[1];r=this.performAction.call(yyval,newState,sp-1,vstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:if(sp!==-2){retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -1025,8 +1053,8 @@ return retval;}};parser.originalParseError=parser.parseError;parser.originalQuot * @public * @constructor * @nocollapse - */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 -Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';var lexer={// Code Generator Information Report + */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){const ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 +Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';const lexer={// Code Generator Information Report // --------------------------------- // // Options: @@ -1095,7 +1123,7 @@ CRLF_Re:/\r\n?|\n/,/** * @this {RegExpLexer} */constructLexErrorInfo:function lexer_constructLexErrorInfo(msg,recoverable,show_input_position){msg=''+msg;// heuristic to determine if the error message already contains a (partial) source code dump // as produced by either `showPosition()` or `prettyPrintRange()`: -if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){var pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){var pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */var pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... +if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){const pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){const pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */const pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:this,/** * and make sure the error info doesn't stay due to potential * ref cycle via userland code manipulations. @@ -1107,7 +1135,11 @@ text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:t * * @public * @this {LexErrorInfo} - */destroy:function destructLexErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! + */destroy:function destructLexErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;},/** * handler which is invoked when a lexer error occurs. * @@ -1118,8 +1150,8 @@ this.__error_infos.push(pei);return pei;},/** * * @public * @this {RegExpLexer} - */yyerror:function yyError(str/*, ...args */){var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** + */yyerror:function yyError(str/*, ...args */){let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: +let args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** * final cleanup function for when we have completed lexing the input; * make it an API so that external code can use this one once userland * code has decided it's time to destroy any lingering lexer error @@ -1134,13 +1166,13 @@ var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_a this.setInput('',{});// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** * clear the lexer token context; intended for internal use only * * @public * @this {RegExpLexer} */clear:function lexer_clear(){this.yytext='';this.yyleng=0;this.match='';// - DO NOT reset `this.matched` -this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** +this.matches=false;this._more=false;this._backtrack=false;const col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** * resets the lexer, sets new input * * @public @@ -1149,10 +1181,10 @@ this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.la // including expansion work to be done to go from a loaded // lexer to a usable lexer: if(!this.__decompressed){// step 1: decompress the regex list: -var rules=this.rules;for(var i=0,len=rules.length;i> tokens and perform user action code for a <> match, but only does so *once*) -return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}var ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). +return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}let ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. -var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;var ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** +let slice_len=1;let lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;const ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** * unshifts one char (or an entire string) into the input * * @public * @this {RegExpLexer} - */unput:function lexer_unput(ch){var len=ch.length;var lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** + */unput:function lexer_unput(ch){let len=ch.length;let lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** // The `offset` value MAY be negative if you `unput()` more text than you have already lexed. // This type of behaviour is generally observed for one kind of 'lexer/parser hack' // where custom token-illiciting characters are pushed in front of the input stream to help @@ -1222,11 +1254,11 @@ var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lin if(-this.offset>this.base_position){this.base_position=-this.offset;}this.match=this.match.substr(0,this.match.length-len);this.matched=this.matched.substr(0,this.matched.length-len);if(lines.length>1){this.yylineno-=lines.length-1;this.yylloc.last_line=this.yylineno+1;// Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. -var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** +let pre=this.match;let pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -1236,8 +1268,8 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */lookAhead:function lexer_lookAhead(){return this._input||'';},/** @@ -1254,7 +1286,7 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 */reject:function lexer_reject(){if(this.options.backtrack_lexer){this._backtrack=true;}else{// when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. -var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** +let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** * retain first n characters of the match * * @public @@ -1276,17 +1308,17 @@ var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yyl * * @public * @this {RegExpLexer} - */pastInput:function lexer_pastInput(maxSize,maxLines){var past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0)maxSize=Infinity;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=Infinity;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substr` anticipation: treat \r\n as a single character and take a little + */pastInput:function lexer_pastInput(maxSize,maxLines){let past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0){maxSize=Infinity;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=Infinity;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past=past.substr(-maxSize*2-2);// now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: -var a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, +let a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, // do add an ellipsis prefix... if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -1312,18 +1344,18 @@ if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} - */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){var next=this.match;var source=this._input||'';if(maxSize<0)maxSize=next.length+source.length;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=maxSize;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substring` anticipation: treat \r\n as a single character and take a little + */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){let next=this.match;let source=this._input||'';if(maxSize<0){maxSize=next.length+source.length;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=maxSize;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: if(next.lengthmaxSize){next=next.substring(0,maxSize)+'...';}return next;},/** @@ -1332,7 +1364,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){var pre=this.pastInput(maxPrefix).replace(/\s/g,' ');var c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** + */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){const pre=this.pastInput(maxPrefix).replace(/\s/g,' ');let c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** * return an YYLLOC info object derived off the given context (actual, preceding, following, current). * Use this method when the given `actual` location is not guaranteed to exist (i.e. when * it MAY be NULL) and you MUST have a valid location info object anyway: @@ -1348,7 +1380,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */deriveLocationInfo:function lexer_deriveYYLLOC(actual,preceding,following,current){var loc={first_line:1,first_column:0,last_line:1,last_column:0,range:[0,0]};if(actual){loc.first_line=actual.first_line|0;loc.last_line=actual.last_line|0;loc.first_column=actual.first_column|0;loc.last_column=actual.last_column|0;if(actual.range){loc.range[0]=actual.range[0]|0;loc.range[1]=actual.range[1]|0;}}if(loc.first_line<=0||loc.last_line=loc.first_line)){loc.last_line=current.last_line|0;loc.last_column=current.last_column|0;if(current.range){loc.range[1]=current.range[1]|0;}}}// sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter // or plan D heuristics to produce a 'sensible' last_line value: @@ -1397,9 +1429,9 @@ loc.range[1]=loc.range[0];}if(loc.first_column<0){loc.first_column=0;}if(loc.las * * @public * @this {RegExpLexer} - */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;var input=this.matched+(this._input||'');var lines=input.split('\n');var l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);var l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);var lineno_display_width=1+Math.log10(l1|1)|0;var ws_prefix=new Array(lineno_display_width).join(' ');var nonempty_line_indexes=[[],[],[]];var rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){var lno=index+l0;var lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);var rv=lno_pfx+': '+line;var errpfx=new Array(lineno_display_width+1).join('^');var offset=2+1;var len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it + */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;let input=this.matched+(this._input||'');let lines=input.split('\n');let l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);let l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);let lineno_display_width=1+Math.log10(l1|1)|0;let ws_prefix=new Array(lineno_display_width).join(' ');let nonempty_line_indexes=[[],[],[]];let rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){let lno=index+l0;let lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);let rv=lno_pfx+': '+line;let errpfx=new Array(lineno_display_width+1).join('^');let offset=2+1;let len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: -for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){var clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;var clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;var intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** +for(let i=0;i<=2;i++){let line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){let clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;let clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;let intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** * helper function, used to produce a human readable description as a string, given * the input `yylloc` location object. * @@ -1408,7 +1440,7 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){var l1=yylloc.first_line;var l2=yylloc.last_line;var c1=yylloc.first_column;var c2=yylloc.last_column;var dl=l2-l1;var dc=c2-c1;var rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){var r1=yylloc.range[0];var r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** + */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){let l1=yylloc.first_line;let l2=yylloc.last_line;let c1=yylloc.first_column;let c2=yylloc.last_column;let dl=l2-l1;let dc=c2-c1;let rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){let r1=yylloc.range[0];let r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** * test the lexed token: return FALSE when not a match, otherwise return token. * * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]` @@ -1425,18 +1457,18 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */test_match:function lexer_test_match(match,indexed_rule){var token,lines,backup,match_str,match_str_len;if(this.options.backtrack_lexer){// save context + */test_match:function lexer_test_match(match,indexed_rule){let backup;if(this.options.backtrack_lexer){// save context backup={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.yylloc.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column,range:this.yylloc.range.slice()},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,//_signaled_error_token: this._signaled_error_token, -yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}match_str=match[0];match_str_len=match_str.length;lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: +yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}let match_str=match[0];let match_str_len=match_str.length;let lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: // those rules will already have moved this `offset` forward matching their match lengths, // hence we must only add our own match length now: this.offset+=match_str_len;this._more=false;this._backtrack=false;this._input=this._input.slice(match_str_len);// calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} -token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: +let token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; if(this.done&&this._input){this.done=false;}if(token){return token;}else if(this._backtrack){// recover context -for(var k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. +for(let k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. }else if(this._signaled_error_token){// produce one 'error' token as `.parseError()` in `reject()` // did not guarantee a failure signal by throwing an exception! token=this._signaled_error_token;this._signaled_error_token=false;return token;}return false;},/** @@ -1444,19 +1476,19 @@ token=this._signaled_error_token;this._signaled_error_token=false;return token;} * * @public * @this {RegExpLexer} - */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}var token,match,tempMatch,index;if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}var spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. + */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}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();// Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 -if(!spec||!spec.rules){var lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! -return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}var rule_ids=spec.rules;var regexes=spec.__rule_regexes;var len=spec.__rule_count;// Note: the arrays are 1-based, while `len` itself is a valid index, +if(!spec||!spec.rules){let lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! +return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}{let rule_ids=spec.rules;let regexes=spec.__rule_regexes;let len=spec.__rule_count;let match;let index;// 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(var i=1;i<=len;i++){tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. +for(let i=1;i<=len;i++){let tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){let token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. }else{// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}}else if(!this.options.flex){break;}}}if(match){token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}if(!this._input){this.done=true;this.clear();return this.EOF;}else{var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);var pendingInput=this._input;var activeCondition=this.topState();var conditionStackDepth=this.conditionStack.length;token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us +return false;}}else if(!this.options.flex){break;}}}if(match){let token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) +return false;}}if(!this._input){this.done=true;this.clear();return this.EOF;}{let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);let pendingInput=this._input;let activeCondition=this.topState();let conditionStackDepth=this.conditionStack.length;let token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: if(!this.matches&&// and make sure the input has been modified/consumed ... @@ -1467,7 +1499,7 @@ activeCondition===this.topState()&&conditionStackDepth===this.conditionStack.len * * @public * @this {RegExpLexer} - */lex:function lexer_lex(){var r;//this._clear_state = 0; + */lex:function lexer_lex(){let r;//this._clear_state = 0; if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}// allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer: if(typeof this.pre_lex==='function'){r=this.pre_lex.call(this,0);}if(typeof this.options.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.pre_lex.call(this,r)||r;}if(this.yy&&typeof this.yy.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) @@ -1475,50 +1507,50 @@ r=this.yy.pre_lex.call(this,r)||r;}while(!r){r=this.next();}if(this.yy&&typeof t r=this.yy.post_lex.call(this,r)||r;}if(typeof this.options.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.post_lex.call(this,r)||r;}if(typeof this.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.post_lex.call(this,r)||r;}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return next match that has a token. Identical to the `lex()` API but does not invoke any of the * `pre_lex()` nor any of the `post_lex()` callbacks. * * @public * @this {RegExpLexer} - */fastLex:function lexer_fastLex(){var r;//this._clear_state = 0; + */fastLex:function lexer_fastLex(){let r;//this._clear_state = 0; while(!r){r=this.next();}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return info about the lexer state that can help a parser or other lexer API user to use the * most efficient means available. This API is provided to aid run-time performance for larger @@ -1526,7 +1558,7 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */canIUse:function lexer_canIUse(){var rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** + */canIUse:function lexer_canIUse(){const rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** * backwards compatible alias for `pushState()`; * the latter is symmetrical with `popState()` and we advise to use * those APIs in any modern lexer code, rather than `begin()`. @@ -1545,20 +1577,20 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */popState:function lexer_popState(){var n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}else{return this.conditionStack[0];}},/** + */popState:function lexer_popState(){const n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}return this.conditionStack[0];},/** * return the currently active lexer condition state; when an index * argument is provided it produces the N-th previous condition state, * if available * * @public * @this {RegExpLexer} - */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}else{return'INITIAL';}},/** + */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}return'INITIAL';},/** * (internal) determine the lexer rule set which is active for the * currently active lexer condition state * * @public * @this {RegExpLexer} - */_currentRules:function lexer__currentRules(){var n=this.conditionStack.length-1;var state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions['INITIAL'];},/** + */_currentRules:function lexer__currentRules(){const n=this.conditionStack.length-1;let state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions.INITIAL;},/** * return the number of states currently on the stack * * @public @@ -1570,11 +1602,11 @@ const ID_REGEX_BASE$1='[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*';// prod // Use this to produce rule productions from transformed EBNF which are // guaranteed not to collide with previously generated / already existing // rules (~ symbols). -function generateUniqueSymbol(id,postfix,opts){var sym=id+postfix;if(opts.grammar[sym]){var i=2;// the first occurrence won't have a number, this is already a collision, so start numbering at *2*. -do{sym=id+postfix+i;i++;}while(opts.grammar[sym]);}return sym;}function generatePushAction(handle,offset){var terms=handle.terms;var rv=[];for(var i=0,len=terms.length;i1){rv='['+rv+']';}return rv;}function transformExpression(e,opts,emit){var type=e[0],value=e[1],name=false,has_transformed=0;var list,n;if(type==='xalias'){type=e[1];value=e[2];name=e[3];if(type){e=e.slice(1);}else{e=value;type=e[0];value=e[1];}}if(type==='symbol'){n=e[1];emit(n+(name?'['+name+']':''));}else if(type==='+'){if(!name){name=generateUniqueSymbol(opts.production,'_repetition_plus',opts);}emit(name);has_transformed=1;opts=optsForProduction(name,opts.grammar);list=transformExpressionList([value],opts);opts.grammar[name]=[[list.fragment,'$$ = ['+generatePushAction(list,1)+'];'],[name+' '+list.fragment,'$1.push('+generatePushAction(list,2)+');\n$$ = $1;']];}else if(type==='*'){if(!name){name=generateUniqueSymbol(opts.production,'_repetition',opts);}emit(name);has_transformed=1;opts=optsForProduction(name,opts.grammar);list=transformExpressionList([value],opts);opts.grammar[name]=[['','$$ = [];'],[name+' '+list.fragment,'$1.push('+generatePushAction(list,2)+');\n$$ = $1;']];}else if(type==='?'){if(!name){name=generateUniqueSymbol(opts.production,'_option',opts);}emit(name);has_transformed=1;opts=optsForProduction(name,opts.grammar);list=transformExpressionList([value],opts);// you want to be able to check if 0 or 1 occurrences were recognized: since jison +if(len>1){rv='['+rv+']';}return rv;}function transformExpression(e,opts,emit){let type=e[0];let value=e[1];let name=false;let has_transformed=0;let list,n;if(type==='xalias'){type=e[1];value=e[2];name=e[3];if(type){e=e.slice(1);}else{e=value;type=e[0];value=e[1];}}if(type==='symbol'){n=e[1];emit(n+(name?'['+name+']':''));}else if(type==='+'){if(!name){name=generateUniqueSymbol(opts.production,'_repetition_plus',opts);}emit(name);has_transformed=1;opts=optsForProduction(name,opts.grammar);list=transformExpressionList([value],opts);opts.grammar[name]=[[list.fragment,'$$ = ['+generatePushAction(list,1)+'];'],[name+' '+list.fragment,'$1.push('+generatePushAction(list,2)+');\n$$ = $1;']];}else if(type==='*'){if(!name){name=generateUniqueSymbol(opts.production,'_repetition',opts);}emit(name);has_transformed=1;opts=optsForProduction(name,opts.grammar);list=transformExpressionList([value],opts);opts.grammar[name]=[['','$$ = [];'],[name+' '+list.fragment,'$1.push('+generatePushAction(list,2)+');\n$$ = $1;']];}else if(type==='?'){if(!name){name=generateUniqueSymbol(opts.production,'_option',opts);}emit(name);has_transformed=1;opts=optsForProduction(name,opts.grammar);list=transformExpressionList([value],opts);// you want to be able to check if 0 or 1 occurrences were recognized: since jison // by default *copies* the lexer token value, i.e. `$$ = $1` is the (optional) default action, // we will need to set the action up explicitly in case of the 0-count match: // `$$ = undefined`. @@ -1582,43 +1614,43 @@ if(len>1){rv='['+rv+']';}return rv;}function transformExpression(e,opts,emit){va // Note that we MUST return an array as the // '1 occurrence' match CAN carry multiple terms, e.g. in constructs like // `(T T T)?`, which would otherwise be unrecognizable from the `T*` construct. -opts.grammar[name]=[['','$$ = undefined;'],[list.fragment,'$$ = '+generatePushAction(list,1)+';']];}else if(type==='()'){if(value.length===1&&!name){list=transformExpressionList(value[0],opts);if(list.first_transformed_term_index){has_transformed=list.first_transformed_term_index;}emit(list);}else{if(!name){name=generateUniqueSymbol(opts.production,'_group',opts);}emit(name);has_transformed=1;opts=optsForProduction(name,opts.grammar);opts.grammar[name]=value.map(function(handle){var list=transformExpressionList(handle,opts);return[list.fragment,'$$ = '+generatePushAction(list,1)+';'];});}}return has_transformed;}function transformExpressionList(list,opts){var first_transformed_term_index=false;var terms=list.reduce(function(tot,e){var ci=tot.length;var has_transformed=transformExpression(e,opts,function(name){if(name.terms){tot.push.apply(tot,name.terms);}else{tot.push(name);}});if(has_transformed){first_transformed_term_index=ci+has_transformed;}return tot;},[]);return{fragment:terms.join(' '),terms:terms,first_transformed_term_index:first_transformed_term_index// 1-based index -};}function optsForProduction(id,grammar){return{production:id,grammar:grammar};}function transformProduction(id,production,grammar){var transform_opts=optsForProduction(id,grammar);return production.map(function(handle){var action=null,opts=null;var i,len,n;if(typeof handle!=='string'){action=handle[1];opts=handle[2];handle=handle[0];}var expressions=handle;if(typeof expressions==='string'){expressions=parser$1.parse(handle);}var list=transformExpressionList(expressions,transform_opts);var ret=[list.fragment];if(action){// make sure the action doesn't address any inner items. +opts.grammar[name]=[['','$$ = undefined;'],[list.fragment,'$$ = '+generatePushAction(list,1)+';']];}else if(type==='()'){if(value.length===1&&!name){list=transformExpressionList(value[0],opts);if(list.first_transformed_term_index){has_transformed=list.first_transformed_term_index;}emit(list);}else{if(!name){name=generateUniqueSymbol(opts.production,'_group',opts);}emit(name);has_transformed=1;opts=optsForProduction(name,opts.grammar);opts.grammar[name]=value.map(function(handle){let list=transformExpressionList(handle,opts);return[list.fragment,'$$ = '+generatePushAction(list,1)+';'];});}}return has_transformed;}function transformExpressionList(list,opts){let first_transformed_term_index=false;let terms=list.reduce(function(tot,e){let ci=tot.length;let has_transformed=transformExpression(e,opts,function(name){if(name.terms){tot.push.apply(tot,name.terms);}else{tot.push(name);}});if(has_transformed){first_transformed_term_index=ci+has_transformed;}return tot;},[]);return{fragment:terms.join(' '),terms:terms,first_transformed_term_index:first_transformed_term_index// 1-based index +};}function optsForProduction(id,grammar){return{production:id,grammar:grammar};}function transformProduction(id,production,grammar){let transform_opts=optsForProduction(id,grammar);return production.map(function(handle){let action=null;let opts=null;let i,len,n;if(typeof handle!=='string'){action=handle[1];opts=handle[2];handle=handle[0];}let expressions=handle;if(typeof expressions==='string'){expressions=parser$1.parse(handle);}let list=transformExpressionList(expressions,transform_opts);let ret=[list.fragment];if(action){// make sure the action doesn't address any inner items. if(list.first_transformed_term_index){// seek out all names and aliases; strip out literal tokens first as those cannot serve as $names: -var alist=list.terms;// rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); -var alias_re=new XRegExp__default['default'](`\\[${ID_REGEX_BASE$1}\\]`);var term_re=new XRegExp__default['default'](`^${ID_REGEX_BASE$1}$`);// and collect the PERMITTED aliases: the names of the terms and all the remaining aliases -var good_aliases={};var alias_cnt={};var donotalias={};// WARNING: this replicates the knowledge/code of jison.js::addName() -var addName=function addNameEBNF(s,i){var base=s.replace(/[0-9]+$/,'');var dna=donotalias[base];if(good_aliases[s]){alias_cnt[s]++;if(!dna){good_aliases[s+alias_cnt[s]]=i+1;alias_cnt[s+alias_cnt[s]]=1;}}else{good_aliases[s]=i+1;alias_cnt[s]=1;if(!dna){good_aliases[s+alias_cnt[s]]=i+1;alias_cnt[s+alias_cnt[s]]=1;}}};// WARNING: this replicates the knowledge/code of jison.js::markBasename() -var markBasename=function markBasenameEBNF(s){if(/[0-9]$/.test(s)){s=s.replace(/[0-9]+$/,'');donotalias[s]=true;}};// mark both regular and aliased names, e.g., `id[alias1]` and `id1` +let alist=list.terms;// rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); +let alias_re=new XRegExp__default['default'](`\\[${ID_REGEX_BASE$1}\\]`);let term_re=new XRegExp__default['default'](`^${ID_REGEX_BASE$1}$`);// and collect the PERMITTED aliases: the names of the terms and all the remaining aliases +let good_aliases={};let alias_cnt={};let donotalias={};// WARNING: this replicates the knowledge/code of jison.js::addName() +let addName=function addNameEBNF(s,i){let base=s.replace(/[0-9]+$/,'');let dna=donotalias[base];if(good_aliases[s]){alias_cnt[s]++;if(!dna){good_aliases[s+alias_cnt[s]]=i+1;alias_cnt[s+alias_cnt[s]]=1;}}else{good_aliases[s]=i+1;alias_cnt[s]=1;if(!dna){good_aliases[s+alias_cnt[s]]=i+1;alias_cnt[s+alias_cnt[s]]=1;}}};// WARNING: this replicates the knowledge/code of jison.js::markBasename() +let markBasename=function markBasenameEBNF(s){if(/[0-9]$/.test(s)){s=s.replace(/[0-9]+$/,'');donotalias[s]=true;}};// mark both regular and aliased names, e.g., `id[alias1]` and `id1` // // WARNING: this replicates the knowledge/code of jison.js::markBasename()+addName() usage for(i=0,len=alist.length;imax_term_index){/* @const */var n_suffixes=['st','nd','rd','th'];throw new Error('The action block references the '+n+n_suffixes[Math.max(0,Math.min(3,n-1))]+' term, '+'which is not available in production "'+handle+'"; '+'Be reminded that you cannot reference sub-elements within EBNF */+/? groups, '+'only the outer-most EBNF group alias will remain available at all times '+'due to the EBNF-to-BNF rewrite process.');}}}}ret.push(action);}if(opts){ret.push(opts);}if(ret.length===1){return ret[0];}else{return ret;}});}var ref_list;var ref_names;// create a deep copy of the input, so we will keep the input constant. -function deepClone(from,sub){if(sub==null){ref_list=[];ref_names=[];sub='root';}if(typeof from==='function')return from;if(from==null||typeof from!=='object')return from;if(from.constructor!==Object&&from.constructor!==Array){return from;}var idx=ref_list.indexOf(from);if(idx>=0){throw new Error('[Circular/Xref:'+ref_names[i]+']');// circular or cross reference -}ref_list.push(from);ref_names.push(sub);if(from.constructor===Array){var to=from.slice();for(var i=0,len=to.length;imax_term_index){/* @const */let n_suffixes=['st','nd','rd','th'];throw new Error('The action block references the '+n+n_suffixes[Math.max(0,Math.min(3,n-1))]+' term, '+'which is not available in production "'+handle+'"; '+'Be reminded that you cannot reference sub-elements within EBNF */+/? groups, '+'only the outer-most EBNF group alias will remain available at all times '+'due to the EBNF-to-BNF rewrite process.');}}}}ret.push(action);}if(opts){ret.push(opts);}if(ret.length===1){return ret[0];}return ret;});}let ref_list;let ref_names;// create a deep copy of the input, so we will keep the input constant. +function deepClone(from,sub){if(sub==null){ref_list=[];ref_names=[];sub='root';}if(typeof from==='function')return from;if(from==null||typeof from!=='object')return from;if(from.constructor!==Object&&from.constructor!==Array){return from;}let idx=ref_list.indexOf(from);if(idx>=0){throw new Error('[Circular/Xref:'+ref_names[i]+']');// circular or cross reference +}ref_list.push(from);ref_names.push(sub);if(from.constructor===Array){var to=from.slice();for(var i=0,len=to.length;i=0);// append to the old one? -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; +if(this.yyError){this.yyError=function yyError(str/*, ...args */){let error_rule_depth=this.options.parserErrorsAreRecoverable?locateNearestErrorRecoveryRule(state):-1;let expected=this.collect_expected_token_set(state);let hash=this.constructParseErrorInfo(str,null,expected,error_rule_depth>=0);// append to the old one? +if(recoveringErrorInfo){let esp=recoveringErrorInfo.info_stack_pointer;recoveringErrorInfo.symbol_stack[esp]=symbol;let 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;recoveringErrorInfo.info_stack_pointer=esp;}else{recoveringErrorInfo=this.shallowCopyErrorInfo(hash);recoveringErrorInfo.yyError=true;recoveringErrorInfo.errorRuleDepth=error_rule_depth;recoveringErrorInfo.recovering=recovering;}// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){hash.extra_error_attributes=args;}return this.parseError(str,hash,this.JisonParserError);};}// Does the shared state override the default `parseError` that already comes with this instance? +let args=Array.prototype.slice.call(arguments,1);if(args.length){hash.extra_error_attributes=args;}return this.parseError(str,hash,this.JisonParserError);};}// Does the shared state override the default `parseError` that already comes with this instance? if(typeof sharedState_yy.parseError==='function'){this.parseError=function parseErrorAlt(str,hash,ExceptionClass){if(!ExceptionClass){ExceptionClass=this.JisonParserError;}return sharedState_yy.parseError.call(this,str,hash,ExceptionClass);};}else{this.parseError=this.originalParseError;}// Does the shared state override the default `quoteName` that already comes with this instance? if(typeof sharedState_yy.quoteName==='function'){this.quoteName=function quoteNameAlt(id_str){return sharedState_yy.quoteName.call(this,id_str);};}else{this.quoteName=this.originalQuoteName;}// set up the cleanup function; make it an API so that external code can re-use this one in case of // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which @@ -2202,7 +2233,7 @@ if(typeof sharedState_yy.quoteName==='function'){this.quoteName=function quoteNa // // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! -this.cleanupAfterParse=function parser_cleanupAfterParse(resultValue,invoke_post_methods,do_not_nuke_errorinfos){var rv;if(invoke_post_methods){var hash;if(sharedState_yy.post_parse||this.post_parse){// create an error hash info instance: we re-use this API in a **non-error situation** +this.cleanupAfterParse=function parser_cleanupAfterParse(resultValue,invoke_post_methods,do_not_nuke_errorinfos){let rv;if(invoke_post_methods){let hash;if(sharedState_yy.post_parse||this.post_parse){// create an error hash info instance: we re-use this API in a **non-error situation** // as this one delivers all parser internals ready for access by userland code. hash=this.constructParseErrorInfo(null/* no error! */,null/* no exception! */,null,false);}if(sharedState_yy.post_parse){rv=sharedState_yy.post_parse.call(this,sharedState_yy,resultValue,hash);if(typeof rv!=='undefined')resultValue=rv;}if(this.post_parse){rv=this.post_parse.call(this,sharedState_yy,resultValue,hash);if(typeof rv!=='undefined')resultValue=rv;}// cleanup: if(hash&&hash.destroy){hash.destroy();}}if(this.__reentrant_call_depth>1)return resultValue;// do not (yet) kill the sharedState when this is a reentrant run. @@ -2214,7 +2245,7 @@ stack.length=0;// fastest way to nuke an array without overly bothering the GC sstack.length=0;lstack.length=0;vstack.length=0;sp=0;// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;for(var i=this.__error_recovery_infos.length-1;i>=0;i--){var el=this.__error_recovery_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_recovery_infos.length=0;// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array, +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;for(let i=this.__error_recovery_infos.length-1;i>=0;i--){let el=this.__error_recovery_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_recovery_infos.length=0;// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array, // hence has been destroyed already: no need to do that *twice*. if(recoveringErrorInfo){recoveringErrorInfo=undefined;}}return resultValue;};// merge yylloc info into a new yylloc instance. // @@ -2228,32 +2259,38 @@ if(recoveringErrorInfo){recoveringErrorInfo=undefined;}}return resultValue;};// // yylloc info. // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. -this.yyMergeLocationInfo=function parser_yyMergeLocationInfo(first_index,last_index,first_yylloc,last_yylloc,dont_look_back){var i1=first_index|0,i2=last_index|0;var l1=first_yylloc,l2=last_yylloc;var rv;// rules: +this.yyMergeLocationInfo=function parser_yyMergeLocationInfo(first_index,last_index,first_yylloc,last_yylloc,dont_look_back){let i1=first_index|0;let i2=last_index|0;let l1=first_yylloc;let l2=last_yylloc;let rv;// rules: // - first/last yylloc entries override first/last indexes -if(!l1){if(first_index!=null){for(var i=i1;i<=i2;i++){l1=lstack[i];if(l1){break;}}}}if(!l2){if(last_index!=null){for(var i=i2;i>=i1;i--){l2=lstack[i];if(l2){break;}}}}// - detect if an epsilon rule is being processed and act accordingly: +if(!l1){if(first_index!=null){for(let i=i1;i<=i2;i++){l1=lstack[i];if(l1){break;}}}}if(!l2){if(last_index!=null){for(let i=i2;i>=i1;i--){l2=lstack[i];if(l2){break;}}}}// - detect if an epsilon rule is being processed and act accordingly: if(!l1&&first_index==null){// epsilon rule span merger. With optional look-ahead in l2. -if(!dont_look_back){for(var i=(i1||sp)-1;i>=0;i--){l1=lstack[i];if(l1){break;}}}if(!l1){if(!l2){// when we still don't have any valid yylloc info, we're looking at an epsilon rule +if(!dont_look_back){for(let i=(i1||sp)-1;i>=0;i--){l1=lstack[i];if(l1){break;}}}if(!l1){if(!l2){// when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: -return undefined;}else{// shallow-copy L2: after all, we MAY be looking +return null;}// shallow-copy L2: after all, we MAY be looking // at unconventional yylloc info objects... -rv=this.copy_yylloc(l2);return rv;}}else{// shallow-copy L1, then adjust first col/row 1 column past the end. +rv=this.copy_yylloc(l2);return rv;}// shallow-copy L1, then adjust first col/row 1 column past the end. rv=this.copy_yylloc(l1);rv.first_line=rv.last_line;rv.first_column=rv.last_column;rv.range[0]=rv.range[1];if(l2){// shallow-mixin L2, then adjust last col/row accordingly. -shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;}}if(!l1){l1=l2;l2=null;}if(!l1){return undefined;}// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking +shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;}if(!l1){l1=l2;l2=null;}if(!l1){return null;}// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... rv=this.copy_yylloc(l1);if(l2){shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;};// NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! -this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){var pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,loc:this.copy_yylloc(lexer.yylloc),expected:expected,recoverable:recoverable,state:state,action:action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,location_stack:lstack,stack_pointer:sp,yy:sharedState_yy,lexer:lexer,parser:this,// and make sure the error info doesn't stay due to potential +this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){const pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,loc:this.copy_yylloc(lexer.yylloc),expected,recoverable,state,action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,location_stack:lstack,stack_pointer:sp,yy:sharedState_yy,lexer,parser:this,// and make sure the error info doesn't stay due to potential // ref cycle via userland code manipulations. // These would otherwise all be memory leak opportunities! // // Note that only array and object references are nuked as those // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. -destroy:function destructParseErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +destroy:function destructParseErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// info.value = null; +// info.value_stack = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;};// clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. -this.shallowCopyErrorInfo=function parser_shallowCopyErrorInfo(p){var rv=shallow_copy(p);// remove the large parts which can only cause cyclic references +this.shallowCopyErrorInfo=function parser_shallowCopyErrorInfo(p){let rv=shallow_copy(p);// remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. delete rv.sharedState_yy;delete rv.parser;delete rv.lexer;// lexer.yytext MAY be a complex value object, rather than a simple string/value: rv.value=this.copy_yytext(rv.value);// yylloc info: @@ -2305,15 +2342,15 @@ rv.value_stack=rv.value_stack.map(this.copy_yytext);// and we don't bother with // - root_failure_pointer: // copy of the `stack_pointer`... // -for(var i=rv.stack_pointer;rv.state_stack[i]!=null;i++){// empty -}rv.base_pointer=i;rv.info_stack_pointer=i;rv.root_failure_pointer=rv.stack_pointer;// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! -this.__error_recovery_infos.push(rv);return rv;};function getNonTerminalFromCode(symbol){var tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){var token=lexer.lex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){var token=lexer.fastLex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}var lex=stdLex;var state,action,r,t;var yyval={$:true,_$:undefined,yy:sharedState_yy};var p;var yyrulelen;var this_production;var newState;var retval=false;// Return the rule stack depth where the nearest error rule can be found. +{let i;for(i=rv.stack_pointer;rv.state_stack[i]!=null;i++){// empty +}rv.base_pointer=i;rv.info_stack_pointer=i;}rv.root_failure_pointer=rv.stack_pointer;// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +this.__error_recovery_infos.push(rv);return rv;};function getNonTerminalFromCode(symbol){let tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){let token=lexer.lex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){let token=lexer.fastLex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}let lex=stdLex;let state,action,r,t;let yyval={$:true,_$:undefined,yy:sharedState_yy};let p;let yyrulelen;let this_production;let newState;let retval=false;// Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. -function locateNearestErrorRecoveryRule(state){var stack_probe=sp-1;var depth=0;// try to recover from error +function locateNearestErrorRecoveryRule(state){let stack_probe=sp-1;let depth=0;// try to recover from error while(stack_probe>=0){// check for error recovery rule in this state -var t=table[state]&&table[state][TERROR]||NO_ACTION;if(t[0]){// We need to make sure we're not cycling forever: +const t=table[state]&&table[state][TERROR]||NO_ACTION;if(t[0]){// We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must // prevent the core from running forever, // e.g. when parent rules are still expecting certain input to @@ -2334,7 +2371,7 @@ state=sstack[stack_probe];++depth;}return-1;// No suitable error recovery rule a // this initial `setInput()` call: hence we can now check and decide // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: -if(typeof lexer.canIUse==='function'){var lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}yyloc=this.copy_yylloc(lexer.yylloc);lstack[sp]=yyloc;vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack +if(typeof lexer.canIUse==='function'){let lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}yyloc=this.copy_yylloc(lexer.yylloc);lstack[sp]=yyloc;vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack state=newState;// sstack[sp - 1]; // use default actions if available if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}else{// The single `==` condition below covers both these `===` comparisons in a single @@ -2344,7 +2381,7 @@ if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}els if(!symbol){symbol=lex();}// read action for current state and first input t=table[state]&&table[state][symbol]||NO_ACTION;newState=t[1];action=t[0];// handle parse error if(!action){// first see if there's any chance at hitting an error recovery rule: -var error_rule_depth=locateNearestErrorRecoveryRule(state);var errStr=null;var errSymbolDescr=this.describeSymbol(symbol)||symbol;var expected=this.collect_expected_token_set(state);if(!recovering){// Report error +let error_rule_depth=locateNearestErrorRecoveryRule(state);let errStr=null;let errSymbolDescr=this.describeSymbol(symbol)||symbol;let expected=this.collect_expected_token_set(state);if(!recovering){// Report error errStr='Parse error';if(typeof lexer.yylineno==='number'){errStr+=' on line '+(lexer.yylineno+1);}if(typeof lexer.showPosition==='function'){errStr+=':\n'+lexer.showPosition(79-10,10)+'\n';}else{errStr+=': ';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}p=this.constructParseErrorInfo(errStr,null,expected,error_rule_depth>=0);// DO NOT cleanup the old one before we start the new error info track: // the old one will *linger* on the error stack and stay alive until we // invoke the parser's cleanup API! @@ -2352,20 +2389,20 @@ recoveringErrorInfo=this.shallowCopyErrorInfo(p);r=this.parseError(p.errStr,p,th // the `recoverable` flag without properly checking first: // we always terminate the parse when there's no recovery rule available anyhow! if(!p.recoverable||error_rule_depth<0){break;}else{// TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process... -}}var esp=recoveringErrorInfo.info_stack_pointer;// just recovered from another error +}}let esp=recoveringErrorInfo.info_stack_pointer;// just recovered from another error if(recovering===ERROR_RECOVERY_TOKEN_DISCARD_COUNT&&error_rule_depth>=0){// Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc=this.copy_yylloc(lexer.yylloc);// SHIFT current lookahead and grab another recoveringErrorInfo.symbol_stack[esp]=symbol;recoveringErrorInfo.location_stack[esp]=yyloc;recoveringErrorInfo.state_stack[esp]=newState;// push state ++esp;preErrorSymbol=0;symbol=lex();}// try to recover from error -if(error_rule_depth<0){ASSERT(recovering>0,"line 897");recoveringErrorInfo.info_stack_pointer=esp;// barf a fatal hairball when we're out of look-ahead symbols and none hit a match +if(error_rule_depth<0){ASSERT(recovering>0,'Line 1048');recoveringErrorInfo.info_stack_pointer=esp;// barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: -var po=this.__error_infos[this.__error_infos.length-1];// Report error +let po=this.__error_infos[this.__error_infos.length-1];// Report error if(typeof lexer.yylineno==='number'){errStr='Parsing halted on line '+(lexer.yylineno+1)+' while starting to recover from another error';}else{errStr='Parsing halted while starting to recover from another error';}if(po){errStr+=' -- previous error which resulted in this fatal result: '+po.errStr;}else{errStr+=': ';}if(typeof lexer.showPosition==='function'){errStr+='\n'+lexer.showPosition(79-10,10)+'\n';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}p=this.constructParseErrorInfo(errStr,null,expected,false);if(po){p.extra_error_attributes=po;}r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}preErrorSymbol=symbol===TERROR?0:symbol;// save the lookahead token symbol=TERROR;// insert generic error symbol as new lookahead const EXTRA_STACK_SAMPLE_DEPTH=3;// REDUCE/COMBINE the pushed terms/tokens to a new ERROR token: -recoveringErrorInfo.symbol_stack[esp]=preErrorSymbol;if(errStr){recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,errStr:errStr,errorSymbolDescr:errSymbolDescr,expectedStr:expected,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}else{recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}recoveringErrorInfo.location_stack[esp]=this.copy_yylloc(lexer.yylloc);recoveringErrorInfo.state_stack[esp]=newState||NO_ACTION[1];++esp;recoveringErrorInfo.info_stack_pointer=esp;yyval.$=recoveringErrorInfo;yyval._$=undefined;yyrulelen=error_rule_depth;r=this.performAction.call(yyval,yyloc,NO_ACTION[1],sp-1,vstack,lstack);if(typeof r!=='undefined'){retval=r;break;}// pop off stack +recoveringErrorInfo.symbol_stack[esp]=preErrorSymbol;if(errStr){recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,errStr,errSymbolDescr,expectedStr:expected,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}else{recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}recoveringErrorInfo.location_stack[esp]=this.copy_yylloc(lexer.yylloc);recoveringErrorInfo.state_stack[esp]=newState||NO_ACTION[1];++esp;recoveringErrorInfo.info_stack_pointer=esp;yyval.$=recoveringErrorInfo;yyval._$=undefined;yyrulelen=error_rule_depth;let combineState=NO_ACTION[1];r=this.performAction.call(yyval,yyloc,combineState,sp-1,vstack,lstack);if(typeof r!=='undefined'){retval=r;break;}// pop off stack sp-=yyrulelen;// and move the top entries + discarded part of the parse stacks onto the error info stack: -for(var idx=sp-EXTRA_STACK_SAMPLE_DEPTH,top=idx+yyrulelen;idx0){recovering--;}}else{// error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: -ASSERT(recovering>0,"line 1163");symbol=preErrorSymbol;preErrorSymbol=0;// read action for current state and first input +ASSERT(recovering>0,'Line 1352');symbol=preErrorSymbol;preErrorSymbol=0;// read action for current state and first input t=table[newState]&&table[newState][symbol]||NO_ACTION;if(!t[0]||symbol===TERROR){// forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where // (simple) stuff might have been missing before the token which caused the error we're // recovering from now... @@ -2456,17 +2493,17 @@ symbol=0;}}// once we have pushed the special ERROR token value, // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! -ASSERT(preErrorSymbol===0,"line 1194");if(recovering===0){break;}continue;// reduce: +ASSERT(preErrorSymbol===0,'Line 1383');if(recovering===0){break;}continue;// reduce: case 2:this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){// signal end of error recovery loop AND end of outer parse loop +yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){// signal end of error recovery loop AND end of outer parse loop action=3;retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}sp=-2;// magic number: signal outer "fast parse loop" ACCEPT state that we already have a properly set up `retval` parser return value. break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;lstack[sp]=yyval._$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -2494,26 +2531,26 @@ break;}// should we also break out of the regular/outer parse loop, // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? -ASSERT(action!==2,"line 1272");if(!action||action===1){continue;}}}switch(action){// catch misc. parse failures: +ASSERT(action!==2,'Line 1509');if(!action||action===1){continue;}}}switch(action){// catch misc. parse failures: default:// this shouldn't happen, unless resolve defaults are off if(action instanceof Array){p=this.constructParseErrorInfo('Parse Error: multiple actions possible at state: '+state+', token: '+symbol,null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}// Another case of better safe than sorry: in case state transitions come out of another error recovery process // or a buggy LUT (LookUp Table): p=this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.',null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;// shift: case 1:stack[sp]=symbol;vstack[sp]=lexer.yytext;lstack[sp]=this.copy_yylloc(lexer.yylloc);sstack[sp]=newState;// push state -if(typeof Jison!=='undefined'&&Jison.parserDebugger){var tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;ASSERT(preErrorSymbol===0,"line 1352");// normal execution / no error -ASSERT(recovering===0,"line 1353");// normal execution / no error +if(typeof Jison!=='undefined'&&Jison.parserDebugger){let tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;ASSERT(preErrorSymbol===0,'Line 1619');// normal execution / no error +ASSERT(recovering===0,'Line 1620');// normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc=this.copy_yylloc(lexer.yylloc);continue;// reduce: -case 2:ASSERT(preErrorSymbol===0,"line 1364");// normal execution / no error -ASSERT(recovering===0,"line 1365");// normal execution / no error +case 2:ASSERT(preErrorSymbol===0,'Line 1631');// normal execution / no error +ASSERT(recovering===0,'Line 1632');// normal execution / no error this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack +yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;lstack[sp]=yyval._$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:if(sp!==-2){retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -2762,8 +2799,8 @@ return retval;},yyError:1};parser$2.originalParseError=parser$2.parseError;parse * @public * @constructor * @nocollapse - */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 -Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';var lexer={// Code Generator Information Report + */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){const ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 +Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';const lexer={// Code Generator Information Report // --------------------------------- // // Options: @@ -2832,7 +2869,7 @@ CRLF_Re:/\r\n?|\n/,/** * @this {RegExpLexer} */constructLexErrorInfo:function lexer_constructLexErrorInfo(msg,recoverable,show_input_position){msg=''+msg;// heuristic to determine if the error message already contains a (partial) source code dump // as produced by either `showPosition()` or `prettyPrintRange()`: -if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){var pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){var pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */var pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... +if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){const pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){const pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */const pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:this,/** * and make sure the error info doesn't stay due to potential * ref cycle via userland code manipulations. @@ -2844,7 +2881,11 @@ text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:t * * @public * @this {LexErrorInfo} - */destroy:function destructLexErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! + */destroy:function destructLexErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;},/** * handler which is invoked when a lexer error occurs. * @@ -2855,8 +2896,8 @@ this.__error_infos.push(pei);return pei;},/** * * @public * @this {RegExpLexer} - */yyerror:function yyError(str/*, ...args */){var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** + */yyerror:function yyError(str/*, ...args */){let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: +let args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** * final cleanup function for when we have completed lexing the input; * make it an API so that external code can use this one once userland * code has decided it's time to destroy any lingering lexer error @@ -2871,13 +2912,13 @@ var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_a this.setInput('',{});// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** * clear the lexer token context; intended for internal use only * * @public * @this {RegExpLexer} */clear:function lexer_clear(){this.yytext='';this.yyleng=0;this.match='';// - DO NOT reset `this.matched` -this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** +this.matches=false;this._more=false;this._backtrack=false;const col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** * resets the lexer, sets new input * * @public @@ -2886,10 +2927,10 @@ this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.la // including expansion work to be done to go from a loaded // lexer to a usable lexer: if(!this.__decompressed){// step 1: decompress the regex list: -var rules=this.rules;for(var i=0,len=rules.length;i> tokens and perform user action code for a <> match, but only does so *once*) -return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}var ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). +return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}let ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. -var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;var ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** +let slice_len=1;let lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;const ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** * unshifts one char (or an entire string) into the input * * @public * @this {RegExpLexer} - */unput:function lexer_unput(ch){var len=ch.length;var lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** + */unput:function lexer_unput(ch){let len=ch.length;let lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** // The `offset` value MAY be negative if you `unput()` more text than you have already lexed. // This type of behaviour is generally observed for one kind of 'lexer/parser hack' // where custom token-illiciting characters are pushed in front of the input stream to help @@ -2959,11 +3000,11 @@ var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lin if(-this.offset>this.base_position){this.base_position=-this.offset;}this.match=this.match.substr(0,this.match.length-len);this.matched=this.matched.substr(0,this.matched.length-len);if(lines.length>1){this.yylineno-=lines.length-1;this.yylloc.last_line=this.yylineno+1;// Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. -var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** +let pre=this.match;let pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -2973,8 +3014,8 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */lookAhead:function lexer_lookAhead(){return this._input||'';},/** @@ -2991,7 +3032,7 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 */reject:function lexer_reject(){if(this.options.backtrack_lexer){this._backtrack=true;}else{// when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. -var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** +let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** * retain first n characters of the match * * @public @@ -3013,17 +3054,17 @@ var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yyl * * @public * @this {RegExpLexer} - */pastInput:function lexer_pastInput(maxSize,maxLines){var past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0)maxSize=Infinity;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=Infinity;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substr` anticipation: treat \r\n as a single character and take a little + */pastInput:function lexer_pastInput(maxSize,maxLines){let past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0){maxSize=Infinity;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=Infinity;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past=past.substr(-maxSize*2-2);// now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: -var a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, +let a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, // do add an ellipsis prefix... if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -3049,18 +3090,18 @@ if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} - */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){var next=this.match;var source=this._input||'';if(maxSize<0)maxSize=next.length+source.length;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=maxSize;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substring` anticipation: treat \r\n as a single character and take a little + */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){let next=this.match;let source=this._input||'';if(maxSize<0){maxSize=next.length+source.length;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=maxSize;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: if(next.lengthmaxSize){next=next.substring(0,maxSize)+'...';}return next;},/** @@ -3069,7 +3110,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){var pre=this.pastInput(maxPrefix).replace(/\s/g,' ');var c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** + */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){const pre=this.pastInput(maxPrefix).replace(/\s/g,' ');let c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** * return an YYLLOC info object derived off the given context (actual, preceding, following, current). * Use this method when the given `actual` location is not guaranteed to exist (i.e. when * it MAY be NULL) and you MUST have a valid location info object anyway: @@ -3085,7 +3126,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */deriveLocationInfo:function lexer_deriveYYLLOC(actual,preceding,following,current){var loc={first_line:1,first_column:0,last_line:1,last_column:0,range:[0,0]};if(actual){loc.first_line=actual.first_line|0;loc.last_line=actual.last_line|0;loc.first_column=actual.first_column|0;loc.last_column=actual.last_column|0;if(actual.range){loc.range[0]=actual.range[0]|0;loc.range[1]=actual.range[1]|0;}}if(loc.first_line<=0||loc.last_line=loc.first_line)){loc.last_line=current.last_line|0;loc.last_column=current.last_column|0;if(current.range){loc.range[1]=current.range[1]|0;}}}// sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter // or plan D heuristics to produce a 'sensible' last_line value: @@ -3134,9 +3175,9 @@ loc.range[1]=loc.range[0];}if(loc.first_column<0){loc.first_column=0;}if(loc.las * * @public * @this {RegExpLexer} - */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;var input=this.matched+(this._input||'');var lines=input.split('\n');var l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);var l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);var lineno_display_width=1+Math.log10(l1|1)|0;var ws_prefix=new Array(lineno_display_width).join(' ');var nonempty_line_indexes=[[],[],[]];var rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){var lno=index+l0;var lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);var rv=lno_pfx+': '+line;var errpfx=new Array(lineno_display_width+1).join('^');var offset=2+1;var len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it + */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;let input=this.matched+(this._input||'');let lines=input.split('\n');let l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);let l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);let lineno_display_width=1+Math.log10(l1|1)|0;let ws_prefix=new Array(lineno_display_width).join(' ');let nonempty_line_indexes=[[],[],[]];let rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){let lno=index+l0;let lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);let rv=lno_pfx+': '+line;let errpfx=new Array(lineno_display_width+1).join('^');let offset=2+1;let len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: -for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){var clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;var clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;var intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** +for(let i=0;i<=2;i++){let line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){let clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;let clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;let intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** * helper function, used to produce a human readable description as a string, given * the input `yylloc` location object. * @@ -3145,7 +3186,7 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){var l1=yylloc.first_line;var l2=yylloc.last_line;var c1=yylloc.first_column;var c2=yylloc.last_column;var dl=l2-l1;var dc=c2-c1;var rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){var r1=yylloc.range[0];var r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** + */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){let l1=yylloc.first_line;let l2=yylloc.last_line;let c1=yylloc.first_column;let c2=yylloc.last_column;let dl=l2-l1;let dc=c2-c1;let rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){let r1=yylloc.range[0];let r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** * test the lexed token: return FALSE when not a match, otherwise return token. * * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]` @@ -3162,18 +3203,18 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */test_match:function lexer_test_match(match,indexed_rule){var token,lines,backup,match_str,match_str_len;if(this.options.backtrack_lexer){// save context + */test_match:function lexer_test_match(match,indexed_rule){let backup;if(this.options.backtrack_lexer){// save context backup={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.yylloc.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column,range:this.yylloc.range.slice()},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,//_signaled_error_token: this._signaled_error_token, -yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}match_str=match[0];match_str_len=match_str.length;lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: +yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}let match_str=match[0];let match_str_len=match_str.length;let lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: // those rules will already have moved this `offset` forward matching their match lengths, // hence we must only add our own match length now: this.offset+=match_str_len;this._more=false;this._backtrack=false;this._input=this._input.slice(match_str_len);// calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} -token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: +let token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; if(this.done&&this._input){this.done=false;}if(token){return token;}else if(this._backtrack){// recover context -for(var k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. +for(let k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. }else if(this._signaled_error_token){// produce one 'error' token as `.parseError()` in `reject()` // did not guarantee a failure signal by throwing an exception! token=this._signaled_error_token;this._signaled_error_token=false;return token;}return false;},/** @@ -3181,19 +3222,19 @@ token=this._signaled_error_token;this._signaled_error_token=false;return token;} * * @public * @this {RegExpLexer} - */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}var token,match,tempMatch,index;if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}var spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. + */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}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();// Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 -if(!spec||!spec.rules){var lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! -return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}var rule_ids=spec.rules;var regexes=spec.__rule_regexes;var len=spec.__rule_count;// Note: the arrays are 1-based, while `len` itself is a valid index, +if(!spec||!spec.rules){let lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! +return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}{let rule_ids=spec.rules;let regexes=spec.__rule_regexes;let len=spec.__rule_count;let match;let index;// 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(var i=1;i<=len;i++){tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. +for(let i=1;i<=len;i++){let tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){let token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. }else{// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}}else if(!this.options.flex){break;}}}if(match){token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}if(!this._input){this.done=true;this.clear();return this.EOF;}else{var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);var pendingInput=this._input;var activeCondition=this.topState();var conditionStackDepth=this.conditionStack.length;token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us +return false;}}else if(!this.options.flex){break;}}}if(match){let token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) +return false;}}if(!this._input){this.done=true;this.clear();return this.EOF;}{let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);let pendingInput=this._input;let activeCondition=this.topState();let conditionStackDepth=this.conditionStack.length;let token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: if(!this.matches&&// and make sure the input has been modified/consumed ... @@ -3204,7 +3245,7 @@ activeCondition===this.topState()&&conditionStackDepth===this.conditionStack.len * * @public * @this {RegExpLexer} - */lex:function lexer_lex(){var r;//this._clear_state = 0; + */lex:function lexer_lex(){let r;//this._clear_state = 0; if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}// allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer: if(typeof this.pre_lex==='function'){r=this.pre_lex.call(this,0);}if(typeof this.options.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.pre_lex.call(this,r)||r;}if(this.yy&&typeof this.yy.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) @@ -3212,50 +3253,50 @@ r=this.yy.pre_lex.call(this,r)||r;}while(!r){r=this.next();}if(this.yy&&typeof t r=this.yy.post_lex.call(this,r)||r;}if(typeof this.options.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.post_lex.call(this,r)||r;}if(typeof this.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.post_lex.call(this,r)||r;}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return next match that has a token. Identical to the `lex()` API but does not invoke any of the * `pre_lex()` nor any of the `post_lex()` callbacks. * * @public * @this {RegExpLexer} - */fastLex:function lexer_fastLex(){var r;//this._clear_state = 0; + */fastLex:function lexer_fastLex(){let r;//this._clear_state = 0; while(!r){r=this.next();}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return info about the lexer state that can help a parser or other lexer API user to use the * most efficient means available. This API is provided to aid run-time performance for larger @@ -3263,7 +3304,7 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */canIUse:function lexer_canIUse(){var rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** + */canIUse:function lexer_canIUse(){const rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** * backwards compatible alias for `pushState()`; * the latter is symmetrical with `popState()` and we advise to use * those APIs in any modern lexer code, rather than `begin()`. @@ -3282,20 +3323,20 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */popState:function lexer_popState(){var n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}else{return this.conditionStack[0];}},/** + */popState:function lexer_popState(){const n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}return this.conditionStack[0];},/** * return the currently active lexer condition state; when an index * argument is provided it produces the N-th previous condition state, * if available * * @public * @this {RegExpLexer} - */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}else{return'INITIAL';}},/** + */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}return'INITIAL';},/** * (internal) determine the lexer rule set which is active for the * currently active lexer condition state * * @public * @this {RegExpLexer} - */_currentRules:function lexer__currentRules(){var n=this.conditionStack.length-1;var state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions['INITIAL'];},/** + */_currentRules:function lexer__currentRules(){const n=this.conditionStack.length-1;let state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions.INITIAL;},/** * return the number of states currently on the stack * * @public @@ -3372,18 +3413,18 @@ if(v&&!isNaN(v)){var rv=+v;if(isFinite(rv)){return rv;}}return v;}parser$2.warn= // 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. -function JisonParserError$2(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonParserError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8/Chrome engine +function JisonParserError$2(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonParserError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){let ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8/Chrome engine Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonParserError$2.prototype,Error.prototype);}else{JisonParserError$2.prototype=Object.create(Error.prototype);}JisonParserError$2.prototype.constructor=JisonParserError$2;JisonParserError$2.prototype.name='JisonParserError';// helper: reconstruct the productions[] table -function bp$2(s){var rv=[];var p=s.pop;var r=s.rule;for(var i=0,l=p.length;i1){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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) +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 delimited set of lexer start conditions';break;case 37:/*! Production:: start_productions_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -yy.__options_flags__=0;yy.__options_category_description__='the lexer rules definition section';break;case 38:/*! Production:: start_epilogue_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -yy.__options_flags__=0;yy.__options_category_description__='the lexer epilogue section';break;case 39:/*! Production:: rules : rules scoped_rules_collective */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1].concat(yyvstack[yysp]);break;case 40:/*! Production:: rules : rules rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1].concat([yyvstack[yysp]]);break;case 41:/*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 30:/*! Production:: option_keyword : OPTIONS */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__=yyvstack[yysp];break;case 31:/*! Production:: import_keyword : IMPORT */case 33:/*! Production:: include_keyword : INCLUDE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS;yy.__options_category_description__=yyvstack[yysp];break;case 32:/*! Production:: init_code_keyword : CODE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS|OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS;yy.__options_category_description__=yyvstack[yysp];break;case 34:/*! Production:: start_inclusive_keyword : START_INC */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__='the inclusive lexer start conditions set (%s)';break;case 35:/*! Production:: start_exclusive_keyword : START_EXC */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__='the exclusive lexer start conditions set (%x)';break;case 36:/*! Production:: start_conditions_marker : "<" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES|OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME;yy.__options_category_description__='the <...> delimited set of lexer start conditions';break;case 37:/*! Production:: start_productions_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=0;yy.__options_category_description__='the lexer rules definition section';break;case 38:/*! Production:: start_epilogue_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=0;yy.__options_category_description__='the lexer epilogue section';break;case 39:/*! Production:: rules : rules scoped_rules_collective */ // 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].concat(yyvstack[yysp]);break;case 40:/*! Production:: rules : rules rule */ // 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].concat([yyvstack[yysp]]);break;case 41:/*! Production:: rules : rules 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]);if(srcCode){var rv=checkActionBlock$2(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$2` The '%{...%}' lexer setup action code section does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-2])} - `);}yy.actionInclude.push(srcCode);}this.$=yyvstack[yysp-3];break;case 42:/*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);}yy.actionInclude.push(srcCode);}this.$=yyvstack[yysp-3];break;case 42:/*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. -this.$=yyvstack[yysp-1];break;case 43:/*! Production:: rules : rules ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) +this.$=yyvstack[yysp-1];break;case 43:/*! Production:: rules : rules ACTION_START_AT_SOL 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,-,-) 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. @@ -3827,8 +3868,8 @@ var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or simila Technical error report: ${yyvstack[yysp].errStr} - `);this.$=yyvstack[yysp-2];break;case 44:/*! Production:: rules : rules ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);this.$=yyvstack[yysp-2];break;case 44:/*! Production:: rules : rules 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,-,-) 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: @@ -3856,8 +3897,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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 the top section of the lexer spec file, above the first '%%' @@ -3866,14 +3907,14 @@ yyparser.yyError(rmCommonWS$2` Erroneous code: ${yylexer.prettyPrintRange(yylstack[yysp])} - `);this.$=yyvstack[yysp-1];break;case 51:/*! Production:: rules : %epsilon */case 58:/*! Production:: rule_block : %epsilon */ // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) -this.$=[];break;case 52:/*! Production:: scoped_rules_collective : start_conditions rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -if(yyvstack[yysp-1]){yyvstack[yysp].unshift(yyvstack[yysp-1]);}this.$=[yyvstack[yysp]];break;case 53:/*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) -if(yyvstack[yysp-3]){yyvstack[yysp-1].forEach(function(d){d.unshift(yyvstack[yysp-3]);});}this.$=yyvstack[yysp-1];break;case 54:/*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp-3];this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + `);this.$=yyvstack[yysp-1];break;case 51:/*! Production:: rules : %epsilon */case 58:/*! Production:: rule_block : %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 52:/*! Production:: scoped_rules_collective : start_conditions rule */ // 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,-,-) +if(yyvstack[yysp-1]){yyvstack[yysp].unshift(yyvstack[yysp-1]);}this.$=[yyvstack[yysp]];break;case 53:/*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ // 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,-,-) +if(yyvstack[yysp-3]){yyvstack[yysp-1].forEach(function(d){d.unshift(yyvstack[yysp-3]);});}this.$=yyvstack[yysp-1];break;case 54:/*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): +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$2` Seems you made a mistake while specifying one of the lexer rules inside the start condition @@ -3885,8 +3926,8 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp-1].errStr} - `);break;case 55:/*! Production:: scoped_rules_collective : start_conditions "{" error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 55:/*! Production:: scoped_rules_collective : start_conditions "{" 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,-,-) yyparser.yyError(rmCommonWS$2` Seems you did not correctly bracket a lexer rules set inside the start condition @@ -3898,8 +3939,8 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 56:/*! Production:: scoped_rules_collective : start_conditions error "}" */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 56:/*! Production:: scoped_rules_collective : start_conditions 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,-,-) yyparser.yyError(rmCommonWS$2` Seems you did not correctly bracket a lexer rules set inside the start condition @@ -3911,17 +3952,17 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp-1].errStr} - `);break;case 57:/*! Production:: rule_block : rule_block rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 57:/*! Production:: rule_block : rule_block rule */ // 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.$.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` 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 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 // will uncover any illegal action code following the arrow operator, e.g. // multiple statements separated by semicolon. @@ -3942,8 +3983,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 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.: @@ -3958,8 +3999,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 63:/*! Production:: rule : regex ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);break;case 63:/*! Production:: rule : regex 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,-,-) // TODO: REWRITE this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$2` A lexer rule regex action code must be properly terminated and must contain a JavaScript statement block (or anything that does parse as such), e.g.: @@ -3976,8 +4017,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 64:/*! Production:: rule : regex ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);break;case 64:/*! Production:: rule : regex ACTION_START_AT_SOL 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,-,-) // TODO: REWRITE this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$2` A lexer rule regex action code must be properly terminated and must contain a JavaScript statement block (or anything that does parse as such), e.g.: @@ -4013,8 +4054,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 65:/*! Production:: rule : regex error */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);break;case 65:/*! Production:: rule : regex 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,-,-) this.$=[yyvstack[yysp-1],yyvstack[yysp]];yyparser.yyError(rmCommonWS$2` Lexer rule regex action code declaration error? @@ -4023,33 +4064,33 @@ this.$=[yyvstack[yysp-1],yyvstack[yysp]];yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 66:/*! Production:: action : action ACTION_BODY */case 83:/*! Production:: regex_concat : regex_concat regex_base */case 95:/*! Production:: regex_base : regex_base range_regex */case 106:/*! Production:: regex_set : regex_set regex_set_atom */case 127:/*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+yyvstack[yysp];break;case 67:/*! Production:: action : action include_macro_code */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'\n\n'+yyvstack[yysp]+'\n\n';break;case 68:/*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 66:/*! Production:: action : action ACTION_BODY */case 83:/*! Production:: regex_concat : regex_concat regex_base */case 95:/*! Production:: regex_base : regex_base range_regex */case 106:/*! Production:: regex_set : regex_set regex_set_atom */case 127:/*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ // 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]+yyvstack[yysp];break;case 67:/*! Production:: action : action 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]+'\n\n'+yyvstack[yysp]+'\n\n';break;case 68:/*! Production:: action : action INCLUDE_PLACEMENT_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` You may place the '%include' instruction only at the start/front of a line. Its use is not permitted at this position: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 69:/*! Production:: action : action BRACKET_MISSING */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 69:/*! Production:: action : action BRACKET_MISSING */ // 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` Missing curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: '{ ... }'. Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 70:/*! Production:: action : action BRACKET_SURPLUS */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 70:/*! Production:: action : action BRACKET_SURPLUS */ // 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` Too many curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: '{ ... }'. Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 71:/*! Production:: action : action UNTERMINATED_STRING_ERROR */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 71:/*! Production:: action : action UNTERMINATED_STRING_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` Unterminated string constant in lexer rule action block. @@ -4058,10 +4099,10 @@ yyparser.yyError(rmCommonWS$2` Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 72:/*! Production:: action : %epsilon */case 77:/*! Production:: regex_list : %epsilon */ // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0,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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 72:/*! Production:: action : %epsilon */case 77:/*! Production:: regex_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 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 // accordingly: @@ -4082,8 +4123,8 @@ 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,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,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` Seems you did not correctly terminate the start condition set @@ -4095,8 +4136,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4135,22 +4176,22 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+'|'+yyvstack[yysp];break;case 79:/*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'|';break;case 80:/*! Production:: nonempty_regex_list : "|" regex_concat */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='|'+yyvstack[yysp];break;case 81:/*! Production:: nonempty_regex_list : "|" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='|';break;case 85:/*! Production:: regex_base : "(" regex_list ")" */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$='('+yyvstack[yysp-1]+')';break;case 86:/*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+')';break;case 87:/*! Production:: regex_base : "(" regex_list error */case 88:/*! Production:: regex_base : SPECIAL_GROUP regex_list error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) +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,-,-): +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,-,-) +this.$=yyvstack[yysp-2]+'|'+yyvstack[yysp];break;case 79:/*! Production:: nonempty_regex_list : nonempty_regex_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,-,-) +this.$=yyvstack[yysp-1]+'|';break;case 80:/*! Production:: nonempty_regex_list : "|" regex_concat */ // 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];break;case 81:/*! Production:: 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,-,-) +this.$='|';break;case 85:/*! Production:: regex_base : "(" regex_list ")" */ // 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-1]+')';break;case 86:/*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ // 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-1]+')';break;case 87:/*! Production:: regex_base : "(" regex_list error */case 88:/*! Production:: regex_base : SPECIAL_GROUP regex_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,-,-) yyparser.yyError(rmCommonWS$2` Seems you did not correctly bracket a lex rule regex part in '(...)' braces. @@ -4159,30 +4200,30 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 89:/*! Production:: regex_base : regex_base "+" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'+';break;case 90:/*! Production:: regex_base : regex_base "*" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'*';break;case 91:/*! Production:: regex_base : regex_base "?" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'?';break;case 92:/*! Production:: regex_base : "/" regex_base */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='(?='+yyvstack[yysp]+')';break;case 93:/*! Production:: regex_base : "/!" regex_base */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='(?!'+yyvstack[yysp]+')';break;case 94:/*! Production:: regex_base : name_expansion */case 96:/*! Production:: regex_base : any_group_regex */case 100:/*! Production:: regex_base : REGEX_SPECIAL_CHAR */case 101:/*! Production:: regex_base : literal_string */case 107:/*! Production:: regex_set : regex_set_atom */case 108:/*! Production:: regex_set_atom : REGEX_SET */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -break;case 97:/*! Production:: regex_base : "." */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='.';break;case 98:/*! Production:: regex_base : "^" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='^';break;case 99:/*! Production:: regex_base : "$" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='$';break;case 102:/*! Production:: regex_base : ESCAPED_CHAR */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp]));break;case 104:/*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+yyvstack[yysp];break;case 105:/*! Production:: any_group_regex : REGEX_SET_START regex_set error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 89:/*! Production:: regex_base : regex_base "+" */ // 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]+'+';break;case 90:/*! Production:: regex_base : regex_base "*" */ // 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]+'*';break;case 91:/*! Production:: regex_base : regex_base "?" */ // 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]+'?';break;case 92:/*! Production:: regex_base : "/" regex_base */ // 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]+')';break;case 93:/*! Production:: regex_base : "/!" regex_base */ // 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]+')';break;case 94:/*! Production:: regex_base : name_expansion */case 96:/*! Production:: regex_base : any_group_regex */case 100:/*! Production:: regex_base : REGEX_SPECIAL_CHAR */case 101:/*! Production:: regex_base : literal_string */case 107:/*! Production:: regex_set : regex_set_atom */case 108:/*! Production:: regex_set_atom : REGEX_SET */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +break;case 97:/*! Production:: regex_base : "." */ // 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.$='.';break;case 98:/*! Production:: regex_base : "^" */ // 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.$='^';break;case 99:/*! Production:: regex_base : "$" */ // 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.$='$';break;case 102:/*! Production:: regex_base : ESCAPED_CHAR */ // 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.$=encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp]));break;case 104:/*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_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,-,-) +this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+yyvstack[yysp];break;case 105:/*! Production:: any_group_regex : REGEX_SET_START regex_set 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,-,-) yyparser.yyError(rmCommonWS$2` Seems you did not correctly bracket a lex rule regex set in '[...]' brackets. @@ -4191,16 +4232,16 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 109:/*! Production:: regex_set_atom : name_expansion */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + `);break;case 109:/*! Production:: regex_set_atom : name_expansion */ // 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,-,-) if(XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g,''))&&yyvstack[yysp].toUpperCase()!==yyvstack[yysp]){// treat this as part of an XRegExp `\p{...}` Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) +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,-,-): +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,-,-): +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$2` You may only specify one name/argument in a ${yy.__options_category_description__} statement. @@ -4215,28 +4256,28 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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` You may only specify one name/argument in a ${yy.__options_category_description__} statement. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp]),yylstack[yysp-3])} - `);}this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 115:/*! Production:: option_list : option */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=[yyvstack[yysp]];break;case 116:/*! Production:: option : option_name */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=[yyvstack[yysp],true];break;case 117:/*! Production:: option : option_name "=" option_value */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);}this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 115:/*! Production:: option_list : option */ // 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 116:/*! Production:: option : 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,-,-) +this.$=[yyvstack[yysp],true];break;case 117:/*! Production:: option : option_name "=" option_value */ // 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_VALUE){yyparser.yyError(rmCommonWS$2` The entries in a ${yy.__options_category_description__} statement MUST NOT be assigned values, such as '${$option_name}=${$option_value}'. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp],yylstack[yysp-2]),yylstack[yysp-4])} - `);}this.$=[yyvstack[yysp-2],yyvstack[yysp]];break;case 118:/*! Production:: option : option_name "=" error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);}this.$=[yyvstack[yysp-2],yyvstack[yysp]];break;case 118:/*! Production:: option : option_name "=" 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$2` Internal error: option "${$option}" value assignment failure in a ${yy.__options_category_description__} statement. @@ -4246,8 +4287,8 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 119:/*! Production:: option : DUMMY3 error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);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` Expected a valid option name${with_value_msg} in a ${yy.__options_category_description__} statement. @@ -4256,8 +4297,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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: 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 @@ -4271,8 +4312,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. @@ -4282,21 +4323,21 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=parseValue$1(yyvstack[yysp]);break;case 124:/*! Production:: epilogue : start_epilogue_marker */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,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,-,-) +this.$=parseValue$1(yyvstack[yysp]);break;case 124:/*! Production:: epilogue : start_epilogue_marker */ // 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.$='';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` 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,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,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. @@ -4305,8 +4346,8 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 128:/*! Production:: epilogue_chunks : epilogue_chunks error */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);break;case 128:/*! Production:: epilogue_chunks : epilogue_chunks 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$2` Module code declaration error? @@ -4316,8 +4357,8 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);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` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -4326,8 +4367,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -4336,12 +4377,12 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,LU,LUbA): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA) +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`: path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$2` @@ -4368,8 +4409,8 @@ var fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});var 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,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,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. @@ -4379,14 +4420,14 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} `);break;}},table:bt$2({len:u$2([15,1,14,21,1,13,28,22,s$2,[9,3],13,1,9,13,c$2,[6,3],27,s$2,[31,5],1,44,4,1,13,6,25,24,25,23,23,17,17,s$2,[24,8],26,5,24,24,9,13,8,9,1,s$2,[9,5],13,9,13,c$2,[3,3],c$2,[13,3],2,1,26,26,9,26,c$2,[5,3],s$2,[26,4],7,24,4,5,8,c$2,[60,3],c$2,[59,3],s$2,[24,5],2,3,2,25,25,6,s$2,[4,3],13,7,8,4,8,13,13,s$2,[7,6],9,5,s$2,[13,3],9,1,13,9,26,26,6,1,5,9,5,5,26,17,c$2,[85,4],27,10,s$2,[24,7],4,s$2,[8,3],9,7,9,1,1,26,5,c$2,[30,3],23,27,26,9,27,9,27,9,27,1,16,7,1,13,13,5,26,15,26,s$2,[27,3],16,13]),symbol:u$2([1,2,19,22,s$2,[24,6,1],31,32,33,55,57,1,c$2,[16,13],58,c$2,[14,13],56,s$2,[59,4,1],64,65,67,c$2,[36,14],1,2,3,7,8,s$2,[13,4,1],c$2,[19,10],s$2,[40,6,1],49,50,69,2,c$2,[26,6],c$2,[16,8],75,s$2,[77,5,1],85,2,11,51,52,53,s$2,[86,4,1],c$2,[9,10],23,30,s$2,[35,5,1],73,c$2,[90,13],2,c$2,[32,9],c$2,[23,14],c$2,[63,17],c$2,[144,40],c$2,[27,5],11,c$2,[28,22],c$2,[75,3],c$2,[31,125],1,c$2,[182,25],c$2,[373,5],s$2,[66,5,2],c$2,[320,7],90,1,33,68,90,20,c$2,[276,14],7,20,22,25,34,c$2,[367,3],9,c$2,[68,4],c$2,[12,4],c$2,[62,8],c$2,[370,6],c$2,[25,19],c$2,[24,8],s$2,[10,7,1],c$2,[27,10],48,49,50,84,c$2,[49,8],c$2,[45,8],s$2,[76,6,1],c$2,[72,9],c$2,[23,15],c$2,[485,13],c$2,[17,21],c$2,[105,24],c$2,[24,189],s$2,[46,5,1],44,47,80,82,83,c$2,[79,48],11,17,21,c$2,[500,3],c$2,[729,18],17,21,25,c$2,[24,3],c$2,[8,3],18,c$2,[9,6],c$2,[10,10],c$2,[9,26],c$2,[76,22],c$2,[849,7],63,93,c$2,[796,15],c$2,[13,11],c$2,[57,22],c$2,[22,9],21,11,17,c$2,[95,4],c$2,[10,4],25,c$2,[670,27],c$2,[26,26],c$2,[981,10],c$2,[35,26],c$2,[88,52],c$2,[26,105],2,22,24,54,91,92,2,4,c$2,[1221,14],72,c$2,[1222,8],c$2,[465,3],c$2,[35,5],c$2,[1158,8],c$2,[8,4],c$2,[1307,14],c$2,[912,78],c$2,[760,117],9,2,7,9,c$2,[5,4],c$2,[152,47],84,2,44,46,47,80,83,c$2,[6,4],c$2,[4,8],c$2,[614,14],c$2,[602,6],c$2,[754,9],52,53,c$2,[12,9],c$2,[689,26],c$2,[592,7],c$2,[7,35],c$2,[1571,14],c$2,[82,26],c$2,[430,14],c$2,[688,8],2,c$2,[842,23],c$2,[580,56],92,c$2,[534,3],c$2,[7,3],c$2,[1765,11],c$2,[14,3],c$2,[5,6],c$2,[794,26],5,c$2,[630,14],71,5,c$2,[159,10],c$2,[9,17],s$2,[1,4,2],c$2,[72,24],c$2,[976,9],c$2,[628,48],c$2,[24,121],c$2,[560,4],c$2,[1290,10],c$2,[8,13],c$2,[205,9],c$2,[495,14],63,93,21,21,c$2,[388,31],c$2,[5,5],c$2,[1301,11],c$2,[14,3],c$2,[354,15],c$2,[984,8],c$2,[333,27],c$2,[100,26],c$2,[549,11],c$2,[62,25],c$2,[36,72],6,c$2,[1170,16],c$2,[53,7],21,c$2,[744,28],c$2,[621,29],c$2,[266,15],c$2,[745,28],c$2,[284,27],c$2,[27,52],c$2,[203,16],c$2,[182,13]]),type:u$2([s$2,[2,13],0,0,1,c$2,[16,14],c$2,[30,15],s$2,[0,6],s$2,[2,41],c$2,[42,16],c$2,[64,12],c$2,[9,18],c$2,[49,19],c$2,[32,16],c$2,[22,19],c$2,[145,45],s$2,[2,181],s$2,[0,18],c$2,[20,4],c$2,[62,45],c$2,[25,24],c$2,[441,40],c$2,[442,13],c$2,[23,31],c$2,[17,34],c$2,[416,210],c$2,[57,111],c$2,[76,42],c$2,[98,34],c$2,[57,22],c$2,[22,10],c$2,[165,66],c$2,[509,189],c$2,[756,25],c$2,[740,56],c$2,[912,70],c$2,[286,136],c$2,[25,29],c$2,[275,31],c$2,[240,14],c$2,[227,82],c$2,[1144,56],c$2,[53,22],c$2,[775,59],c$2,[58,15],c$2,[149,63],c$2,[1837,18],c$2,[81,35],c$2,[628,51],c$2,[1393,171],c$2,[197,47],c$2,[268,26],c$2,[272,64],c$2,[62,36],c$2,[36,72],s$2,[2,226]]),state:u$2([s$2,[1,5,1],13,15,16,8,9,6,s$2,[25,4,2],32,37,38,43,49,51,52,54,58,c$2,[4,3],60,63,c$2,[5,3],65,c$2,[4,3],67,c$2,[4,3],77,79,80,75,76,85,81,70,71,82,83,c$2,[38,6],69,81,87,90,c$2,[8,4],91,c$2,[4,3],95,97,98,c$2,[20,5],99,c$2,[7,6],100,c$2,[4,3],101,c$2,[4,3],105,102,103,108,52,54,c$2,[3,3],119,114,c$2,[8,6],c$2,[3,3],127,130,132,136,c$2,[66,7],143,c$2,[87,3],144,c$2,[67,9],95,95,105,151,152,52,54,153,155,c$2,[22,3],157,119,114,161,163,165,168,170,172,c$2,[49,3],c$2,[29,4],c$2,[67,5],119,114,182,c$2,[57,7],c$2,[12,4],119,114]),mode:u$2([s$2,[2,27],s$2,[1,13],c$2,[27,15],c$2,[53,38],c$2,[66,27],c$2,[46,12],c$2,[65,23],s$2,[2,197],c$2,[271,26],c$2,[340,23],c$2,[25,4],c$2,[27,6],c$2,[264,10],c$2,[20,20],c$2,[12,5],c$2,[66,18],c$2,[89,5],c$2,[102,14],s$2,[1,38],s$2,[2,218],c$2,[220,50],c$2,[274,30],c$2,[25,6],c$2,[85,37],c$2,[736,26],c$2,[52,52],c$2,[427,61],c$2,[54,34],c$2,[515,158],c$2,[696,29],c$2,[1120,25],c$2,[845,62],c$2,[689,122],c$2,[1055,8],c$2,[151,24],c$2,[24,20],c$2,[539,29],c$2,[29,12],c$2,[1006,79],c$2,[660,49],c$2,[45,8],c$2,[793,47],c$2,[131,31],c$2,[439,50],c$2,[44,16],c$2,[125,9],c$2,[161,22],c$2,[663,28],c$2,[599,24],c$2,[1703,174],c$2,[875,16],c$2,[920,43],c$2,[1192,22],c$2,[260,51],c$2,[123,34],c$2,[34,69],c$2,[1284,181],s$2,[2,51]]),goto:u$2([s$2,[7,13],s$2,[9,13],6,17,7,10,11,12,14,21,22,23,19,20,18,24,s$2,[8,13],51,26,s$2,[51,25],28,30,33,35,39,40,41,34,36,42,s$2,[44,5,1],50,55,53,56,57,59,c$2,[5,4],61,s$2,[72,7],s$2,[17,13],62,64,c$2,[27,4],s$2,[22,13],66,c$2,[18,4],68,c$2,[5,4],s$2,[29,13],s$2,[37,27],s$2,[34,31],s$2,[35,31],s$2,[30,31],s$2,[31,31],s$2,[32,31],1,4,86,c$2,[272,6],72,73,74,78,c$2,[330,5],84,c$2,[282,8],5,84,88,s$2,[11,13],75,89,s$2,[75,4],81,81,33,81,c$2,[48,4],s$2,[81,4],c$2,[42,8],82,82,33,82,c$2,[20,4],s$2,[82,4],c$2,[20,8],s$2,[84,4],92,93,94,s$2,[84,14],96,84,84,77,30,33,77,c$2,[384,12],c$2,[16,16],c$2,[413,13],c$2,[13,13],s$2,[94,24],s$2,[96,24],s$2,[97,24],s$2,[98,24],s$2,[99,24],s$2,[100,24],s$2,[101,24],s$2,[102,24],s$2,[103,26],45,104,s$2,[111,24],s$2,[112,24],55,107,106,c$2,[640,3],s$2,[13,13],s$2,[115,8],s$2,[116,3],109,s$2,[116,5],110,s$2,[120,9],s$2,[121,9],s$2,[122,9],s$2,[123,9],55,107,111,c$2,[73,3],s$2,[15,13],112,120,113,s$2,[115,4,1],s$2,[18,13],s$2,[19,13],55,107,121,c$2,[52,3],s$2,[21,13],55,107,122,c$2,[19,3],c$2,[78,3],124,c$2,[7,3],126,125,2,s$2,[39,26],s$2,[40,26],128,s$2,[72,7],s$2,[42,26],129,s$2,[45,26],s$2,[46,26],s$2,[47,26],s$2,[48,26],s$2,[49,26],s$2,[50,26],124,131,133,134,135,138,137,c$2,[1118,14],142,140,139,141,s$2,[38,5],c$2,[1071,4],s$2,[36,4],3,s$2,[10,13],79,79,33,79,c$2,[47,4],s$2,[79,4],c$2,[51,8],80,80,33,80,c$2,[20,4],s$2,[80,4],c$2,[20,8],s$2,[83,4],c$2,[845,3],s$2,[83,14],96,83,83,s$2,[89,24],s$2,[90,24],s$2,[91,24],s$2,[95,24],s$2,[110,24],146,145,76,89,76,148,147,s$2,[92,5],93,94,s$2,[92,14],96,c$2,[19,3],s$2,[93,3],c$2,[24,3],s$2,[93,14],96,93,93,150,45,149,104,s$2,[107,4],s$2,[108,4],s$2,[109,4],s$2,[12,13],c$2,[290,4],s$2,[114,8],154,56,57,s$2,[119,8],s$2,[14,13],s$2,[16,13],s$2,[66,7],s$2,[67,7],s$2,[68,7],s$2,[69,7],s$2,[70,7],s$2,[71,7],156,c$2,[92,4],s$2,[33,5],s$2,[20,13],s$2,[23,13],s$2,[24,13],158,s$2,[72,7],159,s$2,[28,13],160,c$2,[793,6],s$2,[43,26],s$2,[44,26],125,162,c$2,[541,3],126,s$2,[129,5],164,s$2,[72,7],s$2,[132,5],s$2,[133,5],s$2,[52,26],166,s$2,[58,15],167,169,s$2,[72,7],171,s$2,[72,7],173,s$2,[72,7],s$2,[65,27],175,55,107,174,c$2,[255,3],78,78,33,78,c$2,[599,4],s$2,[78,4],c$2,[599,8],s$2,[85,24],s$2,[87,24],s$2,[86,24],s$2,[88,24],s$2,[104,24],s$2,[105,24],s$2,[106,4],s$2,[113,8],s$2,[117,8],s$2,[118,8],55,107,176,c$2,[198,3],s$2,[135,7],177,c$2,[394,6],178,179,s$2,[41,26],s$2,[127,5],s$2,[128,5],180,c$2,[45,6],s$2,[131,5],181,c$2,[927,14],55,55,183,s$2,[55,24],s$2,[56,26],184,c$2,[80,6],s$2,[63,27],185,c$2,[34,6],s$2,[64,27],186,c$2,[34,6],s$2,[62,27],187,s$2,[74,16],s$2,[134,7],188,s$2,[26,13],s$2,[27,13],s$2,[130,5],s$2,[53,26],s$2,[57,15],s$2,[54,26],s$2,[59,27],s$2,[60,27],s$2,[61,27],s$2,[73,16],s$2,[25,13]])}),defaultActions:bda$1({idx:u$2([0,2,5,11,14,s$2,[17,8,1],28,s$2,[37,9,1],47,48,50,51,s$2,[54,4,1],59,61,62,64,69,70,71,73,s$2,[75,6,1],84,86,87,88,s$2,[92,5,1],s$2,[103,4,1],108,s$2,[110,9,1],s$2,[120,4,1],126,128,129,131,132,134,135,136,142,s$2,[145,10,1],156,160,161,162,164,s$2,[167,5,2],176,s$2,[178,11,1]]),goto:u$2([7,9,8,17,22,29,37,34,35,30,31,32,1,11,94,s$2,[96,8,1],111,112,13,115,s$2,[120,4,1],15,18,19,21,2,39,40,42,s$2,[45,6,1],38,36,3,10,89,90,91,95,110,107,108,109,12,114,119,14,16,s$2,[66,6,1],33,20,23,24,28,43,44,126,129,132,133,52,65,85,87,86,88,104,105,106,113,117,118,135,41,127,128,131,56,63,64,62,74,134,26,27,130,53,57,54,59,60,61,73,25])}),parseError:function parseError(str,hash,ExceptionClass){if(hash.recoverable){if(typeof this.trace==='function'){this.trace(str);}hash.destroy();// destroy... well, *almost*! -}else{if(typeof this.trace==='function'){this.trace(str);}if(!ExceptionClass){ExceptionClass=this.JisonParserError;}throw new ExceptionClass(str,hash);}},parse:function parse(input){var self=this;var stack=new Array(128);// token stack: stores token which leads to state at the same index (column storage) -var sstack=new Array(128);// state stack: stores states (column storage) -var vstack=new Array(128);// semantic value stack -var lstack=new Array(128);// location stack -var table=this.table;var sp=0;// 'stack pointer': index into the stacks -var yyloc;var symbol=0;var preErrorSymbol=0;var lastEofErrorStateDepth=Infinity;var recoveringErrorInfo=null;var recovering=0;// (only used when the grammar contains error recovery rules) -var TERROR=this.TERROR;var EOF=this.EOF;var ERROR_RECOVERY_TOKEN_DISCARD_COUNT=this.options.errorRecoveryTokenDiscardCount|0||3;var NO_ACTION=[0,189/* === table.length :: ensures that anyone using this new state will fail dramatically! */];var lexer;if(this.__lexer__){lexer=this.__lexer__;}else{lexer=this.__lexer__=Object.create(this.lexer);}var sharedState_yy={parseError:undefined,quoteName:undefined,lexer:undefined,parser:undefined,pre_parse:undefined,post_parse:undefined,pre_lex:undefined,post_lex:undefined// WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! -};var ASSERT;if(typeof assert!=='function'){ASSERT=function JisonAssert(cond,msg){if(!cond){throw new Error('assertion failed: '+(msg||'***'));}};}else{ASSERT=assert;}this.yyGetSharedState=function yyGetSharedState(){return sharedState_yy;};this.yyGetErrorInfoTrack=function yyGetErrorInfoTrack(){return recoveringErrorInfo;};// shallow clone objects & arrays, straight copy of simple `src` values +}else{if(typeof this.trace==='function'){this.trace(str);}if(!ExceptionClass){ExceptionClass=this.JisonParserError;}throw new ExceptionClass(str,hash);}},parse:function parse(input){let self=this;let stack=new Array(128);// token stack: stores token which leads to state at the same index (column storage) +let sstack=new Array(128);// state stack: stores states (column storage) +let vstack=new Array(128);// semantic value stack +let lstack=new Array(128);// location stack +let table=this.table;let sp=0;// 'stack pointer': index into the stacks +let yyloc;let symbol=0;let preErrorSymbol=0;let lastEofErrorStateDepth=Infinity;let recoveringErrorInfo=null;let recovering=0;// (only used when the grammar contains error recovery rules) +const TERROR=this.TERROR;const EOF=this.EOF;const ERROR_RECOVERY_TOKEN_DISCARD_COUNT=this.options.errorRecoveryTokenDiscardCount|0||3;const NO_ACTION=[0,189/* === table.length :: ensures that anyone using this new state will fail dramatically! */];let lexer;if(this.__lexer__){lexer=this.__lexer__;}else{lexer=this.__lexer__=Object.create(this.lexer);}let sharedState_yy={parseError:undefined,quoteName:undefined,lexer:undefined,parser:undefined,pre_parse:undefined,post_parse:undefined,pre_lex:undefined,post_lex:undefined// WARNING: must be written this way for the code expanders to work correctly! +};const ASSERT=typeof assert!=='function'?function JisonAssert(cond,msg){if(!cond){throw new Error('assertion failed: '+(msg||'***'));}}:assert;this.yyGetSharedState=function yyGetSharedState(){return sharedState_yy;};this.yyGetErrorInfoTrack=function yyGetErrorInfoTrack(){return recoveringErrorInfo;};// shallow clone objects & arrays, straight copy of simple `src` values // e.g. `lexer.yytext` MAY be a complex value object, // rather than a simple string/value. // @@ -4397,14 +4438,13 @@ var TERROR=this.TERROR;var EOF=this.EOF;var ERROR_RECOVERY_TOKEN_DISCARD_COUNT=t // function shallow_copy(src){if(src&&typeof src==='object'){// non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: -if(src.constructor!==Object){if(Array.isArray(src)){return src.slice();}var dst=new src.constructor(src);// and make sure all custom attributes are added to the clone: +if(src.constructor!==Object){if(Array.isArray(src)){return src.slice();}let dst=new src.constructor(src);// and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst,src);return dst;}// native objects must be cloned a different way: -// -//return Object.assign({}, src); -var dst={};shallow_copy_noclobber(dst,src);return dst;}return src;}// add elements from `src` to `dst` when: +{//return Object.assign({}, src); +let dst={};shallow_copy_noclobber(dst,src);return dst;}}return src;}// add elements from `src` to `dst` when: // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` -function shallow_copy_noclobber(dst,src){const chk=Object.prototype.hasOwnProperty;for(var k in src){if(!(k in dst)){if(chk.call(src,k)){dst[k]=src[k];}}else{if(src[k]!=null&&dst[k]==null&&chk.call(src,k)){dst[k]=src[k];}}}}function copy_yylloc_native(loc){var rv=shallow_copy(loc);// shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: +function shallow_copy_noclobber(dst,src){const chk=Object.prototype.hasOwnProperty;for(let k in src){if(!(k in dst)){if(chk.call(src,k)){dst[k]=src[k];}}else if(src[k]!=null&&dst[k]==null&&chk.call(src,k)){dst[k]=src[k];}}}function copy_yylloc_native(loc){let rv=shallow_copy(loc);// shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if(rv){rv.range=rv.range.slice();}return rv;}// copy state shallow_copy_noclobber(sharedState_yy,this.yy);sharedState_yy.lexer=lexer;sharedState_yy.parser=this;// allow userland code to override the yytext and yylloc copy/clone functions: this.copy_yytext=this.options.copy_yytext||sharedState_yy.copy_yytext||shallow_copy;this.copy_yylloc=this.options.copy_yylloc||sharedState_yy.copy_yylloc||copy_yylloc_native;// *Always* setup `yyError`, `YYRECOVERING`, `yyErrOk` and `yyClearIn` functions as it is paramount @@ -4413,10 +4453,10 @@ this.copy_yytext=this.options.copy_yytext||sharedState_yy.copy_yytext||shallow_c // these functions are invoked in the user action code block(s) as // their closure will still refer to the `parse()` instance which set // them up. Hence we MUST set them up at the start of every `parse()` run! -if(this.yyError){this.yyError=function yyError(str/*, ...args */){var error_rule_depth=this.options.parserErrorsAreRecoverable?locateNearestErrorRecoveryRule(state):-1;var expected=this.collect_expected_token_set(state);var hash=this.constructParseErrorInfo(str,null,expected,error_rule_depth>=0);// append to the old one? -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; +if(this.yyError){this.yyError=function yyError(str/*, ...args */){let error_rule_depth=this.options.parserErrorsAreRecoverable?locateNearestErrorRecoveryRule(state):-1;let expected=this.collect_expected_token_set(state);let hash=this.constructParseErrorInfo(str,null,expected,error_rule_depth>=0);// append to the old one? +if(recoveringErrorInfo){let esp=recoveringErrorInfo.info_stack_pointer;recoveringErrorInfo.symbol_stack[esp]=symbol;let 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;recoveringErrorInfo.info_stack_pointer=esp;}else{recoveringErrorInfo=this.shallowCopyErrorInfo(hash);recoveringErrorInfo.yyError=true;recoveringErrorInfo.errorRuleDepth=error_rule_depth;recoveringErrorInfo.recovering=recovering;}// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){hash.extra_error_attributes=args;}return this.parseError(str,hash,this.JisonParserError);};}// Does the shared state override the default `parseError` that already comes with this instance? +let args=Array.prototype.slice.call(arguments,1);if(args.length){hash.extra_error_attributes=args;}return this.parseError(str,hash,this.JisonParserError);};}// Does the shared state override the default `parseError` that already comes with this instance? if(typeof sharedState_yy.parseError==='function'){this.parseError=function parseErrorAlt(str,hash,ExceptionClass){if(!ExceptionClass){ExceptionClass=this.JisonParserError;}return sharedState_yy.parseError.call(this,str,hash,ExceptionClass);};}else{this.parseError=this.originalParseError;}// Does the shared state override the default `quoteName` that already comes with this instance? if(typeof sharedState_yy.quoteName==='function'){this.quoteName=function quoteNameAlt(id_str){return sharedState_yy.quoteName.call(this,id_str);};}else{this.quoteName=this.originalQuoteName;}// set up the cleanup function; make it an API so that external code can re-use this one in case of // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which @@ -4424,7 +4464,7 @@ if(typeof sharedState_yy.quoteName==='function'){this.quoteName=function quoteNa // // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! -this.cleanupAfterParse=function parser_cleanupAfterParse(resultValue,invoke_post_methods,do_not_nuke_errorinfos){var rv;if(invoke_post_methods){var hash;if(sharedState_yy.post_parse||this.post_parse){// create an error hash info instance: we re-use this API in a **non-error situation** +this.cleanupAfterParse=function parser_cleanupAfterParse(resultValue,invoke_post_methods,do_not_nuke_errorinfos){let rv;if(invoke_post_methods){let hash;if(sharedState_yy.post_parse||this.post_parse){// create an error hash info instance: we re-use this API in a **non-error situation** // as this one delivers all parser internals ready for access by userland code. hash=this.constructParseErrorInfo(null/* no error! */,null/* no exception! */,null,false);}if(sharedState_yy.post_parse){rv=sharedState_yy.post_parse.call(this,sharedState_yy,resultValue,hash);if(typeof rv!=='undefined')resultValue=rv;}if(this.post_parse){rv=this.post_parse.call(this,sharedState_yy,resultValue,hash);if(typeof rv!=='undefined')resultValue=rv;}// cleanup: if(hash&&hash.destroy){hash.destroy();}}if(this.__reentrant_call_depth>1)return resultValue;// do not (yet) kill the sharedState when this is a reentrant run. @@ -4436,7 +4476,7 @@ stack.length=0;// fastest way to nuke an array without overly bothering the GC sstack.length=0;lstack.length=0;vstack.length=0;sp=0;// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;for(var i=this.__error_recovery_infos.length-1;i>=0;i--){var el=this.__error_recovery_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_recovery_infos.length=0;// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array, +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;for(let i=this.__error_recovery_infos.length-1;i>=0;i--){let el=this.__error_recovery_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_recovery_infos.length=0;// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array, // hence has been destroyed already: no need to do that *twice*. if(recoveringErrorInfo){recoveringErrorInfo=undefined;}}return resultValue;};// merge yylloc info into a new yylloc instance. // @@ -4450,32 +4490,38 @@ if(recoveringErrorInfo){recoveringErrorInfo=undefined;}}return resultValue;};// // yylloc info. // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. -this.yyMergeLocationInfo=function parser_yyMergeLocationInfo(first_index,last_index,first_yylloc,last_yylloc,dont_look_back){var i1=first_index|0,i2=last_index|0;var l1=first_yylloc,l2=last_yylloc;var rv;// rules: +this.yyMergeLocationInfo=function parser_yyMergeLocationInfo(first_index,last_index,first_yylloc,last_yylloc,dont_look_back){let i1=first_index|0;let i2=last_index|0;let l1=first_yylloc;let l2=last_yylloc;let rv;// rules: // - first/last yylloc entries override first/last indexes -if(!l1){if(first_index!=null){for(var i=i1;i<=i2;i++){l1=lstack[i];if(l1){break;}}}}if(!l2){if(last_index!=null){for(var i=i2;i>=i1;i--){l2=lstack[i];if(l2){break;}}}}// - detect if an epsilon rule is being processed and act accordingly: +if(!l1){if(first_index!=null){for(let i=i1;i<=i2;i++){l1=lstack[i];if(l1){break;}}}}if(!l2){if(last_index!=null){for(let i=i2;i>=i1;i--){l2=lstack[i];if(l2){break;}}}}// - detect if an epsilon rule is being processed and act accordingly: if(!l1&&first_index==null){// epsilon rule span merger. With optional look-ahead in l2. -if(!dont_look_back){for(var i=(i1||sp)-1;i>=0;i--){l1=lstack[i];if(l1){break;}}}if(!l1){if(!l2){// when we still don't have any valid yylloc info, we're looking at an epsilon rule +if(!dont_look_back){for(let i=(i1||sp)-1;i>=0;i--){l1=lstack[i];if(l1){break;}}}if(!l1){if(!l2){// when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: -return undefined;}else{// shallow-copy L2: after all, we MAY be looking +return null;}// shallow-copy L2: after all, we MAY be looking // at unconventional yylloc info objects... -rv=this.copy_yylloc(l2);return rv;}}else{// shallow-copy L1, then adjust first col/row 1 column past the end. +rv=this.copy_yylloc(l2);return rv;}// shallow-copy L1, then adjust first col/row 1 column past the end. rv=this.copy_yylloc(l1);rv.first_line=rv.last_line;rv.first_column=rv.last_column;rv.range[0]=rv.range[1];if(l2){// shallow-mixin L2, then adjust last col/row accordingly. -shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;}}if(!l1){l1=l2;l2=null;}if(!l1){return undefined;}// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking +shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;}if(!l1){l1=l2;l2=null;}if(!l1){return null;}// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... rv=this.copy_yylloc(l1);if(l2){shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;};// NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! -this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){var pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,loc:this.copy_yylloc(lexer.yylloc),expected:expected,recoverable:recoverable,state:state,action:action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,location_stack:lstack,stack_pointer:sp,yy:sharedState_yy,lexer:lexer,parser:this,// and make sure the error info doesn't stay due to potential +this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){const pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,loc:this.copy_yylloc(lexer.yylloc),expected,recoverable,state,action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,location_stack:lstack,stack_pointer:sp,yy:sharedState_yy,lexer,parser:this,// and make sure the error info doesn't stay due to potential // ref cycle via userland code manipulations. // These would otherwise all be memory leak opportunities! // // Note that only array and object references are nuked as those // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. -destroy:function destructParseErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +destroy:function destructParseErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// info.value = null; +// info.value_stack = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;};// clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. -this.shallowCopyErrorInfo=function parser_shallowCopyErrorInfo(p){var rv=shallow_copy(p);// remove the large parts which can only cause cyclic references +this.shallowCopyErrorInfo=function parser_shallowCopyErrorInfo(p){let rv=shallow_copy(p);// remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. delete rv.sharedState_yy;delete rv.parser;delete rv.lexer;// lexer.yytext MAY be a complex value object, rather than a simple string/value: rv.value=this.copy_yytext(rv.value);// yylloc info: @@ -4527,15 +4573,15 @@ rv.value_stack=rv.value_stack.map(this.copy_yytext);// and we don't bother with // - root_failure_pointer: // copy of the `stack_pointer`... // -for(var i=rv.stack_pointer;rv.state_stack[i]!=null;i++){// empty -}rv.base_pointer=i;rv.info_stack_pointer=i;rv.root_failure_pointer=rv.stack_pointer;// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! -this.__error_recovery_infos.push(rv);return rv;};function getNonTerminalFromCode(symbol){var tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){var token=lexer.lex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){var token=lexer.fastLex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}var lex=stdLex;var state,action,r,t;var yyval={$:true,_$:undefined,yy:sharedState_yy};var p;var yyrulelen;var this_production;var newState;var retval=false;// Return the rule stack depth where the nearest error rule can be found. +{let i;for(i=rv.stack_pointer;rv.state_stack[i]!=null;i++){// empty +}rv.base_pointer=i;rv.info_stack_pointer=i;}rv.root_failure_pointer=rv.stack_pointer;// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +this.__error_recovery_infos.push(rv);return rv;};function getNonTerminalFromCode(symbol){let tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){let token=lexer.lex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){let token=lexer.fastLex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}let lex=stdLex;let state,action,r,t;let yyval={$:true,_$:undefined,yy:sharedState_yy};let p;let yyrulelen;let this_production;let newState;let retval=false;// Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. -function locateNearestErrorRecoveryRule(state){var stack_probe=sp-1;var depth=0;// try to recover from error +function locateNearestErrorRecoveryRule(state){let stack_probe=sp-1;let depth=0;// try to recover from error while(stack_probe>=0){// check for error recovery rule in this state -var t=table[state]&&table[state][TERROR]||NO_ACTION;if(t[0]){// We need to make sure we're not cycling forever: +const t=table[state]&&table[state][TERROR]||NO_ACTION;if(t[0]){// We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must // prevent the core from running forever, // e.g. when parent rules are still expecting certain input to @@ -4556,7 +4602,7 @@ state=sstack[stack_probe];++depth;}return-1;// No suitable error recovery rule a // this initial `setInput()` call: hence we can now check and decide // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: -if(typeof lexer.canIUse==='function'){var lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}yyloc=this.copy_yylloc(lexer.yylloc);lstack[sp]=yyloc;vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack +if(typeof lexer.canIUse==='function'){let lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}yyloc=this.copy_yylloc(lexer.yylloc);lstack[sp]=yyloc;vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack state=newState;// sstack[sp - 1]; // use default actions if available if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}else{// The single `==` condition below covers both these `===` comparisons in a single @@ -4566,7 +4612,7 @@ if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}els if(!symbol){symbol=lex();}// read action for current state and first input t=table[state]&&table[state][symbol]||NO_ACTION;newState=t[1];action=t[0];// handle parse error if(!action){// first see if there's any chance at hitting an error recovery rule: -var error_rule_depth=locateNearestErrorRecoveryRule(state);var errStr=null;var errSymbolDescr=this.describeSymbol(symbol)||symbol;var expected=this.collect_expected_token_set(state);if(!recovering){// Report error +let error_rule_depth=locateNearestErrorRecoveryRule(state);let errStr=null;let errSymbolDescr=this.describeSymbol(symbol)||symbol;let expected=this.collect_expected_token_set(state);if(!recovering){// Report error errStr='Parse error';if(typeof lexer.yylineno==='number'){errStr+=' on line '+(lexer.yylineno+1);}if(typeof lexer.showPosition==='function'){errStr+=':\n'+lexer.showPosition(79-10,10)+'\n';}else{errStr+=': ';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}p=this.constructParseErrorInfo(errStr,null,expected,error_rule_depth>=0);// DO NOT cleanup the old one before we start the new error info track: // the old one will *linger* on the error stack and stay alive until we // invoke the parser's cleanup API! @@ -4574,20 +4620,20 @@ recoveringErrorInfo=this.shallowCopyErrorInfo(p);r=this.parseError(p.errStr,p,th // the `recoverable` flag without properly checking first: // we always terminate the parse when there's no recovery rule available anyhow! if(!p.recoverable||error_rule_depth<0){break;}else{// TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process... -}}var esp=recoveringErrorInfo.info_stack_pointer;// just recovered from another error +}}let esp=recoveringErrorInfo.info_stack_pointer;// just recovered from another error if(recovering===ERROR_RECOVERY_TOKEN_DISCARD_COUNT&&error_rule_depth>=0){// Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc=this.copy_yylloc(lexer.yylloc);// SHIFT current lookahead and grab another recoveringErrorInfo.symbol_stack[esp]=symbol;recoveringErrorInfo.location_stack[esp]=yyloc;recoveringErrorInfo.state_stack[esp]=newState;// push state ++esp;preErrorSymbol=0;symbol=lex();}// try to recover from error -if(error_rule_depth<0){ASSERT(recovering>0,"line 897");recoveringErrorInfo.info_stack_pointer=esp;// barf a fatal hairball when we're out of look-ahead symbols and none hit a match +if(error_rule_depth<0){ASSERT(recovering>0,'Line 1048');recoveringErrorInfo.info_stack_pointer=esp;// barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: -var po=this.__error_infos[this.__error_infos.length-1];// Report error +let po=this.__error_infos[this.__error_infos.length-1];// Report error if(typeof lexer.yylineno==='number'){errStr='Parsing halted on line '+(lexer.yylineno+1)+' while starting to recover from another error';}else{errStr='Parsing halted while starting to recover from another error';}if(po){errStr+=' -- previous error which resulted in this fatal result: '+po.errStr;}else{errStr+=': ';}if(typeof lexer.showPosition==='function'){errStr+='\n'+lexer.showPosition(79-10,10)+'\n';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}p=this.constructParseErrorInfo(errStr,null,expected,false);if(po){p.extra_error_attributes=po;}r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}preErrorSymbol=symbol===TERROR?0:symbol;// save the lookahead token symbol=TERROR;// insert generic error symbol as new lookahead const EXTRA_STACK_SAMPLE_DEPTH=3;// REDUCE/COMBINE the pushed terms/tokens to a new ERROR token: -recoveringErrorInfo.symbol_stack[esp]=preErrorSymbol;if(errStr){recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,errStr:errStr,errorSymbolDescr:errSymbolDescr,expectedStr:expected,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}else{recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}recoveringErrorInfo.location_stack[esp]=this.copy_yylloc(lexer.yylloc);recoveringErrorInfo.state_stack[esp]=newState||NO_ACTION[1];++esp;recoveringErrorInfo.info_stack_pointer=esp;yyval.$=recoveringErrorInfo;yyval._$=undefined;yyrulelen=error_rule_depth;r=this.performAction.call(yyval,yyloc,NO_ACTION[1],sp-1,vstack,lstack);if(typeof r!=='undefined'){retval=r;break;}// pop off stack +recoveringErrorInfo.symbol_stack[esp]=preErrorSymbol;if(errStr){recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,errStr,errSymbolDescr,expectedStr:expected,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}else{recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}recoveringErrorInfo.location_stack[esp]=this.copy_yylloc(lexer.yylloc);recoveringErrorInfo.state_stack[esp]=newState||NO_ACTION[1];++esp;recoveringErrorInfo.info_stack_pointer=esp;yyval.$=recoveringErrorInfo;yyval._$=undefined;yyrulelen=error_rule_depth;let combineState=NO_ACTION[1];r=this.performAction.call(yyval,yyloc,combineState,sp-1,vstack,lstack);if(typeof r!=='undefined'){retval=r;break;}// pop off stack sp-=yyrulelen;// and move the top entries + discarded part of the parse stacks onto the error info stack: -for(var idx=sp-EXTRA_STACK_SAMPLE_DEPTH,top=idx+yyrulelen;idx0){recovering--;}}else{// error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: -ASSERT(recovering>0,"line 1163");symbol=preErrorSymbol;preErrorSymbol=0;// read action for current state and first input +ASSERT(recovering>0,'Line 1352');symbol=preErrorSymbol;preErrorSymbol=0;// read action for current state and first input t=table[newState]&&table[newState][symbol]||NO_ACTION;if(!t[0]||symbol===TERROR){// forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where // (simple) stuff might have been missing before the token which caused the error we're // recovering from now... @@ -4678,17 +4724,17 @@ symbol=0;}}// once we have pushed the special ERROR token value, // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! -ASSERT(preErrorSymbol===0,"line 1194");if(recovering===0){break;}continue;// reduce: +ASSERT(preErrorSymbol===0,'Line 1383');if(recovering===0){break;}continue;// reduce: case 2:this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){// signal end of error recovery loop AND end of outer parse loop +yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){// signal end of error recovery loop AND end of outer parse loop action=3;retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}sp=-2;// magic number: signal outer "fast parse loop" ACCEPT state that we already have a properly set up `retval` parser return value. break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;lstack[sp]=yyval._$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -4716,26 +4762,26 @@ break;}// should we also break out of the regular/outer parse loop, // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? -ASSERT(action!==2,"line 1272");if(!action||action===1){continue;}}}switch(action){// catch misc. parse failures: +ASSERT(action!==2,'Line 1509');if(!action||action===1){continue;}}}switch(action){// catch misc. parse failures: default:// this shouldn't happen, unless resolve defaults are off if(action instanceof Array){p=this.constructParseErrorInfo('Parse Error: multiple actions possible at state: '+state+', token: '+symbol,null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}// Another case of better safe than sorry: in case state transitions come out of another error recovery process // or a buggy LUT (LookUp Table): p=this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.',null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;// shift: case 1:stack[sp]=symbol;vstack[sp]=lexer.yytext;lstack[sp]=this.copy_yylloc(lexer.yylloc);sstack[sp]=newState;// push state -if(typeof Jison!=='undefined'&&Jison.parserDebugger){var tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;ASSERT(preErrorSymbol===0,"line 1352");// normal execution / no error -ASSERT(recovering===0,"line 1353");// normal execution / no error +if(typeof Jison!=='undefined'&&Jison.parserDebugger){let tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;ASSERT(preErrorSymbol===0,'Line 1619');// normal execution / no error +ASSERT(recovering===0,'Line 1620');// normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc=this.copy_yylloc(lexer.yylloc);continue;// reduce: -case 2:ASSERT(preErrorSymbol===0,"line 1364");// normal execution / no error -ASSERT(recovering===0,"line 1365");// normal execution / no error +case 2:ASSERT(preErrorSymbol===0,'Line 1631');// normal execution / no error +ASSERT(recovering===0,'Line 1632');// normal execution / no error this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack +yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;lstack[sp]=yyval._$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:if(sp!==-2){retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -4984,8 +5030,8 @@ return retval;},yyError:1};parser$3.originalParseError=parser$3.parseError;parse * @public * @constructor * @nocollapse - */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 -Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';var lexer={// Code Generator Information Report + */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){const ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 +Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';const lexer={// Code Generator Information Report // --------------------------------- // // Options: @@ -5054,7 +5100,7 @@ CRLF_Re:/\r\n?|\n/,/** * @this {RegExpLexer} */constructLexErrorInfo:function lexer_constructLexErrorInfo(msg,recoverable,show_input_position){msg=''+msg;// heuristic to determine if the error message already contains a (partial) source code dump // as produced by either `showPosition()` or `prettyPrintRange()`: -if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){var pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){var pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */var pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... +if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){const pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){const pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */const pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:this,/** * and make sure the error info doesn't stay due to potential * ref cycle via userland code manipulations. @@ -5066,7 +5112,11 @@ text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:t * * @public * @this {LexErrorInfo} - */destroy:function destructLexErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! + */destroy:function destructLexErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;},/** * handler which is invoked when a lexer error occurs. * @@ -5077,8 +5127,8 @@ this.__error_infos.push(pei);return pei;},/** * * @public * @this {RegExpLexer} - */yyerror:function yyError(str/*, ...args */){var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** + */yyerror:function yyError(str/*, ...args */){let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: +let args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** * final cleanup function for when we have completed lexing the input; * make it an API so that external code can use this one once userland * code has decided it's time to destroy any lingering lexer error @@ -5093,13 +5143,13 @@ var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_a this.setInput('',{});// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** * clear the lexer token context; intended for internal use only * * @public * @this {RegExpLexer} */clear:function lexer_clear(){this.yytext='';this.yyleng=0;this.match='';// - DO NOT reset `this.matched` -this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** +this.matches=false;this._more=false;this._backtrack=false;const col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** * resets the lexer, sets new input * * @public @@ -5108,10 +5158,10 @@ this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.la // including expansion work to be done to go from a loaded // lexer to a usable lexer: if(!this.__decompressed){// step 1: decompress the regex list: -var rules=this.rules;for(var i=0,len=rules.length;i> tokens and perform user action code for a <> match, but only does so *once*) -return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}var ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). +return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}let ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. -var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;var ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** +let slice_len=1;let lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;const ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** * unshifts one char (or an entire string) into the input * * @public * @this {RegExpLexer} - */unput:function lexer_unput(ch){var len=ch.length;var lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** + */unput:function lexer_unput(ch){let len=ch.length;let lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** // The `offset` value MAY be negative if you `unput()` more text than you have already lexed. // This type of behaviour is generally observed for one kind of 'lexer/parser hack' // where custom token-illiciting characters are pushed in front of the input stream to help @@ -5181,11 +5231,11 @@ var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lin if(-this.offset>this.base_position){this.base_position=-this.offset;}this.match=this.match.substr(0,this.match.length-len);this.matched=this.matched.substr(0,this.matched.length-len);if(lines.length>1){this.yylineno-=lines.length-1;this.yylloc.last_line=this.yylineno+1;// Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. -var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** +let pre=this.match;let pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -5195,8 +5245,8 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */lookAhead:function lexer_lookAhead(){return this._input||'';},/** @@ -5213,7 +5263,7 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 */reject:function lexer_reject(){if(this.options.backtrack_lexer){this._backtrack=true;}else{// when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. -var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** +let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** * retain first n characters of the match * * @public @@ -5235,17 +5285,17 @@ var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yyl * * @public * @this {RegExpLexer} - */pastInput:function lexer_pastInput(maxSize,maxLines){var past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0)maxSize=Infinity;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=Infinity;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substr` anticipation: treat \r\n as a single character and take a little + */pastInput:function lexer_pastInput(maxSize,maxLines){let past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0){maxSize=Infinity;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=Infinity;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past=past.substr(-maxSize*2-2);// now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: -var a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, +let a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, // do add an ellipsis prefix... if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -5271,18 +5321,18 @@ if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} - */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){var next=this.match;var source=this._input||'';if(maxSize<0)maxSize=next.length+source.length;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=maxSize;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substring` anticipation: treat \r\n as a single character and take a little + */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){let next=this.match;let source=this._input||'';if(maxSize<0){maxSize=next.length+source.length;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=maxSize;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: if(next.lengthmaxSize){next=next.substring(0,maxSize)+'...';}return next;},/** @@ -5291,7 +5341,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){var pre=this.pastInput(maxPrefix).replace(/\s/g,' ');var c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** + */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){const pre=this.pastInput(maxPrefix).replace(/\s/g,' ');let c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** * return an YYLLOC info object derived off the given context (actual, preceding, following, current). * Use this method when the given `actual` location is not guaranteed to exist (i.e. when * it MAY be NULL) and you MUST have a valid location info object anyway: @@ -5307,7 +5357,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */deriveLocationInfo:function lexer_deriveYYLLOC(actual,preceding,following,current){var loc={first_line:1,first_column:0,last_line:1,last_column:0,range:[0,0]};if(actual){loc.first_line=actual.first_line|0;loc.last_line=actual.last_line|0;loc.first_column=actual.first_column|0;loc.last_column=actual.last_column|0;if(actual.range){loc.range[0]=actual.range[0]|0;loc.range[1]=actual.range[1]|0;}}if(loc.first_line<=0||loc.last_line=loc.first_line)){loc.last_line=current.last_line|0;loc.last_column=current.last_column|0;if(current.range){loc.range[1]=current.range[1]|0;}}}// sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter // or plan D heuristics to produce a 'sensible' last_line value: @@ -5356,9 +5406,9 @@ loc.range[1]=loc.range[0];}if(loc.first_column<0){loc.first_column=0;}if(loc.las * * @public * @this {RegExpLexer} - */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;var input=this.matched+(this._input||'');var lines=input.split('\n');var l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);var l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);var lineno_display_width=1+Math.log10(l1|1)|0;var ws_prefix=new Array(lineno_display_width).join(' ');var nonempty_line_indexes=[[],[],[]];var rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){var lno=index+l0;var lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);var rv=lno_pfx+': '+line;var errpfx=new Array(lineno_display_width+1).join('^');var offset=2+1;var len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it + */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;let input=this.matched+(this._input||'');let lines=input.split('\n');let l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);let l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);let lineno_display_width=1+Math.log10(l1|1)|0;let ws_prefix=new Array(lineno_display_width).join(' ');let nonempty_line_indexes=[[],[],[]];let rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){let lno=index+l0;let lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);let rv=lno_pfx+': '+line;let errpfx=new Array(lineno_display_width+1).join('^');let offset=2+1;let len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: -for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){var clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;var clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;var intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** +for(let i=0;i<=2;i++){let line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){let clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;let clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;let intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** * helper function, used to produce a human readable description as a string, given * the input `yylloc` location object. * @@ -5367,7 +5417,7 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){var l1=yylloc.first_line;var l2=yylloc.last_line;var c1=yylloc.first_column;var c2=yylloc.last_column;var dl=l2-l1;var dc=c2-c1;var rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){var r1=yylloc.range[0];var r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** + */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){let l1=yylloc.first_line;let l2=yylloc.last_line;let c1=yylloc.first_column;let c2=yylloc.last_column;let dl=l2-l1;let dc=c2-c1;let rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){let r1=yylloc.range[0];let r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** * test the lexed token: return FALSE when not a match, otherwise return token. * * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]` @@ -5384,18 +5434,18 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */test_match:function lexer_test_match(match,indexed_rule){var token,lines,backup,match_str,match_str_len;if(this.options.backtrack_lexer){// save context + */test_match:function lexer_test_match(match,indexed_rule){let backup;if(this.options.backtrack_lexer){// save context backup={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.yylloc.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column,range:this.yylloc.range.slice()},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,//_signaled_error_token: this._signaled_error_token, -yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}match_str=match[0];match_str_len=match_str.length;lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: +yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}let match_str=match[0];let match_str_len=match_str.length;let lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: // those rules will already have moved this `offset` forward matching their match lengths, // hence we must only add our own match length now: this.offset+=match_str_len;this._more=false;this._backtrack=false;this._input=this._input.slice(match_str_len);// calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} -token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: +let token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; if(this.done&&this._input){this.done=false;}if(token){return token;}else if(this._backtrack){// recover context -for(var k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. +for(let k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. }else if(this._signaled_error_token){// produce one 'error' token as `.parseError()` in `reject()` // did not guarantee a failure signal by throwing an exception! token=this._signaled_error_token;this._signaled_error_token=false;return token;}return false;},/** @@ -5403,19 +5453,19 @@ token=this._signaled_error_token;this._signaled_error_token=false;return token;} * * @public * @this {RegExpLexer} - */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}var token,match,tempMatch,index;if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}var spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. + */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}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();// Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 -if(!spec||!spec.rules){var lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! -return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}var rule_ids=spec.rules;var regexes=spec.__rule_regexes;var len=spec.__rule_count;// Note: the arrays are 1-based, while `len` itself is a valid index, +if(!spec||!spec.rules){let lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! +return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}{let rule_ids=spec.rules;let regexes=spec.__rule_regexes;let len=spec.__rule_count;let match;let index;// 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(var i=1;i<=len;i++){tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. +for(let i=1;i<=len;i++){let tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){let token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. }else{// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}}else if(!this.options.flex){break;}}}if(match){token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}if(!this._input){this.done=true;this.clear();return this.EOF;}else{var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);var pendingInput=this._input;var activeCondition=this.topState();var conditionStackDepth=this.conditionStack.length;token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us +return false;}}else if(!this.options.flex){break;}}}if(match){let token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) +return false;}}if(!this._input){this.done=true;this.clear();return this.EOF;}{let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);let pendingInput=this._input;let activeCondition=this.topState();let conditionStackDepth=this.conditionStack.length;let token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: if(!this.matches&&// and make sure the input has been modified/consumed ... @@ -5426,7 +5476,7 @@ activeCondition===this.topState()&&conditionStackDepth===this.conditionStack.len * * @public * @this {RegExpLexer} - */lex:function lexer_lex(){var r;//this._clear_state = 0; + */lex:function lexer_lex(){let r;//this._clear_state = 0; if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}// allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer: if(typeof this.pre_lex==='function'){r=this.pre_lex.call(this,0);}if(typeof this.options.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.pre_lex.call(this,r)||r;}if(this.yy&&typeof this.yy.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) @@ -5434,50 +5484,50 @@ r=this.yy.pre_lex.call(this,r)||r;}while(!r){r=this.next();}if(this.yy&&typeof t r=this.yy.post_lex.call(this,r)||r;}if(typeof this.options.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.post_lex.call(this,r)||r;}if(typeof this.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.post_lex.call(this,r)||r;}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return next match that has a token. Identical to the `lex()` API but does not invoke any of the * `pre_lex()` nor any of the `post_lex()` callbacks. * * @public * @this {RegExpLexer} - */fastLex:function lexer_fastLex(){var r;//this._clear_state = 0; + */fastLex:function lexer_fastLex(){let r;//this._clear_state = 0; while(!r){r=this.next();}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return info about the lexer state that can help a parser or other lexer API user to use the * most efficient means available. This API is provided to aid run-time performance for larger @@ -5485,7 +5535,7 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */canIUse:function lexer_canIUse(){var rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** + */canIUse:function lexer_canIUse(){const rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** * backwards compatible alias for `pushState()`; * the latter is symmetrical with `popState()` and we advise to use * those APIs in any modern lexer code, rather than `begin()`. @@ -5504,20 +5554,20 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */popState:function lexer_popState(){var n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}else{return this.conditionStack[0];}},/** + */popState:function lexer_popState(){const n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}return this.conditionStack[0];},/** * return the currently active lexer condition state; when an index * argument is provided it produces the N-th previous condition state, * if available * * @public * @this {RegExpLexer} - */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}else{return'INITIAL';}},/** + */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}return'INITIAL';},/** * (internal) determine the lexer rule set which is active for the * currently active lexer condition state * * @public * @this {RegExpLexer} - */_currentRules:function lexer__currentRules(){var n=this.conditionStack.length-1;var state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions['INITIAL'];},/** + */_currentRules:function lexer__currentRules(){const n=this.conditionStack.length-1;let state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions.INITIAL;},/** * return the number of states currently on the stack * * @public @@ -5776,10 +5826,10 @@ return s;}// convert string value to number or boolean value, when possible // 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};var version='0.6.2-220';// require('./package.json').version; +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; 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(var i=0;i, include: } }if(decl.codeSection){if(!grammar.moduleInit){grammar.moduleInit=[];}grammar.moduleInit.push(decl.codeSection);// {qualifier: , include: } @@ -5788,5 +5838,5 @@ grammar.imports.push(decl.imports);}if(decl.initCode){if(!grammar.moduleInit){gr function parseLex(text,position){text=text.replace(/(?:^%lex)|(?:\/lex$)/g,'');// We want the lex input to start at the given 'position', if any, // so that error reports will produce a line number and character index // which matches the original input file: -position=position||{};position.range=position.range||[];var l=position.first_line|0;var c=position.range[0]|0;var prelude='';if(l>1){prelude+=new Array(l).join('\n');c-=prelude.length;}if(c>3){prelude='// '+new Array(c-3).join('.')+prelude;}return jisonlex.parse(prelude+text);}const ebnf_parser={transform};var ebnfParser={parse,transform,// assistant exports for debugging/testing: +position=position||{};position.range=position.range||[];let l=position.first_line|0;let c=position.range[0]|0;let prelude='';if(l>1){prelude+=new Array(l).join('\n');c-=prelude.length;}if(c>3){prelude='// '+new Array(c-3).join('.')+prelude;}return jisonlex.parse(prelude+text);}const ebnf_parser={transform};var ebnfParser={parse,transform,// assistant exports for debugging/testing: bnf_parser:bnf,ebnf_parser,bnf_lexer:jisonlex,version};module.exports=ebnfParser; diff --git a/packages/ebnf-parser/dist/ebnf-parser-cjs.js b/packages/ebnf-parser/dist/ebnf-parser-cjs.js index 4ba05ac6f..83de56502 100644 --- a/packages/ebnf-parser/dist/ebnf-parser-cjs.js +++ b/packages/ebnf-parser/dist/ebnf-parser-cjs.js @@ -4,6 +4,7 @@ var XRegExp = require('@gerhobbelt/xregexp'); var fs = require('fs'); var path$1 = require('path'); var JSON5 = require('@gerhobbelt/json5'); +var mkdirp = require('mkdirp'); var recast = require('recast'); var babel = require('@babel/core'); var assert$1 = require('assert'); @@ -14,10 +15,11 @@ var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); +var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); -// Return TRUE if `src` starts with `searchString`. +// Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -40,19 +42,19 @@ function rmCommonWS(strings, ...values) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -71,19 +73,21 @@ function rmCommonWS(strings, ...values) { // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -92,16 +96,19 @@ function rmCommonWS(strings, ...values) { } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -112,27 +119,79 @@ function camelCase(s) { return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } +// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; +})([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' +]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -150,6 +209,11 @@ function mkIdentifier(s) { .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -158,13 +222,13 @@ function mkIdentifier(s) { function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -175,23 +239,17 @@ function scanRegExp(s) { break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -214,34 +272,33 @@ function isLineTerminator(cp) { /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -264,28 +321,76 @@ function chkBugger(src) { // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } +function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; +} + + +function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); +} + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -296,27 +401,37 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -326,7 +441,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -334,7 +449,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -360,27 +475,43 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -393,9 +524,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -417,22 +549,22 @@ assert__default['default'](recast__default['default']); // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; -// Determine which Unicode NonAsciiIdentifierStart characters +// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -440,40 +572,40 @@ const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -481,30 +613,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -515,59 +647,59 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -609,38 +741,38 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -652,18 +784,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -674,56 +806,56 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -731,97 +863,97 @@ function generateMapper4JisonGrammarIdentifiers(input) { typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -829,7 +961,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -842,7 +974,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -855,7 +987,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -868,7 +1000,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -887,37 +1019,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -949,7 +1081,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -966,37 +1098,37 @@ function parseCodeChunkToAST(src, options) { .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return babel.transformSync(src, options); // => { code, map, ast } @@ -1004,8 +1136,8 @@ function compileCodeToES5(src, options) { function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1014,7 +1146,7 @@ function prettyPrintAST(ast, options) { // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1037,25 +1169,25 @@ function prettyPrintAST(ast, options) { // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1066,9 +1198,9 @@ function checkActionBlock(src, yylloc, options) { // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1076,7 +1208,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1085,14 +1217,14 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1146,7 +1278,7 @@ var parse2AST = { trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1160,7 +1292,7 @@ function chkBugger$1(src) { /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1172,24 +1304,24 @@ const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?: /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1206,8 +1338,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1218,14 +1350,14 @@ function printFunctionSourceCodeContainer(f) { action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1236,17 +1368,17 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; -// -// -// +// +// +// function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1272,7 +1404,7 @@ function detectIstanbulGlobal() { // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1320,7 +1452,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1383,13 +1515,13 @@ var reHelpers = { getRegExpInfo: getRegExpInfo }; -var cycleref = []; -var cyclerefpath = []; +let cycleref = []; +let cyclerefpath = []; -var linkref = []; -var linkrefpath = []; +let linkref = []; +let linkrefpath = []; -var path = []; +let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1397,14 +1529,14 @@ function shallow_copy(src) { return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1417,11 +1549,11 @@ function shallow_copy(src) { function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1434,9 +1566,9 @@ function shallow_copy_and_strip_depth(src, parentKey) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1451,16 +1583,52 @@ function shallow_copy_and_strip_depth(src, parentKey) { } +// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } +// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; +} + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1475,7 +1643,7 @@ function trim_array_tail(arr) { function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1501,10 +1669,10 @@ function treat_value_stack(v) { } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1602,7 +1770,7 @@ function treat_hash(h) { function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1619,7 +1787,7 @@ function treat_error_report_info(e) { path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1647,7 +1815,7 @@ function treat_error_report_info(e) { function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1663,7 +1831,7 @@ function treat_object(e) { linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1675,14 +1843,14 @@ function treat_object(e) { // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1692,7 +1860,7 @@ function trimErrorForTestReporting(e) { cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1706,12 +1874,14 @@ var helpers = { dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1726,7 +1896,7 @@ var helpers = { printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; // See also: @@ -1734,7 +1904,6 @@ var helpers = { // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1751,9 +1920,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -1786,10 +1955,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -1804,18 +1973,18 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -1846,7 +2015,7 @@ JisonParserError.prototype.name = 'JisonParserError'; // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -1863,9 +2032,9 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -1878,7 +2047,7 @@ JisonParserError.prototype.name = 'JisonParserError'; } -var parser = { +let parser = { // Code Generator Information Report // --------------------------------- // @@ -2004,7 +2173,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2012,7 +2180,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2024,8 +2191,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2038,14 +2205,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2061,10 +2227,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2072,10 +2238,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2119,9 +2285,9 @@ performAction: function parser__PerformAction(yystate /* action[1] */, yysp, yyv /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; @@ -2129,17 +2295,17 @@ performAction: function parser__PerformAction(yystate /* action[1] */, yysp, yyv case 0: /*! Production:: $accept : production $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-) break; case 1: /*! Production:: production : handle EOF */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-) return yyvstack[yysp - 1]; @@ -2375,7 +2541,6 @@ defaultActions: { 19: 3 }, parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -2392,37 +2557,32 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) + let vstack = new Array(128); // semantic value stack - var vstack = new Array(128); // semantic value stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks + let symbol = 0; - - - - var symbol = 0; + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -2430,20 +2590,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -2460,7 +2618,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -2468,18 +2625,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -2487,18 +2645,14 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -2520,7 +2674,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -2533,7 +2686,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -2547,11 +2699,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -2605,8 +2756,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -2755,8 +2906,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -2765,10 +2915,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -2776,7 +2926,7 @@ parse: function parse(input) { stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -2787,9 +2937,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -2815,8 +2970,7 @@ parse: function parse(input) { function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -2825,21 +2979,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -2849,21 +3002,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -2872,20 +3024,20 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; try { @@ -2898,7 +3050,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -2951,14 +3103,11 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { - var errStr; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let errStr; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); // Report error errStr = 'Parse error'; @@ -2995,9 +3144,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -3026,7 +3173,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -3068,21 +3215,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, newState, sp - 1, vstack); +r = this.performAction.call(yyval, newState, sp - 1, vstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -3113,14 +3258,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -3130,6 +3276,7 @@ parse: function parse(input) { + } continue; // accept: @@ -3182,8 +3329,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -3443,7 +3589,6 @@ var lexer = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -3460,10 +3605,10 @@ var lexer = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -3495,7 +3640,7 @@ var lexer = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -3537,7 +3682,9 @@ var lexer = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -3623,7 +3770,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -3631,7 +3778,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -3644,7 +3791,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -3670,10 +3817,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -3696,7 +3846,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -3719,16 +3868,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -3750,7 +3899,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -3758,8 +3906,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -3788,7 +3936,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -3813,7 +3961,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -3825,17 +3973,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -3929,7 +4077,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -3950,7 +4098,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -3961,7 +4108,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -3972,15 +4119,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -4014,8 +4161,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -4048,9 +4195,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -4069,9 +4216,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -4081,8 +4228,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -4109,20 +4256,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -4162,17 +4308,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -4181,7 +4329,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -4196,8 +4344,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -4223,24 +4371,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -4251,7 +4401,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -4273,8 +4423,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -4296,8 +4446,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -4441,21 +4590,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -4470,11 +4619,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -4493,13 +4642,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -4523,13 +4672,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -4544,8 +4693,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -4576,7 +4725,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -4608,9 +4757,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -4639,7 +4788,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -4657,7 +4806,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -4682,7 +4831,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -4692,8 +4840,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -4702,7 +4848,7 @@ EOF: 1, this.clear(); } - 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. @@ -4714,13 +4860,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -4730,68 +4876,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -4816,7 +4968,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -4864,24 +5016,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -4901,7 +5053,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -4911,24 +5063,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -4949,8 +5101,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -4990,14 +5141,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -5013,9 +5164,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -5026,8 +5177,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -5035,7 +5186,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -5188,9 +5339,9 @@ const ID_REGEX_BASE$1 = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // guaranteed not to collide with previously generated / already existing // rules (~ symbols). function generateUniqueSymbol(id, postfix, opts) { - var sym = id + postfix; + let sym = id + postfix; if (opts.grammar[sym]) { - var i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. + let i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. do { sym = id + postfix + i; i++; @@ -5200,8 +5351,8 @@ function generateUniqueSymbol(id, postfix, opts) { } function generatePushAction(handle, offset) { - var terms = handle.terms; - var rv = []; + const terms = handle.terms; + let rv = []; for (var i = 0, len = terms.length; i < len; i++) { rv.push('$' + (i + offset)); @@ -5217,11 +5368,11 @@ function generatePushAction(handle, offset) { } function transformExpression(e, opts, emit) { - var type = e[0], - value = e[1], - name = false, - has_transformed = 0; - var list, n; + let type = e[0]; + let value = e[1]; + let name = false; + let has_transformed = 0; + let list, n; if (type === 'xalias') { type = e[1]; @@ -5248,7 +5399,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ list.fragment, @@ -5268,7 +5419,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ '', @@ -5288,7 +5439,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); // you want to be able to check if 0 or 1 occurrences were recognized: since jison // by default *copies* the lexer token value, i.e. `$$ = $1` is the (optional) default action, // we will need to set the action up explicitly in case of the 0-count match: @@ -5324,7 +5475,7 @@ function transformExpression(e, opts, emit) { opts = optsForProduction(name, opts.grammar); opts.grammar[name] = value.map(function (handle) { - var list = transformExpressionList(handle, opts); + let list = transformExpressionList(handle, opts); return [ list.fragment, '$$ = ' + generatePushAction(list, 1) + ';' @@ -5337,11 +5488,11 @@ function transformExpression(e, opts, emit) { } function transformExpressionList(list, opts) { - var first_transformed_term_index = false; - var terms = list.reduce(function (tot, e) { - var ci = tot.length; + let first_transformed_term_index = false; + let terms = list.reduce(function (tot, e) { + let ci = tot.length; - var has_transformed = transformExpression(e, opts, function (name) { + let has_transformed = transformExpression(e, opts, function (name) { if (name.terms) { tot.push.apply(tot, name.terms); } else { @@ -5370,42 +5521,42 @@ function optsForProduction(id, grammar) { } function transformProduction(id, production, grammar) { - var transform_opts = optsForProduction(id, grammar); + let transform_opts = optsForProduction(id, grammar); return production.map(function (handle) { - var action = null, - opts = null; - var i, len, n; + let action = null; + let opts = null; + let i, len, n; if (typeof handle !== 'string') { action = handle[1]; opts = handle[2]; handle = handle[0]; } - var expressions = handle; + let expressions = handle; if (typeof expressions === 'string') { expressions = parser$1.parse(handle); } - var list = transformExpressionList(expressions, transform_opts); + let list = transformExpressionList(expressions, transform_opts); - var ret = [list.fragment]; + let ret = [ list.fragment ]; if (action) { // make sure the action doesn't address any inner items. if (list.first_transformed_term_index) { // seek out all names and aliases; strip out literal tokens first as those cannot serve as $names: - var alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); + let alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); - var alias_re = new XRegExp__default['default'](`\\[${ID_REGEX_BASE$1}\\]`); - var term_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$1}$`); + let alias_re = new XRegExp__default['default'](`\\[${ID_REGEX_BASE$1}\\]`); + let term_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$1}$`); // and collect the PERMITTED aliases: the names of the terms and all the remaining aliases - var good_aliases = {}; - var alias_cnt = {}; - var donotalias = {}; + let good_aliases = {}; + let alias_cnt = {}; + let donotalias = {}; // WARNING: this replicates the knowledge/code of jison.js::addName() - var addName = function addNameEBNF(s, i) { - var base = s.replace(/[0-9]+$/, ''); - var dna = donotalias[base]; + let addName = function addNameEBNF(s, i) { + let base = s.replace(/[0-9]+$/, ''); + let dna = donotalias[base]; if (good_aliases[s]) { alias_cnt[s]++; @@ -5424,7 +5575,7 @@ function transformProduction(id, production, grammar) { }; // WARNING: this replicates the knowledge/code of jison.js::markBasename() - var markBasename = function markBasenameEBNF(s) { + let markBasename = function markBasenameEBNF(s) { if (/[0-9]$/.test(s)) { s = s.replace(/[0-9]+$/, ''); donotalias[s] = true; @@ -5461,13 +5612,13 @@ function transformProduction(id, production, grammar) { // now scan the action for all named and numeric semantic values ($nonterminal / $1 / @1, ##1, ...) // // Note that `#name` are straight **static** symbol translations, which are okay as they don't - // require access to the parse stack: `#n` references can be resolved completely + // require access to the parse stack: `#n` references can be resolved completely // at grammar compile time. // - var nameref_re = new XRegExp__default['default'](`(?:[$@]|##)${ID_REGEX_BASE$1}`, 'g'); - var named_spots = nameref_re.exec(action); - var numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); - var max_term_index = list.terms.length; + let nameref_re = new XRegExp__default['default'](`(?:[$@]|##)${ID_REGEX_BASE$1}`, 'g'); + let named_spots = nameref_re.exec(action); + let numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); + let max_term_index = list.terms.length; // loop through the XRegExp alias regex matches in `action` while (named_spots) { @@ -5497,7 +5648,7 @@ function transformProduction(id, production, grammar) { for (i = 0, len = numbered_spots.length; i < len; i++) { n = parseInt(numbered_spots[i].replace(/^(?:[$@]|##)/, '')); if (n > max_term_index) { - /* @const */ var n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; + /* @const */ let n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; throw new Error('The action block references the ' + n + n_suffixes[Math.max(0, Math.min(3, n - 1))] + ' term, ' + 'which is not available in production "' + handle + '"; ' + 'Be reminded that you cannot reference sub-elements within EBNF */+/? groups, ' + @@ -5515,13 +5666,14 @@ function transformProduction(id, production, grammar) { if (ret.length === 1) { return ret[0]; - } else { - return ret; } + return ret; + }); } -var ref_list; -var ref_names; + +let ref_list; +let ref_names; // create a deep copy of the input, so we will keep the input constant. function deepClone(from, sub) { @@ -5536,7 +5688,7 @@ function deepClone(from, sub) { return from; } - var idx = ref_list.indexOf(from); + let idx = ref_list.indexOf(from); if (idx >= 0) { throw new Error('[Circular/Xref:' + ref_names[i] + ']'); // circular or cross reference } @@ -5552,7 +5704,7 @@ function deepClone(from, sub) { sub += '.'; var to = new from.constructor(); - for (var name in from) { + for (let name in from) { to[name] = deepClone(from[name], sub + name); } } @@ -5568,8 +5720,9 @@ function transformGrammar(grammar) { return grammar; } + function transform(ebnf) { - var rv = transformGrammar(ebnf); + let rv = transformGrammar(ebnf); return rv; } @@ -5579,7 +5732,6 @@ function transform(ebnf) { // 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. function JisonParserError$1(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -5596,9 +5748,9 @@ function JisonParserError$1(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -5631,10 +5783,10 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp$1(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -5647,11 +5799,11 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -5661,18 +5813,18 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt$1(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -5703,7 +5855,7 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // `this` references an array function s$1(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -5720,9 +5872,9 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$1(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -5735,7 +5887,7 @@ JisonParserError$1.prototype.name = 'JisonParserError'; } -var parser$2 = { +let parser$2 = { // Code Generator Information Report // --------------------------------- // @@ -5971,7 +6123,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -5979,7 +6130,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -5991,8 +6141,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -6005,14 +6155,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -6028,10 +6177,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -6039,10 +6188,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -6223,26 +6372,26 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; switch (yystate) { case 0: /*! Production:: $accept : spec $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break; case 1: /*! Production:: spec : declaration_list "%%" grammar optional_end_block EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4]; @@ -6254,10 +6403,10 @@ case 1: case 2: /*! Production:: spec : declaration_list "%%" grammar error EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6276,10 +6425,10 @@ case 2: case 3: /*! Production:: spec : declaration_list error EOF */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6301,9 +6450,9 @@ case 118: case 133: /*! Production:: optional_module_code_chunk : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -6312,9 +6461,9 @@ case 133: case 5: /*! Production:: optional_end_block : "%%" extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6334,9 +6483,9 @@ case 6: case 10: /*! Production:: declaration_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; @@ -6347,9 +6496,9 @@ case 7: case 8: /*! Production:: optional_action_header_block : optional_action_header_block include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -6368,9 +6517,9 @@ case 8: case 9: /*! Production:: declaration_list : declaration_list declaration */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6379,10 +6528,10 @@ case 9: case 11: /*! Production:: declaration_list : declaration_list error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6397,9 +6546,9 @@ case 11: case 12: /*! Production:: declaration : START id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {start: yyvstack[yysp]}; @@ -6408,9 +6557,9 @@ case 12: case 13: /*! Production:: declaration : LEX_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {lex: {text: yyvstack[yysp], position: yylstack[yysp]}}; @@ -6419,9 +6568,9 @@ case 13: case 14: /*! Production:: declaration : operator */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {operator: yyvstack[yysp]}; @@ -6430,9 +6579,9 @@ case 14: case 15: /*! Production:: declaration : TOKEN full_token_definitions */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {token_list: yyvstack[yysp]}; @@ -6441,9 +6590,9 @@ case 15: case 16: /*! Production:: declaration : ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6461,9 +6610,9 @@ case 16: case 17: /*! Production:: declaration : include_macro_code */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6481,9 +6630,9 @@ case 17: case 18: /*! Production:: declaration : parse_params */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parseParams: yyvstack[yysp]}; @@ -6492,9 +6641,9 @@ case 18: case 19: /*! Production:: declaration : parser_type */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parserType: yyvstack[yysp]}; @@ -6503,9 +6652,9 @@ case 19: case 20: /*! Production:: declaration : options */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: yyvstack[yysp]}; @@ -6514,9 +6663,9 @@ case 20: case 21: /*! Production:: declaration : DEBUG */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: [['debug', true]]}; @@ -6525,9 +6674,9 @@ case 21: case 22: /*! Production:: declaration : EBNF */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) ebnf = true; @@ -6537,9 +6686,9 @@ case 22: case 23: /*! Production:: declaration : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {unknownDecl: yyvstack[yysp]}; @@ -6548,9 +6697,9 @@ case 23: case 24: /*! Production:: declaration : IMPORT import_name import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = {imports: {name: yyvstack[yysp - 1], path: yyvstack[yysp]}}; @@ -6559,10 +6708,10 @@ case 24: case 25: /*! Production:: declaration : IMPORT import_name error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6578,10 +6727,10 @@ case 25: case 26: /*! Production:: declaration : IMPORT error import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6597,9 +6746,9 @@ case 26: case 27: /*! Production:: declaration : INIT_CODE init_code_name action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6622,10 +6771,10 @@ case 27: case 28: /*! Production:: declaration : INIT_CODE error action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6641,10 +6790,10 @@ case 28: case 29: /*! Production:: declaration : START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6659,10 +6808,10 @@ case 29: case 30: /*! Production:: declaration : TOKEN error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6677,10 +6826,10 @@ case 30: case 31: /*! Production:: declaration : IMPORT error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6745,9 +6894,9 @@ case 129: case 132: /*! Production:: optional_module_code_chunk : module_code_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -6758,9 +6907,9 @@ case 39: case 111: /*! Production:: action_ne : "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -6769,10 +6918,10 @@ case 111: case 40: /*! Production:: options : OPTIONS error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6787,10 +6936,10 @@ case 40: case 41: /*! Production:: options : OPTIONS error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6809,9 +6958,9 @@ case 59: case 70: /*! Production:: id_list : id_list id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6826,9 +6975,9 @@ case 71: case 84: /*! Production:: handle_list : handle_action */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -6837,9 +6986,9 @@ case 84: case 44: /*! Production:: option : NAME */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -6848,9 +6997,9 @@ case 44: case 45: /*! Production:: option : NAME "=" OPTION_STRING_VALUE */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -6861,9 +7010,9 @@ case 46: case 47: /*! Production:: option : NAME "=" NAME */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], parseValue(yyvstack[yysp])]; @@ -6872,10 +7021,10 @@ case 47: case 48: /*! Production:: option : NAME "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6890,10 +7039,10 @@ case 48: case 49: /*! Production:: option : NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6910,9 +7059,9 @@ case 50: case 52: /*! Production:: parser_type : PARSER_TYPE symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -6921,10 +7070,10 @@ case 52: case 51: /*! Production:: parse_params : PARSE_PARAM error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6942,10 +7091,10 @@ case 51: case 53: /*! Production:: parser_type : PARSER_TYPE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6963,9 +7112,9 @@ case 53: case 54: /*! Production:: operator : associativity token_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1]]; this.$.push.apply(this.$, yyvstack[yysp]); @@ -6974,10 +7123,10 @@ case 54: case 55: /*! Production:: operator : associativity error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6995,9 +7144,9 @@ case 55: case 56: /*! Production:: associativity : LEFT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'left'; @@ -7006,9 +7155,9 @@ case 56: case 57: /*! Production:: associativity : RIGHT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'right'; @@ -7017,9 +7166,9 @@ case 57: case 58: /*! Production:: associativity : NONASSOC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'nonassoc'; @@ -7028,9 +7177,9 @@ case 58: case 61: /*! Production:: full_token_definitions : optional_token_type id_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var rv = []; @@ -7049,9 +7198,9 @@ case 61: case 62: /*! Production:: full_token_definitions : optional_token_type one_full_token */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var m = yyvstack[yysp]; @@ -7064,9 +7213,9 @@ case 62: case 63: /*! Production:: one_full_token : id token_value token_description */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -7079,9 +7228,9 @@ case 63: case 64: /*! Production:: one_full_token : id token_description */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -7093,9 +7242,9 @@ case 64: case 65: /*! Production:: one_full_token : id token_value */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -7107,9 +7256,9 @@ case 65: case 66: /*! Production:: optional_token_type : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = false; @@ -7118,9 +7267,9 @@ case 66: case 72: /*! Production:: grammar : optional_action_header_block production_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -7130,9 +7279,9 @@ case 72: case 73: /*! Production:: production_list : production_list production */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -7146,9 +7295,9 @@ case 73: case 74: /*! Production:: production_list : production */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; this.$[yyvstack[yysp][0]] = yyvstack[yysp][1]; @@ -7157,9 +7306,9 @@ case 74: case 75: /*! Production:: production : production_id handle_list ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp - 1]]; @@ -7168,10 +7317,10 @@ case 75: case 76: /*! Production:: production : production_id error ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7189,10 +7338,10 @@ case 76: case 77: /*! Production:: production : production_id error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7210,9 +7359,9 @@ case 77: case 78: /*! Production:: production_id : id optional_production_description ":" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -7223,10 +7372,10 @@ case 78: case 79: /*! Production:: production_id : id optional_production_description error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7244,10 +7393,10 @@ case 79: case 80: /*! Production:: production_id : id optional_production_description ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7271,18 +7420,18 @@ case 80: case 82: /*! Production:: optional_production_description : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) break; case 83: /*! Production:: handle_list : handle_list "|" handle_action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -7292,10 +7441,10 @@ case 83: case 85: /*! Production:: handle_list : handle_list "|" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7313,10 +7462,10 @@ case 85: case 86: /*! Production:: handle_list : handle_list ":" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7331,9 +7480,9 @@ case 86: case 87: /*! Production:: handle_action : handle prec action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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(' ') : '')]; @@ -7368,9 +7517,9 @@ case 87: case 88: /*! Production:: handle_action : EPSILON action */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = ['']; @@ -7394,10 +7543,10 @@ case 88: case 89: /*! Production:: handle_action : EPSILON error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7412,9 +7561,9 @@ case 89: case 90: /*! Production:: handle : handle suffixed_expression */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -7424,9 +7573,9 @@ case 90: case 91: /*! Production:: handle : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -7435,9 +7584,9 @@ case 91: case 92: /*! Production:: handle_sublist : handle_sublist "|" handle */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -7447,9 +7596,9 @@ case 92: case 93: /*! Production:: handle_sublist : handle */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp].join(' ')]; @@ -7458,9 +7607,9 @@ case 93: case 94: /*! Production:: suffixed_expression : expression suffix ALIAS */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + "[" + yyvstack[yysp] + "]"; @@ -7473,9 +7622,9 @@ case 124: case 130: /*! Production:: module_code_chunk : module_code_chunk CODE */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -7484,9 +7633,9 @@ case 130: case 97: /*! Production:: expression : EOF_ID */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$end'; @@ -7495,9 +7644,9 @@ case 97: case 98: /*! Production:: expression : STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // Re-encode the string *anyway* as it will @@ -7510,9 +7659,9 @@ case 98: case 99: /*! Production:: expression : "(" handle_sublist ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1].join(' | ') + ')'; @@ -7521,10 +7670,10 @@ case 99: case 100: /*! Production:: expression : "(" handle_sublist error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -7538,9 +7687,9 @@ case 100: case 105: /*! Production:: prec : PREC symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { prec: yyvstack[yysp] }; @@ -7549,10 +7698,10 @@ case 105: case 106: /*! Production:: prec : PREC error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7570,9 +7719,9 @@ case 106: case 107: /*! Production:: prec : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = null; @@ -7581,10 +7730,10 @@ case 107: case 112: /*! Production:: action_ne : "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -7598,9 +7747,9 @@ case 112: case 116: /*! Production:: action : ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$$ = (' + yyvstack[yysp] + ');'; @@ -7609,9 +7758,9 @@ case 116: case 120: /*! Production:: action_body : action_body "{" action_body "}" action_comments_body */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4] + yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -7620,9 +7769,9 @@ case 120: case 121: /*! Production:: action_body : action_body "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -7631,10 +7780,10 @@ case 121: case 122: /*! Production:: action_body : action_body "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -7648,9 +7797,9 @@ case 122: case 126: /*! Production:: extra_parser_module_code : optional_module_code_chunk include_macro_code extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -7659,9 +7808,9 @@ case 126: case 127: /*! Production:: include_macro_code : INCLUDE PATH */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' }); @@ -7681,10 +7830,10 @@ case 127: case 128: /*! Production:: include_macro_code : INCLUDE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -7697,10 +7846,10 @@ case 128: case 131: /*! Production:: module_code_chunk : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -9093,7 +9242,6 @@ defaultActions: bda({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -9110,59 +9258,53 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, parser: undefined, pre_parse: undefined, post_parse: undefined, - pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! - }; - - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + pre_lex: undefined, + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! + }; + + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -9184,7 +9326,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -9192,18 +9333,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -9211,24 +9353,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -9266,18 +9403,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -9298,7 +9432,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -9316,7 +9450,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -9329,7 +9462,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -9343,11 +9475,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -9401,8 +9532,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -9410,8 +9541,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -9443,19 +9574,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -9466,7 +9596,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -9479,7 +9609,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -9491,29 +9621,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -9521,7 +9649,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -9541,8 +9669,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -9551,10 +9678,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -9562,7 +9689,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -9573,9 +9700,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -9591,8 +9723,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -9661,11 +9792,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -9676,8 +9810,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -9686,21 +9819,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -9710,21 +9842,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -9733,28 +9864,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -9767,8 +9897,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -9791,8 +9920,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -9804,8 +9932,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -9822,8 +9949,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -9837,8 +9963,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -9852,7 +9977,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -9905,16 +10030,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -9948,9 +10070,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -9973,9 +10093,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -10002,17 +10120,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -10059,8 +10176,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -10072,8 +10189,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -10091,6 +10207,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -10099,7 +10216,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -10110,7 +10227,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -10170,10 +10287,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -10208,9 +10325,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -10223,7 +10338,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -10244,9 +10359,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -10268,12 +10381,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -10282,7 +10395,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -10323,7 +10436,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -10370,7 +10483,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -10388,21 +10501,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -10436,14 +10547,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -10453,6 +10565,7 @@ parse: function parse(input) { + } continue; // accept: @@ -10504,7 +10617,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -10520,9 +10633,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -10551,7 +10662,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -10568,8 +10679,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -10580,8 +10691,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -10593,21 +10704,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -10638,14 +10747,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -10655,6 +10765,7 @@ parse: function parse(input) { + } continue; // accept: @@ -10707,8 +10818,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -10969,7 +11079,6 @@ var lexer$1 = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -10986,10 +11095,10 @@ var lexer$1 = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -11021,7 +11130,7 @@ var lexer$1 = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -11063,7 +11172,9 @@ var lexer$1 = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -11149,7 +11260,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -11157,7 +11268,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -11170,7 +11281,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -11196,10 +11307,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -11222,7 +11336,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -11245,16 +11358,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -11276,7 +11389,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -11284,8 +11396,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -11314,7 +11426,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -11339,7 +11451,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -11351,17 +11463,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -11455,7 +11567,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -11476,7 +11588,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -11487,7 +11598,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -11498,15 +11609,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -11540,8 +11651,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -11574,9 +11685,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -11595,9 +11706,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -11607,8 +11718,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -11635,20 +11746,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -11688,17 +11798,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -11707,7 +11819,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -11722,8 +11834,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -11749,24 +11861,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -11777,7 +11891,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -11799,8 +11913,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -11822,8 +11936,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -11967,21 +12080,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -11996,11 +12109,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -12019,13 +12132,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -12049,13 +12162,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -12070,8 +12183,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -12102,7 +12215,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -12134,9 +12247,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -12165,7 +12278,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -12183,7 +12296,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -12208,7 +12321,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -12218,8 +12330,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -12228,7 +12338,7 @@ EOF: 1, this.clear(); } - 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. @@ -12240,13 +12350,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -12256,68 +12366,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -12342,7 +12458,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -12390,24 +12506,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -12427,7 +12543,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -12437,24 +12553,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -12475,8 +12591,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -12516,14 +12631,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -12539,9 +12654,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -12552,8 +12667,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -12561,7 +12676,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -13611,7 +13726,6 @@ var bnf = { // 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. function JisonParserError$2(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -13628,9 +13742,9 @@ function JisonParserError$2(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -13663,10 +13777,10 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp$2(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -13679,11 +13793,11 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda$1(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -13693,18 +13807,18 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt$2(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -13735,7 +13849,7 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // `this` references an array function s$2(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -13752,9 +13866,9 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$2(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -13767,7 +13881,7 @@ JisonParserError$2.prototype.name = 'JisonParserError'; } -var parser$3 = { +let parser$3 = { // Code Generator Information Report // --------------------------------- // @@ -14017,7 +14131,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -14025,7 +14138,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -14037,8 +14149,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -14051,14 +14163,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -14074,10 +14185,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -14085,10 +14196,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -14243,9 +14354,9 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -14257,18 +14368,18 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -14298,9 +14409,9 @@ case 1: case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -14313,10 +14424,10 @@ case 2: case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14343,9 +14454,9 @@ case 3: case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -14354,10 +14465,10 @@ case 4: case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14385,9 +14496,9 @@ case 5: case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -14396,10 +14507,10 @@ case 6: case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -14438,9 +14549,9 @@ case 7: case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -14505,9 +14616,9 @@ case 8: case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -14522,9 +14633,9 @@ case 9: case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -14559,10 +14670,10 @@ case 10: case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14579,9 +14690,9 @@ case 11: case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -14598,10 +14709,10 @@ case 12: case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14618,9 +14729,9 @@ case 13: case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -14637,10 +14748,10 @@ case 14: case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14657,9 +14768,9 @@ case 15: case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -14683,9 +14794,9 @@ case 17: case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -14696,9 +14807,9 @@ case 132: case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -14718,9 +14829,9 @@ case 18: case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -14744,9 +14855,9 @@ case 19: case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -14759,10 +14870,10 @@ case 20: case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14779,9 +14890,9 @@ case 21: case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -14793,9 +14904,9 @@ case 22: case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -14835,10 +14946,10 @@ case 23: case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14858,9 +14969,9 @@ case 24: case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -14910,10 +15021,10 @@ case 25: case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -14937,10 +15048,10 @@ case 26: case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14960,10 +15071,10 @@ case 27: case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14987,10 +15098,10 @@ case 28: case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15011,10 +15122,10 @@ case 29: case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -15026,10 +15137,10 @@ case 31: case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -15039,10 +15150,10 @@ case 33: case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -15052,10 +15163,10 @@ case 32: case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -15065,10 +15176,10 @@ case 34: case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -15078,10 +15189,10 @@ case 35: case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -15091,10 +15202,10 @@ case 36: case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -15104,10 +15215,10 @@ case 37: case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -15117,9 +15228,9 @@ case 38: case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -15128,9 +15239,9 @@ case 39: case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -15139,9 +15250,9 @@ case 40: case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -15163,9 +15274,9 @@ case 41: case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -15176,9 +15287,9 @@ case 42: case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -15198,9 +15309,9 @@ case 43: case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -15254,9 +15365,9 @@ case 49: case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15276,9 +15387,9 @@ case 51: case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -15287,9 +15398,9 @@ case 58: case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -15301,9 +15412,9 @@ case 52: case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -15317,10 +15428,10 @@ case 53: case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15340,10 +15451,10 @@ case 54: case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15363,10 +15474,10 @@ case 55: case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15386,9 +15497,9 @@ case 56: case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -15399,9 +15510,9 @@ case 59: case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -15420,9 +15531,9 @@ case 60: case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -15463,9 +15574,9 @@ case 61: case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -15489,9 +15600,9 @@ case 62: case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -15517,9 +15628,9 @@ case 63: case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -15564,9 +15675,9 @@ case 64: case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -15592,9 +15703,9 @@ case 106: case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -15603,9 +15714,9 @@ case 127: case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -15614,10 +15725,10 @@ case 67: case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15631,10 +15742,10 @@ case 68: case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15648,10 +15759,10 @@ case 69: case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15665,10 +15776,10 @@ case 70: case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15687,9 +15798,9 @@ case 72: case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -15698,9 +15809,9 @@ case 77: case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -15738,10 +15849,10 @@ case 73: case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -15765,9 +15876,9 @@ case 74: case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -15846,9 +15957,9 @@ case 110: case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -15857,9 +15968,9 @@ case 129: case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -15868,9 +15979,9 @@ case 78: case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -15879,9 +15990,9 @@ case 79: case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -15890,9 +16001,9 @@ case 80: case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -15901,9 +16012,9 @@ case 81: case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -15912,9 +16023,9 @@ case 85: case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -15925,10 +16036,10 @@ case 87: case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15945,9 +16056,9 @@ case 88: case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -15956,9 +16067,9 @@ case 89: case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -15967,9 +16078,9 @@ case 90: case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -15978,9 +16089,9 @@ case 91: case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -15989,9 +16100,9 @@ case 92: case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -16010,18 +16121,18 @@ case 107: case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -16030,9 +16141,9 @@ case 97: case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -16041,9 +16152,9 @@ case 98: case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -16052,9 +16163,9 @@ case 99: case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -16063,9 +16174,9 @@ case 102: case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -16074,10 +16185,10 @@ case 104: case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -16094,9 +16205,9 @@ case 105: case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -16113,9 +16224,9 @@ case 109: case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -16127,9 +16238,9 @@ case 111: case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -16139,9 +16250,9 @@ case 112: case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -16176,9 +16287,9 @@ case 113: case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -16197,9 +16308,9 @@ case 114: case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -16208,9 +16319,9 @@ case 115: case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -16219,9 +16330,9 @@ case 116: case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -16239,10 +16350,10 @@ case 117: case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -16260,10 +16371,10 @@ case 118: case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -16284,9 +16395,9 @@ case 119: case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -16319,9 +16430,9 @@ case 120: case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -16347,9 +16458,9 @@ case 121: case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5__default['default'].parse(yyvstack[yysp]); @@ -16358,9 +16469,9 @@ case 122: case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue$1(yyvstack[yysp]); @@ -16369,9 +16480,9 @@ case 123: case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -16380,9 +16491,9 @@ case 124: case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -16403,10 +16514,10 @@ case 125: case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -16423,9 +16534,9 @@ case 126: case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -16444,9 +16555,9 @@ case 128: case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -16470,9 +16581,9 @@ case 130: case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -16492,9 +16603,9 @@ case 131: case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -16505,9 +16616,9 @@ case 133: case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -16563,10 +16674,10 @@ case 134: case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -18169,7 +18280,6 @@ defaultActions: bda$1({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -18186,38 +18296,34 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -18225,20 +18331,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -18260,7 +18364,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -18268,18 +18371,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -18287,24 +18391,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -18342,18 +18441,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -18374,7 +18470,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -18392,7 +18488,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -18405,7 +18500,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -18419,11 +18513,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -18477,8 +18570,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -18486,8 +18579,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -18519,19 +18612,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -18542,7 +18634,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -18555,7 +18647,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -18567,29 +18659,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -18597,7 +18687,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -18617,8 +18707,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -18627,10 +18716,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -18638,7 +18727,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -18649,9 +18738,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -18667,8 +18761,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -18737,11 +18830,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -18752,8 +18848,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -18762,21 +18857,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -18786,21 +18880,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -18809,28 +18902,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -18843,8 +18935,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -18867,8 +18958,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -18880,8 +18970,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -18898,8 +18987,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -18913,8 +19001,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -18928,7 +19015,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -18981,16 +19068,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -19024,9 +19108,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -19049,9 +19131,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -19078,17 +19158,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -19135,8 +19214,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -19148,8 +19227,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -19167,6 +19245,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -19175,7 +19254,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -19186,7 +19265,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -19246,10 +19325,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -19284,9 +19363,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -19299,7 +19376,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -19320,9 +19397,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -19344,12 +19419,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -19358,7 +19433,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -19399,7 +19474,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -19446,7 +19521,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -19464,21 +19539,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -19512,14 +19585,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -19529,6 +19603,7 @@ parse: function parse(input) { + } continue; // accept: @@ -19580,7 +19655,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -19596,9 +19671,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -19627,7 +19700,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -19644,8 +19717,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -19656,8 +19729,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -19669,21 +19742,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -19714,14 +19785,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -19731,6 +19803,7 @@ parse: function parse(input) { + } continue; // accept: @@ -19783,8 +19856,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -20045,7 +20117,6 @@ var lexer$2 = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -20062,10 +20133,10 @@ var lexer$2 = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -20097,7 +20168,7 @@ var lexer$2 = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -20139,7 +20210,9 @@ var lexer$2 = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -20225,7 +20298,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -20233,7 +20306,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -20246,7 +20319,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -20272,10 +20345,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -20298,7 +20374,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -20321,16 +20396,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -20352,7 +20427,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -20360,8 +20434,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -20390,7 +20464,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -20415,7 +20489,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -20427,17 +20501,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -20531,7 +20605,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -20552,7 +20626,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -20563,7 +20636,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -20574,15 +20647,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -20616,8 +20689,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -20650,9 +20723,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -20671,9 +20744,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -20683,8 +20756,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -20711,20 +20784,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -20764,17 +20836,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -20783,7 +20857,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -20798,8 +20872,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -20825,24 +20899,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -20853,7 +20929,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -20875,8 +20951,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -20898,8 +20974,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -21043,21 +21118,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -21072,11 +21147,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -21095,13 +21170,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -21125,13 +21200,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -21146,8 +21221,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -21178,7 +21253,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -21210,9 +21285,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -21241,7 +21316,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -21259,7 +21334,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -21284,7 +21359,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -21294,8 +21368,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -21304,7 +21376,7 @@ EOF: 1, this.clear(); } - 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. @@ -21316,13 +21388,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -21332,68 +21404,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -21418,7 +21496,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -21466,24 +21544,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -21503,7 +21581,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -21513,24 +21591,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -21551,8 +21629,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -21592,14 +21669,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -21615,9 +21692,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -21628,8 +21705,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -21637,7 +21714,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -23311,7 +23388,7 @@ var jisonlex = { }; -var version = '0.6.2-220'; // require('./package.json').version; +const version = '0.6.2-220'; // require('./package.json').version; function parse(grammar) { return bnf.parser.parse(grammar); @@ -23377,7 +23454,7 @@ bnf.parser.yy.addDeclaration = function bnfAddDeclaration(grammar, decl) { if (decl.options) { if (!grammar.options) grammar.options = {}; // last occurrence of `%options` wins: - for (var i = 0; i < decl.options.length; i++) { + for (let i = 0; i < decl.options.length; i++) { grammar.options[decl.options[i][0]] = decl.options[i][1]; } } @@ -23417,9 +23494,9 @@ function parseLex(text, position) { // which matches the original input file: position = position || {}; position.range = position.range || []; - var l = position.first_line | 0; - var c = position.range[0] | 0; - var prelude = ''; + let l = position.first_line | 0; + let c = position.range[0] | 0; + let prelude = ''; if (l > 1) { prelude += (new Array(l)).join('\n'); c -= prelude.length; @@ -23444,7 +23521,7 @@ var ebnfParser = { ebnf_parser, bnf_lexer: jisonlex, - version, + version }; module.exports = ebnfParser; diff --git a/packages/ebnf-parser/dist/ebnf-parser-es6.js b/packages/ebnf-parser/dist/ebnf-parser-es6.js index 0401f74c9..01ae6be62 100644 --- a/packages/ebnf-parser/dist/ebnf-parser-es6.js +++ b/packages/ebnf-parser/dist/ebnf-parser-es6.js @@ -2,11 +2,12 @@ import XRegExp from '@gerhobbelt/xregexp'; import fs from 'fs'; import path$1 from 'path'; import JSON5 from '@gerhobbelt/json5'; +import mkdirp from 'mkdirp'; import recast from 'recast'; import { transformSync } from '@babel/core'; import assert$1 from 'assert'; -// Return TRUE if `src` starts with `searchString`. +// Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -29,19 +30,19 @@ function rmCommonWS(strings, ...values) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -60,19 +61,21 @@ function rmCommonWS(strings, ...values) { // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -81,16 +84,19 @@ function rmCommonWS(strings, ...values) { } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -101,27 +107,79 @@ function camelCase(s) { return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } +// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; +})([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' +]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -139,6 +197,11 @@ function mkIdentifier(s) { .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -147,13 +210,13 @@ function mkIdentifier(s) { function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -164,23 +227,17 @@ function scanRegExp(s) { break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -203,34 +260,33 @@ function isLineTerminator(cp) { /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -253,28 +309,76 @@ function chkBugger(src) { // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } +function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; +} + + +function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); +} + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path$1.dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path$1.basename(options.inputFilename || options.moduleName || (options.outfile ? path$1.dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path$1.dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path$1.basename(options.inputFilename || options.moduleName || (options.outfile ? path$1.dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -285,27 +389,37 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path$1.normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path$1.normalize(path$1.join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5.stringify(dump, null, 2); + let d = JSON5.stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp(path$1.dirname(dumpfile)); fs.writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -315,7 +429,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -323,7 +437,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -349,27 +463,43 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -382,9 +512,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -406,22 +537,22 @@ assert$1(recast); // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; -// Determine which Unicode NonAsciiIdentifierStart characters +// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -429,40 +560,40 @@ const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -470,30 +601,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -504,59 +635,59 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -598,38 +729,38 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -641,18 +772,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -663,56 +794,56 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -720,97 +851,97 @@ function generateMapper4JisonGrammarIdentifiers(input) { typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp(`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp(`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp(`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp(`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp(`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp(`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp(`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp(`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp(`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp(`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp(`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -818,7 +949,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -831,7 +962,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -844,7 +975,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -857,7 +988,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -876,37 +1007,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -938,7 +1069,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -955,37 +1086,37 @@ function parseCodeChunkToAST(src, options) { .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast.parse(src); + const ast = recast.parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return transformSync(src, options); // => { code, map, ast } @@ -993,8 +1124,8 @@ function compileCodeToES5(src, options) { function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1003,7 +1134,7 @@ function prettyPrintAST(ast, options) { // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1026,25 +1157,25 @@ function prettyPrintAST(ast, options) { // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1055,9 +1186,9 @@ function checkActionBlock(src, yylloc, options) { // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1065,7 +1196,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1074,14 +1205,14 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1135,7 +1266,7 @@ var parse2AST = { trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1149,7 +1280,7 @@ function chkBugger$1(src) { /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1161,24 +1292,24 @@ const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?: /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1195,8 +1326,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1207,14 +1338,14 @@ function printFunctionSourceCodeContainer(f) { action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1225,17 +1356,17 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; -// -// -// +// +// +// function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1261,7 +1392,7 @@ function detectIstanbulGlobal() { // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1309,7 +1440,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1372,13 +1503,13 @@ var reHelpers = { getRegExpInfo: getRegExpInfo }; -var cycleref = []; -var cyclerefpath = []; +let cycleref = []; +let cyclerefpath = []; -var linkref = []; -var linkrefpath = []; +let linkref = []; +let linkrefpath = []; -var path = []; +let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1386,14 +1517,14 @@ function shallow_copy(src) { return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1406,11 +1537,11 @@ function shallow_copy(src) { function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1423,9 +1554,9 @@ function shallow_copy_and_strip_depth(src, parentKey) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1440,16 +1571,52 @@ function shallow_copy_and_strip_depth(src, parentKey) { } +// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } +// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; +} + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1464,7 +1631,7 @@ function trim_array_tail(arr) { function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1490,10 +1657,10 @@ function treat_value_stack(v) { } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1591,7 +1758,7 @@ function treat_hash(h) { function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1608,7 +1775,7 @@ function treat_error_report_info(e) { path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1636,7 +1803,7 @@ function treat_error_report_info(e) { function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1652,7 +1819,7 @@ function treat_object(e) { linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1664,14 +1831,14 @@ function treat_object(e) { // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1681,7 +1848,7 @@ function trimErrorForTestReporting(e) { cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1695,12 +1862,14 @@ var helpers = { dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1715,7 +1884,7 @@ var helpers = { printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; // See also: @@ -1723,7 +1892,6 @@ var helpers = { // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1740,9 +1908,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -1775,10 +1943,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -1793,18 +1961,18 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -1835,7 +2003,7 @@ JisonParserError.prototype.name = 'JisonParserError'; // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -1852,9 +2020,9 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -1867,7 +2035,7 @@ JisonParserError.prototype.name = 'JisonParserError'; } -var parser = { +let parser = { // Code Generator Information Report // --------------------------------- // @@ -1993,7 +2161,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2001,7 +2168,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2013,8 +2179,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2027,14 +2193,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2050,10 +2215,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2061,10 +2226,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2108,9 +2273,9 @@ performAction: function parser__PerformAction(yystate /* action[1] */, yysp, yyv /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; @@ -2118,17 +2283,17 @@ performAction: function parser__PerformAction(yystate /* action[1] */, yysp, yyv case 0: /*! Production:: $accept : production $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-) break; case 1: /*! Production:: production : handle EOF */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-) return yyvstack[yysp - 1]; @@ -2364,7 +2529,6 @@ defaultActions: { 19: 3 }, parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -2381,37 +2545,32 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) + let vstack = new Array(128); // semantic value stack - var vstack = new Array(128); // semantic value stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks + let symbol = 0; - - - - var symbol = 0; + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -2419,20 +2578,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -2449,7 +2606,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -2457,18 +2613,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -2476,18 +2633,14 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -2509,7 +2662,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -2522,7 +2674,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -2536,11 +2687,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -2594,8 +2744,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -2744,8 +2894,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -2754,10 +2903,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -2765,7 +2914,7 @@ parse: function parse(input) { stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -2776,9 +2925,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -2804,8 +2958,7 @@ parse: function parse(input) { function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -2814,21 +2967,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -2838,21 +2990,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -2861,20 +3012,20 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; try { @@ -2887,7 +3038,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -2940,14 +3091,11 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { - var errStr; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let errStr; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); // Report error errStr = 'Parse error'; @@ -2984,9 +3132,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -3015,7 +3161,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -3057,21 +3203,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, newState, sp - 1, vstack); +r = this.performAction.call(yyval, newState, sp - 1, vstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -3102,14 +3246,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -3119,6 +3264,7 @@ parse: function parse(input) { + } continue; // accept: @@ -3171,8 +3317,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -3432,7 +3577,6 @@ var lexer = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -3449,10 +3593,10 @@ var lexer = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -3484,7 +3628,7 @@ var lexer = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -3526,7 +3670,9 @@ var lexer = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -3612,7 +3758,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -3620,7 +3766,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -3633,7 +3779,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -3659,10 +3805,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -3685,7 +3834,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -3708,16 +3856,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -3739,7 +3887,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -3747,8 +3894,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -3777,7 +3924,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -3802,7 +3949,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -3814,17 +3961,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -3918,7 +4065,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -3939,7 +4086,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -3950,7 +4096,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -3961,15 +4107,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -4003,8 +4149,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -4037,9 +4183,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -4058,9 +4204,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -4070,8 +4216,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -4098,20 +4244,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -4151,17 +4296,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -4170,7 +4317,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -4185,8 +4332,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -4212,24 +4359,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -4240,7 +4389,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -4262,8 +4411,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -4285,8 +4434,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -4430,21 +4578,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -4459,11 +4607,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -4482,13 +4630,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -4512,13 +4660,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -4533,8 +4681,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -4565,7 +4713,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -4597,9 +4745,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -4628,7 +4776,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -4646,7 +4794,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -4671,7 +4819,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -4681,8 +4828,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -4691,7 +4836,7 @@ EOF: 1, this.clear(); } - 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. @@ -4703,13 +4848,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -4719,68 +4864,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -4805,7 +4956,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -4853,24 +5004,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -4890,7 +5041,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -4900,24 +5051,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -4938,8 +5089,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -4979,14 +5129,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -5002,9 +5152,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -5015,8 +5165,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -5024,7 +5174,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -5177,9 +5327,9 @@ const ID_REGEX_BASE$1 = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // guaranteed not to collide with previously generated / already existing // rules (~ symbols). function generateUniqueSymbol(id, postfix, opts) { - var sym = id + postfix; + let sym = id + postfix; if (opts.grammar[sym]) { - var i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. + let i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. do { sym = id + postfix + i; i++; @@ -5189,8 +5339,8 @@ function generateUniqueSymbol(id, postfix, opts) { } function generatePushAction(handle, offset) { - var terms = handle.terms; - var rv = []; + const terms = handle.terms; + let rv = []; for (var i = 0, len = terms.length; i < len; i++) { rv.push('$' + (i + offset)); @@ -5206,11 +5356,11 @@ function generatePushAction(handle, offset) { } function transformExpression(e, opts, emit) { - var type = e[0], - value = e[1], - name = false, - has_transformed = 0; - var list, n; + let type = e[0]; + let value = e[1]; + let name = false; + let has_transformed = 0; + let list, n; if (type === 'xalias') { type = e[1]; @@ -5237,7 +5387,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ list.fragment, @@ -5257,7 +5407,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ '', @@ -5277,7 +5427,7 @@ function transformExpression(e, opts, emit) { has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); // you want to be able to check if 0 or 1 occurrences were recognized: since jison // by default *copies* the lexer token value, i.e. `$$ = $1` is the (optional) default action, // we will need to set the action up explicitly in case of the 0-count match: @@ -5313,7 +5463,7 @@ function transformExpression(e, opts, emit) { opts = optsForProduction(name, opts.grammar); opts.grammar[name] = value.map(function (handle) { - var list = transformExpressionList(handle, opts); + let list = transformExpressionList(handle, opts); return [ list.fragment, '$$ = ' + generatePushAction(list, 1) + ';' @@ -5326,11 +5476,11 @@ function transformExpression(e, opts, emit) { } function transformExpressionList(list, opts) { - var first_transformed_term_index = false; - var terms = list.reduce(function (tot, e) { - var ci = tot.length; + let first_transformed_term_index = false; + let terms = list.reduce(function (tot, e) { + let ci = tot.length; - var has_transformed = transformExpression(e, opts, function (name) { + let has_transformed = transformExpression(e, opts, function (name) { if (name.terms) { tot.push.apply(tot, name.terms); } else { @@ -5359,42 +5509,42 @@ function optsForProduction(id, grammar) { } function transformProduction(id, production, grammar) { - var transform_opts = optsForProduction(id, grammar); + let transform_opts = optsForProduction(id, grammar); return production.map(function (handle) { - var action = null, - opts = null; - var i, len, n; + let action = null; + let opts = null; + let i, len, n; if (typeof handle !== 'string') { action = handle[1]; opts = handle[2]; handle = handle[0]; } - var expressions = handle; + let expressions = handle; if (typeof expressions === 'string') { expressions = parser$1.parse(handle); } - var list = transformExpressionList(expressions, transform_opts); + let list = transformExpressionList(expressions, transform_opts); - var ret = [list.fragment]; + let ret = [ list.fragment ]; if (action) { // make sure the action doesn't address any inner items. if (list.first_transformed_term_index) { // seek out all names and aliases; strip out literal tokens first as those cannot serve as $names: - var alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); + let alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); - var alias_re = new XRegExp(`\\[${ID_REGEX_BASE$1}\\]`); - var term_re = new XRegExp(`^${ID_REGEX_BASE$1}$`); + let alias_re = new XRegExp(`\\[${ID_REGEX_BASE$1}\\]`); + let term_re = new XRegExp(`^${ID_REGEX_BASE$1}$`); // and collect the PERMITTED aliases: the names of the terms and all the remaining aliases - var good_aliases = {}; - var alias_cnt = {}; - var donotalias = {}; + let good_aliases = {}; + let alias_cnt = {}; + let donotalias = {}; // WARNING: this replicates the knowledge/code of jison.js::addName() - var addName = function addNameEBNF(s, i) { - var base = s.replace(/[0-9]+$/, ''); - var dna = donotalias[base]; + let addName = function addNameEBNF(s, i) { + let base = s.replace(/[0-9]+$/, ''); + let dna = donotalias[base]; if (good_aliases[s]) { alias_cnt[s]++; @@ -5413,7 +5563,7 @@ function transformProduction(id, production, grammar) { }; // WARNING: this replicates the knowledge/code of jison.js::markBasename() - var markBasename = function markBasenameEBNF(s) { + let markBasename = function markBasenameEBNF(s) { if (/[0-9]$/.test(s)) { s = s.replace(/[0-9]+$/, ''); donotalias[s] = true; @@ -5450,13 +5600,13 @@ function transformProduction(id, production, grammar) { // now scan the action for all named and numeric semantic values ($nonterminal / $1 / @1, ##1, ...) // // Note that `#name` are straight **static** symbol translations, which are okay as they don't - // require access to the parse stack: `#n` references can be resolved completely + // require access to the parse stack: `#n` references can be resolved completely // at grammar compile time. // - var nameref_re = new XRegExp(`(?:[$@]|##)${ID_REGEX_BASE$1}`, 'g'); - var named_spots = nameref_re.exec(action); - var numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); - var max_term_index = list.terms.length; + let nameref_re = new XRegExp(`(?:[$@]|##)${ID_REGEX_BASE$1}`, 'g'); + let named_spots = nameref_re.exec(action); + let numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); + let max_term_index = list.terms.length; // loop through the XRegExp alias regex matches in `action` while (named_spots) { @@ -5486,7 +5636,7 @@ function transformProduction(id, production, grammar) { for (i = 0, len = numbered_spots.length; i < len; i++) { n = parseInt(numbered_spots[i].replace(/^(?:[$@]|##)/, '')); if (n > max_term_index) { - /* @const */ var n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; + /* @const */ let n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; throw new Error('The action block references the ' + n + n_suffixes[Math.max(0, Math.min(3, n - 1))] + ' term, ' + 'which is not available in production "' + handle + '"; ' + 'Be reminded that you cannot reference sub-elements within EBNF */+/? groups, ' + @@ -5504,13 +5654,14 @@ function transformProduction(id, production, grammar) { if (ret.length === 1) { return ret[0]; - } else { - return ret; } + return ret; + }); } -var ref_list; -var ref_names; + +let ref_list; +let ref_names; // create a deep copy of the input, so we will keep the input constant. function deepClone(from, sub) { @@ -5525,7 +5676,7 @@ function deepClone(from, sub) { return from; } - var idx = ref_list.indexOf(from); + let idx = ref_list.indexOf(from); if (idx >= 0) { throw new Error('[Circular/Xref:' + ref_names[i] + ']'); // circular or cross reference } @@ -5541,7 +5692,7 @@ function deepClone(from, sub) { sub += '.'; var to = new from.constructor(); - for (var name in from) { + for (let name in from) { to[name] = deepClone(from[name], sub + name); } } @@ -5557,8 +5708,9 @@ function transformGrammar(grammar) { return grammar; } + function transform(ebnf) { - var rv = transformGrammar(ebnf); + let rv = transformGrammar(ebnf); return rv; } @@ -5568,7 +5720,6 @@ function transform(ebnf) { // 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. function JisonParserError$1(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -5585,9 +5736,9 @@ function JisonParserError$1(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -5620,10 +5771,10 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp$1(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -5636,11 +5787,11 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -5650,18 +5801,18 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt$1(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -5692,7 +5843,7 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // `this` references an array function s$1(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -5709,9 +5860,9 @@ JisonParserError$1.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$1(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -5724,7 +5875,7 @@ JisonParserError$1.prototype.name = 'JisonParserError'; } -var parser$2 = { +let parser$2 = { // Code Generator Information Report // --------------------------------- // @@ -5960,7 +6111,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -5968,7 +6118,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -5980,8 +6129,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -5994,14 +6143,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -6017,10 +6165,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -6028,10 +6176,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -6212,26 +6360,26 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; switch (yystate) { case 0: /*! Production:: $accept : spec $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break; case 1: /*! Production:: spec : declaration_list "%%" grammar optional_end_block EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4]; @@ -6243,10 +6391,10 @@ case 1: case 2: /*! Production:: spec : declaration_list "%%" grammar error EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6265,10 +6413,10 @@ case 2: case 3: /*! Production:: spec : declaration_list error EOF */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6290,9 +6438,9 @@ case 118: case 133: /*! Production:: optional_module_code_chunk : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -6301,9 +6449,9 @@ case 133: case 5: /*! Production:: optional_end_block : "%%" extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6323,9 +6471,9 @@ case 6: case 10: /*! Production:: declaration_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; @@ -6336,9 +6484,9 @@ case 7: case 8: /*! Production:: optional_action_header_block : optional_action_header_block include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -6357,9 +6505,9 @@ case 8: case 9: /*! Production:: declaration_list : declaration_list declaration */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6368,10 +6516,10 @@ case 9: case 11: /*! Production:: declaration_list : declaration_list error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6386,9 +6534,9 @@ case 11: case 12: /*! Production:: declaration : START id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {start: yyvstack[yysp]}; @@ -6397,9 +6545,9 @@ case 12: case 13: /*! Production:: declaration : LEX_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {lex: {text: yyvstack[yysp], position: yylstack[yysp]}}; @@ -6408,9 +6556,9 @@ case 13: case 14: /*! Production:: declaration : operator */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {operator: yyvstack[yysp]}; @@ -6419,9 +6567,9 @@ case 14: case 15: /*! Production:: declaration : TOKEN full_token_definitions */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {token_list: yyvstack[yysp]}; @@ -6430,9 +6578,9 @@ case 15: case 16: /*! Production:: declaration : ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6450,9 +6598,9 @@ case 16: case 17: /*! Production:: declaration : include_macro_code */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6470,9 +6618,9 @@ case 17: case 18: /*! Production:: declaration : parse_params */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parseParams: yyvstack[yysp]}; @@ -6481,9 +6629,9 @@ case 18: case 19: /*! Production:: declaration : parser_type */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parserType: yyvstack[yysp]}; @@ -6492,9 +6640,9 @@ case 19: case 20: /*! Production:: declaration : options */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: yyvstack[yysp]}; @@ -6503,9 +6651,9 @@ case 20: case 21: /*! Production:: declaration : DEBUG */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: [['debug', true]]}; @@ -6514,9 +6662,9 @@ case 21: case 22: /*! Production:: declaration : EBNF */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) ebnf = true; @@ -6526,9 +6674,9 @@ case 22: case 23: /*! Production:: declaration : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {unknownDecl: yyvstack[yysp]}; @@ -6537,9 +6685,9 @@ case 23: case 24: /*! Production:: declaration : IMPORT import_name import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = {imports: {name: yyvstack[yysp - 1], path: yyvstack[yysp]}}; @@ -6548,10 +6696,10 @@ case 24: case 25: /*! Production:: declaration : IMPORT import_name error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6567,10 +6715,10 @@ case 25: case 26: /*! Production:: declaration : IMPORT error import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6586,9 +6734,9 @@ case 26: case 27: /*! Production:: declaration : INIT_CODE init_code_name action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6611,10 +6759,10 @@ case 27: case 28: /*! Production:: declaration : INIT_CODE error action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6630,10 +6778,10 @@ case 28: case 29: /*! Production:: declaration : START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6648,10 +6796,10 @@ case 29: case 30: /*! Production:: declaration : TOKEN error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6666,10 +6814,10 @@ case 30: case 31: /*! Production:: declaration : IMPORT error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6734,9 +6882,9 @@ case 129: case 132: /*! Production:: optional_module_code_chunk : module_code_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -6747,9 +6895,9 @@ case 39: case 111: /*! Production:: action_ne : "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -6758,10 +6906,10 @@ case 111: case 40: /*! Production:: options : OPTIONS error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6776,10 +6924,10 @@ case 40: case 41: /*! Production:: options : OPTIONS error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6798,9 +6946,9 @@ case 59: case 70: /*! Production:: id_list : id_list id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6815,9 +6963,9 @@ case 71: case 84: /*! Production:: handle_list : handle_action */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -6826,9 +6974,9 @@ case 84: case 44: /*! Production:: option : NAME */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -6837,9 +6985,9 @@ case 44: case 45: /*! Production:: option : NAME "=" OPTION_STRING_VALUE */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -6850,9 +6998,9 @@ case 46: case 47: /*! Production:: option : NAME "=" NAME */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], parseValue(yyvstack[yysp])]; @@ -6861,10 +7009,10 @@ case 47: case 48: /*! Production:: option : NAME "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6879,10 +7027,10 @@ case 48: case 49: /*! Production:: option : NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6899,9 +7047,9 @@ case 50: case 52: /*! Production:: parser_type : PARSER_TYPE symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -6910,10 +7058,10 @@ case 52: case 51: /*! Production:: parse_params : PARSE_PARAM error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6931,10 +7079,10 @@ case 51: case 53: /*! Production:: parser_type : PARSER_TYPE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6952,9 +7100,9 @@ case 53: case 54: /*! Production:: operator : associativity token_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1]]; this.$.push.apply(this.$, yyvstack[yysp]); @@ -6963,10 +7111,10 @@ case 54: case 55: /*! Production:: operator : associativity error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6984,9 +7132,9 @@ case 55: case 56: /*! Production:: associativity : LEFT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'left'; @@ -6995,9 +7143,9 @@ case 56: case 57: /*! Production:: associativity : RIGHT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'right'; @@ -7006,9 +7154,9 @@ case 57: case 58: /*! Production:: associativity : NONASSOC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'nonassoc'; @@ -7017,9 +7165,9 @@ case 58: case 61: /*! Production:: full_token_definitions : optional_token_type id_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var rv = []; @@ -7038,9 +7186,9 @@ case 61: case 62: /*! Production:: full_token_definitions : optional_token_type one_full_token */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var m = yyvstack[yysp]; @@ -7053,9 +7201,9 @@ case 62: case 63: /*! Production:: one_full_token : id token_value token_description */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -7068,9 +7216,9 @@ case 63: case 64: /*! Production:: one_full_token : id token_description */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -7082,9 +7230,9 @@ case 64: case 65: /*! Production:: one_full_token : id token_value */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -7096,9 +7244,9 @@ case 65: case 66: /*! Production:: optional_token_type : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = false; @@ -7107,9 +7255,9 @@ case 66: case 72: /*! Production:: grammar : optional_action_header_block production_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -7119,9 +7267,9 @@ case 72: case 73: /*! Production:: production_list : production_list production */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -7135,9 +7283,9 @@ case 73: case 74: /*! Production:: production_list : production */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; this.$[yyvstack[yysp][0]] = yyvstack[yysp][1]; @@ -7146,9 +7294,9 @@ case 74: case 75: /*! Production:: production : production_id handle_list ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp - 1]]; @@ -7157,10 +7305,10 @@ case 75: case 76: /*! Production:: production : production_id error ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7178,10 +7326,10 @@ case 76: case 77: /*! Production:: production : production_id error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7199,9 +7347,9 @@ case 77: case 78: /*! Production:: production_id : id optional_production_description ":" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -7212,10 +7360,10 @@ case 78: case 79: /*! Production:: production_id : id optional_production_description error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7233,10 +7381,10 @@ case 79: case 80: /*! Production:: production_id : id optional_production_description ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7260,18 +7408,18 @@ case 80: case 82: /*! Production:: optional_production_description : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) break; case 83: /*! Production:: handle_list : handle_list "|" handle_action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -7281,10 +7429,10 @@ case 83: case 85: /*! Production:: handle_list : handle_list "|" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7302,10 +7450,10 @@ case 85: case 86: /*! Production:: handle_list : handle_list ":" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7320,9 +7468,9 @@ case 86: case 87: /*! Production:: handle_action : handle prec action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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(' ') : '')]; @@ -7357,9 +7505,9 @@ case 87: case 88: /*! Production:: handle_action : EPSILON action */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = ['']; @@ -7383,10 +7531,10 @@ case 88: case 89: /*! Production:: handle_action : EPSILON error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7401,9 +7549,9 @@ case 89: case 90: /*! Production:: handle : handle suffixed_expression */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -7413,9 +7561,9 @@ case 90: case 91: /*! Production:: handle : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -7424,9 +7572,9 @@ case 91: case 92: /*! Production:: handle_sublist : handle_sublist "|" handle */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -7436,9 +7584,9 @@ case 92: case 93: /*! Production:: handle_sublist : handle */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp].join(' ')]; @@ -7447,9 +7595,9 @@ case 93: case 94: /*! Production:: suffixed_expression : expression suffix ALIAS */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + "[" + yyvstack[yysp] + "]"; @@ -7462,9 +7610,9 @@ case 124: case 130: /*! Production:: module_code_chunk : module_code_chunk CODE */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -7473,9 +7621,9 @@ case 130: case 97: /*! Production:: expression : EOF_ID */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$end'; @@ -7484,9 +7632,9 @@ case 97: case 98: /*! Production:: expression : STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // Re-encode the string *anyway* as it will @@ -7499,9 +7647,9 @@ case 98: case 99: /*! Production:: expression : "(" handle_sublist ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1].join(' | ') + ')'; @@ -7510,10 +7658,10 @@ case 99: case 100: /*! Production:: expression : "(" handle_sublist error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -7527,9 +7675,9 @@ case 100: case 105: /*! Production:: prec : PREC symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { prec: yyvstack[yysp] }; @@ -7538,10 +7686,10 @@ case 105: case 106: /*! Production:: prec : PREC error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7559,9 +7707,9 @@ case 106: case 107: /*! Production:: prec : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = null; @@ -7570,10 +7718,10 @@ case 107: case 112: /*! Production:: action_ne : "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -7587,9 +7735,9 @@ case 112: case 116: /*! Production:: action : ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$$ = (' + yyvstack[yysp] + ');'; @@ -7598,9 +7746,9 @@ case 116: case 120: /*! Production:: action_body : action_body "{" action_body "}" action_comments_body */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4] + yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -7609,9 +7757,9 @@ case 120: case 121: /*! Production:: action_body : action_body "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -7620,10 +7768,10 @@ case 121: case 122: /*! Production:: action_body : action_body "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -7637,9 +7785,9 @@ case 122: case 126: /*! Production:: extra_parser_module_code : optional_module_code_chunk include_macro_code extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -7648,9 +7796,9 @@ case 126: case 127: /*! Production:: include_macro_code : INCLUDE PATH */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' }); @@ -7670,10 +7818,10 @@ case 127: case 128: /*! Production:: include_macro_code : INCLUDE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -7686,10 +7834,10 @@ case 128: case 131: /*! Production:: module_code_chunk : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -9082,7 +9230,6 @@ defaultActions: bda({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -9099,59 +9246,53 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, parser: undefined, pre_parse: undefined, post_parse: undefined, - pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! - }; - - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + pre_lex: undefined, + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! + }; + + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -9173,7 +9314,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -9181,18 +9321,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -9200,24 +9341,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -9255,18 +9391,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -9287,7 +9420,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -9305,7 +9438,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -9318,7 +9450,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -9332,11 +9463,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -9390,8 +9520,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -9399,8 +9529,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -9432,19 +9562,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -9455,7 +9584,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -9468,7 +9597,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -9480,29 +9609,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -9510,7 +9637,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -9530,8 +9657,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -9540,10 +9666,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -9551,7 +9677,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -9562,9 +9688,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -9580,8 +9711,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -9650,11 +9780,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -9665,8 +9798,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -9675,21 +9807,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -9699,21 +9830,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -9722,28 +9852,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -9756,8 +9885,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -9780,8 +9908,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -9793,8 +9920,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -9811,8 +9937,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -9826,8 +9951,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -9841,7 +9965,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -9894,16 +10018,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -9937,9 +10058,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -9962,9 +10081,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -9991,17 +10108,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -10048,8 +10164,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -10061,8 +10177,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -10080,6 +10195,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -10088,7 +10204,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -10099,7 +10215,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -10159,10 +10275,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -10197,9 +10313,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -10212,7 +10326,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -10233,9 +10347,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -10257,12 +10369,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -10271,7 +10383,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -10312,7 +10424,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -10359,7 +10471,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -10377,21 +10489,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -10425,14 +10535,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -10442,6 +10553,7 @@ parse: function parse(input) { + } continue; // accept: @@ -10493,7 +10605,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -10509,9 +10621,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -10540,7 +10650,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -10557,8 +10667,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -10569,8 +10679,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -10582,21 +10692,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -10627,14 +10735,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -10644,6 +10753,7 @@ parse: function parse(input) { + } continue; // accept: @@ -10696,8 +10806,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -10958,7 +11067,6 @@ var lexer$1 = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -10975,10 +11083,10 @@ var lexer$1 = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -11010,7 +11118,7 @@ var lexer$1 = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -11052,7 +11160,9 @@ var lexer$1 = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -11138,7 +11248,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -11146,7 +11256,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -11159,7 +11269,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -11185,10 +11295,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -11211,7 +11324,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -11234,16 +11346,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -11265,7 +11377,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -11273,8 +11384,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -11303,7 +11414,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -11328,7 +11439,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -11340,17 +11451,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -11444,7 +11555,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -11465,7 +11576,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -11476,7 +11586,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -11487,15 +11597,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -11529,8 +11639,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -11563,9 +11673,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -11584,9 +11694,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -11596,8 +11706,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -11624,20 +11734,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -11677,17 +11786,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -11696,7 +11807,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -11711,8 +11822,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -11738,24 +11849,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -11766,7 +11879,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -11788,8 +11901,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -11811,8 +11924,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -11956,21 +12068,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -11985,11 +12097,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -12008,13 +12120,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -12038,13 +12150,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -12059,8 +12171,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -12091,7 +12203,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -12123,9 +12235,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -12154,7 +12266,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -12172,7 +12284,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -12197,7 +12309,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -12207,8 +12318,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -12217,7 +12326,7 @@ EOF: 1, this.clear(); } - 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. @@ -12229,13 +12338,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -12245,68 +12354,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -12331,7 +12446,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -12379,24 +12494,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -12416,7 +12531,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -12426,24 +12541,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -12464,8 +12579,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -12505,14 +12619,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -12528,9 +12642,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -12541,8 +12655,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -12550,7 +12664,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -13600,7 +13714,6 @@ var bnf = { // 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. function JisonParserError$2(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -13617,9 +13730,9 @@ function JisonParserError$2(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -13652,10 +13765,10 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp$2(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -13668,11 +13781,11 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda$1(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -13682,18 +13795,18 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt$2(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -13724,7 +13837,7 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // `this` references an array function s$2(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -13741,9 +13854,9 @@ JisonParserError$2.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$2(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -13756,7 +13869,7 @@ JisonParserError$2.prototype.name = 'JisonParserError'; } -var parser$3 = { +let parser$3 = { // Code Generator Information Report // --------------------------------- // @@ -14006,7 +14119,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -14014,7 +14126,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -14026,8 +14137,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -14040,14 +14151,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -14063,10 +14173,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -14074,10 +14184,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -14232,9 +14342,9 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -14246,18 +14356,18 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -14287,9 +14397,9 @@ case 1: case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -14302,10 +14412,10 @@ case 2: case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14332,9 +14442,9 @@ case 3: case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -14343,10 +14453,10 @@ case 4: case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14374,9 +14484,9 @@ case 5: case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -14385,10 +14495,10 @@ case 6: case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -14427,9 +14537,9 @@ case 7: case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -14494,9 +14604,9 @@ case 8: case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -14511,9 +14621,9 @@ case 9: case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -14548,10 +14658,10 @@ case 10: case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14568,9 +14678,9 @@ case 11: case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -14587,10 +14697,10 @@ case 12: case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14607,9 +14717,9 @@ case 13: case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -14626,10 +14736,10 @@ case 14: case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14646,9 +14756,9 @@ case 15: case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -14672,9 +14782,9 @@ case 17: case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -14685,9 +14795,9 @@ case 132: case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -14707,9 +14817,9 @@ case 18: case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -14733,9 +14843,9 @@ case 19: case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -14748,10 +14858,10 @@ case 20: case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14768,9 +14878,9 @@ case 21: case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -14782,9 +14892,9 @@ case 22: case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -14824,10 +14934,10 @@ case 23: case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14847,9 +14957,9 @@ case 24: case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -14899,10 +15009,10 @@ case 25: case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -14926,10 +15036,10 @@ case 26: case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14949,10 +15059,10 @@ case 27: case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14976,10 +15086,10 @@ case 28: case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15000,10 +15110,10 @@ case 29: case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -15015,10 +15125,10 @@ case 31: case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -15028,10 +15138,10 @@ case 33: case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -15041,10 +15151,10 @@ case 32: case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -15054,10 +15164,10 @@ case 34: case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -15067,10 +15177,10 @@ case 35: case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -15080,10 +15190,10 @@ case 36: case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -15093,10 +15203,10 @@ case 37: case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -15106,9 +15216,9 @@ case 38: case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -15117,9 +15227,9 @@ case 39: case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -15128,9 +15238,9 @@ case 40: case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -15152,9 +15262,9 @@ case 41: case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -15165,9 +15275,9 @@ case 42: case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -15187,9 +15297,9 @@ case 43: case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -15243,9 +15353,9 @@ case 49: case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15265,9 +15375,9 @@ case 51: case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -15276,9 +15386,9 @@ case 58: case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -15290,9 +15400,9 @@ case 52: case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -15306,10 +15416,10 @@ case 53: case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15329,10 +15439,10 @@ case 54: case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15352,10 +15462,10 @@ case 55: case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15375,9 +15485,9 @@ case 56: case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -15388,9 +15498,9 @@ case 59: case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -15409,9 +15519,9 @@ case 60: case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -15452,9 +15562,9 @@ case 61: case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -15478,9 +15588,9 @@ case 62: case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -15506,9 +15616,9 @@ case 63: case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -15553,9 +15663,9 @@ case 64: case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -15581,9 +15691,9 @@ case 106: case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -15592,9 +15702,9 @@ case 127: case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -15603,10 +15713,10 @@ case 67: case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15620,10 +15730,10 @@ case 68: case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15637,10 +15747,10 @@ case 69: case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15654,10 +15764,10 @@ case 70: case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15676,9 +15786,9 @@ case 72: case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -15687,9 +15797,9 @@ case 77: case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -15727,10 +15837,10 @@ case 73: case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -15754,9 +15864,9 @@ case 74: case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -15835,9 +15945,9 @@ case 110: case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -15846,9 +15956,9 @@ case 129: case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -15857,9 +15967,9 @@ case 78: case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -15868,9 +15978,9 @@ case 79: case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -15879,9 +15989,9 @@ case 80: case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -15890,9 +16000,9 @@ case 81: case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -15901,9 +16011,9 @@ case 85: case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -15914,10 +16024,10 @@ case 87: case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15934,9 +16044,9 @@ case 88: case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -15945,9 +16055,9 @@ case 89: case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -15956,9 +16066,9 @@ case 90: case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -15967,9 +16077,9 @@ case 91: case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -15978,9 +16088,9 @@ case 92: case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -15999,18 +16109,18 @@ case 107: case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -16019,9 +16129,9 @@ case 97: case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -16030,9 +16140,9 @@ case 98: case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -16041,9 +16151,9 @@ case 99: case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -16052,9 +16162,9 @@ case 102: case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -16063,10 +16173,10 @@ case 104: case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -16083,9 +16193,9 @@ case 105: case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -16102,9 +16212,9 @@ case 109: case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -16116,9 +16226,9 @@ case 111: case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -16128,9 +16238,9 @@ case 112: case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -16165,9 +16275,9 @@ case 113: case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -16186,9 +16296,9 @@ case 114: case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -16197,9 +16307,9 @@ case 115: case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -16208,9 +16318,9 @@ case 116: case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -16228,10 +16338,10 @@ case 117: case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -16249,10 +16359,10 @@ case 118: case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -16273,9 +16383,9 @@ case 119: case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -16308,9 +16418,9 @@ case 120: case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -16336,9 +16446,9 @@ case 121: case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5.parse(yyvstack[yysp]); @@ -16347,9 +16457,9 @@ case 122: case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue$1(yyvstack[yysp]); @@ -16358,9 +16468,9 @@ case 123: case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -16369,9 +16479,9 @@ case 124: case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -16392,10 +16502,10 @@ case 125: case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -16412,9 +16522,9 @@ case 126: case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -16433,9 +16543,9 @@ case 128: case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -16459,9 +16569,9 @@ case 130: case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -16481,9 +16591,9 @@ case 131: case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -16494,9 +16604,9 @@ case 133: case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -16552,10 +16662,10 @@ case 134: case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -18158,7 +18268,6 @@ defaultActions: bda$1({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -18175,38 +18284,34 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -18214,20 +18319,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -18249,7 +18352,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -18257,18 +18359,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -18276,24 +18379,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -18331,18 +18429,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -18363,7 +18458,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -18381,7 +18476,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -18394,7 +18488,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -18408,11 +18501,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -18466,8 +18558,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -18475,8 +18567,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -18508,19 +18600,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -18531,7 +18622,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -18544,7 +18635,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -18556,29 +18647,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -18586,7 +18675,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -18606,8 +18695,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -18616,10 +18704,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -18627,7 +18715,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -18638,9 +18726,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -18656,8 +18749,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -18726,11 +18818,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -18741,8 +18836,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -18751,21 +18845,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -18775,21 +18868,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -18798,28 +18890,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -18832,8 +18923,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -18856,8 +18946,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -18869,8 +18958,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -18887,8 +18975,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -18902,8 +18989,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -18917,7 +19003,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -18970,16 +19056,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -19013,9 +19096,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -19038,9 +19119,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -19067,17 +19146,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -19124,8 +19202,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -19137,8 +19215,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -19156,6 +19233,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -19164,7 +19242,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -19175,7 +19253,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -19235,10 +19313,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -19273,9 +19351,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -19288,7 +19364,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -19309,9 +19385,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -19333,12 +19407,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -19347,7 +19421,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -19388,7 +19462,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -19435,7 +19509,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -19453,21 +19527,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -19501,14 +19573,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -19518,6 +19591,7 @@ parse: function parse(input) { + } continue; // accept: @@ -19569,7 +19643,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -19585,9 +19659,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -19616,7 +19688,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -19633,8 +19705,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -19645,8 +19717,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -19658,21 +19730,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -19703,14 +19773,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -19720,6 +19791,7 @@ parse: function parse(input) { + } continue; // accept: @@ -19772,8 +19844,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -20034,7 +20105,6 @@ var lexer$2 = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -20051,10 +20121,10 @@ var lexer$2 = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -20086,7 +20156,7 @@ var lexer$2 = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -20128,7 +20198,9 @@ var lexer$2 = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -20214,7 +20286,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -20222,7 +20294,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -20235,7 +20307,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -20261,10 +20333,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -20287,7 +20362,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -20310,16 +20384,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -20341,7 +20415,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -20349,8 +20422,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -20379,7 +20452,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -20404,7 +20477,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -20416,17 +20489,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -20520,7 +20593,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -20541,7 +20614,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -20552,7 +20624,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -20563,15 +20635,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -20605,8 +20677,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -20639,9 +20711,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -20660,9 +20732,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -20672,8 +20744,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -20700,20 +20772,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -20753,17 +20824,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -20772,7 +20845,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -20787,8 +20860,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -20814,24 +20887,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -20842,7 +20917,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -20864,8 +20939,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -20887,8 +20962,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -21032,21 +21106,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -21061,11 +21135,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -21084,13 +21158,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -21114,13 +21188,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -21135,8 +21209,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -21167,7 +21241,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -21199,9 +21273,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -21230,7 +21304,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -21248,7 +21322,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -21273,7 +21347,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -21283,8 +21356,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -21293,7 +21364,7 @@ EOF: 1, this.clear(); } - 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. @@ -21305,13 +21376,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -21321,68 +21392,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -21407,7 +21484,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -21455,24 +21532,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -21492,7 +21569,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -21502,24 +21579,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -21540,8 +21617,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -21581,14 +21657,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -21604,9 +21680,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -21617,8 +21693,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -21626,7 +21702,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -23300,7 +23376,7 @@ var jisonlex = { }; -var version = '0.6.2-220'; // require('./package.json').version; +const version = '0.6.2-220'; // require('./package.json').version; function parse(grammar) { return bnf.parser.parse(grammar); @@ -23366,7 +23442,7 @@ bnf.parser.yy.addDeclaration = function bnfAddDeclaration(grammar, decl) { if (decl.options) { if (!grammar.options) grammar.options = {}; // last occurrence of `%options` wins: - for (var i = 0; i < decl.options.length; i++) { + for (let i = 0; i < decl.options.length; i++) { grammar.options[decl.options[i][0]] = decl.options[i][1]; } } @@ -23406,9 +23482,9 @@ function parseLex(text, position) { // which matches the original input file: position = position || {}; position.range = position.range || []; - var l = position.first_line | 0; - var c = position.range[0] | 0; - var prelude = ''; + let l = position.first_line | 0; + let c = position.range[0] | 0; + let prelude = ''; if (l > 1) { prelude += (new Array(l)).join('\n'); c -= prelude.length; @@ -23433,7 +23509,7 @@ var ebnfParser = { ebnf_parser, bnf_lexer: jisonlex, - version, + version }; export default ebnfParser; diff --git a/packages/ebnf-parser/dist/ebnf-parser-umd-es5.js b/packages/ebnf-parser/dist/ebnf-parser-umd-es5.js index afc1fad5f..97f2f0e20 100644 --- a/packages/ebnf-parser/dist/ebnf-parser-umd-es5.js +++ b/packages/ebnf-parser/dist/ebnf-parser-umd-es5.js @@ -1,4 +1,4 @@ -(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?module.exports=factory(require('@gerhobbelt/xregexp'),require('fs'),require('path'),require('@gerhobbelt/json5'),require('recast'),require('@babel/core'),require('assert')):typeof define==='function'&&define.amd?define(['@gerhobbelt/xregexp','fs','path','@gerhobbelt/json5','recast','@babel/core','assert'],factory):(global=typeof globalThis!=='undefined'?globalThis:global||self,global['ebnf-parser']=factory(global.XRegExp,global.fs,global.path$1,global.JSON5,global.recast,global.babel,global.assert$1));})(this,function(XRegExp,fs,path$1,JSON5,recast,babel,assert$1){'use strict';function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e};}var XRegExp__default=/*#__PURE__*/_interopDefaultLegacy(XRegExp);var fs__default=/*#__PURE__*/_interopDefaultLegacy(fs);var path__default=/*#__PURE__*/_interopDefaultLegacy(path$1);var JSON5__default=/*#__PURE__*/_interopDefaultLegacy(JSON5);var recast__default=/*#__PURE__*/_interopDefaultLegacy(recast);var assert__default=/*#__PURE__*/_interopDefaultLegacy(assert$1);// Return TRUE if `src` starts with `searchString`. +(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?module.exports=factory(require('@gerhobbelt/xregexp'),require('fs'),require('path'),require('@gerhobbelt/json5'),require('mkdirp'),require('recast'),require('@babel/core'),require('assert')):typeof define==='function'&&define.amd?define(['@gerhobbelt/xregexp','fs','path','@gerhobbelt/json5','mkdirp','recast','@babel/core','assert'],factory):(global=typeof globalThis!=='undefined'?globalThis:global||self,global['ebnf-parser']=factory(global.XRegExp,global.fs,global.path$1,global.JSON5,global.mkdirp,global.recast,global.babel,global.assert$1));})(this,function(XRegExp,fs,path$1,JSON5,mkdirp,recast,babel,assert$1){'use strict';function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e};}var XRegExp__default=/*#__PURE__*/_interopDefaultLegacy(XRegExp);var fs__default=/*#__PURE__*/_interopDefaultLegacy(fs);var path__default=/*#__PURE__*/_interopDefaultLegacy(path$1);var JSON5__default=/*#__PURE__*/_interopDefaultLegacy(JSON5);var mkdirp__default=/*#__PURE__*/_interopDefaultLegacy(mkdirp);var recast__default=/*#__PURE__*/_interopDefaultLegacy(recast);var assert__default=/*#__PURE__*/_interopDefaultLegacy(assert$1);// Return TRUE if `src` starts with `searchString`. function startsWith(src,searchString){return src.substr(0,searchString.length)===searchString;}// tagged template string helper which removes the indentation common to all // non-empty lines: that indentation was added as part of the source code // formatting of this lexer spec file and must be removed to produce what @@ -14,62 +14,72 @@ function startsWith(src,searchString){return src.substr(0,searchString.length)== function rmCommonWS(strings,...values){// As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. -// +// // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. -var indent_str=null;var src=strings.map(function splitIntoLines(s){var a=s.split('\n');indent_str=a.reduce(function analyzeLine(indent_str,line,index){// only check indentation of parts which follow a NEWLINE: -if(index!==0){var m=/^(\s*)\S/.exec(line);// only non-empty ~ content-carrying lines matter re common indent calculus: +let indent_str=null;let src=strings.map(function splitIntoLines(s){let a=s.split('\n');indent_str=a.reduce(function analyzeLine(indent_str,line,index){// only check indentation of parts which follow a NEWLINE: +if(index!==0){let m=/^(\s*)\S/.exec(line);// only non-empty ~ content-carrying lines matter re common indent calculus: if(m){if(indent_str==null){indent_str=m[1];}else if(m[1].length start at j=1 rather than j=0 -for(var j=1,linecnt=a.length;j `'camelsHaveOneHump'` +for(let j=1,linecnt=a.length;j `'camelsHaveOneHump'` /** @public */function camelCase(s){// Convert first character to lowercase -return s.replace(/^\w/,function(match){return match.toLowerCase();}).replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// do not mutate 'a-2' to 'a2': -if(c===rv&&c.match(/\d/)){return match;}return rv;});}// Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers -/** @public */function mkIdentifier(s){s=''+s;return s// Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), +return s.replace(/^\w/,function(match){return match.toLowerCase();}).replace(/-\w/g,function(match){const c=match.charAt(1);const rv=c.toUpperCase();// do not mutate 'a-2' to 'a2': +if(c===rv&&c.match(/\d/)){return match;}return rv;});}// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords=(list=>{let rv=new Set();for(let w of list){//console.error('reserved word:', w); +rv.add(w);}return rv;})(['await','break','case','catch','class','const','continue','debugger','default','delete','do','else','enum','export','extends','finally','for','function','if','implements','import','in','instanceof','interface','new','package','private','protected','public','return','super','switch','this','throw','try','typeof','var','void','while','with','yield']);// Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers +/** @public */function mkIdentifier(s){s=''+s;let rv=s// Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` -.replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// mutate 'a-2' to 'a_2': +.replace(/-\w/g,function(match){let c=match.charAt(1);let rv=c.toUpperCase();// mutate 'a-2' to 'a_2': if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;})// cleanup: replace any non-suitable character series to a single underscore: .replace(/^([\d])/,'_$1')// where leading numbers are prefixed by an underscore: '1' --> '_1' .replace(/^[^\w_]/,'_')// do not accept numerics at the leading position, despite those matching regex `\w`: .replace(/^\d/,'_').replace(/[^\w\d_]/g,'_')// and only accept multiple (double, not triple) underscores at start or end of identifier name: -.replace(/^__+/,'#').replace(/__+$/,'#').replace(/_+/g,'_').replace(/#/g,'__');}// Check if the start of the given input matches a regex expression. +.replace(/^__+/,'#').replace(/__+$/,'#').replace(/_+/g,'_').replace(/#/g,'__');if(reservedWords.has(rv)){rv='_'+rv;}return rv;}// Check if the start of the given input matches a regex expression. // Return the length of the regex expression or -1 if none was found. /** @public */function scanRegExp(s){s=''+s;// code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` -var index=0;var length=s.length;var ch=s[index];//assert.assert(ch === '/', 'Regular expression literal must start with a slash'); -var str=s[index++];var classMarker=false;var terminated=false;while(index `'camelsHaveOneHump'` -let ref=s.replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// mutate 'a-2' to 'a_2': -if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;});var alt=mkIdentifier(s);return alt===ref;}// properly quote and escape the given input string -function dquote(s){var sq=s.indexOf('\'')>=0;var dq=s.indexOf('"')>=0;if(sq&&dq){s=s.replace(/"/g,'\\"');dq=false;}if(dq){s='\''+s+'\'';}else{s='"'+s+'"';}return s;}// +let ref=s.replace(/-\w/g,function(match){let c=match.charAt(1);let rv=c.toUpperCase();// mutate 'a-2' to 'a_2': +if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;});let alt=mkIdentifier(s);return alt===ref;}// properly quote and escape the given input string +function dquote(s){let sq=s.indexOf('\'')>=0;let dq=s.indexOf('"')>=0;if(sq&&dq){s=s.replace(/"/g,'\\"');dq=false;}if(dq){s='\''+s+'\'';}else{s='"'+s+'"';}return s;}// function chkBugger(src){src=String(src);if(src.match(/\bcov_\w+/)){console.error('### ISTANBUL COVERAGE CODE DETECTED ###\n',src);}}// Helper function: pad number with leading zeroes -function pad(n,p){p=p||2;var rv='0000'+n;return rv.slice(-p);}// attempt to dump in one of several locations: first winner is *it*! -function dumpSourceToFile(sourcecode,errname,err_id,options,ex){var dumpfile;options=options||{};try{var dumpPaths=[options.outfile?path__default['default'].dirname(options.outfile):null,options.inputPath,process.cwd()];var dumpName=path__default['default'].basename(options.inputFilename||options.moduleName||(options.outfile?path__default['default'].dirname(options.outfile):null)||options.defaultModuleName||errname).replace(/\.[a-z]{1,5}$/i,'')// remove extension .y, .yacc, .jison, ...whatever -.replace(/[^a-z0-9_]/ig,'_');// make sure it's legal in the destination filesystem: the least common denominator. -if(dumpName===''||dumpName==='_'){dumpName='__bugger__';}err_id=err_id||'XXX';var ts=new Date();var tm=ts.getUTCFullYear()+'_'+pad(ts.getUTCMonth()+1)+'_'+pad(ts.getUTCDate())+'T'+pad(ts.getUTCHours())+''+pad(ts.getUTCMinutes())+''+pad(ts.getUTCSeconds())+'.'+pad(ts.getUTCMilliseconds(),3)+'Z';dumpName+='.fatal_'+err_id+'_dump_'+tm+'.js';for(var i=0,l=dumpPaths.length;i'// '+l);d=d.join('\n');fs__default['default'].writeFileSync(dumpfile,sourcecode+'\n\n\n'+d,'utf8');console.error("****** offending generated "+errname+" source code dumped into file: ",dumpfile);break;// abort loop once a dump action was successful! +function pad(n,p){p=p||2;let rv='0000'+n;return rv.slice(-p);}function convertExceptionToObject(ex){if(!ex)return ex;// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error +// +// - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) +let rv=Object.assign({},ex);// - Set up the default fields which should ALWAYS be present: +rv.message=ex.message;rv.name=ex.name;rv.stack=ex.stack;// this assignment stringifies the stack trace in ex.stack. +// - Set the optional fields: +if(ex.code!==undefined)rv.code=ex.code;if(ex.type!==undefined)rv.type=ex.type;if(ex.fileName!==undefined)rv.fileName=ex.fileName;if(ex.lineNumber!==undefined)rv.lineNumber=ex.lineNumber;if(ex.columnNumber!==undefined)rv.columnNumber=ex.columnNumber;if(Array.isArray(ex.errors)){rv.errors=[];for(let se of ex.errors){rv.errors.push(convertExceptionToObject(se));}}return rv;}function find_suitable_app_dump_path(){return process.cwd().replace(/\\/g,'/').replace(/\/node_modules\/.*$/,m=>'/___nm___/').replace(/(\/jison\/)(.*)$/,(m,p1,p2)=>p1+'___'+p2.split('/').map(d=>d.charAt(0).toUpperCase()).join('_'));}// attempt to dump in one of several locations: first winner is *it*! +function dumpSourceToFile(sourcecode,errname,err_id,options,ex){let dumpfile;options=options||{};try{const dumpPaths=[options.outfile?path__default['default'].dirname(options.outfile):null,options.inputPath,find_suitable_app_dump_path()];let dumpName=path__default['default'].basename(options.inputFilename||options.moduleName||(options.outfile?path__default['default'].dirname(options.outfile):null)||options.defaultModuleName||errname).replace(/\.[a-z]{1,5}$/i,'')// remove extension .y, .yacc, .jison, ...whatever +.replace(/[^a-z0-9_]/ig,'_')// make sure it's legal in the destination filesystem: the least common denominator. +.substr(0,100);if(dumpName===''||dumpName==='_'){dumpName='__bugger__';}// generate a stacktrace for the dump no matter what: +if(!ex){try{throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this.");}catch(ex2){ex=ex2;}}err_id=err_id||'XXX';err_id=err_id.replace(/[^a-z0-9_]/ig,'_')// make sure it's legal in the destination filesystem: the least common denominator. +.substr(0,50);const ts=new Date();const tm=ts.getUTCFullYear()+'_'+pad(ts.getUTCMonth()+1)+'_'+pad(ts.getUTCDate())+'T'+pad(ts.getUTCHours())+''+pad(ts.getUTCMinutes())+''+pad(ts.getUTCSeconds())+'.'+pad(ts.getUTCMilliseconds(),3)+'Z';dumpName+='.fatal_'+err_id+'_dump_'+tm+'.js';for(let i=0,l=dumpPaths.length;i'[!circular ref!]'});// make sure each line is a comment line: +d=d.split('\n').map(l=>'// '+l);d=d.join('\n');mkdirp__default['default'](path__default['default'].dirname(dumpfile));fs__default['default'].writeFileSync(dumpfile,sourcecode+'\n\n\n'+d,'utf8');console.error('****** offending generated '+errname+' source code dumped into file: ',dumpfile);break;// abort loop once a dump action was successful! }catch(ex3){//console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); -if(i===l-1){throw ex3;}}}}catch(ex2){console.error("generated "+errname+" source code fatal DUMPING error: ",ex2.message," -- while attempting to dump into file: ",dumpfile,"\n",ex2.stack);}// augment the exception info, when available: +if(i===l-1){throw ex3;}}}}catch(ex2){console.error('generated '+errname+' source code fatal DUMPING error: ',ex2.message,' -- while attempting to dump into file: ',dumpfile,'\n',ex2.stack);}// augment the exception info, when available: if(ex){ex.offending_source_code=sourcecode;ex.offending_source_title=errname;ex.offending_source_dumpfile=dumpfile;}}// // `code_execution_rig` is a function which gets executed, while it is fed the `sourcecode` as a parameter. // When the `code_execution_rig` crashes, its failure is caught and (using the `options`) the sourcecode @@ -88,8 +98,12 @@ if(ex){ex.offending_source_code=sourcecode;ex.offending_source_title=errname;ex. // - options.moduleName // - options.defaultModuleName // -function exec_and_diagnose_this_stuff(sourcecode,code_execution_rig,options,title){options=options||{};var errname=""+(title||"exec_test");var err_id=errname.replace(/[^a-z0-9_]/ig,"_");if(err_id.length===0){err_id="exec_crash";}const debug=0;var p;try{// p = eval(sourcecode); -if(typeof code_execution_rig!=='function'){throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function");}chkBugger(sourcecode);p=code_execution_rig.call(this,sourcecode,options,errname,debug);}catch(ex){if(options.dumpSourceCodeOnFailure||1){dumpSourceToFile(sourcecode,errname,err_id,options,ex);}if(options.throwErrorOnCompileFailure){throw ex;}}return p;}var code_exec={exec:exec_and_diagnose_this_stuff,dump:dumpSourceToFile};// +function exec_and_diagnose_this_stuff(sourcecode,code_execution_rig,options,title){options=options||{};let errname=''+(title||'exec_test');let err_id=errname.replace(/[^a-z0-9_]/ig,'_');if(err_id.length===0){err_id='exec_crash';}const debug=options.debug||0;if(debug)console.warn('generated '+errname+' code under EXEC TEST.');if(debug>1){console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `);}let p;try{// p = eval(sourcecode); +if(typeof code_execution_rig!=='function'){throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function');}chkBugger(sourcecode);p=code_execution_rig.call(this,sourcecode,options,errname,debug);}catch(ex){if(debug>1)console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@');if(debug)console.log('generated '+errname+' source code fatal error: ',ex.message);if(debug>1)console.log('exec-and-diagnose options:',options);if(debug>1)console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@');if(options.dumpSourceCodeOnFailure||1){dumpSourceToFile(sourcecode,errname,err_id,options,ex);}if(options.throwErrorOnCompileFailure){throw ex;}}return p;}var exec={exec:exec_and_diagnose_this_stuff,dump:dumpSourceToFile,convertExceptionToObject};// assert__default['default'](recast__default['default']);//var types = recast.types; //assert(types); //var namedTypes = types.namedTypes; @@ -100,17 +114,17 @@ assert__default['default'](recast__default['default']);//var types = recast.type // WARNING: this regex MUST match the regex for `ID` in ebnf-parser::bnf.l jison language lexer spec! (`ID = [{ALPHA}]{ALNUM}*`) // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! -const ID_REGEX_BASE='[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*';// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +const ID_REGEX_BASE='[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*';// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: -const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode NonAsciiIdentifierStart characters +const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -118,37 +132,37 @@ const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode Non function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); -// As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode +// As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: -// +// // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything -// between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is +// between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. -// +// // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. -// +// // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: -// +// // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A -// +// // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. -// -// To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to +// +// To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the -// first character is fixed and the second character is chosen such that the escape code -// DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input +// first character is fixed and the second character is chosen such that the escape code +// DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: -// -// - the first character is ဩ which is highly visible and allows us to quickly search through a +// +// - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -156,30 +170,30 @@ function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only wan // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will -// pick a different base shape from that CANADIAN SYLLABICS charset. -// - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to +// pick a different base shape from that CANADIAN SYLLABICS charset. +// - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ -// - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered +// - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: -// +// // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 -// - 1489-14A0: ᒉ 5 -// - 14A3-14BA: ᒣ 6 -// - 14C0-14CF: ᓀ +// - 1489-14A0: ᒉ 5 +// - 14A3-14BA: ᒣ 6 +// - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 -// - 1526-153D: ᔦ +// - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -190,58 +204,58 @@ function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only wan // - 1622-162D: ᘢ // // ## JISON identifier formats ## -// +// // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. -// +// // -> (1+2) start-# + end-# -// +// // - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ -// +// // - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# -// +// // - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# -// +// // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - result location reference `@$` -// +// // -> (6) single-@ -// +// // - rule id number `#$` -// +// // -> (3) single-# -// +// // - result stack index `##$` -// +// // -> (4) double-# -// +// // - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -// +// // - 'negative index' location reference, e.g. `@-2` -// +// // -> (7) single-negative-@ -// +// // - 'negative index' stack indexes, e.g. `##-2` -// +// // -> (5) double-negative-# -// +// // count the number of occurrences of ch in src: -// +// // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -258,38 +272,38 @@ function countOccurrences(ch,src){let i=ch.codePointAt(0);return hash[i]||0;}// // Preferrably has ZERO occurrences in the given `input`, but otherwise // deliver the one with the least number of occurrences. function pickChar(set,input){// strip out the spaces: -set=set.replace(/\s+/g,'');assert__default['default'](set.length>=1);let lsidx=0;let lsfreq=Infinity;for(let i=0,l=set.length;i=1);let lsidx=0;let lsfreq=Infinity;for(let i=0,l=set.length;i (1+2) start-# + end-# -// +// // - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ -// +// // - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# -// +// // - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# -// +// // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - result location reference `@$` -// +// // -> (6) single-@ -// +// // - rule id number `#$` -// +// // -> (3) single-# -// +// // - result stack index `##$` -// +// // -> (4) double-# -// +// // - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -// +// // - 'negative index' location reference, e.g. `@-2` -// +// // -> (7) single-negative-@ -// +// // - 'negative index' stack indexes, e.g. `##-2` -// +// // -> (5) double-negative-# -// -const escChar=pickChar(escCharSet);let typeIdChar=[];for(let i=0,l=typeIdCharSets.length;i (1) start-# tokenDirectIdentifierStart:escChar+typeIdChar[0],tokenDirectIdentifierRe:new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`,'g'),// - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart:'$',tokenValueReferenceRe:new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`,'g'),// - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ // - result location reference `@$` -// +// // -> (6) single-@ tokenLocationStart:escChar+typeIdChar[1],tokenLocationRe:new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`,'g'),// - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# // - rule id number `#$` -// +// // -> (3) single-# tokenIdentifierStart:escChar+typeIdChar[2],tokenIdentifierRe:new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`,'g'),// - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# // - result stack index `##$` -// +// // -> (4) double-# tokenStackIndexStart:escChar+typeIdChar[3],tokenStackIndexRe:new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`,'g'),// - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -tokenNegativeValueReferenceStart:escChar+typeIdChar[4],tokenValueReferenceRe:new XRegExp__default['default'](`$-([0-9]+)`,'g'),// - 'negative index' location reference, e.g. `@-2` -// +tokenNegativeValueReferenceStart:escChar+typeIdChar[4],tokenValueReferenceRe:new XRegExp__default['default']('$-([0-9]+)','g'),// - 'negative index' location reference, e.g. `@-2` +// // -> (7) single-negative-@ -tokenNegativeLocationStart:escChar+typeIdChar[5],tokenNegativeLocationRe:new XRegExp__default['default'](`@-([0-9]+)`,'g'),// - 'negative index' stack indexes, e.g. `##-2` -// +tokenNegativeLocationStart:escChar+typeIdChar[5],tokenNegativeLocationRe:new XRegExp__default['default']('@-([0-9]+)','g'),// - 'negative index' stack indexes, e.g. `##-2` +// // -> (5) double-negative-# -tokenNegativeStackIndexStart:escChar+typeIdChar[6],tokenNegativeStackIndexRe:new XRegExp__default['default'](`#-([0-9]+)`,'g'),// combined regex for encoding direction +tokenNegativeStackIndexStart:escChar+typeIdChar[6],tokenNegativeStackIndexRe:new XRegExp__default['default']('#-([0-9]+)','g'),// combined regex for encoding direction tokenDetect4EncodeRe:new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`,'g'),// combined regex for decoding direction tokenDetect4DecodeRe:new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`,'g'),encode:function encodeJisonTokens(src,locationOffsetSpec){let re=this.tokenDetect4EncodeRe;// reset regex re.lastIndex=0;// patch `src` for the lookbehind emulation in the main regex used: src=' '+src;// Perform the encoding, one token at a time via callback function. -// +// // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. -// This is a tad sub-optimal as we won't be able to report errors early +// This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -412,35 +426,35 @@ if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax return src.substring(1);},decode:function decodeJisonTokens(src,locationOffsetSpec){let re=this.tokenDetect4DecodeRe;// reset regex re.lastIndex=0;// patch `src` for the lookbehind emulation in the main regex used: src=' '+src;// Perform the encoding, one token at a time via callback function. -// +// // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. -// This is a tad sub-optimal as we won't be able to report errors early +// This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src=src.replace(re,(m,p1,p2,p3,offset)=>{// p1 is only serving as lookbehind emulation -switch(p2){case this.tokenNegativeValueReferenceStart:return p1+"$-"+p3;case this.tokenNegativeStackIndexStart:return p1+"##-"+p3;case this.tokenStackIndexStart:return p1+"##"+p3;case this.tokenNegativeLocationStart:return p1+"@-"+p3;case this.tokenLocationStart:return p1+"@"+p3;case this.tokenDirectIdentifierStart:// p3 CANNOT be a negative value or token ID +switch(p2){case this.tokenNegativeValueReferenceStart:return p1+'$-'+p3;case this.tokenNegativeStackIndexStart:return p1+'##-'+p3;case this.tokenStackIndexStart:return p1+'##'+p3;case this.tokenNegativeLocationStart:return p1+'@-'+p3;case this.tokenLocationStart:return p1+'@'+p3;case this.tokenDirectIdentifierStart:// p3 CANNOT be a negative value or token ID if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: ${p2+p3+p4} is an illegal negative reference type`,src,offset+p1.length+p2.length);}return p1+p2+p3;}return p1+'#'+p3+'#';case this.tokenIdentifierStart:// p3 CANNOT be a negative value or token ID if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: ${p2+p3+p4} is an illegal negative reference type`,src,offset+p1.length+p2.length);}return p1+p2+p3;}return p1+'#'+p3;default:if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: unexpected jison token sentinel escape ${p2} at ${p2+p3}`,src,offset+p1.length);}return p1+p2+p3;}});// and remove the added prefix which was used for lookbehind emulation: -return src.substring(1);}};}function parseCodeChunkToAST(src,options){src=src.replace(/@/g,'\uFFDA').replace(/#/g,'\uFFDB');var ast=recast__default['default'].parse(src);return ast;}function compileCodeToES5(src,options){options=Object.assign({},{ast:true,code:true,sourceMaps:true,comments:true,filename:'compileCodeToES5.js',sourceFileName:'compileCodeToES5.js',sourceRoot:'.',sourceType:'module',babelrc:false,ignore:["node_modules/**/*.js"],compact:false,retainLines:false,presets:[["@babel/preset-env",{targets:{browsers:["last 2 versions"],node:"8.0"}}]]},options);return babel.transformSync(src,options);// => { code, map, ast } -}function prettyPrintAST(ast,options){var options=options||{};const defaultOptions={tabWidth:2,quote:'single',arrowParensAlways:true,// Do not reuse whitespace (or anything else, for that matter) +return src.substring(1);}};}function parseCodeChunkToAST(src,options){src=src.replace(/@/g,'\uFFDA').replace(/#/g,'\uFFDB');const ast=recast__default['default'].parse(src);return ast;}function compileCodeToES5(src,options){options=Object.assign({},{ast:true,code:true,sourceMaps:true,comments:true,filename:'compileCodeToES5.js',sourceFileName:'compileCodeToES5.js',sourceRoot:'.',sourceType:'module',babelrc:false,ignore:['node_modules/**/*.js'],compact:false,retainLines:false,presets:[['@babel/preset-env',{targets:{browsers:['last 2 versions'],node:'8.0'}}]]},options);return babel.transformSync(src,options);// => { code, map, ast } +}function prettyPrintAST(ast,options){options=options||{};const defaultOptions={tabWidth:2,quote:'single',arrowParensAlways:true,// Do not reuse whitespace (or anything else, for that matter) // when printing generically. -reuseWhitespace:false};for(var key in defaultOptions){if(options[key]===undefined){options[key]=defaultOptions[key];}}let s=recast__default['default'].prettyPrint(ast,defaultOptions);let new_src=s.code;new_src=new_src.replace(/\r\n|\n|\r/g,'\n')// platform dependent EOL fixup +reuseWhitespace:false};for(let key in defaultOptions){if(options[key]===undefined){options[key]=defaultOptions[key];}}let s=recast__default['default'].prettyPrint(ast,defaultOptions);let new_src=s.code;new_src=new_src.replace(/\r\n|\n|\r/g,'\n')// platform dependent EOL fixup // backpatch possible jison variables extant in the prettified code: .replace(/\uFFDA/g,'@').replace(/\uFFDB/g,'#');return new_src;}// validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src,yylloc,options){// make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: -if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cnt);src=lines.join('\n')+src;}if(!src.trim()){return false;}try{var rv=parseCodeChunkToAST(src,options);return false;}catch(ex){return ex.message||"code snippet cannot be parsed";}}// The rough-and-ready preprocessor for any action code block: +if(yylloc&&yylloc.first_line>0){let cnt=yylloc.first_line;let lines=new Array(cnt);src=lines.join('\n')+src;}if(!src.trim()){return false;}try{let rv=parseCodeChunkToAST(src,options);return false;}catch(ex){return ex.message||'code snippet cannot be parsed';}}// The rough-and-ready preprocessor for any action code block: // this one trims off any surplus whitespace and removes any // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -448,7 +462,7 @@ if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cn // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -457,13 +471,13 @@ if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cn // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// -function trimActionCode(src,startMarker){var s=src.trim();// remove outermost set of braces UNLESS there's +// +function trimActionCode(src,startMarker){let s=src.trim();// remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated // code analyzer to simplify the code! @@ -495,34 +509,34 @@ s=s.replace(/^\{([^]*?)\}$/,'$1').trim();}else{// code may not be wrapped or oth // wrapping braces when we can guarantee they're the only ones there, // i.e. only exist as outer wrapping. s=s.replace(/^\{([^}]*)\}$/,'$1').trim();}s=s.replace(/;+$/,'').trim();return s;}var parse2AST={generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST,compileCodeToES5,prettyPrintAST,checkActionBlock,trimActionCode,ID_REGEX_BASE,IN_ID_CHARSET};function chkBugger$1(src){src=String(src);if(src.match(/\bcov_\w+/)){console.error('### ISTANBUL COVERAGE CODE DETECTED ###\n',src);}}/// HELPER FUNCTION: print the function in source code form, properly indented. -/** @public */function printFunctionSourceCode(f){var src=String(f);chkBugger$1(src);return src;}const funcRe=/^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/;const arrowFuncRe=/^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/;/// HELPER FUNCTION: print the function **content** in source code form, properly indented, +/** @public */function printFunctionSourceCode(f){const src=String(f);chkBugger$1(src);return src;}const funcRe=/^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/;const arrowFuncRe=/^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/;/// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// -/** @public */function printFunctionSourceCodeContainer(f){var action=printFunctionSourceCode(f).trim();var args;// Also cope with Arrow Functions (and inline those as well?). +/// +/** @public */function printFunctionSourceCodeContainer(f){let action=printFunctionSourceCode(f).trim();let args;// Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 -var m=funcRe.exec(action);if(m){args=m[1].trim();action=m[2].trim();}else{m=arrowFuncRe.exec(action);if(m){if(m[2]){// non-bracketed arguments: +let m=funcRe.exec(action);if(m){args=m[1].trim();action=m[2].trim();}else{m=arrowFuncRe.exec(action);if(m){if(m[2]){// non-bracketed arguments: args=m[2].trim();}else{// bracketed arguments: may be empty args list! args=m[1].trim();}if(m[5]){// non-bracketed version: implicit `return` statement! // -// Q: Must we make sure we have extra braces around the return value -// to prevent JavaScript from inserting implit EOS (End Of Statement) +// Q: Must we make sure we have extra braces around the return value +// to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already // have formatted the code correctly. -action=m[4].trim();action='return '+action+';';}else{action=m[3].trim();}}else{var e=new Error('Cannot extract code from function');e.subject=action;throw e;}}return{args:args,code:action};}var stringifier={printFunctionSourceCode,printFunctionSourceCodeContainer};// -// -// -function detectIstanbulGlobal(){const gcv="__coverage__";const globalvar=new Function('return this')();var coverage=globalvar[gcv];return coverage||false;}// +action=m[4].trim();action='return '+action+';';}else{action=m[3].trim();}}else{const e=new Error('Cannot extract code from function');e.subject=action;throw e;}}return{args:args,code:action};}var stringifier={printFunctionSourceCode,printFunctionSourceCodeContainer};// +// +// +function detectIstanbulGlobal(){const gcv='__coverage__';const globalvar=new Function('return this')();const coverage=globalvar[gcv];return coverage||false;}// // Helper library for safe code execution/compilation // // MIT Licensed @@ -540,7 +554,7 @@ function detectIstanbulGlobal(){const gcv="__coverage__";const globalvar=new Fun // The default assumed is the standard JavaScript `RegExp` class. // // Return FALSE when there's no failure, otherwise return an `Error` info object. -function checkRegExp(re_src,re_flags,XRegExp){var re;// were we fed a RegExp object or a string? +function checkRegExp(re_src,re_flags,XRegExp){let re;// were we fed a RegExp object or a string? if(re_src&&typeof re_src.source==='string'&&typeof re_src.flags==='string'&&typeof re_src.toString==='function'&&typeof re_src.test==='function'&&typeof re_src.exec==='function'){// we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member // and the `.toString()` method to produce something that's compileable by XRegExp // at least... @@ -554,7 +568,7 @@ if(re_src==null){return new Error('invalid regular expression source: '+re_src); // The default assumed is the standard JavaScript `RegExp` class. // // Return FALSE when the input is not a legal regex. -function getRegExpInfo(re_src,re_flags,XRegExp){var re1,re2,m1,m2;// were we fed a RegExp object or a string? +function getRegExpInfo(re_src,re_flags,XRegExp){let re1,re2,m1,m2;// were we fed a RegExp object or a string? if(re_src&&typeof re_src.source==='string'&&typeof re_src.flags==='string'&&typeof re_src.toString==='function'&&typeof re_src.test==='function'&&typeof re_src.exec==='function'){// we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member // and the `.toString()` method to produce something that's compileable by XRegExp // at least... @@ -566,32 +580,41 @@ return false;}else{re_src=''+re_src;if(re_flags==null){re_flags=undefined;// `ne // wrap it and append `(?:)` to ensure it matches // the empty string, then match it against it to // obtain the `match` array. -re1=new XRegExp(re_src,re_flags);re2=new XRegExp('(?:'+re_src+')|(?:)',re_flags);m1=re1.exec('');m2=re2.exec('');return{acceptsEmptyString:!!m1,captureCount:m2.length-1};}catch(ex){return false;}}var reHelpers={checkRegExp:checkRegExp,getRegExpInfo:getRegExpInfo};var cycleref=[];var cyclerefpath=[];var linkref=[];var linkrefpath=[];var path=[];function shallow_copy(src){if(typeof src==='object'){if(src instanceof Array){return src.slice();}var dst={};if(src instanceof Error){dst.name=src.name;dst.message=src.message;dst.stack=src.stack;}for(var k in src){if(Object.prototype.hasOwnProperty.call(src,k)){dst[k]=src[k];}}return dst;}return src;}function shallow_copy_and_strip_depth(src,parentKey){if(typeof src==='object'){var dst;if(src instanceof Array){dst=src.slice();for(var i=0,len=dst.length;i '+parentKey+'.'+k+']';}else{dst[k]=src[k];}}}}return dst;}return src;}function stripErrorStackPaths(msg){// strip away devbox-specific paths in error stack traces in the output: -msg=msg.replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi,'at $1(/$2)').replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi,'at /$1');return msg;}function trim_array_tail(arr){if(arr instanceof Array){for(var len=arr.length;len>0;len--){if(arr[len-1]!=null){break;}}arr.length=len;}}function treat_value_stack(v){if(v instanceof Array){var idx=cycleref.indexOf(v);if(idx>=0){v='[cyclic reference to parent array --> '+cyclerefpath[idx]+']';}else{idx=linkref.indexOf(v);if(idx>=0){v='[reference to sibling array --> '+linkrefpath[idx]+', length = '+v.length+']';}else{cycleref.push(v);cyclerefpath.push(path.join('.'));linkref.push(v);linkrefpath.push(path.join('.'));v=treat_error_infos_array(v);cycleref.pop();cyclerefpath.pop();}}}else if(v){v=treat_object(v);}return v;}function treat_error_infos_array(arr){var inf=arr.slice();trim_array_tail(inf);for(var key=0,len=inf.length;key '+parentKey+'.'+k+']';}else{dst[k]=src[k];}}}}return dst;}return src;}// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. +function stripErrorStackPaths(msg){// strip away devbox-specific paths in error stack traces in the output: +// and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': +msg=msg.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi,'at $1(/$2:$3)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi,'at /$1:$2');return msg;}// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj){if(typeof obj==='string'){// and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': +let msg=obj.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi,'at $1(/$2)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi,'at /$1');return msg;}if(obj){if(obj.stack){obj.stack=cleanStackTrace4Comparison(obj.stack);}let keys=Object.keys(obj);for(let i in keys){let key=keys[i];let el=obj[key];cleanStackTrace4Comparison(el);}}return obj;}function trim_array_tail(arr){if(arr instanceof Array){for(var len=arr.length;len>0;len--){if(arr[len-1]!=null){break;}}arr.length=len;}}function treat_value_stack(v){if(v instanceof Array){let idx=cycleref.indexOf(v);if(idx>=0){v='[cyclic reference to parent array --> '+cyclerefpath[idx]+']';}else{idx=linkref.indexOf(v);if(idx>=0){v='[reference to sibling array --> '+linkrefpath[idx]+', length = '+v.length+']';}else{cycleref.push(v);cyclerefpath.push(path.join('.'));linkref.push(v);linkrefpath.push(path.join('.'));v=treat_error_infos_array(v);cycleref.pop();cyclerefpath.pop();}}}else if(v){v=treat_object(v);}return v;}function treat_error_infos_array(arr){let inf=arr.slice();trim_array_tail(inf);for(let key=0,len=inf.length;key=0){// cyclic reference, most probably an error instance. +e=shallow_copy(e);if(e&&e.hash){path.push('hash');e.hash=treat_hash(e.hash);path.pop();}if(e.parser){path.push('parser');e.parser=treat_parser(e.parser);path.pop();}if(e.lexer){path.push('lexer');e.lexer=treat_lexer(e.lexer);path.pop();}if(e.__error_infos){path.push('__error_infos');e.__error_infos=treat_value_stack(e.__error_infos);path.pop();}if(e.__error_recovery_infos){path.push('__error_recovery_infos');e.__error_recovery_infos=treat_value_stack(e.__error_recovery_infos);path.pop();}trim_array_tail(e.symbol_stack);trim_array_tail(e.state_stack);trim_array_tail(e.location_stack);if(e.value_stack){path.push('value_stack');e.value_stack=treat_value_stack(e.value_stack);path.pop();}return e;}function treat_object(e){if(e&&typeof e==='object'){let idx=cycleref.indexOf(e);if(idx>=0){// cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: e=shallow_copy_and_strip_depth(e,cyclerefpath[idx]);}else{idx=linkref.indexOf(e);if(idx>=0){e='[reference to sibling --> '+linkrefpath[idx]+']';}else{cycleref.push(e);cyclerefpath.push(path.join('.'));linkref.push(e);linkrefpath.push(path.join('.'));e=treat_error_report_info(e);cycleref.pop();cyclerefpath.pop();}}}return e;}// strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. -function trimErrorForTestReporting(e){cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];if(e){e=treat_object(e);}cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];return e;}var helpers={rmCommonWS,camelCase,mkIdentifier,isLegalIdentifierInput,scanRegExp,dquote,trimErrorForTestReporting,stripErrorStackPaths,checkRegExp:reHelpers.checkRegExp,getRegExpInfo:reHelpers.getRegExpInfo,exec:code_exec.exec,dump:code_exec.dump,generateMapper4JisonGrammarIdentifiers:parse2AST.generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST:parse2AST.parseCodeChunkToAST,compileCodeToES5:parse2AST.compileCodeToES5,prettyPrintAST:parse2AST.prettyPrintAST,checkActionBlock:parse2AST.checkActionBlock,trimActionCode:parse2AST.trimActionCode,ID_REGEX_BASE:parse2AST.ID_REGEX_BASE,IN_ID_CHARSET:parse2AST.IN_ID_CHARSET,printFunctionSourceCode:stringifier.printFunctionSourceCode,printFunctionSourceCodeContainer:stringifier.printFunctionSourceCodeContainer,detectIstanbulGlobal};// See also: +function trimErrorForTestReporting(e){cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];if(e){e=treat_object(e);}cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];return e;}var helpers={rmCommonWS,camelCase,mkIdentifier,isLegalIdentifierInput,scanRegExp,dquote,trimErrorForTestReporting,stripErrorStackPaths,cleanStackTrace4Comparison,checkRegExp:reHelpers.checkRegExp,getRegExpInfo:reHelpers.getRegExpInfo,exec:exec.exec,dump:exec.dump,convertExceptionToObject:exec.convertExceptionToObject,generateMapper4JisonGrammarIdentifiers:parse2AST.generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST:parse2AST.parseCodeChunkToAST,compileCodeToES5:parse2AST.compileCodeToES5,prettyPrintAST:parse2AST.prettyPrintAST,checkActionBlock:parse2AST.checkActionBlock,trimActionCode:parse2AST.trimActionCode,ID_REGEX_BASE:parse2AST.ID_REGEX_BASE,IN_ID_CHARSET:parse2AST.IN_ID_CHARSET,printFunctionSourceCode:stringifier.printFunctionSourceCode,printFunctionSourceCodeContainer:stringifier.printFunctionSourceCodeContainer,detectIstanbulGlobal};// 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. -function JisonParserError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonParserError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8/Chrome engine +function JisonParserError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonParserError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){let ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8/Chrome engine Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonParserError.prototype,Error.prototype);}else{JisonParserError.prototype=Object.create(Error.prototype);}JisonParserError.prototype.constructor=JisonParserError;JisonParserError.prototype.name='JisonParserError';// helper: reconstruct the productions[] table -function bp(s){var rv=[];var p=s.pop;var r=s.rule;for(var i=0,l=p.length;i1)return resultValue;// do not (yet) kill the sharedState when this is a reentrant run. @@ -734,23 +756,29 @@ stack.length=0;// fastest way to nuke an array without overly bothering the GC sstack.length=0;vstack.length=0;sp=0;// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return resultValue;};// NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return resultValue;};// NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! -this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){var pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,expected:expected,recoverable:recoverable,state:state,action:action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,stack_pointer:sp,yy:sharedState_yy,lexer:lexer,parser:this,// and make sure the error info doesn't stay due to potential +this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){const pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,expected,recoverable,state,action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,stack_pointer:sp,yy:sharedState_yy,lexer,parser:this,// and make sure the error info doesn't stay due to potential // ref cycle via userland code manipulations. // These would otherwise all be memory leak opportunities! // // Note that only array and object references are nuked as those // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. -destroy:function destructParseErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! -this.__error_infos.push(pei);return pei;};function getNonTerminalFromCode(symbol){var tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){var token=lexer.lex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){var token=lexer.fastLex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}var lex=stdLex;var state,action,r,t;var yyval={$:true,_$:undefined,yy:sharedState_yy};var p;var yyrulelen;var this_production;var newState;var retval=false;try{this.__reentrant_call_depth++;lexer.setInput(input,sharedState_yy);// NOTE: we *assume* no lexer pre/post handlers are set up *after* +destroy:function destructParseErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// info.value = null; +// info.value_stack = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +this.__error_infos.push(pei);return pei;};function getNonTerminalFromCode(symbol){let tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){let token=lexer.lex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){let token=lexer.fastLex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}let lex=stdLex;let state,action,r,t;let yyval={$:true,_$:undefined,yy:sharedState_yy};let p;let yyrulelen;let this_production;let newState;let retval=false;try{this.__reentrant_call_depth++;lexer.setInput(input,sharedState_yy);// NOTE: we *assume* no lexer pre/post handlers are set up *after* // this initial `setInput()` call: hence we can now check and decide // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: -if(typeof lexer.canIUse==='function'){var lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack +if(typeof lexer.canIUse==='function'){let lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack state=newState;// sstack[sp - 1]; // use default actions if available if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}else{// The single `==` condition below covers both these `===` comparisons in a single @@ -759,7 +787,7 @@ if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}els // if (symbol === null || typeof symbol === 'undefined') ... if(!symbol){symbol=lex();}// read action for current state and first input t=table[state]&&table[state][symbol]||NO_ACTION;newState=t[1];action=t[0];// handle parse error -if(!action){var errStr;var errSymbolDescr=this.describeSymbol(symbol)||symbol;var expected=this.collect_expected_token_set(state);// Report error +if(!action){let errStr;let errSymbolDescr=this.describeSymbol(symbol)||symbol;let expected=this.collect_expected_token_set(state);// Report error errStr='Parse error';if(typeof lexer.yylineno==='number'){errStr+=' on line '+(lexer.yylineno+1);}if(typeof lexer.showPosition==='function'){errStr+=':\n'+lexer.showPosition(79-10,10)+'\n';}else{errStr+=': ';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}// we cannot recover from the error! p=this.constructParseErrorInfo(errStr,null,expected,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}}switch(action){// catch misc. parse failures: default:// this shouldn't happen, unless resolve defaults are off @@ -767,16 +795,16 @@ if(action instanceof Array){p=this.constructParseErrorInfo('Parse Error: multipl // or a buggy LUT (LookUp Table): p=this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.',null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;// shift: case 1:stack[sp]=symbol;vstack[sp]=lexer.yytext;sstack[sp]=newState;// push state -if(typeof Jison!=='undefined'&&Jison.parserDebugger){var tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;// Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: +if(typeof Jison!=='undefined'&&Jison.parserDebugger){let tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;// Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: continue;// reduce: case 2:this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,newState,sp-1,vstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack +yyrulelen=this_production[1];r=this.performAction.call(yyval,newState,sp-1,vstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:if(sp!==-2){retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -1025,8 +1053,8 @@ return retval;}};parser.originalParseError=parser.parseError;parser.originalQuot * @public * @constructor * @nocollapse - */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 -Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';var lexer={// Code Generator Information Report + */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){const ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 +Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';const lexer={// Code Generator Information Report // --------------------------------- // // Options: @@ -1095,7 +1123,7 @@ CRLF_Re:/\r\n?|\n/,/** * @this {RegExpLexer} */constructLexErrorInfo:function lexer_constructLexErrorInfo(msg,recoverable,show_input_position){msg=''+msg;// heuristic to determine if the error message already contains a (partial) source code dump // as produced by either `showPosition()` or `prettyPrintRange()`: -if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){var pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){var pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */var pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... +if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){const pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){const pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */const pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:this,/** * and make sure the error info doesn't stay due to potential * ref cycle via userland code manipulations. @@ -1107,7 +1135,11 @@ text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:t * * @public * @this {LexErrorInfo} - */destroy:function destructLexErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! + */destroy:function destructLexErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;},/** * handler which is invoked when a lexer error occurs. * @@ -1118,8 +1150,8 @@ this.__error_infos.push(pei);return pei;},/** * * @public * @this {RegExpLexer} - */yyerror:function yyError(str/*, ...args */){var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** + */yyerror:function yyError(str/*, ...args */){let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: +let args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** * final cleanup function for when we have completed lexing the input; * make it an API so that external code can use this one once userland * code has decided it's time to destroy any lingering lexer error @@ -1134,13 +1166,13 @@ var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_a this.setInput('',{});// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** * clear the lexer token context; intended for internal use only * * @public * @this {RegExpLexer} */clear:function lexer_clear(){this.yytext='';this.yyleng=0;this.match='';// - DO NOT reset `this.matched` -this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** +this.matches=false;this._more=false;this._backtrack=false;const col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** * resets the lexer, sets new input * * @public @@ -1149,10 +1181,10 @@ this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.la // including expansion work to be done to go from a loaded // lexer to a usable lexer: if(!this.__decompressed){// step 1: decompress the regex list: -var rules=this.rules;for(var i=0,len=rules.length;i> tokens and perform user action code for a <> match, but only does so *once*) -return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}var ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). +return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}let ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. -var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;var ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** +let slice_len=1;let lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;const ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** * unshifts one char (or an entire string) into the input * * @public * @this {RegExpLexer} - */unput:function lexer_unput(ch){var len=ch.length;var lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** + */unput:function lexer_unput(ch){let len=ch.length;let lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** // The `offset` value MAY be negative if you `unput()` more text than you have already lexed. // This type of behaviour is generally observed for one kind of 'lexer/parser hack' // where custom token-illiciting characters are pushed in front of the input stream to help @@ -1222,11 +1254,11 @@ var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lin if(-this.offset>this.base_position){this.base_position=-this.offset;}this.match=this.match.substr(0,this.match.length-len);this.matched=this.matched.substr(0,this.matched.length-len);if(lines.length>1){this.yylineno-=lines.length-1;this.yylloc.last_line=this.yylineno+1;// Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. -var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** +let pre=this.match;let pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -1236,8 +1268,8 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */lookAhead:function lexer_lookAhead(){return this._input||'';},/** @@ -1254,7 +1286,7 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 */reject:function lexer_reject(){if(this.options.backtrack_lexer){this._backtrack=true;}else{// when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. -var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** +let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** * retain first n characters of the match * * @public @@ -1276,17 +1308,17 @@ var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yyl * * @public * @this {RegExpLexer} - */pastInput:function lexer_pastInput(maxSize,maxLines){var past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0)maxSize=Infinity;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=Infinity;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substr` anticipation: treat \r\n as a single character and take a little + */pastInput:function lexer_pastInput(maxSize,maxLines){let past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0){maxSize=Infinity;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=Infinity;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past=past.substr(-maxSize*2-2);// now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: -var a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, +let a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, // do add an ellipsis prefix... if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -1312,18 +1344,18 @@ if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} - */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){var next=this.match;var source=this._input||'';if(maxSize<0)maxSize=next.length+source.length;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=maxSize;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substring` anticipation: treat \r\n as a single character and take a little + */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){let next=this.match;let source=this._input||'';if(maxSize<0){maxSize=next.length+source.length;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=maxSize;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: if(next.lengthmaxSize){next=next.substring(0,maxSize)+'...';}return next;},/** @@ -1332,7 +1364,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){var pre=this.pastInput(maxPrefix).replace(/\s/g,' ');var c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** + */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){const pre=this.pastInput(maxPrefix).replace(/\s/g,' ');let c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** * return an YYLLOC info object derived off the given context (actual, preceding, following, current). * Use this method when the given `actual` location is not guaranteed to exist (i.e. when * it MAY be NULL) and you MUST have a valid location info object anyway: @@ -1348,7 +1380,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */deriveLocationInfo:function lexer_deriveYYLLOC(actual,preceding,following,current){var loc={first_line:1,first_column:0,last_line:1,last_column:0,range:[0,0]};if(actual){loc.first_line=actual.first_line|0;loc.last_line=actual.last_line|0;loc.first_column=actual.first_column|0;loc.last_column=actual.last_column|0;if(actual.range){loc.range[0]=actual.range[0]|0;loc.range[1]=actual.range[1]|0;}}if(loc.first_line<=0||loc.last_line=loc.first_line)){loc.last_line=current.last_line|0;loc.last_column=current.last_column|0;if(current.range){loc.range[1]=current.range[1]|0;}}}// sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter // or plan D heuristics to produce a 'sensible' last_line value: @@ -1397,9 +1429,9 @@ loc.range[1]=loc.range[0];}if(loc.first_column<0){loc.first_column=0;}if(loc.las * * @public * @this {RegExpLexer} - */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;var input=this.matched+(this._input||'');var lines=input.split('\n');var l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);var l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);var lineno_display_width=1+Math.log10(l1|1)|0;var ws_prefix=new Array(lineno_display_width).join(' ');var nonempty_line_indexes=[[],[],[]];var rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){var lno=index+l0;var lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);var rv=lno_pfx+': '+line;var errpfx=new Array(lineno_display_width+1).join('^');var offset=2+1;var len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it + */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;let input=this.matched+(this._input||'');let lines=input.split('\n');let l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);let l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);let lineno_display_width=1+Math.log10(l1|1)|0;let ws_prefix=new Array(lineno_display_width).join(' ');let nonempty_line_indexes=[[],[],[]];let rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){let lno=index+l0;let lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);let rv=lno_pfx+': '+line;let errpfx=new Array(lineno_display_width+1).join('^');let offset=2+1;let len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: -for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){var clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;var clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;var intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** +for(let i=0;i<=2;i++){let line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){let clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;let clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;let intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** * helper function, used to produce a human readable description as a string, given * the input `yylloc` location object. * @@ -1408,7 +1440,7 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){var l1=yylloc.first_line;var l2=yylloc.last_line;var c1=yylloc.first_column;var c2=yylloc.last_column;var dl=l2-l1;var dc=c2-c1;var rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){var r1=yylloc.range[0];var r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** + */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){let l1=yylloc.first_line;let l2=yylloc.last_line;let c1=yylloc.first_column;let c2=yylloc.last_column;let dl=l2-l1;let dc=c2-c1;let rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){let r1=yylloc.range[0];let r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** * test the lexed token: return FALSE when not a match, otherwise return token. * * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]` @@ -1425,18 +1457,18 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */test_match:function lexer_test_match(match,indexed_rule){var token,lines,backup,match_str,match_str_len;if(this.options.backtrack_lexer){// save context + */test_match:function lexer_test_match(match,indexed_rule){let backup;if(this.options.backtrack_lexer){// save context backup={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.yylloc.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column,range:this.yylloc.range.slice()},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,//_signaled_error_token: this._signaled_error_token, -yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}match_str=match[0];match_str_len=match_str.length;lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: +yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}let match_str=match[0];let match_str_len=match_str.length;let lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: // those rules will already have moved this `offset` forward matching their match lengths, // hence we must only add our own match length now: this.offset+=match_str_len;this._more=false;this._backtrack=false;this._input=this._input.slice(match_str_len);// calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} -token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: +let token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; if(this.done&&this._input){this.done=false;}if(token){return token;}else if(this._backtrack){// recover context -for(var k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. +for(let k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. }else if(this._signaled_error_token){// produce one 'error' token as `.parseError()` in `reject()` // did not guarantee a failure signal by throwing an exception! token=this._signaled_error_token;this._signaled_error_token=false;return token;}return false;},/** @@ -1444,19 +1476,19 @@ token=this._signaled_error_token;this._signaled_error_token=false;return token;} * * @public * @this {RegExpLexer} - */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}var token,match,tempMatch,index;if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}var spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. + */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}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();// Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 -if(!spec||!spec.rules){var lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! -return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}var rule_ids=spec.rules;var regexes=spec.__rule_regexes;var len=spec.__rule_count;// Note: the arrays are 1-based, while `len` itself is a valid index, +if(!spec||!spec.rules){let lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! +return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}{let rule_ids=spec.rules;let regexes=spec.__rule_regexes;let len=spec.__rule_count;let match;let index;// 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(var i=1;i<=len;i++){tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. +for(let i=1;i<=len;i++){let tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){let token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. }else{// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}}else if(!this.options.flex){break;}}}if(match){token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}if(!this._input){this.done=true;this.clear();return this.EOF;}else{var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);var pendingInput=this._input;var activeCondition=this.topState();var conditionStackDepth=this.conditionStack.length;token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us +return false;}}else if(!this.options.flex){break;}}}if(match){let token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) +return false;}}if(!this._input){this.done=true;this.clear();return this.EOF;}{let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);let pendingInput=this._input;let activeCondition=this.topState();let conditionStackDepth=this.conditionStack.length;let token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: if(!this.matches&&// and make sure the input has been modified/consumed ... @@ -1467,7 +1499,7 @@ activeCondition===this.topState()&&conditionStackDepth===this.conditionStack.len * * @public * @this {RegExpLexer} - */lex:function lexer_lex(){var r;//this._clear_state = 0; + */lex:function lexer_lex(){let r;//this._clear_state = 0; if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}// allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer: if(typeof this.pre_lex==='function'){r=this.pre_lex.call(this,0);}if(typeof this.options.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.pre_lex.call(this,r)||r;}if(this.yy&&typeof this.yy.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) @@ -1475,50 +1507,50 @@ r=this.yy.pre_lex.call(this,r)||r;}while(!r){r=this.next();}if(this.yy&&typeof t r=this.yy.post_lex.call(this,r)||r;}if(typeof this.options.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.post_lex.call(this,r)||r;}if(typeof this.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.post_lex.call(this,r)||r;}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return next match that has a token. Identical to the `lex()` API but does not invoke any of the * `pre_lex()` nor any of the `post_lex()` callbacks. * * @public * @this {RegExpLexer} - */fastLex:function lexer_fastLex(){var r;//this._clear_state = 0; + */fastLex:function lexer_fastLex(){let r;//this._clear_state = 0; while(!r){r=this.next();}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return info about the lexer state that can help a parser or other lexer API user to use the * most efficient means available. This API is provided to aid run-time performance for larger @@ -1526,7 +1558,7 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */canIUse:function lexer_canIUse(){var rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** + */canIUse:function lexer_canIUse(){const rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** * backwards compatible alias for `pushState()`; * the latter is symmetrical with `popState()` and we advise to use * those APIs in any modern lexer code, rather than `begin()`. @@ -1545,20 +1577,20 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */popState:function lexer_popState(){var n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}else{return this.conditionStack[0];}},/** + */popState:function lexer_popState(){const n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}return this.conditionStack[0];},/** * return the currently active lexer condition state; when an index * argument is provided it produces the N-th previous condition state, * if available * * @public * @this {RegExpLexer} - */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}else{return'INITIAL';}},/** + */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}return'INITIAL';},/** * (internal) determine the lexer rule set which is active for the * currently active lexer condition state * * @public * @this {RegExpLexer} - */_currentRules:function lexer__currentRules(){var n=this.conditionStack.length-1;var state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions['INITIAL'];},/** + */_currentRules:function lexer__currentRules(){const n=this.conditionStack.length-1;let state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions.INITIAL;},/** * return the number of states currently on the stack * * @public @@ -1570,11 +1602,11 @@ const ID_REGEX_BASE$1='[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*';// prod // Use this to produce rule productions from transformed EBNF which are // guaranteed not to collide with previously generated / already existing // rules (~ symbols). -function generateUniqueSymbol(id,postfix,opts){var sym=id+postfix;if(opts.grammar[sym]){var i=2;// the first occurrence won't have a number, this is already a collision, so start numbering at *2*. -do{sym=id+postfix+i;i++;}while(opts.grammar[sym]);}return sym;}function generatePushAction(handle,offset){var terms=handle.terms;var rv=[];for(var i=0,len=terms.length;i1){rv='['+rv+']';}return rv;}function transformExpression(e,opts,emit){var type=e[0],value=e[1],name=false,has_transformed=0;var list,n;if(type==='xalias'){type=e[1];value=e[2];name=e[3];if(type){e=e.slice(1);}else{e=value;type=e[0];value=e[1];}}if(type==='symbol'){n=e[1];emit(n+(name?'['+name+']':''));}else if(type==='+'){if(!name){name=generateUniqueSymbol(opts.production,'_repetition_plus',opts);}emit(name);has_transformed=1;opts=optsForProduction(name,opts.grammar);list=transformExpressionList([value],opts);opts.grammar[name]=[[list.fragment,'$$ = ['+generatePushAction(list,1)+'];'],[name+' '+list.fragment,'$1.push('+generatePushAction(list,2)+');\n$$ = $1;']];}else if(type==='*'){if(!name){name=generateUniqueSymbol(opts.production,'_repetition',opts);}emit(name);has_transformed=1;opts=optsForProduction(name,opts.grammar);list=transformExpressionList([value],opts);opts.grammar[name]=[['','$$ = [];'],[name+' '+list.fragment,'$1.push('+generatePushAction(list,2)+');\n$$ = $1;']];}else if(type==='?'){if(!name){name=generateUniqueSymbol(opts.production,'_option',opts);}emit(name);has_transformed=1;opts=optsForProduction(name,opts.grammar);list=transformExpressionList([value],opts);// you want to be able to check if 0 or 1 occurrences were recognized: since jison +if(len>1){rv='['+rv+']';}return rv;}function transformExpression(e,opts,emit){let type=e[0];let value=e[1];let name=false;let has_transformed=0;let list,n;if(type==='xalias'){type=e[1];value=e[2];name=e[3];if(type){e=e.slice(1);}else{e=value;type=e[0];value=e[1];}}if(type==='symbol'){n=e[1];emit(n+(name?'['+name+']':''));}else if(type==='+'){if(!name){name=generateUniqueSymbol(opts.production,'_repetition_plus',opts);}emit(name);has_transformed=1;opts=optsForProduction(name,opts.grammar);list=transformExpressionList([value],opts);opts.grammar[name]=[[list.fragment,'$$ = ['+generatePushAction(list,1)+'];'],[name+' '+list.fragment,'$1.push('+generatePushAction(list,2)+');\n$$ = $1;']];}else if(type==='*'){if(!name){name=generateUniqueSymbol(opts.production,'_repetition',opts);}emit(name);has_transformed=1;opts=optsForProduction(name,opts.grammar);list=transformExpressionList([value],opts);opts.grammar[name]=[['','$$ = [];'],[name+' '+list.fragment,'$1.push('+generatePushAction(list,2)+');\n$$ = $1;']];}else if(type==='?'){if(!name){name=generateUniqueSymbol(opts.production,'_option',opts);}emit(name);has_transformed=1;opts=optsForProduction(name,opts.grammar);list=transformExpressionList([value],opts);// you want to be able to check if 0 or 1 occurrences were recognized: since jison // by default *copies* the lexer token value, i.e. `$$ = $1` is the (optional) default action, // we will need to set the action up explicitly in case of the 0-count match: // `$$ = undefined`. @@ -1582,43 +1614,43 @@ if(len>1){rv='['+rv+']';}return rv;}function transformExpression(e,opts,emit){va // Note that we MUST return an array as the // '1 occurrence' match CAN carry multiple terms, e.g. in constructs like // `(T T T)?`, which would otherwise be unrecognizable from the `T*` construct. -opts.grammar[name]=[['','$$ = undefined;'],[list.fragment,'$$ = '+generatePushAction(list,1)+';']];}else if(type==='()'){if(value.length===1&&!name){list=transformExpressionList(value[0],opts);if(list.first_transformed_term_index){has_transformed=list.first_transformed_term_index;}emit(list);}else{if(!name){name=generateUniqueSymbol(opts.production,'_group',opts);}emit(name);has_transformed=1;opts=optsForProduction(name,opts.grammar);opts.grammar[name]=value.map(function(handle){var list=transformExpressionList(handle,opts);return[list.fragment,'$$ = '+generatePushAction(list,1)+';'];});}}return has_transformed;}function transformExpressionList(list,opts){var first_transformed_term_index=false;var terms=list.reduce(function(tot,e){var ci=tot.length;var has_transformed=transformExpression(e,opts,function(name){if(name.terms){tot.push.apply(tot,name.terms);}else{tot.push(name);}});if(has_transformed){first_transformed_term_index=ci+has_transformed;}return tot;},[]);return{fragment:terms.join(' '),terms:terms,first_transformed_term_index:first_transformed_term_index// 1-based index -};}function optsForProduction(id,grammar){return{production:id,grammar:grammar};}function transformProduction(id,production,grammar){var transform_opts=optsForProduction(id,grammar);return production.map(function(handle){var action=null,opts=null;var i,len,n;if(typeof handle!=='string'){action=handle[1];opts=handle[2];handle=handle[0];}var expressions=handle;if(typeof expressions==='string'){expressions=parser$1.parse(handle);}var list=transformExpressionList(expressions,transform_opts);var ret=[list.fragment];if(action){// make sure the action doesn't address any inner items. +opts.grammar[name]=[['','$$ = undefined;'],[list.fragment,'$$ = '+generatePushAction(list,1)+';']];}else if(type==='()'){if(value.length===1&&!name){list=transformExpressionList(value[0],opts);if(list.first_transformed_term_index){has_transformed=list.first_transformed_term_index;}emit(list);}else{if(!name){name=generateUniqueSymbol(opts.production,'_group',opts);}emit(name);has_transformed=1;opts=optsForProduction(name,opts.grammar);opts.grammar[name]=value.map(function(handle){let list=transformExpressionList(handle,opts);return[list.fragment,'$$ = '+generatePushAction(list,1)+';'];});}}return has_transformed;}function transformExpressionList(list,opts){let first_transformed_term_index=false;let terms=list.reduce(function(tot,e){let ci=tot.length;let has_transformed=transformExpression(e,opts,function(name){if(name.terms){tot.push.apply(tot,name.terms);}else{tot.push(name);}});if(has_transformed){first_transformed_term_index=ci+has_transformed;}return tot;},[]);return{fragment:terms.join(' '),terms:terms,first_transformed_term_index:first_transformed_term_index// 1-based index +};}function optsForProduction(id,grammar){return{production:id,grammar:grammar};}function transformProduction(id,production,grammar){let transform_opts=optsForProduction(id,grammar);return production.map(function(handle){let action=null;let opts=null;let i,len,n;if(typeof handle!=='string'){action=handle[1];opts=handle[2];handle=handle[0];}let expressions=handle;if(typeof expressions==='string'){expressions=parser$1.parse(handle);}let list=transformExpressionList(expressions,transform_opts);let ret=[list.fragment];if(action){// make sure the action doesn't address any inner items. if(list.first_transformed_term_index){// seek out all names and aliases; strip out literal tokens first as those cannot serve as $names: -var alist=list.terms;// rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); -var alias_re=new XRegExp__default['default'](`\\[${ID_REGEX_BASE$1}\\]`);var term_re=new XRegExp__default['default'](`^${ID_REGEX_BASE$1}$`);// and collect the PERMITTED aliases: the names of the terms and all the remaining aliases -var good_aliases={};var alias_cnt={};var donotalias={};// WARNING: this replicates the knowledge/code of jison.js::addName() -var addName=function addNameEBNF(s,i){var base=s.replace(/[0-9]+$/,'');var dna=donotalias[base];if(good_aliases[s]){alias_cnt[s]++;if(!dna){good_aliases[s+alias_cnt[s]]=i+1;alias_cnt[s+alias_cnt[s]]=1;}}else{good_aliases[s]=i+1;alias_cnt[s]=1;if(!dna){good_aliases[s+alias_cnt[s]]=i+1;alias_cnt[s+alias_cnt[s]]=1;}}};// WARNING: this replicates the knowledge/code of jison.js::markBasename() -var markBasename=function markBasenameEBNF(s){if(/[0-9]$/.test(s)){s=s.replace(/[0-9]+$/,'');donotalias[s]=true;}};// mark both regular and aliased names, e.g., `id[alias1]` and `id1` +let alist=list.terms;// rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); +let alias_re=new XRegExp__default['default'](`\\[${ID_REGEX_BASE$1}\\]`);let term_re=new XRegExp__default['default'](`^${ID_REGEX_BASE$1}$`);// and collect the PERMITTED aliases: the names of the terms and all the remaining aliases +let good_aliases={};let alias_cnt={};let donotalias={};// WARNING: this replicates the knowledge/code of jison.js::addName() +let addName=function addNameEBNF(s,i){let base=s.replace(/[0-9]+$/,'');let dna=donotalias[base];if(good_aliases[s]){alias_cnt[s]++;if(!dna){good_aliases[s+alias_cnt[s]]=i+1;alias_cnt[s+alias_cnt[s]]=1;}}else{good_aliases[s]=i+1;alias_cnt[s]=1;if(!dna){good_aliases[s+alias_cnt[s]]=i+1;alias_cnt[s+alias_cnt[s]]=1;}}};// WARNING: this replicates the knowledge/code of jison.js::markBasename() +let markBasename=function markBasenameEBNF(s){if(/[0-9]$/.test(s)){s=s.replace(/[0-9]+$/,'');donotalias[s]=true;}};// mark both regular and aliased names, e.g., `id[alias1]` and `id1` // // WARNING: this replicates the knowledge/code of jison.js::markBasename()+addName() usage for(i=0,len=alist.length;imax_term_index){/* @const */var n_suffixes=['st','nd','rd','th'];throw new Error('The action block references the '+n+n_suffixes[Math.max(0,Math.min(3,n-1))]+' term, '+'which is not available in production "'+handle+'"; '+'Be reminded that you cannot reference sub-elements within EBNF */+/? groups, '+'only the outer-most EBNF group alias will remain available at all times '+'due to the EBNF-to-BNF rewrite process.');}}}}ret.push(action);}if(opts){ret.push(opts);}if(ret.length===1){return ret[0];}else{return ret;}});}var ref_list;var ref_names;// create a deep copy of the input, so we will keep the input constant. -function deepClone(from,sub){if(sub==null){ref_list=[];ref_names=[];sub='root';}if(typeof from==='function')return from;if(from==null||typeof from!=='object')return from;if(from.constructor!==Object&&from.constructor!==Array){return from;}var idx=ref_list.indexOf(from);if(idx>=0){throw new Error('[Circular/Xref:'+ref_names[i]+']');// circular or cross reference -}ref_list.push(from);ref_names.push(sub);if(from.constructor===Array){var to=from.slice();for(var i=0,len=to.length;imax_term_index){/* @const */let n_suffixes=['st','nd','rd','th'];throw new Error('The action block references the '+n+n_suffixes[Math.max(0,Math.min(3,n-1))]+' term, '+'which is not available in production "'+handle+'"; '+'Be reminded that you cannot reference sub-elements within EBNF */+/? groups, '+'only the outer-most EBNF group alias will remain available at all times '+'due to the EBNF-to-BNF rewrite process.');}}}}ret.push(action);}if(opts){ret.push(opts);}if(ret.length===1){return ret[0];}return ret;});}let ref_list;let ref_names;// create a deep copy of the input, so we will keep the input constant. +function deepClone(from,sub){if(sub==null){ref_list=[];ref_names=[];sub='root';}if(typeof from==='function')return from;if(from==null||typeof from!=='object')return from;if(from.constructor!==Object&&from.constructor!==Array){return from;}let idx=ref_list.indexOf(from);if(idx>=0){throw new Error('[Circular/Xref:'+ref_names[i]+']');// circular or cross reference +}ref_list.push(from);ref_names.push(sub);if(from.constructor===Array){var to=from.slice();for(var i=0,len=to.length;i=0);// append to the old one? -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; +if(this.yyError){this.yyError=function yyError(str/*, ...args */){let error_rule_depth=this.options.parserErrorsAreRecoverable?locateNearestErrorRecoveryRule(state):-1;let expected=this.collect_expected_token_set(state);let hash=this.constructParseErrorInfo(str,null,expected,error_rule_depth>=0);// append to the old one? +if(recoveringErrorInfo){let esp=recoveringErrorInfo.info_stack_pointer;recoveringErrorInfo.symbol_stack[esp]=symbol;let 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;recoveringErrorInfo.info_stack_pointer=esp;}else{recoveringErrorInfo=this.shallowCopyErrorInfo(hash);recoveringErrorInfo.yyError=true;recoveringErrorInfo.errorRuleDepth=error_rule_depth;recoveringErrorInfo.recovering=recovering;}// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){hash.extra_error_attributes=args;}return this.parseError(str,hash,this.JisonParserError);};}// Does the shared state override the default `parseError` that already comes with this instance? +let args=Array.prototype.slice.call(arguments,1);if(args.length){hash.extra_error_attributes=args;}return this.parseError(str,hash,this.JisonParserError);};}// Does the shared state override the default `parseError` that already comes with this instance? if(typeof sharedState_yy.parseError==='function'){this.parseError=function parseErrorAlt(str,hash,ExceptionClass){if(!ExceptionClass){ExceptionClass=this.JisonParserError;}return sharedState_yy.parseError.call(this,str,hash,ExceptionClass);};}else{this.parseError=this.originalParseError;}// Does the shared state override the default `quoteName` that already comes with this instance? if(typeof sharedState_yy.quoteName==='function'){this.quoteName=function quoteNameAlt(id_str){return sharedState_yy.quoteName.call(this,id_str);};}else{this.quoteName=this.originalQuoteName;}// set up the cleanup function; make it an API so that external code can re-use this one in case of // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which @@ -2202,7 +2233,7 @@ if(typeof sharedState_yy.quoteName==='function'){this.quoteName=function quoteNa // // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! -this.cleanupAfterParse=function parser_cleanupAfterParse(resultValue,invoke_post_methods,do_not_nuke_errorinfos){var rv;if(invoke_post_methods){var hash;if(sharedState_yy.post_parse||this.post_parse){// create an error hash info instance: we re-use this API in a **non-error situation** +this.cleanupAfterParse=function parser_cleanupAfterParse(resultValue,invoke_post_methods,do_not_nuke_errorinfos){let rv;if(invoke_post_methods){let hash;if(sharedState_yy.post_parse||this.post_parse){// create an error hash info instance: we re-use this API in a **non-error situation** // as this one delivers all parser internals ready for access by userland code. hash=this.constructParseErrorInfo(null/* no error! */,null/* no exception! */,null,false);}if(sharedState_yy.post_parse){rv=sharedState_yy.post_parse.call(this,sharedState_yy,resultValue,hash);if(typeof rv!=='undefined')resultValue=rv;}if(this.post_parse){rv=this.post_parse.call(this,sharedState_yy,resultValue,hash);if(typeof rv!=='undefined')resultValue=rv;}// cleanup: if(hash&&hash.destroy){hash.destroy();}}if(this.__reentrant_call_depth>1)return resultValue;// do not (yet) kill the sharedState when this is a reentrant run. @@ -2214,7 +2245,7 @@ stack.length=0;// fastest way to nuke an array without overly bothering the GC sstack.length=0;lstack.length=0;vstack.length=0;sp=0;// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;for(var i=this.__error_recovery_infos.length-1;i>=0;i--){var el=this.__error_recovery_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_recovery_infos.length=0;// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array, +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;for(let i=this.__error_recovery_infos.length-1;i>=0;i--){let el=this.__error_recovery_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_recovery_infos.length=0;// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array, // hence has been destroyed already: no need to do that *twice*. if(recoveringErrorInfo){recoveringErrorInfo=undefined;}}return resultValue;};// merge yylloc info into a new yylloc instance. // @@ -2228,32 +2259,38 @@ if(recoveringErrorInfo){recoveringErrorInfo=undefined;}}return resultValue;};// // yylloc info. // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. -this.yyMergeLocationInfo=function parser_yyMergeLocationInfo(first_index,last_index,first_yylloc,last_yylloc,dont_look_back){var i1=first_index|0,i2=last_index|0;var l1=first_yylloc,l2=last_yylloc;var rv;// rules: +this.yyMergeLocationInfo=function parser_yyMergeLocationInfo(first_index,last_index,first_yylloc,last_yylloc,dont_look_back){let i1=first_index|0;let i2=last_index|0;let l1=first_yylloc;let l2=last_yylloc;let rv;// rules: // - first/last yylloc entries override first/last indexes -if(!l1){if(first_index!=null){for(var i=i1;i<=i2;i++){l1=lstack[i];if(l1){break;}}}}if(!l2){if(last_index!=null){for(var i=i2;i>=i1;i--){l2=lstack[i];if(l2){break;}}}}// - detect if an epsilon rule is being processed and act accordingly: +if(!l1){if(first_index!=null){for(let i=i1;i<=i2;i++){l1=lstack[i];if(l1){break;}}}}if(!l2){if(last_index!=null){for(let i=i2;i>=i1;i--){l2=lstack[i];if(l2){break;}}}}// - detect if an epsilon rule is being processed and act accordingly: if(!l1&&first_index==null){// epsilon rule span merger. With optional look-ahead in l2. -if(!dont_look_back){for(var i=(i1||sp)-1;i>=0;i--){l1=lstack[i];if(l1){break;}}}if(!l1){if(!l2){// when we still don't have any valid yylloc info, we're looking at an epsilon rule +if(!dont_look_back){for(let i=(i1||sp)-1;i>=0;i--){l1=lstack[i];if(l1){break;}}}if(!l1){if(!l2){// when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: -return undefined;}else{// shallow-copy L2: after all, we MAY be looking +return null;}// shallow-copy L2: after all, we MAY be looking // at unconventional yylloc info objects... -rv=this.copy_yylloc(l2);return rv;}}else{// shallow-copy L1, then adjust first col/row 1 column past the end. +rv=this.copy_yylloc(l2);return rv;}// shallow-copy L1, then adjust first col/row 1 column past the end. rv=this.copy_yylloc(l1);rv.first_line=rv.last_line;rv.first_column=rv.last_column;rv.range[0]=rv.range[1];if(l2){// shallow-mixin L2, then adjust last col/row accordingly. -shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;}}if(!l1){l1=l2;l2=null;}if(!l1){return undefined;}// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking +shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;}if(!l1){l1=l2;l2=null;}if(!l1){return null;}// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... rv=this.copy_yylloc(l1);if(l2){shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;};// NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! -this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){var pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,loc:this.copy_yylloc(lexer.yylloc),expected:expected,recoverable:recoverable,state:state,action:action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,location_stack:lstack,stack_pointer:sp,yy:sharedState_yy,lexer:lexer,parser:this,// and make sure the error info doesn't stay due to potential +this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){const pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,loc:this.copy_yylloc(lexer.yylloc),expected,recoverable,state,action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,location_stack:lstack,stack_pointer:sp,yy:sharedState_yy,lexer,parser:this,// and make sure the error info doesn't stay due to potential // ref cycle via userland code manipulations. // These would otherwise all be memory leak opportunities! // // Note that only array and object references are nuked as those // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. -destroy:function destructParseErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +destroy:function destructParseErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// info.value = null; +// info.value_stack = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;};// clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. -this.shallowCopyErrorInfo=function parser_shallowCopyErrorInfo(p){var rv=shallow_copy(p);// remove the large parts which can only cause cyclic references +this.shallowCopyErrorInfo=function parser_shallowCopyErrorInfo(p){let rv=shallow_copy(p);// remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. delete rv.sharedState_yy;delete rv.parser;delete rv.lexer;// lexer.yytext MAY be a complex value object, rather than a simple string/value: rv.value=this.copy_yytext(rv.value);// yylloc info: @@ -2305,15 +2342,15 @@ rv.value_stack=rv.value_stack.map(this.copy_yytext);// and we don't bother with // - root_failure_pointer: // copy of the `stack_pointer`... // -for(var i=rv.stack_pointer;rv.state_stack[i]!=null;i++){// empty -}rv.base_pointer=i;rv.info_stack_pointer=i;rv.root_failure_pointer=rv.stack_pointer;// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! -this.__error_recovery_infos.push(rv);return rv;};function getNonTerminalFromCode(symbol){var tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){var token=lexer.lex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){var token=lexer.fastLex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}var lex=stdLex;var state,action,r,t;var yyval={$:true,_$:undefined,yy:sharedState_yy};var p;var yyrulelen;var this_production;var newState;var retval=false;// Return the rule stack depth where the nearest error rule can be found. +{let i;for(i=rv.stack_pointer;rv.state_stack[i]!=null;i++){// empty +}rv.base_pointer=i;rv.info_stack_pointer=i;}rv.root_failure_pointer=rv.stack_pointer;// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +this.__error_recovery_infos.push(rv);return rv;};function getNonTerminalFromCode(symbol){let tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){let token=lexer.lex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){let token=lexer.fastLex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}let lex=stdLex;let state,action,r,t;let yyval={$:true,_$:undefined,yy:sharedState_yy};let p;let yyrulelen;let this_production;let newState;let retval=false;// Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. -function locateNearestErrorRecoveryRule(state){var stack_probe=sp-1;var depth=0;// try to recover from error +function locateNearestErrorRecoveryRule(state){let stack_probe=sp-1;let depth=0;// try to recover from error while(stack_probe>=0){// check for error recovery rule in this state -var t=table[state]&&table[state][TERROR]||NO_ACTION;if(t[0]){// We need to make sure we're not cycling forever: +const t=table[state]&&table[state][TERROR]||NO_ACTION;if(t[0]){// We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must // prevent the core from running forever, // e.g. when parent rules are still expecting certain input to @@ -2334,7 +2371,7 @@ state=sstack[stack_probe];++depth;}return-1;// No suitable error recovery rule a // this initial `setInput()` call: hence we can now check and decide // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: -if(typeof lexer.canIUse==='function'){var lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}yyloc=this.copy_yylloc(lexer.yylloc);lstack[sp]=yyloc;vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack +if(typeof lexer.canIUse==='function'){let lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}yyloc=this.copy_yylloc(lexer.yylloc);lstack[sp]=yyloc;vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack state=newState;// sstack[sp - 1]; // use default actions if available if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}else{// The single `==` condition below covers both these `===` comparisons in a single @@ -2344,7 +2381,7 @@ if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}els if(!symbol){symbol=lex();}// read action for current state and first input t=table[state]&&table[state][symbol]||NO_ACTION;newState=t[1];action=t[0];// handle parse error if(!action){// first see if there's any chance at hitting an error recovery rule: -var error_rule_depth=locateNearestErrorRecoveryRule(state);var errStr=null;var errSymbolDescr=this.describeSymbol(symbol)||symbol;var expected=this.collect_expected_token_set(state);if(!recovering){// Report error +let error_rule_depth=locateNearestErrorRecoveryRule(state);let errStr=null;let errSymbolDescr=this.describeSymbol(symbol)||symbol;let expected=this.collect_expected_token_set(state);if(!recovering){// Report error errStr='Parse error';if(typeof lexer.yylineno==='number'){errStr+=' on line '+(lexer.yylineno+1);}if(typeof lexer.showPosition==='function'){errStr+=':\n'+lexer.showPosition(79-10,10)+'\n';}else{errStr+=': ';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}p=this.constructParseErrorInfo(errStr,null,expected,error_rule_depth>=0);// DO NOT cleanup the old one before we start the new error info track: // the old one will *linger* on the error stack and stay alive until we // invoke the parser's cleanup API! @@ -2352,20 +2389,20 @@ recoveringErrorInfo=this.shallowCopyErrorInfo(p);r=this.parseError(p.errStr,p,th // the `recoverable` flag without properly checking first: // we always terminate the parse when there's no recovery rule available anyhow! if(!p.recoverable||error_rule_depth<0){break;}else{// TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process... -}}var esp=recoveringErrorInfo.info_stack_pointer;// just recovered from another error +}}let esp=recoveringErrorInfo.info_stack_pointer;// just recovered from another error if(recovering===ERROR_RECOVERY_TOKEN_DISCARD_COUNT&&error_rule_depth>=0){// Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc=this.copy_yylloc(lexer.yylloc);// SHIFT current lookahead and grab another recoveringErrorInfo.symbol_stack[esp]=symbol;recoveringErrorInfo.location_stack[esp]=yyloc;recoveringErrorInfo.state_stack[esp]=newState;// push state ++esp;preErrorSymbol=0;symbol=lex();}// try to recover from error -if(error_rule_depth<0){ASSERT(recovering>0,"line 897");recoveringErrorInfo.info_stack_pointer=esp;// barf a fatal hairball when we're out of look-ahead symbols and none hit a match +if(error_rule_depth<0){ASSERT(recovering>0,'Line 1048');recoveringErrorInfo.info_stack_pointer=esp;// barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: -var po=this.__error_infos[this.__error_infos.length-1];// Report error +let po=this.__error_infos[this.__error_infos.length-1];// Report error if(typeof lexer.yylineno==='number'){errStr='Parsing halted on line '+(lexer.yylineno+1)+' while starting to recover from another error';}else{errStr='Parsing halted while starting to recover from another error';}if(po){errStr+=' -- previous error which resulted in this fatal result: '+po.errStr;}else{errStr+=': ';}if(typeof lexer.showPosition==='function'){errStr+='\n'+lexer.showPosition(79-10,10)+'\n';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}p=this.constructParseErrorInfo(errStr,null,expected,false);if(po){p.extra_error_attributes=po;}r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}preErrorSymbol=symbol===TERROR?0:symbol;// save the lookahead token symbol=TERROR;// insert generic error symbol as new lookahead const EXTRA_STACK_SAMPLE_DEPTH=3;// REDUCE/COMBINE the pushed terms/tokens to a new ERROR token: -recoveringErrorInfo.symbol_stack[esp]=preErrorSymbol;if(errStr){recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,errStr:errStr,errorSymbolDescr:errSymbolDescr,expectedStr:expected,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}else{recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}recoveringErrorInfo.location_stack[esp]=this.copy_yylloc(lexer.yylloc);recoveringErrorInfo.state_stack[esp]=newState||NO_ACTION[1];++esp;recoveringErrorInfo.info_stack_pointer=esp;yyval.$=recoveringErrorInfo;yyval._$=undefined;yyrulelen=error_rule_depth;r=this.performAction.call(yyval,yyloc,NO_ACTION[1],sp-1,vstack,lstack);if(typeof r!=='undefined'){retval=r;break;}// pop off stack +recoveringErrorInfo.symbol_stack[esp]=preErrorSymbol;if(errStr){recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,errStr,errSymbolDescr,expectedStr:expected,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}else{recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}recoveringErrorInfo.location_stack[esp]=this.copy_yylloc(lexer.yylloc);recoveringErrorInfo.state_stack[esp]=newState||NO_ACTION[1];++esp;recoveringErrorInfo.info_stack_pointer=esp;yyval.$=recoveringErrorInfo;yyval._$=undefined;yyrulelen=error_rule_depth;let combineState=NO_ACTION[1];r=this.performAction.call(yyval,yyloc,combineState,sp-1,vstack,lstack);if(typeof r!=='undefined'){retval=r;break;}// pop off stack sp-=yyrulelen;// and move the top entries + discarded part of the parse stacks onto the error info stack: -for(var idx=sp-EXTRA_STACK_SAMPLE_DEPTH,top=idx+yyrulelen;idx0){recovering--;}}else{// error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: -ASSERT(recovering>0,"line 1163");symbol=preErrorSymbol;preErrorSymbol=0;// read action for current state and first input +ASSERT(recovering>0,'Line 1352');symbol=preErrorSymbol;preErrorSymbol=0;// read action for current state and first input t=table[newState]&&table[newState][symbol]||NO_ACTION;if(!t[0]||symbol===TERROR){// forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where // (simple) stuff might have been missing before the token which caused the error we're // recovering from now... @@ -2456,17 +2493,17 @@ symbol=0;}}// once we have pushed the special ERROR token value, // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! -ASSERT(preErrorSymbol===0,"line 1194");if(recovering===0){break;}continue;// reduce: +ASSERT(preErrorSymbol===0,'Line 1383');if(recovering===0){break;}continue;// reduce: case 2:this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){// signal end of error recovery loop AND end of outer parse loop +yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){// signal end of error recovery loop AND end of outer parse loop action=3;retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}sp=-2;// magic number: signal outer "fast parse loop" ACCEPT state that we already have a properly set up `retval` parser return value. break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;lstack[sp]=yyval._$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -2494,26 +2531,26 @@ break;}// should we also break out of the regular/outer parse loop, // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? -ASSERT(action!==2,"line 1272");if(!action||action===1){continue;}}}switch(action){// catch misc. parse failures: +ASSERT(action!==2,'Line 1509');if(!action||action===1){continue;}}}switch(action){// catch misc. parse failures: default:// this shouldn't happen, unless resolve defaults are off if(action instanceof Array){p=this.constructParseErrorInfo('Parse Error: multiple actions possible at state: '+state+', token: '+symbol,null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}// Another case of better safe than sorry: in case state transitions come out of another error recovery process // or a buggy LUT (LookUp Table): p=this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.',null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;// shift: case 1:stack[sp]=symbol;vstack[sp]=lexer.yytext;lstack[sp]=this.copy_yylloc(lexer.yylloc);sstack[sp]=newState;// push state -if(typeof Jison!=='undefined'&&Jison.parserDebugger){var tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;ASSERT(preErrorSymbol===0,"line 1352");// normal execution / no error -ASSERT(recovering===0,"line 1353");// normal execution / no error +if(typeof Jison!=='undefined'&&Jison.parserDebugger){let tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;ASSERT(preErrorSymbol===0,'Line 1619');// normal execution / no error +ASSERT(recovering===0,'Line 1620');// normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc=this.copy_yylloc(lexer.yylloc);continue;// reduce: -case 2:ASSERT(preErrorSymbol===0,"line 1364");// normal execution / no error -ASSERT(recovering===0,"line 1365");// normal execution / no error +case 2:ASSERT(preErrorSymbol===0,'Line 1631');// normal execution / no error +ASSERT(recovering===0,'Line 1632');// normal execution / no error this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack +yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;lstack[sp]=yyval._$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:if(sp!==-2){retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -2762,8 +2799,8 @@ return retval;},yyError:1};parser$2.originalParseError=parser$2.parseError;parse * @public * @constructor * @nocollapse - */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 -Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';var lexer={// Code Generator Information Report + */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){const ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 +Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';const lexer={// Code Generator Information Report // --------------------------------- // // Options: @@ -2832,7 +2869,7 @@ CRLF_Re:/\r\n?|\n/,/** * @this {RegExpLexer} */constructLexErrorInfo:function lexer_constructLexErrorInfo(msg,recoverable,show_input_position){msg=''+msg;// heuristic to determine if the error message already contains a (partial) source code dump // as produced by either `showPosition()` or `prettyPrintRange()`: -if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){var pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){var pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */var pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... +if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){const pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){const pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */const pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:this,/** * and make sure the error info doesn't stay due to potential * ref cycle via userland code manipulations. @@ -2844,7 +2881,11 @@ text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:t * * @public * @this {LexErrorInfo} - */destroy:function destructLexErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! + */destroy:function destructLexErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;},/** * handler which is invoked when a lexer error occurs. * @@ -2855,8 +2896,8 @@ this.__error_infos.push(pei);return pei;},/** * * @public * @this {RegExpLexer} - */yyerror:function yyError(str/*, ...args */){var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** + */yyerror:function yyError(str/*, ...args */){let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: +let args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** * final cleanup function for when we have completed lexing the input; * make it an API so that external code can use this one once userland * code has decided it's time to destroy any lingering lexer error @@ -2871,13 +2912,13 @@ var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_a this.setInput('',{});// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** * clear the lexer token context; intended for internal use only * * @public * @this {RegExpLexer} */clear:function lexer_clear(){this.yytext='';this.yyleng=0;this.match='';// - DO NOT reset `this.matched` -this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** +this.matches=false;this._more=false;this._backtrack=false;const col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** * resets the lexer, sets new input * * @public @@ -2886,10 +2927,10 @@ this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.la // including expansion work to be done to go from a loaded // lexer to a usable lexer: if(!this.__decompressed){// step 1: decompress the regex list: -var rules=this.rules;for(var i=0,len=rules.length;i> tokens and perform user action code for a <> match, but only does so *once*) -return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}var ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). +return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}let ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. -var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;var ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** +let slice_len=1;let lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;const ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** * unshifts one char (or an entire string) into the input * * @public * @this {RegExpLexer} - */unput:function lexer_unput(ch){var len=ch.length;var lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** + */unput:function lexer_unput(ch){let len=ch.length;let lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** // The `offset` value MAY be negative if you `unput()` more text than you have already lexed. // This type of behaviour is generally observed for one kind of 'lexer/parser hack' // where custom token-illiciting characters are pushed in front of the input stream to help @@ -2959,11 +3000,11 @@ var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lin if(-this.offset>this.base_position){this.base_position=-this.offset;}this.match=this.match.substr(0,this.match.length-len);this.matched=this.matched.substr(0,this.matched.length-len);if(lines.length>1){this.yylineno-=lines.length-1;this.yylloc.last_line=this.yylineno+1;// Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. -var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** +let pre=this.match;let pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -2973,8 +3014,8 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */lookAhead:function lexer_lookAhead(){return this._input||'';},/** @@ -2991,7 +3032,7 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 */reject:function lexer_reject(){if(this.options.backtrack_lexer){this._backtrack=true;}else{// when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. -var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** +let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** * retain first n characters of the match * * @public @@ -3013,17 +3054,17 @@ var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yyl * * @public * @this {RegExpLexer} - */pastInput:function lexer_pastInput(maxSize,maxLines){var past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0)maxSize=Infinity;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=Infinity;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substr` anticipation: treat \r\n as a single character and take a little + */pastInput:function lexer_pastInput(maxSize,maxLines){let past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0){maxSize=Infinity;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=Infinity;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past=past.substr(-maxSize*2-2);// now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: -var a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, +let a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, // do add an ellipsis prefix... if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -3049,18 +3090,18 @@ if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} - */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){var next=this.match;var source=this._input||'';if(maxSize<0)maxSize=next.length+source.length;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=maxSize;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substring` anticipation: treat \r\n as a single character and take a little + */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){let next=this.match;let source=this._input||'';if(maxSize<0){maxSize=next.length+source.length;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=maxSize;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: if(next.lengthmaxSize){next=next.substring(0,maxSize)+'...';}return next;},/** @@ -3069,7 +3110,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){var pre=this.pastInput(maxPrefix).replace(/\s/g,' ');var c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** + */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){const pre=this.pastInput(maxPrefix).replace(/\s/g,' ');let c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** * return an YYLLOC info object derived off the given context (actual, preceding, following, current). * Use this method when the given `actual` location is not guaranteed to exist (i.e. when * it MAY be NULL) and you MUST have a valid location info object anyway: @@ -3085,7 +3126,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */deriveLocationInfo:function lexer_deriveYYLLOC(actual,preceding,following,current){var loc={first_line:1,first_column:0,last_line:1,last_column:0,range:[0,0]};if(actual){loc.first_line=actual.first_line|0;loc.last_line=actual.last_line|0;loc.first_column=actual.first_column|0;loc.last_column=actual.last_column|0;if(actual.range){loc.range[0]=actual.range[0]|0;loc.range[1]=actual.range[1]|0;}}if(loc.first_line<=0||loc.last_line=loc.first_line)){loc.last_line=current.last_line|0;loc.last_column=current.last_column|0;if(current.range){loc.range[1]=current.range[1]|0;}}}// sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter // or plan D heuristics to produce a 'sensible' last_line value: @@ -3134,9 +3175,9 @@ loc.range[1]=loc.range[0];}if(loc.first_column<0){loc.first_column=0;}if(loc.las * * @public * @this {RegExpLexer} - */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;var input=this.matched+(this._input||'');var lines=input.split('\n');var l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);var l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);var lineno_display_width=1+Math.log10(l1|1)|0;var ws_prefix=new Array(lineno_display_width).join(' ');var nonempty_line_indexes=[[],[],[]];var rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){var lno=index+l0;var lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);var rv=lno_pfx+': '+line;var errpfx=new Array(lineno_display_width+1).join('^');var offset=2+1;var len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it + */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;let input=this.matched+(this._input||'');let lines=input.split('\n');let l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);let l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);let lineno_display_width=1+Math.log10(l1|1)|0;let ws_prefix=new Array(lineno_display_width).join(' ');let nonempty_line_indexes=[[],[],[]];let rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){let lno=index+l0;let lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);let rv=lno_pfx+': '+line;let errpfx=new Array(lineno_display_width+1).join('^');let offset=2+1;let len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: -for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){var clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;var clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;var intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** +for(let i=0;i<=2;i++){let line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){let clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;let clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;let intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** * helper function, used to produce a human readable description as a string, given * the input `yylloc` location object. * @@ -3145,7 +3186,7 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){var l1=yylloc.first_line;var l2=yylloc.last_line;var c1=yylloc.first_column;var c2=yylloc.last_column;var dl=l2-l1;var dc=c2-c1;var rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){var r1=yylloc.range[0];var r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** + */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){let l1=yylloc.first_line;let l2=yylloc.last_line;let c1=yylloc.first_column;let c2=yylloc.last_column;let dl=l2-l1;let dc=c2-c1;let rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){let r1=yylloc.range[0];let r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** * test the lexed token: return FALSE when not a match, otherwise return token. * * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]` @@ -3162,18 +3203,18 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */test_match:function lexer_test_match(match,indexed_rule){var token,lines,backup,match_str,match_str_len;if(this.options.backtrack_lexer){// save context + */test_match:function lexer_test_match(match,indexed_rule){let backup;if(this.options.backtrack_lexer){// save context backup={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.yylloc.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column,range:this.yylloc.range.slice()},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,//_signaled_error_token: this._signaled_error_token, -yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}match_str=match[0];match_str_len=match_str.length;lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: +yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}let match_str=match[0];let match_str_len=match_str.length;let lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: // those rules will already have moved this `offset` forward matching their match lengths, // hence we must only add our own match length now: this.offset+=match_str_len;this._more=false;this._backtrack=false;this._input=this._input.slice(match_str_len);// calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} -token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: +let token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; if(this.done&&this._input){this.done=false;}if(token){return token;}else if(this._backtrack){// recover context -for(var k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. +for(let k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. }else if(this._signaled_error_token){// produce one 'error' token as `.parseError()` in `reject()` // did not guarantee a failure signal by throwing an exception! token=this._signaled_error_token;this._signaled_error_token=false;return token;}return false;},/** @@ -3181,19 +3222,19 @@ token=this._signaled_error_token;this._signaled_error_token=false;return token;} * * @public * @this {RegExpLexer} - */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}var token,match,tempMatch,index;if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}var spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. + */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}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();// Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 -if(!spec||!spec.rules){var lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! -return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}var rule_ids=spec.rules;var regexes=spec.__rule_regexes;var len=spec.__rule_count;// Note: the arrays are 1-based, while `len` itself is a valid index, +if(!spec||!spec.rules){let lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! +return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}{let rule_ids=spec.rules;let regexes=spec.__rule_regexes;let len=spec.__rule_count;let match;let index;// 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(var i=1;i<=len;i++){tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. +for(let i=1;i<=len;i++){let tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){let token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. }else{// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}}else if(!this.options.flex){break;}}}if(match){token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}if(!this._input){this.done=true;this.clear();return this.EOF;}else{var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);var pendingInput=this._input;var activeCondition=this.topState();var conditionStackDepth=this.conditionStack.length;token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us +return false;}}else if(!this.options.flex){break;}}}if(match){let token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) +return false;}}if(!this._input){this.done=true;this.clear();return this.EOF;}{let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);let pendingInput=this._input;let activeCondition=this.topState();let conditionStackDepth=this.conditionStack.length;let token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: if(!this.matches&&// and make sure the input has been modified/consumed ... @@ -3204,7 +3245,7 @@ activeCondition===this.topState()&&conditionStackDepth===this.conditionStack.len * * @public * @this {RegExpLexer} - */lex:function lexer_lex(){var r;//this._clear_state = 0; + */lex:function lexer_lex(){let r;//this._clear_state = 0; if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}// allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer: if(typeof this.pre_lex==='function'){r=this.pre_lex.call(this,0);}if(typeof this.options.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.pre_lex.call(this,r)||r;}if(this.yy&&typeof this.yy.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) @@ -3212,50 +3253,50 @@ r=this.yy.pre_lex.call(this,r)||r;}while(!r){r=this.next();}if(this.yy&&typeof t r=this.yy.post_lex.call(this,r)||r;}if(typeof this.options.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.post_lex.call(this,r)||r;}if(typeof this.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.post_lex.call(this,r)||r;}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return next match that has a token. Identical to the `lex()` API but does not invoke any of the * `pre_lex()` nor any of the `post_lex()` callbacks. * * @public * @this {RegExpLexer} - */fastLex:function lexer_fastLex(){var r;//this._clear_state = 0; + */fastLex:function lexer_fastLex(){let r;//this._clear_state = 0; while(!r){r=this.next();}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return info about the lexer state that can help a parser or other lexer API user to use the * most efficient means available. This API is provided to aid run-time performance for larger @@ -3263,7 +3304,7 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */canIUse:function lexer_canIUse(){var rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** + */canIUse:function lexer_canIUse(){const rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** * backwards compatible alias for `pushState()`; * the latter is symmetrical with `popState()` and we advise to use * those APIs in any modern lexer code, rather than `begin()`. @@ -3282,20 +3323,20 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */popState:function lexer_popState(){var n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}else{return this.conditionStack[0];}},/** + */popState:function lexer_popState(){const n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}return this.conditionStack[0];},/** * return the currently active lexer condition state; when an index * argument is provided it produces the N-th previous condition state, * if available * * @public * @this {RegExpLexer} - */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}else{return'INITIAL';}},/** + */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}return'INITIAL';},/** * (internal) determine the lexer rule set which is active for the * currently active lexer condition state * * @public * @this {RegExpLexer} - */_currentRules:function lexer__currentRules(){var n=this.conditionStack.length-1;var state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions['INITIAL'];},/** + */_currentRules:function lexer__currentRules(){const n=this.conditionStack.length-1;let state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions.INITIAL;},/** * return the number of states currently on the stack * * @public @@ -3372,18 +3413,18 @@ if(v&&!isNaN(v)){var rv=+v;if(isFinite(rv)){return rv;}}return v;}parser$2.warn= // 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. -function JisonParserError$2(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonParserError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8/Chrome engine +function JisonParserError$2(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonParserError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){let ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8/Chrome engine Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonParserError$2.prototype,Error.prototype);}else{JisonParserError$2.prototype=Object.create(Error.prototype);}JisonParserError$2.prototype.constructor=JisonParserError$2;JisonParserError$2.prototype.name='JisonParserError';// helper: reconstruct the productions[] table -function bp$2(s){var rv=[];var p=s.pop;var r=s.rule;for(var i=0,l=p.length;i1){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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) +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 delimited set of lexer start conditions';break;case 37:/*! Production:: start_productions_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -yy.__options_flags__=0;yy.__options_category_description__='the lexer rules definition section';break;case 38:/*! Production:: start_epilogue_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -yy.__options_flags__=0;yy.__options_category_description__='the lexer epilogue section';break;case 39:/*! Production:: rules : rules scoped_rules_collective */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1].concat(yyvstack[yysp]);break;case 40:/*! Production:: rules : rules rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1].concat([yyvstack[yysp]]);break;case 41:/*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 30:/*! Production:: option_keyword : OPTIONS */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__=yyvstack[yysp];break;case 31:/*! Production:: import_keyword : IMPORT */case 33:/*! Production:: include_keyword : INCLUDE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS;yy.__options_category_description__=yyvstack[yysp];break;case 32:/*! Production:: init_code_keyword : CODE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS|OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS;yy.__options_category_description__=yyvstack[yysp];break;case 34:/*! Production:: start_inclusive_keyword : START_INC */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__='the inclusive lexer start conditions set (%s)';break;case 35:/*! Production:: start_exclusive_keyword : START_EXC */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__='the exclusive lexer start conditions set (%x)';break;case 36:/*! Production:: start_conditions_marker : "<" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES|OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME;yy.__options_category_description__='the <...> delimited set of lexer start conditions';break;case 37:/*! Production:: start_productions_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=0;yy.__options_category_description__='the lexer rules definition section';break;case 38:/*! Production:: start_epilogue_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=0;yy.__options_category_description__='the lexer epilogue section';break;case 39:/*! Production:: rules : rules scoped_rules_collective */ // 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].concat(yyvstack[yysp]);break;case 40:/*! Production:: rules : rules rule */ // 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].concat([yyvstack[yysp]]);break;case 41:/*! Production:: rules : rules 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]);if(srcCode){var rv=checkActionBlock$2(srcCode,yylstack[yysp-1],yy);if(rv){yyparser.yyError(rmCommonWS$2` The '%{...%}' lexer setup action code section does not compile: ${rv} Erroneous area: ${yylexer.prettyPrintRange(yylstack[yysp-1],yylstack[yysp-2])} - `);}yy.actionInclude.push(srcCode);}this.$=yyvstack[yysp-3];break;case 42:/*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);}yy.actionInclude.push(srcCode);}this.$=yyvstack[yysp-3];break;case 42:/*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. -this.$=yyvstack[yysp-1];break;case 43:/*! Production:: rules : rules ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) +this.$=yyvstack[yysp-1];break;case 43:/*! Production:: rules : rules ACTION_START_AT_SOL 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,-,-) 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. @@ -3827,8 +3868,8 @@ var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or simila Technical error report: ${yyvstack[yysp].errStr} - `);this.$=yyvstack[yysp-2];break;case 44:/*! Production:: rules : rules ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);this.$=yyvstack[yysp-2];break;case 44:/*! Production:: rules : rules 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,-,-) 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: @@ -3856,8 +3897,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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 the top section of the lexer spec file, above the first '%%' @@ -3866,14 +3907,14 @@ yyparser.yyError(rmCommonWS$2` Erroneous code: ${yylexer.prettyPrintRange(yylstack[yysp])} - `);this.$=yyvstack[yysp-1];break;case 51:/*! Production:: rules : %epsilon */case 58:/*! Production:: rule_block : %epsilon */ // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) -this.$=[];break;case 52:/*! Production:: scoped_rules_collective : start_conditions rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -if(yyvstack[yysp-1]){yyvstack[yysp].unshift(yyvstack[yysp-1]);}this.$=[yyvstack[yysp]];break;case 53:/*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) -if(yyvstack[yysp-3]){yyvstack[yysp-1].forEach(function(d){d.unshift(yyvstack[yysp-3]);});}this.$=yyvstack[yysp-1];break;case 54:/*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp-3];this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + `);this.$=yyvstack[yysp-1];break;case 51:/*! Production:: rules : %epsilon */case 58:/*! Production:: rule_block : %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 52:/*! Production:: scoped_rules_collective : start_conditions rule */ // 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,-,-) +if(yyvstack[yysp-1]){yyvstack[yysp].unshift(yyvstack[yysp-1]);}this.$=[yyvstack[yysp]];break;case 53:/*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ // 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,-,-) +if(yyvstack[yysp-3]){yyvstack[yysp-1].forEach(function(d){d.unshift(yyvstack[yysp-3]);});}this.$=yyvstack[yysp-1];break;case 54:/*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): +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$2` Seems you made a mistake while specifying one of the lexer rules inside the start condition @@ -3885,8 +3926,8 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp-1].errStr} - `);break;case 55:/*! Production:: scoped_rules_collective : start_conditions "{" error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 55:/*! Production:: scoped_rules_collective : start_conditions "{" 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,-,-) yyparser.yyError(rmCommonWS$2` Seems you did not correctly bracket a lexer rules set inside the start condition @@ -3898,8 +3939,8 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 56:/*! Production:: scoped_rules_collective : start_conditions error "}" */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 56:/*! Production:: scoped_rules_collective : start_conditions 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,-,-) yyparser.yyError(rmCommonWS$2` Seems you did not correctly bracket a lexer rules set inside the start condition @@ -3911,17 +3952,17 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp-1].errStr} - `);break;case 57:/*! Production:: rule_block : rule_block rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 57:/*! Production:: rule_block : rule_block rule */ // 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.$.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` 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 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 // will uncover any illegal action code following the arrow operator, e.g. // multiple statements separated by semicolon. @@ -3942,8 +3983,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 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.: @@ -3958,8 +3999,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 63:/*! Production:: rule : regex ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);break;case 63:/*! Production:: rule : regex 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,-,-) // TODO: REWRITE this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$2` A lexer rule regex action code must be properly terminated and must contain a JavaScript statement block (or anything that does parse as such), e.g.: @@ -3976,8 +4017,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 64:/*! Production:: rule : regex ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);break;case 64:/*! Production:: rule : regex ACTION_START_AT_SOL 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,-,-) // TODO: REWRITE this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$2` A lexer rule regex action code must be properly terminated and must contain a JavaScript statement block (or anything that does parse as such), e.g.: @@ -4013,8 +4054,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 65:/*! Production:: rule : regex error */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);break;case 65:/*! Production:: rule : regex 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,-,-) this.$=[yyvstack[yysp-1],yyvstack[yysp]];yyparser.yyError(rmCommonWS$2` Lexer rule regex action code declaration error? @@ -4023,33 +4064,33 @@ this.$=[yyvstack[yysp-1],yyvstack[yysp]];yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 66:/*! Production:: action : action ACTION_BODY */case 83:/*! Production:: regex_concat : regex_concat regex_base */case 95:/*! Production:: regex_base : regex_base range_regex */case 106:/*! Production:: regex_set : regex_set regex_set_atom */case 127:/*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+yyvstack[yysp];break;case 67:/*! Production:: action : action include_macro_code */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'\n\n'+yyvstack[yysp]+'\n\n';break;case 68:/*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 66:/*! Production:: action : action ACTION_BODY */case 83:/*! Production:: regex_concat : regex_concat regex_base */case 95:/*! Production:: regex_base : regex_base range_regex */case 106:/*! Production:: regex_set : regex_set regex_set_atom */case 127:/*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ // 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]+yyvstack[yysp];break;case 67:/*! Production:: action : action 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]+'\n\n'+yyvstack[yysp]+'\n\n';break;case 68:/*! Production:: action : action INCLUDE_PLACEMENT_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` You may place the '%include' instruction only at the start/front of a line. Its use is not permitted at this position: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 69:/*! Production:: action : action BRACKET_MISSING */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 69:/*! Production:: action : action BRACKET_MISSING */ // 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` Missing curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: '{ ... }'. Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 70:/*! Production:: action : action BRACKET_SURPLUS */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 70:/*! Production:: action : action BRACKET_SURPLUS */ // 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` Too many curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: '{ ... }'. Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 71:/*! Production:: action : action UNTERMINATED_STRING_ERROR */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 71:/*! Production:: action : action UNTERMINATED_STRING_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` Unterminated string constant in lexer rule action block. @@ -4058,10 +4099,10 @@ yyparser.yyError(rmCommonWS$2` Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 72:/*! Production:: action : %epsilon */case 77:/*! Production:: regex_list : %epsilon */ // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0,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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 72:/*! Production:: action : %epsilon */case 77:/*! Production:: regex_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 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 // accordingly: @@ -4082,8 +4123,8 @@ 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,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,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` Seems you did not correctly terminate the start condition set @@ -4095,8 +4136,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -4135,22 +4176,22 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+'|'+yyvstack[yysp];break;case 79:/*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'|';break;case 80:/*! Production:: nonempty_regex_list : "|" regex_concat */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='|'+yyvstack[yysp];break;case 81:/*! Production:: nonempty_regex_list : "|" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='|';break;case 85:/*! Production:: regex_base : "(" regex_list ")" */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$='('+yyvstack[yysp-1]+')';break;case 86:/*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+')';break;case 87:/*! Production:: regex_base : "(" regex_list error */case 88:/*! Production:: regex_base : SPECIAL_GROUP regex_list error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) +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,-,-): +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,-,-) +this.$=yyvstack[yysp-2]+'|'+yyvstack[yysp];break;case 79:/*! Production:: nonempty_regex_list : nonempty_regex_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,-,-) +this.$=yyvstack[yysp-1]+'|';break;case 80:/*! Production:: nonempty_regex_list : "|" regex_concat */ // 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];break;case 81:/*! Production:: 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,-,-) +this.$='|';break;case 85:/*! Production:: regex_base : "(" regex_list ")" */ // 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-1]+')';break;case 86:/*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ // 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-1]+')';break;case 87:/*! Production:: regex_base : "(" regex_list error */case 88:/*! Production:: regex_base : SPECIAL_GROUP regex_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,-,-) yyparser.yyError(rmCommonWS$2` Seems you did not correctly bracket a lex rule regex part in '(...)' braces. @@ -4159,30 +4200,30 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 89:/*! Production:: regex_base : regex_base "+" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'+';break;case 90:/*! Production:: regex_base : regex_base "*" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'*';break;case 91:/*! Production:: regex_base : regex_base "?" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'?';break;case 92:/*! Production:: regex_base : "/" regex_base */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='(?='+yyvstack[yysp]+')';break;case 93:/*! Production:: regex_base : "/!" regex_base */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='(?!'+yyvstack[yysp]+')';break;case 94:/*! Production:: regex_base : name_expansion */case 96:/*! Production:: regex_base : any_group_regex */case 100:/*! Production:: regex_base : REGEX_SPECIAL_CHAR */case 101:/*! Production:: regex_base : literal_string */case 107:/*! Production:: regex_set : regex_set_atom */case 108:/*! Production:: regex_set_atom : REGEX_SET */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -break;case 97:/*! Production:: regex_base : "." */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='.';break;case 98:/*! Production:: regex_base : "^" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='^';break;case 99:/*! Production:: regex_base : "$" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='$';break;case 102:/*! Production:: regex_base : ESCAPED_CHAR */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp]));break;case 104:/*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+yyvstack[yysp];break;case 105:/*! Production:: any_group_regex : REGEX_SET_START regex_set error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 89:/*! Production:: regex_base : regex_base "+" */ // 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]+'+';break;case 90:/*! Production:: regex_base : regex_base "*" */ // 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]+'*';break;case 91:/*! Production:: regex_base : regex_base "?" */ // 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]+'?';break;case 92:/*! Production:: regex_base : "/" regex_base */ // 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]+')';break;case 93:/*! Production:: regex_base : "/!" regex_base */ // 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]+')';break;case 94:/*! Production:: regex_base : name_expansion */case 96:/*! Production:: regex_base : any_group_regex */case 100:/*! Production:: regex_base : REGEX_SPECIAL_CHAR */case 101:/*! Production:: regex_base : literal_string */case 107:/*! Production:: regex_set : regex_set_atom */case 108:/*! Production:: regex_set_atom : REGEX_SET */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +break;case 97:/*! Production:: regex_base : "." */ // 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.$='.';break;case 98:/*! Production:: regex_base : "^" */ // 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.$='^';break;case 99:/*! Production:: regex_base : "$" */ // 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.$='$';break;case 102:/*! Production:: regex_base : ESCAPED_CHAR */ // 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.$=encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp]));break;case 104:/*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_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,-,-) +this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+yyvstack[yysp];break;case 105:/*! Production:: any_group_regex : REGEX_SET_START regex_set 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,-,-) yyparser.yyError(rmCommonWS$2` Seems you did not correctly bracket a lex rule regex set in '[...]' brackets. @@ -4191,16 +4232,16 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 109:/*! Production:: regex_set_atom : name_expansion */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + `);break;case 109:/*! Production:: regex_set_atom : name_expansion */ // 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,-,-) if(XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g,''))&&yyvstack[yysp].toUpperCase()!==yyvstack[yysp]){// treat this as part of an XRegExp `\p{...}` Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) +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,-,-): +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,-,-): +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$2` You may only specify one name/argument in a ${yy.__options_category_description__} statement. @@ -4215,28 +4256,28 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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` You may only specify one name/argument in a ${yy.__options_category_description__} statement. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp]),yylstack[yysp-3])} - `);}this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 115:/*! Production:: option_list : option */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=[yyvstack[yysp]];break;case 116:/*! Production:: option : option_name */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=[yyvstack[yysp],true];break;case 117:/*! Production:: option : option_name "=" option_value */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);}this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 115:/*! Production:: option_list : option */ // 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 116:/*! Production:: option : 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,-,-) +this.$=[yyvstack[yysp],true];break;case 117:/*! Production:: option : option_name "=" option_value */ // 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_VALUE){yyparser.yyError(rmCommonWS$2` The entries in a ${yy.__options_category_description__} statement MUST NOT be assigned values, such as '${$option_name}=${$option_value}'. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp],yylstack[yysp-2]),yylstack[yysp-4])} - `);}this.$=[yyvstack[yysp-2],yyvstack[yysp]];break;case 118:/*! Production:: option : option_name "=" error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);}this.$=[yyvstack[yysp-2],yyvstack[yysp]];break;case 118:/*! Production:: option : option_name "=" 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$2` Internal error: option "${$option}" value assignment failure in a ${yy.__options_category_description__} statement. @@ -4246,8 +4287,8 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 119:/*! Production:: option : DUMMY3 error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);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` Expected a valid option name${with_value_msg} in a ${yy.__options_category_description__} statement. @@ -4256,8 +4297,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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: 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 @@ -4271,8 +4312,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. @@ -4282,21 +4323,21 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=parseValue$1(yyvstack[yysp]);break;case 124:/*! Production:: epilogue : start_epilogue_marker */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,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,-,-) +this.$=parseValue$1(yyvstack[yysp]);break;case 124:/*! Production:: epilogue : start_epilogue_marker */ // 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.$='';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` 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,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,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. @@ -4305,8 +4346,8 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 128:/*! Production:: epilogue_chunks : epilogue_chunks error */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);break;case 128:/*! Production:: epilogue_chunks : epilogue_chunks 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$2` Module code declaration error? @@ -4316,8 +4357,8 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);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` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -4326,8 +4367,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -4336,12 +4377,12 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,LU,LUbA): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA) +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`: path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$2` @@ -4368,8 +4409,8 @@ var fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});var 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,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,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. @@ -4379,14 +4420,14 @@ yyparser.yyError(rmCommonWS$2` Technical error report: ${yyvstack[yysp].errStr} `);break;}},table:bt$2({len:u$2([15,1,14,21,1,13,28,22,s$2,[9,3],13,1,9,13,c$2,[6,3],27,s$2,[31,5],1,44,4,1,13,6,25,24,25,23,23,17,17,s$2,[24,8],26,5,24,24,9,13,8,9,1,s$2,[9,5],13,9,13,c$2,[3,3],c$2,[13,3],2,1,26,26,9,26,c$2,[5,3],s$2,[26,4],7,24,4,5,8,c$2,[60,3],c$2,[59,3],s$2,[24,5],2,3,2,25,25,6,s$2,[4,3],13,7,8,4,8,13,13,s$2,[7,6],9,5,s$2,[13,3],9,1,13,9,26,26,6,1,5,9,5,5,26,17,c$2,[85,4],27,10,s$2,[24,7],4,s$2,[8,3],9,7,9,1,1,26,5,c$2,[30,3],23,27,26,9,27,9,27,9,27,1,16,7,1,13,13,5,26,15,26,s$2,[27,3],16,13]),symbol:u$2([1,2,19,22,s$2,[24,6,1],31,32,33,55,57,1,c$2,[16,13],58,c$2,[14,13],56,s$2,[59,4,1],64,65,67,c$2,[36,14],1,2,3,7,8,s$2,[13,4,1],c$2,[19,10],s$2,[40,6,1],49,50,69,2,c$2,[26,6],c$2,[16,8],75,s$2,[77,5,1],85,2,11,51,52,53,s$2,[86,4,1],c$2,[9,10],23,30,s$2,[35,5,1],73,c$2,[90,13],2,c$2,[32,9],c$2,[23,14],c$2,[63,17],c$2,[144,40],c$2,[27,5],11,c$2,[28,22],c$2,[75,3],c$2,[31,125],1,c$2,[182,25],c$2,[373,5],s$2,[66,5,2],c$2,[320,7],90,1,33,68,90,20,c$2,[276,14],7,20,22,25,34,c$2,[367,3],9,c$2,[68,4],c$2,[12,4],c$2,[62,8],c$2,[370,6],c$2,[25,19],c$2,[24,8],s$2,[10,7,1],c$2,[27,10],48,49,50,84,c$2,[49,8],c$2,[45,8],s$2,[76,6,1],c$2,[72,9],c$2,[23,15],c$2,[485,13],c$2,[17,21],c$2,[105,24],c$2,[24,189],s$2,[46,5,1],44,47,80,82,83,c$2,[79,48],11,17,21,c$2,[500,3],c$2,[729,18],17,21,25,c$2,[24,3],c$2,[8,3],18,c$2,[9,6],c$2,[10,10],c$2,[9,26],c$2,[76,22],c$2,[849,7],63,93,c$2,[796,15],c$2,[13,11],c$2,[57,22],c$2,[22,9],21,11,17,c$2,[95,4],c$2,[10,4],25,c$2,[670,27],c$2,[26,26],c$2,[981,10],c$2,[35,26],c$2,[88,52],c$2,[26,105],2,22,24,54,91,92,2,4,c$2,[1221,14],72,c$2,[1222,8],c$2,[465,3],c$2,[35,5],c$2,[1158,8],c$2,[8,4],c$2,[1307,14],c$2,[912,78],c$2,[760,117],9,2,7,9,c$2,[5,4],c$2,[152,47],84,2,44,46,47,80,83,c$2,[6,4],c$2,[4,8],c$2,[614,14],c$2,[602,6],c$2,[754,9],52,53,c$2,[12,9],c$2,[689,26],c$2,[592,7],c$2,[7,35],c$2,[1571,14],c$2,[82,26],c$2,[430,14],c$2,[688,8],2,c$2,[842,23],c$2,[580,56],92,c$2,[534,3],c$2,[7,3],c$2,[1765,11],c$2,[14,3],c$2,[5,6],c$2,[794,26],5,c$2,[630,14],71,5,c$2,[159,10],c$2,[9,17],s$2,[1,4,2],c$2,[72,24],c$2,[976,9],c$2,[628,48],c$2,[24,121],c$2,[560,4],c$2,[1290,10],c$2,[8,13],c$2,[205,9],c$2,[495,14],63,93,21,21,c$2,[388,31],c$2,[5,5],c$2,[1301,11],c$2,[14,3],c$2,[354,15],c$2,[984,8],c$2,[333,27],c$2,[100,26],c$2,[549,11],c$2,[62,25],c$2,[36,72],6,c$2,[1170,16],c$2,[53,7],21,c$2,[744,28],c$2,[621,29],c$2,[266,15],c$2,[745,28],c$2,[284,27],c$2,[27,52],c$2,[203,16],c$2,[182,13]]),type:u$2([s$2,[2,13],0,0,1,c$2,[16,14],c$2,[30,15],s$2,[0,6],s$2,[2,41],c$2,[42,16],c$2,[64,12],c$2,[9,18],c$2,[49,19],c$2,[32,16],c$2,[22,19],c$2,[145,45],s$2,[2,181],s$2,[0,18],c$2,[20,4],c$2,[62,45],c$2,[25,24],c$2,[441,40],c$2,[442,13],c$2,[23,31],c$2,[17,34],c$2,[416,210],c$2,[57,111],c$2,[76,42],c$2,[98,34],c$2,[57,22],c$2,[22,10],c$2,[165,66],c$2,[509,189],c$2,[756,25],c$2,[740,56],c$2,[912,70],c$2,[286,136],c$2,[25,29],c$2,[275,31],c$2,[240,14],c$2,[227,82],c$2,[1144,56],c$2,[53,22],c$2,[775,59],c$2,[58,15],c$2,[149,63],c$2,[1837,18],c$2,[81,35],c$2,[628,51],c$2,[1393,171],c$2,[197,47],c$2,[268,26],c$2,[272,64],c$2,[62,36],c$2,[36,72],s$2,[2,226]]),state:u$2([s$2,[1,5,1],13,15,16,8,9,6,s$2,[25,4,2],32,37,38,43,49,51,52,54,58,c$2,[4,3],60,63,c$2,[5,3],65,c$2,[4,3],67,c$2,[4,3],77,79,80,75,76,85,81,70,71,82,83,c$2,[38,6],69,81,87,90,c$2,[8,4],91,c$2,[4,3],95,97,98,c$2,[20,5],99,c$2,[7,6],100,c$2,[4,3],101,c$2,[4,3],105,102,103,108,52,54,c$2,[3,3],119,114,c$2,[8,6],c$2,[3,3],127,130,132,136,c$2,[66,7],143,c$2,[87,3],144,c$2,[67,9],95,95,105,151,152,52,54,153,155,c$2,[22,3],157,119,114,161,163,165,168,170,172,c$2,[49,3],c$2,[29,4],c$2,[67,5],119,114,182,c$2,[57,7],c$2,[12,4],119,114]),mode:u$2([s$2,[2,27],s$2,[1,13],c$2,[27,15],c$2,[53,38],c$2,[66,27],c$2,[46,12],c$2,[65,23],s$2,[2,197],c$2,[271,26],c$2,[340,23],c$2,[25,4],c$2,[27,6],c$2,[264,10],c$2,[20,20],c$2,[12,5],c$2,[66,18],c$2,[89,5],c$2,[102,14],s$2,[1,38],s$2,[2,218],c$2,[220,50],c$2,[274,30],c$2,[25,6],c$2,[85,37],c$2,[736,26],c$2,[52,52],c$2,[427,61],c$2,[54,34],c$2,[515,158],c$2,[696,29],c$2,[1120,25],c$2,[845,62],c$2,[689,122],c$2,[1055,8],c$2,[151,24],c$2,[24,20],c$2,[539,29],c$2,[29,12],c$2,[1006,79],c$2,[660,49],c$2,[45,8],c$2,[793,47],c$2,[131,31],c$2,[439,50],c$2,[44,16],c$2,[125,9],c$2,[161,22],c$2,[663,28],c$2,[599,24],c$2,[1703,174],c$2,[875,16],c$2,[920,43],c$2,[1192,22],c$2,[260,51],c$2,[123,34],c$2,[34,69],c$2,[1284,181],s$2,[2,51]]),goto:u$2([s$2,[7,13],s$2,[9,13],6,17,7,10,11,12,14,21,22,23,19,20,18,24,s$2,[8,13],51,26,s$2,[51,25],28,30,33,35,39,40,41,34,36,42,s$2,[44,5,1],50,55,53,56,57,59,c$2,[5,4],61,s$2,[72,7],s$2,[17,13],62,64,c$2,[27,4],s$2,[22,13],66,c$2,[18,4],68,c$2,[5,4],s$2,[29,13],s$2,[37,27],s$2,[34,31],s$2,[35,31],s$2,[30,31],s$2,[31,31],s$2,[32,31],1,4,86,c$2,[272,6],72,73,74,78,c$2,[330,5],84,c$2,[282,8],5,84,88,s$2,[11,13],75,89,s$2,[75,4],81,81,33,81,c$2,[48,4],s$2,[81,4],c$2,[42,8],82,82,33,82,c$2,[20,4],s$2,[82,4],c$2,[20,8],s$2,[84,4],92,93,94,s$2,[84,14],96,84,84,77,30,33,77,c$2,[384,12],c$2,[16,16],c$2,[413,13],c$2,[13,13],s$2,[94,24],s$2,[96,24],s$2,[97,24],s$2,[98,24],s$2,[99,24],s$2,[100,24],s$2,[101,24],s$2,[102,24],s$2,[103,26],45,104,s$2,[111,24],s$2,[112,24],55,107,106,c$2,[640,3],s$2,[13,13],s$2,[115,8],s$2,[116,3],109,s$2,[116,5],110,s$2,[120,9],s$2,[121,9],s$2,[122,9],s$2,[123,9],55,107,111,c$2,[73,3],s$2,[15,13],112,120,113,s$2,[115,4,1],s$2,[18,13],s$2,[19,13],55,107,121,c$2,[52,3],s$2,[21,13],55,107,122,c$2,[19,3],c$2,[78,3],124,c$2,[7,3],126,125,2,s$2,[39,26],s$2,[40,26],128,s$2,[72,7],s$2,[42,26],129,s$2,[45,26],s$2,[46,26],s$2,[47,26],s$2,[48,26],s$2,[49,26],s$2,[50,26],124,131,133,134,135,138,137,c$2,[1118,14],142,140,139,141,s$2,[38,5],c$2,[1071,4],s$2,[36,4],3,s$2,[10,13],79,79,33,79,c$2,[47,4],s$2,[79,4],c$2,[51,8],80,80,33,80,c$2,[20,4],s$2,[80,4],c$2,[20,8],s$2,[83,4],c$2,[845,3],s$2,[83,14],96,83,83,s$2,[89,24],s$2,[90,24],s$2,[91,24],s$2,[95,24],s$2,[110,24],146,145,76,89,76,148,147,s$2,[92,5],93,94,s$2,[92,14],96,c$2,[19,3],s$2,[93,3],c$2,[24,3],s$2,[93,14],96,93,93,150,45,149,104,s$2,[107,4],s$2,[108,4],s$2,[109,4],s$2,[12,13],c$2,[290,4],s$2,[114,8],154,56,57,s$2,[119,8],s$2,[14,13],s$2,[16,13],s$2,[66,7],s$2,[67,7],s$2,[68,7],s$2,[69,7],s$2,[70,7],s$2,[71,7],156,c$2,[92,4],s$2,[33,5],s$2,[20,13],s$2,[23,13],s$2,[24,13],158,s$2,[72,7],159,s$2,[28,13],160,c$2,[793,6],s$2,[43,26],s$2,[44,26],125,162,c$2,[541,3],126,s$2,[129,5],164,s$2,[72,7],s$2,[132,5],s$2,[133,5],s$2,[52,26],166,s$2,[58,15],167,169,s$2,[72,7],171,s$2,[72,7],173,s$2,[72,7],s$2,[65,27],175,55,107,174,c$2,[255,3],78,78,33,78,c$2,[599,4],s$2,[78,4],c$2,[599,8],s$2,[85,24],s$2,[87,24],s$2,[86,24],s$2,[88,24],s$2,[104,24],s$2,[105,24],s$2,[106,4],s$2,[113,8],s$2,[117,8],s$2,[118,8],55,107,176,c$2,[198,3],s$2,[135,7],177,c$2,[394,6],178,179,s$2,[41,26],s$2,[127,5],s$2,[128,5],180,c$2,[45,6],s$2,[131,5],181,c$2,[927,14],55,55,183,s$2,[55,24],s$2,[56,26],184,c$2,[80,6],s$2,[63,27],185,c$2,[34,6],s$2,[64,27],186,c$2,[34,6],s$2,[62,27],187,s$2,[74,16],s$2,[134,7],188,s$2,[26,13],s$2,[27,13],s$2,[130,5],s$2,[53,26],s$2,[57,15],s$2,[54,26],s$2,[59,27],s$2,[60,27],s$2,[61,27],s$2,[73,16],s$2,[25,13]])}),defaultActions:bda$1({idx:u$2([0,2,5,11,14,s$2,[17,8,1],28,s$2,[37,9,1],47,48,50,51,s$2,[54,4,1],59,61,62,64,69,70,71,73,s$2,[75,6,1],84,86,87,88,s$2,[92,5,1],s$2,[103,4,1],108,s$2,[110,9,1],s$2,[120,4,1],126,128,129,131,132,134,135,136,142,s$2,[145,10,1],156,160,161,162,164,s$2,[167,5,2],176,s$2,[178,11,1]]),goto:u$2([7,9,8,17,22,29,37,34,35,30,31,32,1,11,94,s$2,[96,8,1],111,112,13,115,s$2,[120,4,1],15,18,19,21,2,39,40,42,s$2,[45,6,1],38,36,3,10,89,90,91,95,110,107,108,109,12,114,119,14,16,s$2,[66,6,1],33,20,23,24,28,43,44,126,129,132,133,52,65,85,87,86,88,104,105,106,113,117,118,135,41,127,128,131,56,63,64,62,74,134,26,27,130,53,57,54,59,60,61,73,25])}),parseError:function parseError(str,hash,ExceptionClass){if(hash.recoverable){if(typeof this.trace==='function'){this.trace(str);}hash.destroy();// destroy... well, *almost*! -}else{if(typeof this.trace==='function'){this.trace(str);}if(!ExceptionClass){ExceptionClass=this.JisonParserError;}throw new ExceptionClass(str,hash);}},parse:function parse(input){var self=this;var stack=new Array(128);// token stack: stores token which leads to state at the same index (column storage) -var sstack=new Array(128);// state stack: stores states (column storage) -var vstack=new Array(128);// semantic value stack -var lstack=new Array(128);// location stack -var table=this.table;var sp=0;// 'stack pointer': index into the stacks -var yyloc;var symbol=0;var preErrorSymbol=0;var lastEofErrorStateDepth=Infinity;var recoveringErrorInfo=null;var recovering=0;// (only used when the grammar contains error recovery rules) -var TERROR=this.TERROR;var EOF=this.EOF;var ERROR_RECOVERY_TOKEN_DISCARD_COUNT=this.options.errorRecoveryTokenDiscardCount|0||3;var NO_ACTION=[0,189/* === table.length :: ensures that anyone using this new state will fail dramatically! */];var lexer;if(this.__lexer__){lexer=this.__lexer__;}else{lexer=this.__lexer__=Object.create(this.lexer);}var sharedState_yy={parseError:undefined,quoteName:undefined,lexer:undefined,parser:undefined,pre_parse:undefined,post_parse:undefined,pre_lex:undefined,post_lex:undefined// WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! -};var ASSERT;if(typeof assert!=='function'){ASSERT=function JisonAssert(cond,msg){if(!cond){throw new Error('assertion failed: '+(msg||'***'));}};}else{ASSERT=assert;}this.yyGetSharedState=function yyGetSharedState(){return sharedState_yy;};this.yyGetErrorInfoTrack=function yyGetErrorInfoTrack(){return recoveringErrorInfo;};// shallow clone objects & arrays, straight copy of simple `src` values +}else{if(typeof this.trace==='function'){this.trace(str);}if(!ExceptionClass){ExceptionClass=this.JisonParserError;}throw new ExceptionClass(str,hash);}},parse:function parse(input){let self=this;let stack=new Array(128);// token stack: stores token which leads to state at the same index (column storage) +let sstack=new Array(128);// state stack: stores states (column storage) +let vstack=new Array(128);// semantic value stack +let lstack=new Array(128);// location stack +let table=this.table;let sp=0;// 'stack pointer': index into the stacks +let yyloc;let symbol=0;let preErrorSymbol=0;let lastEofErrorStateDepth=Infinity;let recoveringErrorInfo=null;let recovering=0;// (only used when the grammar contains error recovery rules) +const TERROR=this.TERROR;const EOF=this.EOF;const ERROR_RECOVERY_TOKEN_DISCARD_COUNT=this.options.errorRecoveryTokenDiscardCount|0||3;const NO_ACTION=[0,189/* === table.length :: ensures that anyone using this new state will fail dramatically! */];let lexer;if(this.__lexer__){lexer=this.__lexer__;}else{lexer=this.__lexer__=Object.create(this.lexer);}let sharedState_yy={parseError:undefined,quoteName:undefined,lexer:undefined,parser:undefined,pre_parse:undefined,post_parse:undefined,pre_lex:undefined,post_lex:undefined// WARNING: must be written this way for the code expanders to work correctly! +};const ASSERT=typeof assert!=='function'?function JisonAssert(cond,msg){if(!cond){throw new Error('assertion failed: '+(msg||'***'));}}:assert;this.yyGetSharedState=function yyGetSharedState(){return sharedState_yy;};this.yyGetErrorInfoTrack=function yyGetErrorInfoTrack(){return recoveringErrorInfo;};// shallow clone objects & arrays, straight copy of simple `src` values // e.g. `lexer.yytext` MAY be a complex value object, // rather than a simple string/value. // @@ -4397,14 +4438,13 @@ var TERROR=this.TERROR;var EOF=this.EOF;var ERROR_RECOVERY_TOKEN_DISCARD_COUNT=t // function shallow_copy(src){if(src&&typeof src==='object'){// non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: -if(src.constructor!==Object){if(Array.isArray(src)){return src.slice();}var dst=new src.constructor(src);// and make sure all custom attributes are added to the clone: +if(src.constructor!==Object){if(Array.isArray(src)){return src.slice();}let dst=new src.constructor(src);// and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst,src);return dst;}// native objects must be cloned a different way: -// -//return Object.assign({}, src); -var dst={};shallow_copy_noclobber(dst,src);return dst;}return src;}// add elements from `src` to `dst` when: +{//return Object.assign({}, src); +let dst={};shallow_copy_noclobber(dst,src);return dst;}}return src;}// add elements from `src` to `dst` when: // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` -function shallow_copy_noclobber(dst,src){const chk=Object.prototype.hasOwnProperty;for(var k in src){if(!(k in dst)){if(chk.call(src,k)){dst[k]=src[k];}}else{if(src[k]!=null&&dst[k]==null&&chk.call(src,k)){dst[k]=src[k];}}}}function copy_yylloc_native(loc){var rv=shallow_copy(loc);// shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: +function shallow_copy_noclobber(dst,src){const chk=Object.prototype.hasOwnProperty;for(let k in src){if(!(k in dst)){if(chk.call(src,k)){dst[k]=src[k];}}else if(src[k]!=null&&dst[k]==null&&chk.call(src,k)){dst[k]=src[k];}}}function copy_yylloc_native(loc){let rv=shallow_copy(loc);// shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if(rv){rv.range=rv.range.slice();}return rv;}// copy state shallow_copy_noclobber(sharedState_yy,this.yy);sharedState_yy.lexer=lexer;sharedState_yy.parser=this;// allow userland code to override the yytext and yylloc copy/clone functions: this.copy_yytext=this.options.copy_yytext||sharedState_yy.copy_yytext||shallow_copy;this.copy_yylloc=this.options.copy_yylloc||sharedState_yy.copy_yylloc||copy_yylloc_native;// *Always* setup `yyError`, `YYRECOVERING`, `yyErrOk` and `yyClearIn` functions as it is paramount @@ -4413,10 +4453,10 @@ this.copy_yytext=this.options.copy_yytext||sharedState_yy.copy_yytext||shallow_c // these functions are invoked in the user action code block(s) as // their closure will still refer to the `parse()` instance which set // them up. Hence we MUST set them up at the start of every `parse()` run! -if(this.yyError){this.yyError=function yyError(str/*, ...args */){var error_rule_depth=this.options.parserErrorsAreRecoverable?locateNearestErrorRecoveryRule(state):-1;var expected=this.collect_expected_token_set(state);var hash=this.constructParseErrorInfo(str,null,expected,error_rule_depth>=0);// append to the old one? -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; +if(this.yyError){this.yyError=function yyError(str/*, ...args */){let error_rule_depth=this.options.parserErrorsAreRecoverable?locateNearestErrorRecoveryRule(state):-1;let expected=this.collect_expected_token_set(state);let hash=this.constructParseErrorInfo(str,null,expected,error_rule_depth>=0);// append to the old one? +if(recoveringErrorInfo){let esp=recoveringErrorInfo.info_stack_pointer;recoveringErrorInfo.symbol_stack[esp]=symbol;let 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;recoveringErrorInfo.info_stack_pointer=esp;}else{recoveringErrorInfo=this.shallowCopyErrorInfo(hash);recoveringErrorInfo.yyError=true;recoveringErrorInfo.errorRuleDepth=error_rule_depth;recoveringErrorInfo.recovering=recovering;}// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){hash.extra_error_attributes=args;}return this.parseError(str,hash,this.JisonParserError);};}// Does the shared state override the default `parseError` that already comes with this instance? +let args=Array.prototype.slice.call(arguments,1);if(args.length){hash.extra_error_attributes=args;}return this.parseError(str,hash,this.JisonParserError);};}// Does the shared state override the default `parseError` that already comes with this instance? if(typeof sharedState_yy.parseError==='function'){this.parseError=function parseErrorAlt(str,hash,ExceptionClass){if(!ExceptionClass){ExceptionClass=this.JisonParserError;}return sharedState_yy.parseError.call(this,str,hash,ExceptionClass);};}else{this.parseError=this.originalParseError;}// Does the shared state override the default `quoteName` that already comes with this instance? if(typeof sharedState_yy.quoteName==='function'){this.quoteName=function quoteNameAlt(id_str){return sharedState_yy.quoteName.call(this,id_str);};}else{this.quoteName=this.originalQuoteName;}// set up the cleanup function; make it an API so that external code can re-use this one in case of // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which @@ -4424,7 +4464,7 @@ if(typeof sharedState_yy.quoteName==='function'){this.quoteName=function quoteNa // // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! -this.cleanupAfterParse=function parser_cleanupAfterParse(resultValue,invoke_post_methods,do_not_nuke_errorinfos){var rv;if(invoke_post_methods){var hash;if(sharedState_yy.post_parse||this.post_parse){// create an error hash info instance: we re-use this API in a **non-error situation** +this.cleanupAfterParse=function parser_cleanupAfterParse(resultValue,invoke_post_methods,do_not_nuke_errorinfos){let rv;if(invoke_post_methods){let hash;if(sharedState_yy.post_parse||this.post_parse){// create an error hash info instance: we re-use this API in a **non-error situation** // as this one delivers all parser internals ready for access by userland code. hash=this.constructParseErrorInfo(null/* no error! */,null/* no exception! */,null,false);}if(sharedState_yy.post_parse){rv=sharedState_yy.post_parse.call(this,sharedState_yy,resultValue,hash);if(typeof rv!=='undefined')resultValue=rv;}if(this.post_parse){rv=this.post_parse.call(this,sharedState_yy,resultValue,hash);if(typeof rv!=='undefined')resultValue=rv;}// cleanup: if(hash&&hash.destroy){hash.destroy();}}if(this.__reentrant_call_depth>1)return resultValue;// do not (yet) kill the sharedState when this is a reentrant run. @@ -4436,7 +4476,7 @@ stack.length=0;// fastest way to nuke an array without overly bothering the GC sstack.length=0;lstack.length=0;vstack.length=0;sp=0;// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;for(var i=this.__error_recovery_infos.length-1;i>=0;i--){var el=this.__error_recovery_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_recovery_infos.length=0;// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array, +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;for(let i=this.__error_recovery_infos.length-1;i>=0;i--){let el=this.__error_recovery_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_recovery_infos.length=0;// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array, // hence has been destroyed already: no need to do that *twice*. if(recoveringErrorInfo){recoveringErrorInfo=undefined;}}return resultValue;};// merge yylloc info into a new yylloc instance. // @@ -4450,32 +4490,38 @@ if(recoveringErrorInfo){recoveringErrorInfo=undefined;}}return resultValue;};// // yylloc info. // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. -this.yyMergeLocationInfo=function parser_yyMergeLocationInfo(first_index,last_index,first_yylloc,last_yylloc,dont_look_back){var i1=first_index|0,i2=last_index|0;var l1=first_yylloc,l2=last_yylloc;var rv;// rules: +this.yyMergeLocationInfo=function parser_yyMergeLocationInfo(first_index,last_index,first_yylloc,last_yylloc,dont_look_back){let i1=first_index|0;let i2=last_index|0;let l1=first_yylloc;let l2=last_yylloc;let rv;// rules: // - first/last yylloc entries override first/last indexes -if(!l1){if(first_index!=null){for(var i=i1;i<=i2;i++){l1=lstack[i];if(l1){break;}}}}if(!l2){if(last_index!=null){for(var i=i2;i>=i1;i--){l2=lstack[i];if(l2){break;}}}}// - detect if an epsilon rule is being processed and act accordingly: +if(!l1){if(first_index!=null){for(let i=i1;i<=i2;i++){l1=lstack[i];if(l1){break;}}}}if(!l2){if(last_index!=null){for(let i=i2;i>=i1;i--){l2=lstack[i];if(l2){break;}}}}// - detect if an epsilon rule is being processed and act accordingly: if(!l1&&first_index==null){// epsilon rule span merger. With optional look-ahead in l2. -if(!dont_look_back){for(var i=(i1||sp)-1;i>=0;i--){l1=lstack[i];if(l1){break;}}}if(!l1){if(!l2){// when we still don't have any valid yylloc info, we're looking at an epsilon rule +if(!dont_look_back){for(let i=(i1||sp)-1;i>=0;i--){l1=lstack[i];if(l1){break;}}}if(!l1){if(!l2){// when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: -return undefined;}else{// shallow-copy L2: after all, we MAY be looking +return null;}// shallow-copy L2: after all, we MAY be looking // at unconventional yylloc info objects... -rv=this.copy_yylloc(l2);return rv;}}else{// shallow-copy L1, then adjust first col/row 1 column past the end. +rv=this.copy_yylloc(l2);return rv;}// shallow-copy L1, then adjust first col/row 1 column past the end. rv=this.copy_yylloc(l1);rv.first_line=rv.last_line;rv.first_column=rv.last_column;rv.range[0]=rv.range[1];if(l2){// shallow-mixin L2, then adjust last col/row accordingly. -shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;}}if(!l1){l1=l2;l2=null;}if(!l1){return undefined;}// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking +shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;}if(!l1){l1=l2;l2=null;}if(!l1){return null;}// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... rv=this.copy_yylloc(l1);if(l2){shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;};// NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! -this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){var pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,loc:this.copy_yylloc(lexer.yylloc),expected:expected,recoverable:recoverable,state:state,action:action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,location_stack:lstack,stack_pointer:sp,yy:sharedState_yy,lexer:lexer,parser:this,// and make sure the error info doesn't stay due to potential +this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){const pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,loc:this.copy_yylloc(lexer.yylloc),expected,recoverable,state,action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,location_stack:lstack,stack_pointer:sp,yy:sharedState_yy,lexer,parser:this,// and make sure the error info doesn't stay due to potential // ref cycle via userland code manipulations. // These would otherwise all be memory leak opportunities! // // Note that only array and object references are nuked as those // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. -destroy:function destructParseErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +destroy:function destructParseErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// info.value = null; +// info.value_stack = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;};// clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. -this.shallowCopyErrorInfo=function parser_shallowCopyErrorInfo(p){var rv=shallow_copy(p);// remove the large parts which can only cause cyclic references +this.shallowCopyErrorInfo=function parser_shallowCopyErrorInfo(p){let rv=shallow_copy(p);// remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. delete rv.sharedState_yy;delete rv.parser;delete rv.lexer;// lexer.yytext MAY be a complex value object, rather than a simple string/value: rv.value=this.copy_yytext(rv.value);// yylloc info: @@ -4527,15 +4573,15 @@ rv.value_stack=rv.value_stack.map(this.copy_yytext);// and we don't bother with // - root_failure_pointer: // copy of the `stack_pointer`... // -for(var i=rv.stack_pointer;rv.state_stack[i]!=null;i++){// empty -}rv.base_pointer=i;rv.info_stack_pointer=i;rv.root_failure_pointer=rv.stack_pointer;// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! -this.__error_recovery_infos.push(rv);return rv;};function getNonTerminalFromCode(symbol){var tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){var token=lexer.lex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){var token=lexer.fastLex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}var lex=stdLex;var state,action,r,t;var yyval={$:true,_$:undefined,yy:sharedState_yy};var p;var yyrulelen;var this_production;var newState;var retval=false;// Return the rule stack depth where the nearest error rule can be found. +{let i;for(i=rv.stack_pointer;rv.state_stack[i]!=null;i++){// empty +}rv.base_pointer=i;rv.info_stack_pointer=i;}rv.root_failure_pointer=rv.stack_pointer;// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +this.__error_recovery_infos.push(rv);return rv;};function getNonTerminalFromCode(symbol){let tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){let token=lexer.lex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){let token=lexer.fastLex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}let lex=stdLex;let state,action,r,t;let yyval={$:true,_$:undefined,yy:sharedState_yy};let p;let yyrulelen;let this_production;let newState;let retval=false;// Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. -function locateNearestErrorRecoveryRule(state){var stack_probe=sp-1;var depth=0;// try to recover from error +function locateNearestErrorRecoveryRule(state){let stack_probe=sp-1;let depth=0;// try to recover from error while(stack_probe>=0){// check for error recovery rule in this state -var t=table[state]&&table[state][TERROR]||NO_ACTION;if(t[0]){// We need to make sure we're not cycling forever: +const t=table[state]&&table[state][TERROR]||NO_ACTION;if(t[0]){// We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must // prevent the core from running forever, // e.g. when parent rules are still expecting certain input to @@ -4556,7 +4602,7 @@ state=sstack[stack_probe];++depth;}return-1;// No suitable error recovery rule a // this initial `setInput()` call: hence we can now check and decide // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: -if(typeof lexer.canIUse==='function'){var lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}yyloc=this.copy_yylloc(lexer.yylloc);lstack[sp]=yyloc;vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack +if(typeof lexer.canIUse==='function'){let lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}yyloc=this.copy_yylloc(lexer.yylloc);lstack[sp]=yyloc;vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack state=newState;// sstack[sp - 1]; // use default actions if available if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}else{// The single `==` condition below covers both these `===` comparisons in a single @@ -4566,7 +4612,7 @@ if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}els if(!symbol){symbol=lex();}// read action for current state and first input t=table[state]&&table[state][symbol]||NO_ACTION;newState=t[1];action=t[0];// handle parse error if(!action){// first see if there's any chance at hitting an error recovery rule: -var error_rule_depth=locateNearestErrorRecoveryRule(state);var errStr=null;var errSymbolDescr=this.describeSymbol(symbol)||symbol;var expected=this.collect_expected_token_set(state);if(!recovering){// Report error +let error_rule_depth=locateNearestErrorRecoveryRule(state);let errStr=null;let errSymbolDescr=this.describeSymbol(symbol)||symbol;let expected=this.collect_expected_token_set(state);if(!recovering){// Report error errStr='Parse error';if(typeof lexer.yylineno==='number'){errStr+=' on line '+(lexer.yylineno+1);}if(typeof lexer.showPosition==='function'){errStr+=':\n'+lexer.showPosition(79-10,10)+'\n';}else{errStr+=': ';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}p=this.constructParseErrorInfo(errStr,null,expected,error_rule_depth>=0);// DO NOT cleanup the old one before we start the new error info track: // the old one will *linger* on the error stack and stay alive until we // invoke the parser's cleanup API! @@ -4574,20 +4620,20 @@ recoveringErrorInfo=this.shallowCopyErrorInfo(p);r=this.parseError(p.errStr,p,th // the `recoverable` flag without properly checking first: // we always terminate the parse when there's no recovery rule available anyhow! if(!p.recoverable||error_rule_depth<0){break;}else{// TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process... -}}var esp=recoveringErrorInfo.info_stack_pointer;// just recovered from another error +}}let esp=recoveringErrorInfo.info_stack_pointer;// just recovered from another error if(recovering===ERROR_RECOVERY_TOKEN_DISCARD_COUNT&&error_rule_depth>=0){// Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc=this.copy_yylloc(lexer.yylloc);// SHIFT current lookahead and grab another recoveringErrorInfo.symbol_stack[esp]=symbol;recoveringErrorInfo.location_stack[esp]=yyloc;recoveringErrorInfo.state_stack[esp]=newState;// push state ++esp;preErrorSymbol=0;symbol=lex();}// try to recover from error -if(error_rule_depth<0){ASSERT(recovering>0,"line 897");recoveringErrorInfo.info_stack_pointer=esp;// barf a fatal hairball when we're out of look-ahead symbols and none hit a match +if(error_rule_depth<0){ASSERT(recovering>0,'Line 1048');recoveringErrorInfo.info_stack_pointer=esp;// barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: -var po=this.__error_infos[this.__error_infos.length-1];// Report error +let po=this.__error_infos[this.__error_infos.length-1];// Report error if(typeof lexer.yylineno==='number'){errStr='Parsing halted on line '+(lexer.yylineno+1)+' while starting to recover from another error';}else{errStr='Parsing halted while starting to recover from another error';}if(po){errStr+=' -- previous error which resulted in this fatal result: '+po.errStr;}else{errStr+=': ';}if(typeof lexer.showPosition==='function'){errStr+='\n'+lexer.showPosition(79-10,10)+'\n';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}p=this.constructParseErrorInfo(errStr,null,expected,false);if(po){p.extra_error_attributes=po;}r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}preErrorSymbol=symbol===TERROR?0:symbol;// save the lookahead token symbol=TERROR;// insert generic error symbol as new lookahead const EXTRA_STACK_SAMPLE_DEPTH=3;// REDUCE/COMBINE the pushed terms/tokens to a new ERROR token: -recoveringErrorInfo.symbol_stack[esp]=preErrorSymbol;if(errStr){recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,errStr:errStr,errorSymbolDescr:errSymbolDescr,expectedStr:expected,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}else{recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}recoveringErrorInfo.location_stack[esp]=this.copy_yylloc(lexer.yylloc);recoveringErrorInfo.state_stack[esp]=newState||NO_ACTION[1];++esp;recoveringErrorInfo.info_stack_pointer=esp;yyval.$=recoveringErrorInfo;yyval._$=undefined;yyrulelen=error_rule_depth;r=this.performAction.call(yyval,yyloc,NO_ACTION[1],sp-1,vstack,lstack);if(typeof r!=='undefined'){retval=r;break;}// pop off stack +recoveringErrorInfo.symbol_stack[esp]=preErrorSymbol;if(errStr){recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,errStr,errSymbolDescr,expectedStr:expected,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}else{recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}recoveringErrorInfo.location_stack[esp]=this.copy_yylloc(lexer.yylloc);recoveringErrorInfo.state_stack[esp]=newState||NO_ACTION[1];++esp;recoveringErrorInfo.info_stack_pointer=esp;yyval.$=recoveringErrorInfo;yyval._$=undefined;yyrulelen=error_rule_depth;let combineState=NO_ACTION[1];r=this.performAction.call(yyval,yyloc,combineState,sp-1,vstack,lstack);if(typeof r!=='undefined'){retval=r;break;}// pop off stack sp-=yyrulelen;// and move the top entries + discarded part of the parse stacks onto the error info stack: -for(var idx=sp-EXTRA_STACK_SAMPLE_DEPTH,top=idx+yyrulelen;idx0){recovering--;}}else{// error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: -ASSERT(recovering>0,"line 1163");symbol=preErrorSymbol;preErrorSymbol=0;// read action for current state and first input +ASSERT(recovering>0,'Line 1352');symbol=preErrorSymbol;preErrorSymbol=0;// read action for current state and first input t=table[newState]&&table[newState][symbol]||NO_ACTION;if(!t[0]||symbol===TERROR){// forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where // (simple) stuff might have been missing before the token which caused the error we're // recovering from now... @@ -4678,17 +4724,17 @@ symbol=0;}}// once we have pushed the special ERROR token value, // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! -ASSERT(preErrorSymbol===0,"line 1194");if(recovering===0){break;}continue;// reduce: +ASSERT(preErrorSymbol===0,'Line 1383');if(recovering===0){break;}continue;// reduce: case 2:this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){// signal end of error recovery loop AND end of outer parse loop +yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){// signal end of error recovery loop AND end of outer parse loop action=3;retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}sp=-2;// magic number: signal outer "fast parse loop" ACCEPT state that we already have a properly set up `retval` parser return value. break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;lstack[sp]=yyval._$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -4716,26 +4762,26 @@ break;}// should we also break out of the regular/outer parse loop, // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? -ASSERT(action!==2,"line 1272");if(!action||action===1){continue;}}}switch(action){// catch misc. parse failures: +ASSERT(action!==2,'Line 1509');if(!action||action===1){continue;}}}switch(action){// catch misc. parse failures: default:// this shouldn't happen, unless resolve defaults are off if(action instanceof Array){p=this.constructParseErrorInfo('Parse Error: multiple actions possible at state: '+state+', token: '+symbol,null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}// Another case of better safe than sorry: in case state transitions come out of another error recovery process // or a buggy LUT (LookUp Table): p=this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.',null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;// shift: case 1:stack[sp]=symbol;vstack[sp]=lexer.yytext;lstack[sp]=this.copy_yylloc(lexer.yylloc);sstack[sp]=newState;// push state -if(typeof Jison!=='undefined'&&Jison.parserDebugger){var tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;ASSERT(preErrorSymbol===0,"line 1352");// normal execution / no error -ASSERT(recovering===0,"line 1353");// normal execution / no error +if(typeof Jison!=='undefined'&&Jison.parserDebugger){let tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;ASSERT(preErrorSymbol===0,'Line 1619');// normal execution / no error +ASSERT(recovering===0,'Line 1620');// normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc=this.copy_yylloc(lexer.yylloc);continue;// reduce: -case 2:ASSERT(preErrorSymbol===0,"line 1364");// normal execution / no error -ASSERT(recovering===0,"line 1365");// normal execution / no error +case 2:ASSERT(preErrorSymbol===0,'Line 1631');// normal execution / no error +ASSERT(recovering===0,'Line 1632');// normal execution / no error this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack +yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;lstack[sp]=yyval._$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:if(sp!==-2){retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -4984,8 +5030,8 @@ return retval;},yyError:1};parser$3.originalParseError=parser$3.parseError;parse * @public * @constructor * @nocollapse - */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 -Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';var lexer={// Code Generator Information Report + */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){const ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 +Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';const lexer={// Code Generator Information Report // --------------------------------- // // Options: @@ -5054,7 +5100,7 @@ CRLF_Re:/\r\n?|\n/,/** * @this {RegExpLexer} */constructLexErrorInfo:function lexer_constructLexErrorInfo(msg,recoverable,show_input_position){msg=''+msg;// heuristic to determine if the error message already contains a (partial) source code dump // as produced by either `showPosition()` or `prettyPrintRange()`: -if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){var pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){var pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */var pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... +if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){const pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){const pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */const pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:this,/** * and make sure the error info doesn't stay due to potential * ref cycle via userland code manipulations. @@ -5066,7 +5112,11 @@ text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:t * * @public * @this {LexErrorInfo} - */destroy:function destructLexErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! + */destroy:function destructLexErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;},/** * handler which is invoked when a lexer error occurs. * @@ -5077,8 +5127,8 @@ this.__error_infos.push(pei);return pei;},/** * * @public * @this {RegExpLexer} - */yyerror:function yyError(str/*, ...args */){var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** + */yyerror:function yyError(str/*, ...args */){let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: +let args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** * final cleanup function for when we have completed lexing the input; * make it an API so that external code can use this one once userland * code has decided it's time to destroy any lingering lexer error @@ -5093,13 +5143,13 @@ var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_a this.setInput('',{});// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** * clear the lexer token context; intended for internal use only * * @public * @this {RegExpLexer} */clear:function lexer_clear(){this.yytext='';this.yyleng=0;this.match='';// - DO NOT reset `this.matched` -this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** +this.matches=false;this._more=false;this._backtrack=false;const col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** * resets the lexer, sets new input * * @public @@ -5108,10 +5158,10 @@ this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.la // including expansion work to be done to go from a loaded // lexer to a usable lexer: if(!this.__decompressed){// step 1: decompress the regex list: -var rules=this.rules;for(var i=0,len=rules.length;i> tokens and perform user action code for a <> match, but only does so *once*) -return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}var ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). +return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}let ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. -var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;var ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** +let slice_len=1;let lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;const ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** * unshifts one char (or an entire string) into the input * * @public * @this {RegExpLexer} - */unput:function lexer_unput(ch){var len=ch.length;var lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** + */unput:function lexer_unput(ch){let len=ch.length;let lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** // The `offset` value MAY be negative if you `unput()` more text than you have already lexed. // This type of behaviour is generally observed for one kind of 'lexer/parser hack' // where custom token-illiciting characters are pushed in front of the input stream to help @@ -5181,11 +5231,11 @@ var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lin if(-this.offset>this.base_position){this.base_position=-this.offset;}this.match=this.match.substr(0,this.match.length-len);this.matched=this.matched.substr(0,this.matched.length-len);if(lines.length>1){this.yylineno-=lines.length-1;this.yylloc.last_line=this.yylineno+1;// Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. -var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** +let pre=this.match;let pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -5195,8 +5245,8 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */lookAhead:function lexer_lookAhead(){return this._input||'';},/** @@ -5213,7 +5263,7 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 */reject:function lexer_reject(){if(this.options.backtrack_lexer){this._backtrack=true;}else{// when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. -var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** +let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** * retain first n characters of the match * * @public @@ -5235,17 +5285,17 @@ var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yyl * * @public * @this {RegExpLexer} - */pastInput:function lexer_pastInput(maxSize,maxLines){var past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0)maxSize=Infinity;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=Infinity;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substr` anticipation: treat \r\n as a single character and take a little + */pastInput:function lexer_pastInput(maxSize,maxLines){let past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0){maxSize=Infinity;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=Infinity;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past=past.substr(-maxSize*2-2);// now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: -var a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, +let a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, // do add an ellipsis prefix... if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -5271,18 +5321,18 @@ if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} - */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){var next=this.match;var source=this._input||'';if(maxSize<0)maxSize=next.length+source.length;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=maxSize;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substring` anticipation: treat \r\n as a single character and take a little + */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){let next=this.match;let source=this._input||'';if(maxSize<0){maxSize=next.length+source.length;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=maxSize;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: if(next.lengthmaxSize){next=next.substring(0,maxSize)+'...';}return next;},/** @@ -5291,7 +5341,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){var pre=this.pastInput(maxPrefix).replace(/\s/g,' ');var c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** + */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){const pre=this.pastInput(maxPrefix).replace(/\s/g,' ');let c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** * return an YYLLOC info object derived off the given context (actual, preceding, following, current). * Use this method when the given `actual` location is not guaranteed to exist (i.e. when * it MAY be NULL) and you MUST have a valid location info object anyway: @@ -5307,7 +5357,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */deriveLocationInfo:function lexer_deriveYYLLOC(actual,preceding,following,current){var loc={first_line:1,first_column:0,last_line:1,last_column:0,range:[0,0]};if(actual){loc.first_line=actual.first_line|0;loc.last_line=actual.last_line|0;loc.first_column=actual.first_column|0;loc.last_column=actual.last_column|0;if(actual.range){loc.range[0]=actual.range[0]|0;loc.range[1]=actual.range[1]|0;}}if(loc.first_line<=0||loc.last_line=loc.first_line)){loc.last_line=current.last_line|0;loc.last_column=current.last_column|0;if(current.range){loc.range[1]=current.range[1]|0;}}}// sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter // or plan D heuristics to produce a 'sensible' last_line value: @@ -5356,9 +5406,9 @@ loc.range[1]=loc.range[0];}if(loc.first_column<0){loc.first_column=0;}if(loc.las * * @public * @this {RegExpLexer} - */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;var input=this.matched+(this._input||'');var lines=input.split('\n');var l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);var l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);var lineno_display_width=1+Math.log10(l1|1)|0;var ws_prefix=new Array(lineno_display_width).join(' ');var nonempty_line_indexes=[[],[],[]];var rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){var lno=index+l0;var lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);var rv=lno_pfx+': '+line;var errpfx=new Array(lineno_display_width+1).join('^');var offset=2+1;var len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it + */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;let input=this.matched+(this._input||'');let lines=input.split('\n');let l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);let l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);let lineno_display_width=1+Math.log10(l1|1)|0;let ws_prefix=new Array(lineno_display_width).join(' ');let nonempty_line_indexes=[[],[],[]];let rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){let lno=index+l0;let lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);let rv=lno_pfx+': '+line;let errpfx=new Array(lineno_display_width+1).join('^');let offset=2+1;let len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: -for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){var clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;var clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;var intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** +for(let i=0;i<=2;i++){let line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){let clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;let clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;let intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** * helper function, used to produce a human readable description as a string, given * the input `yylloc` location object. * @@ -5367,7 +5417,7 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){var l1=yylloc.first_line;var l2=yylloc.last_line;var c1=yylloc.first_column;var c2=yylloc.last_column;var dl=l2-l1;var dc=c2-c1;var rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){var r1=yylloc.range[0];var r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** + */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){let l1=yylloc.first_line;let l2=yylloc.last_line;let c1=yylloc.first_column;let c2=yylloc.last_column;let dl=l2-l1;let dc=c2-c1;let rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){let r1=yylloc.range[0];let r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** * test the lexed token: return FALSE when not a match, otherwise return token. * * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]` @@ -5384,18 +5434,18 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */test_match:function lexer_test_match(match,indexed_rule){var token,lines,backup,match_str,match_str_len;if(this.options.backtrack_lexer){// save context + */test_match:function lexer_test_match(match,indexed_rule){let backup;if(this.options.backtrack_lexer){// save context backup={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.yylloc.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column,range:this.yylloc.range.slice()},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,//_signaled_error_token: this._signaled_error_token, -yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}match_str=match[0];match_str_len=match_str.length;lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: +yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}let match_str=match[0];let match_str_len=match_str.length;let lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: // those rules will already have moved this `offset` forward matching their match lengths, // hence we must only add our own match length now: this.offset+=match_str_len;this._more=false;this._backtrack=false;this._input=this._input.slice(match_str_len);// calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} -token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: +let token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; if(this.done&&this._input){this.done=false;}if(token){return token;}else if(this._backtrack){// recover context -for(var k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. +for(let k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. }else if(this._signaled_error_token){// produce one 'error' token as `.parseError()` in `reject()` // did not guarantee a failure signal by throwing an exception! token=this._signaled_error_token;this._signaled_error_token=false;return token;}return false;},/** @@ -5403,19 +5453,19 @@ token=this._signaled_error_token;this._signaled_error_token=false;return token;} * * @public * @this {RegExpLexer} - */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}var token,match,tempMatch,index;if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}var spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. + */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}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();// Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 -if(!spec||!spec.rules){var lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! -return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}var rule_ids=spec.rules;var regexes=spec.__rule_regexes;var len=spec.__rule_count;// Note: the arrays are 1-based, while `len` itself is a valid index, +if(!spec||!spec.rules){let lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! +return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}{let rule_ids=spec.rules;let regexes=spec.__rule_regexes;let len=spec.__rule_count;let match;let index;// 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(var i=1;i<=len;i++){tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. +for(let i=1;i<=len;i++){let tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){let token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. }else{// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}}else if(!this.options.flex){break;}}}if(match){token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}if(!this._input){this.done=true;this.clear();return this.EOF;}else{var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);var pendingInput=this._input;var activeCondition=this.topState();var conditionStackDepth=this.conditionStack.length;token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us +return false;}}else if(!this.options.flex){break;}}}if(match){let token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) +return false;}}if(!this._input){this.done=true;this.clear();return this.EOF;}{let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);let pendingInput=this._input;let activeCondition=this.topState();let conditionStackDepth=this.conditionStack.length;let token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: if(!this.matches&&// and make sure the input has been modified/consumed ... @@ -5426,7 +5476,7 @@ activeCondition===this.topState()&&conditionStackDepth===this.conditionStack.len * * @public * @this {RegExpLexer} - */lex:function lexer_lex(){var r;//this._clear_state = 0; + */lex:function lexer_lex(){let r;//this._clear_state = 0; if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}// allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer: if(typeof this.pre_lex==='function'){r=this.pre_lex.call(this,0);}if(typeof this.options.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.pre_lex.call(this,r)||r;}if(this.yy&&typeof this.yy.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) @@ -5434,50 +5484,50 @@ r=this.yy.pre_lex.call(this,r)||r;}while(!r){r=this.next();}if(this.yy&&typeof t r=this.yy.post_lex.call(this,r)||r;}if(typeof this.options.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.post_lex.call(this,r)||r;}if(typeof this.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.post_lex.call(this,r)||r;}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return next match that has a token. Identical to the `lex()` API but does not invoke any of the * `pre_lex()` nor any of the `post_lex()` callbacks. * * @public * @this {RegExpLexer} - */fastLex:function lexer_fastLex(){var r;//this._clear_state = 0; + */fastLex:function lexer_fastLex(){let r;//this._clear_state = 0; while(!r){r=this.next();}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return info about the lexer state that can help a parser or other lexer API user to use the * most efficient means available. This API is provided to aid run-time performance for larger @@ -5485,7 +5535,7 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */canIUse:function lexer_canIUse(){var rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** + */canIUse:function lexer_canIUse(){const rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** * backwards compatible alias for `pushState()`; * the latter is symmetrical with `popState()` and we advise to use * those APIs in any modern lexer code, rather than `begin()`. @@ -5504,20 +5554,20 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */popState:function lexer_popState(){var n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}else{return this.conditionStack[0];}},/** + */popState:function lexer_popState(){const n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}return this.conditionStack[0];},/** * return the currently active lexer condition state; when an index * argument is provided it produces the N-th previous condition state, * if available * * @public * @this {RegExpLexer} - */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}else{return'INITIAL';}},/** + */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}return'INITIAL';},/** * (internal) determine the lexer rule set which is active for the * currently active lexer condition state * * @public * @this {RegExpLexer} - */_currentRules:function lexer__currentRules(){var n=this.conditionStack.length-1;var state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions['INITIAL'];},/** + */_currentRules:function lexer__currentRules(){const n=this.conditionStack.length-1;let state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions.INITIAL;},/** * return the number of states currently on the stack * * @public @@ -5776,10 +5826,10 @@ return s;}// convert string value to number or boolean value, when possible // 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};var version='0.6.2-220';// require('./package.json').version; +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; 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(var i=0;i, include: } }if(decl.codeSection){if(!grammar.moduleInit){grammar.moduleInit=[];}grammar.moduleInit.push(decl.codeSection);// {qualifier: , include: } @@ -5788,5 +5838,5 @@ grammar.imports.push(decl.imports);}if(decl.initCode){if(!grammar.moduleInit){gr function parseLex(text,position){text=text.replace(/(?:^%lex)|(?:\/lex$)/g,'');// We want the lex input to start at the given 'position', if any, // so that error reports will produce a line number and character index // which matches the original input file: -position=position||{};position.range=position.range||[];var l=position.first_line|0;var c=position.range[0]|0;var prelude='';if(l>1){prelude+=new Array(l).join('\n');c-=prelude.length;}if(c>3){prelude='// '+new Array(c-3).join('.')+prelude;}return jisonlex.parse(prelude+text);}const ebnf_parser={transform};var ebnfParser={parse,transform,// assistant exports for debugging/testing: +position=position||{};position.range=position.range||[];let l=position.first_line|0;let c=position.range[0]|0;let prelude='';if(l>1){prelude+=new Array(l).join('\n');c-=prelude.length;}if(c>3){prelude='// '+new Array(c-3).join('.')+prelude;}return jisonlex.parse(prelude+text);}const ebnf_parser={transform};var ebnfParser={parse,transform,// assistant exports for debugging/testing: bnf_parser:bnf,ebnf_parser,bnf_lexer:jisonlex,version};return ebnfParser;}); diff --git a/packages/ebnf-parser/dist/ebnf-parser-umd.js b/packages/ebnf-parser/dist/ebnf-parser-umd.js index 1ff9cff9e..1fb8240bf 100644 --- a/packages/ebnf-parser/dist/ebnf-parser-umd.js +++ b/packages/ebnf-parser/dist/ebnf-parser-umd.js @@ -1,8 +1,8 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@gerhobbelt/xregexp'), require('fs'), require('path'), require('@gerhobbelt/json5'), require('recast'), require('@babel/core'), require('assert')) : - typeof define === 'function' && define.amd ? define(['@gerhobbelt/xregexp', 'fs', 'path', '@gerhobbelt/json5', 'recast', '@babel/core', 'assert'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['ebnf-parser'] = factory(global.XRegExp, global.fs, global.path$1, global.JSON5, global.recast, global.babel, global.assert$1)); -}(this, (function (XRegExp, fs, path$1, JSON5, recast, babel, assert$1) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@gerhobbelt/xregexp'), require('fs'), require('path'), require('@gerhobbelt/json5'), require('mkdirp'), require('recast'), require('@babel/core'), require('assert')) : + typeof define === 'function' && define.amd ? define(['@gerhobbelt/xregexp', 'fs', 'path', '@gerhobbelt/json5', 'mkdirp', 'recast', '@babel/core', 'assert'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['ebnf-parser'] = factory(global.XRegExp, global.fs, global.path$1, global.JSON5, global.mkdirp, global.recast, global.babel, global.assert$1)); +}(this, (function (XRegExp, fs, path$1, JSON5, mkdirp, recast, babel, assert$1) { 'use strict'; function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } @@ -10,10 +10,11 @@ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); + var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); - // Return TRUE if `src` starts with `searchString`. + // Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -36,19 +37,19 @@ // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -67,19 +68,21 @@ // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -88,16 +91,19 @@ } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -108,27 +114,79 @@ return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } + // https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words + const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; + })([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' + ]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -146,6 +204,11 @@ .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -154,13 +217,13 @@ function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -171,23 +234,17 @@ break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -210,34 +267,33 @@ /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -260,28 +316,76 @@ // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } + function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; + } + + + function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); + } + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -292,27 +396,37 @@ dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -322,7 +436,7 @@ } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -330,7 +444,7 @@ ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -356,27 +470,43 @@ // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -389,9 +519,10 @@ - var code_exec = { + var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -413,22 +544,22 @@ // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; - // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries + // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; - // Determine which Unicode NonAsciiIdentifierStart characters + // Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. - // + // // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action - // code chunks. - // + // code chunks. + // // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -436,40 +567,40 @@ function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -477,30 +608,30 @@ // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -511,59 +642,59 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -605,38 +736,38 @@ return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -648,18 +779,18 @@ // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -670,56 +801,56 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -727,97 +858,97 @@ typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -825,7 +956,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -838,7 +969,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -851,7 +982,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -864,7 +995,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -883,37 +1014,37 @@ let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -945,7 +1076,7 @@ // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -962,37 +1093,37 @@ .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return babel.transformSync(src, options); // => { code, map, ast } @@ -1000,8 +1131,8 @@ function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1010,7 +1141,7 @@ // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1033,25 +1164,25 @@ // validate the given JISON+JavaScript snippet: does it compile? - // - // Return either the parsed AST (object) or an error message (string). + // + // Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1062,9 +1193,9 @@ // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. - // + // // Returns the trimmed sourcecode which was provided via `src`. - // + // // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1072,7 +1203,7 @@ // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: - // + // // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1081,14 +1212,14 @@ // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} - // + // // Of course the example would be 'ludicrous' action code but the - // key point here is that users will certainly be able to come up with + // key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! - // + // function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1142,7 +1273,7 @@ trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1156,7 +1287,7 @@ /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1168,24 +1299,24 @@ /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. - /// + /// /// Also supports ES6's Arrow Functions: - /// + /// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' - /// + /// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1202,8 +1333,8 @@ if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1214,14 +1345,14 @@ action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1232,17 +1363,17 @@ var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; - // - // - // + // + // + // function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1268,7 +1399,7 @@ // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1316,7 +1447,7 @@ // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1379,13 +1510,13 @@ getRegExpInfo: getRegExpInfo }; - var cycleref = []; - var cyclerefpath = []; + let cycleref = []; + let cyclerefpath = []; - var linkref = []; - var linkrefpath = []; + let linkref = []; + let linkrefpath = []; - var path = []; + let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1393,14 +1524,14 @@ return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1413,11 +1544,11 @@ function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1430,9 +1561,9 @@ dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1447,16 +1578,52 @@ } + // strip developer machine specific parts off any paths in a given stacktrace (string) + // to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } + // strip off the line/position info from any stacktrace as a assert.deepEqual() on these + // will otherwise FAIL due to us running this stuff through both regular `node` and + // the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing + // exceptions and stacktraces which point completely somewhere else and this would b0rk + // our test rigs for the jison subpackages. + function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; + } + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1471,7 +1638,7 @@ function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1497,10 +1664,10 @@ } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1598,7 +1765,7 @@ function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1615,7 +1782,7 @@ path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1643,7 +1810,7 @@ function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1659,7 +1826,7 @@ linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1671,14 +1838,14 @@ // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. - // + // // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1688,7 +1855,7 @@ cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1702,12 +1869,14 @@ dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1722,7 +1891,7 @@ printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; // See also: @@ -1730,7 +1899,6 @@ // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1747,9 +1915,9 @@ this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -1782,10 +1950,10 @@ // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -1800,18 +1968,18 @@ // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -1842,7 +2010,7 @@ // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -1859,9 +2027,9 @@ // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -1874,7 +2042,7 @@ } - var parser = { + let parser = { // Code Generator Information Report // --------------------------------- // @@ -2000,7 +2168,6 @@ // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2008,7 +2175,6 @@ // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2020,8 +2186,8 @@ // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2034,14 +2200,13 @@ // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2057,10 +2222,10 @@ // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2068,10 +2233,10 @@ this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2115,9 +2280,9 @@ /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; @@ -2125,17 +2290,17 @@ case 0: /*! Production:: $accept : production $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-) break; case 1: /*! Production:: production : handle EOF */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-) return yyvstack[yysp - 1]; @@ -2371,7 +2536,6 @@ 19: 3 }, parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -2388,37 +2552,32 @@ } }, parse: function parse(input) { + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) + let vstack = new Array(128); // semantic value stack - var vstack = new Array(128); // semantic value stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks + let symbol = 0; - - - - var symbol = 0; + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -2426,20 +2585,18 @@ pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -2456,7 +2613,6 @@ // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -2464,18 +2620,19 @@ if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -2483,18 +2640,14 @@ // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } @@ -2516,7 +2669,6 @@ // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -2529,7 +2681,6 @@ // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -2543,11 +2694,10 @@ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -2601,8 +2751,8 @@ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -2751,8 +2901,7 @@ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -2761,10 +2910,10 @@ token_id: symbol, line: lexer.yylineno, - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -2772,7 +2921,7 @@ stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -2783,9 +2932,14 @@ // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -2811,8 +2965,7 @@ function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -2821,21 +2974,20 @@ function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -2845,21 +2997,20 @@ } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -2868,20 +3019,20 @@ return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; try { @@ -2894,7 +3045,7 @@ // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -2947,14 +3098,11 @@ - - - - // handle parse error + // handle parse error if (!action) { - var errStr; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let errStr; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); // Report error errStr = 'Parse error'; @@ -2991,9 +3139,7 @@ - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -3022,7 +3168,7 @@ sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -3064,21 +3210,19 @@ - - - r = this.performAction.call(yyval, newState, sp - 1, vstack); + r = this.performAction.call(yyval, newState, sp - 1, vstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -3109,14 +3253,15 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -3126,6 +3271,7 @@ + } continue; // accept: @@ -3178,8 +3324,7 @@ // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -3439,7 +3584,6 @@ * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -3456,10 +3600,10 @@ }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -3491,7 +3635,7 @@ JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -3533,7 +3677,9 @@ // // --------- END OF REPORT ----------- - EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -3619,7 +3765,7 @@ if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -3627,7 +3773,7 @@ msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -3640,7 +3786,7 @@ } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -3666,10 +3812,13 @@ * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -3692,7 +3841,6 @@ * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -3715,16 +3863,16 @@ * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -3746,7 +3894,6 @@ * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -3754,8 +3901,8 @@ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -3784,7 +3931,7 @@ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -3809,7 +3956,7 @@ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -3821,17 +3968,17 @@ } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -3925,7 +4072,7 @@ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -3946,7 +4093,6 @@ * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -3957,7 +4103,7 @@ this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -3968,15 +4114,15 @@ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -4010,8 +4156,8 @@ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -4044,9 +4190,9 @@ // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -4065,9 +4211,9 @@ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -4077,8 +4223,8 @@ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -4105,20 +4251,19 @@ * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -4158,17 +4303,19 @@ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -4177,7 +4324,7 @@ // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -4192,8 +4339,8 @@ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -4219,24 +4366,26 @@ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -4247,7 +4396,7 @@ // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -4269,8 +4418,8 @@ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -4292,8 +4441,7 @@ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -4437,21 +4585,21 @@ const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -4466,11 +4614,11 @@ len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -4489,13 +4637,13 @@ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -4519,13 +4667,13 @@ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -4540,8 +4688,8 @@ } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -4572,7 +4720,7 @@ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -4604,9 +4752,9 @@ }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -4635,7 +4783,7 @@ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -4653,7 +4801,7 @@ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -4678,7 +4826,6 @@ * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -4688,8 +4835,6 @@ this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -4698,7 +4843,7 @@ this.clear(); } - 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. @@ -4710,13 +4855,13 @@ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -4726,68 +4871,74 @@ } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -4812,7 +4963,7 @@ * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -4860,24 +5011,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -4897,7 +5048,7 @@ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -4907,24 +5058,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -4945,8 +5096,7 @@ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -4986,14 +5136,14 @@ * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -5009,9 +5159,9 @@ if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -5022,8 +5172,8 @@ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -5031,7 +5181,7 @@ state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -5184,9 +5334,9 @@ // guaranteed not to collide with previously generated / already existing // rules (~ symbols). function generateUniqueSymbol(id, postfix, opts) { - var sym = id + postfix; + let sym = id + postfix; if (opts.grammar[sym]) { - var i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. + let i = 2; // the first occurrence won't have a number, this is already a collision, so start numbering at *2*. do { sym = id + postfix + i; i++; @@ -5196,8 +5346,8 @@ } function generatePushAction(handle, offset) { - var terms = handle.terms; - var rv = []; + const terms = handle.terms; + let rv = []; for (var i = 0, len = terms.length; i < len; i++) { rv.push('$' + (i + offset)); @@ -5213,11 +5363,11 @@ } function transformExpression(e, opts, emit) { - var type = e[0], - value = e[1], - name = false, - has_transformed = 0; - var list, n; + let type = e[0]; + let value = e[1]; + let name = false; + let has_transformed = 0; + let list, n; if (type === 'xalias') { type = e[1]; @@ -5244,7 +5394,7 @@ has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ list.fragment, @@ -5264,7 +5414,7 @@ has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); opts.grammar[name] = [ [ '', @@ -5284,7 +5434,7 @@ has_transformed = 1; opts = optsForProduction(name, opts.grammar); - list = transformExpressionList([value], opts); + list = transformExpressionList([ value ], opts); // you want to be able to check if 0 or 1 occurrences were recognized: since jison // by default *copies* the lexer token value, i.e. `$$ = $1` is the (optional) default action, // we will need to set the action up explicitly in case of the 0-count match: @@ -5320,7 +5470,7 @@ opts = optsForProduction(name, opts.grammar); opts.grammar[name] = value.map(function (handle) { - var list = transformExpressionList(handle, opts); + let list = transformExpressionList(handle, opts); return [ list.fragment, '$$ = ' + generatePushAction(list, 1) + ';' @@ -5333,11 +5483,11 @@ } function transformExpressionList(list, opts) { - var first_transformed_term_index = false; - var terms = list.reduce(function (tot, e) { - var ci = tot.length; + let first_transformed_term_index = false; + let terms = list.reduce(function (tot, e) { + let ci = tot.length; - var has_transformed = transformExpression(e, opts, function (name) { + let has_transformed = transformExpression(e, opts, function (name) { if (name.terms) { tot.push.apply(tot, name.terms); } else { @@ -5366,42 +5516,42 @@ } function transformProduction(id, production, grammar) { - var transform_opts = optsForProduction(id, grammar); + let transform_opts = optsForProduction(id, grammar); return production.map(function (handle) { - var action = null, - opts = null; - var i, len, n; + let action = null; + let opts = null; + let i, len, n; if (typeof handle !== 'string') { action = handle[1]; opts = handle[2]; handle = handle[0]; } - var expressions = handle; + let expressions = handle; if (typeof expressions === 'string') { expressions = parser$1.parse(handle); } - var list = transformExpressionList(expressions, transform_opts); + let list = transformExpressionList(expressions, transform_opts); - var ret = [list.fragment]; + let ret = [ list.fragment ]; if (action) { // make sure the action doesn't address any inner items. if (list.first_transformed_term_index) { // seek out all names and aliases; strip out literal tokens first as those cannot serve as $names: - var alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); + let alist = list.terms; // rhs.replace(/'[^']+'/g, '~').replace(/"[^"]+"/g, '~').split(' '); - var alias_re = new XRegExp__default['default'](`\\[${ID_REGEX_BASE$1}\\]`); - var term_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$1}$`); + let alias_re = new XRegExp__default['default'](`\\[${ID_REGEX_BASE$1}\\]`); + let term_re = new XRegExp__default['default'](`^${ID_REGEX_BASE$1}$`); // and collect the PERMITTED aliases: the names of the terms and all the remaining aliases - var good_aliases = {}; - var alias_cnt = {}; - var donotalias = {}; + let good_aliases = {}; + let alias_cnt = {}; + let donotalias = {}; // WARNING: this replicates the knowledge/code of jison.js::addName() - var addName = function addNameEBNF(s, i) { - var base = s.replace(/[0-9]+$/, ''); - var dna = donotalias[base]; + let addName = function addNameEBNF(s, i) { + let base = s.replace(/[0-9]+$/, ''); + let dna = donotalias[base]; if (good_aliases[s]) { alias_cnt[s]++; @@ -5420,7 +5570,7 @@ }; // WARNING: this replicates the knowledge/code of jison.js::markBasename() - var markBasename = function markBasenameEBNF(s) { + let markBasename = function markBasenameEBNF(s) { if (/[0-9]$/.test(s)) { s = s.replace(/[0-9]+$/, ''); donotalias[s] = true; @@ -5457,13 +5607,13 @@ // now scan the action for all named and numeric semantic values ($nonterminal / $1 / @1, ##1, ...) // // Note that `#name` are straight **static** symbol translations, which are okay as they don't - // require access to the parse stack: `#n` references can be resolved completely + // require access to the parse stack: `#n` references can be resolved completely // at grammar compile time. // - var nameref_re = new XRegExp__default['default'](`(?:[$@]|##)${ID_REGEX_BASE$1}`, 'g'); - var named_spots = nameref_re.exec(action); - var numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); - var max_term_index = list.terms.length; + let nameref_re = new XRegExp__default['default'](`(?:[$@]|##)${ID_REGEX_BASE$1}`, 'g'); + let named_spots = nameref_re.exec(action); + let numbered_spots = action.match(/(?:[$@]|##)[0-9]+\b/g); + let max_term_index = list.terms.length; // loop through the XRegExp alias regex matches in `action` while (named_spots) { @@ -5493,7 +5643,7 @@ for (i = 0, len = numbered_spots.length; i < len; i++) { n = parseInt(numbered_spots[i].replace(/^(?:[$@]|##)/, '')); if (n > max_term_index) { - /* @const */ var n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; + /* @const */ let n_suffixes = [ 'st', 'nd', 'rd', 'th' ]; throw new Error('The action block references the ' + n + n_suffixes[Math.max(0, Math.min(3, n - 1))] + ' term, ' + 'which is not available in production "' + handle + '"; ' + 'Be reminded that you cannot reference sub-elements within EBNF */+/? groups, ' + @@ -5511,13 +5661,14 @@ if (ret.length === 1) { return ret[0]; - } else { - return ret; } + return ret; + }); } - var ref_list; - var ref_names; + + let ref_list; + let ref_names; // create a deep copy of the input, so we will keep the input constant. function deepClone(from, sub) { @@ -5532,7 +5683,7 @@ return from; } - var idx = ref_list.indexOf(from); + let idx = ref_list.indexOf(from); if (idx >= 0) { throw new Error('[Circular/Xref:' + ref_names[i] + ']'); // circular or cross reference } @@ -5548,7 +5699,7 @@ sub += '.'; var to = new from.constructor(); - for (var name in from) { + for (let name in from) { to[name] = deepClone(from[name], sub + name); } } @@ -5564,8 +5715,9 @@ return grammar; } + function transform(ebnf) { - var rv = transformGrammar(ebnf); + let rv = transformGrammar(ebnf); return rv; } @@ -5575,7 +5727,6 @@ // 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. function JisonParserError$1(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -5592,9 +5743,9 @@ this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -5627,10 +5778,10 @@ // helper: reconstruct the productions[] table function bp$1(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -5643,11 +5794,11 @@ // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -5657,18 +5808,18 @@ // helper: reconstruct the 'goto' table function bt$1(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -5699,7 +5850,7 @@ // `this` references an array function s$1(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -5716,9 +5867,9 @@ // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$1(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -5731,7 +5882,7 @@ } - var parser$2 = { + let parser$2 = { // Code Generator Information Report // --------------------------------- // @@ -5967,7 +6118,6 @@ // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -5975,7 +6125,6 @@ // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -5987,8 +6136,8 @@ // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -6001,14 +6150,13 @@ // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -6024,10 +6172,10 @@ // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -6035,10 +6183,10 @@ this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -6219,26 +6367,26 @@ /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; switch (yystate) { case 0: /*! Production:: $accept : spec $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break; case 1: /*! Production:: spec : declaration_list "%%" grammar optional_end_block EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4]; @@ -6250,10 +6398,10 @@ case 2: /*! Production:: spec : declaration_list "%%" grammar error EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6272,10 +6420,10 @@ case 3: /*! Production:: spec : declaration_list error EOF */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6297,9 +6445,9 @@ case 133: /*! Production:: optional_module_code_chunk : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -6308,9 +6456,9 @@ case 5: /*! Production:: optional_end_block : "%%" extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6330,9 +6478,9 @@ case 10: /*! Production:: declaration_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; @@ -6343,9 +6491,9 @@ case 8: /*! Production:: optional_action_header_block : optional_action_header_block include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -6364,9 +6512,9 @@ case 9: /*! Production:: declaration_list : declaration_list declaration */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6375,10 +6523,10 @@ case 11: /*! Production:: declaration_list : declaration_list error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6393,9 +6541,9 @@ case 12: /*! Production:: declaration : START id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {start: yyvstack[yysp]}; @@ -6404,9 +6552,9 @@ case 13: /*! Production:: declaration : LEX_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {lex: {text: yyvstack[yysp], position: yylstack[yysp]}}; @@ -6415,9 +6563,9 @@ case 14: /*! Production:: declaration : operator */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {operator: yyvstack[yysp]}; @@ -6426,9 +6574,9 @@ case 15: /*! Production:: declaration : TOKEN full_token_definitions */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {token_list: yyvstack[yysp]}; @@ -6437,9 +6585,9 @@ case 16: /*! Production:: declaration : ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6457,9 +6605,9 @@ case 17: /*! Production:: declaration : include_macro_code */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6477,9 +6625,9 @@ case 18: /*! Production:: declaration : parse_params */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parseParams: yyvstack[yysp]}; @@ -6488,9 +6636,9 @@ case 19: /*! Production:: declaration : parser_type */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parserType: yyvstack[yysp]}; @@ -6499,9 +6647,9 @@ case 20: /*! Production:: declaration : options */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: yyvstack[yysp]}; @@ -6510,9 +6658,9 @@ case 21: /*! Production:: declaration : DEBUG */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: [['debug', true]]}; @@ -6521,9 +6669,9 @@ case 22: /*! Production:: declaration : EBNF */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) ebnf = true; @@ -6533,9 +6681,9 @@ case 23: /*! Production:: declaration : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {unknownDecl: yyvstack[yysp]}; @@ -6544,9 +6692,9 @@ case 24: /*! Production:: declaration : IMPORT import_name import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = {imports: {name: yyvstack[yysp - 1], path: yyvstack[yysp]}}; @@ -6555,10 +6703,10 @@ case 25: /*! Production:: declaration : IMPORT import_name error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6574,10 +6722,10 @@ case 26: /*! Production:: declaration : IMPORT error import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6593,9 +6741,9 @@ case 27: /*! Production:: declaration : INIT_CODE init_code_name action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6618,10 +6766,10 @@ case 28: /*! Production:: declaration : INIT_CODE error action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6637,10 +6785,10 @@ case 29: /*! Production:: declaration : START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6655,10 +6803,10 @@ case 30: /*! Production:: declaration : TOKEN error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6673,10 +6821,10 @@ case 31: /*! Production:: declaration : IMPORT error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6741,9 +6889,9 @@ case 132: /*! Production:: optional_module_code_chunk : module_code_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -6754,9 +6902,9 @@ case 111: /*! Production:: action_ne : "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -6765,10 +6913,10 @@ case 40: /*! Production:: options : OPTIONS error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6783,10 +6931,10 @@ case 41: /*! Production:: options : OPTIONS error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6805,9 +6953,9 @@ case 70: /*! Production:: id_list : id_list id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -6822,9 +6970,9 @@ case 84: /*! Production:: handle_list : handle_action */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -6833,9 +6981,9 @@ case 44: /*! Production:: option : NAME */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -6844,9 +6992,9 @@ case 45: /*! Production:: option : NAME "=" OPTION_STRING_VALUE */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -6857,9 +7005,9 @@ case 47: /*! Production:: option : NAME "=" NAME */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], parseValue(yyvstack[yysp])]; @@ -6868,10 +7016,10 @@ case 48: /*! Production:: option : NAME "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6886,10 +7034,10 @@ case 49: /*! Production:: option : NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6906,9 +7054,9 @@ case 52: /*! Production:: parser_type : PARSER_TYPE symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -6917,10 +7065,10 @@ case 51: /*! Production:: parse_params : PARSE_PARAM error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6938,10 +7086,10 @@ case 53: /*! Production:: parser_type : PARSER_TYPE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6959,9 +7107,9 @@ case 54: /*! Production:: operator : associativity token_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1]]; this.$.push.apply(this.$, yyvstack[yysp]); @@ -6970,10 +7118,10 @@ case 55: /*! Production:: operator : associativity error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -6991,9 +7139,9 @@ case 56: /*! Production:: associativity : LEFT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'left'; @@ -7002,9 +7150,9 @@ case 57: /*! Production:: associativity : RIGHT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'right'; @@ -7013,9 +7161,9 @@ case 58: /*! Production:: associativity : NONASSOC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'nonassoc'; @@ -7024,9 +7172,9 @@ case 61: /*! Production:: full_token_definitions : optional_token_type id_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var rv = []; @@ -7045,9 +7193,9 @@ case 62: /*! Production:: full_token_definitions : optional_token_type one_full_token */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var m = yyvstack[yysp]; @@ -7060,9 +7208,9 @@ case 63: /*! Production:: one_full_token : id token_value token_description */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -7075,9 +7223,9 @@ case 64: /*! Production:: one_full_token : id token_description */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -7089,9 +7237,9 @@ case 65: /*! Production:: one_full_token : id token_value */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -7103,9 +7251,9 @@ case 66: /*! Production:: optional_token_type : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = false; @@ -7114,9 +7262,9 @@ case 72: /*! Production:: grammar : optional_action_header_block production_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -7126,9 +7274,9 @@ case 73: /*! Production:: production_list : production_list production */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -7142,9 +7290,9 @@ case 74: /*! Production:: production_list : production */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; this.$[yyvstack[yysp][0]] = yyvstack[yysp][1]; @@ -7153,9 +7301,9 @@ case 75: /*! Production:: production : production_id handle_list ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp - 1]]; @@ -7164,10 +7312,10 @@ case 76: /*! Production:: production : production_id error ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7185,10 +7333,10 @@ case 77: /*! Production:: production : production_id error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7206,9 +7354,9 @@ case 78: /*! Production:: production_id : id optional_production_description ":" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -7219,10 +7367,10 @@ case 79: /*! Production:: production_id : id optional_production_description error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7240,10 +7388,10 @@ case 80: /*! Production:: production_id : id optional_production_description ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7267,18 +7415,18 @@ case 82: /*! Production:: optional_production_description : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) break; case 83: /*! Production:: handle_list : handle_list "|" handle_action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -7288,10 +7436,10 @@ case 85: /*! Production:: handle_list : handle_list "|" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7309,10 +7457,10 @@ case 86: /*! Production:: handle_list : handle_list ":" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7327,9 +7475,9 @@ case 87: /*! Production:: handle_action : handle prec action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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(' ') : '')]; @@ -7364,9 +7512,9 @@ case 88: /*! Production:: handle_action : EPSILON action */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = ['']; @@ -7390,10 +7538,10 @@ case 89: /*! Production:: handle_action : EPSILON error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7408,9 +7556,9 @@ case 90: /*! Production:: handle : handle suffixed_expression */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -7420,9 +7568,9 @@ case 91: /*! Production:: handle : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -7431,9 +7579,9 @@ case 92: /*! Production:: handle_sublist : handle_sublist "|" handle */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -7443,9 +7591,9 @@ case 93: /*! Production:: handle_sublist : handle */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp].join(' ')]; @@ -7454,9 +7602,9 @@ case 94: /*! Production:: suffixed_expression : expression suffix ALIAS */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + "[" + yyvstack[yysp] + "]"; @@ -7469,9 +7617,9 @@ case 130: /*! Production:: module_code_chunk : module_code_chunk CODE */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -7480,9 +7628,9 @@ case 97: /*! Production:: expression : EOF_ID */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$end'; @@ -7491,9 +7639,9 @@ case 98: /*! Production:: expression : STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // Re-encode the string *anyway* as it will @@ -7506,9 +7654,9 @@ case 99: /*! Production:: expression : "(" handle_sublist ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1].join(' | ') + ')'; @@ -7517,10 +7665,10 @@ case 100: /*! Production:: expression : "(" handle_sublist error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -7534,9 +7682,9 @@ case 105: /*! Production:: prec : PREC symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { prec: yyvstack[yysp] }; @@ -7545,10 +7693,10 @@ case 106: /*! Production:: prec : PREC error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -7566,9 +7714,9 @@ case 107: /*! Production:: prec : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = null; @@ -7577,10 +7725,10 @@ case 112: /*! Production:: action_ne : "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -7594,9 +7742,9 @@ case 116: /*! Production:: action : ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$$ = (' + yyvstack[yysp] + ');'; @@ -7605,9 +7753,9 @@ case 120: /*! Production:: action_body : action_body "{" action_body "}" action_comments_body */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4] + yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -7616,9 +7764,9 @@ case 121: /*! Production:: action_body : action_body "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -7627,10 +7775,10 @@ case 122: /*! Production:: action_body : action_body "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -7644,9 +7792,9 @@ case 126: /*! Production:: extra_parser_module_code : optional_module_code_chunk include_macro_code extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -7655,9 +7803,9 @@ case 127: /*! Production:: include_macro_code : INCLUDE PATH */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' }); @@ -7677,10 +7825,10 @@ case 128: /*! Production:: include_macro_code : INCLUDE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -7693,10 +7841,10 @@ case 131: /*! Production:: module_code_chunk : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -9089,7 +9237,6 @@ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -9106,59 +9253,53 @@ } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, parser: undefined, pre_parse: undefined, post_parse: undefined, - pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! - }; - - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + pre_lex: undefined, + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! + }; + + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -9180,7 +9321,6 @@ // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -9188,18 +9328,19 @@ if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -9207,24 +9348,19 @@ // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -9262,18 +9398,15 @@ - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); + let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -9294,7 +9427,7 @@ // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -9312,7 +9445,6 @@ // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -9325,7 +9457,6 @@ // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -9339,11 +9470,10 @@ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -9397,8 +9527,8 @@ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -9406,8 +9536,8 @@ this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -9439,19 +9569,18 @@ // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -9462,7 +9591,7 @@ if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -9475,7 +9604,7 @@ if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -9487,29 +9616,27 @@ // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -9517,7 +9644,7 @@ l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -9537,8 +9664,7 @@ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -9547,10 +9673,10 @@ token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -9558,7 +9684,7 @@ location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -9569,9 +9695,14 @@ // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -9587,8 +9718,7 @@ // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -9657,11 +9787,14 @@ // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -9672,8 +9805,7 @@ }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -9682,21 +9814,20 @@ function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -9706,21 +9837,20 @@ } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -9729,28 +9859,27 @@ return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -9763,8 +9892,7 @@ - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; + const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -9787,8 +9915,7 @@ - - if (symbol === EOF) { + if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -9800,8 +9927,7 @@ - - --stack_probe; // popStack(1): [symbol, action] + --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -9818,8 +9944,7 @@ - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -9833,8 +9958,7 @@ - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } @@ -9848,7 +9972,7 @@ // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -9901,16 +10025,13 @@ - - - - // handle parse error + // handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -9944,9 +10065,7 @@ - - - r = this.parseError(p.errStr, p, this.JisonParserError); + r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -9969,9 +10088,7 @@ - - - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -9998,17 +10115,16 @@ - - } + } // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -10055,8 +10171,8 @@ recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -10068,8 +10184,7 @@ - - } else { + } else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -10087,6 +10202,7 @@ yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -10095,7 +10211,7 @@ - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -10106,7 +10222,7 @@ sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -10166,10 +10282,10 @@ // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -10204,9 +10320,7 @@ - - - // encountered another parse error? If so, break out to main loop + // encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -10219,7 +10333,7 @@ - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -10240,9 +10354,7 @@ - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -10264,12 +10376,12 @@ // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -10278,7 +10390,7 @@ ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -10319,7 +10431,7 @@ } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -10366,7 +10478,7 @@ // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -10384,21 +10496,19 @@ - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -10432,14 +10542,15 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -10449,6 +10560,7 @@ + } continue; // accept: @@ -10500,7 +10612,7 @@ // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -10516,9 +10628,7 @@ - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -10547,7 +10657,7 @@ sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -10564,8 +10674,8 @@ symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -10576,8 +10686,8 @@ // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -10589,21 +10699,19 @@ - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -10634,14 +10742,15 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -10651,6 +10760,7 @@ + } continue; // accept: @@ -10703,8 +10813,7 @@ // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -10965,7 +11074,6 @@ * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -10982,10 +11090,10 @@ }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -11017,7 +11125,7 @@ JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -11059,7 +11167,9 @@ // // --------- END OF REPORT ----------- - EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -11145,7 +11255,7 @@ if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -11153,7 +11263,7 @@ msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -11166,7 +11276,7 @@ } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -11192,10 +11302,13 @@ * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -11218,7 +11331,6 @@ * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -11241,16 +11353,16 @@ * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -11272,7 +11384,6 @@ * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -11280,8 +11391,8 @@ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -11310,7 +11421,7 @@ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -11335,7 +11446,7 @@ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -11347,17 +11458,17 @@ } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -11451,7 +11562,7 @@ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -11472,7 +11583,6 @@ * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -11483,7 +11593,7 @@ this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -11494,15 +11604,15 @@ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -11536,8 +11646,8 @@ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -11570,9 +11680,9 @@ // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -11591,9 +11701,9 @@ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -11603,8 +11713,8 @@ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -11631,20 +11741,19 @@ * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -11684,17 +11793,19 @@ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -11703,7 +11814,7 @@ // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -11718,8 +11829,8 @@ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -11745,24 +11856,26 @@ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -11773,7 +11886,7 @@ // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -11795,8 +11908,8 @@ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -11818,8 +11931,7 @@ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -11963,21 +12075,21 @@ const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -11992,11 +12104,11 @@ len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -12015,13 +12127,13 @@ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -12045,13 +12157,13 @@ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -12066,8 +12178,8 @@ } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -12098,7 +12210,7 @@ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -12130,9 +12242,9 @@ }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -12161,7 +12273,7 @@ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -12179,7 +12291,7 @@ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -12204,7 +12316,6 @@ * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -12214,8 +12325,6 @@ this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -12224,7 +12333,7 @@ this.clear(); } - 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. @@ -12236,13 +12345,13 @@ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -12252,68 +12361,74 @@ } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -12338,7 +12453,7 @@ * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -12386,24 +12501,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -12423,7 +12538,7 @@ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -12433,24 +12548,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -12471,8 +12586,7 @@ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -12512,14 +12626,14 @@ * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -12535,9 +12649,9 @@ if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -12548,8 +12662,8 @@ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -12557,7 +12671,7 @@ state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -13607,7 +13721,6 @@ // 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. function JisonParserError$2(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -13624,9 +13737,9 @@ this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -13659,10 +13772,10 @@ // helper: reconstruct the productions[] table function bp$2(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -13675,11 +13788,11 @@ // helper: reconstruct the defaultActions[] table function bda$1(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -13689,18 +13802,18 @@ // helper: reconstruct the 'goto' table function bt$2(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -13731,7 +13844,7 @@ // `this` references an array function s$2(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -13748,9 +13861,9 @@ // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u$2(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -13763,7 +13876,7 @@ } - var parser$3 = { + let parser$3 = { // Code Generator Information Report // --------------------------------- // @@ -14013,7 +14126,6 @@ // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -14021,7 +14133,6 @@ // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -14033,8 +14144,8 @@ // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -14047,14 +14158,13 @@ // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -14070,10 +14180,10 @@ // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -14081,10 +14191,10 @@ this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -14239,9 +14349,9 @@ /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -14253,18 +14363,18 @@ case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -14294,9 +14404,9 @@ case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -14309,10 +14419,10 @@ case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14339,9 +14449,9 @@ case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -14350,10 +14460,10 @@ case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14381,9 +14491,9 @@ case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -14392,10 +14502,10 @@ case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -14434,9 +14544,9 @@ case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -14501,9 +14611,9 @@ case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -14518,9 +14628,9 @@ case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -14555,10 +14665,10 @@ case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14575,9 +14685,9 @@ case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -14594,10 +14704,10 @@ case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14614,9 +14724,9 @@ case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -14633,10 +14743,10 @@ case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14653,9 +14763,9 @@ case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -14679,9 +14789,9 @@ case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -14692,9 +14802,9 @@ case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -14714,9 +14824,9 @@ case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -14740,9 +14850,9 @@ case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -14755,10 +14865,10 @@ case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14775,9 +14885,9 @@ case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -14789,9 +14899,9 @@ case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -14831,10 +14941,10 @@ case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14854,9 +14964,9 @@ case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -14906,10 +15016,10 @@ case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -14933,10 +15043,10 @@ case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14956,10 +15066,10 @@ case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -14983,10 +15093,10 @@ case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15007,10 +15117,10 @@ case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -15022,10 +15132,10 @@ case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -15035,10 +15145,10 @@ case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -15048,10 +15158,10 @@ case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -15061,10 +15171,10 @@ case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -15074,10 +15184,10 @@ case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -15087,10 +15197,10 @@ case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -15100,10 +15210,10 @@ case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -15113,9 +15223,9 @@ case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -15124,9 +15234,9 @@ case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -15135,9 +15245,9 @@ case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -15159,9 +15269,9 @@ case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -15172,9 +15282,9 @@ case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -15194,9 +15304,9 @@ case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -15250,9 +15360,9 @@ case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15272,9 +15382,9 @@ case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -15283,9 +15393,9 @@ case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -15297,9 +15407,9 @@ case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -15313,10 +15423,10 @@ case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15336,10 +15446,10 @@ case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15359,10 +15469,10 @@ case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15382,9 +15492,9 @@ case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -15395,9 +15505,9 @@ case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -15416,9 +15526,9 @@ case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -15459,9 +15569,9 @@ case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -15485,9 +15595,9 @@ case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -15513,9 +15623,9 @@ case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -15560,9 +15670,9 @@ case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -15588,9 +15698,9 @@ case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -15599,9 +15709,9 @@ case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -15610,10 +15720,10 @@ case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15627,10 +15737,10 @@ case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15644,10 +15754,10 @@ case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15661,10 +15771,10 @@ case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15683,9 +15793,9 @@ case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -15694,9 +15804,9 @@ case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -15734,10 +15844,10 @@ case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -15761,9 +15871,9 @@ case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -15842,9 +15952,9 @@ case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -15853,9 +15963,9 @@ case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -15864,9 +15974,9 @@ case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -15875,9 +15985,9 @@ case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -15886,9 +15996,9 @@ case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -15897,9 +16007,9 @@ case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -15908,9 +16018,9 @@ case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -15921,10 +16031,10 @@ case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -15941,9 +16051,9 @@ case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -15952,9 +16062,9 @@ case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -15963,9 +16073,9 @@ case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -15974,9 +16084,9 @@ case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -15985,9 +16095,9 @@ case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -16006,18 +16116,18 @@ case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -16026,9 +16136,9 @@ case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -16037,9 +16147,9 @@ case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -16048,9 +16158,9 @@ case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -16059,9 +16169,9 @@ case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -16070,10 +16180,10 @@ case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -16090,9 +16200,9 @@ case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -16109,9 +16219,9 @@ case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -16123,9 +16233,9 @@ case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -16135,9 +16245,9 @@ case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -16172,9 +16282,9 @@ case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -16193,9 +16303,9 @@ case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -16204,9 +16314,9 @@ case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -16215,9 +16325,9 @@ case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -16235,10 +16345,10 @@ case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -16256,10 +16366,10 @@ case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -16280,9 +16390,9 @@ case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -16315,9 +16425,9 @@ case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -16343,9 +16453,9 @@ case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5__default['default'].parse(yyvstack[yysp]); @@ -16354,9 +16464,9 @@ case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue$1(yyvstack[yysp]); @@ -16365,9 +16475,9 @@ case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -16376,9 +16486,9 @@ case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -16399,10 +16509,10 @@ case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -16419,9 +16529,9 @@ case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -16440,9 +16550,9 @@ case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -16466,9 +16576,9 @@ case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -16488,9 +16598,9 @@ case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -16501,9 +16611,9 @@ case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -16559,10 +16669,10 @@ case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$2` @@ -18165,7 +18275,6 @@ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -18182,38 +18291,34 @@ } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -18221,20 +18326,18 @@ pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -18256,7 +18359,6 @@ // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -18264,18 +18366,19 @@ if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -18283,24 +18386,19 @@ // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -18338,18 +18436,15 @@ - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); + let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -18370,7 +18465,7 @@ // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -18388,7 +18483,6 @@ // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -18401,7 +18495,6 @@ // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -18415,11 +18508,10 @@ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -18473,8 +18565,8 @@ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -18482,8 +18574,8 @@ this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -18515,19 +18607,18 @@ // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -18538,7 +18629,7 @@ if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -18551,7 +18642,7 @@ if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -18563,29 +18654,27 @@ // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -18593,7 +18682,7 @@ l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -18613,8 +18702,7 @@ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -18623,10 +18711,10 @@ token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -18634,7 +18722,7 @@ location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -18645,9 +18733,14 @@ // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -18663,8 +18756,7 @@ // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -18733,11 +18825,14 @@ // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -18748,8 +18843,7 @@ }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -18758,21 +18852,20 @@ function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -18782,21 +18875,20 @@ } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -18805,28 +18897,27 @@ return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -18839,8 +18930,7 @@ - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; + const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -18863,8 +18953,7 @@ - - if (symbol === EOF) { + if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -18876,8 +18965,7 @@ - - --stack_probe; // popStack(1): [symbol, action] + --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -18894,8 +18982,7 @@ - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -18909,8 +18996,7 @@ - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } @@ -18924,7 +19010,7 @@ // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -18977,16 +19063,13 @@ - - - - // handle parse error + // handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -19020,9 +19103,7 @@ - - - r = this.parseError(p.errStr, p, this.JisonParserError); + r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -19045,9 +19126,7 @@ - - - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -19074,17 +19153,16 @@ - - } + } // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -19131,8 +19209,8 @@ recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -19144,8 +19222,7 @@ - - } else { + } else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -19163,6 +19240,7 @@ yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -19171,7 +19249,7 @@ - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -19182,7 +19260,7 @@ sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -19242,10 +19320,10 @@ // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -19280,9 +19358,7 @@ - - - // encountered another parse error? If so, break out to main loop + // encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -19295,7 +19371,7 @@ - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -19316,9 +19392,7 @@ - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -19340,12 +19414,12 @@ // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -19354,7 +19428,7 @@ ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -19395,7 +19469,7 @@ } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -19442,7 +19516,7 @@ // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -19460,21 +19534,19 @@ - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -19508,14 +19580,15 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -19525,6 +19598,7 @@ + } continue; // accept: @@ -19576,7 +19650,7 @@ // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -19592,9 +19666,7 @@ - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -19623,7 +19695,7 @@ sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -19640,8 +19712,8 @@ symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -19652,8 +19724,8 @@ // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -19665,21 +19737,19 @@ - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -19710,14 +19780,15 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -19727,6 +19798,7 @@ + } continue; // accept: @@ -19779,8 +19851,7 @@ // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -20041,7 +20112,6 @@ * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -20058,10 +20128,10 @@ }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -20093,7 +20163,7 @@ JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -20135,7 +20205,9 @@ // // --------- END OF REPORT ----------- - EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -20221,7 +20293,7 @@ if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -20229,7 +20301,7 @@ msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -20242,7 +20314,7 @@ } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -20268,10 +20340,13 @@ * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -20294,7 +20369,6 @@ * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -20317,16 +20391,16 @@ * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -20348,7 +20422,6 @@ * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -20356,8 +20429,8 @@ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -20386,7 +20459,7 @@ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -20411,7 +20484,7 @@ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -20423,17 +20496,17 @@ } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -20527,7 +20600,7 @@ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -20548,7 +20621,6 @@ * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -20559,7 +20631,7 @@ this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -20570,15 +20642,15 @@ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -20612,8 +20684,8 @@ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -20646,9 +20718,9 @@ // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -20667,9 +20739,9 @@ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -20679,8 +20751,8 @@ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -20707,20 +20779,19 @@ * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -20760,17 +20831,19 @@ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -20779,7 +20852,7 @@ // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -20794,8 +20867,8 @@ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -20821,24 +20894,26 @@ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -20849,7 +20924,7 @@ // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -20871,8 +20946,8 @@ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -20894,8 +20969,7 @@ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -21039,21 +21113,21 @@ const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -21068,11 +21142,11 @@ len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -21091,13 +21165,13 @@ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -21121,13 +21195,13 @@ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -21142,8 +21216,8 @@ } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -21174,7 +21248,7 @@ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -21206,9 +21280,9 @@ }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -21237,7 +21311,7 @@ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -21255,7 +21329,7 @@ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -21280,7 +21354,6 @@ * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -21290,8 +21363,6 @@ this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -21300,7 +21371,7 @@ this.clear(); } - 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. @@ -21312,13 +21383,13 @@ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -21328,68 +21399,74 @@ } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -21414,7 +21491,7 @@ * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -21462,24 +21539,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -21499,7 +21576,7 @@ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -21509,24 +21586,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -21547,8 +21624,7 @@ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -21588,14 +21664,14 @@ * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -21611,9 +21687,9 @@ if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -21624,8 +21700,8 @@ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -21633,7 +21709,7 @@ state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -23307,7 +23383,7 @@ }; - var version = '0.6.2-220'; // require('./package.json').version; + const version = '0.6.2-220'; // require('./package.json').version; function parse(grammar) { return bnf.parser.parse(grammar); @@ -23373,7 +23449,7 @@ if (decl.options) { if (!grammar.options) grammar.options = {}; // last occurrence of `%options` wins: - for (var i = 0; i < decl.options.length; i++) { + for (let i = 0; i < decl.options.length; i++) { grammar.options[decl.options[i][0]] = decl.options[i][1]; } } @@ -23413,9 +23489,9 @@ // which matches the original input file: position = position || {}; position.range = position.range || []; - var l = position.first_line | 0; - var c = position.range[0] | 0; - var prelude = ''; + let l = position.first_line | 0; + let c = position.range[0] | 0; + let prelude = ''; if (l > 1) { prelude += (new Array(l)).join('\n'); c -= prelude.length; @@ -23440,7 +23516,7 @@ ebnf_parser, bnf_lexer: jisonlex, - version, + version }; return ebnfParser; diff --git a/packages/ebnf-parser/parser.js b/packages/ebnf-parser/parser.js index dfb328a50..7ed930108 100644 --- a/packages/ebnf-parser/parser.js +++ b/packages/ebnf-parser/parser.js @@ -1,5 +1,5 @@ -/* parser generated by jison 0.6.2-220 */ +/* parser generated by jison 0.7.0-220 */ /* * Returns a Parser object of the following structure: @@ -162,9 +162,9 @@ * Produces a new errorInfo 'hash object' which can be passed into `parseError()`. * See it's use in this parser kernel in many places; example usage: * - * var infoObj = parser.constructParseErrorInfo('fail!', null, + * let infoObj = parser.constructParseErrorInfo('fail!', null, * parser.collect_expected_token_set(state), true); - * var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); + * let retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); * * originalParseError: function(str, hash, ExceptionClass), * The basic `parseError` handler provided by JISON. @@ -366,212 +366,7 @@ * flex: boolean * optional: `true` ==> flex-like lexing behaviour where the rules are tested * exhaustively to find the longest match. - * backtrack_lexer: boolean (⅏ 센 ⅊ ⁖ ⁘ ⁙ ⁚ ⁛ ⁜ ⁝ ⁞ † ‡ - a⯈b - ∀ ∁ ∂ ∃ ∄ ∅ ∆ ∇ ∈ ∉ ∊ ∋ ∌ ∍ ∎ ∏ -U+221x ∐ ∑ − ∓ ∔ ∕ ∖ ∗ ∘ ∙ √ ∛ ∜ ∝ ∞ ∟ -U+222x ∠ ∡ ∢ ∣ ∤ ∥ ∦ ∧ ∨ ∩ ∪ ∫ ∬ ∭ ∮ ∯ -U+223x ∰ ∱ ∲ ∳ ∴ ∵ ∶ ∷ ∸ ∹ ∺ ∻ ∼ ∽ ∾ ∿ -U+224x ≀ ≁ ≂ ≃ ≄ ≅ ≆ ≇ ≈ ≉ ≊ ≋ ≌ ≍ ≎ ≏ -U+225x ≐ ≑ ≒ ≓ ≔ ≕ ≖ ≗ ≘ ≙ ≚ ≛ ≜ ≝ ≞ ≟ -U+226x ≠ ≡ ≢ ≣ ≤ ≥ ≦ ≧ ≨ ≩ ≪ ≫ ≬ ≭ ≮ ≯ -U+227x ≰ ≱ ≲ ≳ ≴ ≵ ≶ ≷ ≸ ≹ ≺ ≻ ≼ ≽ ≾ ≿ -U+228x ⊀ ⊁ ⊂ ⊃ ⊄ ⊅ ⊆ ⊇ ⊈ ⊉ ⊊ ⊋ ⊌ ⊍ ⊎ ⊏ -U+229x ⊐ ⊑ ⊒ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊜ ⊝ ⊞ ⊟ -U+22Ax ⊠ ⊡ ⊢ ⊣ ⊤ ⊥ ⊦ ⊧ ⊨ ⊩ ⊪ ⊫ ⊬ ⊭ ⊮ ⊯ -U+22Bx ⊰ ⊱ ⊲ ⊳ ⊴ ⊵ ⊶ ⊷ ⊸ ⊹ ⊺ ⊻ ⊼ ⊽ ⊾ ⊿ -U+22Cx ⋀ ⋁ ⋂ ⋃ ⋄ ⋅ ⋆ ⋇ ⋈ ⋉ ⋊ ⋋ ⋌ ⋍ ⋎ ⋏ -U+22Dx ⋐ ⋑ ⋒ ⋓ ⋔ ⋕ ⋖ ⋗ ⋘ ⋙ ⋚ ⋛ ⋜ ⋝ ⋞ ⋟ -U+22Ex ⋠ ⋡ ⋢ ⋣ ⋤ ⋥ ⋦ ⋧ ⋨ ⋩ ⋪ ⋫ ⋬ ⋭ ⋮ ⋯ -U+22Fx ⋰ ⋱ ⋲ ⋳ ⋴ ⋵ ⋶ ⋷ ⋸ ⋹ ⋺ ⋻ ⋼ ⋽ ⋾ ⋿) -U+230x ⌀ ⌁ ⌂ ⌃ ⌄ ⌅ ⌆ ⌇ ⌈ ⌉ ⌊ ⌋ ⌌ ⌍ ⌎ ⌏ -U+231x ⌐ ⌑ ⌒ ⌓ ⌔ ⌕ ⌖ ⌗ ⌘ ⌙ ⌚ ⌛ ⌜ ⌝ ⌞ ⌟ -U+232x ⌠ ⌡ ⌢ ⌣ ⌤ ⌥ ⌦ ⌧ ⌨ 〈 〉 ⌫ ⌬ ⌭ ⌮ ⌯ -U+233x ⌰ ⌱ ⌲ ⌳ ⌴ ⌵ ⌶ ⌷ ⌸ ⌹ ⌺ ⌻ ⌼ ⌽ ⌾ ⌿ -U+234x ⍀ ⍁ ⍂ ⍃ ⍄ ⍅ ⍆ ⍇ ⍈ ⍉ ⍊ ⍋ ⍌ ⍍ ⍎ ⍏ -U+235x ⍐ ⍑ ⍒ ⍓ ⍔ ⍕ ⍖ ⍗ ⍘ ⍙ ⍚ ⍛ ⍜ ⍝ ⍞ ⍟ -U+236x ⍠ ⍡ ⍢ ⍣ ⍤ ⍥ ⍦ ⍧ ⍨ ⍩ ⍪ ⍫ ⍬ ⍭ ⍮ ⍯ -U+237x ⍰ ⍱ ⍲ ⍳ ⍴ ⍵ ⍶ ⍷ ⍸ ⍹ ⍺ ⍻ ⍼ ⍽ ⍾ ⍿ -U+238x ⎀ ⎁ ⎂ ⎃ ⎄ ⎅ ⎆ ⎇ ⎈ ⎉ ⎊ ⎋ ⎌ ⎍ ⎎ ⎏ -U+239x ⎐ ⎑ ⎒ ⎓ ⎔ ⎕ ⎖ ⎗ ⎘ ⎙ ⎚ ⎛ ⎜ ⎝ ⎞ ⎟ -U+23Ax ⎠ ⎡ ⎢ ⎣ ⎤ ⎥ ⎦ ⎧ ⎨ ⎩ ⎪ ⎫ ⎬ ⎭ ⎮ ⎯ -U+23Bx ⎰ ⎱ ⎲ ⎳ ⎴ ⎵ ⎶ ⎷ ⎸ ⎹ ⎺ ⎻ ⎼ ⎽ ⎾ ⎿ -U+23Cx ⏀ ⏁ ⏂ ⏃ ⏄ ⏅ ⏆ ⏇ ⏈ ⏉ ⏊ ⏋ ⏌ ⏍ ⏎ ⏏ -U+23Dx ⏐ ⏑ ⏒ ⏓ ⏔ ⏕ ⏖ ⏗ ⏘ ⏙ ⏚ ⏛ ⏜ ⏝ ⏞ ⏟ -U+23Ex ⏠ ⏡ ⏢ ⏣ ⏤ ⏥ ⏦ ⏧ ⏨ ⏩ ⏪ ⏫ ⏬ ⏭ ⏮ ⏯ -U+23Fx ⏰ ⏱ ⏲ ⏳ ⏴ ⏵ ⏶ ⏷ ⏸ ⏹ ⏺ ⏻ ⏼ ⏽ ⏾ ⏿ - -U+260x ☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☎ ☏ -U+261x ☐ ☑ ☒ ☓ ☔ ☕ ☖ ☗ ☘ ☙ ☚ ☛ ☜ ☝ ☞ ☟ -U+262x ☠ ☡ ☢ ☣ ☤ ☥ ☦ ☧ ☨ ☩ ☪ ☫ ☬ ☭ ☮ ☯ -U+263x ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷ ☸ ☹ ☺ ☻ ☼ ☽ ☾ ☿ -U+264x ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇ ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ -U+265x ♐ ♑ ♒ ♓ ♔ ♕ ♖ ♗ ♘ ♙ ♚ ♛ ♜ ♝ ♞ ♟ -U+266x ♠ ♡ ♢ ♣ ♤ ♥ ♦ ♧ ♨ ♩ ♪ ♫ ♬ ♭ ♮ ♯ -U+267x ♰ ♱ ♲ ♳ ♴ ♵ ♶ ♷ ♸ ♹ ♺ ♻ ♼ ♽ ♾ ♿ -U+268x ⚀ ⚁ ⚂ ⚃ ⚄ ⚅ ⚆ ⚇ ⚈ ⚉ ⚊ ⚋ ⚌ ⚍ ⚎ ⚏ -U+269x ⚐ ⚑ ⚒ ⚓ ⚔ ⚕ ⚖ ⚗ ⚘ ⚙ ⚚ ⚛ ⚜ ⚝ ⚞ ⚟ -U+26Ax ⚠ ⚡ ⚢ ⚣ ⚤ ⚥ ⚦ ⚧ ⚨ ⚩ ⚪ ⚫ ⚬ ⚭ ⚮ ⚯ -U+26Bx ⚰ ⚱ ⚲ ⚳ ⚴ ⚵ ⚶ ⚷ ⚸ ⚹ ⚺ ⚻ ⚼ ⚽ ⚾ ⚿ -U+26Cx ⛀ ⛁ ⛂ ⛃ ⛄ ⛅ ⛆ ⛇ ⛈ ⛉ ⛊ ⛋ ⛌ ⛍ ⛎ ⛏ -U+26Dx ⛐ ⛑ ⛒ ⛓ ⛔ ⛕ ⛖ ⛗ ⛘ ⛙ ⛚ ⛛ ⛜ ⛝ ⛞ ⛟ -U+26Ex ⛠ ⛡ ⛢ ⛣ ⛤ ⛥ ⛦ ⛧ ⛨ ⛩ ⛪ ⛫ ⛬ ⛭ ⛮ ⛯ -U+26Fx ⛰ ⛱ ⛲ ⛳ ⛴ ⛵ ⛶ ⛷ ⛸ ⛹ ⛺ ⛻ ⛼ ⛽ ⛾ ⛿ - - ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ☛ ☞ ✌ ✍ ✎ ✏ -✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -✠ ✡ ✢ ✣ ✤ ✥ ✦ ✧ ★ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ● ❍ ■ ❏ -☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ❐ ❑ ❒ ▲ ▼ ◆ ❖ -◗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ - -U+270x ✀ ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ✊ ✋ ✌ ✍ ✎ ✏ -U+271x ✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -U+272x ✠ ✡ ✢ ✣ a✤b a✥b a✦b a✧b ✨ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -U+273x ✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -U+274x ❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ❌ ❍ ❎ ❏ -U+275x ❐ ❑ ❒ ❓ ❔ ❕ ❖ ❗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ ❟ -U+276x ❠ ❡ ❢ ❣ ❤ ❥ ❦ ❧ ❨ ❩ ❪ ❫ ❬ ❭ ❮ a❯b -U+277x ❰ ❱ ❲ ❳ ❴ ❵ ❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ ❾ ❿ -U+278x ➀ ➁ ➂ ➃ ➄ ➅ ➆ ➇ ➈ ➉ ➊ ➋ ➌ ➍ ➎ ➏ -U+279x ➐ ➑ ➒ ➓ ➔ ➕ ➖ ➗ ➘ ➙ ➚ ➛ ➜ ➝ ➞ ➟ -U+27Ax ➠ ➡ ➢ ➣ ➤ ➥ ➦ ➧ a➨b ➩ ➪ ➫ ➬ ➭ ➮ ➯ -U+27Bx ➰ a➱b ➲ ➳ ➴ ➵ ➶ ➷ ➸ ➹ ➺ ➻ ➼ ➽ ➾ ➿ - -U+2580 ▀ Upper half block -U+2581 ▁ Lower one eighth block -U+2582 ▂ Lower one quarter block -U+2583 ▃ Lower three eighths block -U+2584 ▄ Lower half block -U+2585 ▅ Lower five eighths block -U+2586 ▆ Lower three quarters block -U+2587 ▇ Lower seven eighths block -U+2588 █ Full block -U+2589 ▉ Left seven eighths block -U+258A ▊ Left three quarters block -U+258B ▋ Left five eighths block -U+258C ▌ Left half block -U+258D ▍ Left three eighths block -U+258E ▎ Left one quarter block -U+258F ▏ Left one eighth block -U+2590 ▐ Right half block -U+2591 ░ Light shade -U+2592 ▒ Medium shade -U+2593 ▓ Dark shade -U+2594 ▔ Upper one eighth block -U+2595 ▕ Right one eighth block -U+2596 ▖ Quadrant lower left -U+2597 ▗ Quadrant lower right -U+2598 ▘ Quadrant upper left -U+2599 ▙ Quadrant upper left and lower left and lower right -U+259A ▚ Quadrant upper left and lower right -U+259B ▛ Quadrant upper left and upper right and lower left -U+259C ▜ Quadrant upper left and upper right and lower right -U+259D ▝ Quadrant upper right -U+259E ▞ Quadrant upper right and lower left -U+259F ▟ Quadrant upper right and lower left and lower right -Geometric Shapes -Main articles: Geometric Shapes (Unicode block) and Geometric Shapes Extended (Unicode block) -[hide]Code Glyph Description -U+25A0 ■ Black square -U+25A1 □ White square -U+25A2 ▢ White square with rounded corners -U+25A3 ▣ White square containing small black square -U+25A4 ▤ Square with horizontal fill -U+25A5 ▥ Square with vertical fill -U+25A6 ▦ Square with orthogonal crosshatch fill -U+25A7 ▧ Square with upper left to lower right fill -U+25A8 ▨ Square with upper right to lower left fill -U+25A9 ▩ Square with diagonal crosshatch fill -U+25AA ▪ Black small square -U+25AB ▫ White small square -U+25AC ▬ Black rectangle -U+25AD ▭ White rectangle -U+25AE ▮ Black vertical rectangle -U+25AF ▯ White vertical rectangle -U+25B0 ▰ Black parallelogram -U+25B1 ▱ White parallelogram -U+25B2 ▲ Black up-pointing triangle -U+25B3 △ White up-pointing triangle -U+25B4 ▴ Black up-pointing small triangle -U+25B5 ▵ White up-pointing small triangle -U+25B6 ▶ Black right-pointing triangle -U+25B7 ▷ White right-pointing triangle -U+25B8 ▸ Black right-pointing small triangle -U+25B9 ▹ White right-pointing small triangle -U+25BA ► Black right-pointing pointer -U+25BB ▻ White right-pointing pointer -U+25BC ▼ Black down-pointing triangle -U+25BD ▽ White down-pointing triangle -U+25BE ▾ Black down-pointing small triangle -U+25BF ▿ White down-pointing small triangle -U+25C0 ◀ Black left-pointing triangle -U+25C1 ◁ White left-pointing triangle -U+25C2 ◂ Black left-pointing small triangle -U+25C3 ◃ White left-pointing small triangle -U+25C4 ◄ Black left-pointing pointer -U+25C5 ◅ White left-pointing pointer -U+25C6 ◆ Black diamond -U+25C7 ◇ White diamond -U+25C8 ◈ White diamond containing small black diamond -U+25C9 ◉ Fisheye -U+25CA ◊ Lozenge -U+25CB ○ White circle -U+25CC ◌ Dotted circle -U+25CD ◍ Circle with vertical fill -U+25CE ◎ Bullseye -U+25CF ● Black circle -U+25D0 ◐ Circle with left half black -U+25D1 ◑ Circle with right half black -U+25D2 ◒ Circle with lower half black -U+25D3 ◓ Circle with upper half black -U+25D4 ◔ Circle with upper right quadrant black -U+25D5 ◕ Circle with all but upper left quadrant black -U+25D6 ◖ Left half circle black -U+25D7 ◗ Right half black circle -U+25D8 ◘ Inverse bullet -U+25D9 ◙ Inverse white circle -U+25DA ◚ Upper half inverse white circle -U+25DB ◛ Lower half inverse white circle -U+25DC ◜ Upper left quadrant circular arc -U+25DD ◝ Upper right quadrant circular arc -U+25DE ◞ Lower right quadrant circular arc -U+25DF ◟ Lower left quadrant circular arc -U+25E0 ◠ Upper half circle -U+25E1 ◡ Lower half circle -U+25E2 ◢ Black lower right triangle -U+25E3 ◣ Black lower left triangle -U+25E4 ◤ Black upper left triangle -U+25E5 ◥ Black upper right triangle -U+25E6 ◦ White bullet -U+25E7 ◧ Square with left half black -U+25E8 ◨ Square with right half black -U+25E9 ◩ Square with upper left diagonal half black -U+25EA ◪ Square with lower right diagonal half black -U+25EB ◫ White square with vertical bisecting line -U+25EC ◬ White up-pointing triangle with dot -U+25ED ◭ Up-pointing triangle with left half black -U+25EE ◮ Up-pointing triangle with right half black -U+25EF ◯ Large circle -U+25F0 ◰ White square with upper left quadrant -U+25F1 ◱ White square with lower left quadrant -U+25F2 ◲ White square with lower right quadrant -U+25F3 ◳ White square with upper right quadrant -U+25F4 ◴ White circle with upper left quadrant -U+25F5 ◵ White circle with lower left quadrant -U+25F6 ◶ White circle with lower right quadrant -U+25F7 ◷ White circle with upper right quadrant -U+25F8 ◸ Upper left triangle -U+25F9 ◹ Upper right triangle -U+25FA ◺ Lower-left triangle -U+25FB ◻ White medium square -U+25FC ◼ Black medium square -U+25FD ◽ White medium small square -U+25FE ◾ Black medium small square -U+25FF ◿ Lower right triangle - - + * backtrack_lexer: boolean * optional: `true` ==> lexer regexes are tested in order and for invoked; * the lexer terminates the scan when a token is returned by the action code. * xregexp: boolean @@ -593,8 +388,6 @@ import XRegExp from '@gerhobbelt/xregexp'; // for helping out the `%optio // 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. function JisonParserError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -611,9 +404,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -646,10 +439,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -662,11 +455,11 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -676,18 +469,18 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -718,7 +511,7 @@ JisonParserError.prototype.name = 'JisonParserError'; // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -735,9 +528,9 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -750,7 +543,7 @@ JisonParserError.prototype.name = 'JisonParserError'; } -var parser = { +let parser = { // Code Generator Information Report // --------------------------------- // @@ -986,8 +779,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - "use strict"; - return '"' + id_str + '"'; }, @@ -995,8 +786,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - "use strict"; - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -1008,8 +797,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -1022,15 +811,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - "use strict"; - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -1046,11 +833,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { - "use strict"; + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -1058,10 +844,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -1242,9 +1028,9 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -1256,18 +1042,18 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy case 0: /*! Production:: $accept : spec $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-) break; case 1: /*! Production:: spec : declaration_list "%%" grammar optional_end_block EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4]; @@ -1280,10 +1066,10 @@ case 1: case 2: /*! Production:: spec : declaration_list "%%" grammar error EOF */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -1302,10 +1088,10 @@ case 2: case 3: /*! Production:: spec : declaration_list error EOF */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -1327,9 +1113,9 @@ case 118: case 133: /*! Production:: optional_module_code_chunk : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -1338,9 +1124,9 @@ case 133: case 5: /*! Production:: optional_end_block : "%%" extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]); @@ -1360,9 +1146,9 @@ case 6: case 10: /*! Production:: declaration_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; @@ -1373,9 +1159,9 @@ case 7: case 8: /*! Production:: optional_action_header_block : optional_action_header_block include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -1394,9 +1180,9 @@ case 8: case 9: /*! Production:: declaration_list : declaration_list declaration */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -1405,10 +1191,10 @@ case 9: case 11: /*! Production:: declaration_list : declaration_list error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -1423,9 +1209,9 @@ case 11: case 12: /*! Production:: declaration : START id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {start: yyvstack[yysp]}; @@ -1434,9 +1220,9 @@ case 12: case 13: /*! Production:: declaration : LEX_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {lex: {text: yyvstack[yysp], position: yylstack[yysp]}}; @@ -1445,9 +1231,9 @@ case 13: case 14: /*! Production:: declaration : operator */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {operator: yyvstack[yysp]}; @@ -1456,9 +1242,9 @@ case 14: case 15: /*! Production:: declaration : TOKEN full_token_definitions */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = {token_list: yyvstack[yysp]}; @@ -1467,9 +1253,9 @@ case 15: case 16: /*! Production:: declaration : ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]); @@ -1487,9 +1273,9 @@ case 16: case 17: /*! Production:: declaration : include_macro_code */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]); @@ -1507,9 +1293,9 @@ case 17: case 18: /*! Production:: declaration : parse_params */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parseParams: yyvstack[yysp]}; @@ -1518,9 +1304,9 @@ case 18: case 19: /*! Production:: declaration : parser_type */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {parserType: yyvstack[yysp]}; @@ -1529,9 +1315,9 @@ case 19: case 20: /*! Production:: declaration : options */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: yyvstack[yysp]}; @@ -1540,9 +1326,9 @@ case 20: case 21: /*! Production:: declaration : DEBUG */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {options: [['debug', true]]}; @@ -1551,9 +1337,9 @@ case 21: case 22: /*! Production:: declaration : EBNF */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) ebnf = true; @@ -1563,9 +1349,9 @@ case 22: case 23: /*! Production:: declaration : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {unknownDecl: yyvstack[yysp]}; @@ -1574,9 +1360,9 @@ case 23: case 24: /*! Production:: declaration : IMPORT import_name import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = {imports: {name: yyvstack[yysp - 1], path: yyvstack[yysp]}}; @@ -1585,10 +1371,10 @@ case 24: case 25: /*! Production:: declaration : IMPORT import_name error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -1604,10 +1390,10 @@ case 25: case 26: /*! Production:: declaration : IMPORT error import_path */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -1623,9 +1409,9 @@ case 26: case 27: /*! Production:: declaration : INIT_CODE init_code_name action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var rv = checkActionBlock(yyvstack[yysp], yylstack[yysp]); @@ -1648,10 +1434,10 @@ case 27: case 28: /*! Production:: declaration : INIT_CODE error action_ne */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -1667,10 +1453,10 @@ case 28: case 29: /*! Production:: declaration : START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -1685,10 +1471,10 @@ case 29: case 30: /*! Production:: declaration : TOKEN error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -1703,10 +1489,10 @@ case 30: case 31: /*! Production:: declaration : IMPORT error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -1771,9 +1557,9 @@ case 129: case 132: /*! Production:: optional_module_code_chunk : module_code_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -1784,9 +1570,9 @@ case 39: case 111: /*! Production:: action_ne : "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -1795,10 +1581,10 @@ case 111: case 40: /*! Production:: options : OPTIONS error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -1813,10 +1599,10 @@ case 40: case 41: /*! Production:: options : OPTIONS error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -1835,9 +1621,9 @@ case 59: case 70: /*! Production:: id_list : id_list id */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -1852,9 +1638,9 @@ case 71: case 84: /*! Production:: handle_list : handle_action */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -1863,9 +1649,9 @@ case 84: case 44: /*! Production:: option : NAME */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -1874,9 +1660,9 @@ case 44: case 45: /*! Production:: option : NAME "=" OPTION_STRING_VALUE */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -1887,9 +1673,9 @@ case 46: case 47: /*! Production:: option : NAME "=" NAME */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], parseValue(yyvstack[yysp])]; @@ -1898,10 +1684,10 @@ case 47: case 48: /*! Production:: option : NAME "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -1916,10 +1702,10 @@ case 48: case 49: /*! Production:: option : NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -1936,9 +1722,9 @@ case 50: case 52: /*! Production:: parser_type : PARSER_TYPE symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -1947,10 +1733,10 @@ case 52: case 51: /*! Production:: parse_params : PARSE_PARAM error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -1968,10 +1754,10 @@ case 51: case 53: /*! Production:: parser_type : PARSER_TYPE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -1989,9 +1775,9 @@ case 53: case 54: /*! Production:: operator : associativity token_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1]]; this.$.push.apply(this.$, yyvstack[yysp]); @@ -2000,10 +1786,10 @@ case 54: case 55: /*! Production:: operator : associativity error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -2021,9 +1807,9 @@ case 55: case 56: /*! Production:: associativity : LEFT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'left'; @@ -2032,9 +1818,9 @@ case 56: case 57: /*! Production:: associativity : RIGHT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'right'; @@ -2043,9 +1829,9 @@ case 57: case 58: /*! Production:: associativity : NONASSOC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = 'nonassoc'; @@ -2054,9 +1840,9 @@ case 58: case 61: /*! Production:: full_token_definitions : optional_token_type id_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var rv = []; @@ -2075,9 +1861,9 @@ case 61: case 62: /*! Production:: full_token_definitions : optional_token_type one_full_token */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var m = yyvstack[yysp]; @@ -2090,9 +1876,9 @@ case 62: case 63: /*! Production:: one_full_token : id token_value token_description */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2105,9 +1891,9 @@ case 63: case 64: /*! Production:: one_full_token : id token_description */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2119,9 +1905,9 @@ case 64: case 65: /*! Production:: one_full_token : id token_value */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2133,9 +1919,9 @@ case 65: case 66: /*! Production:: optional_token_type : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = false; @@ -2144,9 +1930,9 @@ case 66: case 72: /*! Production:: grammar : optional_action_header_block production_list */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2156,9 +1942,9 @@ case 72: case 73: /*! Production:: production_list : production_list production */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2172,9 +1958,9 @@ case 73: case 74: /*! Production:: production_list : production */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = {}; this.$[yyvstack[yysp][0]] = yyvstack[yysp][1]; @@ -2183,9 +1969,9 @@ case 74: case 75: /*! Production:: production : production_id handle_list ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp - 1]]; @@ -2194,10 +1980,10 @@ case 75: case 76: /*! Production:: production : production_id error ";" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -2215,10 +2001,10 @@ case 76: case 77: /*! Production:: production : production_id error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -2236,9 +2022,9 @@ case 77: case 78: /*! Production:: production_id : id optional_production_description ":" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -2249,10 +2035,10 @@ case 78: case 79: /*! Production:: production_id : id optional_production_description error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -2270,10 +2056,10 @@ case 79: case 80: /*! Production:: production_id : id optional_production_description ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -2297,18 +2083,18 @@ case 80: case 82: /*! Production:: optional_production_description : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) break; case 83: /*! Production:: handle_list : handle_list "|" handle_action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -2318,10 +2104,10 @@ case 83: case 85: /*! Production:: handle_list : handle_list "|" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -2339,10 +2125,10 @@ case 85: case 86: /*! Production:: handle_list : handle_list ":" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -2357,9 +2143,9 @@ case 86: case 87: /*! Production:: handle_action : handle prec action */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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(' ') : '')]; @@ -2394,9 +2180,9 @@ case 87: case 88: /*! Production:: handle_action : EPSILON action */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = ['']; @@ -2420,10 +2206,10 @@ case 88: case 89: /*! Production:: handle_action : EPSILON error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -2438,9 +2224,9 @@ case 89: case 90: /*! Production:: handle : handle suffixed_expression */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2450,9 +2236,9 @@ case 90: case 91: /*! Production:: handle : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -2461,9 +2247,9 @@ case 91: case 92: /*! Production:: handle_sublist : handle_sublist "|" handle */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2]; @@ -2473,9 +2259,9 @@ case 92: case 93: /*! Production:: handle_sublist : handle */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp].join(' ')]; @@ -2484,9 +2270,9 @@ case 93: case 94: /*! Production:: suffixed_expression : expression suffix ALIAS */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + "[" + yyvstack[yysp] + "]"; @@ -2499,9 +2285,9 @@ case 124: case 130: /*! Production:: module_code_chunk : module_code_chunk CODE */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -2510,9 +2296,9 @@ case 130: case 97: /*! Production:: expression : EOF_ID */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$end'; @@ -2521,9 +2307,9 @@ case 97: case 98: /*! Production:: expression : STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // Re-encode the string *anyway* as it will @@ -2536,9 +2322,9 @@ case 98: case 99: /*! Production:: expression : "(" handle_sublist ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1].join(' | ') + ')'; @@ -2547,10 +2333,10 @@ case 99: case 100: /*! Production:: expression : "(" handle_sublist error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -2564,9 +2350,9 @@ case 100: case 105: /*! Production:: prec : PREC symbol */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { prec: yyvstack[yysp] }; @@ -2575,10 +2361,10 @@ case 105: case 106: /*! Production:: prec : PREC error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -2596,9 +2382,9 @@ case 106: case 107: /*! Production:: prec : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = null; @@ -2607,10 +2393,10 @@ case 107: case 112: /*! Production:: action_ne : "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -2624,9 +2410,9 @@ case 112: case 116: /*! Production:: action : ARROW_ACTION */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$$ = (' + yyvstack[yysp] + ');'; @@ -2635,9 +2421,9 @@ case 116: case 120: /*! Production:: action_body : action_body "{" action_body "}" action_comments_body */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-): this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 4] + yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -2646,9 +2432,9 @@ case 120: case 121: /*! Production:: action_body : action_body "{" action_body "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 3] + yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -2657,10 +2443,10 @@ case 121: case 122: /*! Production:: action_body : action_body "{" action_body error */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -2674,9 +2460,9 @@ case 122: case 126: /*! Production:: extra_parser_module_code : optional_module_code_chunk include_macro_code extra_parser_module_code */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -2685,9 +2471,9 @@ case 126: case 127: /*! Production:: include_macro_code : INCLUDE PATH */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' }); @@ -2707,10 +2493,10 @@ case 127: case 128: /*! Production:: include_macro_code : INCLUDE error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -2723,10 +2509,10 @@ case 128: case 131: /*! Production:: module_code_chunk : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -4127,8 +3913,6 @@ defaultActions: bda({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - "use strict"; - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -4145,39 +3929,37 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - "use strict"; - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + let yytext; + let yylineno; + let yyleng; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 165 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -4185,21 +3967,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - "use strict"; - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -4221,8 +4000,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - "use strict"; - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -4230,18 +4007,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -4249,26 +4027,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - "use strict"; - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - "use strict"; - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -4298,8 +4069,6 @@ parse: function parse(input) { // them up. Hence we MUST set them up at the start of every `parse()` run! if (this.yyError) { this.yyError = function yyError(str /*, ...args */) { - "use strict"; - @@ -4308,17 +4077,15 @@ parse: function parse(input) { - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -4339,7 +4106,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -4357,8 +4124,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -4371,8 +4136,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - "use strict"; - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -4386,12 +4149,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - "use strict"; - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -4445,8 +4206,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -4454,8 +4215,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -4487,20 +4248,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - "use strict"; - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -4511,7 +4270,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -4524,7 +4283,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -4536,29 +4295,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -4566,7 +4323,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -4586,9 +4343,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - "use strict"; - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -4597,10 +4352,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -4608,7 +4363,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -4625,10 +4380,8 @@ parse: function parse(input) { // info.value = null; // info.value_stack = null; // ... - "use strict"; - - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -4644,9 +4397,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - "use strict"; - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -4715,11 +4466,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -4730,9 +4484,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - "use strict"; - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -4741,22 +4493,20 @@ parse: function parse(input) { function stdLex() { - "use strict"; - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -4766,22 +4516,20 @@ parse: function parse(input) { } function fastLex() { - "use strict"; - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -4790,29 +4538,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - "use strict"; - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -4825,8 +4571,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -4849,8 +4594,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -4862,8 +4606,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -4880,8 +4623,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -4895,8 +4637,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -4910,7 +4651,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -4963,16 +4704,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -5006,9 +4744,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -5031,9 +4767,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -5060,17 +4794,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -5117,8 +4850,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -5130,8 +4863,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -5149,6 +4881,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -5157,7 +4890,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -5168,7 +4901,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -5228,10 +4961,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -5266,9 +4999,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -5281,7 +5012,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -5302,9 +5033,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -5326,12 +5055,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -5340,7 +5069,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -5381,7 +5110,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -5428,7 +5157,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -5446,21 +5175,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -5494,14 +5221,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -5511,6 +5239,7 @@ parse: function parse(input) { + } continue; // accept: @@ -5562,7 +5291,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -5578,9 +5307,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -5609,7 +5336,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -5626,8 +5353,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -5638,8 +5365,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -5651,21 +5378,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -5696,14 +5421,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -5713,6 +5439,7 @@ parse: function parse(input) { + } continue; // accept: @@ -5765,8 +5492,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -6028,8 +5754,6 @@ var lexer = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - 'use strict'; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -6046,10 +5770,10 @@ var lexer = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -6081,7 +5805,7 @@ var lexer = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -6123,7 +5847,9 @@ var lexer = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -6199,7 +5925,6 @@ EOF: 1, * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - 'use strict'; msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -6210,7 +5935,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -6218,7 +5943,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -6231,7 +5956,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -6261,11 +5986,9 @@ EOF: 1, // info.yy = null; // info.lexer = null; // ... - 'use strict'; - - var rec = !!this.recoverable; + const rec = !!this.recoverable; - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -6288,8 +6011,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - 'use strict'; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -6312,17 +6033,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - 'use strict'; - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -6344,8 +6064,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - 'use strict'; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -6353,8 +6071,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -6374,7 +6092,6 @@ EOF: 1, * @this {RegExpLexer} */ clear: function lexer_clear() { - 'use strict'; this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -6384,7 +6101,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -6402,7 +6119,6 @@ EOF: 1, * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - 'use strict'; this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -6410,7 +6126,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -6422,17 +6138,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -6526,8 +6242,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - 'use strict'; - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -6548,8 +6263,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - 'use strict'; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -6560,7 +6273,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -6571,15 +6284,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -6613,9 +6326,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - 'use strict'; - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -6648,9 +6360,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -6669,9 +6381,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -6681,13 +6393,12 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - 'use strict'; return this._input || ''; }, @@ -6698,7 +6409,6 @@ EOF: 1, * @this {RegExpLexer} */ more: function lexer_more() { - 'use strict'; this._more = true; return this; }, @@ -6711,21 +6421,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - 'use strict'; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -6743,7 +6451,6 @@ EOF: 1, * @this {RegExpLexer} */ less: function lexer_less(n) { - 'use strict'; return this.unput(this.match.slice(n)); }, @@ -6766,18 +6473,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - 'use strict'; - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -6786,7 +6494,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -6801,8 +6509,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -6828,25 +6536,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - 'use strict'; - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -6857,7 +6566,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -6879,9 +6588,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - 'use strict'; - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -6903,9 +6611,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - 'use strict'; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -7045,27 +6751,25 @@ EOF: 1, * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - 'use strict'; loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - 'use strict'; - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -7080,11 +6784,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -7103,13 +6807,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -7133,14 +6837,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - 'use strict'; - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -7155,8 +6858,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -7187,8 +6890,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - 'use strict'; - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -7220,9 +6922,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -7251,7 +6953,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -7269,7 +6971,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -7294,8 +6996,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - 'use strict'; - if (this.done) { this.clear(); return this.EOF; @@ -7305,8 +7005,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -7315,7 +7013,7 @@ EOF: 1, this.clear(); } - 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. @@ -7327,13 +7025,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -7343,68 +7041,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -7429,8 +7133,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - 'use strict'; - var r; + let r; //this._clear_state = 0; @@ -7478,24 +7181,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -7515,8 +7218,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - 'use strict'; - var r; + let r; //this._clear_state = 0; @@ -7526,24 +7228,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -7564,9 +7266,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - 'use strict'; - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -7582,7 +7282,6 @@ EOF: 1, * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - 'use strict'; return this.pushState(condition); }, @@ -7594,7 +7293,6 @@ EOF: 1, * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - 'use strict'; this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -7608,15 +7306,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - 'use strict'; - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -7628,14 +7325,13 @@ EOF: 1, * @this {RegExpLexer} */ topState: function lexer_topState(n) { - 'use strict'; n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -7646,9 +7342,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - 'use strict'; - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -7656,7 +7351,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -7666,7 +7361,6 @@ EOF: 1, * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - 'use strict'; return this.conditionStack.length; }, 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 6b222a4b1..bdaac6f32 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,12 +29,12 @@ multiple alternative rule productions should be separated by a '|' pipe characte ^...........^^^^ 7: - at Object.parseError (/ebnf-parser-cjs.js:9109:15) - at Object.yyError (/ebnf-parser-cjs.js:9306:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:7323:14) - at Object.parse (/ebnf-parser-cjs.js:10393:52) - at Object.parse (/ebnf-parser-cjs.js:23317:23) - at Context.testEachParserExample (/ebnf_parse.js:329:19) + 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 Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 474d330f7..7c3a5299d 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,10 +11,10 @@ bogus: foo bar; name: 'JisonParserError', message: '$id is not defined', stack: `ReferenceError: $id is not defined - at Object.parser__PerformAction (/ebnf-parser-cjs.js:7255:32) - at Object.parse (/ebnf-parser-cjs.js:10598:40) - at Object.parse (/ebnf-parser-cjs.js:23317:23) - at Context.testEachParserExample (/ebnf_parse.js:329:19) + 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 Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 6c236f1fd..1e411d369 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,12 +33,12 @@ multiple alternative rule productions should be separated by a '|' pipe characte 5: 6: bogus: foo bar; - at Object.parseError (/ebnf-parser-cjs.js:9109:15) - at Object.yyError (/ebnf-parser-cjs.js:9306:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:7323:14) - at Object.parse (/ebnf-parser-cjs.js:10393:52) - at Object.parse (/ebnf-parser-cjs.js:23317:23) - at Context.testEachParserExample (/ebnf_parse.js:329:19) + 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 Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 00ac936eb..91511f85f 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,12 +23,12 @@ Maybe you did not correctly separate the parse 'header section' (token definitio 3: ^..^ - at Object.parseError (/ebnf-parser-cjs.js:9109:15) - at Object.yyError (/ebnf-parser-cjs.js:9306:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:6285:14) - at Object.parse (/ebnf-parser-cjs.js:10393:52) - at Object.parse (/ebnf-parser-cjs.js:23317:23) - at Context.testEachParserExample (/ebnf_parse.js:329:19) + 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:6434:14) + at Object.parse (/ebnf-parser-cjs.js:10504:24) + at Object.parse (/ebnf-parser-cjs.js:23394:23) + at Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 83f22bad4..91b71e753 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,12 +26,12 @@ declaration list error? 4: %% ^..^^ - at Object.parseError (/ebnf-parser-cjs.js:9109:15) - at Object.yyError (/ebnf-parser-cjs.js:9306:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:6389:14) - at Object.parse (/ebnf-parser-cjs.js:10393:52) - at Object.parse (/ebnf-parser-cjs.js:23317:23) - at Context.testEachParserExample (/ebnf_parse.js:329:19) + 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 Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 f2e55ceb3..fd58cb861 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,12 +44,12 @@ Parse error on line 12: ^ Expecting ":", "STRING", "ARROW_ACTION", "optional_production_description", got unexpected "%%" - at Object.parseError (/ebnf-parser-cjs.js:9109:15) - at Object.yyError (/ebnf-parser-cjs.js:9306:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:7233:14) - at Object.parse (/ebnf-parser-cjs.js:10393:52) - at Object.parse (/ebnf-parser-cjs.js:23317:23) - at Context.testEachParserExample (/ebnf_parse.js:329:19) + 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 Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 7dc75f9d4..9a1327aa3 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,12 +39,12 @@ declaration list error? 7: 8: foo: bar; - at Object.parseError (/ebnf-parser-cjs.js:9109:15) - at Object.yyError (/ebnf-parser-cjs.js:9306:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:6389:14) - at Object.parse (/ebnf-parser-cjs.js:10393:52) - at Object.parse (/ebnf-parser-cjs.js:23317:23) - at Context.testEachParserExample (/ebnf_parse.js:329:19) + 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 Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 6b222a4b1..bdaac6f32 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,12 +29,12 @@ multiple alternative rule productions should be separated by a '|' pipe characte ^...........^^^^ 7: - at Object.parseError (/ebnf-parser-cjs.js:9109:15) - at Object.yyError (/ebnf-parser-cjs.js:9306:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:7323:14) - at Object.parse (/ebnf-parser-cjs.js:10393:52) - at Object.parse (/ebnf-parser-cjs.js:23317:23) - at Context.testEachParserExample (/ebnf_parse.js:329:19) + 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 Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 474d330f7..7c3a5299d 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,10 +11,10 @@ bogus: foo bar; name: 'JisonParserError', message: '$id is not defined', stack: `ReferenceError: $id is not defined - at Object.parser__PerformAction (/ebnf-parser-cjs.js:7255:32) - at Object.parse (/ebnf-parser-cjs.js:10598:40) - at Object.parse (/ebnf-parser-cjs.js:23317:23) - at Context.testEachParserExample (/ebnf_parse.js:329:19) + 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 Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 6c236f1fd..1e411d369 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,12 +33,12 @@ multiple alternative rule productions should be separated by a '|' pipe characte 5: 6: bogus: foo bar; - at Object.parseError (/ebnf-parser-cjs.js:9109:15) - at Object.yyError (/ebnf-parser-cjs.js:9306:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:7323:14) - at Object.parse (/ebnf-parser-cjs.js:10393:52) - at Object.parse (/ebnf-parser-cjs.js:23317:23) - at Context.testEachParserExample (/ebnf_parse.js:329:19) + 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 Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 00ac936eb..91511f85f 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,12 +23,12 @@ Maybe you did not correctly separate the parse 'header section' (token definitio 3: ^..^ - at Object.parseError (/ebnf-parser-cjs.js:9109:15) - at Object.yyError (/ebnf-parser-cjs.js:9306:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:6285:14) - at Object.parse (/ebnf-parser-cjs.js:10393:52) - at Object.parse (/ebnf-parser-cjs.js:23317:23) - at Context.testEachParserExample (/ebnf_parse.js:329:19) + 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:6434:14) + at Object.parse (/ebnf-parser-cjs.js:10504:24) + at Object.parse (/ebnf-parser-cjs.js:23394:23) + at Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 83f22bad4..91b71e753 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,12 +26,12 @@ declaration list error? 4: %% ^..^^ - at Object.parseError (/ebnf-parser-cjs.js:9109:15) - at Object.yyError (/ebnf-parser-cjs.js:9306:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:6389:14) - at Object.parse (/ebnf-parser-cjs.js:10393:52) - at Object.parse (/ebnf-parser-cjs.js:23317:23) - at Context.testEachParserExample (/ebnf_parse.js:329:19) + 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 Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 f2e55ceb3..fd58cb861 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,12 +44,12 @@ Parse error on line 12: ^ Expecting ":", "STRING", "ARROW_ACTION", "optional_production_description", got unexpected "%%" - at Object.parseError (/ebnf-parser-cjs.js:9109:15) - at Object.yyError (/ebnf-parser-cjs.js:9306:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:7233:14) - at Object.parse (/ebnf-parser-cjs.js:10393:52) - at Object.parse (/ebnf-parser-cjs.js:23317:23) - at Context.testEachParserExample (/ebnf_parse.js:329:19) + 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 Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 7dc75f9d4..9a1327aa3 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,12 +39,12 @@ declaration list error? 7: 8: foo: bar; - at Object.parseError (/ebnf-parser-cjs.js:9109:15) - at Object.yyError (/ebnf-parser-cjs.js:9306:25) - at Object.parser__PerformAction (/ebnf-parser-cjs.js:6389:14) - at Object.parse (/ebnf-parser-cjs.js:10393:52) - at Object.parse (/ebnf-parser-cjs.js:23317:23) - at Context.testEachParserExample (/ebnf_parse.js:329:19) + 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 Context.testEachParserExample (/ebnf_parse.js:345:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/ebnf-parser/transform-parser.js b/packages/ebnf-parser/transform-parser.js index 562f76b66..945b4921a 100644 --- a/packages/ebnf-parser/transform-parser.js +++ b/packages/ebnf-parser/transform-parser.js @@ -1,5 +1,5 @@ -/* parser generated by jison 0.6.2-220 */ +/* parser generated by jison 0.7.0-220 */ /* * Returns a Parser object of the following structure: @@ -162,9 +162,9 @@ * Produces a new errorInfo 'hash object' which can be passed into `parseError()`. * See it's use in this parser kernel in many places; example usage: * - * var infoObj = parser.constructParseErrorInfo('fail!', null, + * let infoObj = parser.constructParseErrorInfo('fail!', null, * parser.collect_expected_token_set(state), true); - * var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); + * let retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); * * originalParseError: function(str, hash, ExceptionClass), * The basic `parseError` handler provided by JISON. @@ -366,212 +366,7 @@ * flex: boolean * optional: `true` ==> flex-like lexing behaviour where the rules are tested * exhaustively to find the longest match. - * backtrack_lexer: boolean (⅏ 센 ⅊ ⁖ ⁘ ⁙ ⁚ ⁛ ⁜ ⁝ ⁞ † ‡ - a⯈b - ∀ ∁ ∂ ∃ ∄ ∅ ∆ ∇ ∈ ∉ ∊ ∋ ∌ ∍ ∎ ∏ -U+221x ∐ ∑ − ∓ ∔ ∕ ∖ ∗ ∘ ∙ √ ∛ ∜ ∝ ∞ ∟ -U+222x ∠ ∡ ∢ ∣ ∤ ∥ ∦ ∧ ∨ ∩ ∪ ∫ ∬ ∭ ∮ ∯ -U+223x ∰ ∱ ∲ ∳ ∴ ∵ ∶ ∷ ∸ ∹ ∺ ∻ ∼ ∽ ∾ ∿ -U+224x ≀ ≁ ≂ ≃ ≄ ≅ ≆ ≇ ≈ ≉ ≊ ≋ ≌ ≍ ≎ ≏ -U+225x ≐ ≑ ≒ ≓ ≔ ≕ ≖ ≗ ≘ ≙ ≚ ≛ ≜ ≝ ≞ ≟ -U+226x ≠ ≡ ≢ ≣ ≤ ≥ ≦ ≧ ≨ ≩ ≪ ≫ ≬ ≭ ≮ ≯ -U+227x ≰ ≱ ≲ ≳ ≴ ≵ ≶ ≷ ≸ ≹ ≺ ≻ ≼ ≽ ≾ ≿ -U+228x ⊀ ⊁ ⊂ ⊃ ⊄ ⊅ ⊆ ⊇ ⊈ ⊉ ⊊ ⊋ ⊌ ⊍ ⊎ ⊏ -U+229x ⊐ ⊑ ⊒ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊜ ⊝ ⊞ ⊟ -U+22Ax ⊠ ⊡ ⊢ ⊣ ⊤ ⊥ ⊦ ⊧ ⊨ ⊩ ⊪ ⊫ ⊬ ⊭ ⊮ ⊯ -U+22Bx ⊰ ⊱ ⊲ ⊳ ⊴ ⊵ ⊶ ⊷ ⊸ ⊹ ⊺ ⊻ ⊼ ⊽ ⊾ ⊿ -U+22Cx ⋀ ⋁ ⋂ ⋃ ⋄ ⋅ ⋆ ⋇ ⋈ ⋉ ⋊ ⋋ ⋌ ⋍ ⋎ ⋏ -U+22Dx ⋐ ⋑ ⋒ ⋓ ⋔ ⋕ ⋖ ⋗ ⋘ ⋙ ⋚ ⋛ ⋜ ⋝ ⋞ ⋟ -U+22Ex ⋠ ⋡ ⋢ ⋣ ⋤ ⋥ ⋦ ⋧ ⋨ ⋩ ⋪ ⋫ ⋬ ⋭ ⋮ ⋯ -U+22Fx ⋰ ⋱ ⋲ ⋳ ⋴ ⋵ ⋶ ⋷ ⋸ ⋹ ⋺ ⋻ ⋼ ⋽ ⋾ ⋿) -U+230x ⌀ ⌁ ⌂ ⌃ ⌄ ⌅ ⌆ ⌇ ⌈ ⌉ ⌊ ⌋ ⌌ ⌍ ⌎ ⌏ -U+231x ⌐ ⌑ ⌒ ⌓ ⌔ ⌕ ⌖ ⌗ ⌘ ⌙ ⌚ ⌛ ⌜ ⌝ ⌞ ⌟ -U+232x ⌠ ⌡ ⌢ ⌣ ⌤ ⌥ ⌦ ⌧ ⌨ 〈 〉 ⌫ ⌬ ⌭ ⌮ ⌯ -U+233x ⌰ ⌱ ⌲ ⌳ ⌴ ⌵ ⌶ ⌷ ⌸ ⌹ ⌺ ⌻ ⌼ ⌽ ⌾ ⌿ -U+234x ⍀ ⍁ ⍂ ⍃ ⍄ ⍅ ⍆ ⍇ ⍈ ⍉ ⍊ ⍋ ⍌ ⍍ ⍎ ⍏ -U+235x ⍐ ⍑ ⍒ ⍓ ⍔ ⍕ ⍖ ⍗ ⍘ ⍙ ⍚ ⍛ ⍜ ⍝ ⍞ ⍟ -U+236x ⍠ ⍡ ⍢ ⍣ ⍤ ⍥ ⍦ ⍧ ⍨ ⍩ ⍪ ⍫ ⍬ ⍭ ⍮ ⍯ -U+237x ⍰ ⍱ ⍲ ⍳ ⍴ ⍵ ⍶ ⍷ ⍸ ⍹ ⍺ ⍻ ⍼ ⍽ ⍾ ⍿ -U+238x ⎀ ⎁ ⎂ ⎃ ⎄ ⎅ ⎆ ⎇ ⎈ ⎉ ⎊ ⎋ ⎌ ⎍ ⎎ ⎏ -U+239x ⎐ ⎑ ⎒ ⎓ ⎔ ⎕ ⎖ ⎗ ⎘ ⎙ ⎚ ⎛ ⎜ ⎝ ⎞ ⎟ -U+23Ax ⎠ ⎡ ⎢ ⎣ ⎤ ⎥ ⎦ ⎧ ⎨ ⎩ ⎪ ⎫ ⎬ ⎭ ⎮ ⎯ -U+23Bx ⎰ ⎱ ⎲ ⎳ ⎴ ⎵ ⎶ ⎷ ⎸ ⎹ ⎺ ⎻ ⎼ ⎽ ⎾ ⎿ -U+23Cx ⏀ ⏁ ⏂ ⏃ ⏄ ⏅ ⏆ ⏇ ⏈ ⏉ ⏊ ⏋ ⏌ ⏍ ⏎ ⏏ -U+23Dx ⏐ ⏑ ⏒ ⏓ ⏔ ⏕ ⏖ ⏗ ⏘ ⏙ ⏚ ⏛ ⏜ ⏝ ⏞ ⏟ -U+23Ex ⏠ ⏡ ⏢ ⏣ ⏤ ⏥ ⏦ ⏧ ⏨ ⏩ ⏪ ⏫ ⏬ ⏭ ⏮ ⏯ -U+23Fx ⏰ ⏱ ⏲ ⏳ ⏴ ⏵ ⏶ ⏷ ⏸ ⏹ ⏺ ⏻ ⏼ ⏽ ⏾ ⏿ - -U+260x ☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☎ ☏ -U+261x ☐ ☑ ☒ ☓ ☔ ☕ ☖ ☗ ☘ ☙ ☚ ☛ ☜ ☝ ☞ ☟ -U+262x ☠ ☡ ☢ ☣ ☤ ☥ ☦ ☧ ☨ ☩ ☪ ☫ ☬ ☭ ☮ ☯ -U+263x ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷ ☸ ☹ ☺ ☻ ☼ ☽ ☾ ☿ -U+264x ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇ ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ -U+265x ♐ ♑ ♒ ♓ ♔ ♕ ♖ ♗ ♘ ♙ ♚ ♛ ♜ ♝ ♞ ♟ -U+266x ♠ ♡ ♢ ♣ ♤ ♥ ♦ ♧ ♨ ♩ ♪ ♫ ♬ ♭ ♮ ♯ -U+267x ♰ ♱ ♲ ♳ ♴ ♵ ♶ ♷ ♸ ♹ ♺ ♻ ♼ ♽ ♾ ♿ -U+268x ⚀ ⚁ ⚂ ⚃ ⚄ ⚅ ⚆ ⚇ ⚈ ⚉ ⚊ ⚋ ⚌ ⚍ ⚎ ⚏ -U+269x ⚐ ⚑ ⚒ ⚓ ⚔ ⚕ ⚖ ⚗ ⚘ ⚙ ⚚ ⚛ ⚜ ⚝ ⚞ ⚟ -U+26Ax ⚠ ⚡ ⚢ ⚣ ⚤ ⚥ ⚦ ⚧ ⚨ ⚩ ⚪ ⚫ ⚬ ⚭ ⚮ ⚯ -U+26Bx ⚰ ⚱ ⚲ ⚳ ⚴ ⚵ ⚶ ⚷ ⚸ ⚹ ⚺ ⚻ ⚼ ⚽ ⚾ ⚿ -U+26Cx ⛀ ⛁ ⛂ ⛃ ⛄ ⛅ ⛆ ⛇ ⛈ ⛉ ⛊ ⛋ ⛌ ⛍ ⛎ ⛏ -U+26Dx ⛐ ⛑ ⛒ ⛓ ⛔ ⛕ ⛖ ⛗ ⛘ ⛙ ⛚ ⛛ ⛜ ⛝ ⛞ ⛟ -U+26Ex ⛠ ⛡ ⛢ ⛣ ⛤ ⛥ ⛦ ⛧ ⛨ ⛩ ⛪ ⛫ ⛬ ⛭ ⛮ ⛯ -U+26Fx ⛰ ⛱ ⛲ ⛳ ⛴ ⛵ ⛶ ⛷ ⛸ ⛹ ⛺ ⛻ ⛼ ⛽ ⛾ ⛿ - - ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ☛ ☞ ✌ ✍ ✎ ✏ -✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -✠ ✡ ✢ ✣ ✤ ✥ ✦ ✧ ★ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ● ❍ ■ ❏ -☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ❐ ❑ ❒ ▲ ▼ ◆ ❖ -◗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ - -U+270x ✀ ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ✊ ✋ ✌ ✍ ✎ ✏ -U+271x ✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -U+272x ✠ ✡ ✢ ✣ a✤b a✥b a✦b a✧b ✨ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -U+273x ✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -U+274x ❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ❌ ❍ ❎ ❏ -U+275x ❐ ❑ ❒ ❓ ❔ ❕ ❖ ❗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ ❟ -U+276x ❠ ❡ ❢ ❣ ❤ ❥ ❦ ❧ ❨ ❩ ❪ ❫ ❬ ❭ ❮ a❯b -U+277x ❰ ❱ ❲ ❳ ❴ ❵ ❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ ❾ ❿ -U+278x ➀ ➁ ➂ ➃ ➄ ➅ ➆ ➇ ➈ ➉ ➊ ➋ ➌ ➍ ➎ ➏ -U+279x ➐ ➑ ➒ ➓ ➔ ➕ ➖ ➗ ➘ ➙ ➚ ➛ ➜ ➝ ➞ ➟ -U+27Ax ➠ ➡ ➢ ➣ ➤ ➥ ➦ ➧ a➨b ➩ ➪ ➫ ➬ ➭ ➮ ➯ -U+27Bx ➰ a➱b ➲ ➳ ➴ ➵ ➶ ➷ ➸ ➹ ➺ ➻ ➼ ➽ ➾ ➿ - -U+2580 ▀ Upper half block -U+2581 ▁ Lower one eighth block -U+2582 ▂ Lower one quarter block -U+2583 ▃ Lower three eighths block -U+2584 ▄ Lower half block -U+2585 ▅ Lower five eighths block -U+2586 ▆ Lower three quarters block -U+2587 ▇ Lower seven eighths block -U+2588 █ Full block -U+2589 ▉ Left seven eighths block -U+258A ▊ Left three quarters block -U+258B ▋ Left five eighths block -U+258C ▌ Left half block -U+258D ▍ Left three eighths block -U+258E ▎ Left one quarter block -U+258F ▏ Left one eighth block -U+2590 ▐ Right half block -U+2591 ░ Light shade -U+2592 ▒ Medium shade -U+2593 ▓ Dark shade -U+2594 ▔ Upper one eighth block -U+2595 ▕ Right one eighth block -U+2596 ▖ Quadrant lower left -U+2597 ▗ Quadrant lower right -U+2598 ▘ Quadrant upper left -U+2599 ▙ Quadrant upper left and lower left and lower right -U+259A ▚ Quadrant upper left and lower right -U+259B ▛ Quadrant upper left and upper right and lower left -U+259C ▜ Quadrant upper left and upper right and lower right -U+259D ▝ Quadrant upper right -U+259E ▞ Quadrant upper right and lower left -U+259F ▟ Quadrant upper right and lower left and lower right -Geometric Shapes -Main articles: Geometric Shapes (Unicode block) and Geometric Shapes Extended (Unicode block) -[hide]Code Glyph Description -U+25A0 ■ Black square -U+25A1 □ White square -U+25A2 ▢ White square with rounded corners -U+25A3 ▣ White square containing small black square -U+25A4 ▤ Square with horizontal fill -U+25A5 ▥ Square with vertical fill -U+25A6 ▦ Square with orthogonal crosshatch fill -U+25A7 ▧ Square with upper left to lower right fill -U+25A8 ▨ Square with upper right to lower left fill -U+25A9 ▩ Square with diagonal crosshatch fill -U+25AA ▪ Black small square -U+25AB ▫ White small square -U+25AC ▬ Black rectangle -U+25AD ▭ White rectangle -U+25AE ▮ Black vertical rectangle -U+25AF ▯ White vertical rectangle -U+25B0 ▰ Black parallelogram -U+25B1 ▱ White parallelogram -U+25B2 ▲ Black up-pointing triangle -U+25B3 △ White up-pointing triangle -U+25B4 ▴ Black up-pointing small triangle -U+25B5 ▵ White up-pointing small triangle -U+25B6 ▶ Black right-pointing triangle -U+25B7 ▷ White right-pointing triangle -U+25B8 ▸ Black right-pointing small triangle -U+25B9 ▹ White right-pointing small triangle -U+25BA ► Black right-pointing pointer -U+25BB ▻ White right-pointing pointer -U+25BC ▼ Black down-pointing triangle -U+25BD ▽ White down-pointing triangle -U+25BE ▾ Black down-pointing small triangle -U+25BF ▿ White down-pointing small triangle -U+25C0 ◀ Black left-pointing triangle -U+25C1 ◁ White left-pointing triangle -U+25C2 ◂ Black left-pointing small triangle -U+25C3 ◃ White left-pointing small triangle -U+25C4 ◄ Black left-pointing pointer -U+25C5 ◅ White left-pointing pointer -U+25C6 ◆ Black diamond -U+25C7 ◇ White diamond -U+25C8 ◈ White diamond containing small black diamond -U+25C9 ◉ Fisheye -U+25CA ◊ Lozenge -U+25CB ○ White circle -U+25CC ◌ Dotted circle -U+25CD ◍ Circle with vertical fill -U+25CE ◎ Bullseye -U+25CF ● Black circle -U+25D0 ◐ Circle with left half black -U+25D1 ◑ Circle with right half black -U+25D2 ◒ Circle with lower half black -U+25D3 ◓ Circle with upper half black -U+25D4 ◔ Circle with upper right quadrant black -U+25D5 ◕ Circle with all but upper left quadrant black -U+25D6 ◖ Left half circle black -U+25D7 ◗ Right half black circle -U+25D8 ◘ Inverse bullet -U+25D9 ◙ Inverse white circle -U+25DA ◚ Upper half inverse white circle -U+25DB ◛ Lower half inverse white circle -U+25DC ◜ Upper left quadrant circular arc -U+25DD ◝ Upper right quadrant circular arc -U+25DE ◞ Lower right quadrant circular arc -U+25DF ◟ Lower left quadrant circular arc -U+25E0 ◠ Upper half circle -U+25E1 ◡ Lower half circle -U+25E2 ◢ Black lower right triangle -U+25E3 ◣ Black lower left triangle -U+25E4 ◤ Black upper left triangle -U+25E5 ◥ Black upper right triangle -U+25E6 ◦ White bullet -U+25E7 ◧ Square with left half black -U+25E8 ◨ Square with right half black -U+25E9 ◩ Square with upper left diagonal half black -U+25EA ◪ Square with lower right diagonal half black -U+25EB ◫ White square with vertical bisecting line -U+25EC ◬ White up-pointing triangle with dot -U+25ED ◭ Up-pointing triangle with left half black -U+25EE ◮ Up-pointing triangle with right half black -U+25EF ◯ Large circle -U+25F0 ◰ White square with upper left quadrant -U+25F1 ◱ White square with lower left quadrant -U+25F2 ◲ White square with lower right quadrant -U+25F3 ◳ White square with upper right quadrant -U+25F4 ◴ White circle with upper left quadrant -U+25F5 ◵ White circle with lower left quadrant -U+25F6 ◶ White circle with lower right quadrant -U+25F7 ◷ White circle with upper right quadrant -U+25F8 ◸ Upper left triangle -U+25F9 ◹ Upper right triangle -U+25FA ◺ Lower-left triangle -U+25FB ◻ White medium square -U+25FC ◼ Black medium square -U+25FD ◽ White medium small square -U+25FE ◾ Black medium small square -U+25FF ◿ Lower right triangle - - + * backtrack_lexer: boolean * optional: `true` ==> lexer regexes are tested in order and for invoked; * the lexer terminates the scan when a token is returned by the action code. * xregexp: boolean @@ -590,8 +385,6 @@ import XRegExp from '@gerhobbelt/xregexp'; // for helping out the `%option // 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. function JisonParserError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -608,9 +401,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -643,10 +436,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -661,18 +454,18 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -703,7 +496,7 @@ JisonParserError.prototype.name = 'JisonParserError'; // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -720,9 +513,9 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -735,7 +528,7 @@ JisonParserError.prototype.name = 'JisonParserError'; } -var parser = { +let parser = { // Code Generator Information Report // --------------------------------- // @@ -861,8 +654,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - "use strict"; - return '"' + id_str + '"'; }, @@ -870,8 +661,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - "use strict"; - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -883,8 +672,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -897,15 +686,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - "use strict"; - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -921,11 +708,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { - "use strict"; + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -933,10 +719,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -980,9 +766,9 @@ performAction: function parser__PerformAction(yystate /* action[1] */, yysp, yyv /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; @@ -990,17 +776,17 @@ performAction: function parser__PerformAction(yystate /* action[1] */, yysp, yyv case 0: /*! Production:: $accept : production $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,-,-,-,-) break; case 1: /*! Production:: production : handle EOF */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-): + // default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-): this.$ = yyvstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,-,-,-,-) return yyvstack[yysp - 1]; @@ -1237,8 +1023,6 @@ defaultActions: { 19: 3 }, parseError: function parseError(str, hash, ExceptionClass) { - "use strict"; - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -1255,38 +1039,36 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - "use strict"; - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks + let vstack = new Array(128); // semantic value stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks - - + let yytext; + let yylineno; + let yyleng; - var symbol = 0; + let symbol = 0; - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 20 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - var lexer; + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -1294,21 +1076,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - "use strict"; - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -1325,8 +1104,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - "use strict"; - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -1334,18 +1111,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -1353,26 +1131,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - "use strict"; - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - "use strict"; - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); if (rv) { rv.range = rv.range.slice(); @@ -1397,8 +1168,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -1411,8 +1180,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - "use strict"; - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -1426,12 +1193,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - "use strict"; - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -1485,8 +1250,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -1635,9 +1400,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - "use strict"; - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -1646,10 +1409,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -1657,7 +1420,7 @@ parse: function parse(input) { stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -1674,10 +1437,8 @@ parse: function parse(input) { // info.value = null; // info.value_stack = null; // ... - "use strict"; - - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -1703,9 +1464,7 @@ parse: function parse(input) { function getNonTerminalFromCode(symbol) { - "use strict"; - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -1714,22 +1473,20 @@ parse: function parse(input) { function stdLex() { - "use strict"; - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -1739,22 +1496,20 @@ parse: function parse(input) { } function fastLex() { - "use strict"; - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -1763,20 +1518,20 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; try { @@ -1789,7 +1544,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -1842,14 +1597,11 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { - var errStr; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let errStr; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); // Report error errStr = 'Parse error'; @@ -1886,9 +1638,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -1917,7 +1667,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -1959,21 +1709,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, newState, sp - 1, vstack); +r = this.performAction.call(yyval, newState, sp - 1, vstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -2004,14 +1752,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -2021,6 +1770,7 @@ parse: function parse(input) { + } continue; // accept: @@ -2073,8 +1823,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -2335,8 +2084,6 @@ var lexer = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - 'use strict'; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -2353,10 +2100,10 @@ var lexer = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -2388,7 +2135,7 @@ var lexer = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -2430,7 +2177,9 @@ var lexer = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -2506,7 +2255,6 @@ EOF: 1, * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - 'use strict'; msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -2517,7 +2265,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -2525,7 +2273,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -2538,7 +2286,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -2568,11 +2316,9 @@ EOF: 1, // info.yy = null; // info.lexer = null; // ... - 'use strict'; - - var rec = !!this.recoverable; + const rec = !!this.recoverable; - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -2595,8 +2341,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - 'use strict'; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -2619,17 +2363,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - 'use strict'; - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -2651,8 +2394,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - 'use strict'; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -2660,8 +2401,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -2681,7 +2422,6 @@ EOF: 1, * @this {RegExpLexer} */ clear: function lexer_clear() { - 'use strict'; this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -2691,7 +2431,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -2709,7 +2449,6 @@ EOF: 1, * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - 'use strict'; this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -2717,7 +2456,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -2729,17 +2468,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -2833,8 +2572,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - 'use strict'; - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -2855,8 +2593,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - 'use strict'; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -2867,7 +2603,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -2878,15 +2614,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -2920,9 +2656,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - 'use strict'; - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -2955,9 +2690,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -2976,9 +2711,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -2988,13 +2723,12 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - 'use strict'; return this._input || ''; }, @@ -3005,7 +2739,6 @@ EOF: 1, * @this {RegExpLexer} */ more: function lexer_more() { - 'use strict'; this._more = true; return this; }, @@ -3018,21 +2751,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - 'use strict'; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -3050,7 +2781,6 @@ EOF: 1, * @this {RegExpLexer} */ less: function lexer_less(n) { - 'use strict'; return this.unput(this.match.slice(n)); }, @@ -3073,18 +2803,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - 'use strict'; - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -3093,7 +2824,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -3108,8 +2839,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -3135,25 +2866,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - 'use strict'; - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -3164,7 +2896,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -3186,9 +2918,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - 'use strict'; - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -3210,9 +2941,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - 'use strict'; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -3352,27 +3081,25 @@ EOF: 1, * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - 'use strict'; loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - 'use strict'; - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -3387,11 +3114,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -3410,13 +3137,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -3440,14 +3167,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - 'use strict'; - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -3462,8 +3188,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -3494,8 +3220,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - 'use strict'; - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -3527,9 +3252,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -3558,7 +3283,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -3576,7 +3301,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -3601,8 +3326,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - 'use strict'; - if (this.done) { this.clear(); return this.EOF; @@ -3612,8 +3335,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -3622,7 +3343,7 @@ EOF: 1, this.clear(); } - 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. @@ -3634,13 +3355,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -3650,68 +3371,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -3736,8 +3463,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - 'use strict'; - var r; + let r; //this._clear_state = 0; @@ -3785,24 +3511,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -3822,8 +3548,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - 'use strict'; - var r; + let r; //this._clear_state = 0; @@ -3833,24 +3558,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -3871,9 +3596,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - 'use strict'; - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -3889,7 +3612,6 @@ EOF: 1, * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - 'use strict'; return this.pushState(condition); }, @@ -3901,7 +3623,6 @@ EOF: 1, * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - 'use strict'; this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -3915,15 +3636,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - 'use strict'; - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -3935,14 +3655,13 @@ EOF: 1, * @this {RegExpLexer} */ topState: function lexer_topState(n) { - 'use strict'; n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -3953,9 +3672,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - 'use strict'; - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -3963,7 +3681,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -3973,7 +3691,6 @@ EOF: 1, * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - 'use strict'; return this.conditionStack.length; }, diff --git a/packages/helpers-lib/dist/helpers-lib-cjs-es5.js b/packages/helpers-lib/dist/helpers-lib-cjs-es5.js index a4328e2fb..d1d5a2e33 100644 --- a/packages/helpers-lib/dist/helpers-lib-cjs-es5.js +++ b/packages/helpers-lib/dist/helpers-lib-cjs-es5.js @@ -6,6 +6,8 @@ var path$1 = require('path'); var JSON5 = require('@gerhobbelt/json5'); +var mkdirp = require('mkdirp'); + var XRegExp = require('@gerhobbelt/xregexp'); var recast = require('recast'); @@ -26,11 +28,13 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); +var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); + var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); -var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert); // Return TRUE if `src` starts with `searchString`. +var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert); // Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { @@ -53,18 +57,18 @@ function rmCommonWS(strings, ...values) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -82,18 +86,20 @@ function rmCommonWS(strings, ...values) { // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); // Done removing common indentation. - // + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; // only correct indentation at start of line, i.e. only check for + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -102,17 +108,20 @@ function rmCommonWS(strings, ...values) { } // now merge everything to construct the template result: - var rv = []; + { + let rv = []; + let i = 0; - for (var i = 0, len = values.length; i < len; i++) { - rv.push(src[i].join('\n')); - rv.push(values[i]); - } // the last value is always followed by a last template string partial: + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + rv.push(src[i].join('\n')); + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` /** @public */ @@ -123,8 +132,8 @@ function camelCase(s) { return s.replace(/^\w/, function (match) { return match.toLowerCase(); }).replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; @@ -132,18 +141,30 @@ function camelCase(s) { return rv; }); -} // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers +} // https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words + + +const reservedWords = (list => { + let rv = new Set(); + + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + + return rv; +})(['await', 'break', 'case', 'catch', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'enum', 'export', 'extends', 'finally', 'for', 'function', 'if', 'implements', 'import', 'in', 'instanceof', 'interface', 'new', 'package', 'private', 'protected', 'public', 'return', 'super', 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'yield']); // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -155,6 +176,12 @@ function mkIdentifier(s) { .replace(/^[^\w_]/, '_') // do not accept numerics at the leading position, despite those matching regex `\w`: .replace(/^\d/, '_').replace(/[^\w\d_]/g, '_') // and only accept multiple (double, not triple) underscores at start or end of identifier name: .replace(/^__+/, '#').replace(/__+$/, '#').replace(/_+/g, '_').replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + + return rv; } // Check if the start of the given input matches a regex expression. // Return the length of the regex expression or -1 if none was found. @@ -164,13 +191,13 @@ function mkIdentifier(s) { function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; @@ -190,13 +217,11 @@ function scanRegExp(s) { if (ch === ']') { classMarker = false; } - } else { - if (ch === '/') { - terminated = true; - break; - } else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } @@ -220,12 +245,12 @@ function isLineTerminator(cp) { function isLegalIdentifierInput(s) { - s = '' + s; // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + s = '' + s; // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s.replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -233,14 +258,14 @@ function isLegalIdentifierInput(s) { return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = s.indexOf('\'') >= 0; - var dq = s.indexOf('"') >= 0; + let sq = s.indexOf('\'') >= 0; + let dq = s.indexOf('"') >= 0; if (sq && dq) { s = s.replace(/"/g, '\\"'); @@ -268,48 +293,104 @@ function chkBugger(src) { function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); +} + +function convertExceptionToObject(ex) { + if (!ex) return ex; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + + let rv = Object.assign({}, ex); // - Set up the default fields which should ALWAYS be present: + + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + + if (Array.isArray(ex.errors)) { + rv.errors = []; + + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + + return rv; +} + +function find_suitable_app_dump_path() { + return process.cwd().replace(/\\/g, '/').replace(/\/node_modules\/.*$/, m => '/___nm___/').replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map(d => d.charAt(0).toUpperCase()).join('_')); } // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [options.outfile ? path__default['default'].dirname(options.outfile) : null, options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname).replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + const dumpPaths = [options.outfile ? path__default['default'].dirname(options.outfile) : null, options.inputPath, find_suitable_app_dump_path()]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname).replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; + } // generate a stacktrace for the dump no matter what: + + + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } } err_id = err_id || 'XXX'; - var ts = new Date(); - var tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + '' + pad(ts.getUTCMinutes()) + '' + pad(ts.getUTCSeconds()) + '.' + pad(ts.getUTCMilliseconds(), 3) + 'Z'; + err_id = err_id.replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + '' + pad(ts.getUTCMinutes()) + '' + pad(ts.getUTCSeconds()) + '.' + pad(ts.getUTCMilliseconds(), 3) + 'Z'; dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); - let dump = { + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); + const dump = { errname, err_id, options, - ex + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); // make sure each line is a comment line: + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]' + }); // make sure each line is a comment line: d = d.split('\n').map(l => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -319,7 +400,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -350,25 +431,40 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; } - const debug = 0; - var p; + const debug = options.debug || 0; + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); + } + + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + if (debug > 1) console.log('exec-and-diagnose options:', options); + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } @@ -381,9 +477,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t return p; } -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject }; // assert__default['default'](recast__default['default']); //var types = recast.types; @@ -397,18 +494,18 @@ assert__default['default'](recast__default['default']); //var types = recast.typ // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! -const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: -const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; // Determine which Unicode NonAsciiIdentifierStart characters +const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; // Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -418,37 +515,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -456,30 +553,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -490,58 +587,58 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -586,27 +683,27 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: - const typeIdCharSets = ["ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", + const typeIdCharSets = ['ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ"]; //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ']; //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -617,18 +714,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { hash[i] = (hash[i] || 0) + 1; } // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -639,56 +736,56 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); @@ -696,7 +793,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { for (let i = 0, l = typeIdCharSets.length; i < l; i++) { typeIdChar[i] = pickChar(typeIdCharSets[i]); - } // produce a function set for encoding and decoding content, + } // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: @@ -704,57 +801,57 @@ function generateMapper4JisonGrammarIdentifiers(input) { return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction @@ -765,10 +862,10 @@ function generateMapper4JisonGrammarIdentifiers(input) { re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -851,10 +948,10 @@ function generateMapper4JisonGrammarIdentifiers(input) { re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -863,19 +960,19 @@ function generateMapper4JisonGrammarIdentifiers(input) { // p1 is only serving as lookbehind emulation switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -917,7 +1014,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { function parseCodeChunkToAST(src, options) { src = src.replace(/@/g, '\uFFDA').replace(/#/g, '\uFFDB'); - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } @@ -932,13 +1029,13 @@ function compileCodeToES5(src, options) { sourceRoot: '.', sourceType: 'module', babelrc: false, - ignore: ["node_modules/**/*.js"], + ignore: ['node_modules/**/*.js'], compact: false, retainLines: false, - presets: [["@babel/preset-env", { + presets: [['@babel/preset-env', { targets: { - browsers: ["last 2 versions"], - node: "8.0" + browsers: ['last 2 versions'], + node: '8.0' } }]] }, options); @@ -946,7 +1043,7 @@ function compileCodeToES5(src, options) { } function prettyPrintAST(ast, options) { - var options = options || {}; + options = options || {}; const defaultOptions = { tabWidth: 2, quote: 'single', @@ -956,7 +1053,7 @@ function prettyPrintAST(ast, options) { reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -969,16 +1066,16 @@ function prettyPrintAST(ast, options) { .replace(/\uFFDA/g, '@').replace(/\uFFDB/g, '#'); return new_src; } // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; } @@ -987,19 +1084,19 @@ function checkActionBlock(src, yylloc, options) { } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } // The rough-and-ready preprocessor for any action code block: // this one trims off any surplus whitespace and removes any // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1007,7 +1104,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1016,16 +1113,16 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { - var s = src.trim(); // remove outermost set of braces UNLESS there's + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated // code analyzer to simplify the code! @@ -1090,7 +1187,7 @@ function chkBugger$1(src) { function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1098,25 +1195,25 @@ function printFunctionSourceCode(f) { const funcRe = /^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/; const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/; /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; // Also cope with Arrow Functions (and inline those as well?). + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); @@ -1136,8 +1233,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1148,7 +1245,7 @@ function printFunctionSourceCodeContainer(f) { action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } @@ -1163,14 +1260,14 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { printFunctionSourceCode, printFunctionSourceCodeContainer -}; // -// -// +}; // +// +// function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } // // Helper library for safe code execution/compilation @@ -1193,7 +1290,7 @@ function detectIstanbulGlobal() { function checkRegExp(re_src, re_flags, XRegExp) { - var re; // were we fed a RegExp object or a string? + let re; // were we fed a RegExp object or a string? if (re_src && typeof re_src.source === 'string' && typeof re_src.flags === 'string' && typeof re_src.toString === 'function' && typeof re_src.test === 'function' && typeof re_src.exec === 'function') { // we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member @@ -1237,7 +1334,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; // were we fed a RegExp object or a string? + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src && typeof re_src.source === 'string' && typeof re_src.flags === 'string' && typeof re_src.toString === 'function' && typeof re_src.test === 'function' && typeof re_src.exec === 'function') { // we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member @@ -1285,11 +1382,11 @@ var reHelpers = { checkRegExp: checkRegExp, getRegExpInfo: getRegExpInfo }; -var cycleref = []; -var cyclerefpath = []; -var linkref = []; -var linkrefpath = []; -var path = []; +let cycleref = []; +let cyclerefpath = []; +let linkref = []; +let linkrefpath = []; +let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1297,7 +1394,7 @@ function shallow_copy(src) { return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; @@ -1305,7 +1402,7 @@ function shallow_copy(src) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1319,12 +1416,12 @@ function shallow_copy(src) { function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1338,9 +1435,9 @@ function shallow_copy_and_strip_depth(src, parentKey) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; @@ -1355,12 +1452,44 @@ function shallow_copy_and_strip_depth(src, parentKey) { } return src; -} +} // strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. + function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: - msg = msg.replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)').replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + msg = msg.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; +} // strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. + + +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + + let keys = Object.keys(obj); + + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + + return obj; } function trim_array_tail(arr) { @@ -1377,7 +1506,7 @@ function trim_array_tail(arr) { function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; @@ -1404,11 +1533,11 @@ function treat_value_stack(v) { } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1555,7 +1684,7 @@ function treat_error_report_info(e) { function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. @@ -1581,7 +1710,7 @@ function treat_object(e) { return e; } // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. @@ -1613,10 +1742,12 @@ var index = { dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, compileCodeToES5: parse2AST.compileCodeToES5, diff --git a/packages/helpers-lib/dist/helpers-lib-cjs.js b/packages/helpers-lib/dist/helpers-lib-cjs.js index c99d3b999..13a33c709 100644 --- a/packages/helpers-lib/dist/helpers-lib-cjs.js +++ b/packages/helpers-lib/dist/helpers-lib-cjs.js @@ -3,6 +3,7 @@ var fs = require('fs'); var path$1 = require('path'); var JSON5 = require('@gerhobbelt/json5'); +var mkdirp = require('mkdirp'); var XRegExp = require('@gerhobbelt/xregexp'); var recast = require('recast'); var babel = require('@babel/core'); @@ -13,11 +14,12 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); +var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert); -// Return TRUE if `src` starts with `searchString`. +// Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -40,19 +42,19 @@ function rmCommonWS(strings, ...values) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -71,19 +73,21 @@ function rmCommonWS(strings, ...values) { // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -92,16 +96,19 @@ function rmCommonWS(strings, ...values) { } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -112,27 +119,79 @@ function camelCase(s) { return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } +// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; +})([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' +]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -150,6 +209,11 @@ function mkIdentifier(s) { .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -158,13 +222,13 @@ function mkIdentifier(s) { function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -175,23 +239,17 @@ function scanRegExp(s) { break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -214,34 +272,33 @@ function isLineTerminator(cp) { /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -264,28 +321,76 @@ function chkBugger(src) { // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } +function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; +} + + +function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); +} + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -296,27 +401,37 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -326,7 +441,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -334,7 +449,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -360,27 +475,43 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -393,9 +524,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -417,22 +549,22 @@ assert__default['default'](recast__default['default']); // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; -// Determine which Unicode NonAsciiIdentifierStart characters +// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -440,40 +572,40 @@ const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -481,30 +613,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -515,59 +647,59 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -609,38 +741,38 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -652,18 +784,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -674,56 +806,56 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -731,97 +863,97 @@ function generateMapper4JisonGrammarIdentifiers(input) { typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -829,7 +961,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -842,7 +974,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -855,7 +987,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -868,7 +1000,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -887,37 +1019,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -949,7 +1081,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -966,37 +1098,37 @@ function parseCodeChunkToAST(src, options) { .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return babel.transformSync(src, options); // => { code, map, ast } @@ -1004,8 +1136,8 @@ function compileCodeToES5(src, options) { function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1014,7 +1146,7 @@ function prettyPrintAST(ast, options) { // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1037,25 +1169,25 @@ function prettyPrintAST(ast, options) { // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1066,9 +1198,9 @@ function checkActionBlock(src, yylloc, options) { // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1076,7 +1208,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1085,14 +1217,14 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1146,7 +1278,7 @@ var parse2AST = { trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1160,7 +1292,7 @@ function chkBugger$1(src) { /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1172,24 +1304,24 @@ const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?: /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1206,8 +1338,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1218,14 +1350,14 @@ function printFunctionSourceCodeContainer(f) { action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1236,17 +1368,17 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; -// -// -// +// +// +// function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1272,7 +1404,7 @@ function detectIstanbulGlobal() { // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1320,7 +1452,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1383,13 +1515,13 @@ var reHelpers = { getRegExpInfo: getRegExpInfo }; -var cycleref = []; -var cyclerefpath = []; +let cycleref = []; +let cyclerefpath = []; -var linkref = []; -var linkrefpath = []; +let linkref = []; +let linkrefpath = []; -var path = []; +let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1397,14 +1529,14 @@ function shallow_copy(src) { return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1417,11 +1549,11 @@ function shallow_copy(src) { function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1434,9 +1566,9 @@ function shallow_copy_and_strip_depth(src, parentKey) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1451,16 +1583,52 @@ function shallow_copy_and_strip_depth(src, parentKey) { } +// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } +// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; +} + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1475,7 +1643,7 @@ function trim_array_tail(arr) { function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1501,10 +1669,10 @@ function treat_value_stack(v) { } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1602,7 +1770,7 @@ function treat_hash(h) { function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1619,7 +1787,7 @@ function treat_error_report_info(e) { path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1647,7 +1815,7 @@ function treat_error_report_info(e) { function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1663,7 +1831,7 @@ function treat_object(e) { linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1675,14 +1843,14 @@ function treat_object(e) { // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1692,7 +1860,7 @@ function trimErrorForTestReporting(e) { cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1706,12 +1874,14 @@ var index = { dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1726,7 +1896,7 @@ var index = { printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; module.exports = index; diff --git a/packages/helpers-lib/dist/helpers-lib-es6.js b/packages/helpers-lib/dist/helpers-lib-es6.js index 2003dd954..1d587f6f1 100644 --- a/packages/helpers-lib/dist/helpers-lib-es6.js +++ b/packages/helpers-lib/dist/helpers-lib-es6.js @@ -1,12 +1,13 @@ import fs from 'fs'; import path$1 from 'path'; import JSON5 from '@gerhobbelt/json5'; +import mkdirp from 'mkdirp'; import XRegExp from '@gerhobbelt/xregexp'; import recast from 'recast'; import { transformSync } from '@babel/core'; import assert from 'assert'; -// Return TRUE if `src` starts with `searchString`. +// Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -29,19 +30,19 @@ function rmCommonWS(strings, ...values) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -60,19 +61,21 @@ function rmCommonWS(strings, ...values) { // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -81,16 +84,19 @@ function rmCommonWS(strings, ...values) { } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -101,27 +107,79 @@ function camelCase(s) { return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } +// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; +})([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' +]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -139,6 +197,11 @@ function mkIdentifier(s) { .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -147,13 +210,13 @@ function mkIdentifier(s) { function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -164,23 +227,17 @@ function scanRegExp(s) { break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -203,34 +260,33 @@ function isLineTerminator(cp) { /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -253,28 +309,76 @@ function chkBugger(src) { // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } +function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; +} + + +function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); +} + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path$1.dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path$1.basename(options.inputFilename || options.moduleName || (options.outfile ? path$1.dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path$1.dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path$1.basename(options.inputFilename || options.moduleName || (options.outfile ? path$1.dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -285,27 +389,37 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path$1.normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path$1.normalize(path$1.join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5.stringify(dump, null, 2); + let d = JSON5.stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp(path$1.dirname(dumpfile)); fs.writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -315,7 +429,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -323,7 +437,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -349,27 +463,43 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -382,9 +512,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -406,22 +537,22 @@ assert(recast); // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; -// Determine which Unicode NonAsciiIdentifierStart characters +// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -429,40 +560,40 @@ const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -470,30 +601,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -504,59 +635,59 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -598,38 +729,38 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -641,18 +772,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -663,56 +794,56 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -720,97 +851,97 @@ function generateMapper4JisonGrammarIdentifiers(input) { typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp(`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp(`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp(`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp(`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp(`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp(`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp(`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp(`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp(`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp(`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp(`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -818,7 +949,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -831,7 +962,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -844,7 +975,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -857,7 +988,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -876,37 +1007,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -938,7 +1069,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -955,37 +1086,37 @@ function parseCodeChunkToAST(src, options) { .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast.parse(src); + const ast = recast.parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return transformSync(src, options); // => { code, map, ast } @@ -993,8 +1124,8 @@ function compileCodeToES5(src, options) { function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1003,7 +1134,7 @@ function prettyPrintAST(ast, options) { // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1026,25 +1157,25 @@ function prettyPrintAST(ast, options) { // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1055,9 +1186,9 @@ function checkActionBlock(src, yylloc, options) { // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1065,7 +1196,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1074,14 +1205,14 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1135,7 +1266,7 @@ var parse2AST = { trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1149,7 +1280,7 @@ function chkBugger$1(src) { /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1161,24 +1292,24 @@ const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?: /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1195,8 +1326,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1207,14 +1338,14 @@ function printFunctionSourceCodeContainer(f) { action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1225,17 +1356,17 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; -// -// -// +// +// +// function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1261,7 +1392,7 @@ function detectIstanbulGlobal() { // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1309,7 +1440,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1372,13 +1503,13 @@ var reHelpers = { getRegExpInfo: getRegExpInfo }; -var cycleref = []; -var cyclerefpath = []; +let cycleref = []; +let cyclerefpath = []; -var linkref = []; -var linkrefpath = []; +let linkref = []; +let linkrefpath = []; -var path = []; +let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1386,14 +1517,14 @@ function shallow_copy(src) { return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1406,11 +1537,11 @@ function shallow_copy(src) { function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1423,9 +1554,9 @@ function shallow_copy_and_strip_depth(src, parentKey) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1440,16 +1571,52 @@ function shallow_copy_and_strip_depth(src, parentKey) { } +// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } +// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; +} + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1464,7 +1631,7 @@ function trim_array_tail(arr) { function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1490,10 +1657,10 @@ function treat_value_stack(v) { } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1591,7 +1758,7 @@ function treat_hash(h) { function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1608,7 +1775,7 @@ function treat_error_report_info(e) { path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1636,7 +1803,7 @@ function treat_error_report_info(e) { function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1652,7 +1819,7 @@ function treat_object(e) { linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1664,14 +1831,14 @@ function treat_object(e) { // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1681,7 +1848,7 @@ function trimErrorForTestReporting(e) { cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1695,12 +1862,14 @@ var index = { dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1715,7 +1884,7 @@ var index = { printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; export default index; diff --git a/packages/helpers-lib/dist/helpers-lib-umd-es5.js b/packages/helpers-lib/dist/helpers-lib-umd-es5.js index 116810127..16e19230c 100644 --- a/packages/helpers-lib/dist/helpers-lib-umd-es5.js +++ b/packages/helpers-lib/dist/helpers-lib-umd-es5.js @@ -1,6 +1,6 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('fs'), require('path'), require('@gerhobbelt/json5'), require('@gerhobbelt/xregexp'), require('recast'), require('@babel/core'), require('assert')) : typeof define === 'function' && define.amd ? define(['fs', 'path', '@gerhobbelt/json5', '@gerhobbelt/xregexp', 'recast', '@babel/core', 'assert'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['jison-helpers-lib'] = factory(global.fs, global.path$1, global.JSON5, global.XRegExp, global.recast, global.babel, global.assert)); -})(this, function (fs, path$1, JSON5, XRegExp, recast, babel, assert) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('fs'), require('path'), require('@gerhobbelt/json5'), require('mkdirp'), require('@gerhobbelt/xregexp'), require('recast'), require('@babel/core'), require('assert')) : typeof define === 'function' && define.amd ? define(['fs', 'path', '@gerhobbelt/json5', 'mkdirp', '@gerhobbelt/xregexp', 'recast', '@babel/core', 'assert'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['jison-helpers-lib'] = factory(global.fs, global.path$1, global.JSON5, global.mkdirp, global.XRegExp, global.recast, global.babel, global.assert)); +})(this, function (fs, path$1, JSON5, mkdirp, XRegExp, recast, babel, assert) { 'use strict'; function _interopDefaultLegacy(e) { @@ -15,11 +15,13 @@ var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); + var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); + var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); - var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert); // Return TRUE if `src` starts with `searchString`. + var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert); // Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { @@ -42,18 +44,18 @@ // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -71,18 +73,20 @@ // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); // Done removing common indentation. - // + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; // only correct indentation at start of line, i.e. only check for + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -91,17 +95,20 @@ } // now merge everything to construct the template result: - var rv = []; + { + let rv = []; + let i = 0; - for (var i = 0, len = values.length; i < len; i++) { - rv.push(src[i].join('\n')); - rv.push(values[i]); - } // the last value is always followed by a last template string partial: + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + rv.push(src[i].join('\n')); + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` /** @public */ @@ -112,8 +119,8 @@ return s.replace(/^\w/, function (match) { return match.toLowerCase(); }).replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; @@ -121,18 +128,30 @@ return rv; }); - } // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers + } // https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words + + + const reservedWords = (list => { + let rv = new Set(); + + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + + return rv; + })(['await', 'break', 'case', 'catch', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'enum', 'export', 'extends', 'finally', 'for', 'function', 'if', 'implements', 'import', 'in', 'instanceof', 'interface', 'new', 'package', 'private', 'protected', 'public', 'return', 'super', 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'yield']); // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -144,6 +163,12 @@ .replace(/^[^\w_]/, '_') // do not accept numerics at the leading position, despite those matching regex `\w`: .replace(/^\d/, '_').replace(/[^\w\d_]/g, '_') // and only accept multiple (double, not triple) underscores at start or end of identifier name: .replace(/^__+/, '#').replace(/__+$/, '#').replace(/_+/g, '_').replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + + return rv; } // Check if the start of the given input matches a regex expression. // Return the length of the regex expression or -1 if none was found. @@ -153,13 +178,13 @@ function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; @@ -179,13 +204,11 @@ if (ch === ']') { classMarker = false; } - } else { - if (ch === '/') { - terminated = true; - break; - } else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } @@ -209,12 +232,12 @@ function isLegalIdentifierInput(s) { - s = '' + s; // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + s = '' + s; // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s.replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -222,14 +245,14 @@ return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = s.indexOf('\'') >= 0; - var dq = s.indexOf('"') >= 0; + let sq = s.indexOf('\'') >= 0; + let dq = s.indexOf('"') >= 0; if (sq && dq) { s = s.replace(/"/g, '\\"'); @@ -257,48 +280,104 @@ function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); + } + + function convertExceptionToObject(ex) { + if (!ex) return ex; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + + let rv = Object.assign({}, ex); // - Set up the default fields which should ALWAYS be present: + + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + + if (Array.isArray(ex.errors)) { + rv.errors = []; + + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + + return rv; + } + + function find_suitable_app_dump_path() { + return process.cwd().replace(/\\/g, '/').replace(/\/node_modules\/.*$/, m => '/___nm___/').replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map(d => d.charAt(0).toUpperCase()).join('_')); } // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [options.outfile ? path__default['default'].dirname(options.outfile) : null, options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname).replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + const dumpPaths = [options.outfile ? path__default['default'].dirname(options.outfile) : null, options.inputPath, find_suitable_app_dump_path()]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname).replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; + } // generate a stacktrace for the dump no matter what: + + + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } } err_id = err_id || 'XXX'; - var ts = new Date(); - var tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + '' + pad(ts.getUTCMinutes()) + '' + pad(ts.getUTCSeconds()) + '.' + pad(ts.getUTCMilliseconds(), 3) + 'Z'; + err_id = err_id.replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + '' + pad(ts.getUTCMinutes()) + '' + pad(ts.getUTCSeconds()) + '.' + pad(ts.getUTCMilliseconds(), 3) + 'Z'; dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); - let dump = { + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); + const dump = { errname, err_id, options, - ex + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); // make sure each line is a comment line: + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]' + }); // make sure each line is a comment line: d = d.split('\n').map(l => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -308,7 +387,7 @@ } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -339,25 +418,40 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; } - const debug = 0; - var p; + const debug = options.debug || 0; + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); + } + + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + if (debug > 1) console.log('exec-and-diagnose options:', options); + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } @@ -370,9 +464,10 @@ return p; } - var code_exec = { + var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject }; // assert__default['default'](recast__default['default']); //var types = recast.types; @@ -386,18 +481,18 @@ // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! - const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries + const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: - const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; // Determine which Unicode NonAsciiIdentifierStart characters + const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; // Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. - // + // // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action - // code chunks. - // + // code chunks. + // // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -407,37 +502,37 @@ // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -445,30 +540,30 @@ // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -479,58 +574,58 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -575,27 +670,27 @@ return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: - const typeIdCharSets = ["ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", + const typeIdCharSets = ['ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ"]; //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ']; //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -606,18 +701,18 @@ hash[i] = (hash[i] || 0) + 1; } // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -628,56 +723,56 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); @@ -685,7 +780,7 @@ for (let i = 0, l = typeIdCharSets.length; i < l; i++) { typeIdChar[i] = pickChar(typeIdCharSets[i]); - } // produce a function set for encoding and decoding content, + } // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: @@ -693,57 +788,57 @@ return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction @@ -754,10 +849,10 @@ re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -840,10 +935,10 @@ re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -852,19 +947,19 @@ // p1 is only serving as lookbehind emulation switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -906,7 +1001,7 @@ function parseCodeChunkToAST(src, options) { src = src.replace(/@/g, '\uFFDA').replace(/#/g, '\uFFDB'); - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } @@ -921,13 +1016,13 @@ sourceRoot: '.', sourceType: 'module', babelrc: false, - ignore: ["node_modules/**/*.js"], + ignore: ['node_modules/**/*.js'], compact: false, retainLines: false, - presets: [["@babel/preset-env", { + presets: [['@babel/preset-env', { targets: { - browsers: ["last 2 versions"], - node: "8.0" + browsers: ['last 2 versions'], + node: '8.0' } }]] }, options); @@ -935,7 +1030,7 @@ } function prettyPrintAST(ast, options) { - var options = options || {}; + options = options || {}; const defaultOptions = { tabWidth: 2, quote: 'single', @@ -945,7 +1040,7 @@ reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -958,16 +1053,16 @@ .replace(/\uFFDA/g, '@').replace(/\uFFDB/g, '#'); return new_src; } // validate the given JISON+JavaScript snippet: does it compile? - // - // Return either the parsed AST (object) or an error message (string). + // + // Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; } @@ -976,19 +1071,19 @@ } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } // The rough-and-ready preprocessor for any action code block: // this one trims off any surplus whitespace and removes any // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. - // + // // Returns the trimmed sourcecode which was provided via `src`. - // + // // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -996,7 +1091,7 @@ // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: - // + // // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1005,16 +1100,16 @@ // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} - // + // // Of course the example would be 'ludicrous' action code but the - // key point here is that users will certainly be able to come up with + // key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! - // + // function trimActionCode(src, startMarker) { - var s = src.trim(); // remove outermost set of braces UNLESS there's + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated // code analyzer to simplify the code! @@ -1079,7 +1174,7 @@ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1087,25 +1182,25 @@ const funcRe = /^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/; const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/; /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. - /// + /// /// Also supports ES6's Arrow Functions: - /// + /// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' - /// + /// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; // Also cope with Arrow Functions (and inline those as well?). + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); @@ -1125,8 +1220,8 @@ if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1137,7 +1232,7 @@ action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } @@ -1152,14 +1247,14 @@ var stringifier = { printFunctionSourceCode, printFunctionSourceCodeContainer - }; // - // - // + }; // + // + // function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } // // Helper library for safe code execution/compilation @@ -1182,7 +1277,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { - var re; // were we fed a RegExp object or a string? + let re; // were we fed a RegExp object or a string? if (re_src && typeof re_src.source === 'string' && typeof re_src.flags === 'string' && typeof re_src.toString === 'function' && typeof re_src.test === 'function' && typeof re_src.exec === 'function') { // we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member @@ -1226,7 +1321,7 @@ function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; // were we fed a RegExp object or a string? + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src && typeof re_src.source === 'string' && typeof re_src.flags === 'string' && typeof re_src.toString === 'function' && typeof re_src.test === 'function' && typeof re_src.exec === 'function') { // we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member @@ -1274,11 +1369,11 @@ checkRegExp: checkRegExp, getRegExpInfo: getRegExpInfo }; - var cycleref = []; - var cyclerefpath = []; - var linkref = []; - var linkrefpath = []; - var path = []; + let cycleref = []; + let cyclerefpath = []; + let linkref = []; + let linkrefpath = []; + let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1286,7 +1381,7 @@ return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; @@ -1294,7 +1389,7 @@ dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1308,12 +1403,12 @@ function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1327,9 +1422,9 @@ dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; @@ -1344,12 +1439,44 @@ } return src; - } + } // strip developer machine specific parts off any paths in a given stacktrace (string) + // to ease cross-platform comparison of these stacktraces. + function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: - msg = msg.replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)').replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + msg = msg.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; + } // strip off the line/position info from any stacktrace as a assert.deepEqual() on these + // will otherwise FAIL due to us running this stuff through both regular `node` and + // the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing + // exceptions and stacktraces which point completely somewhere else and this would b0rk + // our test rigs for the jison subpackages. + + + function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + + let keys = Object.keys(obj); + + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + + return obj; } function trim_array_tail(arr) { @@ -1366,7 +1493,7 @@ function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; @@ -1393,11 +1520,11 @@ } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1544,7 +1671,7 @@ function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. @@ -1570,7 +1697,7 @@ return e; } // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. - // + // // Internal use in the unit test rigs. @@ -1602,10 +1729,12 @@ dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, compileCodeToES5: parse2AST.compileCodeToES5, diff --git a/packages/helpers-lib/dist/helpers-lib-umd.js b/packages/helpers-lib/dist/helpers-lib-umd.js index 4ca28fb77..c07b3c20c 100644 --- a/packages/helpers-lib/dist/helpers-lib-umd.js +++ b/packages/helpers-lib/dist/helpers-lib-umd.js @@ -1,19 +1,20 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('fs'), require('path'), require('@gerhobbelt/json5'), require('@gerhobbelt/xregexp'), require('recast'), require('@babel/core'), require('assert')) : - typeof define === 'function' && define.amd ? define(['fs', 'path', '@gerhobbelt/json5', '@gerhobbelt/xregexp', 'recast', '@babel/core', 'assert'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['jison-helpers-lib'] = factory(global.fs, global.path$1, global.JSON5, global.XRegExp, global.recast, global.babel, global.assert)); -}(this, (function (fs, path$1, JSON5, XRegExp, recast, babel, assert) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('fs'), require('path'), require('@gerhobbelt/json5'), require('mkdirp'), require('@gerhobbelt/xregexp'), require('recast'), require('@babel/core'), require('assert')) : + typeof define === 'function' && define.amd ? define(['fs', 'path', '@gerhobbelt/json5', 'mkdirp', '@gerhobbelt/xregexp', 'recast', '@babel/core', 'assert'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['jison-helpers-lib'] = factory(global.fs, global.path$1, global.JSON5, global.mkdirp, global.XRegExp, global.recast, global.babel, global.assert)); +}(this, (function (fs, path$1, JSON5, mkdirp, XRegExp, recast, babel, assert) { 'use strict'; function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); + var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert); - // Return TRUE if `src` starts with `searchString`. + // Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -36,19 +37,19 @@ // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -67,19 +68,21 @@ // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -88,16 +91,19 @@ } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -108,27 +114,79 @@ return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } + // https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words + const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; + })([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' + ]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -146,6 +204,11 @@ .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -154,13 +217,13 @@ function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -171,23 +234,17 @@ break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -210,34 +267,33 @@ /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -260,28 +316,76 @@ // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } + function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; + } + + + function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); + } + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -292,27 +396,37 @@ dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -322,7 +436,7 @@ } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -330,7 +444,7 @@ ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -356,27 +470,43 @@ // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -389,9 +519,10 @@ - var code_exec = { + var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -413,22 +544,22 @@ // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; - // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries + // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; - // Determine which Unicode NonAsciiIdentifierStart characters + // Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. - // + // // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action - // code chunks. - // + // code chunks. + // // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -436,40 +567,40 @@ function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -477,30 +608,30 @@ // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -511,59 +642,59 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -605,38 +736,38 @@ return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -648,18 +779,18 @@ // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -670,56 +801,56 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -727,97 +858,97 @@ typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -825,7 +956,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -838,7 +969,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -851,7 +982,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -864,7 +995,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -883,37 +1014,37 @@ let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -945,7 +1076,7 @@ // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -962,37 +1093,37 @@ .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return babel.transformSync(src, options); // => { code, map, ast } @@ -1000,8 +1131,8 @@ function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1010,7 +1141,7 @@ // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1033,25 +1164,25 @@ // validate the given JISON+JavaScript snippet: does it compile? - // - // Return either the parsed AST (object) or an error message (string). + // + // Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1062,9 +1193,9 @@ // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. - // + // // Returns the trimmed sourcecode which was provided via `src`. - // + // // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1072,7 +1203,7 @@ // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: - // + // // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1081,14 +1212,14 @@ // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} - // + // // Of course the example would be 'ludicrous' action code but the - // key point here is that users will certainly be able to come up with + // key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! - // + // function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1142,7 +1273,7 @@ trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1156,7 +1287,7 @@ /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1168,24 +1299,24 @@ /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. - /// + /// /// Also supports ES6's Arrow Functions: - /// + /// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' - /// + /// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1202,8 +1333,8 @@ if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1214,14 +1345,14 @@ action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1232,17 +1363,17 @@ var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; - // - // - // + // + // + // function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1268,7 +1399,7 @@ // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1316,7 +1447,7 @@ // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1379,13 +1510,13 @@ getRegExpInfo: getRegExpInfo }; - var cycleref = []; - var cyclerefpath = []; + let cycleref = []; + let cyclerefpath = []; - var linkref = []; - var linkrefpath = []; + let linkref = []; + let linkrefpath = []; - var path = []; + let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1393,14 +1524,14 @@ return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1413,11 +1544,11 @@ function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1430,9 +1561,9 @@ dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1447,16 +1578,52 @@ } + // strip developer machine specific parts off any paths in a given stacktrace (string) + // to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } + // strip off the line/position info from any stacktrace as a assert.deepEqual() on these + // will otherwise FAIL due to us running this stuff through both regular `node` and + // the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing + // exceptions and stacktraces which point completely somewhere else and this would b0rk + // our test rigs for the jison subpackages. + function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; + } + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1471,7 +1638,7 @@ function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1497,10 +1664,10 @@ } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1598,7 +1765,7 @@ function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1615,7 +1782,7 @@ path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1643,7 +1810,7 @@ function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1659,7 +1826,7 @@ linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1671,14 +1838,14 @@ // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. - // + // // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1688,7 +1855,7 @@ cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1702,12 +1869,14 @@ dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1722,7 +1891,7 @@ printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; return index; diff --git a/packages/jison-lex/dist/cli-cjs-es5.js b/packages/jison-lex/dist/cli-cjs-es5.js index fae8968cb..50df9acb6 100644 --- a/packages/jison-lex/dist/cli-cjs-es5.js +++ b/packages/jison-lex/dist/cli-cjs-es5.js @@ -1,7 +1,7 @@ #!/usr/bin/env node -'use strict';var fs=require('fs');var path$1=require('path');var nomnom=require('@gerhobbelt/nomnom');var JSON5=require('@gerhobbelt/json5');var XRegExp=require('@gerhobbelt/xregexp');var recast=require('recast');var babel=require('@babel/core');var assert$1=require('assert');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e};}var fs__default=/*#__PURE__*/_interopDefaultLegacy(fs);var path__default=/*#__PURE__*/_interopDefaultLegacy(path$1);var nomnom__default=/*#__PURE__*/_interopDefaultLegacy(nomnom);var JSON5__default=/*#__PURE__*/_interopDefaultLegacy(JSON5);var XRegExp__default=/*#__PURE__*/_interopDefaultLegacy(XRegExp);var recast__default=/*#__PURE__*/_interopDefaultLegacy(recast);var assert__default=/*#__PURE__*/_interopDefaultLegacy(assert$1);// Return TRUE if `src` starts with `searchString`. +'use strict';var fs=require('fs');var path$1=require('path');var nomnom=require('@gerhobbelt/nomnom');var JSON5=require('@gerhobbelt/json5');var mkdirp=require('mkdirp');var XRegExp=require('@gerhobbelt/xregexp');var recast=require('recast');var babel=require('@babel/core');var assert$1=require('assert');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e};}var fs__default=/*#__PURE__*/_interopDefaultLegacy(fs);var path__default=/*#__PURE__*/_interopDefaultLegacy(path$1);var nomnom__default=/*#__PURE__*/_interopDefaultLegacy(nomnom);var JSON5__default=/*#__PURE__*/_interopDefaultLegacy(JSON5);var mkdirp__default=/*#__PURE__*/_interopDefaultLegacy(mkdirp);var XRegExp__default=/*#__PURE__*/_interopDefaultLegacy(XRegExp);var recast__default=/*#__PURE__*/_interopDefaultLegacy(recast);var assert__default=/*#__PURE__*/_interopDefaultLegacy(assert$1);// Return TRUE if `src` starts with `searchString`. function startsWith(src,searchString){return src.substr(0,searchString.length)===searchString;}// tagged template string helper which removes the indentation common to all // non-empty lines: that indentation was added as part of the source code // formatting of this lexer spec file and must be removed to produce what @@ -17,62 +17,72 @@ function startsWith(src,searchString){return src.substr(0,searchString.length)== function rmCommonWS(strings,...values){// As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. -// +// // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. -var indent_str=null;var src=strings.map(function splitIntoLines(s){var a=s.split('\n');indent_str=a.reduce(function analyzeLine(indent_str,line,index){// only check indentation of parts which follow a NEWLINE: -if(index!==0){var m=/^(\s*)\S/.exec(line);// only non-empty ~ content-carrying lines matter re common indent calculus: +let indent_str=null;let src=strings.map(function splitIntoLines(s){let a=s.split('\n');indent_str=a.reduce(function analyzeLine(indent_str,line,index){// only check indentation of parts which follow a NEWLINE: +if(index!==0){let m=/^(\s*)\S/.exec(line);// only non-empty ~ content-carrying lines matter re common indent calculus: if(m){if(indent_str==null){indent_str=m[1];}else if(m[1].length start at j=1 rather than j=0 -for(var j=1,linecnt=a.length;j `'camelsHaveOneHump'` +for(let j=1,linecnt=a.length;j `'camelsHaveOneHump'` /** @public */function camelCase(s){// Convert first character to lowercase -return s.replace(/^\w/,function(match){return match.toLowerCase();}).replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// do not mutate 'a-2' to 'a2': -if(c===rv&&c.match(/\d/)){return match;}return rv;});}// Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers -/** @public */function mkIdentifier(s){s=''+s;return s// Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), +return s.replace(/^\w/,function(match){return match.toLowerCase();}).replace(/-\w/g,function(match){const c=match.charAt(1);const rv=c.toUpperCase();// do not mutate 'a-2' to 'a2': +if(c===rv&&c.match(/\d/)){return match;}return rv;});}// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords=(list=>{let rv=new Set();for(let w of list){//console.error('reserved word:', w); +rv.add(w);}return rv;})(['await','break','case','catch','class','const','continue','debugger','default','delete','do','else','enum','export','extends','finally','for','function','if','implements','import','in','instanceof','interface','new','package','private','protected','public','return','super','switch','this','throw','try','typeof','var','void','while','with','yield']);// Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers +/** @public */function mkIdentifier(s){s=''+s;let rv=s// Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` -.replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// mutate 'a-2' to 'a_2': +.replace(/-\w/g,function(match){let c=match.charAt(1);let rv=c.toUpperCase();// mutate 'a-2' to 'a_2': if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;})// cleanup: replace any non-suitable character series to a single underscore: .replace(/^([\d])/,'_$1')// where leading numbers are prefixed by an underscore: '1' --> '_1' .replace(/^[^\w_]/,'_')// do not accept numerics at the leading position, despite those matching regex `\w`: .replace(/^\d/,'_').replace(/[^\w\d_]/g,'_')// and only accept multiple (double, not triple) underscores at start or end of identifier name: -.replace(/^__+/,'#').replace(/__+$/,'#').replace(/_+/g,'_').replace(/#/g,'__');}// Check if the start of the given input matches a regex expression. +.replace(/^__+/,'#').replace(/__+$/,'#').replace(/_+/g,'_').replace(/#/g,'__');if(reservedWords.has(rv)){rv='_'+rv;}return rv;}// Check if the start of the given input matches a regex expression. // Return the length of the regex expression or -1 if none was found. /** @public */function scanRegExp(s){s=''+s;// code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` -var index=0;var length=s.length;var ch=s[index];//assert.assert(ch === '/', 'Regular expression literal must start with a slash'); -var str=s[index++];var classMarker=false;var terminated=false;while(index `'camelsHaveOneHump'` -let ref=s.replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// mutate 'a-2' to 'a_2': -if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;});var alt=mkIdentifier(s);return alt===ref;}// properly quote and escape the given input string -function dquote(s){var sq=s.indexOf('\'')>=0;var dq=s.indexOf('"')>=0;if(sq&&dq){s=s.replace(/"/g,'\\"');dq=false;}if(dq){s='\''+s+'\'';}else{s='"'+s+'"';}return s;}// +let ref=s.replace(/-\w/g,function(match){let c=match.charAt(1);let rv=c.toUpperCase();// mutate 'a-2' to 'a_2': +if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;});let alt=mkIdentifier(s);return alt===ref;}// properly quote and escape the given input string +function dquote(s){let sq=s.indexOf('\'')>=0;let dq=s.indexOf('"')>=0;if(sq&&dq){s=s.replace(/"/g,'\\"');dq=false;}if(dq){s='\''+s+'\'';}else{s='"'+s+'"';}return s;}// function chkBugger(src){src=String(src);if(src.match(/\bcov_\w+/)){console.error('### ISTANBUL COVERAGE CODE DETECTED ###\n',src);}}// Helper function: pad number with leading zeroes -function pad(n,p){p=p||2;var rv='0000'+n;return rv.slice(-p);}// attempt to dump in one of several locations: first winner is *it*! -function dumpSourceToFile(sourcecode,errname,err_id,options,ex){var dumpfile;options=options||{};try{var dumpPaths=[options.outfile?path__default['default'].dirname(options.outfile):null,options.inputPath,process.cwd()];var dumpName=path__default['default'].basename(options.inputFilename||options.moduleName||(options.outfile?path__default['default'].dirname(options.outfile):null)||options.defaultModuleName||errname).replace(/\.[a-z]{1,5}$/i,'')// remove extension .y, .yacc, .jison, ...whatever -.replace(/[^a-z0-9_]/ig,'_');// make sure it's legal in the destination filesystem: the least common denominator. -if(dumpName===''||dumpName==='_'){dumpName='__bugger__';}err_id=err_id||'XXX';var ts=new Date();var tm=ts.getUTCFullYear()+'_'+pad(ts.getUTCMonth()+1)+'_'+pad(ts.getUTCDate())+'T'+pad(ts.getUTCHours())+''+pad(ts.getUTCMinutes())+''+pad(ts.getUTCSeconds())+'.'+pad(ts.getUTCMilliseconds(),3)+'Z';dumpName+='.fatal_'+err_id+'_dump_'+tm+'.js';for(var i=0,l=dumpPaths.length;i'// '+l);d=d.join('\n');fs__default['default'].writeFileSync(dumpfile,sourcecode+'\n\n\n'+d,'utf8');console.error("****** offending generated "+errname+" source code dumped into file: ",dumpfile);break;// abort loop once a dump action was successful! +function pad(n,p){p=p||2;let rv='0000'+n;return rv.slice(-p);}function convertExceptionToObject(ex){if(!ex)return ex;// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error +// +// - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) +let rv=Object.assign({},ex);// - Set up the default fields which should ALWAYS be present: +rv.message=ex.message;rv.name=ex.name;rv.stack=ex.stack;// this assignment stringifies the stack trace in ex.stack. +// - Set the optional fields: +if(ex.code!==undefined)rv.code=ex.code;if(ex.type!==undefined)rv.type=ex.type;if(ex.fileName!==undefined)rv.fileName=ex.fileName;if(ex.lineNumber!==undefined)rv.lineNumber=ex.lineNumber;if(ex.columnNumber!==undefined)rv.columnNumber=ex.columnNumber;if(Array.isArray(ex.errors)){rv.errors=[];for(let se of ex.errors){rv.errors.push(convertExceptionToObject(se));}}return rv;}function find_suitable_app_dump_path(){return process.cwd().replace(/\\/g,'/').replace(/\/node_modules\/.*$/,m=>'/___nm___/').replace(/(\/jison\/)(.*)$/,(m,p1,p2)=>p1+'___'+p2.split('/').map(d=>d.charAt(0).toUpperCase()).join('_'));}// attempt to dump in one of several locations: first winner is *it*! +function dumpSourceToFile(sourcecode,errname,err_id,options,ex){let dumpfile;options=options||{};try{const dumpPaths=[options.outfile?path__default['default'].dirname(options.outfile):null,options.inputPath,find_suitable_app_dump_path()];let dumpName=path__default['default'].basename(options.inputFilename||options.moduleName||(options.outfile?path__default['default'].dirname(options.outfile):null)||options.defaultModuleName||errname).replace(/\.[a-z]{1,5}$/i,'')// remove extension .y, .yacc, .jison, ...whatever +.replace(/[^a-z0-9_]/ig,'_')// make sure it's legal in the destination filesystem: the least common denominator. +.substr(0,100);if(dumpName===''||dumpName==='_'){dumpName='__bugger__';}// generate a stacktrace for the dump no matter what: +if(!ex){try{throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this.");}catch(ex2){ex=ex2;}}err_id=err_id||'XXX';err_id=err_id.replace(/[^a-z0-9_]/ig,'_')// make sure it's legal in the destination filesystem: the least common denominator. +.substr(0,50);const ts=new Date();const tm=ts.getUTCFullYear()+'_'+pad(ts.getUTCMonth()+1)+'_'+pad(ts.getUTCDate())+'T'+pad(ts.getUTCHours())+''+pad(ts.getUTCMinutes())+''+pad(ts.getUTCSeconds())+'.'+pad(ts.getUTCMilliseconds(),3)+'Z';dumpName+='.fatal_'+err_id+'_dump_'+tm+'.js';for(let i=0,l=dumpPaths.length;i'[!circular ref!]'});// make sure each line is a comment line: +d=d.split('\n').map(l=>'// '+l);d=d.join('\n');mkdirp__default['default'](path__default['default'].dirname(dumpfile));fs__default['default'].writeFileSync(dumpfile,sourcecode+'\n\n\n'+d,'utf8');console.error('****** offending generated '+errname+' source code dumped into file: ',dumpfile);break;// abort loop once a dump action was successful! }catch(ex3){//console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); -if(i===l-1){throw ex3;}}}}catch(ex2){console.error("generated "+errname+" source code fatal DUMPING error: ",ex2.message," -- while attempting to dump into file: ",dumpfile,"\n",ex2.stack);}// augment the exception info, when available: +if(i===l-1){throw ex3;}}}}catch(ex2){console.error('generated '+errname+' source code fatal DUMPING error: ',ex2.message,' -- while attempting to dump into file: ',dumpfile,'\n',ex2.stack);}// augment the exception info, when available: if(ex){ex.offending_source_code=sourcecode;ex.offending_source_title=errname;ex.offending_source_dumpfile=dumpfile;}}// // `code_execution_rig` is a function which gets executed, while it is fed the `sourcecode` as a parameter. // When the `code_execution_rig` crashes, its failure is caught and (using the `options`) the sourcecode @@ -91,8 +101,12 @@ if(ex){ex.offending_source_code=sourcecode;ex.offending_source_title=errname;ex. // - options.moduleName // - options.defaultModuleName // -function exec_and_diagnose_this_stuff(sourcecode,code_execution_rig,options,title){options=options||{};var errname=""+(title||"exec_test");var err_id=errname.replace(/[^a-z0-9_]/ig,"_");if(err_id.length===0){err_id="exec_crash";}const debug=0;var p;try{// p = eval(sourcecode); -if(typeof code_execution_rig!=='function'){throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function");}chkBugger(sourcecode);p=code_execution_rig.call(this,sourcecode,options,errname,debug);}catch(ex){if(options.dumpSourceCodeOnFailure||1){dumpSourceToFile(sourcecode,errname,err_id,options,ex);}if(options.throwErrorOnCompileFailure){throw ex;}}return p;}var code_exec={exec:exec_and_diagnose_this_stuff,dump:dumpSourceToFile};// +function exec_and_diagnose_this_stuff(sourcecode,code_execution_rig,options,title){options=options||{};let errname=''+(title||'exec_test');let err_id=errname.replace(/[^a-z0-9_]/ig,'_');if(err_id.length===0){err_id='exec_crash';}const debug=options.debug||0;if(debug)console.warn('generated '+errname+' code under EXEC TEST.');if(debug>1){console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `);}let p;try{// p = eval(sourcecode); +if(typeof code_execution_rig!=='function'){throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function');}chkBugger(sourcecode);p=code_execution_rig.call(this,sourcecode,options,errname,debug);}catch(ex){if(debug>1)console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@');if(debug)console.log('generated '+errname+' source code fatal error: ',ex.message);if(debug>1)console.log('exec-and-diagnose options:',options);if(debug>1)console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@');if(options.dumpSourceCodeOnFailure||1){dumpSourceToFile(sourcecode,errname,err_id,options,ex);}if(options.throwErrorOnCompileFailure){throw ex;}}return p;}var exec={exec:exec_and_diagnose_this_stuff,dump:dumpSourceToFile,convertExceptionToObject};// assert__default['default'](recast__default['default']);//var types = recast.types; //assert(types); //var namedTypes = types.namedTypes; @@ -103,17 +117,17 @@ assert__default['default'](recast__default['default']);//var types = recast.type // WARNING: this regex MUST match the regex for `ID` in ebnf-parser::bnf.l jison language lexer spec! (`ID = [{ALPHA}]{ALNUM}*`) // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! -const ID_REGEX_BASE='[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*';// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +const ID_REGEX_BASE='[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*';// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: -const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode NonAsciiIdentifierStart characters +const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -121,37 +135,37 @@ const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode Non function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); -// As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode +// As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: -// +// // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything -// between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is +// between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. -// +// // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. -// +// // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: -// +// // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A -// +// // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. -// -// To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to +// +// To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the -// first character is fixed and the second character is chosen such that the escape code -// DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input +// first character is fixed and the second character is chosen such that the escape code +// DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: -// -// - the first character is ဩ which is highly visible and allows us to quickly search through a +// +// - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -159,30 +173,30 @@ function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only wan // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will -// pick a different base shape from that CANADIAN SYLLABICS charset. -// - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to +// pick a different base shape from that CANADIAN SYLLABICS charset. +// - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ -// - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered +// - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: -// +// // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 -// - 1489-14A0: ᒉ 5 -// - 14A3-14BA: ᒣ 6 -// - 14C0-14CF: ᓀ +// - 1489-14A0: ᒉ 5 +// - 14A3-14BA: ᒣ 6 +// - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 -// - 1526-153D: ᔦ +// - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -193,58 +207,58 @@ function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only wan // - 1622-162D: ᘢ // // ## JISON identifier formats ## -// +// // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. -// +// // -> (1+2) start-# + end-# -// +// // - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ -// +// // - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# -// +// // - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# -// +// // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - result location reference `@$` -// +// // -> (6) single-@ -// +// // - rule id number `#$` -// +// // -> (3) single-# -// +// // - result stack index `##$` -// +// // -> (4) double-# -// +// // - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -// +// // - 'negative index' location reference, e.g. `@-2` -// +// // -> (7) single-negative-@ -// +// // - 'negative index' stack indexes, e.g. `##-2` -// +// // -> (5) double-negative-# -// +// // count the number of occurrences of ch in src: -// +// // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -261,38 +275,38 @@ function countOccurrences(ch,src){let i=ch.codePointAt(0);return hash[i]||0;}// // Preferrably has ZERO occurrences in the given `input`, but otherwise // deliver the one with the least number of occurrences. function pickChar(set,input){// strip out the spaces: -set=set.replace(/\s+/g,'');assert__default['default'](set.length>=1);let lsidx=0;let lsfreq=Infinity;for(let i=0,l=set.length;i=1);let lsidx=0;let lsfreq=Infinity;for(let i=0,l=set.length;i (1+2) start-# + end-# -// +// // - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ -// +// // - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# -// +// // - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# -// +// // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - result location reference `@$` -// +// // -> (6) single-@ -// +// // - rule id number `#$` -// +// // -> (3) single-# -// +// // - result stack index `##$` -// +// // -> (4) double-# -// +// // - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -// +// // - 'negative index' location reference, e.g. `@-2` -// +// // -> (7) single-negative-@ -// +// // - 'negative index' stack indexes, e.g. `##-2` -// +// // -> (5) double-negative-# -// -const escChar=pickChar(escCharSet);let typeIdChar=[];for(let i=0,l=typeIdCharSets.length;i (1) start-# tokenDirectIdentifierStart:escChar+typeIdChar[0],tokenDirectIdentifierRe:new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`,'g'),// - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart:'$',tokenValueReferenceRe:new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`,'g'),// - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ // - result location reference `@$` -// +// // -> (6) single-@ tokenLocationStart:escChar+typeIdChar[1],tokenLocationRe:new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`,'g'),// - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# // - rule id number `#$` -// +// // -> (3) single-# tokenIdentifierStart:escChar+typeIdChar[2],tokenIdentifierRe:new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`,'g'),// - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# // - result stack index `##$` -// +// // -> (4) double-# tokenStackIndexStart:escChar+typeIdChar[3],tokenStackIndexRe:new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`,'g'),// - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -tokenNegativeValueReferenceStart:escChar+typeIdChar[4],tokenValueReferenceRe:new XRegExp__default['default'](`$-([0-9]+)`,'g'),// - 'negative index' location reference, e.g. `@-2` -// +tokenNegativeValueReferenceStart:escChar+typeIdChar[4],tokenValueReferenceRe:new XRegExp__default['default']('$-([0-9]+)','g'),// - 'negative index' location reference, e.g. `@-2` +// // -> (7) single-negative-@ -tokenNegativeLocationStart:escChar+typeIdChar[5],tokenNegativeLocationRe:new XRegExp__default['default'](`@-([0-9]+)`,'g'),// - 'negative index' stack indexes, e.g. `##-2` -// +tokenNegativeLocationStart:escChar+typeIdChar[5],tokenNegativeLocationRe:new XRegExp__default['default']('@-([0-9]+)','g'),// - 'negative index' stack indexes, e.g. `##-2` +// // -> (5) double-negative-# -tokenNegativeStackIndexStart:escChar+typeIdChar[6],tokenNegativeStackIndexRe:new XRegExp__default['default'](`#-([0-9]+)`,'g'),// combined regex for encoding direction +tokenNegativeStackIndexStart:escChar+typeIdChar[6],tokenNegativeStackIndexRe:new XRegExp__default['default']('#-([0-9]+)','g'),// combined regex for encoding direction tokenDetect4EncodeRe:new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`,'g'),// combined regex for decoding direction tokenDetect4DecodeRe:new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`,'g'),encode:function encodeJisonTokens(src,locationOffsetSpec){let re=this.tokenDetect4EncodeRe;// reset regex re.lastIndex=0;// patch `src` for the lookbehind emulation in the main regex used: src=' '+src;// Perform the encoding, one token at a time via callback function. -// +// // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. -// This is a tad sub-optimal as we won't be able to report errors early +// This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -415,35 +429,35 @@ if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax return src.substring(1);},decode:function decodeJisonTokens(src,locationOffsetSpec){let re=this.tokenDetect4DecodeRe;// reset regex re.lastIndex=0;// patch `src` for the lookbehind emulation in the main regex used: src=' '+src;// Perform the encoding, one token at a time via callback function. -// +// // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. -// This is a tad sub-optimal as we won't be able to report errors early +// This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src=src.replace(re,(m,p1,p2,p3,offset)=>{// p1 is only serving as lookbehind emulation -switch(p2){case this.tokenNegativeValueReferenceStart:return p1+"$-"+p3;case this.tokenNegativeStackIndexStart:return p1+"##-"+p3;case this.tokenStackIndexStart:return p1+"##"+p3;case this.tokenNegativeLocationStart:return p1+"@-"+p3;case this.tokenLocationStart:return p1+"@"+p3;case this.tokenDirectIdentifierStart:// p3 CANNOT be a negative value or token ID +switch(p2){case this.tokenNegativeValueReferenceStart:return p1+'$-'+p3;case this.tokenNegativeStackIndexStart:return p1+'##-'+p3;case this.tokenStackIndexStart:return p1+'##'+p3;case this.tokenNegativeLocationStart:return p1+'@-'+p3;case this.tokenLocationStart:return p1+'@'+p3;case this.tokenDirectIdentifierStart:// p3 CANNOT be a negative value or token ID if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: ${p2+p3+p4} is an illegal negative reference type`,src,offset+p1.length+p2.length);}return p1+p2+p3;}return p1+'#'+p3+'#';case this.tokenIdentifierStart:// p3 CANNOT be a negative value or token ID if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: ${p2+p3+p4} is an illegal negative reference type`,src,offset+p1.length+p2.length);}return p1+p2+p3;}return p1+'#'+p3;default:if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: unexpected jison token sentinel escape ${p2} at ${p2+p3}`,src,offset+p1.length);}return p1+p2+p3;}});// and remove the added prefix which was used for lookbehind emulation: -return src.substring(1);}};}function parseCodeChunkToAST(src,options){src=src.replace(/@/g,'\uFFDA').replace(/#/g,'\uFFDB');var ast=recast__default['default'].parse(src);return ast;}function compileCodeToES5(src,options){options=Object.assign({},{ast:true,code:true,sourceMaps:true,comments:true,filename:'compileCodeToES5.js',sourceFileName:'compileCodeToES5.js',sourceRoot:'.',sourceType:'module',babelrc:false,ignore:["node_modules/**/*.js"],compact:false,retainLines:false,presets:[["@babel/preset-env",{targets:{browsers:["last 2 versions"],node:"8.0"}}]]},options);return babel.transformSync(src,options);// => { code, map, ast } -}function prettyPrintAST(ast,options){var options=options||{};const defaultOptions={tabWidth:2,quote:'single',arrowParensAlways:true,// Do not reuse whitespace (or anything else, for that matter) +return src.substring(1);}};}function parseCodeChunkToAST(src,options){src=src.replace(/@/g,'\uFFDA').replace(/#/g,'\uFFDB');const ast=recast__default['default'].parse(src);return ast;}function compileCodeToES5(src,options){options=Object.assign({},{ast:true,code:true,sourceMaps:true,comments:true,filename:'compileCodeToES5.js',sourceFileName:'compileCodeToES5.js',sourceRoot:'.',sourceType:'module',babelrc:false,ignore:['node_modules/**/*.js'],compact:false,retainLines:false,presets:[['@babel/preset-env',{targets:{browsers:['last 2 versions'],node:'8.0'}}]]},options);return babel.transformSync(src,options);// => { code, map, ast } +}function prettyPrintAST(ast,options){options=options||{};const defaultOptions={tabWidth:2,quote:'single',arrowParensAlways:true,// Do not reuse whitespace (or anything else, for that matter) // when printing generically. -reuseWhitespace:false};for(var key in defaultOptions){if(options[key]===undefined){options[key]=defaultOptions[key];}}let s=recast__default['default'].prettyPrint(ast,defaultOptions);let new_src=s.code;new_src=new_src.replace(/\r\n|\n|\r/g,'\n')// platform dependent EOL fixup +reuseWhitespace:false};for(let key in defaultOptions){if(options[key]===undefined){options[key]=defaultOptions[key];}}let s=recast__default['default'].prettyPrint(ast,defaultOptions);let new_src=s.code;new_src=new_src.replace(/\r\n|\n|\r/g,'\n')// platform dependent EOL fixup // backpatch possible jison variables extant in the prettified code: .replace(/\uFFDA/g,'@').replace(/\uFFDB/g,'#');return new_src;}// validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src,yylloc,options){// make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: -if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cnt);src=lines.join('\n')+src;}if(!src.trim()){return false;}try{var rv=parseCodeChunkToAST(src,options);return false;}catch(ex){return ex.message||"code snippet cannot be parsed";}}// The rough-and-ready preprocessor for any action code block: +if(yylloc&&yylloc.first_line>0){let cnt=yylloc.first_line;let lines=new Array(cnt);src=lines.join('\n')+src;}if(!src.trim()){return false;}try{let rv=parseCodeChunkToAST(src,options);return false;}catch(ex){return ex.message||'code snippet cannot be parsed';}}// The rough-and-ready preprocessor for any action code block: // this one trims off any surplus whitespace and removes any // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -451,7 +465,7 @@ if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cn // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -460,13 +474,13 @@ if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cn // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// -function trimActionCode(src,startMarker){var s=src.trim();// remove outermost set of braces UNLESS there's +// +function trimActionCode(src,startMarker){let s=src.trim();// remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated // code analyzer to simplify the code! @@ -498,34 +512,34 @@ s=s.replace(/^\{([^]*?)\}$/,'$1').trim();}else{// code may not be wrapped or oth // wrapping braces when we can guarantee they're the only ones there, // i.e. only exist as outer wrapping. s=s.replace(/^\{([^}]*)\}$/,'$1').trim();}s=s.replace(/;+$/,'').trim();return s;}var parse2AST={generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST,compileCodeToES5,prettyPrintAST,checkActionBlock,trimActionCode,ID_REGEX_BASE,IN_ID_CHARSET};function chkBugger$1(src){src=String(src);if(src.match(/\bcov_\w+/)){console.error('### ISTANBUL COVERAGE CODE DETECTED ###\n',src);}}/// HELPER FUNCTION: print the function in source code form, properly indented. -/** @public */function printFunctionSourceCode(f){var src=String(f);chkBugger$1(src);return src;}const funcRe=/^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/;const arrowFuncRe=/^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/;/// HELPER FUNCTION: print the function **content** in source code form, properly indented, +/** @public */function printFunctionSourceCode(f){const src=String(f);chkBugger$1(src);return src;}const funcRe=/^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/;const arrowFuncRe=/^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/;/// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// -/** @public */function printFunctionSourceCodeContainer(f){var action=printFunctionSourceCode(f).trim();var args;// Also cope with Arrow Functions (and inline those as well?). +/// +/** @public */function printFunctionSourceCodeContainer(f){let action=printFunctionSourceCode(f).trim();let args;// Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 -var m=funcRe.exec(action);if(m){args=m[1].trim();action=m[2].trim();}else{m=arrowFuncRe.exec(action);if(m){if(m[2]){// non-bracketed arguments: +let m=funcRe.exec(action);if(m){args=m[1].trim();action=m[2].trim();}else{m=arrowFuncRe.exec(action);if(m){if(m[2]){// non-bracketed arguments: args=m[2].trim();}else{// bracketed arguments: may be empty args list! args=m[1].trim();}if(m[5]){// non-bracketed version: implicit `return` statement! // -// Q: Must we make sure we have extra braces around the return value -// to prevent JavaScript from inserting implit EOS (End Of Statement) +// Q: Must we make sure we have extra braces around the return value +// to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already // have formatted the code correctly. -action=m[4].trim();action='return '+action+';';}else{action=m[3].trim();}}else{var e=new Error('Cannot extract code from function');e.subject=action;throw e;}}return{args:args,code:action};}var stringifier={printFunctionSourceCode,printFunctionSourceCodeContainer};// -// -// -function detectIstanbulGlobal(){const gcv="__coverage__";const globalvar=new Function('return this')();var coverage=globalvar[gcv];return coverage||false;}// +action=m[4].trim();action='return '+action+';';}else{action=m[3].trim();}}else{const e=new Error('Cannot extract code from function');e.subject=action;throw e;}}return{args:args,code:action};}var stringifier={printFunctionSourceCode,printFunctionSourceCodeContainer};// +// +// +function detectIstanbulGlobal(){const gcv='__coverage__';const globalvar=new Function('return this')();const coverage=globalvar[gcv];return coverage||false;}// // Helper library for safe code execution/compilation // // MIT Licensed @@ -543,7 +557,7 @@ function detectIstanbulGlobal(){const gcv="__coverage__";const globalvar=new Fun // The default assumed is the standard JavaScript `RegExp` class. // // Return FALSE when there's no failure, otherwise return an `Error` info object. -function checkRegExp(re_src,re_flags,XRegExp){var re;// were we fed a RegExp object or a string? +function checkRegExp(re_src,re_flags,XRegExp){let re;// were we fed a RegExp object or a string? if(re_src&&typeof re_src.source==='string'&&typeof re_src.flags==='string'&&typeof re_src.toString==='function'&&typeof re_src.test==='function'&&typeof re_src.exec==='function'){// we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member // and the `.toString()` method to produce something that's compileable by XRegExp // at least... @@ -557,7 +571,7 @@ if(re_src==null){return new Error('invalid regular expression source: '+re_src); // The default assumed is the standard JavaScript `RegExp` class. // // Return FALSE when the input is not a legal regex. -function getRegExpInfo(re_src,re_flags,XRegExp){var re1,re2,m1,m2;// were we fed a RegExp object or a string? +function getRegExpInfo(re_src,re_flags,XRegExp){let re1,re2,m1,m2;// were we fed a RegExp object or a string? if(re_src&&typeof re_src.source==='string'&&typeof re_src.flags==='string'&&typeof re_src.toString==='function'&&typeof re_src.test==='function'&&typeof re_src.exec==='function'){// we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member // and the `.toString()` method to produce something that's compileable by XRegExp // at least... @@ -569,33 +583,42 @@ return false;}else{re_src=''+re_src;if(re_flags==null){re_flags=undefined;// `ne // wrap it and append `(?:)` to ensure it matches // the empty string, then match it against it to // obtain the `match` array. -re1=new XRegExp(re_src,re_flags);re2=new XRegExp('(?:'+re_src+')|(?:)',re_flags);m1=re1.exec('');m2=re2.exec('');return{acceptsEmptyString:!!m1,captureCount:m2.length-1};}catch(ex){return false;}}var reHelpers={checkRegExp:checkRegExp,getRegExpInfo:getRegExpInfo};var cycleref=[];var cyclerefpath=[];var linkref=[];var linkrefpath=[];var path=[];function shallow_copy(src){if(typeof src==='object'){if(src instanceof Array){return src.slice();}var dst={};if(src instanceof Error){dst.name=src.name;dst.message=src.message;dst.stack=src.stack;}for(var k in src){if(Object.prototype.hasOwnProperty.call(src,k)){dst[k]=src[k];}}return dst;}return src;}function shallow_copy_and_strip_depth(src,parentKey){if(typeof src==='object'){var dst;if(src instanceof Array){dst=src.slice();for(var i=0,len=dst.length;i '+parentKey+'.'+k+']';}else{dst[k]=src[k];}}}}return dst;}return src;}function stripErrorStackPaths(msg){// strip away devbox-specific paths in error stack traces in the output: -msg=msg.replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi,'at $1(/$2)').replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi,'at /$1');return msg;}function trim_array_tail(arr){if(arr instanceof Array){for(var len=arr.length;len>0;len--){if(arr[len-1]!=null){break;}}arr.length=len;}}function treat_value_stack(v){if(v instanceof Array){var idx=cycleref.indexOf(v);if(idx>=0){v='[cyclic reference to parent array --> '+cyclerefpath[idx]+']';}else{idx=linkref.indexOf(v);if(idx>=0){v='[reference to sibling array --> '+linkrefpath[idx]+', length = '+v.length+']';}else{cycleref.push(v);cyclerefpath.push(path.join('.'));linkref.push(v);linkrefpath.push(path.join('.'));v=treat_error_infos_array(v);cycleref.pop();cyclerefpath.pop();}}}else if(v){v=treat_object(v);}return v;}function treat_error_infos_array(arr){var inf=arr.slice();trim_array_tail(inf);for(var key=0,len=inf.length;key '+parentKey+'.'+k+']';}else{dst[k]=src[k];}}}}return dst;}return src;}// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. +function stripErrorStackPaths(msg){// strip away devbox-specific paths in error stack traces in the output: +// and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': +msg=msg.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi,'at $1(/$2:$3)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi,'at /$1:$2');return msg;}// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj){if(typeof obj==='string'){// and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': +let msg=obj.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi,'at $1(/$2)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi,'at /$1');return msg;}if(obj){if(obj.stack){obj.stack=cleanStackTrace4Comparison(obj.stack);}let keys=Object.keys(obj);for(let i in keys){let key=keys[i];let el=obj[key];cleanStackTrace4Comparison(el);}}return obj;}function trim_array_tail(arr){if(arr instanceof Array){for(var len=arr.length;len>0;len--){if(arr[len-1]!=null){break;}}arr.length=len;}}function treat_value_stack(v){if(v instanceof Array){let idx=cycleref.indexOf(v);if(idx>=0){v='[cyclic reference to parent array --> '+cyclerefpath[idx]+']';}else{idx=linkref.indexOf(v);if(idx>=0){v='[reference to sibling array --> '+linkrefpath[idx]+', length = '+v.length+']';}else{cycleref.push(v);cyclerefpath.push(path.join('.'));linkref.push(v);linkrefpath.push(path.join('.'));v=treat_error_infos_array(v);cycleref.pop();cyclerefpath.pop();}}}else if(v){v=treat_object(v);}return v;}function treat_error_infos_array(arr){let inf=arr.slice();trim_array_tail(inf);for(let key=0,len=inf.length;key=0){// cyclic reference, most probably an error instance. +e=shallow_copy(e);if(e&&e.hash){path.push('hash');e.hash=treat_hash(e.hash);path.pop();}if(e.parser){path.push('parser');e.parser=treat_parser(e.parser);path.pop();}if(e.lexer){path.push('lexer');e.lexer=treat_lexer(e.lexer);path.pop();}if(e.__error_infos){path.push('__error_infos');e.__error_infos=treat_value_stack(e.__error_infos);path.pop();}if(e.__error_recovery_infos){path.push('__error_recovery_infos');e.__error_recovery_infos=treat_value_stack(e.__error_recovery_infos);path.pop();}trim_array_tail(e.symbol_stack);trim_array_tail(e.state_stack);trim_array_tail(e.location_stack);if(e.value_stack){path.push('value_stack');e.value_stack=treat_value_stack(e.value_stack);path.pop();}return e;}function treat_object(e){if(e&&typeof e==='object'){let idx=cycleref.indexOf(e);if(idx>=0){// cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: e=shallow_copy_and_strip_depth(e,cyclerefpath[idx]);}else{idx=linkref.indexOf(e);if(idx>=0){e='[reference to sibling --> '+linkrefpath[idx]+']';}else{cycleref.push(e);cyclerefpath.push(path.join('.'));linkref.push(e);linkrefpath.push(path.join('.'));e=treat_error_report_info(e);cycleref.pop();cyclerefpath.pop();}}}return e;}// strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. -function trimErrorForTestReporting(e){cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];if(e){e=treat_object(e);}cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];return e;}var helpers={rmCommonWS,camelCase,mkIdentifier,isLegalIdentifierInput,scanRegExp,dquote,trimErrorForTestReporting,stripErrorStackPaths,checkRegExp:reHelpers.checkRegExp,getRegExpInfo:reHelpers.getRegExpInfo,exec:code_exec.exec,dump:code_exec.dump,generateMapper4JisonGrammarIdentifiers:parse2AST.generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST:parse2AST.parseCodeChunkToAST,compileCodeToES5:parse2AST.compileCodeToES5,prettyPrintAST:parse2AST.prettyPrintAST,checkActionBlock:parse2AST.checkActionBlock,trimActionCode:parse2AST.trimActionCode,ID_REGEX_BASE:parse2AST.ID_REGEX_BASE,IN_ID_CHARSET:parse2AST.IN_ID_CHARSET,printFunctionSourceCode:stringifier.printFunctionSourceCode,printFunctionSourceCodeContainer:stringifier.printFunctionSourceCodeContainer,detectIstanbulGlobal};// See also: +function trimErrorForTestReporting(e){cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];if(e){e=treat_object(e);}cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];return e;}var helpers={rmCommonWS,camelCase,mkIdentifier,isLegalIdentifierInput,scanRegExp,dquote,trimErrorForTestReporting,stripErrorStackPaths,cleanStackTrace4Comparison,checkRegExp:reHelpers.checkRegExp,getRegExpInfo:reHelpers.getRegExpInfo,exec:exec.exec,dump:exec.dump,convertExceptionToObject:exec.convertExceptionToObject,generateMapper4JisonGrammarIdentifiers:parse2AST.generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST:parse2AST.parseCodeChunkToAST,compileCodeToES5:parse2AST.compileCodeToES5,prettyPrintAST:parse2AST.prettyPrintAST,checkActionBlock:parse2AST.checkActionBlock,trimActionCode:parse2AST.trimActionCode,ID_REGEX_BASE:parse2AST.ID_REGEX_BASE,IN_ID_CHARSET:parse2AST.IN_ID_CHARSET,printFunctionSourceCode:stringifier.printFunctionSourceCode,printFunctionSourceCodeContainer:stringifier.printFunctionSourceCodeContainer,detectIstanbulGlobal};// 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. -function JisonParserError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonParserError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8/Chrome engine +function JisonParserError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonParserError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){let ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8/Chrome engine Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonParserError.prototype,Error.prototype);}else{JisonParserError.prototype=Object.create(Error.prototype);}JisonParserError.prototype.constructor=JisonParserError;JisonParserError.prototype.name='JisonParserError';// helper: reconstruct the productions[] table -function bp(s){var rv=[];var p=s.pop;var r=s.rule;for(var i=0,l=p.length;i1){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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) +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 delimited set of lexer start conditions';break;case 37:/*! Production:: start_productions_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -yy.__options_flags__=0;yy.__options_category_description__='the lexer rules definition section';break;case 38:/*! Production:: start_epilogue_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -yy.__options_flags__=0;yy.__options_category_description__='the lexer epilogue section';break;case 39:/*! Production:: rules : rules scoped_rules_collective */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1].concat(yyvstack[yysp]);break;case 40:/*! Production:: rules : rules rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1].concat([yyvstack[yysp]]);break;case 41:/*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 30:/*! Production:: option_keyword : OPTIONS */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__=yyvstack[yysp];break;case 31:/*! Production:: import_keyword : IMPORT */case 33:/*! Production:: include_keyword : INCLUDE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS;yy.__options_category_description__=yyvstack[yysp];break;case 32:/*! Production:: init_code_keyword : CODE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS|OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS;yy.__options_category_description__=yyvstack[yysp];break;case 34:/*! Production:: start_inclusive_keyword : START_INC */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__='the inclusive lexer start conditions set (%s)';break;case 35:/*! Production:: start_exclusive_keyword : START_EXC */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__='the exclusive lexer start conditions set (%x)';break;case 36:/*! Production:: start_conditions_marker : "<" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES|OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME;yy.__options_category_description__='the <...> delimited set of lexer start conditions';break;case 37:/*! Production:: start_productions_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=0;yy.__options_category_description__='the lexer rules definition section';break;case 38:/*! Production:: start_epilogue_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=0;yy.__options_category_description__='the lexer epilogue section';break;case 39:/*! Production:: rules : rules scoped_rules_collective */ // 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].concat(yyvstack[yysp]);break;case 40:/*! Production:: rules : rules rule */ // 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].concat([yyvstack[yysp]]);break;case 41:/*! Production:: rules : rules 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]);if(srcCode){var rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);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);}this.$=yyvstack[yysp-3];break;case 42:/*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);}yy.actionInclude.push(srcCode);}this.$=yyvstack[yysp-3];break;case 42:/*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. -this.$=yyvstack[yysp-1];break;case 43:/*! Production:: rules : rules ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) +this.$=yyvstack[yysp-1];break;case 43:/*! Production:: rules : rules ACTION_START_AT_SOL 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,-,-) 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. @@ -1039,8 +1062,8 @@ var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or simila Technical error report: ${yyvstack[yysp].errStr} - `);this.$=yyvstack[yysp-2];break;case 44:/*! Production:: rules : rules ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);this.$=yyvstack[yysp-2];break;case 44:/*! Production:: rules : rules 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,-,-) 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: @@ -1068,8 +1091,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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 the top section of the lexer spec file, above the first '%%' @@ -1078,14 +1101,14 @@ yyparser.yyError(rmCommonWS$1` Erroneous code: ${yylexer.prettyPrintRange(yylstack[yysp])} - `);this.$=yyvstack[yysp-1];break;case 51:/*! Production:: rules : %epsilon */case 58:/*! Production:: rule_block : %epsilon */ // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) -this.$=[];break;case 52:/*! Production:: scoped_rules_collective : start_conditions rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -if(yyvstack[yysp-1]){yyvstack[yysp].unshift(yyvstack[yysp-1]);}this.$=[yyvstack[yysp]];break;case 53:/*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) -if(yyvstack[yysp-3]){yyvstack[yysp-1].forEach(function(d){d.unshift(yyvstack[yysp-3]);});}this.$=yyvstack[yysp-1];break;case 54:/*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp-3];this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + `);this.$=yyvstack[yysp-1];break;case 51:/*! Production:: rules : %epsilon */case 58:/*! Production:: rule_block : %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 52:/*! Production:: scoped_rules_collective : start_conditions rule */ // 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,-,-) +if(yyvstack[yysp-1]){yyvstack[yysp].unshift(yyvstack[yysp-1]);}this.$=[yyvstack[yysp]];break;case 53:/*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ // 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,-,-) +if(yyvstack[yysp-3]){yyvstack[yysp-1].forEach(function(d){d.unshift(yyvstack[yysp-3]);});}this.$=yyvstack[yysp-1];break;case 54:/*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): +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$1` Seems you made a mistake while specifying one of the lexer rules inside the start condition @@ -1097,8 +1120,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp-1].errStr} - `);break;case 55:/*! Production:: scoped_rules_collective : start_conditions "{" error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 55:/*! Production:: scoped_rules_collective : start_conditions "{" 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,-,-) yyparser.yyError(rmCommonWS$1` Seems you did not correctly bracket a lexer rules set inside the start condition @@ -1110,8 +1133,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 56:/*! Production:: scoped_rules_collective : start_conditions error "}" */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 56:/*! Production:: scoped_rules_collective : start_conditions 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,-,-) yyparser.yyError(rmCommonWS$1` Seems you did not correctly bracket a lexer rules set inside the start condition @@ -1123,17 +1146,17 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp-1].errStr} - `);break;case 57:/*! Production:: rule_block : rule_block rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 57:/*! Production:: rule_block : rule_block rule */ // 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.$.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` 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 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 // will uncover any illegal action code following the arrow operator, e.g. // multiple statements separated by semicolon. @@ -1154,8 +1177,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 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.: @@ -1170,8 +1193,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 63:/*! Production:: rule : regex ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);break;case 63:/*! Production:: rule : regex 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,-,-) // TODO: REWRITE this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` A lexer rule regex action code must be properly terminated and must contain a JavaScript statement block (or anything that does parse as such), e.g.: @@ -1188,8 +1211,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 64:/*! Production:: rule : regex ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);break;case 64:/*! Production:: rule : regex ACTION_START_AT_SOL 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,-,-) // TODO: REWRITE this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` A lexer rule regex action code must be properly terminated and must contain a JavaScript statement block (or anything that does parse as such), e.g.: @@ -1225,8 +1248,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 65:/*! Production:: rule : regex error */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);break;case 65:/*! Production:: rule : regex 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,-,-) this.$=[yyvstack[yysp-1],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Lexer rule regex action code declaration error? @@ -1235,33 +1258,33 @@ this.$=[yyvstack[yysp-1],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 66:/*! Production:: action : action ACTION_BODY */case 83:/*! Production:: regex_concat : regex_concat regex_base */case 95:/*! Production:: regex_base : regex_base range_regex */case 106:/*! Production:: regex_set : regex_set regex_set_atom */case 127:/*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+yyvstack[yysp];break;case 67:/*! Production:: action : action include_macro_code */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'\n\n'+yyvstack[yysp]+'\n\n';break;case 68:/*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 66:/*! Production:: action : action ACTION_BODY */case 83:/*! Production:: regex_concat : regex_concat regex_base */case 95:/*! Production:: regex_base : regex_base range_regex */case 106:/*! Production:: regex_set : regex_set regex_set_atom */case 127:/*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ // 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]+yyvstack[yysp];break;case 67:/*! Production:: action : action 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]+'\n\n'+yyvstack[yysp]+'\n\n';break;case 68:/*! Production:: action : action INCLUDE_PLACEMENT_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` You may place the '%include' instruction only at the start/front of a line. Its use is not permitted at this position: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 69:/*! Production:: action : action BRACKET_MISSING */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 69:/*! Production:: action : action BRACKET_MISSING */ // 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` Missing curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: '{ ... }'. Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 70:/*! Production:: action : action BRACKET_SURPLUS */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 70:/*! Production:: action : action BRACKET_SURPLUS */ // 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` Too many curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: '{ ... }'. Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 71:/*! Production:: action : action UNTERMINATED_STRING_ERROR */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 71:/*! Production:: action : action UNTERMINATED_STRING_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` Unterminated string constant in lexer rule action block. @@ -1270,10 +1293,10 @@ yyparser.yyError(rmCommonWS$1` Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 72:/*! Production:: action : %epsilon */case 77:/*! Production:: regex_list : %epsilon */ // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0,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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 72:/*! Production:: action : %epsilon */case 77:/*! Production:: regex_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 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 // accordingly: @@ -1294,8 +1317,8 @@ 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,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,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` Seems you did not correctly terminate the start condition set @@ -1307,8 +1330,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -1347,22 +1370,22 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+'|'+yyvstack[yysp];break;case 79:/*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'|';break;case 80:/*! Production:: nonempty_regex_list : "|" regex_concat */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='|'+yyvstack[yysp];break;case 81:/*! Production:: nonempty_regex_list : "|" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='|';break;case 85:/*! Production:: regex_base : "(" regex_list ")" */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$='('+yyvstack[yysp-1]+')';break;case 86:/*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+')';break;case 87:/*! Production:: regex_base : "(" regex_list error */case 88:/*! Production:: regex_base : SPECIAL_GROUP regex_list error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) +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,-,-): +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,-,-) +this.$=yyvstack[yysp-2]+'|'+yyvstack[yysp];break;case 79:/*! Production:: nonempty_regex_list : nonempty_regex_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,-,-) +this.$=yyvstack[yysp-1]+'|';break;case 80:/*! Production:: nonempty_regex_list : "|" regex_concat */ // 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];break;case 81:/*! Production:: 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,-,-) +this.$='|';break;case 85:/*! Production:: regex_base : "(" regex_list ")" */ // 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-1]+')';break;case 86:/*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ // 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-1]+')';break;case 87:/*! Production:: regex_base : "(" regex_list error */case 88:/*! Production:: regex_base : SPECIAL_GROUP regex_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,-,-) yyparser.yyError(rmCommonWS$1` Seems you did not correctly bracket a lex rule regex part in '(...)' braces. @@ -1371,30 +1394,30 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 89:/*! Production:: regex_base : regex_base "+" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'+';break;case 90:/*! Production:: regex_base : regex_base "*" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'*';break;case 91:/*! Production:: regex_base : regex_base "?" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'?';break;case 92:/*! Production:: regex_base : "/" regex_base */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='(?='+yyvstack[yysp]+')';break;case 93:/*! Production:: regex_base : "/!" regex_base */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='(?!'+yyvstack[yysp]+')';break;case 94:/*! Production:: regex_base : name_expansion */case 96:/*! Production:: regex_base : any_group_regex */case 100:/*! Production:: regex_base : REGEX_SPECIAL_CHAR */case 101:/*! Production:: regex_base : literal_string */case 107:/*! Production:: regex_set : regex_set_atom */case 108:/*! Production:: regex_set_atom : REGEX_SET */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -break;case 97:/*! Production:: regex_base : "." */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='.';break;case 98:/*! Production:: regex_base : "^" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='^';break;case 99:/*! Production:: regex_base : "$" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='$';break;case 102:/*! Production:: regex_base : ESCAPED_CHAR */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp]));break;case 104:/*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+yyvstack[yysp];break;case 105:/*! Production:: any_group_regex : REGEX_SET_START regex_set error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 89:/*! Production:: regex_base : regex_base "+" */ // 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]+'+';break;case 90:/*! Production:: regex_base : regex_base "*" */ // 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]+'*';break;case 91:/*! Production:: regex_base : regex_base "?" */ // 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]+'?';break;case 92:/*! Production:: regex_base : "/" regex_base */ // 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]+')';break;case 93:/*! Production:: regex_base : "/!" regex_base */ // 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]+')';break;case 94:/*! Production:: regex_base : name_expansion */case 96:/*! Production:: regex_base : any_group_regex */case 100:/*! Production:: regex_base : REGEX_SPECIAL_CHAR */case 101:/*! Production:: regex_base : literal_string */case 107:/*! Production:: regex_set : regex_set_atom */case 108:/*! Production:: regex_set_atom : REGEX_SET */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +break;case 97:/*! Production:: regex_base : "." */ // 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.$='.';break;case 98:/*! Production:: regex_base : "^" */ // 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.$='^';break;case 99:/*! Production:: regex_base : "$" */ // 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.$='$';break;case 102:/*! Production:: regex_base : ESCAPED_CHAR */ // 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.$=encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp]));break;case 104:/*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_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,-,-) +this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+yyvstack[yysp];break;case 105:/*! Production:: any_group_regex : REGEX_SET_START regex_set 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,-,-) yyparser.yyError(rmCommonWS$1` Seems you did not correctly bracket a lex rule regex set in '[...]' brackets. @@ -1403,16 +1426,16 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 109:/*! Production:: regex_set_atom : name_expansion */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + `);break;case 109:/*! Production:: regex_set_atom : name_expansion */ // 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,-,-) if(XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g,''))&&yyvstack[yysp].toUpperCase()!==yyvstack[yysp]){// treat this as part of an XRegExp `\p{...}` Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) +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,-,-): +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,-,-): +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` You may only specify one name/argument in a ${yy.__options_category_description__} statement. @@ -1427,28 +1450,28 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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` You may only specify one name/argument in a ${yy.__options_category_description__} statement. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp]),yylstack[yysp-3])} - `);}this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 115:/*! Production:: option_list : option */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=[yyvstack[yysp]];break;case 116:/*! Production:: option : option_name */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=[yyvstack[yysp],true];break;case 117:/*! Production:: option : option_name "=" option_value */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);}this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 115:/*! Production:: option_list : option */ // 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 116:/*! Production:: option : 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,-,-) +this.$=[yyvstack[yysp],true];break;case 117:/*! Production:: option : option_name "=" option_value */ // 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_VALUE){yyparser.yyError(rmCommonWS$1` The entries in a ${yy.__options_category_description__} statement MUST NOT be assigned values, such as '${$option_name}=${$option_value}'. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp],yylstack[yysp-2]),yylstack[yysp-4])} - `);}this.$=[yyvstack[yysp-2],yyvstack[yysp]];break;case 118:/*! Production:: option : option_name "=" error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);}this.$=[yyvstack[yysp-2],yyvstack[yysp]];break;case 118:/*! Production:: option : option_name "=" 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$1` Internal error: option "${$option}" value assignment failure in a ${yy.__options_category_description__} statement. @@ -1458,8 +1481,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 119:/*! Production:: option : DUMMY3 error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);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` Expected a valid option name${with_value_msg} in a ${yy.__options_category_description__} statement. @@ -1468,8 +1491,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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: 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 @@ -1483,8 +1506,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. @@ -1494,21 +1517,21 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=parseValue(yyvstack[yysp]);break;case 124:/*! Production:: epilogue : start_epilogue_marker */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,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,-,-) +this.$=parseValue(yyvstack[yysp]);break;case 124:/*! Production:: epilogue : start_epilogue_marker */ // 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.$='';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` 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,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,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. @@ -1517,8 +1540,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 128:/*! Production:: epilogue_chunks : epilogue_chunks error */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);break;case 128:/*! Production:: epilogue_chunks : epilogue_chunks 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$1` Module code declaration error? @@ -1528,8 +1551,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);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` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -1538,8 +1561,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -1548,12 +1571,12 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,LU,LUbA): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA) +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`: path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$1` @@ -1580,8 +1603,8 @@ var fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});var 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,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,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. @@ -1591,14 +1614,14 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} `);break;}},table:bt({len:u([15,1,14,21,1,13,28,22,s,[9,3],13,1,9,13,c,[6,3],27,s,[31,5],1,44,4,1,13,6,25,24,25,23,23,17,17,s,[24,8],26,5,24,24,9,13,8,9,1,s,[9,5],13,9,13,c,[3,3],c,[13,3],2,1,26,26,9,26,c,[5,3],s,[26,4],7,24,4,5,8,c,[60,3],c,[59,3],s,[24,5],2,3,2,25,25,6,s,[4,3],13,7,8,4,8,13,13,s,[7,6],9,5,s,[13,3],9,1,13,9,26,26,6,1,5,9,5,5,26,17,c,[85,4],27,10,s,[24,7],4,s,[8,3],9,7,9,1,1,26,5,c,[30,3],23,27,26,9,27,9,27,9,27,1,16,7,1,13,13,5,26,15,26,s,[27,3],16,13]),symbol:u([1,2,19,22,s,[24,6,1],31,32,33,55,57,1,c,[16,13],58,c,[14,13],56,s,[59,4,1],64,65,67,c,[36,14],1,2,3,7,8,s,[13,4,1],c,[19,10],s,[40,6,1],49,50,69,2,c,[26,6],c,[16,8],75,s,[77,5,1],85,2,11,51,52,53,s,[86,4,1],c,[9,10],23,30,s,[35,5,1],73,c,[90,13],2,c,[32,9],c,[23,14],c,[63,17],c,[144,40],c,[27,5],11,c,[28,22],c,[75,3],c,[31,125],1,c,[182,25],c,[373,5],s,[66,5,2],c,[320,7],90,1,33,68,90,20,c,[276,14],7,20,22,25,34,c,[367,3],9,c,[68,4],c,[12,4],c,[62,8],c,[370,6],c,[25,19],c,[24,8],s,[10,7,1],c,[27,10],48,49,50,84,c,[49,8],c,[45,8],s,[76,6,1],c,[72,9],c,[23,15],c,[485,13],c,[17,21],c,[105,24],c,[24,189],s,[46,5,1],44,47,80,82,83,c,[79,48],11,17,21,c,[500,3],c,[729,18],17,21,25,c,[24,3],c,[8,3],18,c,[9,6],c,[10,10],c,[9,26],c,[76,22],c,[849,7],63,93,c,[796,15],c,[13,11],c,[57,22],c,[22,9],21,11,17,c,[95,4],c,[10,4],25,c,[670,27],c,[26,26],c,[981,10],c,[35,26],c,[88,52],c,[26,105],2,22,24,54,91,92,2,4,c,[1221,14],72,c,[1222,8],c,[465,3],c,[35,5],c,[1158,8],c,[8,4],c,[1307,14],c,[912,78],c,[760,117],9,2,7,9,c,[5,4],c,[152,47],84,2,44,46,47,80,83,c,[6,4],c,[4,8],c,[614,14],c,[602,6],c,[754,9],52,53,c,[12,9],c,[689,26],c,[592,7],c,[7,35],c,[1571,14],c,[82,26],c,[430,14],c,[688,8],2,c,[842,23],c,[580,56],92,c,[534,3],c,[7,3],c,[1765,11],c,[14,3],c,[5,6],c,[794,26],5,c,[630,14],71,5,c,[159,10],c,[9,17],s,[1,4,2],c,[72,24],c,[976,9],c,[628,48],c,[24,121],c,[560,4],c,[1290,10],c,[8,13],c,[205,9],c,[495,14],63,93,21,21,c,[388,31],c,[5,5],c,[1301,11],c,[14,3],c,[354,15],c,[984,8],c,[333,27],c,[100,26],c,[549,11],c,[62,25],c,[36,72],6,c,[1170,16],c,[53,7],21,c,[744,28],c,[621,29],c,[266,15],c,[745,28],c,[284,27],c,[27,52],c,[203,16],c,[182,13]]),type:u([s,[2,13],0,0,1,c,[16,14],c,[30,15],s,[0,6],s,[2,41],c,[42,16],c,[64,12],c,[9,18],c,[49,19],c,[32,16],c,[22,19],c,[145,45],s,[2,181],s,[0,18],c,[20,4],c,[62,45],c,[25,24],c,[441,40],c,[442,13],c,[23,31],c,[17,34],c,[416,210],c,[57,111],c,[76,42],c,[98,34],c,[57,22],c,[22,10],c,[165,66],c,[509,189],c,[756,25],c,[740,56],c,[912,70],c,[286,136],c,[25,29],c,[275,31],c,[240,14],c,[227,82],c,[1144,56],c,[53,22],c,[775,59],c,[58,15],c,[149,63],c,[1837,18],c,[81,35],c,[628,51],c,[1393,171],c,[197,47],c,[268,26],c,[272,64],c,[62,36],c,[36,72],s,[2,226]]),state:u([s,[1,5,1],13,15,16,8,9,6,s,[25,4,2],32,37,38,43,49,51,52,54,58,c,[4,3],60,63,c,[5,3],65,c,[4,3],67,c,[4,3],77,79,80,75,76,85,81,70,71,82,83,c,[38,6],69,81,87,90,c,[8,4],91,c,[4,3],95,97,98,c,[20,5],99,c,[7,6],100,c,[4,3],101,c,[4,3],105,102,103,108,52,54,c,[3,3],119,114,c,[8,6],c,[3,3],127,130,132,136,c,[66,7],143,c,[87,3],144,c,[67,9],95,95,105,151,152,52,54,153,155,c,[22,3],157,119,114,161,163,165,168,170,172,c,[49,3],c,[29,4],c,[67,5],119,114,182,c,[57,7],c,[12,4],119,114]),mode:u([s,[2,27],s,[1,13],c,[27,15],c,[53,38],c,[66,27],c,[46,12],c,[65,23],s,[2,197],c,[271,26],c,[340,23],c,[25,4],c,[27,6],c,[264,10],c,[20,20],c,[12,5],c,[66,18],c,[89,5],c,[102,14],s,[1,38],s,[2,218],c,[220,50],c,[274,30],c,[25,6],c,[85,37],c,[736,26],c,[52,52],c,[427,61],c,[54,34],c,[515,158],c,[696,29],c,[1120,25],c,[845,62],c,[689,122],c,[1055,8],c,[151,24],c,[24,20],c,[539,29],c,[29,12],c,[1006,79],c,[660,49],c,[45,8],c,[793,47],c,[131,31],c,[439,50],c,[44,16],c,[125,9],c,[161,22],c,[663,28],c,[599,24],c,[1703,174],c,[875,16],c,[920,43],c,[1192,22],c,[260,51],c,[123,34],c,[34,69],c,[1284,181],s,[2,51]]),goto:u([s,[7,13],s,[9,13],6,17,7,10,11,12,14,21,22,23,19,20,18,24,s,[8,13],51,26,s,[51,25],28,30,33,35,39,40,41,34,36,42,s,[44,5,1],50,55,53,56,57,59,c,[5,4],61,s,[72,7],s,[17,13],62,64,c,[27,4],s,[22,13],66,c,[18,4],68,c,[5,4],s,[29,13],s,[37,27],s,[34,31],s,[35,31],s,[30,31],s,[31,31],s,[32,31],1,4,86,c,[272,6],72,73,74,78,c,[330,5],84,c,[282,8],5,84,88,s,[11,13],75,89,s,[75,4],81,81,33,81,c,[48,4],s,[81,4],c,[42,8],82,82,33,82,c,[20,4],s,[82,4],c,[20,8],s,[84,4],92,93,94,s,[84,14],96,84,84,77,30,33,77,c,[384,12],c,[16,16],c,[413,13],c,[13,13],s,[94,24],s,[96,24],s,[97,24],s,[98,24],s,[99,24],s,[100,24],s,[101,24],s,[102,24],s,[103,26],45,104,s,[111,24],s,[112,24],55,107,106,c,[640,3],s,[13,13],s,[115,8],s,[116,3],109,s,[116,5],110,s,[120,9],s,[121,9],s,[122,9],s,[123,9],55,107,111,c,[73,3],s,[15,13],112,120,113,s,[115,4,1],s,[18,13],s,[19,13],55,107,121,c,[52,3],s,[21,13],55,107,122,c,[19,3],c,[78,3],124,c,[7,3],126,125,2,s,[39,26],s,[40,26],128,s,[72,7],s,[42,26],129,s,[45,26],s,[46,26],s,[47,26],s,[48,26],s,[49,26],s,[50,26],124,131,133,134,135,138,137,c,[1118,14],142,140,139,141,s,[38,5],c,[1071,4],s,[36,4],3,s,[10,13],79,79,33,79,c,[47,4],s,[79,4],c,[51,8],80,80,33,80,c,[20,4],s,[80,4],c,[20,8],s,[83,4],c,[845,3],s,[83,14],96,83,83,s,[89,24],s,[90,24],s,[91,24],s,[95,24],s,[110,24],146,145,76,89,76,148,147,s,[92,5],93,94,s,[92,14],96,c,[19,3],s,[93,3],c,[24,3],s,[93,14],96,93,93,150,45,149,104,s,[107,4],s,[108,4],s,[109,4],s,[12,13],c,[290,4],s,[114,8],154,56,57,s,[119,8],s,[14,13],s,[16,13],s,[66,7],s,[67,7],s,[68,7],s,[69,7],s,[70,7],s,[71,7],156,c,[92,4],s,[33,5],s,[20,13],s,[23,13],s,[24,13],158,s,[72,7],159,s,[28,13],160,c,[793,6],s,[43,26],s,[44,26],125,162,c,[541,3],126,s,[129,5],164,s,[72,7],s,[132,5],s,[133,5],s,[52,26],166,s,[58,15],167,169,s,[72,7],171,s,[72,7],173,s,[72,7],s,[65,27],175,55,107,174,c,[255,3],78,78,33,78,c,[599,4],s,[78,4],c,[599,8],s,[85,24],s,[87,24],s,[86,24],s,[88,24],s,[104,24],s,[105,24],s,[106,4],s,[113,8],s,[117,8],s,[118,8],55,107,176,c,[198,3],s,[135,7],177,c,[394,6],178,179,s,[41,26],s,[127,5],s,[128,5],180,c,[45,6],s,[131,5],181,c,[927,14],55,55,183,s,[55,24],s,[56,26],184,c,[80,6],s,[63,27],185,c,[34,6],s,[64,27],186,c,[34,6],s,[62,27],187,s,[74,16],s,[134,7],188,s,[26,13],s,[27,13],s,[130,5],s,[53,26],s,[57,15],s,[54,26],s,[59,27],s,[60,27],s,[61,27],s,[73,16],s,[25,13]])}),defaultActions:bda({idx:u([0,2,5,11,14,s,[17,8,1],28,s,[37,9,1],47,48,50,51,s,[54,4,1],59,61,62,64,69,70,71,73,s,[75,6,1],84,86,87,88,s,[92,5,1],s,[103,4,1],108,s,[110,9,1],s,[120,4,1],126,128,129,131,132,134,135,136,142,s,[145,10,1],156,160,161,162,164,s,[167,5,2],176,s,[178,11,1]]),goto:u([7,9,8,17,22,29,37,34,35,30,31,32,1,11,94,s,[96,8,1],111,112,13,115,s,[120,4,1],15,18,19,21,2,39,40,42,s,[45,6,1],38,36,3,10,89,90,91,95,110,107,108,109,12,114,119,14,16,s,[66,6,1],33,20,23,24,28,43,44,126,129,132,133,52,65,85,87,86,88,104,105,106,113,117,118,135,41,127,128,131,56,63,64,62,74,134,26,27,130,53,57,54,59,60,61,73,25])}),parseError:function parseError(str,hash,ExceptionClass){if(hash.recoverable){if(typeof this.trace==='function'){this.trace(str);}hash.destroy();// destroy... well, *almost*! -}else{if(typeof this.trace==='function'){this.trace(str);}if(!ExceptionClass){ExceptionClass=this.JisonParserError;}throw new ExceptionClass(str,hash);}},parse:function parse(input){var self=this;var stack=new Array(128);// token stack: stores token which leads to state at the same index (column storage) -var sstack=new Array(128);// state stack: stores states (column storage) -var vstack=new Array(128);// semantic value stack -var lstack=new Array(128);// location stack -var table=this.table;var sp=0;// 'stack pointer': index into the stacks -var yyloc;var symbol=0;var preErrorSymbol=0;var lastEofErrorStateDepth=Infinity;var recoveringErrorInfo=null;var recovering=0;// (only used when the grammar contains error recovery rules) -var TERROR=this.TERROR;var EOF=this.EOF;var ERROR_RECOVERY_TOKEN_DISCARD_COUNT=this.options.errorRecoveryTokenDiscardCount|0||3;var NO_ACTION=[0,189/* === table.length :: ensures that anyone using this new state will fail dramatically! */];var lexer;if(this.__lexer__){lexer=this.__lexer__;}else{lexer=this.__lexer__=Object.create(this.lexer);}var sharedState_yy={parseError:undefined,quoteName:undefined,lexer:undefined,parser:undefined,pre_parse:undefined,post_parse:undefined,pre_lex:undefined,post_lex:undefined// WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! -};var ASSERT;if(typeof assert!=='function'){ASSERT=function JisonAssert(cond,msg){if(!cond){throw new Error('assertion failed: '+(msg||'***'));}};}else{ASSERT=assert;}this.yyGetSharedState=function yyGetSharedState(){return sharedState_yy;};this.yyGetErrorInfoTrack=function yyGetErrorInfoTrack(){return recoveringErrorInfo;};// shallow clone objects & arrays, straight copy of simple `src` values +}else{if(typeof this.trace==='function'){this.trace(str);}if(!ExceptionClass){ExceptionClass=this.JisonParserError;}throw new ExceptionClass(str,hash);}},parse:function parse(input){let self=this;let stack=new Array(128);// token stack: stores token which leads to state at the same index (column storage) +let sstack=new Array(128);// state stack: stores states (column storage) +let vstack=new Array(128);// semantic value stack +let lstack=new Array(128);// location stack +let table=this.table;let sp=0;// 'stack pointer': index into the stacks +let yyloc;let symbol=0;let preErrorSymbol=0;let lastEofErrorStateDepth=Infinity;let recoveringErrorInfo=null;let recovering=0;// (only used when the grammar contains error recovery rules) +const TERROR=this.TERROR;const EOF=this.EOF;const ERROR_RECOVERY_TOKEN_DISCARD_COUNT=this.options.errorRecoveryTokenDiscardCount|0||3;const NO_ACTION=[0,189/* === table.length :: ensures that anyone using this new state will fail dramatically! */];let lexer;if(this.__lexer__){lexer=this.__lexer__;}else{lexer=this.__lexer__=Object.create(this.lexer);}let sharedState_yy={parseError:undefined,quoteName:undefined,lexer:undefined,parser:undefined,pre_parse:undefined,post_parse:undefined,pre_lex:undefined,post_lex:undefined// WARNING: must be written this way for the code expanders to work correctly! +};const ASSERT=typeof assert!=='function'?function JisonAssert(cond,msg){if(!cond){throw new Error('assertion failed: '+(msg||'***'));}}:assert;this.yyGetSharedState=function yyGetSharedState(){return sharedState_yy;};this.yyGetErrorInfoTrack=function yyGetErrorInfoTrack(){return recoveringErrorInfo;};// shallow clone objects & arrays, straight copy of simple `src` values // e.g. `lexer.yytext` MAY be a complex value object, // rather than a simple string/value. // @@ -1609,14 +1632,13 @@ var TERROR=this.TERROR;var EOF=this.EOF;var ERROR_RECOVERY_TOKEN_DISCARD_COUNT=t // function shallow_copy(src){if(src&&typeof src==='object'){// non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: -if(src.constructor!==Object){if(Array.isArray(src)){return src.slice();}var dst=new src.constructor(src);// and make sure all custom attributes are added to the clone: +if(src.constructor!==Object){if(Array.isArray(src)){return src.slice();}let dst=new src.constructor(src);// and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst,src);return dst;}// native objects must be cloned a different way: -// -//return Object.assign({}, src); -var dst={};shallow_copy_noclobber(dst,src);return dst;}return src;}// add elements from `src` to `dst` when: +{//return Object.assign({}, src); +let dst={};shallow_copy_noclobber(dst,src);return dst;}}return src;}// add elements from `src` to `dst` when: // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` -function shallow_copy_noclobber(dst,src){const chk=Object.prototype.hasOwnProperty;for(var k in src){if(!(k in dst)){if(chk.call(src,k)){dst[k]=src[k];}}else{if(src[k]!=null&&dst[k]==null&&chk.call(src,k)){dst[k]=src[k];}}}}function copy_yylloc_native(loc){var rv=shallow_copy(loc);// shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: +function shallow_copy_noclobber(dst,src){const chk=Object.prototype.hasOwnProperty;for(let k in src){if(!(k in dst)){if(chk.call(src,k)){dst[k]=src[k];}}else if(src[k]!=null&&dst[k]==null&&chk.call(src,k)){dst[k]=src[k];}}}function copy_yylloc_native(loc){let rv=shallow_copy(loc);// shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if(rv){rv.range=rv.range.slice();}return rv;}// copy state shallow_copy_noclobber(sharedState_yy,this.yy);sharedState_yy.lexer=lexer;sharedState_yy.parser=this;// allow userland code to override the yytext and yylloc copy/clone functions: this.copy_yytext=this.options.copy_yytext||sharedState_yy.copy_yytext||shallow_copy;this.copy_yylloc=this.options.copy_yylloc||sharedState_yy.copy_yylloc||copy_yylloc_native;// *Always* setup `yyError`, `YYRECOVERING`, `yyErrOk` and `yyClearIn` functions as it is paramount @@ -1625,10 +1647,10 @@ this.copy_yytext=this.options.copy_yytext||sharedState_yy.copy_yytext||shallow_c // these functions are invoked in the user action code block(s) as // their closure will still refer to the `parse()` instance which set // them up. Hence we MUST set them up at the start of every `parse()` run! -if(this.yyError){this.yyError=function yyError(str/*, ...args */){var error_rule_depth=this.options.parserErrorsAreRecoverable?locateNearestErrorRecoveryRule(state):-1;var expected=this.collect_expected_token_set(state);var hash=this.constructParseErrorInfo(str,null,expected,error_rule_depth>=0);// append to the old one? -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; +if(this.yyError){this.yyError=function yyError(str/*, ...args */){let error_rule_depth=this.options.parserErrorsAreRecoverable?locateNearestErrorRecoveryRule(state):-1;let expected=this.collect_expected_token_set(state);let hash=this.constructParseErrorInfo(str,null,expected,error_rule_depth>=0);// append to the old one? +if(recoveringErrorInfo){let esp=recoveringErrorInfo.info_stack_pointer;recoveringErrorInfo.symbol_stack[esp]=symbol;let 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;recoveringErrorInfo.info_stack_pointer=esp;}else{recoveringErrorInfo=this.shallowCopyErrorInfo(hash);recoveringErrorInfo.yyError=true;recoveringErrorInfo.errorRuleDepth=error_rule_depth;recoveringErrorInfo.recovering=recovering;}// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){hash.extra_error_attributes=args;}return this.parseError(str,hash,this.JisonParserError);};}// Does the shared state override the default `parseError` that already comes with this instance? +let args=Array.prototype.slice.call(arguments,1);if(args.length){hash.extra_error_attributes=args;}return this.parseError(str,hash,this.JisonParserError);};}// Does the shared state override the default `parseError` that already comes with this instance? if(typeof sharedState_yy.parseError==='function'){this.parseError=function parseErrorAlt(str,hash,ExceptionClass){if(!ExceptionClass){ExceptionClass=this.JisonParserError;}return sharedState_yy.parseError.call(this,str,hash,ExceptionClass);};}else{this.parseError=this.originalParseError;}// Does the shared state override the default `quoteName` that already comes with this instance? if(typeof sharedState_yy.quoteName==='function'){this.quoteName=function quoteNameAlt(id_str){return sharedState_yy.quoteName.call(this,id_str);};}else{this.quoteName=this.originalQuoteName;}// set up the cleanup function; make it an API so that external code can re-use this one in case of // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which @@ -1636,7 +1658,7 @@ if(typeof sharedState_yy.quoteName==='function'){this.quoteName=function quoteNa // // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! -this.cleanupAfterParse=function parser_cleanupAfterParse(resultValue,invoke_post_methods,do_not_nuke_errorinfos){var rv;if(invoke_post_methods){var hash;if(sharedState_yy.post_parse||this.post_parse){// create an error hash info instance: we re-use this API in a **non-error situation** +this.cleanupAfterParse=function parser_cleanupAfterParse(resultValue,invoke_post_methods,do_not_nuke_errorinfos){let rv;if(invoke_post_methods){let hash;if(sharedState_yy.post_parse||this.post_parse){// create an error hash info instance: we re-use this API in a **non-error situation** // as this one delivers all parser internals ready for access by userland code. hash=this.constructParseErrorInfo(null/* no error! */,null/* no exception! */,null,false);}if(sharedState_yy.post_parse){rv=sharedState_yy.post_parse.call(this,sharedState_yy,resultValue,hash);if(typeof rv!=='undefined')resultValue=rv;}if(this.post_parse){rv=this.post_parse.call(this,sharedState_yy,resultValue,hash);if(typeof rv!=='undefined')resultValue=rv;}// cleanup: if(hash&&hash.destroy){hash.destroy();}}if(this.__reentrant_call_depth>1)return resultValue;// do not (yet) kill the sharedState when this is a reentrant run. @@ -1648,7 +1670,7 @@ stack.length=0;// fastest way to nuke an array without overly bothering the GC sstack.length=0;lstack.length=0;vstack.length=0;sp=0;// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;for(var i=this.__error_recovery_infos.length-1;i>=0;i--){var el=this.__error_recovery_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_recovery_infos.length=0;// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array, +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;for(let i=this.__error_recovery_infos.length-1;i>=0;i--){let el=this.__error_recovery_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_recovery_infos.length=0;// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array, // hence has been destroyed already: no need to do that *twice*. if(recoveringErrorInfo){recoveringErrorInfo=undefined;}}return resultValue;};// merge yylloc info into a new yylloc instance. // @@ -1662,32 +1684,38 @@ if(recoveringErrorInfo){recoveringErrorInfo=undefined;}}return resultValue;};// // yylloc info. // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. -this.yyMergeLocationInfo=function parser_yyMergeLocationInfo(first_index,last_index,first_yylloc,last_yylloc,dont_look_back){var i1=first_index|0,i2=last_index|0;var l1=first_yylloc,l2=last_yylloc;var rv;// rules: +this.yyMergeLocationInfo=function parser_yyMergeLocationInfo(first_index,last_index,first_yylloc,last_yylloc,dont_look_back){let i1=first_index|0;let i2=last_index|0;let l1=first_yylloc;let l2=last_yylloc;let rv;// rules: // - first/last yylloc entries override first/last indexes -if(!l1){if(first_index!=null){for(var i=i1;i<=i2;i++){l1=lstack[i];if(l1){break;}}}}if(!l2){if(last_index!=null){for(var i=i2;i>=i1;i--){l2=lstack[i];if(l2){break;}}}}// - detect if an epsilon rule is being processed and act accordingly: +if(!l1){if(first_index!=null){for(let i=i1;i<=i2;i++){l1=lstack[i];if(l1){break;}}}}if(!l2){if(last_index!=null){for(let i=i2;i>=i1;i--){l2=lstack[i];if(l2){break;}}}}// - detect if an epsilon rule is being processed and act accordingly: if(!l1&&first_index==null){// epsilon rule span merger. With optional look-ahead in l2. -if(!dont_look_back){for(var i=(i1||sp)-1;i>=0;i--){l1=lstack[i];if(l1){break;}}}if(!l1){if(!l2){// when we still don't have any valid yylloc info, we're looking at an epsilon rule +if(!dont_look_back){for(let i=(i1||sp)-1;i>=0;i--){l1=lstack[i];if(l1){break;}}}if(!l1){if(!l2){// when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: -return undefined;}else{// shallow-copy L2: after all, we MAY be looking +return null;}// shallow-copy L2: after all, we MAY be looking // at unconventional yylloc info objects... -rv=this.copy_yylloc(l2);return rv;}}else{// shallow-copy L1, then adjust first col/row 1 column past the end. +rv=this.copy_yylloc(l2);return rv;}// shallow-copy L1, then adjust first col/row 1 column past the end. rv=this.copy_yylloc(l1);rv.first_line=rv.last_line;rv.first_column=rv.last_column;rv.range[0]=rv.range[1];if(l2){// shallow-mixin L2, then adjust last col/row accordingly. -shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;}}if(!l1){l1=l2;l2=null;}if(!l1){return undefined;}// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking +shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;}if(!l1){l1=l2;l2=null;}if(!l1){return null;}// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... rv=this.copy_yylloc(l1);if(l2){shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;};// NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! -this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){var pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,loc:this.copy_yylloc(lexer.yylloc),expected:expected,recoverable:recoverable,state:state,action:action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,location_stack:lstack,stack_pointer:sp,yy:sharedState_yy,lexer:lexer,parser:this,// and make sure the error info doesn't stay due to potential +this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){const pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,loc:this.copy_yylloc(lexer.yylloc),expected,recoverable,state,action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,location_stack:lstack,stack_pointer:sp,yy:sharedState_yy,lexer,parser:this,// and make sure the error info doesn't stay due to potential // ref cycle via userland code manipulations. // These would otherwise all be memory leak opportunities! // // Note that only array and object references are nuked as those // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. -destroy:function destructParseErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +destroy:function destructParseErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// info.value = null; +// info.value_stack = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;};// clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. -this.shallowCopyErrorInfo=function parser_shallowCopyErrorInfo(p){var rv=shallow_copy(p);// remove the large parts which can only cause cyclic references +this.shallowCopyErrorInfo=function parser_shallowCopyErrorInfo(p){let rv=shallow_copy(p);// remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. delete rv.sharedState_yy;delete rv.parser;delete rv.lexer;// lexer.yytext MAY be a complex value object, rather than a simple string/value: rv.value=this.copy_yytext(rv.value);// yylloc info: @@ -1739,15 +1767,15 @@ rv.value_stack=rv.value_stack.map(this.copy_yytext);// and we don't bother with // - root_failure_pointer: // copy of the `stack_pointer`... // -for(var i=rv.stack_pointer;rv.state_stack[i]!=null;i++){// empty -}rv.base_pointer=i;rv.info_stack_pointer=i;rv.root_failure_pointer=rv.stack_pointer;// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! -this.__error_recovery_infos.push(rv);return rv;};function getNonTerminalFromCode(symbol){var tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){var token=lexer.lex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){var token=lexer.fastLex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}var lex=stdLex;var state,action,r,t;var yyval={$:true,_$:undefined,yy:sharedState_yy};var p;var yyrulelen;var this_production;var newState;var retval=false;// Return the rule stack depth where the nearest error rule can be found. +{let i;for(i=rv.stack_pointer;rv.state_stack[i]!=null;i++){// empty +}rv.base_pointer=i;rv.info_stack_pointer=i;}rv.root_failure_pointer=rv.stack_pointer;// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +this.__error_recovery_infos.push(rv);return rv;};function getNonTerminalFromCode(symbol){let tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){let token=lexer.lex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){let token=lexer.fastLex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}let lex=stdLex;let state,action,r,t;let yyval={$:true,_$:undefined,yy:sharedState_yy};let p;let yyrulelen;let this_production;let newState;let retval=false;// Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. -function locateNearestErrorRecoveryRule(state){var stack_probe=sp-1;var depth=0;// try to recover from error +function locateNearestErrorRecoveryRule(state){let stack_probe=sp-1;let depth=0;// try to recover from error while(stack_probe>=0){// check for error recovery rule in this state -var t=table[state]&&table[state][TERROR]||NO_ACTION;if(t[0]){// We need to make sure we're not cycling forever: +const t=table[state]&&table[state][TERROR]||NO_ACTION;if(t[0]){// We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must // prevent the core from running forever, // e.g. when parent rules are still expecting certain input to @@ -1768,7 +1796,7 @@ state=sstack[stack_probe];++depth;}return-1;// No suitable error recovery rule a // this initial `setInput()` call: hence we can now check and decide // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: -if(typeof lexer.canIUse==='function'){var lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}yyloc=this.copy_yylloc(lexer.yylloc);lstack[sp]=yyloc;vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack +if(typeof lexer.canIUse==='function'){let lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}yyloc=this.copy_yylloc(lexer.yylloc);lstack[sp]=yyloc;vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack state=newState;// sstack[sp - 1]; // use default actions if available if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}else{// The single `==` condition below covers both these `===` comparisons in a single @@ -1778,7 +1806,7 @@ if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}els if(!symbol){symbol=lex();}// read action for current state and first input t=table[state]&&table[state][symbol]||NO_ACTION;newState=t[1];action=t[0];// handle parse error if(!action){// first see if there's any chance at hitting an error recovery rule: -var error_rule_depth=locateNearestErrorRecoveryRule(state);var errStr=null;var errSymbolDescr=this.describeSymbol(symbol)||symbol;var expected=this.collect_expected_token_set(state);if(!recovering){// Report error +let error_rule_depth=locateNearestErrorRecoveryRule(state);let errStr=null;let errSymbolDescr=this.describeSymbol(symbol)||symbol;let expected=this.collect_expected_token_set(state);if(!recovering){// Report error errStr='Parse error';if(typeof lexer.yylineno==='number'){errStr+=' on line '+(lexer.yylineno+1);}if(typeof lexer.showPosition==='function'){errStr+=':\n'+lexer.showPosition(79-10,10)+'\n';}else{errStr+=': ';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}p=this.constructParseErrorInfo(errStr,null,expected,error_rule_depth>=0);// DO NOT cleanup the old one before we start the new error info track: // the old one will *linger* on the error stack and stay alive until we // invoke the parser's cleanup API! @@ -1786,20 +1814,20 @@ recoveringErrorInfo=this.shallowCopyErrorInfo(p);r=this.parseError(p.errStr,p,th // the `recoverable` flag without properly checking first: // we always terminate the parse when there's no recovery rule available anyhow! if(!p.recoverable||error_rule_depth<0){break;}else{// TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process... -}}var esp=recoveringErrorInfo.info_stack_pointer;// just recovered from another error +}}let esp=recoveringErrorInfo.info_stack_pointer;// just recovered from another error if(recovering===ERROR_RECOVERY_TOKEN_DISCARD_COUNT&&error_rule_depth>=0){// Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc=this.copy_yylloc(lexer.yylloc);// SHIFT current lookahead and grab another recoveringErrorInfo.symbol_stack[esp]=symbol;recoveringErrorInfo.location_stack[esp]=yyloc;recoveringErrorInfo.state_stack[esp]=newState;// push state ++esp;preErrorSymbol=0;symbol=lex();}// try to recover from error -if(error_rule_depth<0){ASSERT(recovering>0,"line 897");recoveringErrorInfo.info_stack_pointer=esp;// barf a fatal hairball when we're out of look-ahead symbols and none hit a match +if(error_rule_depth<0){ASSERT(recovering>0,'Line 1048');recoveringErrorInfo.info_stack_pointer=esp;// barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: -var po=this.__error_infos[this.__error_infos.length-1];// Report error +let po=this.__error_infos[this.__error_infos.length-1];// Report error if(typeof lexer.yylineno==='number'){errStr='Parsing halted on line '+(lexer.yylineno+1)+' while starting to recover from another error';}else{errStr='Parsing halted while starting to recover from another error';}if(po){errStr+=' -- previous error which resulted in this fatal result: '+po.errStr;}else{errStr+=': ';}if(typeof lexer.showPosition==='function'){errStr+='\n'+lexer.showPosition(79-10,10)+'\n';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}p=this.constructParseErrorInfo(errStr,null,expected,false);if(po){p.extra_error_attributes=po;}r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}preErrorSymbol=symbol===TERROR?0:symbol;// save the lookahead token symbol=TERROR;// insert generic error symbol as new lookahead const EXTRA_STACK_SAMPLE_DEPTH=3;// REDUCE/COMBINE the pushed terms/tokens to a new ERROR token: -recoveringErrorInfo.symbol_stack[esp]=preErrorSymbol;if(errStr){recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,errStr:errStr,errorSymbolDescr:errSymbolDescr,expectedStr:expected,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}else{recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}recoveringErrorInfo.location_stack[esp]=this.copy_yylloc(lexer.yylloc);recoveringErrorInfo.state_stack[esp]=newState||NO_ACTION[1];++esp;recoveringErrorInfo.info_stack_pointer=esp;yyval.$=recoveringErrorInfo;yyval._$=undefined;yyrulelen=error_rule_depth;r=this.performAction.call(yyval,yyloc,NO_ACTION[1],sp-1,vstack,lstack);if(typeof r!=='undefined'){retval=r;break;}// pop off stack +recoveringErrorInfo.symbol_stack[esp]=preErrorSymbol;if(errStr){recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,errStr,errSymbolDescr,expectedStr:expected,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}else{recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}recoveringErrorInfo.location_stack[esp]=this.copy_yylloc(lexer.yylloc);recoveringErrorInfo.state_stack[esp]=newState||NO_ACTION[1];++esp;recoveringErrorInfo.info_stack_pointer=esp;yyval.$=recoveringErrorInfo;yyval._$=undefined;yyrulelen=error_rule_depth;let combineState=NO_ACTION[1];r=this.performAction.call(yyval,yyloc,combineState,sp-1,vstack,lstack);if(typeof r!=='undefined'){retval=r;break;}// pop off stack sp-=yyrulelen;// and move the top entries + discarded part of the parse stacks onto the error info stack: -for(var idx=sp-EXTRA_STACK_SAMPLE_DEPTH,top=idx+yyrulelen;idx0){recovering--;}}else{// error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: -ASSERT(recovering>0,"line 1163");symbol=preErrorSymbol;preErrorSymbol=0;// read action for current state and first input +ASSERT(recovering>0,'Line 1352');symbol=preErrorSymbol;preErrorSymbol=0;// read action for current state and first input t=table[newState]&&table[newState][symbol]||NO_ACTION;if(!t[0]||symbol===TERROR){// forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where // (simple) stuff might have been missing before the token which caused the error we're // recovering from now... @@ -1890,17 +1918,17 @@ symbol=0;}}// once we have pushed the special ERROR token value, // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! -ASSERT(preErrorSymbol===0,"line 1194");if(recovering===0){break;}continue;// reduce: +ASSERT(preErrorSymbol===0,'Line 1383');if(recovering===0){break;}continue;// reduce: case 2:this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){// signal end of error recovery loop AND end of outer parse loop +yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){// signal end of error recovery loop AND end of outer parse loop action=3;retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}sp=-2;// magic number: signal outer "fast parse loop" ACCEPT state that we already have a properly set up `retval` parser return value. break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;lstack[sp]=yyval._$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -1928,26 +1956,26 @@ break;}// should we also break out of the regular/outer parse loop, // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? -ASSERT(action!==2,"line 1272");if(!action||action===1){continue;}}}switch(action){// catch misc. parse failures: +ASSERT(action!==2,'Line 1509');if(!action||action===1){continue;}}}switch(action){// catch misc. parse failures: default:// this shouldn't happen, unless resolve defaults are off if(action instanceof Array){p=this.constructParseErrorInfo('Parse Error: multiple actions possible at state: '+state+', token: '+symbol,null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}// Another case of better safe than sorry: in case state transitions come out of another error recovery process // or a buggy LUT (LookUp Table): p=this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.',null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;// shift: case 1:stack[sp]=symbol;vstack[sp]=lexer.yytext;lstack[sp]=this.copy_yylloc(lexer.yylloc);sstack[sp]=newState;// push state -if(typeof Jison!=='undefined'&&Jison.parserDebugger){var tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;ASSERT(preErrorSymbol===0,"line 1352");// normal execution / no error -ASSERT(recovering===0,"line 1353");// normal execution / no error +if(typeof Jison!=='undefined'&&Jison.parserDebugger){let tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;ASSERT(preErrorSymbol===0,'Line 1619');// normal execution / no error +ASSERT(recovering===0,'Line 1620');// normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc=this.copy_yylloc(lexer.yylloc);continue;// reduce: -case 2:ASSERT(preErrorSymbol===0,"line 1364");// normal execution / no error -ASSERT(recovering===0,"line 1365");// normal execution / no error +case 2:ASSERT(preErrorSymbol===0,'Line 1631');// normal execution / no error +ASSERT(recovering===0,'Line 1632');// normal execution / no error this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack +yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;lstack[sp]=yyval._$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:if(sp!==-2){retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -2196,8 +2224,8 @@ return retval;},yyError:1};parser.originalParseError=parser.parseError;parser.or * @public * @constructor * @nocollapse - */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 -Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';var lexer={// Code Generator Information Report + */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){const ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 +Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';const lexer={// Code Generator Information Report // --------------------------------- // // Options: @@ -2266,7 +2294,7 @@ CRLF_Re:/\r\n?|\n/,/** * @this {RegExpLexer} */constructLexErrorInfo:function lexer_constructLexErrorInfo(msg,recoverable,show_input_position){msg=''+msg;// heuristic to determine if the error message already contains a (partial) source code dump // as produced by either `showPosition()` or `prettyPrintRange()`: -if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){var pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){var pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */var pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... +if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){const pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){const pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */const pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:this,/** * and make sure the error info doesn't stay due to potential * ref cycle via userland code manipulations. @@ -2278,7 +2306,11 @@ text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:t * * @public * @this {LexErrorInfo} - */destroy:function destructLexErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! + */destroy:function destructLexErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;},/** * handler which is invoked when a lexer error occurs. * @@ -2289,8 +2321,8 @@ this.__error_infos.push(pei);return pei;},/** * * @public * @this {RegExpLexer} - */yyerror:function yyError(str/*, ...args */){var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** + */yyerror:function yyError(str/*, ...args */){let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: +let args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** * final cleanup function for when we have completed lexing the input; * make it an API so that external code can use this one once userland * code has decided it's time to destroy any lingering lexer error @@ -2305,13 +2337,13 @@ var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_a this.setInput('',{});// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** * clear the lexer token context; intended for internal use only * * @public * @this {RegExpLexer} */clear:function lexer_clear(){this.yytext='';this.yyleng=0;this.match='';// - DO NOT reset `this.matched` -this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** +this.matches=false;this._more=false;this._backtrack=false;const col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** * resets the lexer, sets new input * * @public @@ -2320,10 +2352,10 @@ this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.la // including expansion work to be done to go from a loaded // lexer to a usable lexer: if(!this.__decompressed){// step 1: decompress the regex list: -var rules=this.rules;for(var i=0,len=rules.length;i> tokens and perform user action code for a <> match, but only does so *once*) -return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}var ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). +return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}let ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. -var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;var ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** +let slice_len=1;let lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;const ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** * unshifts one char (or an entire string) into the input * * @public * @this {RegExpLexer} - */unput:function lexer_unput(ch){var len=ch.length;var lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** + */unput:function lexer_unput(ch){let len=ch.length;let lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** // The `offset` value MAY be negative if you `unput()` more text than you have already lexed. // This type of behaviour is generally observed for one kind of 'lexer/parser hack' // where custom token-illiciting characters are pushed in front of the input stream to help @@ -2393,11 +2425,11 @@ var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lin if(-this.offset>this.base_position){this.base_position=-this.offset;}this.match=this.match.substr(0,this.match.length-len);this.matched=this.matched.substr(0,this.matched.length-len);if(lines.length>1){this.yylineno-=lines.length-1;this.yylloc.last_line=this.yylineno+1;// Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. -var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** +let pre=this.match;let pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -2407,8 +2439,8 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */lookAhead:function lexer_lookAhead(){return this._input||'';},/** @@ -2425,7 +2457,7 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 */reject:function lexer_reject(){if(this.options.backtrack_lexer){this._backtrack=true;}else{// when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. -var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** +let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** * retain first n characters of the match * * @public @@ -2447,17 +2479,17 @@ var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yyl * * @public * @this {RegExpLexer} - */pastInput:function lexer_pastInput(maxSize,maxLines){var past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0)maxSize=Infinity;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=Infinity;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substr` anticipation: treat \r\n as a single character and take a little + */pastInput:function lexer_pastInput(maxSize,maxLines){let past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0){maxSize=Infinity;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=Infinity;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past=past.substr(-maxSize*2-2);// now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: -var a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, +let a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, // do add an ellipsis prefix... if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -2483,18 +2515,18 @@ if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} - */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){var next=this.match;var source=this._input||'';if(maxSize<0)maxSize=next.length+source.length;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=maxSize;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substring` anticipation: treat \r\n as a single character and take a little + */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){let next=this.match;let source=this._input||'';if(maxSize<0){maxSize=next.length+source.length;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=maxSize;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: if(next.lengthmaxSize){next=next.substring(0,maxSize)+'...';}return next;},/** @@ -2503,7 +2535,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){var pre=this.pastInput(maxPrefix).replace(/\s/g,' ');var c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** + */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){const pre=this.pastInput(maxPrefix).replace(/\s/g,' ');let c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** * return an YYLLOC info object derived off the given context (actual, preceding, following, current). * Use this method when the given `actual` location is not guaranteed to exist (i.e. when * it MAY be NULL) and you MUST have a valid location info object anyway: @@ -2519,7 +2551,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */deriveLocationInfo:function lexer_deriveYYLLOC(actual,preceding,following,current){var loc={first_line:1,first_column:0,last_line:1,last_column:0,range:[0,0]};if(actual){loc.first_line=actual.first_line|0;loc.last_line=actual.last_line|0;loc.first_column=actual.first_column|0;loc.last_column=actual.last_column|0;if(actual.range){loc.range[0]=actual.range[0]|0;loc.range[1]=actual.range[1]|0;}}if(loc.first_line<=0||loc.last_line=loc.first_line)){loc.last_line=current.last_line|0;loc.last_column=current.last_column|0;if(current.range){loc.range[1]=current.range[1]|0;}}}// sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter // or plan D heuristics to produce a 'sensible' last_line value: @@ -2568,9 +2600,9 @@ loc.range[1]=loc.range[0];}if(loc.first_column<0){loc.first_column=0;}if(loc.las * * @public * @this {RegExpLexer} - */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;var input=this.matched+(this._input||'');var lines=input.split('\n');var l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);var l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);var lineno_display_width=1+Math.log10(l1|1)|0;var ws_prefix=new Array(lineno_display_width).join(' ');var nonempty_line_indexes=[[],[],[]];var rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){var lno=index+l0;var lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);var rv=lno_pfx+': '+line;var errpfx=new Array(lineno_display_width+1).join('^');var offset=2+1;var len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it + */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;let input=this.matched+(this._input||'');let lines=input.split('\n');let l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);let l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);let lineno_display_width=1+Math.log10(l1|1)|0;let ws_prefix=new Array(lineno_display_width).join(' ');let nonempty_line_indexes=[[],[],[]];let rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){let lno=index+l0;let lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);let rv=lno_pfx+': '+line;let errpfx=new Array(lineno_display_width+1).join('^');let offset=2+1;let len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: -for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){var clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;var clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;var intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** +for(let i=0;i<=2;i++){let line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){let clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;let clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;let intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** * helper function, used to produce a human readable description as a string, given * the input `yylloc` location object. * @@ -2579,7 +2611,7 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){var l1=yylloc.first_line;var l2=yylloc.last_line;var c1=yylloc.first_column;var c2=yylloc.last_column;var dl=l2-l1;var dc=c2-c1;var rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){var r1=yylloc.range[0];var r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** + */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){let l1=yylloc.first_line;let l2=yylloc.last_line;let c1=yylloc.first_column;let c2=yylloc.last_column;let dl=l2-l1;let dc=c2-c1;let rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){let r1=yylloc.range[0];let r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** * test the lexed token: return FALSE when not a match, otherwise return token. * * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]` @@ -2596,18 +2628,18 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */test_match:function lexer_test_match(match,indexed_rule){var token,lines,backup,match_str,match_str_len;if(this.options.backtrack_lexer){// save context + */test_match:function lexer_test_match(match,indexed_rule){let backup;if(this.options.backtrack_lexer){// save context backup={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.yylloc.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column,range:this.yylloc.range.slice()},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,//_signaled_error_token: this._signaled_error_token, -yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}match_str=match[0];match_str_len=match_str.length;lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: +yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}let match_str=match[0];let match_str_len=match_str.length;let lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: // those rules will already have moved this `offset` forward matching their match lengths, // hence we must only add our own match length now: this.offset+=match_str_len;this._more=false;this._backtrack=false;this._input=this._input.slice(match_str_len);// calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} -token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: +let token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; if(this.done&&this._input){this.done=false;}if(token){return token;}else if(this._backtrack){// recover context -for(var k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. +for(let k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. }else if(this._signaled_error_token){// produce one 'error' token as `.parseError()` in `reject()` // did not guarantee a failure signal by throwing an exception! token=this._signaled_error_token;this._signaled_error_token=false;return token;}return false;},/** @@ -2615,19 +2647,19 @@ token=this._signaled_error_token;this._signaled_error_token=false;return token;} * * @public * @this {RegExpLexer} - */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}var token,match,tempMatch,index;if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}var spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. + */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}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();// Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 -if(!spec||!spec.rules){var lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! -return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}var rule_ids=spec.rules;var regexes=spec.__rule_regexes;var len=spec.__rule_count;// Note: the arrays are 1-based, while `len` itself is a valid index, +if(!spec||!spec.rules){let lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! +return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}{let rule_ids=spec.rules;let regexes=spec.__rule_regexes;let len=spec.__rule_count;let match;let index;// 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(var i=1;i<=len;i++){tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. +for(let i=1;i<=len;i++){let tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){let token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. }else{// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}}else if(!this.options.flex){break;}}}if(match){token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}if(!this._input){this.done=true;this.clear();return this.EOF;}else{var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);var pendingInput=this._input;var activeCondition=this.topState();var conditionStackDepth=this.conditionStack.length;token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us +return false;}}else if(!this.options.flex){break;}}}if(match){let token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) +return false;}}if(!this._input){this.done=true;this.clear();return this.EOF;}{let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);let pendingInput=this._input;let activeCondition=this.topState();let conditionStackDepth=this.conditionStack.length;let token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: if(!this.matches&&// and make sure the input has been modified/consumed ... @@ -2638,7 +2670,7 @@ activeCondition===this.topState()&&conditionStackDepth===this.conditionStack.len * * @public * @this {RegExpLexer} - */lex:function lexer_lex(){var r;//this._clear_state = 0; + */lex:function lexer_lex(){let r;//this._clear_state = 0; if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}// allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer: if(typeof this.pre_lex==='function'){r=this.pre_lex.call(this,0);}if(typeof this.options.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.pre_lex.call(this,r)||r;}if(this.yy&&typeof this.yy.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) @@ -2646,50 +2678,50 @@ r=this.yy.pre_lex.call(this,r)||r;}while(!r){r=this.next();}if(this.yy&&typeof t r=this.yy.post_lex.call(this,r)||r;}if(typeof this.options.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.post_lex.call(this,r)||r;}if(typeof this.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.post_lex.call(this,r)||r;}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return next match that has a token. Identical to the `lex()` API but does not invoke any of the * `pre_lex()` nor any of the `post_lex()` callbacks. * * @public * @this {RegExpLexer} - */fastLex:function lexer_fastLex(){var r;//this._clear_state = 0; + */fastLex:function lexer_fastLex(){let r;//this._clear_state = 0; while(!r){r=this.next();}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return info about the lexer state that can help a parser or other lexer API user to use the * most efficient means available. This API is provided to aid run-time performance for larger @@ -2697,7 +2729,7 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */canIUse:function lexer_canIUse(){var rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** + */canIUse:function lexer_canIUse(){const rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** * backwards compatible alias for `pushState()`; * the latter is symmetrical with `popState()` and we advise to use * those APIs in any modern lexer code, rather than `begin()`. @@ -2716,20 +2748,20 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */popState:function lexer_popState(){var n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}else{return this.conditionStack[0];}},/** + */popState:function lexer_popState(){const n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}return this.conditionStack[0];},/** * return the currently active lexer condition state; when an index * argument is provided it produces the N-th previous condition state, * if available * * @public * @this {RegExpLexer} - */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}else{return'INITIAL';}},/** + */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}return'INITIAL';},/** * (internal) determine the lexer rule set which is active for the * currently active lexer condition state * * @public * @this {RegExpLexer} - */_currentRules:function lexer__currentRules(){var n=this.conditionStack.length-1;var state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions['INITIAL'];},/** + */_currentRules:function lexer__currentRules(){const n=this.conditionStack.length-1;let state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions.INITIAL;},/** * return the number of states currently on the stack * * @public @@ -2996,7 +3028,7 @@ const CHR_RE=/^(?:[^\\]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[ const WHITESPACE_SETSTR=' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff';// `/\d/`: const DIGIT_SETSTR='0-9';// `/\w/`: const WORDCHAR_SETSTR='A-Za-z0-9_';// Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex -function i2c(i){var c,x;switch(i){case 10:return'\\n';case 13:return'\\r';case 9:return'\\t';case 8:return'\\b';case 12:return'\\f';case 11:return'\\v';case 45:// ASCII/Unicode for '-' dash +function i2c(i){let c,x;switch(i){case 10:return'\\n';case 13:return'\\r';case 9:return'\\t';case 8:return'\\b';case 12:return'\\f';case 11:return'\\v';case 45:// ASCII/Unicode for '-' dash return'\\-';case 91:// '[' return'\\[';case 92:// '\\' return'\\\\';case 93:// ']' @@ -3006,13 +3038,13 @@ return'\\^';}if(i<32||i>0xFFF0/* Unicode Specials, also in UTF16 */||i>=0xD800&& // source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report // a b0rked generated parser, as the generated code would include this regex right here. // Hence we MUST escape these buggers everywhere we go... -x=i.toString(16);if(x.length>=1&&i<=0xFFFF){c='0000'+x;return'\\u'+c.substr(c.length-4);}else{return'\\u{'+x+'}';}}return String.fromCharCode(i);}// Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating +x=i.toString(16);if(x.length>=1&&i<=0xFFFF){c='0000'+x;return'\\u'+c.substr(c.length-4);}return'\\u{'+x+'}';}return String.fromCharCode(i);}// Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating // this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a // `\\p{NAME}` shorthand to represent [part of] the bitarray: -var Pcodes_bitarray_cache={};var Pcodes_bitarray_cache_test_order=[];// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by +let Pcodes_bitarray_cache={};let Pcodes_bitarray_cache_test_order=[];// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. -var EscCode_bitarray_output_refs;// now initialize the EscCodes_... table above: -init_EscCode_lookup_table();function init_EscCode_lookup_table(){var s,bitarr,set2esc={},esc2bitarr={};// patch global lookup tables for the time being, while we calculate their *real* content in this function: +let EscCode_bitarray_output_refs;// now initialize the EscCodes_... table above: +init_EscCode_lookup_table();function init_EscCode_lookup_table(){let s,bitarr,set2esc={},esc2bitarr={};// patch global lookup tables for the time being, while we calculate their *real* content in this function: EscCode_bitarray_output_refs={esc2bitarr:{},set2esc:{}};Pcodes_bitarray_cache_test_order=[];// `/\S': bitarr=[];set2bitarray(bitarr,'^'+WHITESPACE_SETSTR);s=bitarray2set(bitarr);esc2bitarr['S']=bitarr;set2esc[s]='S';// set2esc['^' + s] = 's'; Pcodes_bitarray_cache['\\S']=bitarr;// `/\s': @@ -3025,34 +3057,34 @@ Pcodes_bitarray_cache['\\d']=bitarr;// `/\W': bitarr=[];set2bitarray(bitarr,'^'+WORDCHAR_SETSTR);s=bitarray2set(bitarr);esc2bitarr['W']=bitarr;set2esc[s]='W';// set2esc['^' + s] = 'w'; Pcodes_bitarray_cache['\\W']=bitarr;// `/\w': bitarr=[];set2bitarray(bitarr,WORDCHAR_SETSTR);s=bitarray2set(bitarr);esc2bitarr['w']=bitarr;set2esc[s]='w';// set2esc['^' + s] = 'W'; -Pcodes_bitarray_cache['\\w']=bitarr;EscCode_bitarray_output_refs={esc2bitarr:esc2bitarr,set2esc:set2esc};updatePcodesBitarrayCacheTestOrder();}function updatePcodesBitarrayCacheTestOrder(opts){var t=new Array(UNICODE_BASE_PLANE_MAX_CP+1);var l={};var user_has_xregexp=opts&&opts.options&&opts.options.xregexp;var i,j,k,ba;// mark every character with which regex pcodes they are part of: -for(k in Pcodes_bitarray_cache){ba=Pcodes_bitarray_cache[k];if(!user_has_xregexp&&k.indexOf('\\p{')>=0){continue;}var cnt=0;for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(ba[i]){cnt++;if(!t[i]){t[i]=[k];}else{t[i].push(k);}}}l[k]=cnt;}// now dig out the unique ones: only need one per pcode. -// +Pcodes_bitarray_cache['\\w']=bitarr;EscCode_bitarray_output_refs={esc2bitarr:esc2bitarr,set2esc:set2esc};updatePcodesBitarrayCacheTestOrder();}function updatePcodesBitarrayCacheTestOrder(opts){let t=new Array(UNICODE_BASE_PLANE_MAX_CP+1);let l={};let user_has_xregexp=opts&&opts.options&&opts.options.xregexp;let i,j,k,ba;// mark every character with which regex pcodes they are part of: +for(k in Pcodes_bitarray_cache){ba=Pcodes_bitarray_cache[k];if(!user_has_xregexp&&k.indexOf('\\p{')>=0){continue;}let cnt=0;for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(ba[i]){cnt++;if(!t[i]){t[i]=[k];}else{t[i].push(k);}}}l[k]=cnt;}// now dig out the unique ones: only need one per pcode. +// // We ASSUME every \\p{NAME} 'pcode' has at least ONE character -// in it that is ONLY matched by that particular pcode. +// in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode -// won't be tested during optimization. -// +// won't be tested during optimization. +// // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to // look for markers which match multiple escapes/pcodes for those // ones where a unique item isn't available... -var lut=[];var done={};var keys=Object.keys(Pcodes_bitarray_cache);for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){k=t[i][0];if(t[i].length===1&&!done[k]){assert__default['default'](l[k]>0);lut.push([i,k]);done[k]=true;}}for(j=0;keys[j];j++){k=keys[j];if(!user_has_xregexp&&k.indexOf('\\p{')>=0){continue;}if(!done[k]){assert__default['default'](l[k]>0);// find a minimum span character to mark this one: -var w=Infinity;var rv;ba=Pcodes_bitarray_cache[k];for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(ba[i]){var tl=t[i].length;if(tl>1&&tl0);rv=[i,k];w=tl;}}}if(rv){done[k]=true;lut.push(rv);}}}// order from large set to small set so that small sets don't gobble +let lut=[];let done={};let keys=Object.keys(Pcodes_bitarray_cache);for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){k=t[i][0];if(t[i].length===1&&!done[k]){assert__default['default'](l[k]>0);lut.push([i,k]);done[k]=true;}}for(j=0;keys[j];j++){k=keys[j];if(!user_has_xregexp&&k.indexOf('\\p{')>=0){continue;}if(!done[k]){assert__default['default'](l[k]>0);// find a minimum span character to mark this one: +let w=Infinity;var rv;ba=Pcodes_bitarray_cache[k];for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(ba[i]){let tl=t[i].length;if(tl>1&&tl0);rv=[i,k];w=tl;}}}if(rv){done[k]=true;lut.push(rv);}}}// order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. -// +// // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more -// optimal minification of the regex set expression. -// +// optimal minification of the regex set expression. +// // This is a guestimate/heuristic only! -lut.sort(function(a,b){var k1=a[1];var k2=b[1];var ld=l[k2]-l[k1];if(ld){return ld;}// and for same-size sets, order from high to low unique identifier. +lut.sort(function(a,b){let k1=a[1];let k2=b[1];let ld=l[k2]-l[k1];if(ld){return ld;}// and for same-size sets, order from high to low unique identifier. return b[0]-a[0];});Pcodes_bitarray_cache_test_order=lut;}// 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set. -function set2bitarray(bitarr,s,opts){var orig=s;var set_is_inverted=false;var bitarr_orig;function mark(d1,d2){if(d2==null)d2=d1;for(var i=d1;i<=d2;i++){bitarr[i]=true;}}function add2bitarray(dst,src){for(var i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(src[i]){dst[i]=true;}}}function eval_escaped_code(s){var c;// decode escaped code? If none, just take the character as-is -if(s.indexOf('\\')===0){var l=s.substr(0,2);switch(l){case'\\c':c=s.charCodeAt(2)-'A'.charCodeAt(0)+1;return String.fromCharCode(c);case'\\x':s=s.substr(2);c=parseInt(s,16);return String.fromCharCode(c);case'\\u':s=s.substr(2);if(s[0]==='{'){s=s.substr(1,s.length-2);}c=parseInt(s,16);if(c>=0x10000){return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{'+s+'}');}return String.fromCharCode(c);case'\\0':case'\\1':case'\\2':case'\\3':case'\\4':case'\\5':case'\\6':case'\\7':s=s.substr(1);c=parseInt(s,8);return String.fromCharCode(c);case'\\r':return'\r';case'\\n':return'\n';case'\\v':return'\v';case'\\f':return'\f';case'\\t':return'\t';case'\\b':return'\b';default:// just the character itself: -return s.substr(1);}}else{return s;}}if(s&&s.length){var c1,c2;// inverted set? +function set2bitarray(bitarr,s,opts){let orig=s;let set_is_inverted=false;let bitarr_orig;function mark(d1,d2){if(d2==null)d2=d1;for(let i=d1;i<=d2;i++){bitarr[i]=true;}}function add2bitarray(dst,src){for(let i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(src[i]){dst[i]=true;}}}function eval_escaped_code(s){let c;// decode escaped code? If none, just take the character as-is +if(s.indexOf('\\')===0){let l=s.substr(0,2);switch(l){case'\\c':c=s.charCodeAt(2)-'A'.charCodeAt(0)+1;return String.fromCharCode(c);case'\\x':s=s.substr(2);c=parseInt(s,16);return String.fromCharCode(c);case'\\u':s=s.substr(2);if(s[0]==='{'){s=s.substr(1,s.length-2);}c=parseInt(s,16);if(c>=0x10000){return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{'+s+'}');}return String.fromCharCode(c);case'\\0':case'\\1':case'\\2':case'\\3':case'\\4':case'\\5':case'\\6':case'\\7':s=s.substr(1);c=parseInt(s,8);return String.fromCharCode(c);case'\\r':return'\r';case'\\n':return'\n';case'\\v':return'\v';case'\\f':return'\f';case'\\t':return'\t';case'\\b':return'\b';default:// just the character itself: +return s.substr(1);}}else{return s;}}if(s&&s.length){let c1,c2;// inverted set? if(s[0]==='^'){set_is_inverted=true;s=s.substr(1);bitarr_orig=bitarr;bitarr=new Array(UNICODE_BASE_PLANE_MAX_CP+1);}// BITARR collects flags for characters set. Inversion means the complement set of character is st instead. // This results in an OR operations when sets are joined/chained. while(s.length){c1=s.match(CHR_RE);if(!c1){// hit an illegal escape sequence? cope anyway! @@ -3060,31 +3092,31 @@ c1=s[0];}else{c1=c1[0];// Quick hack for XRegExp escapes inside a regex `[...]` // intact but it's easier to unfold them here; this is not nice for when the grammar specifies explicit // XRegExp support, but alas, we'll get there when we get there... ;-) switch(c1){case'\\p':s=s.substr(c1.length);c2=s.match(XREGEXP_UNICODE_ESCAPE_RE);if(c2){c2=c2[0];s=s.substr(c2.length);// do we have this one cached already? -var pex=c1+c2;var ba4p=Pcodes_bitarray_cache[pex];if(!ba4p){// expand escape: -var xr=new XRegExp__default['default']('['+pex+']');// TODO: case-insensitive grammar??? +let pex=c1+c2;let ba4p=Pcodes_bitarray_cache[pex];if(!ba4p){// expand escape: +let xr=new XRegExp__default['default']('['+pex+']');// TODO: case-insensitive grammar??? // rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`: -var xs=''+xr;// remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: +let xs=''+xr;// remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: xs=xs.substr(1,xs.length-2);ba4p=reduceRegexToSetBitArray(xs,pex,opts);Pcodes_bitarray_cache[pex]=ba4p;updatePcodesBitarrayCacheTestOrder(opts);}// merge bitarrays: add2bitarray(bitarr,ba4p);continue;}break;case'\\S':case'\\s':case'\\W':case'\\w':case'\\d':case'\\D':// these can't participate in a range, but need to be treated special: s=s.substr(c1.length);// check for \S, \s, \D, \d, \W, \w and expand them: var ba4e=EscCode_bitarray_output_refs.esc2bitarr[c1[1]];assert__default['default'](ba4e);add2bitarray(bitarr,ba4e);continue;case'\\b':// matches a backspace: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions#special-backspace -c1='\u0008';break;}}var v1=eval_escaped_code(c1);// propagate deferred exceptions = error reports. +c1='\u0008';break;}}let v1=eval_escaped_code(c1);// propagate deferred exceptions = error reports. if(v1 instanceof Error){return v1;}v1=v1.charCodeAt(0);s=s.substr(c1.length);if(s[0]==='-'&&s.length>=2){// we can expect a range like 'a-z': s=s.substr(1);c2=s.match(CHR_RE);if(!c2){// hit an illegal escape sequence? cope anyway! -c2=s[0];}else{c2=c2[0];}var v2=eval_escaped_code(c2);// propagate deferred exceptions = error reports. +c2=s[0];}else{c2=c2[0];}let v2=eval_escaped_code(c2);// propagate deferred exceptions = error reports. if(v2 instanceof Error){return v1;}v2=v2.charCodeAt(0);s=s.substr(c2.length);// legal ranges go UP, not /DOWN! if(v1<=v2){mark(v1,v2);}else{console.warn('INVALID CHARACTER RANGE found in regex: ',{re:orig,start:c1,start_n:v1,end:c2,end_n:v2});mark(v1);mark('-'.charCodeAt(0));mark(v2);}continue;}mark(v1);}// When we have marked all slots, '^' NEGATES the set, hence we flip all slots. -// +// // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. -if(set_is_inverted){for(var i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(!bitarr[i]){bitarr_orig[i]=true;}}}}return false;}// convert a simple bitarray back into a regex set `[...]` content: +if(set_is_inverted){for(let i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(!bitarr[i]){bitarr_orig[i]=true;}}}}return false;}// convert a simple bitarray back into a regex set `[...]` content: function bitarray2set(l,output_inverted_variant,output_minimized){// construct the inverse(?) set from the mark-set: // // Before we do that, we inject a sentinel so that our inner loops // below can be simple and fast: l[UNICODE_BASE_PLANE_MAX_CP+1]=1;// now reconstruct the regex set: -var rv=[];var i,j,cnt,lut,tn,tspec,match,pcode,ba4pcode,l2;var bitarr_is_cloned=false;var l_orig=l;if(output_inverted_variant){// generate the inverted set, hence all unmarked slots are part of the output range: +let rv=[];let i,j,cnt,lut,tn,tspec,match,pcode,ba4pcode,l2;let bitarr_is_cloned=false;let l_orig=l;if(output_inverted_variant){// generate the inverted set, hence all unmarked slots are part of the output range: cnt=0;for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(!l[i]){cnt++;}}if(cnt===UNICODE_BASE_PLANE_MAX_CP+1){// When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. // BUT... since we output the INVERTED set, we output the match-all set instead: return'\\S\\s';}else if(cnt===0){// When we find the entire Unicode range is in the output match set, we replace this with @@ -3096,9 +3128,9 @@ if(!l[tspec[0]]){// check if the pcode is covered by the inverted set: pcode=tspec[1];ba4pcode=Pcodes_bitarray_cache[pcode];match=0;for(j=0;j<=UNICODE_BASE_PLANE_MAX_CP;j++){if(ba4pcode[j]){if(!l[j]){// match in current inverted bitset, i.e. there's at // least one 'new' bit covered by this pcode/escape: match++;}else if(l_orig[j]){// mismatch! -match=false;break;}}}// We're only interested in matches which actually cover some +match=false;break;}}}// We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. -// +// // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if(match&&match>pcode.length){rv.push(pcode);// and nuke the bits in the array which match the given pcode: @@ -3119,9 +3151,9 @@ if(l[tspec[0]]){// check if the pcode is covered by the set: pcode=tspec[1];ba4pcode=Pcodes_bitarray_cache[pcode];match=0;for(j=0;j<=UNICODE_BASE_PLANE_MAX_CP;j++){if(ba4pcode[j]){if(l[j]){// match in current bitset, i.e. there's at // least one 'new' bit covered by this pcode/escape: match++;}else if(!l_orig[j]){// mismatch! -match=false;break;}}}// We're only interested in matches which actually cover some +match=false;break;}}}// We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. -// +// // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if(match&&match>pcode.length){rv.push(pcode);// and nuke the bits in the array which match the given pcode: @@ -3131,17 +3163,17 @@ if(!bitarr_is_cloned){l2=new Array(UNICODE_BASE_PLANE_MAX_CP+1);for(j=0;j<=UNICO l2[UNICODE_BASE_PLANE_MAX_CP+1]=1;l=l2;bitarr_is_cloned=true;}else{for(j=0;j<=UNICODE_BASE_PLANE_MAX_CP;j++){l[j]=l[j]&&!ba4pcode[j];}}}}}}i=0;while(i<=UNICODE_BASE_PLANE_MAX_CP){// find first character not in original set: while(!l[i]){i++;}if(i>=UNICODE_BASE_PLANE_MAX_CP+1){break;}// find next character not in original set: for(j=i+1;l[j];j++){}/* empty loop */if(j>UNICODE_BASE_PLANE_MAX_CP+1){j=UNICODE_BASE_PLANE_MAX_CP+1;}// generate subset: -rv.push(i2c(i));if(j-1>i){rv.push((j-2>i?'-':'')+i2c(j-1));}i=j;}}assert__default['default'](rv.length);var s=rv.join('');assert__default['default'](s);// Check if the set is better represented by one of the regex escapes: -var esc4s=EscCode_bitarray_output_refs.set2esc[s];if(esc4s){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! +rv.push(i2c(i));if(j-1>i){rv.push((j-2>i?'-':'')+i2c(j-1));}i=j;}}assert__default['default'](rv.length);let s=rv.join('');assert__default['default'](s);// Check if the set is better represented by one of the regex escapes: +let esc4s=EscCode_bitarray_output_refs.set2esc[s];if(esc4s){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return'\\'+esc4s;}return s;}// Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there; // ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`. -function reduceRegexToSetBitArray(s,name,opts){var orig=s;// propagate deferred exceptions = error reports. -if(s instanceof Error){return s;}var l=new Array(UNICODE_BASE_PLANE_MAX_CP+1);var internal_state=0;var derr;while(s.length){var c1=s.match(CHR_RE);if(!c1){// cope with illegal escape sequences too! -return new Error('illegal escape sequence at start of regex part: "'+s+'" of regex "'+orig+'"');}else{c1=c1[0];}s=s.substr(c1.length);switch(c1){case'[':// this is starting a set within the regex: scan until end of set! -var set_content=[];while(s.length){var inner=s.match(SET_PART_RE);if(!inner){inner=s.match(CHR_RE);if(!inner){// cope with illegal escape sequences too! -return new Error('illegal escape sequence at start of regex part: '+s+'" of regex "'+orig+'"');}else{inner=inner[0];}if(inner===']')break;}else{inner=inner[0];}set_content.push(inner);s=s.substr(inner.length);}// ensure that we hit the terminating ']': +function reduceRegexToSetBitArray(s,name,opts){let orig=s;// propagate deferred exceptions = error reports. +if(s instanceof Error){return s;}let l=new Array(UNICODE_BASE_PLANE_MAX_CP+1);let internal_state=0;let derr;while(s.length){let c1=s.match(CHR_RE);if(!c1){// cope with illegal escape sequences too! +return new Error('illegal escape sequence at start of regex part: "'+s+'" of regex "'+orig+'"');}c1=c1[0];s=s.substr(c1.length);switch(c1){case'[':// this is starting a set within the regex: scan until end of set! +var set_content=[];while(s.length){let inner=s.match(SET_PART_RE);if(!inner){inner=s.match(CHR_RE);if(!inner){// cope with illegal escape sequences too! +return new Error('illegal escape sequence at start of regex part: '+s+'" of regex "'+orig+'"');}inner=inner[0];if(inner===']')break;}else{inner=inner[0];}set_content.push(inner);s=s.substr(inner.length);}// ensure that we hit the terminating ']': var c2=s.match(CHR_RE);if(!c2){// cope with illegal escape sequences too! -return new Error('regex set expression is broken in regex: "'+orig+'" --> "'+s+'"');}else{c2=c2[0];}if(c2!==']'){return new Error('regex set expression is broken in regex: '+orig);}s=s.substr(c2.length);var se=set_content.join('');if(!internal_state){derr=set2bitarray(l,se,opts);// propagate deferred exceptions = error reports. +return new Error('regex set expression is broken in regex: "'+orig+'" --> "'+s+'"');}c2=c2[0];if(c2!==']'){return new Error('regex set expression is broken in regex: '+orig);}s=s.substr(c2.length);var se=set_content.join('');if(!internal_state){derr=set2bitarray(l,se,opts);// propagate deferred exceptions = error reports. if(derr instanceof Error){return derr;}// a set is to use like a single character in a longer literal phrase, hence input `[abc]word[def]` would thus produce output `[abc]`: internal_state=1;}break;// Strip unescaped pipes to catch constructs like `\\r|\\n` and turn them into // something ready for use inside a regex set, e.g. `\\r\\n`. @@ -3175,34 +3207,34 @@ if(!internal_state){derr=set2bitarray(l,c1,opts);// propagate deferred exception if(derr instanceof Error){return derr;}internal_state=2;}break;}}s=bitarray2set(l);// When this result is suitable for use in a set, than we should be able to compile // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: -try{var re;assert__default['default'](s);assert__default['default'](!(s instanceof Error));re=new XRegExp__default['default']('['+s+']');re.test(s[0]);// One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` +try{assert__default['default'](s);assert__default['default'](!(s instanceof Error));let re=new XRegExp__default['default']('['+s+']');re.test(s[0]);// One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` // so we check for lingering UNESCAPED brackets in here as those cannot be: if(/[^\\][\[\]]/.exec(s)){throw new Error('unescaped brackets in set data');}}catch(ex){// make sure we produce a set range expression which will fail badly when it is used // in actual code: s=new Error('[macro ['+name+'] is unsuitable for use inside regex set expressions: "['+s+']"]: '+ex.message);}assert__default['default'](s);// propagate deferred exceptions = error reports. -if(s instanceof Error){return s;}return l;}// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` +if(s instanceof Error){return s;}return l;}// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! function produceOptimizedRegex4Set(bitarr){// First try to produce a minimum regex from the bitarray directly: -var s1=bitarray2set(bitarr,false,true);// and when the regex set turns out to match a single pcode/escape, then +let s1=bitarray2set(bitarr,false,true);// and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if(s1.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! -return s1;}else{s1='['+s1+']';}// Now try to produce a minimum regex from the *inverted* bitarray via negation: +return s1;}s1='['+s1+']';// Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. -var s2=bitarray2set(bitarr,true,true);if(s2[0]==='^'){s2=s2.substr(1);if(s2.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! +let s2=bitarray2set(bitarr,true,true);if(s2[0]==='^'){s2=s2.substr(1);if(s2.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s2;}}else{s2='^'+s2;}s2='['+s2+']';// Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: -// +// // First try to produce a minimum regex from the bitarray directly: -var s3=bitarray2set(bitarr,false,false);// and when the regex set turns out to match a single pcode/escape, then +let s3=bitarray2set(bitarr,false,false);// and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if(s3.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! -return s3;}else{s3='['+s3+']';}// Now try to produce a minimum regex from the *inverted* bitarray via negation: +return s3;}s3='['+s3+']';// Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. -var s4=bitarray2set(bitarr,true,false);if(s4[0]==='^'){s4=s4.substr(1);if(s4.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! +let s4=bitarray2set(bitarr,true,false);if(s4[0]==='^'){s4=s4.substr(1);if(s4.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s4;}}else{s4='^'+s4;}s4='['+s4+']';if(s2.length0){err=e;}else{err=new Error('Could not parse jison lexer spec in JSON AUTODETECT mode:\nin JISON Mode we get Error: '+e.message+'\n\nwhile JSON5 Mode produces Error: '+ex1.message);err.secondary_exception=e;err.stack=ex1.stack;}}else{err=new Error('Could not parse lexer spec\nError: '+e.message);err.stack=e.stack;}throw err;}}}else{chk_l=lexerSpec;}// Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: +const commonErrors=[/does not compile/,/you did not correctly separate trailing code/,/You did not specify/,/You cannot specify/,/must be qualified/,/%start/,/%token/,/%import/,/%include/,/%options/,/%parse-params/,/%parser-type/,/%epsilon/,/definition list error/,/token list error/,/declaration error/,/should be followed/,/should be separated/,/an error in one or more of your lexer regex rules/,/an error in your lexer epilogue/,/unsupported definition type/];let cmnerr=commonErrors.filter(function check(re){return e.message.match(re);});if(cmnerr.length>0){err=e;}else{err=new Error('Could not parse jison lexer spec in JSON AUTODETECT mode:\nin JISON Mode we get Error: '+e.message+'\n\nwhile JSON5 Mode produces Error: '+ex1.message);err.secondary_exception=e;err.stack=ex1.stack;}}else{err=new Error('Could not parse lexer spec\nError: '+e.message);err.stack=e.stack;}throw err;}}}else{chk_l=lexerSpec;}// Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: return chk_l;}// expand macros and convert matchers to RegExp's -function prepareRules(dict,actions,caseHelper,tokens,startConditions,opts){var m,i,k,rule,action,conditions;var active_conditions;assert__default['default'](Array.isArray(dict.rules));var rules=dict.rules.slice(0);// shallow copy of the rules array as we MAY modify it in here! -var newRules=[];var macros={};var regular_rule_count=0;var simple_rule_count=0;// Assure all options are camelCased: +function prepareRules(dict,actions,caseHelper,tokens,startConditions,opts){let m,i,k,rule,action,conditions;let active_conditions;assert__default['default'](Array.isArray(dict.rules));let rules=dict.rules.slice(0);// shallow copy of the rules array as we MAY modify it in here! +let newRules=[];let macros={};let regular_rule_count=0;let simple_rule_count=0;// Assure all options are camelCased: assert__default['default'](typeof opts.options['case-insensitive']==='undefined');if(!tokens){tokens={};}if(opts.options.flex&&rules.length>0){rules.push(['.','console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']);}// Depending on the location within the regex we need different expansions of the macros: // one expansion for when a macro is *inside* a `[...]` and another expansion when a macro // is anywhere else in a regex: if(dict.macros){macros=prepareMacros(dict.macros,opts);}function tokenNumberReplacement(str,token){return'return '+(tokens[token]||'\''+token.replace(/'/g,'\\\'')+'\'');}// Make sure a comment does not contain any embedded '*/' end-of-comment marker // as that would break the generated code function postprocessComment(str){if(Array.isArray(str)){str=str.join(' ');}str=str.replace(/\*\//g,'*\\/');// destroy any inner `*/` comment terminator sequence. -return str;}var routingCode=['switch(yyrulenumber) {'];for(i=0;i0){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. -function reduceRegex(s,name,opts,expandAllMacrosInSet_cb,expandAllMacrosElsewhere_cb){var orig=s;function errinfo(){if(name){return'macro [['+name+']]';}else{return'regex [['+orig+']]';}}// propagate deferred exceptions = error reports. -if(s instanceof Error){return s;}var c1,c2;var rv=[];var derr;var se;while(s.length){c1=s.match(CHR_RE$1);if(!c1){// cope with illegal escape sequences too! -return new Error(errinfo()+': illegal escape sequence at start of regex part: '+s);}else{c1=c1[0];}s=s.substr(c1.length);switch(c1){case'[':// this is starting a set within the regex: scan until end of set! -var set_content=[];var l=new Array(UNICODE_BASE_PLANE_MAX_CP$1+1);while(s.length){var inner=s.match(SET_PART_RE$1);if(!inner){inner=s.match(CHR_RE$1);if(!inner){// cope with illegal escape sequences too! -return new Error(errinfo()+': illegal escape sequence at start of regex part: '+s);}else{inner=inner[0];}if(inner===']')break;}else{inner=inner[0];}set_content.push(inner);s=s.substr(inner.length);}// ensure that we hit the terminating ']': +function reduceRegex(s,name,opts,expandAllMacrosInSet_cb,expandAllMacrosElsewhere_cb){let orig=s;function errinfo(){if(name){return'macro [['+name+']]';}return'regex [['+orig+']]';}// propagate deferred exceptions = error reports. +if(s instanceof Error){return s;}let c1,c2;let rv=[];let derr;let se;while(s.length){c1=s.match(CHR_RE$1);if(!c1){// cope with illegal escape sequences too! +return new Error(errinfo()+': illegal escape sequence at start of regex part: '+s);}c1=c1[0];s=s.substr(c1.length);switch(c1){case'[':// this is starting a set within the regex: scan until end of set! +var set_content=[];var l=new Array(UNICODE_BASE_PLANE_MAX_CP$1+1);while(s.length){let inner=s.match(SET_PART_RE$1);if(!inner){inner=s.match(CHR_RE$1);if(!inner){// cope with illegal escape sequences too! +return new Error(errinfo()+': illegal escape sequence at start of regex part: '+s);}inner=inner[0];if(inner===']')break;}else{inner=inner[0];}set_content.push(inner);s=s.substr(inner.length);}// ensure that we hit the terminating ']': c2=s.match(CHR_RE$1);if(!c2){// cope with illegal escape sequences too! -return new Error(errinfo()+': regex set expression is broken: "'+s+'"');}else{c2=c2[0];}if(c2!==']'){return new Error(errinfo()+': regex set expression is broken: apparently unterminated');}s=s.substr(c2.length);se=set_content.join('');// expand any macros in here: +return new Error(errinfo()+': regex set expression is broken: "'+s+'"');}c2=c2[0];if(c2!==']'){return new Error(errinfo()+': regex set expression is broken: apparently unterminated');}s=s.substr(c2.length);se=set_content.join('');// expand any macros in here: if(expandAllMacrosInSet_cb){se=expandAllMacrosInSet_cb(se);assert__default['default'](se);if(se instanceof Error){return new Error(errinfo()+': '+se.message);}}derr=setmgmt.set2bitarray(l,se,opts);if(derr instanceof Error){return new Error(errinfo()+': '+derr.message);}// find out which set expression is optimal in size: var s1=setmgmt.produceOptimizedRegex4Set(l);// check if the source regex set potentially has any expansions (guestimate!) // @@ -3311,7 +3343,7 @@ case'\\p':c2=s.match(XREGEXP_UNICODE_ESCAPE_RE$1);if(c2){c2=c2[0];s=s.substr(c2. rv.push(c1+c2);}else{// nothing to stretch this match, hence nothing to expand. rv.push(c1);}break;// Either a range expression or the start of a macro reference: `.{1,3}` or `{NAME}`. // Treat it as a macro reference and see if it will expand to anything: -case'{':c2=s.match(NOTHING_SPECIAL_RE$1);if(c2){c2=c2[0];s=s.substr(c2.length);var c3=s[0];s=s.substr(c3.length);if(c3==='}'){// possibly a macro name in there... Expand if possible: +case'{':c2=s.match(NOTHING_SPECIAL_RE$1);if(c2){c2=c2[0];s=s.substr(c2.length);let c3=s[0];s=s.substr(c3.length);if(c3==='}'){// possibly a macro name in there... Expand if possible: c2=c1+c2+c3;if(expandAllMacrosElsewhere_cb){c2=expandAllMacrosElsewhere_cb(c2);assert__default['default'](c2);if(c2 instanceof Error){return new Error(errinfo()+': '+c2.message);}}}else{// not a well-terminated macro reference or something completely different: // we do not even attempt to expand this as there's guaranteed nothing to expand // in this bit. @@ -3327,11 +3359,11 @@ rv.push(c1+c2);}else{// nothing to stretch this match, hence nothing to expand. rv.push(c1);}break;}}s=rv.join('');// When this result is suitable for use in a set, than we should be able to compile // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: -try{var re;re=new XRegExp__default['default'](s);re.test(s[0]);}catch(ex){// make sure we produce a regex expression which will fail badly when it is used +try{let re;re=new XRegExp__default['default'](s);re.test(s[0]);}catch(ex){// make sure we produce a regex expression which will fail badly when it is used // in actual code: return new Error(errinfo()+': expands to an invalid regex: /'+s+'/');}assert__default['default'](s);return s;}// expand macros within macros and cache the result -function prepareMacros(dict_macros,opts){var macros={};// expand a `{NAME}` macro which exists inside a `[...]` set: -function expandMacroInSet(i){var k,a,m;if(!macros[i]){m=dict_macros[i];if(m.indexOf('{')>=0){// set up our own record so we can detect definition loops: +function prepareMacros(dict_macros,opts){let macros={};// expand a `{NAME}` macro which exists inside a `[...]` set: +function expandMacroInSet(i){let k,a,m;if(!macros[i]){m=dict_macros[i];if(m.indexOf('{')>=0){// set up our own record so we can detect definition loops: macros[i]={in_set:false,elsewhere:null,raw:dict_macros[i]};for(k in dict_macros){if(dict_macros.hasOwnProperty(k)&&i!==k){// it doesn't matter if the lexer recognized that the inner macro(s) // were sitting inside a `[...]` set or not: the fact that they are used // here in macro `i` which itself sits in a set, makes them *all* live in @@ -3343,18 +3375,18 @@ if(XRegExp__default['default']._getUnicodeProperty(k)){// Work-around so that yo // Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories, // while using `\p{ASCII}` as a *macro expansion* of the `ASCII` // macro: -if(k.toUpperCase()!==k){m=new Error('Cannot use name "'+k+'" as a macro name as it clashes with the same XRegExp "\\p{..}" Unicode \'General Category\' Property name. Use all-uppercase macro names, e.g. name your macro "'+k.toUpperCase()+'" to work around this issue or give your offending macro a different name.');break;}}a=m.split('{'+k+'}');if(a.length>1){var x=expandMacroInSet(k);assert__default['default'](x);if(x instanceof Error){m=x;break;}m=a.join(x);}}}}var mba=setmgmt.reduceRegexToSetBitArray(m,i,opts);var s1;// propagate deferred exceptions = error reports. +if(k.toUpperCase()!==k){m=new Error('Cannot use name "'+k+'" as a macro name as it clashes with the same XRegExp "\\p{..}" Unicode \'General Category\' Property name. Use all-uppercase macro names, e.g. name your macro "'+k.toUpperCase()+'" to work around this issue or give your offending macro a different name.');break;}}a=m.split('{'+k+'}');if(a.length>1){let x=expandMacroInSet(k);assert__default['default'](x);if(x instanceof Error){m=x;break;}m=a.join(x);}}}}let mba=setmgmt.reduceRegexToSetBitArray(m,i,opts);let s1;// propagate deferred exceptions = error reports. if(mba instanceof Error){s1=mba;}else{s1=setmgmt.bitarray2set(mba,false);m=s1;}macros[i]={in_set:s1,elsewhere:null,raw:dict_macros[i]};}else{m=macros[i].in_set;if(m instanceof Error){// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away! return new Error(m.message);}// detect definition loop: -if(m===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}}return m;}function expandMacroElsewhere(i){var m;if(macros[i].elsewhere==null){m=dict_macros[i];// set up our own record so we can detect definition loops: +if(m===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}}return m;}function expandMacroElsewhere(i){let m;if(macros[i].elsewhere==null){m=dict_macros[i];// set up our own record so we can detect definition loops: macros[i].elsewhere=false;// the macro MAY contain other macros which MAY be inside a `[...]` set in this // macro or elsewhere, hence we must parse the regex: m=reduceRegex(m,i,opts,expandAllMacrosInSet,expandAllMacrosElsewhere);// propagate deferred exceptions = error reports. if(m instanceof Error){return m;}macros[i].elsewhere=m;}else{m=macros[i].elsewhere;if(m instanceof Error){// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away! return m;}// detect definition loop: -if(m===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}}return m;}function expandAllMacrosInSet(s){var i,x;// process *all* the macros inside [...] set: -if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){var a=s.split('{'+i+'}');if(a.length>1){x=expandMacroInSet(i);assert__default['default'](x);if(x instanceof Error){return new Error('failure to expand the macro ['+i+'] in set ['+s+']: '+x.message);}s=a.join(x);}// stop the brute-force expansion attempt when we done 'em all: -if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s){var i,x;// When we process the remaining macro occurrences in the regex +if(m===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}}return m;}function expandAllMacrosInSet(s){let i,x;// process *all* the macros inside [...] set: +if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){let a=s.split('{'+i+'}');if(a.length>1){x=expandMacroInSet(i);assert__default['default'](x);if(x instanceof Error){return new Error('failure to expand the macro ['+i+'] in set ['+s+']: '+x.message);}s=a.join(x);}// stop the brute-force expansion attempt when we done 'em all: +if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s){let i,x;// When we process the remaining macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. // // Meanwhile the cached expansion will expand any submacros into @@ -3364,21 +3396,21 @@ if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s) // // This is a BREAKING CHANGE from vanilla jison 0.4.15! if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){// These are all submacro expansions, hence non-capturing grouping is applied: -var a=s.split('{'+i+'}');if(a.length>1){x=expandMacroElsewhere(i);assert__default['default'](x);if(x instanceof Error){return new Error('failure to expand the macro ['+i+'] in regex /'+s+'/: '+x.message);}s=a.join('(?:'+x+')');}// stop the brute-force expansion attempt when we done 'em all: -if(s.indexOf('{')===-1){break;}}}}return s;}var i;if(opts.debug)console.log('\n############## RAW macros: ',dict_macros);// first we create the part of the dictionary which is targeting the use of macros +let a=s.split('{'+i+'}');if(a.length>1){x=expandMacroElsewhere(i);assert__default['default'](x);if(x instanceof Error){return new Error('failure to expand the macro ['+i+'] in regex /'+s+'/: '+x.message);}s=a.join('(?:'+x+')');}// stop the brute-force expansion attempt when we done 'em all: +if(s.indexOf('{')===-1){break;}}}}return s;}let i;if(opts.debug)console.log('\n############## RAW macros: ',dict_macros);// first we create the part of the dictionary which is targeting the use of macros // *inside* `[...]` sets; once we have completed that half of the expansions work, // we then go and expand the macros for when they are used elsewhere in a regex: // iff we encounter submacros then which are used *inside* a set, we can use that // first half dictionary to speed things up a bit as we can use those expansions // straight away! for(i in dict_macros){if(dict_macros.hasOwnProperty(i)){expandMacroInSet(i);}}for(i in dict_macros){if(dict_macros.hasOwnProperty(i)){expandMacroElsewhere(i);}}if(opts.debug)console.log('\n############### expanded macros: ',macros);return macros;}// expand macros in a regex; expands them recursively -function expandMacros(src,macros,opts){var expansion_count=0;// By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! +function expandMacros(src,macros,opts){let expansion_count=0;// By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! // Hence things should be easy in there: -function expandAllMacrosInSet(s){var i,m,x;// process *all* the macros inside [...] set: -if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){m=macros[i];var a=s.split('{'+i+'}');if(a.length>1){x=m.in_set;assert__default['default'](x);if(x instanceof Error){// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away! +function expandAllMacrosInSet(s){let i,m,x;// process *all* the macros inside [...] set: +if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){m=macros[i];let a=s.split('{'+i+'}');if(a.length>1){x=m.in_set;assert__default['default'](x);if(x instanceof Error){// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away! throw x;}// detect definition loop: if(x===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}s=a.join(x);expansion_count++;}// stop the brute-force expansion attempt when we done 'em all: -if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s){var i,m,x;// When we process the main macro occurrences in the regex +if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s){let i,m,x;// When we process the main macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. // // Meanwhile the cached expansion will expand any submacros into @@ -3387,7 +3419,7 @@ if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s) // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! -if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){m=macros[i];var a=s.split('{'+i+'}');if(a.length>1){// These are all main macro expansions, hence CAPTURING grouping is applied: +if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){m=macros[i];let a=s.split('{'+i+'}');if(a.length>1){// These are all main macro expansions, hence CAPTURING grouping is applied: x=m.elsewhere;assert__default['default'](x);// detect definition loop: if(x===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}s=a.join('('+x+')');expansion_count++;}// stop the brute-force expansion attempt when we done 'em all: if(s.indexOf('{')===-1){break;}}}}return s;}// When we process the macro occurrences in the regex @@ -3399,7 +3431,7 @@ if(s.indexOf('{')===-1){break;}}}}return s;}// When we process the macro occurre // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! -var s2=reduceRegex(src,null,opts,expandAllMacrosInSet,expandAllMacrosElsewhere);// propagate deferred exceptions = error reports. +let s2=reduceRegex(src,null,opts,expandAllMacrosInSet,expandAllMacrosElsewhere);// propagate deferred exceptions = error reports. if(s2 instanceof Error){throw s2;}// only when we did expand some actual macros do we take the re-interpreted/optimized/regenerated regex from reduceRegex() // in order to keep our test cases simple and rules recognizable. This assumes the user can code good regexes on his own, // as long as no macros are involved... @@ -3407,8 +3439,8 @@ if(s2 instanceof Error){throw s2;}// only when we did expand some actual macros // Also pick the reduced regex when there (potentially) are XRegExp extensions in the original, e.g. `\\p{Number}`, // unless the `xregexp` output option has been enabled. if(expansion_count>0||src.indexOf('\\p{')>=0&&!opts.options.xregexp){src=s2;}else{// Check if the reduced regex is smaller in size; when it is, we still go with the new one! -if(s2.length0){toks[tokens[tok]]=idx;}}var gen=prepareRules(dict,actions,caseHelper,tokens&&toks,opts.conditions,opts);var code=actions.join('\n');'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function(yy){code=code.replace(new RegExp('\\b('+yy+')\\b','g'),'yy_.$1');});return{caseHelperInclude:'{\n'+caseHelper.join(',')+'\n}',actions:`function lexer__performAction(yy, yyrulenumber, YY_START) { +if(s2.length0){toks[tokens[tok]]=idx;}}let gen=prepareRules(dict,actions,caseHelper,tokens&&toks,opts.conditions,opts);let code=actions.join('\n');'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function(yy){code=code.replace(new RegExp('\\b('+yy+')\\b','g'),'yy_.$1');});return{caseHelperInclude:'{\n'+caseHelper.join(',')+'\n}',actions:`function lexer__performAction(yy, yyrulenumber, YY_START) { var yy_ = this; ${code} @@ -3418,7 +3450,7 @@ regular_rule_count:gen.regular_rule_count,simple_rule_count:gen.simple_rule_coun // jison/lib/jison.js @ line 2304:lrGeneratorMixin.generateErrorClass // function generateErrorClass(){// --- START lexer error class --- -var prelude=`/** +const prelude=`/** * 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 @@ -3429,8 +3461,6 @@ var prelude=`/** * @nocollapse */ function JisonLexerError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -3447,9 +3477,9 @@ function JisonLexerError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -3492,43 +3522,59 @@ return prelude;}const jisonLexerErrorDefinition=generateErrorClass();function ge fake.__hacky_backy__ = __hacky_counter__; return fake; } - `;}/** @constructor */function RegExpLexer(dict,input,tokens,build_options){var opts;var dump=false;function test_me(tweak_cb,description,src_exception,ex_callback){opts=processGrammar(dict,tokens,build_options);opts.__in_rules_failure_analysis_mode__=false;prepExportStructures(opts);assert__default['default'](opts.options);if(tweak_cb){tweak_cb();}var source=generateModuleBody(opts);try{// The generated code will always have the `lexer` variable declared at local scope + `;}/** @constructor */function RegExpLexer(dict,input,tokens,build_options){let opts;let dump=false;function test_me(tweak_cb,description,src_exception,ex_callback){opts=processGrammar(dict,tokens,build_options);opts.__in_rules_failure_analysis_mode__=false;prepExportStructures(opts);assert__default['default'](opts.options);if(tweak_cb){tweak_cb();}let source=generateModuleBody(opts);try{// The generated code will always have the `lexer` variable declared at local scope // as `eval()` will use the local scope. // // The compiled code will look something like this: // // ``` -// var lexer; +// let lexer; // bla bla... // ``` // // or // // ``` -// var lexer = { bla... }; +// const lexer = { bla... }; // ``` -var testcode=['// provide a local version for test purposes:',jisonLexerErrorDefinition,'',generateFakeXRegExpClassSrcCode(),'',source,'','return lexer;'].join('\n');var lexer=code_exec$1(testcode,function generated_code_exec_wrapper_regexp_lexer(sourcecode){//console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); -chkBugger$2(sourcecode);var lexer_f=new Function('',sourcecode);return lexer_f();},opts.options,"lexer");if(!lexer){throw new Error('no lexer defined *at all*?!');}if(typeof lexer.options!=='object'||lexer.options==null){throw new Error('your lexer class MUST have an .options member object or it won\'t fly!');}if(typeof lexer.setInput!=='function'){throw new Error('your lexer class MUST have a .setInput function member or it won\'t fly!');}if(lexer.EOF!==1&&lexer.ERROR!==2){throw new Error('your lexer class MUST have these constants defined: lexer.EOF = 1 and lexer.ERROR = 2 or it won\'t fly!');}// When we do NOT crash, we found/killed the problem area just before this call! -if(src_exception&&description){var msg=description;if(typeof description==='function'){msg=description();}src_exception.message+='\n ('+msg+')';}// patch the pre and post handlers in there, now that we have some live code to work with: -if(opts.options){var pre=opts.options.pre_lex;var post=opts.options.post_lex;// since JSON cannot encode functions, we'll have to do it manually now: -if(typeof pre==='function'){lexer.options.pre_lex=pre;}if(typeof post==='function'){lexer.options.post_lex=post;}}if(opts.options.showSource){if(typeof opts.options.showSource==='function'){opts.options.showSource(lexer,source,opts,RegExpLexer);}else{console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n",source,"\n----------------------------------------\n");}}return lexer;}catch(ex){// if (src_exception) { +let testcode=['// provide a local version for test purposes:',jisonLexerErrorDefinition,'',generateFakeXRegExpClassSrcCode(),'',source,'',rmCommonWS$2` + // JISON INJECTED VALIDATION CODE + // which attempts to ascertain you have defined a minimal viable lexer at least: + if (typeof lexer === "undefined") { + throw new SyntaxError("user-defined lexer does not define the required 'lexer' instance."); + } + if (!lexer) { + throw new SyntaxError("user-defined lexer does not define a non-NULL 'lexer' instance."); + } + if (typeof lexer.setInput !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.setInput()' API function."); + } + if (typeof lexer.lex !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.lex()' API function."); + } + // END OF JISON INJECTED VALIDATION CODE + `,'return lexer;'].join('\n');let lexer=code_exec(testcode,function generated_code_exec_wrapper_regexp_lexer(sourcecode){//console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); +chkBugger$2(sourcecode);let lexer_f=new Function('',sourcecode);return lexer_f();},Object.assign({},opts.options,{throwErrorOnCompileFailure:true}),'lexer');if(!lexer){throw new Error('no lexer defined *at all*?!');}if(typeof lexer.options!=='object'||lexer.options==null){throw new Error('your lexer class MUST have an .options member object or it won\'t fly!');}if(typeof lexer.setInput!=='function'){throw new Error('your lexer class MUST have a .setInput function member or it won\'t fly!');}if(lexer.EOF!==1&&lexer.ERROR!==2){throw new Error('your lexer class MUST have these constants defined: lexer.EOF = 1 and lexer.ERROR = 2 or it won\'t fly!');}// When we do NOT crash, we found/killed the problem area just before this call! +if(src_exception&&description){let msg=description;if(typeof description==='function'){msg=description();}src_exception.message+='\n ('+msg+')';}// patch the pre and post handlers in there, now that we have some live code to work with: +if(opts.options){let pre=opts.options.pre_lex;let post=opts.options.post_lex;// since JSON cannot encode functions, we'll have to do it manually now: +if(typeof pre==='function'){lexer.options.pre_lex=pre;}if(typeof post==='function'){lexer.options.post_lex=post;}}if(opts.options.showSource){if(typeof opts.options.showSource==='function'){opts.options.showSource(lexer,source,opts,RegExpLexer);}else{console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n',source,'\n----------------------------------------\n');}}return lexer;}catch(ex){// if (src_exception) { // src_exception.message += '\n (' + description + ': ' + ex.message + ')'; // } -if(ex_callback){ex_callback(ex);}else if(dump){console.log('source code:\n',source);}return false;}}/** @constructor */var lexer=test_me(null,null,null,function(ex){// When we get an exception here, it means some part of the user-specified lexer is botched. +if(ex_callback){ex_callback(ex);}else if(dump){console.log('source code:\n',source);}return false;}}/** @constructor */let lexer=test_me(null,null,null,function(ex){// When we get an exception here, it means some part of the user-specified lexer is botched. // // Now we go and try to narrow down the problem area/category: -assert__default['default'](opts.options);assert__default['default'](opts.options.xregexp!==undefined);var orig_xregexp_opt=!!opts.options.xregexp;if(!test_me(function(){assert__default['default'](opts.options.xregexp!==undefined);opts.options.xregexp=false;opts.showSource=false;},'When you have specified %option xregexp, you must also properly IMPORT the XRegExp library in the generated lexer.',ex,null)){if(!test_me(function(){// restore xregexp option setting: the trouble wasn't caused by the xregexp flag i.c.w. incorrect XRegExp library importing! -opts.options.xregexp=orig_xregexp_opt;opts.conditions=[];opts.showSource=false;},function(){assert__default['default'](Array.isArray(opts.rules));return opts.rules.length>0?'One or more of your lexer state names are possibly botched?':'Your custom lexer is somehow botched.';},ex,null)){var rulesSpecSize;if(!test_me(function(){// store the parsed rule set size so we can use that info in case +assert__default['default'](opts.options);assert__default['default'](opts.options.xregexp!==undefined);let orig_xregexp_opt=!!opts.options.xregexp;if(!test_me(function(){assert__default['default'](opts.options.xregexp!==undefined);opts.options.xregexp=false;opts.showSource=false;},'When you have specified %option xregexp, you must also properly IMPORT the XRegExp library in the generated lexer.',ex,null)){if(!test_me(function(){// restore xregexp option setting: the trouble wasn't caused by the xregexp flag i.c.w. incorrect XRegExp library importing! +opts.options.xregexp=orig_xregexp_opt;opts.conditions=[];opts.showSource=false;},function(){assert__default['default'](Array.isArray(opts.rules));return opts.rules.length>0?'One or more of your lexer state names are possibly botched?':'Your custom lexer is somehow botched.';},ex,null)){let rulesSpecSize;if(!test_me(function(){// store the parsed rule set size so we can use that info in case // this attempt also fails: assert__default['default'](Array.isArray(opts.rules));rulesSpecSize=opts.rules.length;// opts.conditions = []; opts.rules=[];opts.showSource=false;opts.__in_rules_failure_analysis_mode__=true;},'One or more of your lexer rules are possibly botched?',ex,null)){// kill each rule action block, one at a time and test again after each 'edit': -var rv=false;for(var i=0,len=rulesSpecSize;i= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -3755,8 +3792,6 @@ return`{ * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -3766,14 +3801,14 @@ return`{ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -3784,8 +3819,6 @@ return`{ * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -3793,40 +3826,40 @@ return`{ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -3838,7 +3871,7 @@ return`{ this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -3846,7 +3879,7 @@ return`{ last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -3907,9 +3940,7 @@ return`{ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -3928,8 +3959,6 @@ return`{ * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set \`done\` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -3938,7 +3967,7 @@ return`{ this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -3948,13 +3977,13 @@ return`{ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\\n') { lines = true; } else if (ch === '\\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\\n') { slice_len++; ch += ch2; @@ -3986,10 +4015,8 @@ return`{ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -4021,8 +4048,8 @@ return`{ // Get last entirely matched line into the \`pre_lines[]\` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -4040,9 +4067,9 @@ return`{ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -4052,14 +4079,12 @@ return`{ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -4070,8 +4095,6 @@ return`{ * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -4084,19 +4107,17 @@ return`{ * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the \`parseError()\` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // \`.lex()\` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -4109,8 +4130,6 @@ return`{ * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -4133,24 +4152,24 @@ return`{ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substr\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -4162,8 +4181,8 @@ return`{ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to \`maxSize\` (default: 20). @@ -4189,24 +4208,25 @@ return`{ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > \`lookAhead()\` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substring\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -4215,7 +4235,7 @@ return`{ } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -4234,10 +4254,8 @@ return`{ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^'; }, @@ -4259,15 +4277,13 @@ return`{ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -4398,58 +4414,54 @@ return`{ * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\\t/g, ' '); @@ -4458,13 +4470,13 @@ return`{ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -4486,15 +4498,13 @@ return`{ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -4506,8 +4516,8 @@ return`{ rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -4536,13 +4546,7 @@ return`{ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -4571,10 +4575,10 @@ return`{ }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -4602,7 +4606,7 @@ return`{ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -4613,7 +4617,7 @@ return`{ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -4635,8 +4639,6 @@ return`{ * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -4645,17 +4647,13 @@ return`{ this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -4665,67 +4663,75 @@ return`{ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that \`parseError()\` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) \`parseError()\` @@ -4752,9 +4758,7 @@ return`{ * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -4797,24 +4801,24 @@ return`{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -4834,9 +4838,7 @@ return`{ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -4846,24 +4848,24 @@ return`{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -4871,7 +4873,7 @@ return`{ this._clear_state = 0; } - + return r; }, @@ -4884,9 +4886,7 @@ return`{ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -4894,7 +4894,7 @@ return`{ (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -4909,8 +4909,6 @@ return`{ * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -4922,8 +4920,6 @@ return`{ * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -4937,15 +4933,12 @@ return`{ * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -4957,14 +4950,11 @@ return`{ * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -4975,16 +4965,14 @@ return`{ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -4994,8 +4982,6 @@ return`{ * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; } }`;// --- END lexer kernel --- @@ -5018,7 +5004,7 @@ function stripUnusedLexerCode(src,opt){// uses yyleng: ..................... $ // uses display APIs pastInput(), upcomingInput(), showPosition(): // ............................. ${opt.lexerActionsUseDisplayAPIs} // uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC} -var new_src;try{var ast=helpers.parseCodeChunkToAST(src,opt);new_src=helpers.prettyPrintAST(ast,opt);}catch(ex){let line=ex.lineNumber||0;let a=src.split(/\r?\n/g);let len=a.length;let minl=Math.max(0,line-10);let b=a.slice(minl,line+10);let c=b.splice(line-minl,0,"","^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^","");let offendingChunk=' '+b.join('\n ');console.error(rmCommonWS$2` +let new_src;try{let ast=helpers.parseCodeChunkToAST(src,opt);new_src=helpers.prettyPrintAST(ast,opt);}catch(ex){let line=ex.lineNumber||0;let a=src.split(/\r?\n/g);let len=a.length;let minl=Math.max(0,line-10);let b=a.slice(minl,line+10);let c=b.splice(line-minl,0,'','^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^','');let offendingChunk=' '+b.join('\n ');console.error(rmCommonWS$2` stripUnusedLexerCode WARNING: JISON failed to reformat the generated lexer. @@ -5074,8 +5060,8 @@ new_src=new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g,rmCommonWS$2 // --------- END OF REPORT ----------- `);return new_src;}// generate lexer source from a grammar -/** @public */function generate(dict,tokens,build_options){var opt=processGrammar(dict,tokens,build_options);return generateFromOpts(opt);}// process the grammar and build final data structures and functions -/** @public */function processGrammar(dict,tokens,build_options){build_options=build_options||{};var opts={// include the knowledge passed through `build_options` about which lexer +/** @public */function generate(dict,tokens,build_options){let opt=processGrammar(dict,tokens,build_options);return generateFromOpts(opt);}// process the grammar and build final data structures and functions +/** @public */function processGrammar(dict,tokens,build_options){build_options=build_options||{};let opts={// include the knowledge passed through `build_options` about which lexer // features will actually be *used* by the environment (which in 99.9% // of cases is a jison *parser*): // @@ -5088,22 +5074,22 @@ opts.lex_rule_dictionary=dict;// Always provide the lexer with an options object opts.options=mkStdOptions(build_options,dict.options);opts.moduleType=opts.options.moduleType;opts.moduleName=opts.options.moduleName;opts.conditions=prepareStartConditions(dict.startConditions);opts.conditions.INITIAL={rules:[],inclusive:true};// only produce rule action code blocks when there are any rules at all; // a "custom lexer" has ZERO rules and must be defined entirely in // other code blocks: -var code=dict.rules?buildActions(dict,tokens,opts):{};opts.performAction=code.actions;opts.caseHelperInclude=code.caseHelperInclude;opts.rules=code.rules||[];opts.macros=code.macros;opts.regular_rule_count=code.regular_rule_count;opts.simple_rule_count=code.simple_rule_count;opts.conditionStack=['INITIAL'];opts.actionInclude=dict.actionInclude||'';opts.moduleInclude=(opts.moduleInclude||'')+(dict.moduleInclude||'').trim();return opts;}// Assemble the final source from the processed grammar -/** @public */function generateFromOpts(opt){var code='';switch(opt.moduleType){case'js':code=generateModule(opt);break;case'amd':code=generateAMDModule(opt);break;case'es':code=generateESModule(opt);break;case'commonjs':code=generateCommonJSModule(opt);break;default:throw new Error('unsupported moduleType: '+opt.moduleType);}return code;}function generateRegexesInitTableCode(opt){var a=opt.rules;var print_xregexp=opt.options&&opt.options.xregexp;var id_display_width=1+Math.log10(a.length|1)|0;var ws_prefix=new Array(id_display_width).join(' ');var b=a.map(function generateXRegExpInitCode(re,idx){var idx_str=(ws_prefix+idx).substr(-id_display_width);if(re instanceof XRegExp__default['default']){// When we don't need the special XRegExp sauce at run-time, we do with the original +let code=dict.rules?buildActions(dict,tokens,opts):{};opts.performAction=code.actions;opts.caseHelperInclude=code.caseHelperInclude;opts.rules=code.rules||[];opts.macros=code.macros;opts.regular_rule_count=code.regular_rule_count;opts.simple_rule_count=code.simple_rule_count;opts.conditionStack=['INITIAL'];opts.actionInclude=dict.actionInclude||'';opts.moduleInclude=(opts.moduleInclude||'')+(dict.moduleInclude||'').trim();return opts;}// Assemble the final source from the processed grammar +/** @public */function generateFromOpts(opt){let code='';switch(opt.moduleType){case'js':code=generateModule(opt);break;case'amd':code=generateAMDModule(opt);break;case'es':code=generateESModule(opt);break;case'commonjs':code=generateCommonJSModule(opt);break;default:throw new Error('unsupported moduleType: '+opt.moduleType);}return code;}function generateRegexesInitTableCode(opt){let a=opt.rules;let print_xregexp=opt.options&&opt.options.xregexp;let id_display_width=1+Math.log10(a.length|1)|0;let ws_prefix=new Array(id_display_width).join(' ');let b=a.map(function generateXRegExpInitCode(re,idx){let idx_str=(ws_prefix+idx).substr(-id_display_width);if(re instanceof XRegExp__default['default']){// When we don't need the special XRegExp sauce at run-time, we do with the original // JavaScript RegExp instance a.k.a. 'native regex': if(re.xregexp.isNative||!print_xregexp){return`/* ${idx_str}: */ ${re}`;}// And make sure to escape the regex to make it suitable for placement inside a *string* // as it is passed as a string argument to the XRegExp constructor here. -var re_src=re.xregexp.source.replace(/[\\"]/g,'\\$&');return`/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`;}else{return`/* ${idx_str}: */ ${re}`;}});return b.join(',\n');}function generateModuleBody(opt){// make the JSON output look more like JavaScript: -function cleanupJSON(str){str=str.replace(/ "rules": \[/g,' rules: [');str=str.replace(/ "inclusive": /g,' inclusive: ');return str;}function produceOptions(opts){var obj={};var do_not_pass={debug:!opts.debug,// do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! -enableDebugLogs:1,json:1,_:1,noMain:1,dumpSourceCodeOnFailure:1,throwErrorOnCompileFailure:1,reportStats:1,file:1,outfile:1,inputPath:1,inputFilename:1,defaultModuleName:1,moduleName:1,moduleType:1,lexerErrorsAreRecoverable:0,flex:0,backtrack_lexer:0,caseInsensitive:0,showSource:1,exportAST:1,exportAllTables:1,exportSourceCode:1,prettyCfg:1,parseActionsUseYYLENG:1,parseActionsUseYYLINENO:1,parseActionsUseYYTEXT:1,parseActionsUseYYLOC:1,parseActionsUseParseError:1,parseActionsUseYYERROR:1,parseActionsUseYYRECOVERING:1,parseActionsUseYYERROK:1,parseActionsUseYYCLEARIN:1,parseActionsUseValueTracking:1,parseActionsUseValueAssignment:1,parseActionsUseLocationTracking:1,parseActionsUseLocationAssignment:1,parseActionsUseYYSTACK:1,parseActionsUseYYSSTACK:1,parseActionsUseYYSTACKPOINTER:1,parseActionsUseYYRULELENGTH:1,parseActionsUseYYMERGELOCATIONINFO:1,parserHasErrorRecovery:1,parserHasErrorReporting:1,lexerActionsUseYYLENG:1,lexerActionsUseYYLINENO:1,lexerActionsUseYYTEXT:1,lexerActionsUseYYLOC:1,lexerActionsUseParseError:1,lexerActionsUseYYERROR:1,lexerActionsUseLocationTracking:1,lexerActionsUseMore:1,lexerActionsUseUnput:1,lexerActionsUseReject:1,lexerActionsUseLess:1,lexerActionsUseDisplayAPIs:1,lexerActionsUseDescribeYYLOC:1};for(var k in opts){if(!do_not_pass[k]&&opts[k]!=null&&opts[k]!==false){// make sure numeric values are encoded as numeric, the rest as boolean/string. -if(typeof opts[k]==='string'){var f=parseFloat(opts[k]);if(f==opts[k]){obj[k]=f;continue;}}obj[k]=opts[k];}}// And now some options which should receive some special processing: -var pre=obj.pre_lex;var post=obj.post_lex;// since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: -if(pre){obj.pre_lex=true;}if(post){obj.post_lex=true;}var js=JSON.stringify(obj,null,2);js=js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$1})": `,'g'),' $1: ');js=js.replace(/^( +)pre_lex: true(,)?$/gm,function(m,ls,tc){return ls+'pre_lex: '+String(pre)+(tc||'');});js=js.replace(/^( +)post_lex: true(,)?$/gm,function(m,ls,tc){return ls+'post_lex: '+String(post)+(tc||'');});return js;}var out;if(opt.rules.length>0||opt.__in_rules_failure_analysis_mode__){// we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: +let re_src=re.xregexp.source.replace(/[\\"]/g,'\\$&');return`/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`;}return`/* ${idx_str}: */ ${re}`;});return b.join(',\n');}function generateModuleBody(opt){// make the JSON output look more like JavaScript: +function cleanupJSON(str){str=str.replace(/ {2}"rules": \[/g,' rules: [');str=str.replace(/ {2}"inclusive": /g,' inclusive: ');return str;}function produceOptions(opts){let obj={};const do_not_pass={debug:!opts.debug,// do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! +enableDebugLogs:1,json:1,_:1,noMain:1,dumpSourceCodeOnFailure:1,throwErrorOnCompileFailure:1,reportStats:1,file:1,outfile:1,inputPath:1,inputFilename:1,defaultModuleName:1,moduleName:1,moduleType:1,lexerErrorsAreRecoverable:0,flex:0,backtrack_lexer:0,caseInsensitive:0,showSource:1,exportAST:1,exportAllTables:1,exportSourceCode:1,prettyCfg:1,parseActionsUseYYLENG:1,parseActionsUseYYLINENO:1,parseActionsUseYYTEXT:1,parseActionsUseYYLOC:1,parseActionsUseParseError:1,parseActionsUseYYERROR:1,parseActionsUseYYRECOVERING:1,parseActionsUseYYERROK:1,parseActionsUseYYCLEARIN:1,parseActionsUseValueTracking:1,parseActionsUseValueAssignment:1,parseActionsUseLocationTracking:1,parseActionsUseLocationAssignment:1,parseActionsUseYYSTACK:1,parseActionsUseYYSSTACK:1,parseActionsUseYYSTACKPOINTER:1,parseActionsUseYYRULELENGTH:1,parseActionsUseYYMERGELOCATIONINFO:1,parserHasErrorRecovery:1,parserHasErrorReporting:1,lexerActionsUseYYLENG:1,lexerActionsUseYYLINENO:1,lexerActionsUseYYTEXT:1,lexerActionsUseYYLOC:1,lexerActionsUseParseError:1,lexerActionsUseYYERROR:1,lexerActionsUseLocationTracking:1,lexerActionsUseMore:1,lexerActionsUseUnput:1,lexerActionsUseReject:1,lexerActionsUseLess:1,lexerActionsUseDisplayAPIs:1,lexerActionsUseDescribeYYLOC:1};for(let k in opts){if(!do_not_pass[k]&&opts[k]!=null&&opts[k]!==false){// make sure numeric values are encoded as numeric, the rest as boolean/string. +if(typeof opts[k]==='string'){let f=parseFloat(opts[k]);if(f==opts[k]){obj[k]=f;continue;}}obj[k]=opts[k];}}// And now some options which should receive some special processing: +let pre=obj.pre_lex;let post=obj.post_lex;// since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: +if(pre){obj.pre_lex=true;}if(post){obj.post_lex=true;}let js=JSON.stringify(obj,null,2);js=js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$1})": `,'g'),' $1: ');js=js.replace(/^( +)pre_lex: true(,)?$/gm,function(m,ls,tc){return ls+'pre_lex: '+String(pre)+(tc||'');});js=js.replace(/^( +)post_lex: true(,)?$/gm,function(m,ls,tc){return ls+'post_lex: '+String(post)+(tc||'');});return js;}let out;if(opt.rules.length>0||opt.__in_rules_failure_analysis_mode__){// we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. -var code=[rmCommonWS$2` - var lexer = { - `,'/*JISON-LEX-ANALYTICS-REPORT*/'/* slot #1: placeholder for analysis report further below */];// get the RegExpLexer.prototype in source code form: -var protosrc=getRegExpLexerPrototype();// and strip off the surrounding bits we don't want: +let code=[rmCommonWS$2` + const lexer = { + `,'/* JISON-LEX-ANALYTICS-REPORT */\n'/* slot #1: placeholder for analysis report further below */];// get the RegExpLexer.prototype in source code form: +let protosrc=getRegExpLexerPrototype();// and strip off the surrounding bits we don't want: protosrc=protosrc.replace(/^[\s\r\n]*\{/,'').replace(/\s*\}[\s\r\n]*$/,'').trim();code.push(protosrc+',\n');assert__default['default'](opt.options);// Assure all options are camelCased: assert__default['default'](typeof opt.options['case-insensitive']==='undefined');code.push(' options: '+produceOptions(opt.options));/* function isEmpty(code) { @@ -5116,7 +5102,7 @@ assert__default['default'](typeof opt.options['case-insensitive']==='undefined') } } -*/var performActionCode=String(opt.performAction);var simpleCaseActionClustersCode=String(opt.caseHelperInclude);var rulesCode=generateRegexesInitTableCode(opt);var conditionsCode=cleanupJSON(JSON.stringify(opt.conditions,null,2));code.push(rmCommonWS$2`, +*/let performActionCode=String(opt.performAction);let simpleCaseActionClustersCode=String(opt.caseHelperInclude);let rulesCode=generateRegexesInitTableCode(opt);let conditionsCode=cleanupJSON(JSON.stringify(opt.conditions,null,2));code.push(rmCommonWS$2`, JisonLexerError: JisonLexerError, performAction: ${performActionCode}, simpleCaseActionClusters: ${simpleCaseActionClustersCode}, @@ -5129,18 +5115,16 @@ assert__default['default'](typeof opt.options['case-insensitive']==='undefined') // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // -// Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter +// Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. -out='var lexer;\n';assert__default['default'](opt.regular_rule_count===0);assert__default['default'](opt.simple_rule_count===0);opt.is_custom_lexer=true;if(opt.actionInclude){out+=opt.actionInclude+(!opt.actionInclude.match(/;[\s\r\n]*$/)?';':'')+'\n';}}// The output of this function is guaranteed to read something like this: +out='\n';assert__default['default'](opt.regular_rule_count===0);assert__default['default'](opt.simple_rule_count===0);opt.is_custom_lexer=true;if(opt.actionInclude){out+=opt.actionInclude+(!opt.actionInclude.match(/;[\s\r\n]*$/)?';':'')+'\n';}}// The output of this function is guaranteed to read something like this: // // ``` -// var lexer; -// // bla bla bla bla ... lotsa bla bla; // ``` // // and that should work nicely as an `eval()`-able piece of source code. -return out;}function generateGenericHeaderComment(){var out=rmCommonWS$2` +return out;}function generateGenericHeaderComment(){let out=rmCommonWS$2` /* lexer generated by jison-lex ${version} */ /* @@ -5359,8 +5343,8 @@ return out;}function generateGenericHeaderComment(){var out=rmCommonWS$2` * } */ `;return out;}function prepareOptions(opt){opt=opt||{};// check for illegal identifier -if(!opt.moduleName||!opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)){if(opt.moduleName){var msg='WARNING: The specified moduleName "'+opt.moduleName+'" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.';if(typeof opt.warn_cb==='function'){opt.warn_cb(msg);}else{// do not treat as warning; barf hairball instead so that this oddity gets noticed right away! -throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return opt;}function generateModule(opt){opt=prepareOptions(opt);var modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';var src=rmCommonWS$2` +if(!opt.moduleName||!opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)){if(opt.moduleName){let msg='WARNING: The specified moduleName "'+opt.moduleName+'" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.';if(typeof opt.warn_cb==='function'){opt.warn_cb(msg);}else{// do not treat as warning; barf hairball instead so that this oddity gets noticed right away! +throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return opt;}function generateModule(opt){opt=prepareOptions(opt);let modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';let src=rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -5374,7 +5358,7 @@ throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return return lexer; })(); - `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateAMDModule(opt){opt=prepareOptions(opt);var modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';var src=rmCommonWS$2` + `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateAMDModule(opt){opt=prepareOptions(opt);let modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';let src=rmCommonWS$2` ${generateGenericHeaderComment()} define([], function () { @@ -5388,10 +5372,10 @@ throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return return lexer; }); - `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateESModule(opt){opt=prepareOptions(opt);var modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';var src=rmCommonWS$2` + `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateESModule(opt){opt=prepareOptions(opt);let modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';let src=rmCommonWS$2` ${generateGenericHeaderComment()} - var lexer = (function () { + const lexer = (function () { "use strict"; ${jisonLexerErrorDefinition} @@ -5411,7 +5395,7 @@ throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return lexer, yylex as lex }; - `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateCommonJSModule(opt){opt=prepareOptions(opt);var modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';var src=rmCommonWS$2` + `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateCommonJSModule(opt){opt=prepareOptions(opt);let modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';let src=rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -5432,21 +5416,21 @@ throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return return ${opt.moduleName}.lex.apply(lexer, arguments); }; } - `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}RegExpLexer.generate=generate;RegExpLexer.version=version;RegExpLexer.defaultJisonLexOptions=defaultJisonLexOptions;RegExpLexer.mkStdOptions=mkStdOptions;RegExpLexer.camelCase=helpers.camelCase;RegExpLexer.mkIdentifier=mkIdentifier$2;RegExpLexer.autodetectAndConvertToJSONformat=autodetectAndConvertToJSONformat;var mkIdentifier$3=helpers.mkIdentifier;var version$1='0.6.2-220';// require('./package.json').version; -function getCommandlineOptions(){var opts=nomnom__default['default'].script('jison-lex').unknownOptionTreatment(false)// do not accept unknown options! -.options({file:{flag:true,position:0,help:'file containing a lexical grammar.'},json:{abbr:'j',flag:true,default:false,help:'jison will expect a grammar in either JSON/JSON5 or JISON format: the precise format is autodetected.'},outfile:{abbr:'o',metavar:'FILE',help:'Filepath and base module name of the generated parser. When terminated with a "/" (dir separator) it is treated as the destination directory where the generated output will be stored.'},debug:{abbr:'t',flag:true,default:false,help:'Debug mode.'},dumpSourceCodeOnFailure:{full:'dump-sourcecode-on-failure',flag:true,default:true,help:'Dump the generated source code to a special named file when the internal generator tests fail, i.e. when the generated source code does not compile in the JavaScript engine. Enabling this option helps you to diagnose/debug crashes (thrown exceptions) in the code generator due to various reasons: you can, for example, load the dumped sourcecode in another environment (e.g. NodeJS) to get more info on the precise location and cause of the compile failure.'},throwErrorOnCompileFailure:{full:'throw-on-compile-failure',flag:true,default:true,help:'Throw an exception when the generated source code fails to compile in the JavaScript engine. **WARNING**: Turning this feature OFF permits the code generator to produce non-working source code and treat that as SUCCESS. This MAY be desirable code generator behaviour, but only rarely.'},reportStats:{full:'info',abbr:'I',flag:true,default:false,help:'Report some statistics about the generated parser.'},moduleType:{full:'module-type',abbr:'m',default:'commonjs',metavar:'TYPE',choices:['commonjs','amd','js','es'],help:'The type of module to generate (commonjs, amd, es, js)'},moduleName:{full:'module-name',abbr:'n',metavar:'NAME',help:'The name of the generated parser object, namespace supported.'},main:{full:'main',abbr:'x',flag:true,default:false,help:'Include .main() entry point in generated commonjs module.'},moduleMain:{full:'module-main',abbr:'y',metavar:'NAME',help:'The main module function definition.'},version:{abbr:'V',flag:true,help:'Print version and exit.',callback:function(){console.log(version$1);process.exit(0);}}}).parse();if(opts.debug){console.log("JISON-LEX CLI options:\n",opts);}return opts;}function cliMain(opts){opts=RegExpLexer.mkStdOptions(opts);function isDirectory(fp){try{return fs__default['default'].lstatSync(fp).isDirectory();}catch(e){return false;}}function mkdirp(fp){if(!fp||fp==='.'||fp.length===0){return false;}try{fs__default['default'].mkdirSync(fp);return true;}catch(e){if(e.code==='ENOENT'){var parent=path__default['default'].dirname(fp);// Did we hit the root directory by now? If so, abort! + `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}RegExpLexer.generate=generate;RegExpLexer.version=version;RegExpLexer.defaultJisonLexOptions=defaultJisonLexOptions;RegExpLexer.mkStdOptions=mkStdOptions;RegExpLexer.camelCase=helpers.camelCase;RegExpLexer.mkIdentifier=mkIdentifier$2;RegExpLexer.autodetectAndConvertToJSONformat=autodetectAndConvertToJSONformat;const mkIdentifier$3=helpers.mkIdentifier;const version$1='0.6.2-220';// require('./package.json').version; +function getCommandlineOptions(){let opts=nomnom__default['default'].script('jison-lex').unknownOptionTreatment(false)// do not accept unknown options! +.options({file:{flag:true,position:0,help:'file containing a lexical grammar.'},json:{abbr:'j',flag:true,default:false,help:'jison will expect a grammar in either JSON/JSON5 or JISON format: the precise format is autodetected.'},outfile:{abbr:'o',metavar:'FILE',help:'Filepath and base module name of the generated parser. When terminated with a "/" (dir separator) it is treated as the destination directory where the generated output will be stored.'},debug:{abbr:'t',flag:true,default:false,help:'Debug mode.'},dumpSourceCodeOnFailure:{full:'dump-sourcecode-on-failure',flag:true,default:true,help:'Dump the generated source code to a special named file when the internal generator tests fail, i.e. when the generated source code does not compile in the JavaScript engine. Enabling this option helps you to diagnose/debug crashes (thrown exceptions) in the code generator due to various reasons: you can, for example, load the dumped sourcecode in another environment (e.g. NodeJS) to get more info on the precise location and cause of the compile failure.'},throwErrorOnCompileFailure:{full:'throw-on-compile-failure',flag:true,default:true,help:'Throw an exception when the generated source code fails to compile in the JavaScript engine. **WARNING**: Turning this feature OFF permits the code generator to produce non-working source code and treat that as SUCCESS. This MAY be desirable code generator behaviour, but only rarely.'},reportStats:{full:'info',abbr:'I',flag:true,default:false,help:'Report some statistics about the generated parser.'},moduleType:{full:'module-type',abbr:'m',default:'commonjs',metavar:'TYPE',choices:['commonjs','amd','js','es'],help:'The type of module to generate (commonjs, amd, es, js)'},moduleName:{full:'module-name',abbr:'n',metavar:'NAME',help:'The name of the generated parser object, namespace supported.'},main:{full:'main',abbr:'x',flag:true,default:false,help:'Include .main() entry point in generated commonjs module.'},moduleMain:{full:'module-main',abbr:'y',metavar:'NAME',help:'The main module function definition.'},version:{abbr:'V',flag:true,help:'Print version and exit.',callback:function(){console.log(version$1);process.exit(0);}}}).parse();if(opts.debug){console.log('JISON-LEX CLI options:\n',opts);}return opts;}function cliMain(opts){opts=RegExpLexer.mkStdOptions(opts);function isDirectory(fp){try{return fs__default['default'].lstatSync(fp).isDirectory();}catch(e){return false;}}function mkdirp(fp){if(!fp||fp==='.'||fp.length===0){return false;}try{fs__default['default'].mkdirSync(fp);return true;}catch(e){if(e.code==='ENOENT'){let parent=path__default['default'].dirname(fp);// Did we hit the root directory by now? If so, abort! // Else, create the parent; iff that fails, we fail too... if(parent!==fp&&mkdirp(parent)){try{// Retry creating the original directory: it should succeed now -fs__default['default'].mkdirSync(fp);return true;}catch(e){return false;}}}}return false;}function processInputFile(){var original_cwd=process.cwd();var raw=fs__default['default'].readFileSync(path__default['default'].normalize(opts.file),'utf8');// making best guess at json mode +fs__default['default'].mkdirSync(fp);return true;}catch(e){return false;}}}}return false;}function processInputFile(){let original_cwd=process.cwd();let raw=fs__default['default'].readFileSync(path__default['default'].normalize(opts.file),'utf8');// making best guess at json mode opts.json=path__default['default'].extname(opts.file)==='.json'||opts.json;// When only the directory part of the output path was specified, then we // do NOT have the target module name in there as well! -var outpath=opts.outfile;if(typeof outpath==='string'){if(/[\\\/]$/.test(outpath)||isDirectory(outpath)){opts.outfile=null;outpath=outpath.replace(/[\\\/]$/,'');}else{outpath=path__default['default'].dirname(outpath);}}else{outpath=null;}if(outpath&&outpath.length>0){outpath+='/';}else{outpath='';}// setting output file name and module name based on input file name +let outpath=opts.outfile;if(typeof outpath==='string'){if(/[\\\/]$/.test(outpath)||isDirectory(outpath)){opts.outfile=null;outpath=outpath.replace(/[\\\/]$/,'');}else{outpath=path__default['default'].dirname(outpath);}}else{outpath=null;}if(outpath&&outpath.length>0){outpath+='/';}else{outpath='';}// setting output file name and module name based on input file name // if they aren't specified. -var name=path__default['default'].basename(opts.outfile||opts.file);// get the base name (i.e. the file name without extension) +let name=path__default['default'].basename(opts.outfile||opts.file);// get the base name (i.e. the file name without extension) // i.e. strip off only the extension and keep any other dots in the filename name=path__default['default'].basename(name,path__default['default'].extname(name));opts.outfile=opts.outfile||outpath+name+'.js';if(!opts.moduleName&&name){opts.moduleName=opts.defaultModuleName=mkIdentifier$3(name);}// Change CWD to the directory where the source grammar resides: this helps us properly // %include any files mentioned in the grammar with relative paths: -var new_cwd=path__default['default'].dirname(path__default['default'].normalize(opts.file));process.chdir(new_cwd);var lexer=cli.generateLexerString(raw,opts);// and change back to the CWD we started out with: -process.chdir(original_cwd);opts.outfile=path__default['default'].normalize(opts.outfile);mkdirp(path__default['default'].dirname(opts.outfile));fs__default['default'].writeFileSync(opts.outfile,lexer);console.log('JISON-LEX output for module ['+opts.moduleName+'] has been written to file:',opts.outfile);}function readin(cb){var stdin=process.openStdin(),data='';stdin.setEncoding('utf8');stdin.addListener('data',function(chunk){data+=chunk;});stdin.addListener('end',function(){cb(data);});}function processStdin(){readin(function processStdinReadInCallback(raw){console.log(cli.generateLexerString(raw,opts));});}// if an input file wasn't given, assume input on stdin +let new_cwd=path__default['default'].dirname(path__default['default'].normalize(opts.file));process.chdir(new_cwd);let lexer=cli.generateLexerString(raw,opts);// and change back to the CWD we started out with: +process.chdir(original_cwd);opts.outfile=path__default['default'].normalize(opts.outfile);mkdirp(path__default['default'].dirname(opts.outfile));fs__default['default'].writeFileSync(opts.outfile,lexer);console.log('JISON-LEX output for module ['+opts.moduleName+'] has been written to file:',opts.outfile);}function readin(cb){const stdin=process.openStdin();let data='';stdin.setEncoding('utf8');stdin.addListener('data',function(chunk){data+=chunk;});stdin.addListener('end',function(){cb(data);});}function processStdin(){readin(function processStdinReadInCallback(raw){console.log(cli.generateLexerString(raw,opts));});}// if an input file wasn't given, assume input on stdin if(opts.file){processInputFile();}else{processStdin();}}function generateLexerString(lexerSpec,opts){// var settings = RegExpLexer.mkStdOptions(opts); -var predefined_tokens=null;return RegExpLexer.generate(lexerSpec,predefined_tokens,opts);}var cli={main:cliMain,generateLexerString:generateLexerString};if(require.main===module){var opts=getCommandlineOptions();cli.main(opts);}module.exports=cli; +let predefined_tokens=null;return RegExpLexer.generate(lexerSpec,predefined_tokens,opts);}var cli={main:cliMain,generateLexerString:generateLexerString};if(require.main===module){const opts=getCommandlineOptions();cli.main(opts);}module.exports=cli; diff --git a/packages/jison-lex/dist/cli-cjs.js b/packages/jison-lex/dist/cli-cjs.js index 1fd640d71..652980772 100644 --- a/packages/jison-lex/dist/cli-cjs.js +++ b/packages/jison-lex/dist/cli-cjs.js @@ -7,6 +7,7 @@ var fs = require('fs'); var path$1 = require('path'); var nomnom = require('@gerhobbelt/nomnom'); var JSON5 = require('@gerhobbelt/json5'); +var mkdirp = require('mkdirp'); var XRegExp = require('@gerhobbelt/xregexp'); var recast = require('recast'); var babel = require('@babel/core'); @@ -18,11 +19,12 @@ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); var nomnom__default = /*#__PURE__*/_interopDefaultLegacy(nomnom); var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); +var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); -// Return TRUE if `src` starts with `searchString`. +// Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -45,19 +47,19 @@ function rmCommonWS(strings, ...values) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -76,19 +78,21 @@ function rmCommonWS(strings, ...values) { // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -97,16 +101,19 @@ function rmCommonWS(strings, ...values) { } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -117,27 +124,79 @@ function camelCase(s) { return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } +// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; +})([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' +]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -155,6 +214,11 @@ function mkIdentifier(s) { .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -163,13 +227,13 @@ function mkIdentifier(s) { function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -180,23 +244,17 @@ function scanRegExp(s) { break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -219,34 +277,33 @@ function isLineTerminator(cp) { /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -269,28 +326,76 @@ function chkBugger(src) { // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } +function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; +} + + +function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); +} + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -301,27 +406,37 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -331,7 +446,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -339,7 +454,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -365,27 +480,43 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -398,9 +529,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -422,22 +554,22 @@ assert__default['default'](recast__default['default']); // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; -// Determine which Unicode NonAsciiIdentifierStart characters +// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -445,40 +577,40 @@ const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -486,30 +618,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -520,59 +652,59 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -614,38 +746,38 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -657,18 +789,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -679,56 +811,56 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -736,97 +868,97 @@ function generateMapper4JisonGrammarIdentifiers(input) { typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -834,7 +966,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -847,7 +979,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -860,7 +992,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -873,7 +1005,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -892,37 +1024,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -954,7 +1086,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -971,37 +1103,37 @@ function parseCodeChunkToAST(src, options) { .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return babel.transformSync(src, options); // => { code, map, ast } @@ -1009,8 +1141,8 @@ function compileCodeToES5(src, options) { function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1019,7 +1151,7 @@ function prettyPrintAST(ast, options) { // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1042,25 +1174,25 @@ function prettyPrintAST(ast, options) { // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1071,9 +1203,9 @@ function checkActionBlock(src, yylloc, options) { // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1081,7 +1213,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1090,14 +1222,14 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1151,7 +1283,7 @@ var parse2AST = { trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1165,7 +1297,7 @@ function chkBugger$1(src) { /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1177,24 +1309,24 @@ const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?: /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1211,8 +1343,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1223,14 +1355,14 @@ function printFunctionSourceCodeContainer(f) { action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1241,17 +1373,17 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; -// -// -// +// +// +// function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1277,7 +1409,7 @@ function detectIstanbulGlobal() { // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1325,7 +1457,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1388,13 +1520,13 @@ var reHelpers = { getRegExpInfo: getRegExpInfo }; -var cycleref = []; -var cyclerefpath = []; +let cycleref = []; +let cyclerefpath = []; -var linkref = []; -var linkrefpath = []; +let linkref = []; +let linkrefpath = []; -var path = []; +let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1402,14 +1534,14 @@ function shallow_copy(src) { return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1422,11 +1554,11 @@ function shallow_copy(src) { function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1439,9 +1571,9 @@ function shallow_copy_and_strip_depth(src, parentKey) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1456,16 +1588,52 @@ function shallow_copy_and_strip_depth(src, parentKey) { } +// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } +// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; +} + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1480,7 +1648,7 @@ function trim_array_tail(arr) { function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1506,10 +1674,10 @@ function treat_value_stack(v) { } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1607,7 +1775,7 @@ function treat_hash(h) { function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1624,7 +1792,7 @@ function treat_error_report_info(e) { path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1652,7 +1820,7 @@ function treat_error_report_info(e) { function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1668,7 +1836,7 @@ function treat_object(e) { linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1680,14 +1848,14 @@ function treat_object(e) { // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1697,7 +1865,7 @@ function trimErrorForTestReporting(e) { cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1711,12 +1879,14 @@ var helpers = { dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1731,7 +1901,7 @@ var helpers = { printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; // See also: @@ -1739,7 +1909,6 @@ var helpers = { // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1756,9 +1925,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -1791,10 +1960,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -1807,11 +1976,11 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -1821,18 +1990,18 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -1863,7 +2032,7 @@ JisonParserError.prototype.name = 'JisonParserError'; // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -1880,9 +2049,9 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -1895,7 +2064,7 @@ JisonParserError.prototype.name = 'JisonParserError'; } -var parser = { +let parser = { // Code Generator Information Report // --------------------------------- // @@ -2145,7 +2314,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2153,7 +2321,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2165,8 +2332,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2179,14 +2346,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2202,10 +2368,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2213,10 +2379,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2371,9 +2537,9 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -2385,18 +2551,18 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2426,9 +2592,9 @@ case 1: case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -2441,10 +2607,10 @@ case 2: case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2471,9 +2637,9 @@ case 3: case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -2482,10 +2648,10 @@ case 4: case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2513,9 +2679,9 @@ case 5: case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -2524,10 +2690,10 @@ case 6: case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -2566,9 +2732,9 @@ case 7: case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2633,9 +2799,9 @@ case 8: case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2650,9 +2816,9 @@ case 9: case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -2687,10 +2853,10 @@ case 10: case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2707,9 +2873,9 @@ case 11: case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2726,10 +2892,10 @@ case 12: case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2746,9 +2912,9 @@ case 13: case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2765,10 +2931,10 @@ case 14: case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2785,9 +2951,9 @@ case 15: case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -2811,9 +2977,9 @@ case 17: case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -2824,9 +2990,9 @@ case 132: case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2846,9 +3012,9 @@ case 18: case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2872,9 +3038,9 @@ case 19: case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2887,10 +3053,10 @@ case 20: case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2907,9 +3073,9 @@ case 21: case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2921,9 +3087,9 @@ case 22: case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -2963,10 +3129,10 @@ case 23: case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2986,9 +3152,9 @@ case 24: case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3038,10 +3204,10 @@ case 25: case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -3065,10 +3231,10 @@ case 26: case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3088,10 +3254,10 @@ case 27: case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3115,10 +3281,10 @@ case 28: case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3139,10 +3305,10 @@ case 29: case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3154,10 +3320,10 @@ case 31: case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3167,10 +3333,10 @@ case 33: case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3180,10 +3346,10 @@ case 32: case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3193,10 +3359,10 @@ case 34: case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3206,10 +3372,10 @@ case 35: case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -3219,10 +3385,10 @@ case 36: case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3232,10 +3398,10 @@ case 37: case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3245,9 +3411,9 @@ case 38: case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -3256,9 +3422,9 @@ case 39: case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -3267,9 +3433,9 @@ case 40: case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3291,9 +3457,9 @@ case 41: case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3304,9 +3470,9 @@ case 42: case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3326,9 +3492,9 @@ case 43: case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3382,9 +3548,9 @@ case 49: case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3404,9 +3570,9 @@ case 51: case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -3415,9 +3581,9 @@ case 58: case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -3429,9 +3595,9 @@ case 52: case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -3445,10 +3611,10 @@ case 53: case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3468,10 +3634,10 @@ case 54: case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3491,10 +3657,10 @@ case 55: case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3514,9 +3680,9 @@ case 56: case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3527,9 +3693,9 @@ case 59: case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3548,9 +3714,9 @@ case 60: case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -3591,9 +3757,9 @@ case 61: case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3617,9 +3783,9 @@ case 62: case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3645,9 +3811,9 @@ case 63: case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3692,9 +3858,9 @@ case 64: case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -3720,9 +3886,9 @@ case 106: case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -3731,9 +3897,9 @@ case 127: case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -3742,10 +3908,10 @@ case 67: case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3759,10 +3925,10 @@ case 68: case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3776,10 +3942,10 @@ case 69: case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3793,10 +3959,10 @@ case 70: case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3815,9 +3981,9 @@ case 72: case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -3826,9 +3992,9 @@ case 77: case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -3866,10 +4032,10 @@ case 73: case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -3893,9 +4059,9 @@ case 74: case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -3974,9 +4140,9 @@ case 110: case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -3985,9 +4151,9 @@ case 129: case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -3996,9 +4162,9 @@ case 78: case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -4007,9 +4173,9 @@ case 79: case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -4018,9 +4184,9 @@ case 80: case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -4029,9 +4195,9 @@ case 81: case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -4040,9 +4206,9 @@ case 85: case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -4053,10 +4219,10 @@ case 87: case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4073,9 +4239,9 @@ case 88: case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -4084,9 +4250,9 @@ case 89: case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -4095,9 +4261,9 @@ case 90: case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -4106,9 +4272,9 @@ case 91: case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -4117,9 +4283,9 @@ case 92: case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -4138,18 +4304,18 @@ case 107: case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -4158,9 +4324,9 @@ case 97: case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -4169,9 +4335,9 @@ case 98: case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -4180,9 +4346,9 @@ case 99: case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -4191,9 +4357,9 @@ case 102: case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -4202,10 +4368,10 @@ case 104: case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4222,9 +4388,9 @@ case 105: case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -4241,9 +4407,9 @@ case 109: case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -4255,9 +4421,9 @@ case 111: case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -4267,9 +4433,9 @@ case 112: case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4304,9 +4470,9 @@ case 113: case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4325,9 +4491,9 @@ case 114: case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -4336,9 +4502,9 @@ case 115: case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -4347,9 +4513,9 @@ case 116: case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4367,10 +4533,10 @@ case 117: case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -4388,10 +4554,10 @@ case 118: case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -4412,9 +4578,9 @@ case 119: case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4447,9 +4613,9 @@ case 120: case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4475,9 +4641,9 @@ case 121: case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5__default['default'].parse(yyvstack[yysp]); @@ -4486,9 +4652,9 @@ case 122: case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue(yyvstack[yysp]); @@ -4497,9 +4663,9 @@ case 123: case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4508,9 +4674,9 @@ case 124: case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -4531,10 +4697,10 @@ case 125: case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4551,9 +4717,9 @@ case 126: case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -4572,9 +4738,9 @@ case 128: case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4598,9 +4764,9 @@ case 130: case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -4620,9 +4786,9 @@ case 131: case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4633,9 +4799,9 @@ case 133: case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -4691,10 +4857,10 @@ case 134: case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6297,7 +6463,6 @@ defaultActions: bda({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -6314,38 +6479,34 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -6353,20 +6514,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -6388,7 +6547,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -6396,18 +6554,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -6415,24 +6574,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -6470,18 +6624,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -6502,7 +6653,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -6520,7 +6671,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -6533,7 +6683,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -6547,11 +6696,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -6605,8 +6753,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6614,8 +6762,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6647,19 +6795,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -6670,7 +6817,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -6683,7 +6830,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -6695,29 +6842,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -6725,7 +6870,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -6745,8 +6890,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -6755,10 +6899,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -6766,7 +6910,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -6777,9 +6921,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -6795,8 +6944,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -6865,11 +7013,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -6880,8 +7031,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -6890,21 +7040,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6914,21 +7063,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6937,28 +7085,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -6971,8 +7118,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -6995,8 +7141,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -7008,8 +7153,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -7026,8 +7170,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -7041,8 +7184,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -7056,7 +7198,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -7109,16 +7251,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -7152,9 +7291,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -7177,9 +7314,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -7206,17 +7341,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -7263,8 +7397,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -7276,8 +7410,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -7295,6 +7428,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -7303,7 +7437,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -7314,7 +7448,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -7374,10 +7508,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -7412,9 +7546,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -7427,7 +7559,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -7448,9 +7580,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7472,12 +7602,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -7486,7 +7616,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7527,7 +7657,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -7574,7 +7704,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -7592,21 +7722,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7640,14 +7768,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7657,6 +7786,7 @@ parse: function parse(input) { + } continue; // accept: @@ -7708,7 +7838,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -7724,9 +7854,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7755,7 +7883,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7772,8 +7900,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -7784,8 +7912,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -7797,21 +7925,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7842,14 +7968,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7859,6 +7986,7 @@ parse: function parse(input) { + } continue; // accept: @@ -7911,8 +8039,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -8173,7 +8300,6 @@ var lexer = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -8190,10 +8316,10 @@ var lexer = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -8225,7 +8351,7 @@ var lexer = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -8267,7 +8393,9 @@ var lexer = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -8353,7 +8481,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -8361,7 +8489,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -8374,7 +8502,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -8400,10 +8528,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -8426,7 +8557,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -8449,16 +8579,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -8480,7 +8610,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -8488,8 +8617,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -8518,7 +8647,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -8543,7 +8672,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -8555,17 +8684,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -8659,7 +8788,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -8680,7 +8809,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -8691,7 +8819,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -8702,15 +8830,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -8744,8 +8872,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -8778,9 +8906,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -8799,9 +8927,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -8811,8 +8939,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -8839,20 +8967,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -8892,17 +9019,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8911,7 +9040,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -8926,8 +9055,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -8953,24 +9082,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8981,7 +9112,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -9003,8 +9134,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -9026,8 +9157,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -9171,21 +9301,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -9200,11 +9330,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -9223,13 +9353,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -9253,13 +9383,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -9274,8 +9404,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -9306,7 +9436,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -9338,9 +9468,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -9369,7 +9499,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -9387,7 +9517,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -9412,7 +9542,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -9422,8 +9551,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -9432,7 +9559,7 @@ EOF: 1, this.clear(); } - 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. @@ -9444,13 +9571,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -9460,68 +9587,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -9546,7 +9679,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -9594,24 +9727,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9631,7 +9764,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -9641,24 +9774,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9679,8 +9812,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -9720,14 +9852,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -9743,9 +9875,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -9756,8 +9888,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -9765,7 +9897,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -11455,7 +11587,7 @@ const UNICODE_BASE_PLANE_MAX_CP = 65535; // The expanded regex sets which are equivalent to the given `\\{c}` escapes: // // `/\s/`: -const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; +const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; // `/\d/`: const DIGIT_SETSTR = '0-9'; // `/\w/`: @@ -11467,7 +11599,7 @@ const WORDCHAR_SETSTR = 'A-Za-z0-9_'; // Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex function i2c(i) { - var c, x; + let c, x; switch (i) { case 10: @@ -11507,7 +11639,7 @@ function i2c(i) { || i > 0xFFF0 /* Unicode Specials, also in UTF16 */ || (i >= 0xD800 && i <= 0xDFFF) /* Unicode Supplementary Planes; we're TOAST in JavaScript as we're NOT UTF-16 but UCS-2! */ || String.fromCharCode(i).match(/[\u2028\u2029]/) /* Code compilation via `new Function()` does not like to see these, or rather: treats them as just another form of CRLF, which breaks your generated regex code! */ - ) { + ) { // Detail about a detail: // U+2028 and U+2029 are part of the `\s` regex escape code (`\s` and `[\s]` match either of these) and when placed in a JavaScript // source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report @@ -11515,11 +11647,10 @@ function i2c(i) { // Hence we MUST escape these buggers everywhere we go... x = i.toString(16); if (x.length >= 1 && i <= 0xFFFF) { - c = '0000' + x; - return '\\u' + c.substr(c.length - 4); - } else { - return '\\u{' + x + '}'; + c = '0000' + x; + return '\\u' + c.substr(c.length - 4); } + return '\\u{' + x + '}'; } return String.fromCharCode(i); } @@ -11528,18 +11659,18 @@ function i2c(i) { // Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating // this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a // `\\p{NAME}` shorthand to represent [part of] the bitarray: -var Pcodes_bitarray_cache = {}; -var Pcodes_bitarray_cache_test_order = []; +let Pcodes_bitarray_cache = {}; +let Pcodes_bitarray_cache_test_order = []; -// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by +// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. -var EscCode_bitarray_output_refs; +let EscCode_bitarray_output_refs; // now initialize the EscCodes_... table above: init_EscCode_lookup_table(); function init_EscCode_lookup_table() { - var s, bitarr, set2esc = {}, esc2bitarr = {}; + let s, bitarr, set2esc = {}, esc2bitarr = {}; // patch global lookup tables for the time being, while we calculate their *real* content in this function: EscCode_bitarray_output_refs = { @@ -11608,13 +11739,13 @@ function init_EscCode_lookup_table() { }; updatePcodesBitarrayCacheTestOrder(); -} +} function updatePcodesBitarrayCacheTestOrder(opts) { - var t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var l = {}; - var user_has_xregexp = opts && opts.options && opts.options.xregexp; - var i, j, k, ba; + let t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let l = {}; + let user_has_xregexp = opts && opts.options && opts.options.xregexp; + let i, j, k, ba; // mark every character with which regex pcodes they are part of: for (k in Pcodes_bitarray_cache) { @@ -11624,12 +11755,12 @@ function updatePcodesBitarrayCacheTestOrder(opts) { continue; } - var cnt = 0; + let cnt = 0; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { cnt++; if (!t[i]) { - t[i] = [k]; + t[i] = [ k ]; } else { t[i].push(k); } @@ -11639,27 +11770,27 @@ function updatePcodesBitarrayCacheTestOrder(opts) { } // now dig out the unique ones: only need one per pcode. - // + // // We ASSUME every \\p{NAME} 'pcode' has at least ONE character - // in it that is ONLY matched by that particular pcode. + // in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode - // won't be tested during optimization. - // + // won't be tested during optimization. + // // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to // look for markers which match multiple escapes/pcodes for those // ones where a unique item isn't available... - var lut = []; - var done = {}; - var keys = Object.keys(Pcodes_bitarray_cache); + let lut = []; + let done = {}; + let keys = Object.keys(Pcodes_bitarray_cache); for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { k = t[i][0]; if (t[i].length === 1 && !done[k]) { assert__default['default'](l[k] > 0); - lut.push([i, k]); + lut.push([ i, k ]); done[k] = true; } } @@ -11670,19 +11801,19 @@ function updatePcodesBitarrayCacheTestOrder(opts) { if (!user_has_xregexp && k.indexOf('\\p{') >= 0) { continue; } - + if (!done[k]) { assert__default['default'](l[k] > 0); // find a minimum span character to mark this one: - var w = Infinity; + let w = Infinity; var rv; ba = Pcodes_bitarray_cache[k]; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { - var tl = t[i].length; + let tl = t[i].length; if (tl > 1 && tl < w) { assert__default['default'](l[k] > 0); - rv = [i, k]; + rv = [ i, k ]; w = tl; } } @@ -11696,16 +11827,16 @@ function updatePcodesBitarrayCacheTestOrder(opts) { // order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. - // + // // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more - // optimal minification of the regex set expression. - // + // optimal minification of the regex set expression. + // // This is a guestimate/heuristic only! lut.sort(function (a, b) { - var k1 = a[1]; - var k2 = b[1]; - var ld = l[k2] - l[k1]; + let k1 = a[1]; + let k2 = b[1]; + let ld = l[k2] - l[k1]; if (ld) { return ld; } @@ -11723,19 +11854,19 @@ function updatePcodesBitarrayCacheTestOrder(opts) { // 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set. function set2bitarray(bitarr, s, opts) { - var orig = s; - var set_is_inverted = false; - var bitarr_orig; + let orig = s; + let set_is_inverted = false; + let bitarr_orig; function mark(d1, d2) { if (d2 == null) d2 = d1; - for (var i = d1; i <= d2; i++) { + for (let i = d1; i <= d2; i++) { bitarr[i] = true; } } function add2bitarray(dst, src) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (src[i]) { dst[i] = true; } @@ -11743,10 +11874,10 @@ function set2bitarray(bitarr, s, opts) { } function eval_escaped_code(s) { - var c; + let c; // decode escaped code? If none, just take the character as-is if (s.indexOf('\\') === 0) { - var l = s.substr(0, 2); + let l = s.substr(0, 2); switch (l) { case '\\c': c = s.charCodeAt(2) - 'A'.charCodeAt(0) + 1; @@ -11764,7 +11895,7 @@ function set2bitarray(bitarr, s, opts) { } c = parseInt(s, 16); if (c >= 0x10000) { - return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); + return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); } return String.fromCharCode(c); @@ -11808,7 +11939,7 @@ function set2bitarray(bitarr, s, opts) { } if (s && s.length) { - var c1, c2; + let c1, c2; // inverted set? if (s[0] === '^') { @@ -11839,13 +11970,13 @@ function set2bitarray(bitarr, s, opts) { c2 = c2[0]; s = s.substr(c2.length); // do we have this one cached already? - var pex = c1 + c2; - var ba4p = Pcodes_bitarray_cache[pex]; + let pex = c1 + c2; + let ba4p = Pcodes_bitarray_cache[pex]; if (!ba4p) { // expand escape: - var xr = new XRegExp__default['default']('[' + pex + ']'); // TODO: case-insensitive grammar??? + let xr = new XRegExp__default['default']('[' + pex + ']'); // TODO: case-insensitive grammar??? // rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`: - var xs = '' + xr; + let xs = '' + xr; // remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: xs = xs.substr(1, xs.length - 2); @@ -11880,7 +12011,7 @@ function set2bitarray(bitarr, s, opts) { break; } } - var v1 = eval_escaped_code(c1); + let v1 = eval_escaped_code(c1); // propagate deferred exceptions = error reports. if (v1 instanceof Error) { return v1; @@ -11898,7 +12029,7 @@ function set2bitarray(bitarr, s, opts) { } else { c2 = c2[0]; } - var v2 = eval_escaped_code(c2); + let v2 = eval_escaped_code(c2); // propagate deferred exceptions = error reports. if (v2 instanceof Error) { return v1; @@ -11921,12 +12052,12 @@ function set2bitarray(bitarr, s, opts) { } // When we have marked all slots, '^' NEGATES the set, hence we flip all slots. - // + // // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. if (set_is_inverted) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (!bitarr[i]) { bitarr_orig[i] = true; } @@ -11945,10 +12076,10 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // below can be simple and fast: l[UNICODE_BASE_PLANE_MAX_CP + 1] = 1; // now reconstruct the regex set: - var rv = []; - var i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; - var bitarr_is_cloned = false; - var l_orig = l; + let rv = []; + let i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; + let bitarr_is_cloned = false; + let l_orig = l; if (output_inverted_variant) { // generate the inverted set, hence all unmarked slots are part of the output range: @@ -11962,8 +12093,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. // BUT... since we output the INVERTED set, we output the match-all set instead: return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` // BUT... since we output the INVERTED set, we output the match-nothing set instead: @@ -11995,9 +12125,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12024,7 +12154,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } } - + i = 0; while (i <= UNICODE_BASE_PLANE_MAX_CP) { // find first character not in original set: @@ -12055,8 +12185,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. return '^\\S\\s'; } @@ -12086,9 +12215,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12140,11 +12269,11 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } assert__default['default'](rv.length); - var s = rv.join(''); + let s = rv.join(''); assert__default['default'](s); // Check if the set is better represented by one of the regex escapes: - var esc4s = EscCode_bitarray_output_refs.set2esc[s]; + let esc4s = EscCode_bitarray_output_refs.set2esc[s]; if (esc4s) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return '\\' + esc4s; @@ -12159,25 +12288,24 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there; // ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`. function reduceRegexToSetBitArray(s, name, opts) { - var orig = s; + let orig = s; // propagate deferred exceptions = error reports. if (s instanceof Error) { return s; } - var l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var internal_state = 0; - var derr; + let l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let internal_state = 0; + let derr; while (s.length) { - var c1 = s.match(CHR_RE); + let c1 = s.match(CHR_RE); if (!c1) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"'); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12185,15 +12313,14 @@ function reduceRegexToSetBitArray(s, name, opts) { // this is starting a set within the regex: scan until end of set! var set_content = []; while (s.length) { - var inner = s.match(SET_PART_RE); + let inner = s.match(SET_PART_RE); if (!inner) { inner = s.match(CHR_RE); if (!inner) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"'); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12207,9 +12334,8 @@ function reduceRegexToSetBitArray(s, name, opts) { if (!c2) { // cope with illegal escape sequences too! return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error('regex set expression is broken in regex: ' + orig); } @@ -12293,10 +12419,9 @@ function reduceRegexToSetBitArray(s, name, opts) { // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; assert__default['default'](s); assert__default['default'](!(s instanceof Error)); - re = new XRegExp__default['default']('[' + s + ']'); + let re = new XRegExp__default['default']('[' + s + ']'); re.test(s[0]); // One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` @@ -12321,25 +12446,24 @@ function reduceRegexToSetBitArray(s, name, opts) { -// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` +// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! function produceOptimizedRegex4Set(bitarr) { // First try to produce a minimum regex from the bitarray directly: - var s1 = bitarray2set(bitarr, false, true); + let s1 = bitarray2set(bitarr, false, true); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s1.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s1; - } else { - s1 = '[' + s1 + ']'; } + s1 = '[' + s1 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s2 = bitarray2set(bitarr, true, true); + let s2 = bitarray2set(bitarr, true, true); if (s2[0] === '^') { s2 = s2.substr(1); @@ -12354,23 +12478,22 @@ function produceOptimizedRegex4Set(bitarr) { // Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: - // + // // First try to produce a minimum regex from the bitarray directly: - var s3 = bitarray2set(bitarr, false, false); + let s3 = bitarray2set(bitarr, false, false); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s3.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s3; - } else { - s3 = '[' + s3 + ']'; } + s3 = '[' + s3 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s4 = bitarray2set(bitarr, true, false); + let s4 = bitarray2set(bitarr, true, false); if (s4[0] === '^') { s4 = s4.substr(1); @@ -12402,30 +12525,30 @@ function produceOptimizedRegex4Set(bitarr) { var setmgmt = { - XREGEXP_UNICODE_ESCAPE_RE, - CHR_RE, - SET_PART_RE, - NOTHING_SPECIAL_RE, - SET_IS_SINGLE_PCODE_RE, - - UNICODE_BASE_PLANE_MAX_CP, - - WHITESPACE_SETSTR, - DIGIT_SETSTR, - WORDCHAR_SETSTR, - - set2bitarray, - bitarray2set, - produceOptimizedRegex4Set, - reduceRegexToSetBitArray, + XREGEXP_UNICODE_ESCAPE_RE, + CHR_RE, + SET_PART_RE, + NOTHING_SPECIAL_RE, + SET_IS_SINGLE_PCODE_RE, + + UNICODE_BASE_PLANE_MAX_CP, + + WHITESPACE_SETSTR, + DIGIT_SETSTR, + WORDCHAR_SETSTR, + + set2bitarray, + bitarray2set, + produceOptimizedRegex4Set, + reduceRegexToSetBitArray }; // Basic Lexer implemented using JavaScript regular expressions -var rmCommonWS$2 = helpers.rmCommonWS; -var mkIdentifier$2 = helpers.mkIdentifier; -var code_exec$1 = helpers.exec; +const rmCommonWS$2 = helpers.rmCommonWS; +const mkIdentifier$2 = helpers.mkIdentifier; +const code_exec = helpers.exec; -var version = '0.6.2-220'; // require('./package.json').version; +const version = '0.6.2-220'; // require('./package.json').version; @@ -12486,7 +12609,7 @@ const defaultJisonLexOptions = { exportAST: false, prettyCfg: true, pre_lex: undefined, - post_lex: undefined, + post_lex: undefined }; @@ -12504,23 +12627,23 @@ const defaultJisonLexOptions = { // Return a fresh set of options. /** @public */ function mkStdOptions(/*...args*/) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - var args = [].concat.apply([], arguments); + let opts = {}; + let args = [].concat.apply([], arguments); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(defaultJisonLexOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; for (var p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { @@ -12558,7 +12681,7 @@ function mkStdOptions(/*...args*/) { function prepExportStructures(options) { // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -12579,8 +12702,8 @@ function prepExportStructures(options) { // Otherwise return the *parsed* lexer spec as it has // been processed through LexParser. function autodetectAndConvertToJSONformat(lexerSpec, options) { - var chk_l = null; - var ex1, err; + let chk_l = null; + let ex1, err; if (typeof lexerSpec === 'string') { if (options.json) { @@ -12632,9 +12755,9 @@ function autodetectAndConvertToJSONformat(lexerSpec, options) { /should be separated/, /an error in one or more of your lexer regex rules/, /an error in your lexer epilogue/, - /unsupported definition type/, + /unsupported definition type/ ]; - var cmnerr = commonErrors.filter(function check(re) { + let cmnerr = commonErrors.filter(function check(re) { return e.message.match(re); }); if (cmnerr.length > 0) { @@ -12663,14 +12786,14 @@ function autodetectAndConvertToJSONformat(lexerSpec, options) { // expand macros and convert matchers to RegExp's function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) { - var m, i, k, rule, action, conditions; - var active_conditions; + let m, i, k, rule, action, conditions; + let active_conditions; assert__default['default'](Array.isArray(dict.rules)); - var rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! - var newRules = []; - var macros = {}; - var regular_rule_count = 0; - var simple_rule_count = 0; + let rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! + let newRules = []; + let macros = {}; + let regular_rule_count = 0; + let simple_rule_count = 0; // Assure all options are camelCased: assert__default['default'](typeof opts.options['case-insensitive'] === 'undefined'); @@ -12680,7 +12803,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) } if (opts.options.flex && rules.length > 0) { - rules.push(['.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']); + rules.push([ '.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */' ]); } // Depending on the location within the regex we need different expansions of the macros: @@ -12704,7 +12827,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) return str; } - var routingCode = ['switch(yyrulenumber) {']; + let routingCode = [ 'switch(yyrulenumber) {' ]; for (i = 0; i < rules.length; i++) { rule = rules[i].slice(0); // shallow copy: do not modify input rules @@ -12758,7 +12881,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) action = action.replace(/return\s*\(?'((?:\\'|[^']+)+)'\)?/g, tokenNumberReplacement); action = action.replace(/return\s*\(?"((?:\\"|[^"]+)+)"\)?/g, tokenNumberReplacement); - var code = ['\n/*! Conditions::']; + let code = [ '\n/*! Conditions::' ]; code.push(postprocessComment(active_conditions)); code.push('*/', '\n/*! Rule:: '); code.push(postprocessComment(rule[0])); @@ -12779,7 +12902,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) // 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'. - var match_nr = /^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim()); + 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 ')); @@ -12806,7 +12929,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) macros: macros, regular_rule_count: regular_rule_count, - simple_rule_count: simple_rule_count, + simple_rule_count: simple_rule_count }; } @@ -12819,14 +12942,13 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) // 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. function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElsewhere_cb) { - var orig = s; + let orig = s; function errinfo() { if (name) { return 'macro [[' + name + ']]'; - } else { - return 'regex [[' + orig + ']]'; } + return 'regex [[' + orig + ']]'; } // propagate deferred exceptions = error reports. @@ -12834,19 +12956,18 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse return s; } - var c1, c2; - var rv = []; - var derr; - var se; + let c1, c2; + let rv = []; + let derr; + let se; while (s.length) { c1 = s.match(CHR_RE$1); if (!c1) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12856,15 +12977,14 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse var l = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1); while (s.length) { - var inner = s.match(SET_PART_RE$1); + let inner = s.match(SET_PART_RE$1); if (!inner) { inner = s.match(CHR_RE$1); if (!inner) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12878,9 +12998,8 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse if (!c2) { // cope with illegal escape sequences too! return new Error(errinfo() + ': regex set expression is broken: "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error(errinfo() + ': regex set expression is broken: apparently unterminated'); } @@ -12941,7 +13060,7 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse c2 = c2[0]; s = s.substr(c2.length); - var c3 = s[0]; + let c3 = s[0]; s = s.substr(c3.length); if (c3 === '}') { // possibly a macro name in there... Expand if possible: @@ -12994,7 +13113,7 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; + let re; re = new XRegExp__default['default'](s); re.test(s[0]); } catch (ex) { @@ -13010,11 +13129,11 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse // expand macros within macros and cache the result function prepareMacros(dict_macros, opts) { - var macros = {}; + let macros = {}; // expand a `{NAME}` macro which exists inside a `[...]` set: function expandMacroInSet(i) { - var k, a, m; + let k, a, m; if (!macros[i]) { m = dict_macros[i]; @@ -13048,7 +13167,7 @@ function prepareMacros(dict_macros, opts) { a = m.split('{' + k + '}'); if (a.length > 1) { - var x = expandMacroInSet(k); + let x = expandMacroInSet(k); assert__default['default'](x); if (x instanceof Error) { m = x; @@ -13060,9 +13179,9 @@ function prepareMacros(dict_macros, opts) { } } - var mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); + let mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); - var s1; + let s1; // propagate deferred exceptions = error reports. if (mba instanceof Error) { @@ -13096,7 +13215,7 @@ function prepareMacros(dict_macros, opts) { } function expandMacroElsewhere(i) { - var m; + let m; if (macros[i].elsewhere == null) { m = dict_macros[i]; @@ -13131,13 +13250,13 @@ function prepareMacros(dict_macros, opts) { } function expandAllMacrosInSet(s) { - var i, x; + let i, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { for (i in macros) { if (macros.hasOwnProperty(i)) { - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroInSet(i); assert__default['default'](x); @@ -13159,7 +13278,7 @@ function prepareMacros(dict_macros, opts) { } function expandAllMacrosElsewhere(s) { - var i, x; + let i, x; // When we process the remaining macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13174,7 +13293,7 @@ function prepareMacros(dict_macros, opts) { for (i in macros) { if (macros.hasOwnProperty(i)) { // These are all submacro expansions, hence non-capturing grouping is applied: - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroElsewhere(i); assert__default['default'](x); @@ -13196,7 +13315,7 @@ function prepareMacros(dict_macros, opts) { } - var i; + let i; if (opts.debug) console.log('\n############## RAW macros: ', dict_macros); @@ -13227,13 +13346,13 @@ function prepareMacros(dict_macros, opts) { // expand macros in a regex; expands them recursively function expandMacros(src, macros, opts) { - var expansion_count = 0; + let expansion_count = 0; // By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! // Hence things should be easy in there: function expandAllMacrosInSet(s) { - var i, m, x; + let i, m, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { @@ -13241,7 +13360,7 @@ function expandMacros(src, macros, opts) { if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = m.in_set; @@ -13272,7 +13391,7 @@ function expandMacros(src, macros, opts) { } function expandAllMacrosElsewhere(s) { - var i, m, x; + let i, m, x; // When we process the main macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13288,7 +13407,7 @@ function expandMacros(src, macros, opts) { if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { // These are all main macro expansions, hence CAPTURING grouping is applied: x = m.elsewhere; @@ -13324,7 +13443,7 @@ function expandMacros(src, macros, opts) { // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! - var s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); + let s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); // propagate deferred exceptions = error reports. if (s2 instanceof Error) { throw s2; @@ -13349,8 +13468,8 @@ function expandMacros(src, macros, opts) { } function prepareStartConditions(conditions) { - var sc; - var hash = {}; + let sc; + let hash = {}; for (sc in conditions) { if (conditions.hasOwnProperty(sc)) { @@ -13364,22 +13483,22 @@ function prepareStartConditions(conditions) { } function buildActions(dict, tokens, opts) { - var actions = [dict.actionInclude || '', 'var YYSTATE = YY_START;']; - var tok; - var toks = {}; - var caseHelper = []; + let actions = [ dict.actionInclude || '', 'var YYSTATE = YY_START;' ]; + let tok; + let toks = {}; + let caseHelper = []; // tokens: map/array of token numbers to token names for (tok in tokens) { - var idx = parseInt(tok); + let idx = parseInt(tok); if (idx && idx > 0) { toks[tokens[tok]] = idx; } } - var gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); + let gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); - var code = actions.join('\n'); + let code = actions.join('\n'); 'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function (yy) { code = code.replace(new RegExp('\\b(' + yy + ')\\b', 'g'), 'yy_.$1'); }); @@ -13397,7 +13516,7 @@ function buildActions(dict, tokens, opts) { macros: gen.macros, // propagate these for debugging/diagnostic purposes regular_rule_count: gen.regular_rule_count, - simple_rule_count: gen.simple_rule_count, + simple_rule_count: gen.simple_rule_count }; } @@ -13408,7 +13527,7 @@ function buildActions(dict, tokens, opts) { function generateErrorClass() { // --- START lexer error class --- -var prelude = `/** +const prelude = `/** * 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 @@ -13419,8 +13538,6 @@ var prelude = `/** * @nocollapse */ function JisonLexerError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -13437,9 +13554,9 @@ function JisonLexerError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -13500,8 +13617,8 @@ function generateFakeXRegExpClassSrcCode() { /** @constructor */ function RegExpLexer(dict, input, tokens, build_options) { - var opts; - var dump = false; + let opts; + let dump = false; function test_me(tweak_cb, description, src_exception, ex_callback) { opts = processGrammar(dict, tokens, build_options); @@ -13511,7 +13628,7 @@ function RegExpLexer(dict, input, tokens, build_options) { if (tweak_cb) { tweak_cb(); } - var source = generateModuleBody(opts); + let source = generateModuleBody(opts); try { // The generated code will always have the `lexer` variable declared at local scope // as `eval()` will use the local scope. @@ -13519,16 +13636,16 @@ function RegExpLexer(dict, input, tokens, build_options) { // The compiled code will look something like this: // // ``` - // var lexer; + // let lexer; // bla bla... // ``` // // or // // ``` - // var lexer = { bla... }; + // const lexer = { bla... }; // ``` - var testcode = [ + let testcode = [ '// provide a local version for test purposes:', jisonLexerErrorDefinition, '', @@ -13536,14 +13653,33 @@ function RegExpLexer(dict, input, tokens, build_options) { '', source, '', + rmCommonWS$2` + // JISON INJECTED VALIDATION CODE + // which attempts to ascertain you have defined a minimal viable lexer at least: + if (typeof lexer === "undefined") { + throw new SyntaxError("user-defined lexer does not define the required 'lexer' instance."); + } + if (!lexer) { + throw new SyntaxError("user-defined lexer does not define a non-NULL 'lexer' instance."); + } + if (typeof lexer.setInput !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.setInput()' API function."); + } + if (typeof lexer.lex !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.lex()' API function."); + } + // END OF JISON INJECTED VALIDATION CODE + `, 'return lexer;' ].join('\n'); - var lexer = code_exec$1(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { + let lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { //console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$2(sourcecode); - var lexer_f = new Function('', sourcecode); + let lexer_f = new Function('', sourcecode); return lexer_f(); - }, opts.options, "lexer"); + }, Object.assign({}, opts.options, { + throwErrorOnCompileFailure: true + }), 'lexer'); if (!lexer) { throw new Error('no lexer defined *at all*?!'); @@ -13560,7 +13696,7 @@ function RegExpLexer(dict, input, tokens, build_options) { // When we do NOT crash, we found/killed the problem area just before this call! if (src_exception && description) { - var msg = description; + let msg = description; if (typeof description === 'function') { msg = description(); } @@ -13569,8 +13705,8 @@ function RegExpLexer(dict, input, tokens, build_options) { // patch the pre and post handlers in there, now that we have some live code to work with: if (opts.options) { - var pre = opts.options.pre_lex; - var post = opts.options.post_lex; + let pre = opts.options.pre_lex; + let post = opts.options.post_lex; // since JSON cannot encode functions, we'll have to do it manually now: if (typeof pre === 'function') { lexer.options.pre_lex = pre; @@ -13584,7 +13720,7 @@ function RegExpLexer(dict, input, tokens, build_options) { if (typeof opts.options.showSource === 'function') { opts.options.showSource(lexer, source, opts, RegExpLexer); } else { - console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n"); + console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n', source, '\n----------------------------------------\n'); } } return lexer; @@ -13603,13 +13739,13 @@ function RegExpLexer(dict, input, tokens, build_options) { } /** @constructor */ - var lexer = test_me(null, null, null, function (ex) { + let lexer = test_me(null, null, null, function (ex) { // When we get an exception here, it means some part of the user-specified lexer is botched. // // Now we go and try to narrow down the problem area/category: assert__default['default'](opts.options); assert__default['default'](opts.options.xregexp !== undefined); - var orig_xregexp_opt = !!opts.options.xregexp; + let orig_xregexp_opt = !!opts.options.xregexp; if (!test_me(function () { assert__default['default'](opts.options.xregexp !== undefined); opts.options.xregexp = false; @@ -13628,7 +13764,7 @@ function RegExpLexer(dict, input, tokens, build_options) { 'Your custom lexer is somehow botched.' ); }, ex, null)) { - var rulesSpecSize; + let rulesSpecSize; if (!test_me(function () { // store the parsed rule set size so we can use that info in case // this attempt also fails: @@ -13641,7 +13777,7 @@ function RegExpLexer(dict, input, tokens, build_options) { opts.__in_rules_failure_analysis_mode__ = true; }, 'One or more of your lexer rules are possibly botched?', ex, null)) { // kill each rule action block, one at a time and test again after each 'edit': - var rv = false; + let rv = false; for (var i = 0, len = rulesSpecSize; i < len; i++) { var lastEditedRuleSpec; rv = test_me(function () { @@ -13653,10 +13789,10 @@ function RegExpLexer(dict, input, tokens, build_options) { // opts.__in_rules_failure_analysis_mode__ = true; // nuke all rules' actions up to and including rule numero `i`: - for (var j = 0; j <= i; j++) { + for (let j = 0; j <= i; j++) { // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; // now we want to edit the *action* part: - var rule = opts.rules[j]; + let rule = opts.rules[j]; assert__default['default'](Array.isArray(rule)); assert__default['default'](rule.length === 2 || rule.length === 3); rule.pop(); @@ -13790,8 +13926,6 @@ return `{ * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -13801,14 +13935,14 @@ return `{ } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\\n\\s*$/.test(msg)) { msg += '\\n'; } msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') { msg += '\\n' + pos_str; @@ -13819,14 +13953,14 @@ return `{ } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the \`upcomingInput\` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -13846,9 +13980,8 @@ return `{ // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -13868,8 +14001,6 @@ return `{ * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -13890,16 +14021,14 @@ return `{ * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -13920,8 +14049,6 @@ return `{ * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -13929,8 +14056,8 @@ return `{ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -13948,8 +14075,6 @@ return `{ * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -13959,14 +14084,14 @@ return `{ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -13977,8 +14102,6 @@ return `{ * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -13986,40 +14109,40 @@ return `{ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -14031,7 +14154,7 @@ return `{ this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -14039,7 +14162,7 @@ return `{ last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -14100,9 +14223,7 @@ return `{ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -14121,8 +14242,6 @@ return `{ * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set \`done\` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -14131,7 +14250,7 @@ return `{ this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -14141,13 +14260,13 @@ return `{ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\\n') { lines = true; } else if (ch === '\\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\\n') { slice_len++; ch += ch2; @@ -14179,10 +14298,8 @@ return `{ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -14214,8 +14331,8 @@ return `{ // Get last entirely matched line into the \`pre_lines[]\` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -14233,9 +14350,9 @@ return `{ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -14245,14 +14362,12 @@ return `{ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -14263,8 +14378,6 @@ return `{ * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -14277,19 +14390,17 @@ return `{ * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the \`parseError()\` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // \`.lex()\` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -14302,8 +14413,6 @@ return `{ * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -14326,24 +14435,24 @@ return `{ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substr\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14355,8 +14464,8 @@ return `{ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to \`maxSize\` (default: 20). @@ -14382,24 +14491,25 @@ return `{ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > \`lookAhead()\` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substring\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -14408,7 +14518,7 @@ return `{ } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14427,10 +14537,8 @@ return `{ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^'; }, @@ -14452,15 +14560,13 @@ return `{ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -14591,58 +14697,54 @@ return `{ * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\\t/g, ' '); @@ -14651,13 +14753,13 @@ return `{ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -14679,15 +14781,13 @@ return `{ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -14699,8 +14799,8 @@ return `{ rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -14729,13 +14829,7 @@ return `{ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -14764,10 +14858,10 @@ return `{ }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -14795,7 +14889,7 @@ return `{ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -14806,7 +14900,7 @@ return `{ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -14828,8 +14922,6 @@ return `{ * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -14838,17 +14930,13 @@ return `{ this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -14858,67 +14946,75 @@ return `{ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that \`parseError()\` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) \`parseError()\` @@ -14945,9 +15041,7 @@ return `{ * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -14990,24 +15084,24 @@ return `{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15027,9 +15121,7 @@ return `{ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15039,24 +15131,24 @@ return `{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15064,7 +15156,7 @@ return `{ this._clear_state = 0; } - + return r; }, @@ -15077,9 +15169,7 @@ return `{ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -15087,7 +15177,7 @@ return `{ (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -15102,8 +15192,6 @@ return `{ * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -15115,8 +15203,6 @@ return `{ * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -15130,15 +15216,12 @@ return `{ * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -15150,14 +15233,11 @@ return `{ * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -15168,16 +15248,14 @@ return `{ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -15187,8 +15265,6 @@ return `{ * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; } }`; @@ -15220,18 +15296,17 @@ function stripUnusedLexerCode(src, opt) { // ............................. ${opt.lexerActionsUseDisplayAPIs} // uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC} - var new_src; + let new_src; try { - var ast = helpers.parseCodeChunkToAST(src, opt); + let ast = helpers.parseCodeChunkToAST(src, opt); new_src = helpers.prettyPrintAST(ast, opt); - } - catch (ex) { + } catch (ex) { let line = ex.lineNumber || 0; let a = src.split(/\r?\n/g); let len = a.length; let minl = Math.max(0, line - 10); let b = a.slice(minl, line + 10); - let c = b.splice(line - minl, 0, "", "^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", ""); + let c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); let offendingChunk = ' ' + b.join('\n '); console.error(rmCommonWS$2` stripUnusedLexerCode WARNING: @@ -15247,17 +15322,11 @@ function stripUnusedLexerCode(src, opt) { ${offendingChunk} `); - + new_src = src; } - - - - - - // inject analysis report now: new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2` // Code Generator Information Report @@ -15312,7 +15381,7 @@ function stripUnusedLexerCode(src, opt) { // generate lexer source from a grammar /** @public */ function generate(dict, tokens, build_options) { - var opt = processGrammar(dict, tokens, build_options); + let opt = processGrammar(dict, tokens, build_options); return generateFromOpts(opt); } @@ -15321,7 +15390,7 @@ function generate(dict, tokens, build_options) { /** @public */ function processGrammar(dict, tokens, build_options) { build_options = build_options || {}; - var opts = { + let opts = { // include the knowledge passed through `build_options` about which lexer // features will actually be *used* by the environment (which in 99.9% // of cases is a jison *parser*): @@ -15361,7 +15430,7 @@ function processGrammar(dict, tokens, build_options) { lexerActionsUseReject: '???', lexerActionsUseLess: '???', lexerActionsUseDisplayAPIs: '???', - lexerActionsUseDescribeYYLOC: '???', + lexerActionsUseDescribeYYLOC: '???' }; dict = autodetectAndConvertToJSONformat(dict, build_options) || {}; @@ -15386,7 +15455,7 @@ function processGrammar(dict, tokens, build_options) { // only produce rule action code blocks when there are any rules at all; // a "custom lexer" has ZERO rules and must be defined entirely in // other code blocks: - var code = (dict.rules ? buildActions(dict, tokens, opts) : {}); + let code = (dict.rules ? buildActions(dict, tokens, opts) : {}); opts.performAction = code.actions; opts.caseHelperInclude = code.caseHelperInclude; opts.rules = code.rules || []; @@ -15395,7 +15464,7 @@ function processGrammar(dict, tokens, build_options) { opts.regular_rule_count = code.regular_rule_count; opts.simple_rule_count = code.simple_rule_count; - opts.conditionStack = ['INITIAL']; + opts.conditionStack = [ 'INITIAL' ]; opts.actionInclude = (dict.actionInclude || ''); opts.moduleInclude = (opts.moduleInclude || '') + (dict.moduleInclude || '').trim(); @@ -15406,7 +15475,7 @@ function processGrammar(dict, tokens, build_options) { // Assemble the final source from the processed grammar /** @public */ function generateFromOpts(opt) { - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -15429,12 +15498,12 @@ function generateFromOpts(opt) { } function generateRegexesInitTableCode(opt) { - var a = opt.rules; - var print_xregexp = opt.options && opt.options.xregexp; - var id_display_width = (1 + Math.log10(a.length | 1) | 0); - var ws_prefix = new Array(id_display_width).join(' '); - var b = a.map(function generateXRegExpInitCode(re, idx) { - var idx_str = (ws_prefix + idx).substr(-id_display_width); + let a = opt.rules; + let print_xregexp = opt.options && opt.options.xregexp; + let id_display_width = (1 + Math.log10(a.length | 1) | 0); + let ws_prefix = new Array(id_display_width).join(' '); + let b = a.map(function generateXRegExpInitCode(re, idx) { + let idx_str = (ws_prefix + idx).substr(-id_display_width); if (re instanceof XRegExp__default['default']) { // When we don't need the special XRegExp sauce at run-time, we do with the original @@ -15444,11 +15513,11 @@ function generateRegexesInitTableCode(opt) { } // And make sure to escape the regex to make it suitable for placement inside a *string* // as it is passed as a string argument to the XRegExp constructor here. - var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); + let re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); return `/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`; - } else { - return `/* ${idx_str}: */ ${re}`; } + return `/* ${idx_str}: */ ${re}`; + }); return b.join(',\n'); } @@ -15456,77 +15525,77 @@ function generateRegexesInitTableCode(opt) { function generateModuleBody(opt) { // make the JSON output look more like JavaScript: function cleanupJSON(str) { - str = str.replace(/ "rules": \[/g, ' rules: ['); - str = str.replace(/ "inclusive": /g, ' inclusive: '); + str = str.replace(/ {2}"rules": \[/g, ' rules: ['); + str = str.replace(/ {2}"inclusive": /g, ' inclusive: '); return str; } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - json: 1, - _: 1, - noMain: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - lexerErrorsAreRecoverable: 0, - flex: 0, - backtrack_lexer: 0, - caseInsensitive: 0, - showSource: 1, - exportAST: 1, - exportAllTables: 1, - exportSourceCode: 1, - prettyCfg: 1, - parseActionsUseYYLENG: 1, - parseActionsUseYYLINENO: 1, - parseActionsUseYYTEXT: 1, - parseActionsUseYYLOC: 1, - parseActionsUseParseError: 1, - parseActionsUseYYERROR: 1, - parseActionsUseYYRECOVERING: 1, - parseActionsUseYYERROK: 1, - parseActionsUseYYCLEARIN: 1, - parseActionsUseValueTracking: 1, - parseActionsUseValueAssignment: 1, - parseActionsUseLocationTracking: 1, - parseActionsUseLocationAssignment: 1, - parseActionsUseYYSTACK: 1, - parseActionsUseYYSSTACK: 1, - parseActionsUseYYSTACKPOINTER: 1, - parseActionsUseYYRULELENGTH: 1, - parseActionsUseYYMERGELOCATIONINFO: 1, - parserHasErrorRecovery: 1, - parserHasErrorReporting: 1, - lexerActionsUseYYLENG: 1, - lexerActionsUseYYLINENO: 1, - lexerActionsUseYYTEXT: 1, - lexerActionsUseYYLOC: 1, - lexerActionsUseParseError: 1, - lexerActionsUseYYERROR: 1, - lexerActionsUseLocationTracking: 1, - lexerActionsUseMore: 1, - lexerActionsUseUnput: 1, - lexerActionsUseReject: 1, - lexerActionsUseLess: 1, - lexerActionsUseDisplayAPIs: 1, - lexerActionsUseDescribeYYLOC: 1, + let obj = {}; + const do_not_pass = { + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + json: 1, + _: 1, + noMain: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + lexerErrorsAreRecoverable: 0, + flex: 0, + backtrack_lexer: 0, + caseInsensitive: 0, + showSource: 1, + exportAST: 1, + exportAllTables: 1, + exportSourceCode: 1, + prettyCfg: 1, + parseActionsUseYYLENG: 1, + parseActionsUseYYLINENO: 1, + parseActionsUseYYTEXT: 1, + parseActionsUseYYLOC: 1, + parseActionsUseParseError: 1, + parseActionsUseYYERROR: 1, + parseActionsUseYYRECOVERING: 1, + parseActionsUseYYERROK: 1, + parseActionsUseYYCLEARIN: 1, + parseActionsUseValueTracking: 1, + parseActionsUseValueAssignment: 1, + parseActionsUseLocationTracking: 1, + parseActionsUseLocationAssignment: 1, + parseActionsUseYYSTACK: 1, + parseActionsUseYYSSTACK: 1, + parseActionsUseYYSTACKPOINTER: 1, + parseActionsUseYYRULELENGTH: 1, + parseActionsUseYYMERGELOCATIONINFO: 1, + parserHasErrorRecovery: 1, + parserHasErrorReporting: 1, + lexerActionsUseYYLENG: 1, + lexerActionsUseYYLINENO: 1, + lexerActionsUseYYTEXT: 1, + lexerActionsUseYYLOC: 1, + lexerActionsUseParseError: 1, + lexerActionsUseYYERROR: 1, + lexerActionsUseLocationTracking: 1, + lexerActionsUseMore: 1, + lexerActionsUseUnput: 1, + lexerActionsUseReject: 1, + lexerActionsUseLess: 1, + lexerActionsUseDisplayAPIs: 1, + lexerActionsUseDescribeYYLOC: 1 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -15537,8 +15606,8 @@ function generateModuleBody(opt) { } // And now some options which should receive some special processing: - var pre = obj.pre_lex; - var post = obj.post_lex; + let pre = obj.pre_lex; + let post = obj.post_lex; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_lex = true; @@ -15547,7 +15616,7 @@ function generateModuleBody(opt) { obj.post_lex = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$1})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_lex: true(,)?$/gm, function (m, ls, tc) { @@ -15560,17 +15629,17 @@ function generateModuleBody(opt) { } - var out; + let out; if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) { // we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. - var code = [rmCommonWS$2` - var lexer = { - `, '/*JISON-LEX-ANALYTICS-REPORT*/' /* slot #1: placeholder for analysis report further below */ + let code = [ rmCommonWS$2` + const lexer = { + `, '/* JISON-LEX-ANALYTICS-REPORT */\n' /* slot #1: placeholder for analysis report further below */ ]; // get the RegExpLexer.prototype in source code form: - var protosrc = getRegExpLexerPrototype(); + let protosrc = getRegExpLexerPrototype(); // and strip off the surrounding bits we don't want: protosrc = protosrc .replace(/^[\s\r\n]*\{/, '') @@ -15597,10 +15666,10 @@ function generateModuleBody(opt) { } */ - var performActionCode = String(opt.performAction); - var simpleCaseActionClustersCode = String(opt.caseHelperInclude); - var rulesCode = generateRegexesInitTableCode(opt); - var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); + let performActionCode = String(opt.performAction); + let simpleCaseActionClustersCode = String(opt.caseHelperInclude); + let rulesCode = generateRegexesInitTableCode(opt); + let conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); code.push(rmCommonWS$2`, JisonLexerError: JisonLexerError, performAction: ${performActionCode}, @@ -15620,9 +15689,9 @@ function generateModuleBody(opt) { // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // - // Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter + // Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. - out = 'var lexer;\n'; + out = '\n'; assert__default['default'](opt.regular_rule_count === 0); assert__default['default'](opt.simple_rule_count === 0); @@ -15636,8 +15705,6 @@ function generateModuleBody(opt) { // The output of this function is guaranteed to read something like this: // // ``` - // var lexer; - // // bla bla bla bla ... lotsa bla bla; // ``` // @@ -15646,7 +15713,7 @@ function generateModuleBody(opt) { } function generateGenericHeaderComment() { - var out = rmCommonWS$2` + let out = rmCommonWS$2` /* lexer generated by jison-lex ${version} */ /* @@ -15875,7 +15942,7 @@ function prepareOptions(opt) { // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else { @@ -15893,9 +15960,9 @@ function prepareOptions(opt) { function generateModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -15918,9 +15985,9 @@ function generateModule(opt) { function generateAMDModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} define([], function () { @@ -15943,12 +16010,12 @@ function generateAMDModule(opt) { function generateESModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} - var lexer = (function () { + const lexer = (function () { "use strict"; ${jisonLexerErrorDefinition} @@ -15977,9 +16044,9 @@ function generateESModule(opt) { function generateCommonJSModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -16016,14 +16083,13 @@ RegExpLexer.camelCase = helpers.camelCase; RegExpLexer.mkIdentifier = mkIdentifier$2; RegExpLexer.autodetectAndConvertToJSONformat = autodetectAndConvertToJSONformat; -var mkIdentifier$3 = helpers.mkIdentifier; +const mkIdentifier$3 = helpers.mkIdentifier; -var version$1 = '0.6.2-220'; // require('./package.json').version; +const version$1 = '0.6.2-220'; // require('./package.json').version; function getCommandlineOptions() { - - var opts = nomnom__default['default'] + let opts = nomnom__default['default'] .script('jison-lex') .unknownOptionTreatment(false) // do not accept unknown options! .options({ @@ -16073,7 +16139,7 @@ function getCommandlineOptions() { abbr: 'm', default: 'commonjs', metavar: 'TYPE', - choices: ['commonjs', 'amd', 'js', 'es'], + choices: [ 'commonjs', 'amd', 'js', 'es' ], help: 'The type of module to generate (commonjs, amd, es, js)' }, moduleName: { @@ -16107,7 +16173,7 @@ function getCommandlineOptions() { }).parse(); if (opts.debug) { - console.log("JISON-LEX CLI options:\n", opts); + console.log('JISON-LEX CLI options:\n', opts); } return opts; @@ -16135,7 +16201,7 @@ function cliMain(opts) { return true; } catch (e) { if (e.code === 'ENOENT') { - var parent = path__default['default'].dirname(fp); + let parent = path__default['default'].dirname(fp); // Did we hit the root directory by now? If so, abort! // Else, create the parent; iff that fails, we fail too... if (parent !== fp && mkdirp(parent)) { @@ -16153,16 +16219,16 @@ function cliMain(opts) { } function processInputFile() { - var original_cwd = process.cwd(); + let original_cwd = process.cwd(); - var raw = fs__default['default'].readFileSync(path__default['default'].normalize(opts.file), 'utf8'); + let raw = fs__default['default'].readFileSync(path__default['default'].normalize(opts.file), 'utf8'); // making best guess at json mode opts.json = path__default['default'].extname(opts.file) === '.json' || opts.json; // When only the directory part of the output path was specified, then we // do NOT have the target module name in there as well! - var outpath = opts.outfile; + let outpath = opts.outfile; if (typeof outpath === 'string') { if (/[\\\/]$/.test(outpath) || isDirectory(outpath)) { opts.outfile = null; @@ -16181,7 +16247,7 @@ function cliMain(opts) { // setting output file name and module name based on input file name // if they aren't specified. - var name = path__default['default'].basename(opts.outfile || opts.file); + let name = path__default['default'].basename(opts.outfile || opts.file); // get the base name (i.e. the file name without extension) // i.e. strip off only the extension and keep any other dots in the filename @@ -16194,10 +16260,10 @@ function cliMain(opts) { // Change CWD to the directory where the source grammar resides: this helps us properly // %include any files mentioned in the grammar with relative paths: - var new_cwd = path__default['default'].dirname(path__default['default'].normalize(opts.file)); + let new_cwd = path__default['default'].dirname(path__default['default'].normalize(opts.file)); process.chdir(new_cwd); - var lexer = cli.generateLexerString(raw, opts); + let lexer = cli.generateLexerString(raw, opts); // and change back to the CWD we started out with: process.chdir(original_cwd); @@ -16209,8 +16275,8 @@ function cliMain(opts) { } function readin(cb) { - var stdin = process.openStdin(), - data = ''; + const stdin = process.openStdin(); + let data = ''; stdin.setEncoding('utf8'); stdin.addListener('data', function (chunk) { @@ -16237,9 +16303,8 @@ function cliMain(opts) { function generateLexerString(lexerSpec, opts) { - // var settings = RegExpLexer.mkStdOptions(opts); - var predefined_tokens = null; + let predefined_tokens = null; return RegExpLexer.generate(lexerSpec, predefined_tokens, opts); } @@ -16251,7 +16316,7 @@ var cli = { if (require.main === module) { - var opts = getCommandlineOptions(); + const opts = getCommandlineOptions(); cli.main(opts); } diff --git a/packages/jison-lex/dist/cli-es6.js b/packages/jison-lex/dist/cli-es6.js index f867ebf44..7ee1030d5 100644 --- a/packages/jison-lex/dist/cli-es6.js +++ b/packages/jison-lex/dist/cli-es6.js @@ -5,12 +5,13 @@ import fs from 'fs'; import path$1 from 'path'; import nomnom from '@gerhobbelt/nomnom'; import JSON5 from '@gerhobbelt/json5'; +import mkdirp from 'mkdirp'; import XRegExp from '@gerhobbelt/xregexp'; import recast from 'recast'; import { transformSync } from '@babel/core'; import assert$1 from 'assert'; -// Return TRUE if `src` starts with `searchString`. +// Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -33,19 +34,19 @@ function rmCommonWS(strings, ...values) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -64,19 +65,21 @@ function rmCommonWS(strings, ...values) { // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -85,16 +88,19 @@ function rmCommonWS(strings, ...values) { } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -105,27 +111,79 @@ function camelCase(s) { return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } +// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; +})([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' +]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -143,6 +201,11 @@ function mkIdentifier(s) { .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -151,13 +214,13 @@ function mkIdentifier(s) { function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -168,23 +231,17 @@ function scanRegExp(s) { break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -207,34 +264,33 @@ function isLineTerminator(cp) { /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -257,28 +313,76 @@ function chkBugger(src) { // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } +function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; +} + + +function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); +} + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path$1.dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path$1.basename(options.inputFilename || options.moduleName || (options.outfile ? path$1.dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path$1.dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path$1.basename(options.inputFilename || options.moduleName || (options.outfile ? path$1.dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -289,27 +393,37 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path$1.normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path$1.normalize(path$1.join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5.stringify(dump, null, 2); + let d = JSON5.stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp(path$1.dirname(dumpfile)); fs.writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -319,7 +433,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -327,7 +441,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -353,27 +467,43 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -386,9 +516,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -410,22 +541,22 @@ assert$1(recast); // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; -// Determine which Unicode NonAsciiIdentifierStart characters +// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -433,40 +564,40 @@ const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -474,30 +605,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -508,59 +639,59 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -602,38 +733,38 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -645,18 +776,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -667,56 +798,56 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -724,97 +855,97 @@ function generateMapper4JisonGrammarIdentifiers(input) { typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp(`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp(`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp(`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp(`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp(`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp(`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp(`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp(`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp(`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp(`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp(`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -822,7 +953,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -835,7 +966,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -848,7 +979,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -861,7 +992,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -880,37 +1011,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -942,7 +1073,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -959,37 +1090,37 @@ function parseCodeChunkToAST(src, options) { .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast.parse(src); + const ast = recast.parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return transformSync(src, options); // => { code, map, ast } @@ -997,8 +1128,8 @@ function compileCodeToES5(src, options) { function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1007,7 +1138,7 @@ function prettyPrintAST(ast, options) { // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1030,25 +1161,25 @@ function prettyPrintAST(ast, options) { // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1059,9 +1190,9 @@ function checkActionBlock(src, yylloc, options) { // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1069,7 +1200,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1078,14 +1209,14 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1139,7 +1270,7 @@ var parse2AST = { trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1153,7 +1284,7 @@ function chkBugger$1(src) { /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1165,24 +1296,24 @@ const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?: /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1199,8 +1330,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1211,14 +1342,14 @@ function printFunctionSourceCodeContainer(f) { action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1229,17 +1360,17 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; -// -// -// +// +// +// function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1265,7 +1396,7 @@ function detectIstanbulGlobal() { // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1313,7 +1444,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1376,13 +1507,13 @@ var reHelpers = { getRegExpInfo: getRegExpInfo }; -var cycleref = []; -var cyclerefpath = []; +let cycleref = []; +let cyclerefpath = []; -var linkref = []; -var linkrefpath = []; +let linkref = []; +let linkrefpath = []; -var path = []; +let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1390,14 +1521,14 @@ function shallow_copy(src) { return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1410,11 +1541,11 @@ function shallow_copy(src) { function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1427,9 +1558,9 @@ function shallow_copy_and_strip_depth(src, parentKey) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1444,16 +1575,52 @@ function shallow_copy_and_strip_depth(src, parentKey) { } +// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } +// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; +} + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1468,7 +1635,7 @@ function trim_array_tail(arr) { function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1494,10 +1661,10 @@ function treat_value_stack(v) { } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1595,7 +1762,7 @@ function treat_hash(h) { function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1612,7 +1779,7 @@ function treat_error_report_info(e) { path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1640,7 +1807,7 @@ function treat_error_report_info(e) { function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1656,7 +1823,7 @@ function treat_object(e) { linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1668,14 +1835,14 @@ function treat_object(e) { // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1685,7 +1852,7 @@ function trimErrorForTestReporting(e) { cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1699,12 +1866,14 @@ var helpers = { dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1719,7 +1888,7 @@ var helpers = { printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; // See also: @@ -1727,7 +1896,6 @@ var helpers = { // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1744,9 +1912,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -1779,10 +1947,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -1795,11 +1963,11 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -1809,18 +1977,18 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -1851,7 +2019,7 @@ JisonParserError.prototype.name = 'JisonParserError'; // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -1868,9 +2036,9 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -1883,7 +2051,7 @@ JisonParserError.prototype.name = 'JisonParserError'; } -var parser = { +let parser = { // Code Generator Information Report // --------------------------------- // @@ -2133,7 +2301,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2141,7 +2308,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2153,8 +2319,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2167,14 +2333,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2190,10 +2355,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2201,10 +2366,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2359,9 +2524,9 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -2373,18 +2538,18 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2414,9 +2579,9 @@ case 1: case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -2429,10 +2594,10 @@ case 2: case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2459,9 +2624,9 @@ case 3: case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -2470,10 +2635,10 @@ case 4: case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2501,9 +2666,9 @@ case 5: case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -2512,10 +2677,10 @@ case 6: case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -2554,9 +2719,9 @@ case 7: case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2621,9 +2786,9 @@ case 8: case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2638,9 +2803,9 @@ case 9: case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -2675,10 +2840,10 @@ case 10: case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2695,9 +2860,9 @@ case 11: case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2714,10 +2879,10 @@ case 12: case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2734,9 +2899,9 @@ case 13: case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2753,10 +2918,10 @@ case 14: case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2773,9 +2938,9 @@ case 15: case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -2799,9 +2964,9 @@ case 17: case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -2812,9 +2977,9 @@ case 132: case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2834,9 +2999,9 @@ case 18: case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2860,9 +3025,9 @@ case 19: case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2875,10 +3040,10 @@ case 20: case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2895,9 +3060,9 @@ case 21: case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2909,9 +3074,9 @@ case 22: case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -2951,10 +3116,10 @@ case 23: case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2974,9 +3139,9 @@ case 24: case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3026,10 +3191,10 @@ case 25: case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -3053,10 +3218,10 @@ case 26: case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3076,10 +3241,10 @@ case 27: case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3103,10 +3268,10 @@ case 28: case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3127,10 +3292,10 @@ case 29: case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3142,10 +3307,10 @@ case 31: case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3155,10 +3320,10 @@ case 33: case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3168,10 +3333,10 @@ case 32: case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3181,10 +3346,10 @@ case 34: case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3194,10 +3359,10 @@ case 35: case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -3207,10 +3372,10 @@ case 36: case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3220,10 +3385,10 @@ case 37: case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3233,9 +3398,9 @@ case 38: case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -3244,9 +3409,9 @@ case 39: case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -3255,9 +3420,9 @@ case 40: case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3279,9 +3444,9 @@ case 41: case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3292,9 +3457,9 @@ case 42: case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3314,9 +3479,9 @@ case 43: case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3370,9 +3535,9 @@ case 49: case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3392,9 +3557,9 @@ case 51: case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -3403,9 +3568,9 @@ case 58: case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -3417,9 +3582,9 @@ case 52: case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -3433,10 +3598,10 @@ case 53: case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3456,10 +3621,10 @@ case 54: case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3479,10 +3644,10 @@ case 55: case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3502,9 +3667,9 @@ case 56: case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3515,9 +3680,9 @@ case 59: case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3536,9 +3701,9 @@ case 60: case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -3579,9 +3744,9 @@ case 61: case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3605,9 +3770,9 @@ case 62: case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3633,9 +3798,9 @@ case 63: case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3680,9 +3845,9 @@ case 64: case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -3708,9 +3873,9 @@ case 106: case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -3719,9 +3884,9 @@ case 127: case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -3730,10 +3895,10 @@ case 67: case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3747,10 +3912,10 @@ case 68: case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3764,10 +3929,10 @@ case 69: case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3781,10 +3946,10 @@ case 70: case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3803,9 +3968,9 @@ case 72: case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -3814,9 +3979,9 @@ case 77: case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -3854,10 +4019,10 @@ case 73: case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -3881,9 +4046,9 @@ case 74: case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -3962,9 +4127,9 @@ case 110: case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -3973,9 +4138,9 @@ case 129: case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -3984,9 +4149,9 @@ case 78: case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -3995,9 +4160,9 @@ case 79: case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -4006,9 +4171,9 @@ case 80: case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -4017,9 +4182,9 @@ case 81: case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -4028,9 +4193,9 @@ case 85: case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -4041,10 +4206,10 @@ case 87: case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4061,9 +4226,9 @@ case 88: case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -4072,9 +4237,9 @@ case 89: case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -4083,9 +4248,9 @@ case 90: case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -4094,9 +4259,9 @@ case 91: case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -4105,9 +4270,9 @@ case 92: case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -4126,18 +4291,18 @@ case 107: case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -4146,9 +4311,9 @@ case 97: case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -4157,9 +4322,9 @@ case 98: case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -4168,9 +4333,9 @@ case 99: case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -4179,9 +4344,9 @@ case 102: case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -4190,10 +4355,10 @@ case 104: case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4210,9 +4375,9 @@ case 105: case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -4229,9 +4394,9 @@ case 109: case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -4243,9 +4408,9 @@ case 111: case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -4255,9 +4420,9 @@ case 112: case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4292,9 +4457,9 @@ case 113: case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4313,9 +4478,9 @@ case 114: case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -4324,9 +4489,9 @@ case 115: case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -4335,9 +4500,9 @@ case 116: case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4355,10 +4520,10 @@ case 117: case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -4376,10 +4541,10 @@ case 118: case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -4400,9 +4565,9 @@ case 119: case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4435,9 +4600,9 @@ case 120: case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4463,9 +4628,9 @@ case 121: case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5.parse(yyvstack[yysp]); @@ -4474,9 +4639,9 @@ case 122: case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue(yyvstack[yysp]); @@ -4485,9 +4650,9 @@ case 123: case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4496,9 +4661,9 @@ case 124: case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -4519,10 +4684,10 @@ case 125: case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4539,9 +4704,9 @@ case 126: case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -4560,9 +4725,9 @@ case 128: case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4586,9 +4751,9 @@ case 130: case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -4608,9 +4773,9 @@ case 131: case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4621,9 +4786,9 @@ case 133: case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -4679,10 +4844,10 @@ case 134: case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6285,7 +6450,6 @@ defaultActions: bda({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -6302,38 +6466,34 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -6341,20 +6501,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -6376,7 +6534,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -6384,18 +6541,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -6403,24 +6561,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -6458,18 +6611,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -6490,7 +6640,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -6508,7 +6658,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -6521,7 +6670,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -6535,11 +6683,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -6593,8 +6740,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6602,8 +6749,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6635,19 +6782,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -6658,7 +6804,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -6671,7 +6817,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -6683,29 +6829,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -6713,7 +6857,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -6733,8 +6877,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -6743,10 +6886,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -6754,7 +6897,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -6765,9 +6908,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -6783,8 +6931,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -6853,11 +7000,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -6868,8 +7018,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -6878,21 +7027,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6902,21 +7050,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6925,28 +7072,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -6959,8 +7105,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -6983,8 +7128,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -6996,8 +7140,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -7014,8 +7157,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -7029,8 +7171,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -7044,7 +7185,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -7097,16 +7238,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -7140,9 +7278,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -7165,9 +7301,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -7194,17 +7328,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -7251,8 +7384,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -7264,8 +7397,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -7283,6 +7415,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -7291,7 +7424,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -7302,7 +7435,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -7362,10 +7495,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -7400,9 +7533,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -7415,7 +7546,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -7436,9 +7567,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7460,12 +7589,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -7474,7 +7603,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7515,7 +7644,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -7562,7 +7691,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -7580,21 +7709,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7628,14 +7755,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7645,6 +7773,7 @@ parse: function parse(input) { + } continue; // accept: @@ -7696,7 +7825,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -7712,9 +7841,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7743,7 +7870,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7760,8 +7887,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -7772,8 +7899,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -7785,21 +7912,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7830,14 +7955,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7847,6 +7973,7 @@ parse: function parse(input) { + } continue; // accept: @@ -7899,8 +8026,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -8161,7 +8287,6 @@ var lexer = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -8178,10 +8303,10 @@ var lexer = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -8213,7 +8338,7 @@ var lexer = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -8255,7 +8380,9 @@ var lexer = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -8341,7 +8468,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -8349,7 +8476,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -8362,7 +8489,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -8388,10 +8515,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -8414,7 +8544,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -8437,16 +8566,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -8468,7 +8597,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -8476,8 +8604,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -8506,7 +8634,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -8531,7 +8659,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -8543,17 +8671,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -8647,7 +8775,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -8668,7 +8796,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -8679,7 +8806,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -8690,15 +8817,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -8732,8 +8859,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -8766,9 +8893,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -8787,9 +8914,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -8799,8 +8926,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -8827,20 +8954,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -8880,17 +9006,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8899,7 +9027,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -8914,8 +9042,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -8941,24 +9069,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8969,7 +9099,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -8991,8 +9121,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -9014,8 +9144,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -9159,21 +9288,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -9188,11 +9317,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -9211,13 +9340,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -9241,13 +9370,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -9262,8 +9391,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -9294,7 +9423,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -9326,9 +9455,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -9357,7 +9486,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -9375,7 +9504,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -9400,7 +9529,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -9410,8 +9538,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -9420,7 +9546,7 @@ EOF: 1, this.clear(); } - 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. @@ -9432,13 +9558,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -9448,68 +9574,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -9534,7 +9666,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -9582,24 +9714,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9619,7 +9751,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -9629,24 +9761,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9667,8 +9799,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -9708,14 +9839,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -9731,9 +9862,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -9744,8 +9875,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -9753,7 +9884,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -11443,7 +11574,7 @@ const UNICODE_BASE_PLANE_MAX_CP = 65535; // The expanded regex sets which are equivalent to the given `\\{c}` escapes: // // `/\s/`: -const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; +const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; // `/\d/`: const DIGIT_SETSTR = '0-9'; // `/\w/`: @@ -11455,7 +11586,7 @@ const WORDCHAR_SETSTR = 'A-Za-z0-9_'; // Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex function i2c(i) { - var c, x; + let c, x; switch (i) { case 10: @@ -11495,7 +11626,7 @@ function i2c(i) { || i > 0xFFF0 /* Unicode Specials, also in UTF16 */ || (i >= 0xD800 && i <= 0xDFFF) /* Unicode Supplementary Planes; we're TOAST in JavaScript as we're NOT UTF-16 but UCS-2! */ || String.fromCharCode(i).match(/[\u2028\u2029]/) /* Code compilation via `new Function()` does not like to see these, or rather: treats them as just another form of CRLF, which breaks your generated regex code! */ - ) { + ) { // Detail about a detail: // U+2028 and U+2029 are part of the `\s` regex escape code (`\s` and `[\s]` match either of these) and when placed in a JavaScript // source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report @@ -11503,11 +11634,10 @@ function i2c(i) { // Hence we MUST escape these buggers everywhere we go... x = i.toString(16); if (x.length >= 1 && i <= 0xFFFF) { - c = '0000' + x; - return '\\u' + c.substr(c.length - 4); - } else { - return '\\u{' + x + '}'; + c = '0000' + x; + return '\\u' + c.substr(c.length - 4); } + return '\\u{' + x + '}'; } return String.fromCharCode(i); } @@ -11516,18 +11646,18 @@ function i2c(i) { // Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating // this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a // `\\p{NAME}` shorthand to represent [part of] the bitarray: -var Pcodes_bitarray_cache = {}; -var Pcodes_bitarray_cache_test_order = []; +let Pcodes_bitarray_cache = {}; +let Pcodes_bitarray_cache_test_order = []; -// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by +// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. -var EscCode_bitarray_output_refs; +let EscCode_bitarray_output_refs; // now initialize the EscCodes_... table above: init_EscCode_lookup_table(); function init_EscCode_lookup_table() { - var s, bitarr, set2esc = {}, esc2bitarr = {}; + let s, bitarr, set2esc = {}, esc2bitarr = {}; // patch global lookup tables for the time being, while we calculate their *real* content in this function: EscCode_bitarray_output_refs = { @@ -11596,13 +11726,13 @@ function init_EscCode_lookup_table() { }; updatePcodesBitarrayCacheTestOrder(); -} +} function updatePcodesBitarrayCacheTestOrder(opts) { - var t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var l = {}; - var user_has_xregexp = opts && opts.options && opts.options.xregexp; - var i, j, k, ba; + let t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let l = {}; + let user_has_xregexp = opts && opts.options && opts.options.xregexp; + let i, j, k, ba; // mark every character with which regex pcodes they are part of: for (k in Pcodes_bitarray_cache) { @@ -11612,12 +11742,12 @@ function updatePcodesBitarrayCacheTestOrder(opts) { continue; } - var cnt = 0; + let cnt = 0; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { cnt++; if (!t[i]) { - t[i] = [k]; + t[i] = [ k ]; } else { t[i].push(k); } @@ -11627,27 +11757,27 @@ function updatePcodesBitarrayCacheTestOrder(opts) { } // now dig out the unique ones: only need one per pcode. - // + // // We ASSUME every \\p{NAME} 'pcode' has at least ONE character - // in it that is ONLY matched by that particular pcode. + // in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode - // won't be tested during optimization. - // + // won't be tested during optimization. + // // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to // look for markers which match multiple escapes/pcodes for those // ones where a unique item isn't available... - var lut = []; - var done = {}; - var keys = Object.keys(Pcodes_bitarray_cache); + let lut = []; + let done = {}; + let keys = Object.keys(Pcodes_bitarray_cache); for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { k = t[i][0]; if (t[i].length === 1 && !done[k]) { assert$1(l[k] > 0); - lut.push([i, k]); + lut.push([ i, k ]); done[k] = true; } } @@ -11658,19 +11788,19 @@ function updatePcodesBitarrayCacheTestOrder(opts) { if (!user_has_xregexp && k.indexOf('\\p{') >= 0) { continue; } - + if (!done[k]) { assert$1(l[k] > 0); // find a minimum span character to mark this one: - var w = Infinity; + let w = Infinity; var rv; ba = Pcodes_bitarray_cache[k]; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { - var tl = t[i].length; + let tl = t[i].length; if (tl > 1 && tl < w) { assert$1(l[k] > 0); - rv = [i, k]; + rv = [ i, k ]; w = tl; } } @@ -11684,16 +11814,16 @@ function updatePcodesBitarrayCacheTestOrder(opts) { // order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. - // + // // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more - // optimal minification of the regex set expression. - // + // optimal minification of the regex set expression. + // // This is a guestimate/heuristic only! lut.sort(function (a, b) { - var k1 = a[1]; - var k2 = b[1]; - var ld = l[k2] - l[k1]; + let k1 = a[1]; + let k2 = b[1]; + let ld = l[k2] - l[k1]; if (ld) { return ld; } @@ -11711,19 +11841,19 @@ function updatePcodesBitarrayCacheTestOrder(opts) { // 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set. function set2bitarray(bitarr, s, opts) { - var orig = s; - var set_is_inverted = false; - var bitarr_orig; + let orig = s; + let set_is_inverted = false; + let bitarr_orig; function mark(d1, d2) { if (d2 == null) d2 = d1; - for (var i = d1; i <= d2; i++) { + for (let i = d1; i <= d2; i++) { bitarr[i] = true; } } function add2bitarray(dst, src) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (src[i]) { dst[i] = true; } @@ -11731,10 +11861,10 @@ function set2bitarray(bitarr, s, opts) { } function eval_escaped_code(s) { - var c; + let c; // decode escaped code? If none, just take the character as-is if (s.indexOf('\\') === 0) { - var l = s.substr(0, 2); + let l = s.substr(0, 2); switch (l) { case '\\c': c = s.charCodeAt(2) - 'A'.charCodeAt(0) + 1; @@ -11752,7 +11882,7 @@ function set2bitarray(bitarr, s, opts) { } c = parseInt(s, 16); if (c >= 0x10000) { - return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); + return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); } return String.fromCharCode(c); @@ -11796,7 +11926,7 @@ function set2bitarray(bitarr, s, opts) { } if (s && s.length) { - var c1, c2; + let c1, c2; // inverted set? if (s[0] === '^') { @@ -11827,13 +11957,13 @@ function set2bitarray(bitarr, s, opts) { c2 = c2[0]; s = s.substr(c2.length); // do we have this one cached already? - var pex = c1 + c2; - var ba4p = Pcodes_bitarray_cache[pex]; + let pex = c1 + c2; + let ba4p = Pcodes_bitarray_cache[pex]; if (!ba4p) { // expand escape: - var xr = new XRegExp('[' + pex + ']'); // TODO: case-insensitive grammar??? + let xr = new XRegExp('[' + pex + ']'); // TODO: case-insensitive grammar??? // rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`: - var xs = '' + xr; + let xs = '' + xr; // remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: xs = xs.substr(1, xs.length - 2); @@ -11868,7 +11998,7 @@ function set2bitarray(bitarr, s, opts) { break; } } - var v1 = eval_escaped_code(c1); + let v1 = eval_escaped_code(c1); // propagate deferred exceptions = error reports. if (v1 instanceof Error) { return v1; @@ -11886,7 +12016,7 @@ function set2bitarray(bitarr, s, opts) { } else { c2 = c2[0]; } - var v2 = eval_escaped_code(c2); + let v2 = eval_escaped_code(c2); // propagate deferred exceptions = error reports. if (v2 instanceof Error) { return v1; @@ -11909,12 +12039,12 @@ function set2bitarray(bitarr, s, opts) { } // When we have marked all slots, '^' NEGATES the set, hence we flip all slots. - // + // // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. if (set_is_inverted) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (!bitarr[i]) { bitarr_orig[i] = true; } @@ -11933,10 +12063,10 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // below can be simple and fast: l[UNICODE_BASE_PLANE_MAX_CP + 1] = 1; // now reconstruct the regex set: - var rv = []; - var i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; - var bitarr_is_cloned = false; - var l_orig = l; + let rv = []; + let i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; + let bitarr_is_cloned = false; + let l_orig = l; if (output_inverted_variant) { // generate the inverted set, hence all unmarked slots are part of the output range: @@ -11950,8 +12080,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. // BUT... since we output the INVERTED set, we output the match-all set instead: return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` // BUT... since we output the INVERTED set, we output the match-nothing set instead: @@ -11983,9 +12112,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12012,7 +12141,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } } - + i = 0; while (i <= UNICODE_BASE_PLANE_MAX_CP) { // find first character not in original set: @@ -12043,8 +12172,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. return '^\\S\\s'; } @@ -12074,9 +12202,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12128,11 +12256,11 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } assert$1(rv.length); - var s = rv.join(''); + let s = rv.join(''); assert$1(s); // Check if the set is better represented by one of the regex escapes: - var esc4s = EscCode_bitarray_output_refs.set2esc[s]; + let esc4s = EscCode_bitarray_output_refs.set2esc[s]; if (esc4s) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return '\\' + esc4s; @@ -12147,25 +12275,24 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there; // ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`. function reduceRegexToSetBitArray(s, name, opts) { - var orig = s; + let orig = s; // propagate deferred exceptions = error reports. if (s instanceof Error) { return s; } - var l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var internal_state = 0; - var derr; + let l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let internal_state = 0; + let derr; while (s.length) { - var c1 = s.match(CHR_RE); + let c1 = s.match(CHR_RE); if (!c1) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"'); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12173,15 +12300,14 @@ function reduceRegexToSetBitArray(s, name, opts) { // this is starting a set within the regex: scan until end of set! var set_content = []; while (s.length) { - var inner = s.match(SET_PART_RE); + let inner = s.match(SET_PART_RE); if (!inner) { inner = s.match(CHR_RE); if (!inner) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"'); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12195,9 +12321,8 @@ function reduceRegexToSetBitArray(s, name, opts) { if (!c2) { // cope with illegal escape sequences too! return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error('regex set expression is broken in regex: ' + orig); } @@ -12281,10 +12406,9 @@ function reduceRegexToSetBitArray(s, name, opts) { // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; assert$1(s); assert$1(!(s instanceof Error)); - re = new XRegExp('[' + s + ']'); + let re = new XRegExp('[' + s + ']'); re.test(s[0]); // One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` @@ -12309,25 +12433,24 @@ function reduceRegexToSetBitArray(s, name, opts) { -// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` +// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! function produceOptimizedRegex4Set(bitarr) { // First try to produce a minimum regex from the bitarray directly: - var s1 = bitarray2set(bitarr, false, true); + let s1 = bitarray2set(bitarr, false, true); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s1.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s1; - } else { - s1 = '[' + s1 + ']'; } + s1 = '[' + s1 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s2 = bitarray2set(bitarr, true, true); + let s2 = bitarray2set(bitarr, true, true); if (s2[0] === '^') { s2 = s2.substr(1); @@ -12342,23 +12465,22 @@ function produceOptimizedRegex4Set(bitarr) { // Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: - // + // // First try to produce a minimum regex from the bitarray directly: - var s3 = bitarray2set(bitarr, false, false); + let s3 = bitarray2set(bitarr, false, false); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s3.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s3; - } else { - s3 = '[' + s3 + ']'; } + s3 = '[' + s3 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s4 = bitarray2set(bitarr, true, false); + let s4 = bitarray2set(bitarr, true, false); if (s4[0] === '^') { s4 = s4.substr(1); @@ -12390,30 +12512,30 @@ function produceOptimizedRegex4Set(bitarr) { var setmgmt = { - XREGEXP_UNICODE_ESCAPE_RE, - CHR_RE, - SET_PART_RE, - NOTHING_SPECIAL_RE, - SET_IS_SINGLE_PCODE_RE, - - UNICODE_BASE_PLANE_MAX_CP, - - WHITESPACE_SETSTR, - DIGIT_SETSTR, - WORDCHAR_SETSTR, - - set2bitarray, - bitarray2set, - produceOptimizedRegex4Set, - reduceRegexToSetBitArray, + XREGEXP_UNICODE_ESCAPE_RE, + CHR_RE, + SET_PART_RE, + NOTHING_SPECIAL_RE, + SET_IS_SINGLE_PCODE_RE, + + UNICODE_BASE_PLANE_MAX_CP, + + WHITESPACE_SETSTR, + DIGIT_SETSTR, + WORDCHAR_SETSTR, + + set2bitarray, + bitarray2set, + produceOptimizedRegex4Set, + reduceRegexToSetBitArray }; // Basic Lexer implemented using JavaScript regular expressions -var rmCommonWS$2 = helpers.rmCommonWS; -var mkIdentifier$2 = helpers.mkIdentifier; -var code_exec$1 = helpers.exec; +const rmCommonWS$2 = helpers.rmCommonWS; +const mkIdentifier$2 = helpers.mkIdentifier; +const code_exec = helpers.exec; -var version = '0.6.2-220'; // require('./package.json').version; +const version = '0.6.2-220'; // require('./package.json').version; @@ -12474,7 +12596,7 @@ const defaultJisonLexOptions = { exportAST: false, prettyCfg: true, pre_lex: undefined, - post_lex: undefined, + post_lex: undefined }; @@ -12492,23 +12614,23 @@ const defaultJisonLexOptions = { // Return a fresh set of options. /** @public */ function mkStdOptions(/*...args*/) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - var args = [].concat.apply([], arguments); + let opts = {}; + let args = [].concat.apply([], arguments); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(defaultJisonLexOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; for (var p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { @@ -12546,7 +12668,7 @@ function mkStdOptions(/*...args*/) { function prepExportStructures(options) { // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -12567,8 +12689,8 @@ function prepExportStructures(options) { // Otherwise return the *parsed* lexer spec as it has // been processed through LexParser. function autodetectAndConvertToJSONformat(lexerSpec, options) { - var chk_l = null; - var ex1, err; + let chk_l = null; + let ex1, err; if (typeof lexerSpec === 'string') { if (options.json) { @@ -12620,9 +12742,9 @@ function autodetectAndConvertToJSONformat(lexerSpec, options) { /should be separated/, /an error in one or more of your lexer regex rules/, /an error in your lexer epilogue/, - /unsupported definition type/, + /unsupported definition type/ ]; - var cmnerr = commonErrors.filter(function check(re) { + let cmnerr = commonErrors.filter(function check(re) { return e.message.match(re); }); if (cmnerr.length > 0) { @@ -12651,14 +12773,14 @@ function autodetectAndConvertToJSONformat(lexerSpec, options) { // expand macros and convert matchers to RegExp's function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) { - var m, i, k, rule, action, conditions; - var active_conditions; + let m, i, k, rule, action, conditions; + let active_conditions; assert$1(Array.isArray(dict.rules)); - var rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! - var newRules = []; - var macros = {}; - var regular_rule_count = 0; - var simple_rule_count = 0; + let rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! + let newRules = []; + let macros = {}; + let regular_rule_count = 0; + let simple_rule_count = 0; // Assure all options are camelCased: assert$1(typeof opts.options['case-insensitive'] === 'undefined'); @@ -12668,7 +12790,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) } if (opts.options.flex && rules.length > 0) { - rules.push(['.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']); + rules.push([ '.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */' ]); } // Depending on the location within the regex we need different expansions of the macros: @@ -12692,7 +12814,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) return str; } - var routingCode = ['switch(yyrulenumber) {']; + let routingCode = [ 'switch(yyrulenumber) {' ]; for (i = 0; i < rules.length; i++) { rule = rules[i].slice(0); // shallow copy: do not modify input rules @@ -12746,7 +12868,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) action = action.replace(/return\s*\(?'((?:\\'|[^']+)+)'\)?/g, tokenNumberReplacement); action = action.replace(/return\s*\(?"((?:\\"|[^"]+)+)"\)?/g, tokenNumberReplacement); - var code = ['\n/*! Conditions::']; + let code = [ '\n/*! Conditions::' ]; code.push(postprocessComment(active_conditions)); code.push('*/', '\n/*! Rule:: '); code.push(postprocessComment(rule[0])); @@ -12767,7 +12889,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) // 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'. - var match_nr = /^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim()); + 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 ')); @@ -12794,7 +12916,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) macros: macros, regular_rule_count: regular_rule_count, - simple_rule_count: simple_rule_count, + simple_rule_count: simple_rule_count }; } @@ -12807,14 +12929,13 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) // 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. function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElsewhere_cb) { - var orig = s; + let orig = s; function errinfo() { if (name) { return 'macro [[' + name + ']]'; - } else { - return 'regex [[' + orig + ']]'; } + return 'regex [[' + orig + ']]'; } // propagate deferred exceptions = error reports. @@ -12822,19 +12943,18 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse return s; } - var c1, c2; - var rv = []; - var derr; - var se; + let c1, c2; + let rv = []; + let derr; + let se; while (s.length) { c1 = s.match(CHR_RE$1); if (!c1) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12844,15 +12964,14 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse var l = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1); while (s.length) { - var inner = s.match(SET_PART_RE$1); + let inner = s.match(SET_PART_RE$1); if (!inner) { inner = s.match(CHR_RE$1); if (!inner) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12866,9 +12985,8 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse if (!c2) { // cope with illegal escape sequences too! return new Error(errinfo() + ': regex set expression is broken: "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error(errinfo() + ': regex set expression is broken: apparently unterminated'); } @@ -12929,7 +13047,7 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse c2 = c2[0]; s = s.substr(c2.length); - var c3 = s[0]; + let c3 = s[0]; s = s.substr(c3.length); if (c3 === '}') { // possibly a macro name in there... Expand if possible: @@ -12982,7 +13100,7 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; + let re; re = new XRegExp(s); re.test(s[0]); } catch (ex) { @@ -12998,11 +13116,11 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse // expand macros within macros and cache the result function prepareMacros(dict_macros, opts) { - var macros = {}; + let macros = {}; // expand a `{NAME}` macro which exists inside a `[...]` set: function expandMacroInSet(i) { - var k, a, m; + let k, a, m; if (!macros[i]) { m = dict_macros[i]; @@ -13036,7 +13154,7 @@ function prepareMacros(dict_macros, opts) { a = m.split('{' + k + '}'); if (a.length > 1) { - var x = expandMacroInSet(k); + let x = expandMacroInSet(k); assert$1(x); if (x instanceof Error) { m = x; @@ -13048,9 +13166,9 @@ function prepareMacros(dict_macros, opts) { } } - var mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); + let mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); - var s1; + let s1; // propagate deferred exceptions = error reports. if (mba instanceof Error) { @@ -13084,7 +13202,7 @@ function prepareMacros(dict_macros, opts) { } function expandMacroElsewhere(i) { - var m; + let m; if (macros[i].elsewhere == null) { m = dict_macros[i]; @@ -13119,13 +13237,13 @@ function prepareMacros(dict_macros, opts) { } function expandAllMacrosInSet(s) { - var i, x; + let i, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { for (i in macros) { if (macros.hasOwnProperty(i)) { - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroInSet(i); assert$1(x); @@ -13147,7 +13265,7 @@ function prepareMacros(dict_macros, opts) { } function expandAllMacrosElsewhere(s) { - var i, x; + let i, x; // When we process the remaining macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13162,7 +13280,7 @@ function prepareMacros(dict_macros, opts) { for (i in macros) { if (macros.hasOwnProperty(i)) { // These are all submacro expansions, hence non-capturing grouping is applied: - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroElsewhere(i); assert$1(x); @@ -13184,7 +13302,7 @@ function prepareMacros(dict_macros, opts) { } - var i; + let i; if (opts.debug) console.log('\n############## RAW macros: ', dict_macros); @@ -13215,13 +13333,13 @@ function prepareMacros(dict_macros, opts) { // expand macros in a regex; expands them recursively function expandMacros(src, macros, opts) { - var expansion_count = 0; + let expansion_count = 0; // By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! // Hence things should be easy in there: function expandAllMacrosInSet(s) { - var i, m, x; + let i, m, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { @@ -13229,7 +13347,7 @@ function expandMacros(src, macros, opts) { if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = m.in_set; @@ -13260,7 +13378,7 @@ function expandMacros(src, macros, opts) { } function expandAllMacrosElsewhere(s) { - var i, m, x; + let i, m, x; // When we process the main macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13276,7 +13394,7 @@ function expandMacros(src, macros, opts) { if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { // These are all main macro expansions, hence CAPTURING grouping is applied: x = m.elsewhere; @@ -13312,7 +13430,7 @@ function expandMacros(src, macros, opts) { // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! - var s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); + let s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); // propagate deferred exceptions = error reports. if (s2 instanceof Error) { throw s2; @@ -13337,8 +13455,8 @@ function expandMacros(src, macros, opts) { } function prepareStartConditions(conditions) { - var sc; - var hash = {}; + let sc; + let hash = {}; for (sc in conditions) { if (conditions.hasOwnProperty(sc)) { @@ -13352,22 +13470,22 @@ function prepareStartConditions(conditions) { } function buildActions(dict, tokens, opts) { - var actions = [dict.actionInclude || '', 'var YYSTATE = YY_START;']; - var tok; - var toks = {}; - var caseHelper = []; + let actions = [ dict.actionInclude || '', 'var YYSTATE = YY_START;' ]; + let tok; + let toks = {}; + let caseHelper = []; // tokens: map/array of token numbers to token names for (tok in tokens) { - var idx = parseInt(tok); + let idx = parseInt(tok); if (idx && idx > 0) { toks[tokens[tok]] = idx; } } - var gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); + let gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); - var code = actions.join('\n'); + let code = actions.join('\n'); 'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function (yy) { code = code.replace(new RegExp('\\b(' + yy + ')\\b', 'g'), 'yy_.$1'); }); @@ -13385,7 +13503,7 @@ function buildActions(dict, tokens, opts) { macros: gen.macros, // propagate these for debugging/diagnostic purposes regular_rule_count: gen.regular_rule_count, - simple_rule_count: gen.simple_rule_count, + simple_rule_count: gen.simple_rule_count }; } @@ -13396,7 +13514,7 @@ function buildActions(dict, tokens, opts) { function generateErrorClass() { // --- START lexer error class --- -var prelude = `/** +const prelude = `/** * 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 @@ -13407,8 +13525,6 @@ var prelude = `/** * @nocollapse */ function JisonLexerError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -13425,9 +13541,9 @@ function JisonLexerError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -13488,8 +13604,8 @@ function generateFakeXRegExpClassSrcCode() { /** @constructor */ function RegExpLexer(dict, input, tokens, build_options) { - var opts; - var dump = false; + let opts; + let dump = false; function test_me(tweak_cb, description, src_exception, ex_callback) { opts = processGrammar(dict, tokens, build_options); @@ -13499,7 +13615,7 @@ function RegExpLexer(dict, input, tokens, build_options) { if (tweak_cb) { tweak_cb(); } - var source = generateModuleBody(opts); + let source = generateModuleBody(opts); try { // The generated code will always have the `lexer` variable declared at local scope // as `eval()` will use the local scope. @@ -13507,16 +13623,16 @@ function RegExpLexer(dict, input, tokens, build_options) { // The compiled code will look something like this: // // ``` - // var lexer; + // let lexer; // bla bla... // ``` // // or // // ``` - // var lexer = { bla... }; + // const lexer = { bla... }; // ``` - var testcode = [ + let testcode = [ '// provide a local version for test purposes:', jisonLexerErrorDefinition, '', @@ -13524,14 +13640,33 @@ function RegExpLexer(dict, input, tokens, build_options) { '', source, '', + rmCommonWS$2` + // JISON INJECTED VALIDATION CODE + // which attempts to ascertain you have defined a minimal viable lexer at least: + if (typeof lexer === "undefined") { + throw new SyntaxError("user-defined lexer does not define the required 'lexer' instance."); + } + if (!lexer) { + throw new SyntaxError("user-defined lexer does not define a non-NULL 'lexer' instance."); + } + if (typeof lexer.setInput !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.setInput()' API function."); + } + if (typeof lexer.lex !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.lex()' API function."); + } + // END OF JISON INJECTED VALIDATION CODE + `, 'return lexer;' ].join('\n'); - var lexer = code_exec$1(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { + let lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { //console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$2(sourcecode); - var lexer_f = new Function('', sourcecode); + let lexer_f = new Function('', sourcecode); return lexer_f(); - }, opts.options, "lexer"); + }, Object.assign({}, opts.options, { + throwErrorOnCompileFailure: true + }), 'lexer'); if (!lexer) { throw new Error('no lexer defined *at all*?!'); @@ -13548,7 +13683,7 @@ function RegExpLexer(dict, input, tokens, build_options) { // When we do NOT crash, we found/killed the problem area just before this call! if (src_exception && description) { - var msg = description; + let msg = description; if (typeof description === 'function') { msg = description(); } @@ -13557,8 +13692,8 @@ function RegExpLexer(dict, input, tokens, build_options) { // patch the pre and post handlers in there, now that we have some live code to work with: if (opts.options) { - var pre = opts.options.pre_lex; - var post = opts.options.post_lex; + let pre = opts.options.pre_lex; + let post = opts.options.post_lex; // since JSON cannot encode functions, we'll have to do it manually now: if (typeof pre === 'function') { lexer.options.pre_lex = pre; @@ -13572,7 +13707,7 @@ function RegExpLexer(dict, input, tokens, build_options) { if (typeof opts.options.showSource === 'function') { opts.options.showSource(lexer, source, opts, RegExpLexer); } else { - console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n"); + console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n', source, '\n----------------------------------------\n'); } } return lexer; @@ -13591,13 +13726,13 @@ function RegExpLexer(dict, input, tokens, build_options) { } /** @constructor */ - var lexer = test_me(null, null, null, function (ex) { + let lexer = test_me(null, null, null, function (ex) { // When we get an exception here, it means some part of the user-specified lexer is botched. // // Now we go and try to narrow down the problem area/category: assert$1(opts.options); assert$1(opts.options.xregexp !== undefined); - var orig_xregexp_opt = !!opts.options.xregexp; + let orig_xregexp_opt = !!opts.options.xregexp; if (!test_me(function () { assert$1(opts.options.xregexp !== undefined); opts.options.xregexp = false; @@ -13616,7 +13751,7 @@ function RegExpLexer(dict, input, tokens, build_options) { 'Your custom lexer is somehow botched.' ); }, ex, null)) { - var rulesSpecSize; + let rulesSpecSize; if (!test_me(function () { // store the parsed rule set size so we can use that info in case // this attempt also fails: @@ -13629,7 +13764,7 @@ function RegExpLexer(dict, input, tokens, build_options) { opts.__in_rules_failure_analysis_mode__ = true; }, 'One or more of your lexer rules are possibly botched?', ex, null)) { // kill each rule action block, one at a time and test again after each 'edit': - var rv = false; + let rv = false; for (var i = 0, len = rulesSpecSize; i < len; i++) { var lastEditedRuleSpec; rv = test_me(function () { @@ -13641,10 +13776,10 @@ function RegExpLexer(dict, input, tokens, build_options) { // opts.__in_rules_failure_analysis_mode__ = true; // nuke all rules' actions up to and including rule numero `i`: - for (var j = 0; j <= i; j++) { + for (let j = 0; j <= i; j++) { // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; // now we want to edit the *action* part: - var rule = opts.rules[j]; + let rule = opts.rules[j]; assert$1(Array.isArray(rule)); assert$1(rule.length === 2 || rule.length === 3); rule.pop(); @@ -13778,8 +13913,6 @@ return `{ * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -13789,14 +13922,14 @@ return `{ } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\\n\\s*$/.test(msg)) { msg += '\\n'; } msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') { msg += '\\n' + pos_str; @@ -13807,14 +13940,14 @@ return `{ } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the \`upcomingInput\` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -13834,9 +13967,8 @@ return `{ // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -13856,8 +13988,6 @@ return `{ * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -13878,16 +14008,14 @@ return `{ * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -13908,8 +14036,6 @@ return `{ * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -13917,8 +14043,8 @@ return `{ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -13936,8 +14062,6 @@ return `{ * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -13947,14 +14071,14 @@ return `{ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -13965,8 +14089,6 @@ return `{ * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -13974,40 +14096,40 @@ return `{ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -14019,7 +14141,7 @@ return `{ this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -14027,7 +14149,7 @@ return `{ last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -14088,9 +14210,7 @@ return `{ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -14109,8 +14229,6 @@ return `{ * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set \`done\` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -14119,7 +14237,7 @@ return `{ this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -14129,13 +14247,13 @@ return `{ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\\n') { lines = true; } else if (ch === '\\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\\n') { slice_len++; ch += ch2; @@ -14167,10 +14285,8 @@ return `{ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -14202,8 +14318,8 @@ return `{ // Get last entirely matched line into the \`pre_lines[]\` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -14221,9 +14337,9 @@ return `{ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -14233,14 +14349,12 @@ return `{ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -14251,8 +14365,6 @@ return `{ * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -14265,19 +14377,17 @@ return `{ * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the \`parseError()\` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // \`.lex()\` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -14290,8 +14400,6 @@ return `{ * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -14314,24 +14422,24 @@ return `{ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substr\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14343,8 +14451,8 @@ return `{ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to \`maxSize\` (default: 20). @@ -14370,24 +14478,25 @@ return `{ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > \`lookAhead()\` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substring\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -14396,7 +14505,7 @@ return `{ } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14415,10 +14524,8 @@ return `{ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^'; }, @@ -14440,15 +14547,13 @@ return `{ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -14579,58 +14684,54 @@ return `{ * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\\t/g, ' '); @@ -14639,13 +14740,13 @@ return `{ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -14667,15 +14768,13 @@ return `{ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -14687,8 +14786,8 @@ return `{ rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -14717,13 +14816,7 @@ return `{ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -14752,10 +14845,10 @@ return `{ }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -14783,7 +14876,7 @@ return `{ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -14794,7 +14887,7 @@ return `{ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -14816,8 +14909,6 @@ return `{ * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -14826,17 +14917,13 @@ return `{ this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -14846,67 +14933,75 @@ return `{ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that \`parseError()\` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) \`parseError()\` @@ -14933,9 +15028,7 @@ return `{ * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -14978,24 +15071,24 @@ return `{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15015,9 +15108,7 @@ return `{ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15027,24 +15118,24 @@ return `{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15052,7 +15143,7 @@ return `{ this._clear_state = 0; } - + return r; }, @@ -15065,9 +15156,7 @@ return `{ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -15075,7 +15164,7 @@ return `{ (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -15090,8 +15179,6 @@ return `{ * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -15103,8 +15190,6 @@ return `{ * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -15118,15 +15203,12 @@ return `{ * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -15138,14 +15220,11 @@ return `{ * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -15156,16 +15235,14 @@ return `{ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -15175,8 +15252,6 @@ return `{ * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; } }`; @@ -15208,18 +15283,17 @@ function stripUnusedLexerCode(src, opt) { // ............................. ${opt.lexerActionsUseDisplayAPIs} // uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC} - var new_src; + let new_src; try { - var ast = helpers.parseCodeChunkToAST(src, opt); + let ast = helpers.parseCodeChunkToAST(src, opt); new_src = helpers.prettyPrintAST(ast, opt); - } - catch (ex) { + } catch (ex) { let line = ex.lineNumber || 0; let a = src.split(/\r?\n/g); let len = a.length; let minl = Math.max(0, line - 10); let b = a.slice(minl, line + 10); - let c = b.splice(line - minl, 0, "", "^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", ""); + let c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); let offendingChunk = ' ' + b.join('\n '); console.error(rmCommonWS$2` stripUnusedLexerCode WARNING: @@ -15235,17 +15309,11 @@ function stripUnusedLexerCode(src, opt) { ${offendingChunk} `); - + new_src = src; } - - - - - - // inject analysis report now: new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2` // Code Generator Information Report @@ -15300,7 +15368,7 @@ function stripUnusedLexerCode(src, opt) { // generate lexer source from a grammar /** @public */ function generate(dict, tokens, build_options) { - var opt = processGrammar(dict, tokens, build_options); + let opt = processGrammar(dict, tokens, build_options); return generateFromOpts(opt); } @@ -15309,7 +15377,7 @@ function generate(dict, tokens, build_options) { /** @public */ function processGrammar(dict, tokens, build_options) { build_options = build_options || {}; - var opts = { + let opts = { // include the knowledge passed through `build_options` about which lexer // features will actually be *used* by the environment (which in 99.9% // of cases is a jison *parser*): @@ -15349,7 +15417,7 @@ function processGrammar(dict, tokens, build_options) { lexerActionsUseReject: '???', lexerActionsUseLess: '???', lexerActionsUseDisplayAPIs: '???', - lexerActionsUseDescribeYYLOC: '???', + lexerActionsUseDescribeYYLOC: '???' }; dict = autodetectAndConvertToJSONformat(dict, build_options) || {}; @@ -15374,7 +15442,7 @@ function processGrammar(dict, tokens, build_options) { // only produce rule action code blocks when there are any rules at all; // a "custom lexer" has ZERO rules and must be defined entirely in // other code blocks: - var code = (dict.rules ? buildActions(dict, tokens, opts) : {}); + let code = (dict.rules ? buildActions(dict, tokens, opts) : {}); opts.performAction = code.actions; opts.caseHelperInclude = code.caseHelperInclude; opts.rules = code.rules || []; @@ -15383,7 +15451,7 @@ function processGrammar(dict, tokens, build_options) { opts.regular_rule_count = code.regular_rule_count; opts.simple_rule_count = code.simple_rule_count; - opts.conditionStack = ['INITIAL']; + opts.conditionStack = [ 'INITIAL' ]; opts.actionInclude = (dict.actionInclude || ''); opts.moduleInclude = (opts.moduleInclude || '') + (dict.moduleInclude || '').trim(); @@ -15394,7 +15462,7 @@ function processGrammar(dict, tokens, build_options) { // Assemble the final source from the processed grammar /** @public */ function generateFromOpts(opt) { - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -15417,12 +15485,12 @@ function generateFromOpts(opt) { } function generateRegexesInitTableCode(opt) { - var a = opt.rules; - var print_xregexp = opt.options && opt.options.xregexp; - var id_display_width = (1 + Math.log10(a.length | 1) | 0); - var ws_prefix = new Array(id_display_width).join(' '); - var b = a.map(function generateXRegExpInitCode(re, idx) { - var idx_str = (ws_prefix + idx).substr(-id_display_width); + let a = opt.rules; + let print_xregexp = opt.options && opt.options.xregexp; + let id_display_width = (1 + Math.log10(a.length | 1) | 0); + let ws_prefix = new Array(id_display_width).join(' '); + let b = a.map(function generateXRegExpInitCode(re, idx) { + let idx_str = (ws_prefix + idx).substr(-id_display_width); if (re instanceof XRegExp) { // When we don't need the special XRegExp sauce at run-time, we do with the original @@ -15432,11 +15500,11 @@ function generateRegexesInitTableCode(opt) { } // And make sure to escape the regex to make it suitable for placement inside a *string* // as it is passed as a string argument to the XRegExp constructor here. - var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); + let re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); return `/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`; - } else { - return `/* ${idx_str}: */ ${re}`; } + return `/* ${idx_str}: */ ${re}`; + }); return b.join(',\n'); } @@ -15444,77 +15512,77 @@ function generateRegexesInitTableCode(opt) { function generateModuleBody(opt) { // make the JSON output look more like JavaScript: function cleanupJSON(str) { - str = str.replace(/ "rules": \[/g, ' rules: ['); - str = str.replace(/ "inclusive": /g, ' inclusive: '); + str = str.replace(/ {2}"rules": \[/g, ' rules: ['); + str = str.replace(/ {2}"inclusive": /g, ' inclusive: '); return str; } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - json: 1, - _: 1, - noMain: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - lexerErrorsAreRecoverable: 0, - flex: 0, - backtrack_lexer: 0, - caseInsensitive: 0, - showSource: 1, - exportAST: 1, - exportAllTables: 1, - exportSourceCode: 1, - prettyCfg: 1, - parseActionsUseYYLENG: 1, - parseActionsUseYYLINENO: 1, - parseActionsUseYYTEXT: 1, - parseActionsUseYYLOC: 1, - parseActionsUseParseError: 1, - parseActionsUseYYERROR: 1, - parseActionsUseYYRECOVERING: 1, - parseActionsUseYYERROK: 1, - parseActionsUseYYCLEARIN: 1, - parseActionsUseValueTracking: 1, - parseActionsUseValueAssignment: 1, - parseActionsUseLocationTracking: 1, - parseActionsUseLocationAssignment: 1, - parseActionsUseYYSTACK: 1, - parseActionsUseYYSSTACK: 1, - parseActionsUseYYSTACKPOINTER: 1, - parseActionsUseYYRULELENGTH: 1, - parseActionsUseYYMERGELOCATIONINFO: 1, - parserHasErrorRecovery: 1, - parserHasErrorReporting: 1, - lexerActionsUseYYLENG: 1, - lexerActionsUseYYLINENO: 1, - lexerActionsUseYYTEXT: 1, - lexerActionsUseYYLOC: 1, - lexerActionsUseParseError: 1, - lexerActionsUseYYERROR: 1, - lexerActionsUseLocationTracking: 1, - lexerActionsUseMore: 1, - lexerActionsUseUnput: 1, - lexerActionsUseReject: 1, - lexerActionsUseLess: 1, - lexerActionsUseDisplayAPIs: 1, - lexerActionsUseDescribeYYLOC: 1, + let obj = {}; + const do_not_pass = { + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + json: 1, + _: 1, + noMain: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + lexerErrorsAreRecoverable: 0, + flex: 0, + backtrack_lexer: 0, + caseInsensitive: 0, + showSource: 1, + exportAST: 1, + exportAllTables: 1, + exportSourceCode: 1, + prettyCfg: 1, + parseActionsUseYYLENG: 1, + parseActionsUseYYLINENO: 1, + parseActionsUseYYTEXT: 1, + parseActionsUseYYLOC: 1, + parseActionsUseParseError: 1, + parseActionsUseYYERROR: 1, + parseActionsUseYYRECOVERING: 1, + parseActionsUseYYERROK: 1, + parseActionsUseYYCLEARIN: 1, + parseActionsUseValueTracking: 1, + parseActionsUseValueAssignment: 1, + parseActionsUseLocationTracking: 1, + parseActionsUseLocationAssignment: 1, + parseActionsUseYYSTACK: 1, + parseActionsUseYYSSTACK: 1, + parseActionsUseYYSTACKPOINTER: 1, + parseActionsUseYYRULELENGTH: 1, + parseActionsUseYYMERGELOCATIONINFO: 1, + parserHasErrorRecovery: 1, + parserHasErrorReporting: 1, + lexerActionsUseYYLENG: 1, + lexerActionsUseYYLINENO: 1, + lexerActionsUseYYTEXT: 1, + lexerActionsUseYYLOC: 1, + lexerActionsUseParseError: 1, + lexerActionsUseYYERROR: 1, + lexerActionsUseLocationTracking: 1, + lexerActionsUseMore: 1, + lexerActionsUseUnput: 1, + lexerActionsUseReject: 1, + lexerActionsUseLess: 1, + lexerActionsUseDisplayAPIs: 1, + lexerActionsUseDescribeYYLOC: 1 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -15525,8 +15593,8 @@ function generateModuleBody(opt) { } // And now some options which should receive some special processing: - var pre = obj.pre_lex; - var post = obj.post_lex; + let pre = obj.pre_lex; + let post = obj.post_lex; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_lex = true; @@ -15535,7 +15603,7 @@ function generateModuleBody(opt) { obj.post_lex = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp(` "(${ID_REGEX_BASE$1})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_lex: true(,)?$/gm, function (m, ls, tc) { @@ -15548,17 +15616,17 @@ function generateModuleBody(opt) { } - var out; + let out; if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) { // we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. - var code = [rmCommonWS$2` - var lexer = { - `, '/*JISON-LEX-ANALYTICS-REPORT*/' /* slot #1: placeholder for analysis report further below */ + let code = [ rmCommonWS$2` + const lexer = { + `, '/* JISON-LEX-ANALYTICS-REPORT */\n' /* slot #1: placeholder for analysis report further below */ ]; // get the RegExpLexer.prototype in source code form: - var protosrc = getRegExpLexerPrototype(); + let protosrc = getRegExpLexerPrototype(); // and strip off the surrounding bits we don't want: protosrc = protosrc .replace(/^[\s\r\n]*\{/, '') @@ -15585,10 +15653,10 @@ function generateModuleBody(opt) { } */ - var performActionCode = String(opt.performAction); - var simpleCaseActionClustersCode = String(opt.caseHelperInclude); - var rulesCode = generateRegexesInitTableCode(opt); - var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); + let performActionCode = String(opt.performAction); + let simpleCaseActionClustersCode = String(opt.caseHelperInclude); + let rulesCode = generateRegexesInitTableCode(opt); + let conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); code.push(rmCommonWS$2`, JisonLexerError: JisonLexerError, performAction: ${performActionCode}, @@ -15608,9 +15676,9 @@ function generateModuleBody(opt) { // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // - // Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter + // Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. - out = 'var lexer;\n'; + out = '\n'; assert$1(opt.regular_rule_count === 0); assert$1(opt.simple_rule_count === 0); @@ -15624,8 +15692,6 @@ function generateModuleBody(opt) { // The output of this function is guaranteed to read something like this: // // ``` - // var lexer; - // // bla bla bla bla ... lotsa bla bla; // ``` // @@ -15634,7 +15700,7 @@ function generateModuleBody(opt) { } function generateGenericHeaderComment() { - var out = rmCommonWS$2` + let out = rmCommonWS$2` /* lexer generated by jison-lex ${version} */ /* @@ -15863,7 +15929,7 @@ function prepareOptions(opt) { // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else { @@ -15881,9 +15947,9 @@ function prepareOptions(opt) { function generateModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -15906,9 +15972,9 @@ function generateModule(opt) { function generateAMDModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} define([], function () { @@ -15931,12 +15997,12 @@ function generateAMDModule(opt) { function generateESModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} - var lexer = (function () { + const lexer = (function () { "use strict"; ${jisonLexerErrorDefinition} @@ -15965,9 +16031,9 @@ function generateESModule(opt) { function generateCommonJSModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -16004,14 +16070,13 @@ RegExpLexer.camelCase = helpers.camelCase; RegExpLexer.mkIdentifier = mkIdentifier$2; RegExpLexer.autodetectAndConvertToJSONformat = autodetectAndConvertToJSONformat; -var mkIdentifier$3 = helpers.mkIdentifier; +const mkIdentifier$3 = helpers.mkIdentifier; -var version$1 = '0.6.2-220'; // require('./package.json').version; +const version$1 = '0.6.2-220'; // require('./package.json').version; function getCommandlineOptions() { - - var opts = nomnom + let opts = nomnom .script('jison-lex') .unknownOptionTreatment(false) // do not accept unknown options! .options({ @@ -16061,7 +16126,7 @@ function getCommandlineOptions() { abbr: 'm', default: 'commonjs', metavar: 'TYPE', - choices: ['commonjs', 'amd', 'js', 'es'], + choices: [ 'commonjs', 'amd', 'js', 'es' ], help: 'The type of module to generate (commonjs, amd, es, js)' }, moduleName: { @@ -16095,7 +16160,7 @@ function getCommandlineOptions() { }).parse(); if (opts.debug) { - console.log("JISON-LEX CLI options:\n", opts); + console.log('JISON-LEX CLI options:\n', opts); } return opts; @@ -16123,7 +16188,7 @@ function cliMain(opts) { return true; } catch (e) { if (e.code === 'ENOENT') { - var parent = path$1.dirname(fp); + let parent = path$1.dirname(fp); // Did we hit the root directory by now? If so, abort! // Else, create the parent; iff that fails, we fail too... if (parent !== fp && mkdirp(parent)) { @@ -16141,16 +16206,16 @@ function cliMain(opts) { } function processInputFile() { - var original_cwd = process.cwd(); + let original_cwd = process.cwd(); - var raw = fs.readFileSync(path$1.normalize(opts.file), 'utf8'); + let raw = fs.readFileSync(path$1.normalize(opts.file), 'utf8'); // making best guess at json mode opts.json = path$1.extname(opts.file) === '.json' || opts.json; // When only the directory part of the output path was specified, then we // do NOT have the target module name in there as well! - var outpath = opts.outfile; + let outpath = opts.outfile; if (typeof outpath === 'string') { if (/[\\\/]$/.test(outpath) || isDirectory(outpath)) { opts.outfile = null; @@ -16169,7 +16234,7 @@ function cliMain(opts) { // setting output file name and module name based on input file name // if they aren't specified. - var name = path$1.basename(opts.outfile || opts.file); + let name = path$1.basename(opts.outfile || opts.file); // get the base name (i.e. the file name without extension) // i.e. strip off only the extension and keep any other dots in the filename @@ -16182,10 +16247,10 @@ function cliMain(opts) { // Change CWD to the directory where the source grammar resides: this helps us properly // %include any files mentioned in the grammar with relative paths: - var new_cwd = path$1.dirname(path$1.normalize(opts.file)); + let new_cwd = path$1.dirname(path$1.normalize(opts.file)); process.chdir(new_cwd); - var lexer = cli.generateLexerString(raw, opts); + let lexer = cli.generateLexerString(raw, opts); // and change back to the CWD we started out with: process.chdir(original_cwd); @@ -16197,8 +16262,8 @@ function cliMain(opts) { } function readin(cb) { - var stdin = process.openStdin(), - data = ''; + const stdin = process.openStdin(); + let data = ''; stdin.setEncoding('utf8'); stdin.addListener('data', function (chunk) { @@ -16225,9 +16290,8 @@ function cliMain(opts) { function generateLexerString(lexerSpec, opts) { - // var settings = RegExpLexer.mkStdOptions(opts); - var predefined_tokens = null; + let predefined_tokens = null; return RegExpLexer.generate(lexerSpec, predefined_tokens, opts); } @@ -16239,7 +16303,7 @@ var cli = { if (require.main === module) { - var opts = getCommandlineOptions(); + const opts = getCommandlineOptions(); cli.main(opts); } diff --git a/packages/jison-lex/dist/cli-umd-es5.js b/packages/jison-lex/dist/cli-umd-es5.js index a08987c5c..9071ae3dc 100644 --- a/packages/jison-lex/dist/cli-umd-es5.js +++ b/packages/jison-lex/dist/cli-umd-es5.js @@ -1,7 +1,7 @@ #!/usr/bin/env node -(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?module.exports=factory(require('fs'),require('path'),require('@gerhobbelt/nomnom'),require('@gerhobbelt/json5'),require('@gerhobbelt/xregexp'),require('recast'),require('@babel/core'),require('assert')):typeof define==='function'&&define.amd?define(['fs','path','@gerhobbelt/nomnom','@gerhobbelt/json5','@gerhobbelt/xregexp','recast','@babel/core','assert'],factory):(global=typeof globalThis!=='undefined'?globalThis:global||self,global['jison-lex']=factory(global.fs,global.path$1,global.nomnom,global.JSON5,global.XRegExp,global.recast,global.babel,global.assert$1));})(this,function(fs,path$1,nomnom,JSON5,XRegExp,recast,babel,assert$1){'use strict';function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e};}var fs__default=/*#__PURE__*/_interopDefaultLegacy(fs);var path__default=/*#__PURE__*/_interopDefaultLegacy(path$1);var nomnom__default=/*#__PURE__*/_interopDefaultLegacy(nomnom);var JSON5__default=/*#__PURE__*/_interopDefaultLegacy(JSON5);var XRegExp__default=/*#__PURE__*/_interopDefaultLegacy(XRegExp);var recast__default=/*#__PURE__*/_interopDefaultLegacy(recast);var assert__default=/*#__PURE__*/_interopDefaultLegacy(assert$1);// Return TRUE if `src` starts with `searchString`. +(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?module.exports=factory(require('fs'),require('path'),require('@gerhobbelt/nomnom'),require('@gerhobbelt/json5'),require('mkdirp'),require('@gerhobbelt/xregexp'),require('recast'),require('@babel/core'),require('assert')):typeof define==='function'&&define.amd?define(['fs','path','@gerhobbelt/nomnom','@gerhobbelt/json5','mkdirp','@gerhobbelt/xregexp','recast','@babel/core','assert'],factory):(global=typeof globalThis!=='undefined'?globalThis:global||self,global['jison-lex']=factory(global.fs,global.path$1,global.nomnom,global.JSON5,global.mkdirp,global.XRegExp,global.recast,global.babel,global.assert$1));})(this,function(fs,path$1,nomnom,JSON5,mkdirp,XRegExp,recast,babel,assert$1){'use strict';function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e};}var fs__default=/*#__PURE__*/_interopDefaultLegacy(fs);var path__default=/*#__PURE__*/_interopDefaultLegacy(path$1);var nomnom__default=/*#__PURE__*/_interopDefaultLegacy(nomnom);var JSON5__default=/*#__PURE__*/_interopDefaultLegacy(JSON5);var mkdirp__default=/*#__PURE__*/_interopDefaultLegacy(mkdirp);var XRegExp__default=/*#__PURE__*/_interopDefaultLegacy(XRegExp);var recast__default=/*#__PURE__*/_interopDefaultLegacy(recast);var assert__default=/*#__PURE__*/_interopDefaultLegacy(assert$1);// Return TRUE if `src` starts with `searchString`. function startsWith(src,searchString){return src.substr(0,searchString.length)===searchString;}// tagged template string helper which removes the indentation common to all // non-empty lines: that indentation was added as part of the source code // formatting of this lexer spec file and must be removed to produce what @@ -17,62 +17,72 @@ function startsWith(src,searchString){return src.substr(0,searchString.length)== function rmCommonWS(strings,...values){// As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. -// +// // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. -var indent_str=null;var src=strings.map(function splitIntoLines(s){var a=s.split('\n');indent_str=a.reduce(function analyzeLine(indent_str,line,index){// only check indentation of parts which follow a NEWLINE: -if(index!==0){var m=/^(\s*)\S/.exec(line);// only non-empty ~ content-carrying lines matter re common indent calculus: +let indent_str=null;let src=strings.map(function splitIntoLines(s){let a=s.split('\n');indent_str=a.reduce(function analyzeLine(indent_str,line,index){// only check indentation of parts which follow a NEWLINE: +if(index!==0){let m=/^(\s*)\S/.exec(line);// only non-empty ~ content-carrying lines matter re common indent calculus: if(m){if(indent_str==null){indent_str=m[1];}else if(m[1].length start at j=1 rather than j=0 -for(var j=1,linecnt=a.length;j `'camelsHaveOneHump'` +for(let j=1,linecnt=a.length;j `'camelsHaveOneHump'` /** @public */function camelCase(s){// Convert first character to lowercase -return s.replace(/^\w/,function(match){return match.toLowerCase();}).replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// do not mutate 'a-2' to 'a2': -if(c===rv&&c.match(/\d/)){return match;}return rv;});}// Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers -/** @public */function mkIdentifier(s){s=''+s;return s// Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), +return s.replace(/^\w/,function(match){return match.toLowerCase();}).replace(/-\w/g,function(match){const c=match.charAt(1);const rv=c.toUpperCase();// do not mutate 'a-2' to 'a2': +if(c===rv&&c.match(/\d/)){return match;}return rv;});}// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords=(list=>{let rv=new Set();for(let w of list){//console.error('reserved word:', w); +rv.add(w);}return rv;})(['await','break','case','catch','class','const','continue','debugger','default','delete','do','else','enum','export','extends','finally','for','function','if','implements','import','in','instanceof','interface','new','package','private','protected','public','return','super','switch','this','throw','try','typeof','var','void','while','with','yield']);// Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers +/** @public */function mkIdentifier(s){s=''+s;let rv=s// Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` -.replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// mutate 'a-2' to 'a_2': +.replace(/-\w/g,function(match){let c=match.charAt(1);let rv=c.toUpperCase();// mutate 'a-2' to 'a_2': if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;})// cleanup: replace any non-suitable character series to a single underscore: .replace(/^([\d])/,'_$1')// where leading numbers are prefixed by an underscore: '1' --> '_1' .replace(/^[^\w_]/,'_')// do not accept numerics at the leading position, despite those matching regex `\w`: .replace(/^\d/,'_').replace(/[^\w\d_]/g,'_')// and only accept multiple (double, not triple) underscores at start or end of identifier name: -.replace(/^__+/,'#').replace(/__+$/,'#').replace(/_+/g,'_').replace(/#/g,'__');}// Check if the start of the given input matches a regex expression. +.replace(/^__+/,'#').replace(/__+$/,'#').replace(/_+/g,'_').replace(/#/g,'__');if(reservedWords.has(rv)){rv='_'+rv;}return rv;}// Check if the start of the given input matches a regex expression. // Return the length of the regex expression or -1 if none was found. /** @public */function scanRegExp(s){s=''+s;// code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` -var index=0;var length=s.length;var ch=s[index];//assert.assert(ch === '/', 'Regular expression literal must start with a slash'); -var str=s[index++];var classMarker=false;var terminated=false;while(index `'camelsHaveOneHump'` -let ref=s.replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// mutate 'a-2' to 'a_2': -if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;});var alt=mkIdentifier(s);return alt===ref;}// properly quote and escape the given input string -function dquote(s){var sq=s.indexOf('\'')>=0;var dq=s.indexOf('"')>=0;if(sq&&dq){s=s.replace(/"/g,'\\"');dq=false;}if(dq){s='\''+s+'\'';}else{s='"'+s+'"';}return s;}// +let ref=s.replace(/-\w/g,function(match){let c=match.charAt(1);let rv=c.toUpperCase();// mutate 'a-2' to 'a_2': +if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;});let alt=mkIdentifier(s);return alt===ref;}// properly quote and escape the given input string +function dquote(s){let sq=s.indexOf('\'')>=0;let dq=s.indexOf('"')>=0;if(sq&&dq){s=s.replace(/"/g,'\\"');dq=false;}if(dq){s='\''+s+'\'';}else{s='"'+s+'"';}return s;}// function chkBugger(src){src=String(src);if(src.match(/\bcov_\w+/)){console.error('### ISTANBUL COVERAGE CODE DETECTED ###\n',src);}}// Helper function: pad number with leading zeroes -function pad(n,p){p=p||2;var rv='0000'+n;return rv.slice(-p);}// attempt to dump in one of several locations: first winner is *it*! -function dumpSourceToFile(sourcecode,errname,err_id,options,ex){var dumpfile;options=options||{};try{var dumpPaths=[options.outfile?path__default['default'].dirname(options.outfile):null,options.inputPath,process.cwd()];var dumpName=path__default['default'].basename(options.inputFilename||options.moduleName||(options.outfile?path__default['default'].dirname(options.outfile):null)||options.defaultModuleName||errname).replace(/\.[a-z]{1,5}$/i,'')// remove extension .y, .yacc, .jison, ...whatever -.replace(/[^a-z0-9_]/ig,'_');// make sure it's legal in the destination filesystem: the least common denominator. -if(dumpName===''||dumpName==='_'){dumpName='__bugger__';}err_id=err_id||'XXX';var ts=new Date();var tm=ts.getUTCFullYear()+'_'+pad(ts.getUTCMonth()+1)+'_'+pad(ts.getUTCDate())+'T'+pad(ts.getUTCHours())+''+pad(ts.getUTCMinutes())+''+pad(ts.getUTCSeconds())+'.'+pad(ts.getUTCMilliseconds(),3)+'Z';dumpName+='.fatal_'+err_id+'_dump_'+tm+'.js';for(var i=0,l=dumpPaths.length;i'// '+l);d=d.join('\n');fs__default['default'].writeFileSync(dumpfile,sourcecode+'\n\n\n'+d,'utf8');console.error("****** offending generated "+errname+" source code dumped into file: ",dumpfile);break;// abort loop once a dump action was successful! +function pad(n,p){p=p||2;let rv='0000'+n;return rv.slice(-p);}function convertExceptionToObject(ex){if(!ex)return ex;// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error +// +// - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) +let rv=Object.assign({},ex);// - Set up the default fields which should ALWAYS be present: +rv.message=ex.message;rv.name=ex.name;rv.stack=ex.stack;// this assignment stringifies the stack trace in ex.stack. +// - Set the optional fields: +if(ex.code!==undefined)rv.code=ex.code;if(ex.type!==undefined)rv.type=ex.type;if(ex.fileName!==undefined)rv.fileName=ex.fileName;if(ex.lineNumber!==undefined)rv.lineNumber=ex.lineNumber;if(ex.columnNumber!==undefined)rv.columnNumber=ex.columnNumber;if(Array.isArray(ex.errors)){rv.errors=[];for(let se of ex.errors){rv.errors.push(convertExceptionToObject(se));}}return rv;}function find_suitable_app_dump_path(){return process.cwd().replace(/\\/g,'/').replace(/\/node_modules\/.*$/,m=>'/___nm___/').replace(/(\/jison\/)(.*)$/,(m,p1,p2)=>p1+'___'+p2.split('/').map(d=>d.charAt(0).toUpperCase()).join('_'));}// attempt to dump in one of several locations: first winner is *it*! +function dumpSourceToFile(sourcecode,errname,err_id,options,ex){let dumpfile;options=options||{};try{const dumpPaths=[options.outfile?path__default['default'].dirname(options.outfile):null,options.inputPath,find_suitable_app_dump_path()];let dumpName=path__default['default'].basename(options.inputFilename||options.moduleName||(options.outfile?path__default['default'].dirname(options.outfile):null)||options.defaultModuleName||errname).replace(/\.[a-z]{1,5}$/i,'')// remove extension .y, .yacc, .jison, ...whatever +.replace(/[^a-z0-9_]/ig,'_')// make sure it's legal in the destination filesystem: the least common denominator. +.substr(0,100);if(dumpName===''||dumpName==='_'){dumpName='__bugger__';}// generate a stacktrace for the dump no matter what: +if(!ex){try{throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this.");}catch(ex2){ex=ex2;}}err_id=err_id||'XXX';err_id=err_id.replace(/[^a-z0-9_]/ig,'_')// make sure it's legal in the destination filesystem: the least common denominator. +.substr(0,50);const ts=new Date();const tm=ts.getUTCFullYear()+'_'+pad(ts.getUTCMonth()+1)+'_'+pad(ts.getUTCDate())+'T'+pad(ts.getUTCHours())+''+pad(ts.getUTCMinutes())+''+pad(ts.getUTCSeconds())+'.'+pad(ts.getUTCMilliseconds(),3)+'Z';dumpName+='.fatal_'+err_id+'_dump_'+tm+'.js';for(let i=0,l=dumpPaths.length;i'[!circular ref!]'});// make sure each line is a comment line: +d=d.split('\n').map(l=>'// '+l);d=d.join('\n');mkdirp__default['default'](path__default['default'].dirname(dumpfile));fs__default['default'].writeFileSync(dumpfile,sourcecode+'\n\n\n'+d,'utf8');console.error('****** offending generated '+errname+' source code dumped into file: ',dumpfile);break;// abort loop once a dump action was successful! }catch(ex3){//console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); -if(i===l-1){throw ex3;}}}}catch(ex2){console.error("generated "+errname+" source code fatal DUMPING error: ",ex2.message," -- while attempting to dump into file: ",dumpfile,"\n",ex2.stack);}// augment the exception info, when available: +if(i===l-1){throw ex3;}}}}catch(ex2){console.error('generated '+errname+' source code fatal DUMPING error: ',ex2.message,' -- while attempting to dump into file: ',dumpfile,'\n',ex2.stack);}// augment the exception info, when available: if(ex){ex.offending_source_code=sourcecode;ex.offending_source_title=errname;ex.offending_source_dumpfile=dumpfile;}}// // `code_execution_rig` is a function which gets executed, while it is fed the `sourcecode` as a parameter. // When the `code_execution_rig` crashes, its failure is caught and (using the `options`) the sourcecode @@ -91,8 +101,12 @@ if(ex){ex.offending_source_code=sourcecode;ex.offending_source_title=errname;ex. // - options.moduleName // - options.defaultModuleName // -function exec_and_diagnose_this_stuff(sourcecode,code_execution_rig,options,title){options=options||{};var errname=""+(title||"exec_test");var err_id=errname.replace(/[^a-z0-9_]/ig,"_");if(err_id.length===0){err_id="exec_crash";}const debug=0;var p;try{// p = eval(sourcecode); -if(typeof code_execution_rig!=='function'){throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function");}chkBugger(sourcecode);p=code_execution_rig.call(this,sourcecode,options,errname,debug);}catch(ex){if(options.dumpSourceCodeOnFailure||1){dumpSourceToFile(sourcecode,errname,err_id,options,ex);}if(options.throwErrorOnCompileFailure){throw ex;}}return p;}var code_exec={exec:exec_and_diagnose_this_stuff,dump:dumpSourceToFile};// +function exec_and_diagnose_this_stuff(sourcecode,code_execution_rig,options,title){options=options||{};let errname=''+(title||'exec_test');let err_id=errname.replace(/[^a-z0-9_]/ig,'_');if(err_id.length===0){err_id='exec_crash';}const debug=options.debug||0;if(debug)console.warn('generated '+errname+' code under EXEC TEST.');if(debug>1){console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `);}let p;try{// p = eval(sourcecode); +if(typeof code_execution_rig!=='function'){throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function');}chkBugger(sourcecode);p=code_execution_rig.call(this,sourcecode,options,errname,debug);}catch(ex){if(debug>1)console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@');if(debug)console.log('generated '+errname+' source code fatal error: ',ex.message);if(debug>1)console.log('exec-and-diagnose options:',options);if(debug>1)console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@');if(options.dumpSourceCodeOnFailure||1){dumpSourceToFile(sourcecode,errname,err_id,options,ex);}if(options.throwErrorOnCompileFailure){throw ex;}}return p;}var exec={exec:exec_and_diagnose_this_stuff,dump:dumpSourceToFile,convertExceptionToObject};// assert__default['default'](recast__default['default']);//var types = recast.types; //assert(types); //var namedTypes = types.namedTypes; @@ -103,17 +117,17 @@ assert__default['default'](recast__default['default']);//var types = recast.type // WARNING: this regex MUST match the regex for `ID` in ebnf-parser::bnf.l jison language lexer spec! (`ID = [{ALPHA}]{ALNUM}*`) // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! -const ID_REGEX_BASE='[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*';// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +const ID_REGEX_BASE='[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*';// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: -const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode NonAsciiIdentifierStart characters +const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -121,37 +135,37 @@ const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode Non function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); -// As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode +// As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: -// +// // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything -// between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is +// between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. -// +// // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. -// +// // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: -// +// // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A -// +// // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. -// -// To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to +// +// To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the -// first character is fixed and the second character is chosen such that the escape code -// DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input +// first character is fixed and the second character is chosen such that the escape code +// DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: -// -// - the first character is ဩ which is highly visible and allows us to quickly search through a +// +// - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -159,30 +173,30 @@ function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only wan // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will -// pick a different base shape from that CANADIAN SYLLABICS charset. -// - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to +// pick a different base shape from that CANADIAN SYLLABICS charset. +// - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ -// - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered +// - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: -// +// // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 -// - 1489-14A0: ᒉ 5 -// - 14A3-14BA: ᒣ 6 -// - 14C0-14CF: ᓀ +// - 1489-14A0: ᒉ 5 +// - 14A3-14BA: ᒣ 6 +// - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 -// - 1526-153D: ᔦ +// - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -193,58 +207,58 @@ function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only wan // - 1622-162D: ᘢ // // ## JISON identifier formats ## -// +// // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. -// +// // -> (1+2) start-# + end-# -// +// // - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ -// +// // - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# -// +// // - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# -// +// // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - result location reference `@$` -// +// // -> (6) single-@ -// +// // - rule id number `#$` -// +// // -> (3) single-# -// +// // - result stack index `##$` -// +// // -> (4) double-# -// +// // - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -// +// // - 'negative index' location reference, e.g. `@-2` -// +// // -> (7) single-negative-@ -// +// // - 'negative index' stack indexes, e.g. `##-2` -// +// // -> (5) double-negative-# -// +// // count the number of occurrences of ch in src: -// +// // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -261,38 +275,38 @@ function countOccurrences(ch,src){let i=ch.codePointAt(0);return hash[i]||0;}// // Preferrably has ZERO occurrences in the given `input`, but otherwise // deliver the one with the least number of occurrences. function pickChar(set,input){// strip out the spaces: -set=set.replace(/\s+/g,'');assert__default['default'](set.length>=1);let lsidx=0;let lsfreq=Infinity;for(let i=0,l=set.length;i=1);let lsidx=0;let lsfreq=Infinity;for(let i=0,l=set.length;i (1+2) start-# + end-# -// +// // - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ -// +// // - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# -// +// // - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# -// +// // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - result location reference `@$` -// +// // -> (6) single-@ -// +// // - rule id number `#$` -// +// // -> (3) single-# -// +// // - result stack index `##$` -// +// // -> (4) double-# -// +// // - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -// +// // - 'negative index' location reference, e.g. `@-2` -// +// // -> (7) single-negative-@ -// +// // - 'negative index' stack indexes, e.g. `##-2` -// +// // -> (5) double-negative-# -// -const escChar=pickChar(escCharSet);let typeIdChar=[];for(let i=0,l=typeIdCharSets.length;i (1) start-# tokenDirectIdentifierStart:escChar+typeIdChar[0],tokenDirectIdentifierRe:new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`,'g'),// - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart:'$',tokenValueReferenceRe:new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`,'g'),// - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ // - result location reference `@$` -// +// // -> (6) single-@ tokenLocationStart:escChar+typeIdChar[1],tokenLocationRe:new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`,'g'),// - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# // - rule id number `#$` -// +// // -> (3) single-# tokenIdentifierStart:escChar+typeIdChar[2],tokenIdentifierRe:new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`,'g'),// - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# // - result stack index `##$` -// +// // -> (4) double-# tokenStackIndexStart:escChar+typeIdChar[3],tokenStackIndexRe:new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`,'g'),// - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -tokenNegativeValueReferenceStart:escChar+typeIdChar[4],tokenValueReferenceRe:new XRegExp__default['default'](`$-([0-9]+)`,'g'),// - 'negative index' location reference, e.g. `@-2` -// +tokenNegativeValueReferenceStart:escChar+typeIdChar[4],tokenValueReferenceRe:new XRegExp__default['default']('$-([0-9]+)','g'),// - 'negative index' location reference, e.g. `@-2` +// // -> (7) single-negative-@ -tokenNegativeLocationStart:escChar+typeIdChar[5],tokenNegativeLocationRe:new XRegExp__default['default'](`@-([0-9]+)`,'g'),// - 'negative index' stack indexes, e.g. `##-2` -// +tokenNegativeLocationStart:escChar+typeIdChar[5],tokenNegativeLocationRe:new XRegExp__default['default']('@-([0-9]+)','g'),// - 'negative index' stack indexes, e.g. `##-2` +// // -> (5) double-negative-# -tokenNegativeStackIndexStart:escChar+typeIdChar[6],tokenNegativeStackIndexRe:new XRegExp__default['default'](`#-([0-9]+)`,'g'),// combined regex for encoding direction +tokenNegativeStackIndexStart:escChar+typeIdChar[6],tokenNegativeStackIndexRe:new XRegExp__default['default']('#-([0-9]+)','g'),// combined regex for encoding direction tokenDetect4EncodeRe:new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`,'g'),// combined regex for decoding direction tokenDetect4DecodeRe:new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`,'g'),encode:function encodeJisonTokens(src,locationOffsetSpec){let re=this.tokenDetect4EncodeRe;// reset regex re.lastIndex=0;// patch `src` for the lookbehind emulation in the main regex used: src=' '+src;// Perform the encoding, one token at a time via callback function. -// +// // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. -// This is a tad sub-optimal as we won't be able to report errors early +// This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -415,35 +429,35 @@ if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax return src.substring(1);},decode:function decodeJisonTokens(src,locationOffsetSpec){let re=this.tokenDetect4DecodeRe;// reset regex re.lastIndex=0;// patch `src` for the lookbehind emulation in the main regex used: src=' '+src;// Perform the encoding, one token at a time via callback function. -// +// // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. -// This is a tad sub-optimal as we won't be able to report errors early +// This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src=src.replace(re,(m,p1,p2,p3,offset)=>{// p1 is only serving as lookbehind emulation -switch(p2){case this.tokenNegativeValueReferenceStart:return p1+"$-"+p3;case this.tokenNegativeStackIndexStart:return p1+"##-"+p3;case this.tokenStackIndexStart:return p1+"##"+p3;case this.tokenNegativeLocationStart:return p1+"@-"+p3;case this.tokenLocationStart:return p1+"@"+p3;case this.tokenDirectIdentifierStart:// p3 CANNOT be a negative value or token ID +switch(p2){case this.tokenNegativeValueReferenceStart:return p1+'$-'+p3;case this.tokenNegativeStackIndexStart:return p1+'##-'+p3;case this.tokenStackIndexStart:return p1+'##'+p3;case this.tokenNegativeLocationStart:return p1+'@-'+p3;case this.tokenLocationStart:return p1+'@'+p3;case this.tokenDirectIdentifierStart:// p3 CANNOT be a negative value or token ID if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: ${p2+p3+p4} is an illegal negative reference type`,src,offset+p1.length+p2.length);}return p1+p2+p3;}return p1+'#'+p3+'#';case this.tokenIdentifierStart:// p3 CANNOT be a negative value or token ID if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: ${p2+p3+p4} is an illegal negative reference type`,src,offset+p1.length+p2.length);}return p1+p2+p3;}return p1+'#'+p3;default:if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: unexpected jison token sentinel escape ${p2} at ${p2+p3}`,src,offset+p1.length);}return p1+p2+p3;}});// and remove the added prefix which was used for lookbehind emulation: -return src.substring(1);}};}function parseCodeChunkToAST(src,options){src=src.replace(/@/g,'\uFFDA').replace(/#/g,'\uFFDB');var ast=recast__default['default'].parse(src);return ast;}function compileCodeToES5(src,options){options=Object.assign({},{ast:true,code:true,sourceMaps:true,comments:true,filename:'compileCodeToES5.js',sourceFileName:'compileCodeToES5.js',sourceRoot:'.',sourceType:'module',babelrc:false,ignore:["node_modules/**/*.js"],compact:false,retainLines:false,presets:[["@babel/preset-env",{targets:{browsers:["last 2 versions"],node:"8.0"}}]]},options);return babel.transformSync(src,options);// => { code, map, ast } -}function prettyPrintAST(ast,options){var options=options||{};const defaultOptions={tabWidth:2,quote:'single',arrowParensAlways:true,// Do not reuse whitespace (or anything else, for that matter) +return src.substring(1);}};}function parseCodeChunkToAST(src,options){src=src.replace(/@/g,'\uFFDA').replace(/#/g,'\uFFDB');const ast=recast__default['default'].parse(src);return ast;}function compileCodeToES5(src,options){options=Object.assign({},{ast:true,code:true,sourceMaps:true,comments:true,filename:'compileCodeToES5.js',sourceFileName:'compileCodeToES5.js',sourceRoot:'.',sourceType:'module',babelrc:false,ignore:['node_modules/**/*.js'],compact:false,retainLines:false,presets:[['@babel/preset-env',{targets:{browsers:['last 2 versions'],node:'8.0'}}]]},options);return babel.transformSync(src,options);// => { code, map, ast } +}function prettyPrintAST(ast,options){options=options||{};const defaultOptions={tabWidth:2,quote:'single',arrowParensAlways:true,// Do not reuse whitespace (or anything else, for that matter) // when printing generically. -reuseWhitespace:false};for(var key in defaultOptions){if(options[key]===undefined){options[key]=defaultOptions[key];}}let s=recast__default['default'].prettyPrint(ast,defaultOptions);let new_src=s.code;new_src=new_src.replace(/\r\n|\n|\r/g,'\n')// platform dependent EOL fixup +reuseWhitespace:false};for(let key in defaultOptions){if(options[key]===undefined){options[key]=defaultOptions[key];}}let s=recast__default['default'].prettyPrint(ast,defaultOptions);let new_src=s.code;new_src=new_src.replace(/\r\n|\n|\r/g,'\n')// platform dependent EOL fixup // backpatch possible jison variables extant in the prettified code: .replace(/\uFFDA/g,'@').replace(/\uFFDB/g,'#');return new_src;}// validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src,yylloc,options){// make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: -if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cnt);src=lines.join('\n')+src;}if(!src.trim()){return false;}try{var rv=parseCodeChunkToAST(src,options);return false;}catch(ex){return ex.message||"code snippet cannot be parsed";}}// The rough-and-ready preprocessor for any action code block: +if(yylloc&&yylloc.first_line>0){let cnt=yylloc.first_line;let lines=new Array(cnt);src=lines.join('\n')+src;}if(!src.trim()){return false;}try{let rv=parseCodeChunkToAST(src,options);return false;}catch(ex){return ex.message||'code snippet cannot be parsed';}}// The rough-and-ready preprocessor for any action code block: // this one trims off any surplus whitespace and removes any // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -451,7 +465,7 @@ if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cn // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -460,13 +474,13 @@ if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cn // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// -function trimActionCode(src,startMarker){var s=src.trim();// remove outermost set of braces UNLESS there's +// +function trimActionCode(src,startMarker){let s=src.trim();// remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated // code analyzer to simplify the code! @@ -498,34 +512,34 @@ s=s.replace(/^\{([^]*?)\}$/,'$1').trim();}else{// code may not be wrapped or oth // wrapping braces when we can guarantee they're the only ones there, // i.e. only exist as outer wrapping. s=s.replace(/^\{([^}]*)\}$/,'$1').trim();}s=s.replace(/;+$/,'').trim();return s;}var parse2AST={generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST,compileCodeToES5,prettyPrintAST,checkActionBlock,trimActionCode,ID_REGEX_BASE,IN_ID_CHARSET};function chkBugger$1(src){src=String(src);if(src.match(/\bcov_\w+/)){console.error('### ISTANBUL COVERAGE CODE DETECTED ###\n',src);}}/// HELPER FUNCTION: print the function in source code form, properly indented. -/** @public */function printFunctionSourceCode(f){var src=String(f);chkBugger$1(src);return src;}const funcRe=/^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/;const arrowFuncRe=/^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/;/// HELPER FUNCTION: print the function **content** in source code form, properly indented, +/** @public */function printFunctionSourceCode(f){const src=String(f);chkBugger$1(src);return src;}const funcRe=/^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/;const arrowFuncRe=/^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/;/// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// -/** @public */function printFunctionSourceCodeContainer(f){var action=printFunctionSourceCode(f).trim();var args;// Also cope with Arrow Functions (and inline those as well?). +/// +/** @public */function printFunctionSourceCodeContainer(f){let action=printFunctionSourceCode(f).trim();let args;// Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 -var m=funcRe.exec(action);if(m){args=m[1].trim();action=m[2].trim();}else{m=arrowFuncRe.exec(action);if(m){if(m[2]){// non-bracketed arguments: +let m=funcRe.exec(action);if(m){args=m[1].trim();action=m[2].trim();}else{m=arrowFuncRe.exec(action);if(m){if(m[2]){// non-bracketed arguments: args=m[2].trim();}else{// bracketed arguments: may be empty args list! args=m[1].trim();}if(m[5]){// non-bracketed version: implicit `return` statement! // -// Q: Must we make sure we have extra braces around the return value -// to prevent JavaScript from inserting implit EOS (End Of Statement) +// Q: Must we make sure we have extra braces around the return value +// to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already // have formatted the code correctly. -action=m[4].trim();action='return '+action+';';}else{action=m[3].trim();}}else{var e=new Error('Cannot extract code from function');e.subject=action;throw e;}}return{args:args,code:action};}var stringifier={printFunctionSourceCode,printFunctionSourceCodeContainer};// -// -// -function detectIstanbulGlobal(){const gcv="__coverage__";const globalvar=new Function('return this')();var coverage=globalvar[gcv];return coverage||false;}// +action=m[4].trim();action='return '+action+';';}else{action=m[3].trim();}}else{const e=new Error('Cannot extract code from function');e.subject=action;throw e;}}return{args:args,code:action};}var stringifier={printFunctionSourceCode,printFunctionSourceCodeContainer};// +// +// +function detectIstanbulGlobal(){const gcv='__coverage__';const globalvar=new Function('return this')();const coverage=globalvar[gcv];return coverage||false;}// // Helper library for safe code execution/compilation // // MIT Licensed @@ -543,7 +557,7 @@ function detectIstanbulGlobal(){const gcv="__coverage__";const globalvar=new Fun // The default assumed is the standard JavaScript `RegExp` class. // // Return FALSE when there's no failure, otherwise return an `Error` info object. -function checkRegExp(re_src,re_flags,XRegExp){var re;// were we fed a RegExp object or a string? +function checkRegExp(re_src,re_flags,XRegExp){let re;// were we fed a RegExp object or a string? if(re_src&&typeof re_src.source==='string'&&typeof re_src.flags==='string'&&typeof re_src.toString==='function'&&typeof re_src.test==='function'&&typeof re_src.exec==='function'){// we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member // and the `.toString()` method to produce something that's compileable by XRegExp // at least... @@ -557,7 +571,7 @@ if(re_src==null){return new Error('invalid regular expression source: '+re_src); // The default assumed is the standard JavaScript `RegExp` class. // // Return FALSE when the input is not a legal regex. -function getRegExpInfo(re_src,re_flags,XRegExp){var re1,re2,m1,m2;// were we fed a RegExp object or a string? +function getRegExpInfo(re_src,re_flags,XRegExp){let re1,re2,m1,m2;// were we fed a RegExp object or a string? if(re_src&&typeof re_src.source==='string'&&typeof re_src.flags==='string'&&typeof re_src.toString==='function'&&typeof re_src.test==='function'&&typeof re_src.exec==='function'){// we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member // and the `.toString()` method to produce something that's compileable by XRegExp // at least... @@ -569,33 +583,42 @@ return false;}else{re_src=''+re_src;if(re_flags==null){re_flags=undefined;// `ne // wrap it and append `(?:)` to ensure it matches // the empty string, then match it against it to // obtain the `match` array. -re1=new XRegExp(re_src,re_flags);re2=new XRegExp('(?:'+re_src+')|(?:)',re_flags);m1=re1.exec('');m2=re2.exec('');return{acceptsEmptyString:!!m1,captureCount:m2.length-1};}catch(ex){return false;}}var reHelpers={checkRegExp:checkRegExp,getRegExpInfo:getRegExpInfo};var cycleref=[];var cyclerefpath=[];var linkref=[];var linkrefpath=[];var path=[];function shallow_copy(src){if(typeof src==='object'){if(src instanceof Array){return src.slice();}var dst={};if(src instanceof Error){dst.name=src.name;dst.message=src.message;dst.stack=src.stack;}for(var k in src){if(Object.prototype.hasOwnProperty.call(src,k)){dst[k]=src[k];}}return dst;}return src;}function shallow_copy_and_strip_depth(src,parentKey){if(typeof src==='object'){var dst;if(src instanceof Array){dst=src.slice();for(var i=0,len=dst.length;i '+parentKey+'.'+k+']';}else{dst[k]=src[k];}}}}return dst;}return src;}function stripErrorStackPaths(msg){// strip away devbox-specific paths in error stack traces in the output: -msg=msg.replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi,'at $1(/$2)').replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi,'at /$1');return msg;}function trim_array_tail(arr){if(arr instanceof Array){for(var len=arr.length;len>0;len--){if(arr[len-1]!=null){break;}}arr.length=len;}}function treat_value_stack(v){if(v instanceof Array){var idx=cycleref.indexOf(v);if(idx>=0){v='[cyclic reference to parent array --> '+cyclerefpath[idx]+']';}else{idx=linkref.indexOf(v);if(idx>=0){v='[reference to sibling array --> '+linkrefpath[idx]+', length = '+v.length+']';}else{cycleref.push(v);cyclerefpath.push(path.join('.'));linkref.push(v);linkrefpath.push(path.join('.'));v=treat_error_infos_array(v);cycleref.pop();cyclerefpath.pop();}}}else if(v){v=treat_object(v);}return v;}function treat_error_infos_array(arr){var inf=arr.slice();trim_array_tail(inf);for(var key=0,len=inf.length;key '+parentKey+'.'+k+']';}else{dst[k]=src[k];}}}}return dst;}return src;}// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. +function stripErrorStackPaths(msg){// strip away devbox-specific paths in error stack traces in the output: +// and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': +msg=msg.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi,'at $1(/$2:$3)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi,'at /$1:$2');return msg;}// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj){if(typeof obj==='string'){// and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': +let msg=obj.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi,'at $1(/$2)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi,'at /$1');return msg;}if(obj){if(obj.stack){obj.stack=cleanStackTrace4Comparison(obj.stack);}let keys=Object.keys(obj);for(let i in keys){let key=keys[i];let el=obj[key];cleanStackTrace4Comparison(el);}}return obj;}function trim_array_tail(arr){if(arr instanceof Array){for(var len=arr.length;len>0;len--){if(arr[len-1]!=null){break;}}arr.length=len;}}function treat_value_stack(v){if(v instanceof Array){let idx=cycleref.indexOf(v);if(idx>=0){v='[cyclic reference to parent array --> '+cyclerefpath[idx]+']';}else{idx=linkref.indexOf(v);if(idx>=0){v='[reference to sibling array --> '+linkrefpath[idx]+', length = '+v.length+']';}else{cycleref.push(v);cyclerefpath.push(path.join('.'));linkref.push(v);linkrefpath.push(path.join('.'));v=treat_error_infos_array(v);cycleref.pop();cyclerefpath.pop();}}}else if(v){v=treat_object(v);}return v;}function treat_error_infos_array(arr){let inf=arr.slice();trim_array_tail(inf);for(let key=0,len=inf.length;key=0){// cyclic reference, most probably an error instance. +e=shallow_copy(e);if(e&&e.hash){path.push('hash');e.hash=treat_hash(e.hash);path.pop();}if(e.parser){path.push('parser');e.parser=treat_parser(e.parser);path.pop();}if(e.lexer){path.push('lexer');e.lexer=treat_lexer(e.lexer);path.pop();}if(e.__error_infos){path.push('__error_infos');e.__error_infos=treat_value_stack(e.__error_infos);path.pop();}if(e.__error_recovery_infos){path.push('__error_recovery_infos');e.__error_recovery_infos=treat_value_stack(e.__error_recovery_infos);path.pop();}trim_array_tail(e.symbol_stack);trim_array_tail(e.state_stack);trim_array_tail(e.location_stack);if(e.value_stack){path.push('value_stack');e.value_stack=treat_value_stack(e.value_stack);path.pop();}return e;}function treat_object(e){if(e&&typeof e==='object'){let idx=cycleref.indexOf(e);if(idx>=0){// cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: e=shallow_copy_and_strip_depth(e,cyclerefpath[idx]);}else{idx=linkref.indexOf(e);if(idx>=0){e='[reference to sibling --> '+linkrefpath[idx]+']';}else{cycleref.push(e);cyclerefpath.push(path.join('.'));linkref.push(e);linkrefpath.push(path.join('.'));e=treat_error_report_info(e);cycleref.pop();cyclerefpath.pop();}}}return e;}// strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. -function trimErrorForTestReporting(e){cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];if(e){e=treat_object(e);}cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];return e;}var helpers={rmCommonWS,camelCase,mkIdentifier,isLegalIdentifierInput,scanRegExp,dquote,trimErrorForTestReporting,stripErrorStackPaths,checkRegExp:reHelpers.checkRegExp,getRegExpInfo:reHelpers.getRegExpInfo,exec:code_exec.exec,dump:code_exec.dump,generateMapper4JisonGrammarIdentifiers:parse2AST.generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST:parse2AST.parseCodeChunkToAST,compileCodeToES5:parse2AST.compileCodeToES5,prettyPrintAST:parse2AST.prettyPrintAST,checkActionBlock:parse2AST.checkActionBlock,trimActionCode:parse2AST.trimActionCode,ID_REGEX_BASE:parse2AST.ID_REGEX_BASE,IN_ID_CHARSET:parse2AST.IN_ID_CHARSET,printFunctionSourceCode:stringifier.printFunctionSourceCode,printFunctionSourceCodeContainer:stringifier.printFunctionSourceCodeContainer,detectIstanbulGlobal};// See also: +function trimErrorForTestReporting(e){cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];if(e){e=treat_object(e);}cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];return e;}var helpers={rmCommonWS,camelCase,mkIdentifier,isLegalIdentifierInput,scanRegExp,dquote,trimErrorForTestReporting,stripErrorStackPaths,cleanStackTrace4Comparison,checkRegExp:reHelpers.checkRegExp,getRegExpInfo:reHelpers.getRegExpInfo,exec:exec.exec,dump:exec.dump,convertExceptionToObject:exec.convertExceptionToObject,generateMapper4JisonGrammarIdentifiers:parse2AST.generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST:parse2AST.parseCodeChunkToAST,compileCodeToES5:parse2AST.compileCodeToES5,prettyPrintAST:parse2AST.prettyPrintAST,checkActionBlock:parse2AST.checkActionBlock,trimActionCode:parse2AST.trimActionCode,ID_REGEX_BASE:parse2AST.ID_REGEX_BASE,IN_ID_CHARSET:parse2AST.IN_ID_CHARSET,printFunctionSourceCode:stringifier.printFunctionSourceCode,printFunctionSourceCodeContainer:stringifier.printFunctionSourceCodeContainer,detectIstanbulGlobal};// 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. -function JisonParserError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonParserError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8/Chrome engine +function JisonParserError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonParserError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){let ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8/Chrome engine Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonParserError.prototype,Error.prototype);}else{JisonParserError.prototype=Object.create(Error.prototype);}JisonParserError.prototype.constructor=JisonParserError;JisonParserError.prototype.name='JisonParserError';// helper: reconstruct the productions[] table -function bp(s){var rv=[];var p=s.pop;var r=s.rule;for(var i=0,l=p.length;i1){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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) +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 delimited set of lexer start conditions';break;case 37:/*! Production:: start_productions_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -yy.__options_flags__=0;yy.__options_category_description__='the lexer rules definition section';break;case 38:/*! Production:: start_epilogue_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -yy.__options_flags__=0;yy.__options_category_description__='the lexer epilogue section';break;case 39:/*! Production:: rules : rules scoped_rules_collective */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1].concat(yyvstack[yysp]);break;case 40:/*! Production:: rules : rules rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1].concat([yyvstack[yysp]]);break;case 41:/*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 30:/*! Production:: option_keyword : OPTIONS */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__=yyvstack[yysp];break;case 31:/*! Production:: import_keyword : IMPORT */case 33:/*! Production:: include_keyword : INCLUDE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS;yy.__options_category_description__=yyvstack[yysp];break;case 32:/*! Production:: init_code_keyword : CODE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS|OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS;yy.__options_category_description__=yyvstack[yysp];break;case 34:/*! Production:: start_inclusive_keyword : START_INC */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__='the inclusive lexer start conditions set (%s)';break;case 35:/*! Production:: start_exclusive_keyword : START_EXC */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__='the exclusive lexer start conditions set (%x)';break;case 36:/*! Production:: start_conditions_marker : "<" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES|OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME;yy.__options_category_description__='the <...> delimited set of lexer start conditions';break;case 37:/*! Production:: start_productions_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=0;yy.__options_category_description__='the lexer rules definition section';break;case 38:/*! Production:: start_epilogue_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=0;yy.__options_category_description__='the lexer epilogue section';break;case 39:/*! Production:: rules : rules scoped_rules_collective */ // 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].concat(yyvstack[yysp]);break;case 40:/*! Production:: rules : rules rule */ // 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].concat([yyvstack[yysp]]);break;case 41:/*! Production:: rules : rules 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]);if(srcCode){var rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);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);}this.$=yyvstack[yysp-3];break;case 42:/*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);}yy.actionInclude.push(srcCode);}this.$=yyvstack[yysp-3];break;case 42:/*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. -this.$=yyvstack[yysp-1];break;case 43:/*! Production:: rules : rules ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) +this.$=yyvstack[yysp-1];break;case 43:/*! Production:: rules : rules ACTION_START_AT_SOL 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,-,-) 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. @@ -1039,8 +1062,8 @@ var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or simila Technical error report: ${yyvstack[yysp].errStr} - `);this.$=yyvstack[yysp-2];break;case 44:/*! Production:: rules : rules ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);this.$=yyvstack[yysp-2];break;case 44:/*! Production:: rules : rules 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,-,-) 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: @@ -1068,8 +1091,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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 the top section of the lexer spec file, above the first '%%' @@ -1078,14 +1101,14 @@ yyparser.yyError(rmCommonWS$1` Erroneous code: ${yylexer.prettyPrintRange(yylstack[yysp])} - `);this.$=yyvstack[yysp-1];break;case 51:/*! Production:: rules : %epsilon */case 58:/*! Production:: rule_block : %epsilon */ // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) -this.$=[];break;case 52:/*! Production:: scoped_rules_collective : start_conditions rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -if(yyvstack[yysp-1]){yyvstack[yysp].unshift(yyvstack[yysp-1]);}this.$=[yyvstack[yysp]];break;case 53:/*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) -if(yyvstack[yysp-3]){yyvstack[yysp-1].forEach(function(d){d.unshift(yyvstack[yysp-3]);});}this.$=yyvstack[yysp-1];break;case 54:/*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp-3];this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + `);this.$=yyvstack[yysp-1];break;case 51:/*! Production:: rules : %epsilon */case 58:/*! Production:: rule_block : %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 52:/*! Production:: scoped_rules_collective : start_conditions rule */ // 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,-,-) +if(yyvstack[yysp-1]){yyvstack[yysp].unshift(yyvstack[yysp-1]);}this.$=[yyvstack[yysp]];break;case 53:/*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ // 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,-,-) +if(yyvstack[yysp-3]){yyvstack[yysp-1].forEach(function(d){d.unshift(yyvstack[yysp-3]);});}this.$=yyvstack[yysp-1];break;case 54:/*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): +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$1` Seems you made a mistake while specifying one of the lexer rules inside the start condition @@ -1097,8 +1120,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp-1].errStr} - `);break;case 55:/*! Production:: scoped_rules_collective : start_conditions "{" error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 55:/*! Production:: scoped_rules_collective : start_conditions "{" 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,-,-) yyparser.yyError(rmCommonWS$1` Seems you did not correctly bracket a lexer rules set inside the start condition @@ -1110,8 +1133,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 56:/*! Production:: scoped_rules_collective : start_conditions error "}" */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 56:/*! Production:: scoped_rules_collective : start_conditions 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,-,-) yyparser.yyError(rmCommonWS$1` Seems you did not correctly bracket a lexer rules set inside the start condition @@ -1123,17 +1146,17 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp-1].errStr} - `);break;case 57:/*! Production:: rule_block : rule_block rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 57:/*! Production:: rule_block : rule_block rule */ // 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.$.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` 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 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 // will uncover any illegal action code following the arrow operator, e.g. // multiple statements separated by semicolon. @@ -1154,8 +1177,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 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.: @@ -1170,8 +1193,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 63:/*! Production:: rule : regex ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);break;case 63:/*! Production:: rule : regex 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,-,-) // TODO: REWRITE this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` A lexer rule regex action code must be properly terminated and must contain a JavaScript statement block (or anything that does parse as such), e.g.: @@ -1188,8 +1211,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 64:/*! Production:: rule : regex ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);break;case 64:/*! Production:: rule : regex ACTION_START_AT_SOL 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,-,-) // TODO: REWRITE this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` A lexer rule regex action code must be properly terminated and must contain a JavaScript statement block (or anything that does parse as such), e.g.: @@ -1225,8 +1248,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 65:/*! Production:: rule : regex error */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);break;case 65:/*! Production:: rule : regex 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,-,-) this.$=[yyvstack[yysp-1],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Lexer rule regex action code declaration error? @@ -1235,33 +1258,33 @@ this.$=[yyvstack[yysp-1],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 66:/*! Production:: action : action ACTION_BODY */case 83:/*! Production:: regex_concat : regex_concat regex_base */case 95:/*! Production:: regex_base : regex_base range_regex */case 106:/*! Production:: regex_set : regex_set regex_set_atom */case 127:/*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+yyvstack[yysp];break;case 67:/*! Production:: action : action include_macro_code */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'\n\n'+yyvstack[yysp]+'\n\n';break;case 68:/*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 66:/*! Production:: action : action ACTION_BODY */case 83:/*! Production:: regex_concat : regex_concat regex_base */case 95:/*! Production:: regex_base : regex_base range_regex */case 106:/*! Production:: regex_set : regex_set regex_set_atom */case 127:/*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ // 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]+yyvstack[yysp];break;case 67:/*! Production:: action : action 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]+'\n\n'+yyvstack[yysp]+'\n\n';break;case 68:/*! Production:: action : action INCLUDE_PLACEMENT_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` You may place the '%include' instruction only at the start/front of a line. Its use is not permitted at this position: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 69:/*! Production:: action : action BRACKET_MISSING */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 69:/*! Production:: action : action BRACKET_MISSING */ // 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` Missing curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: '{ ... }'. Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 70:/*! Production:: action : action BRACKET_SURPLUS */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 70:/*! Production:: action : action BRACKET_SURPLUS */ // 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` Too many curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: '{ ... }'. Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 71:/*! Production:: action : action UNTERMINATED_STRING_ERROR */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 71:/*! Production:: action : action UNTERMINATED_STRING_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` Unterminated string constant in lexer rule action block. @@ -1270,10 +1293,10 @@ yyparser.yyError(rmCommonWS$1` Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 72:/*! Production:: action : %epsilon */case 77:/*! Production:: regex_list : %epsilon */ // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0,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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 72:/*! Production:: action : %epsilon */case 77:/*! Production:: regex_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 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 // accordingly: @@ -1294,8 +1317,8 @@ 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,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,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` Seems you did not correctly terminate the start condition set @@ -1307,8 +1330,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -1347,22 +1370,22 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+'|'+yyvstack[yysp];break;case 79:/*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'|';break;case 80:/*! Production:: nonempty_regex_list : "|" regex_concat */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='|'+yyvstack[yysp];break;case 81:/*! Production:: nonempty_regex_list : "|" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='|';break;case 85:/*! Production:: regex_base : "(" regex_list ")" */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$='('+yyvstack[yysp-1]+')';break;case 86:/*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+')';break;case 87:/*! Production:: regex_base : "(" regex_list error */case 88:/*! Production:: regex_base : SPECIAL_GROUP regex_list error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) +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,-,-): +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,-,-) +this.$=yyvstack[yysp-2]+'|'+yyvstack[yysp];break;case 79:/*! Production:: nonempty_regex_list : nonempty_regex_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,-,-) +this.$=yyvstack[yysp-1]+'|';break;case 80:/*! Production:: nonempty_regex_list : "|" regex_concat */ // 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];break;case 81:/*! Production:: 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,-,-) +this.$='|';break;case 85:/*! Production:: regex_base : "(" regex_list ")" */ // 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-1]+')';break;case 86:/*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ // 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-1]+')';break;case 87:/*! Production:: regex_base : "(" regex_list error */case 88:/*! Production:: regex_base : SPECIAL_GROUP regex_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,-,-) yyparser.yyError(rmCommonWS$1` Seems you did not correctly bracket a lex rule regex part in '(...)' braces. @@ -1371,30 +1394,30 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 89:/*! Production:: regex_base : regex_base "+" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'+';break;case 90:/*! Production:: regex_base : regex_base "*" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'*';break;case 91:/*! Production:: regex_base : regex_base "?" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'?';break;case 92:/*! Production:: regex_base : "/" regex_base */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='(?='+yyvstack[yysp]+')';break;case 93:/*! Production:: regex_base : "/!" regex_base */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='(?!'+yyvstack[yysp]+')';break;case 94:/*! Production:: regex_base : name_expansion */case 96:/*! Production:: regex_base : any_group_regex */case 100:/*! Production:: regex_base : REGEX_SPECIAL_CHAR */case 101:/*! Production:: regex_base : literal_string */case 107:/*! Production:: regex_set : regex_set_atom */case 108:/*! Production:: regex_set_atom : REGEX_SET */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -break;case 97:/*! Production:: regex_base : "." */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='.';break;case 98:/*! Production:: regex_base : "^" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='^';break;case 99:/*! Production:: regex_base : "$" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='$';break;case 102:/*! Production:: regex_base : ESCAPED_CHAR */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp]));break;case 104:/*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+yyvstack[yysp];break;case 105:/*! Production:: any_group_regex : REGEX_SET_START regex_set error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 89:/*! Production:: regex_base : regex_base "+" */ // 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]+'+';break;case 90:/*! Production:: regex_base : regex_base "*" */ // 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]+'*';break;case 91:/*! Production:: regex_base : regex_base "?" */ // 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]+'?';break;case 92:/*! Production:: regex_base : "/" regex_base */ // 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]+')';break;case 93:/*! Production:: regex_base : "/!" regex_base */ // 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]+')';break;case 94:/*! Production:: regex_base : name_expansion */case 96:/*! Production:: regex_base : any_group_regex */case 100:/*! Production:: regex_base : REGEX_SPECIAL_CHAR */case 101:/*! Production:: regex_base : literal_string */case 107:/*! Production:: regex_set : regex_set_atom */case 108:/*! Production:: regex_set_atom : REGEX_SET */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +break;case 97:/*! Production:: regex_base : "." */ // 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.$='.';break;case 98:/*! Production:: regex_base : "^" */ // 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.$='^';break;case 99:/*! Production:: regex_base : "$" */ // 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.$='$';break;case 102:/*! Production:: regex_base : ESCAPED_CHAR */ // 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.$=encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp]));break;case 104:/*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_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,-,-) +this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+yyvstack[yysp];break;case 105:/*! Production:: any_group_regex : REGEX_SET_START regex_set 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,-,-) yyparser.yyError(rmCommonWS$1` Seems you did not correctly bracket a lex rule regex set in '[...]' brackets. @@ -1403,16 +1426,16 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 109:/*! Production:: regex_set_atom : name_expansion */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + `);break;case 109:/*! Production:: regex_set_atom : name_expansion */ // 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,-,-) if(XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g,''))&&yyvstack[yysp].toUpperCase()!==yyvstack[yysp]){// treat this as part of an XRegExp `\p{...}` Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) +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,-,-): +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,-,-): +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` You may only specify one name/argument in a ${yy.__options_category_description__} statement. @@ -1427,28 +1450,28 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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` You may only specify one name/argument in a ${yy.__options_category_description__} statement. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp]),yylstack[yysp-3])} - `);}this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 115:/*! Production:: option_list : option */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=[yyvstack[yysp]];break;case 116:/*! Production:: option : option_name */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=[yyvstack[yysp],true];break;case 117:/*! Production:: option : option_name "=" option_value */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);}this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 115:/*! Production:: option_list : option */ // 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 116:/*! Production:: option : 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,-,-) +this.$=[yyvstack[yysp],true];break;case 117:/*! Production:: option : option_name "=" option_value */ // 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_VALUE){yyparser.yyError(rmCommonWS$1` The entries in a ${yy.__options_category_description__} statement MUST NOT be assigned values, such as '${$option_name}=${$option_value}'. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp],yylstack[yysp-2]),yylstack[yysp-4])} - `);}this.$=[yyvstack[yysp-2],yyvstack[yysp]];break;case 118:/*! Production:: option : option_name "=" error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);}this.$=[yyvstack[yysp-2],yyvstack[yysp]];break;case 118:/*! Production:: option : option_name "=" 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$1` Internal error: option "${$option}" value assignment failure in a ${yy.__options_category_description__} statement. @@ -1458,8 +1481,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 119:/*! Production:: option : DUMMY3 error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);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` Expected a valid option name${with_value_msg} in a ${yy.__options_category_description__} statement. @@ -1468,8 +1491,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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: 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 @@ -1483,8 +1506,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. @@ -1494,21 +1517,21 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=parseValue(yyvstack[yysp]);break;case 124:/*! Production:: epilogue : start_epilogue_marker */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,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,-,-) +this.$=parseValue(yyvstack[yysp]);break;case 124:/*! Production:: epilogue : start_epilogue_marker */ // 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.$='';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` 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,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,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. @@ -1517,8 +1540,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 128:/*! Production:: epilogue_chunks : epilogue_chunks error */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);break;case 128:/*! Production:: epilogue_chunks : epilogue_chunks 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$1` Module code declaration error? @@ -1528,8 +1551,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);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` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -1538,8 +1561,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -1548,12 +1571,12 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,LU,LUbA): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA) +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`: path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$1` @@ -1580,8 +1603,8 @@ var fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});var 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,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,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. @@ -1591,14 +1614,14 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} `);break;}},table:bt({len:u([15,1,14,21,1,13,28,22,s,[9,3],13,1,9,13,c,[6,3],27,s,[31,5],1,44,4,1,13,6,25,24,25,23,23,17,17,s,[24,8],26,5,24,24,9,13,8,9,1,s,[9,5],13,9,13,c,[3,3],c,[13,3],2,1,26,26,9,26,c,[5,3],s,[26,4],7,24,4,5,8,c,[60,3],c,[59,3],s,[24,5],2,3,2,25,25,6,s,[4,3],13,7,8,4,8,13,13,s,[7,6],9,5,s,[13,3],9,1,13,9,26,26,6,1,5,9,5,5,26,17,c,[85,4],27,10,s,[24,7],4,s,[8,3],9,7,9,1,1,26,5,c,[30,3],23,27,26,9,27,9,27,9,27,1,16,7,1,13,13,5,26,15,26,s,[27,3],16,13]),symbol:u([1,2,19,22,s,[24,6,1],31,32,33,55,57,1,c,[16,13],58,c,[14,13],56,s,[59,4,1],64,65,67,c,[36,14],1,2,3,7,8,s,[13,4,1],c,[19,10],s,[40,6,1],49,50,69,2,c,[26,6],c,[16,8],75,s,[77,5,1],85,2,11,51,52,53,s,[86,4,1],c,[9,10],23,30,s,[35,5,1],73,c,[90,13],2,c,[32,9],c,[23,14],c,[63,17],c,[144,40],c,[27,5],11,c,[28,22],c,[75,3],c,[31,125],1,c,[182,25],c,[373,5],s,[66,5,2],c,[320,7],90,1,33,68,90,20,c,[276,14],7,20,22,25,34,c,[367,3],9,c,[68,4],c,[12,4],c,[62,8],c,[370,6],c,[25,19],c,[24,8],s,[10,7,1],c,[27,10],48,49,50,84,c,[49,8],c,[45,8],s,[76,6,1],c,[72,9],c,[23,15],c,[485,13],c,[17,21],c,[105,24],c,[24,189],s,[46,5,1],44,47,80,82,83,c,[79,48],11,17,21,c,[500,3],c,[729,18],17,21,25,c,[24,3],c,[8,3],18,c,[9,6],c,[10,10],c,[9,26],c,[76,22],c,[849,7],63,93,c,[796,15],c,[13,11],c,[57,22],c,[22,9],21,11,17,c,[95,4],c,[10,4],25,c,[670,27],c,[26,26],c,[981,10],c,[35,26],c,[88,52],c,[26,105],2,22,24,54,91,92,2,4,c,[1221,14],72,c,[1222,8],c,[465,3],c,[35,5],c,[1158,8],c,[8,4],c,[1307,14],c,[912,78],c,[760,117],9,2,7,9,c,[5,4],c,[152,47],84,2,44,46,47,80,83,c,[6,4],c,[4,8],c,[614,14],c,[602,6],c,[754,9],52,53,c,[12,9],c,[689,26],c,[592,7],c,[7,35],c,[1571,14],c,[82,26],c,[430,14],c,[688,8],2,c,[842,23],c,[580,56],92,c,[534,3],c,[7,3],c,[1765,11],c,[14,3],c,[5,6],c,[794,26],5,c,[630,14],71,5,c,[159,10],c,[9,17],s,[1,4,2],c,[72,24],c,[976,9],c,[628,48],c,[24,121],c,[560,4],c,[1290,10],c,[8,13],c,[205,9],c,[495,14],63,93,21,21,c,[388,31],c,[5,5],c,[1301,11],c,[14,3],c,[354,15],c,[984,8],c,[333,27],c,[100,26],c,[549,11],c,[62,25],c,[36,72],6,c,[1170,16],c,[53,7],21,c,[744,28],c,[621,29],c,[266,15],c,[745,28],c,[284,27],c,[27,52],c,[203,16],c,[182,13]]),type:u([s,[2,13],0,0,1,c,[16,14],c,[30,15],s,[0,6],s,[2,41],c,[42,16],c,[64,12],c,[9,18],c,[49,19],c,[32,16],c,[22,19],c,[145,45],s,[2,181],s,[0,18],c,[20,4],c,[62,45],c,[25,24],c,[441,40],c,[442,13],c,[23,31],c,[17,34],c,[416,210],c,[57,111],c,[76,42],c,[98,34],c,[57,22],c,[22,10],c,[165,66],c,[509,189],c,[756,25],c,[740,56],c,[912,70],c,[286,136],c,[25,29],c,[275,31],c,[240,14],c,[227,82],c,[1144,56],c,[53,22],c,[775,59],c,[58,15],c,[149,63],c,[1837,18],c,[81,35],c,[628,51],c,[1393,171],c,[197,47],c,[268,26],c,[272,64],c,[62,36],c,[36,72],s,[2,226]]),state:u([s,[1,5,1],13,15,16,8,9,6,s,[25,4,2],32,37,38,43,49,51,52,54,58,c,[4,3],60,63,c,[5,3],65,c,[4,3],67,c,[4,3],77,79,80,75,76,85,81,70,71,82,83,c,[38,6],69,81,87,90,c,[8,4],91,c,[4,3],95,97,98,c,[20,5],99,c,[7,6],100,c,[4,3],101,c,[4,3],105,102,103,108,52,54,c,[3,3],119,114,c,[8,6],c,[3,3],127,130,132,136,c,[66,7],143,c,[87,3],144,c,[67,9],95,95,105,151,152,52,54,153,155,c,[22,3],157,119,114,161,163,165,168,170,172,c,[49,3],c,[29,4],c,[67,5],119,114,182,c,[57,7],c,[12,4],119,114]),mode:u([s,[2,27],s,[1,13],c,[27,15],c,[53,38],c,[66,27],c,[46,12],c,[65,23],s,[2,197],c,[271,26],c,[340,23],c,[25,4],c,[27,6],c,[264,10],c,[20,20],c,[12,5],c,[66,18],c,[89,5],c,[102,14],s,[1,38],s,[2,218],c,[220,50],c,[274,30],c,[25,6],c,[85,37],c,[736,26],c,[52,52],c,[427,61],c,[54,34],c,[515,158],c,[696,29],c,[1120,25],c,[845,62],c,[689,122],c,[1055,8],c,[151,24],c,[24,20],c,[539,29],c,[29,12],c,[1006,79],c,[660,49],c,[45,8],c,[793,47],c,[131,31],c,[439,50],c,[44,16],c,[125,9],c,[161,22],c,[663,28],c,[599,24],c,[1703,174],c,[875,16],c,[920,43],c,[1192,22],c,[260,51],c,[123,34],c,[34,69],c,[1284,181],s,[2,51]]),goto:u([s,[7,13],s,[9,13],6,17,7,10,11,12,14,21,22,23,19,20,18,24,s,[8,13],51,26,s,[51,25],28,30,33,35,39,40,41,34,36,42,s,[44,5,1],50,55,53,56,57,59,c,[5,4],61,s,[72,7],s,[17,13],62,64,c,[27,4],s,[22,13],66,c,[18,4],68,c,[5,4],s,[29,13],s,[37,27],s,[34,31],s,[35,31],s,[30,31],s,[31,31],s,[32,31],1,4,86,c,[272,6],72,73,74,78,c,[330,5],84,c,[282,8],5,84,88,s,[11,13],75,89,s,[75,4],81,81,33,81,c,[48,4],s,[81,4],c,[42,8],82,82,33,82,c,[20,4],s,[82,4],c,[20,8],s,[84,4],92,93,94,s,[84,14],96,84,84,77,30,33,77,c,[384,12],c,[16,16],c,[413,13],c,[13,13],s,[94,24],s,[96,24],s,[97,24],s,[98,24],s,[99,24],s,[100,24],s,[101,24],s,[102,24],s,[103,26],45,104,s,[111,24],s,[112,24],55,107,106,c,[640,3],s,[13,13],s,[115,8],s,[116,3],109,s,[116,5],110,s,[120,9],s,[121,9],s,[122,9],s,[123,9],55,107,111,c,[73,3],s,[15,13],112,120,113,s,[115,4,1],s,[18,13],s,[19,13],55,107,121,c,[52,3],s,[21,13],55,107,122,c,[19,3],c,[78,3],124,c,[7,3],126,125,2,s,[39,26],s,[40,26],128,s,[72,7],s,[42,26],129,s,[45,26],s,[46,26],s,[47,26],s,[48,26],s,[49,26],s,[50,26],124,131,133,134,135,138,137,c,[1118,14],142,140,139,141,s,[38,5],c,[1071,4],s,[36,4],3,s,[10,13],79,79,33,79,c,[47,4],s,[79,4],c,[51,8],80,80,33,80,c,[20,4],s,[80,4],c,[20,8],s,[83,4],c,[845,3],s,[83,14],96,83,83,s,[89,24],s,[90,24],s,[91,24],s,[95,24],s,[110,24],146,145,76,89,76,148,147,s,[92,5],93,94,s,[92,14],96,c,[19,3],s,[93,3],c,[24,3],s,[93,14],96,93,93,150,45,149,104,s,[107,4],s,[108,4],s,[109,4],s,[12,13],c,[290,4],s,[114,8],154,56,57,s,[119,8],s,[14,13],s,[16,13],s,[66,7],s,[67,7],s,[68,7],s,[69,7],s,[70,7],s,[71,7],156,c,[92,4],s,[33,5],s,[20,13],s,[23,13],s,[24,13],158,s,[72,7],159,s,[28,13],160,c,[793,6],s,[43,26],s,[44,26],125,162,c,[541,3],126,s,[129,5],164,s,[72,7],s,[132,5],s,[133,5],s,[52,26],166,s,[58,15],167,169,s,[72,7],171,s,[72,7],173,s,[72,7],s,[65,27],175,55,107,174,c,[255,3],78,78,33,78,c,[599,4],s,[78,4],c,[599,8],s,[85,24],s,[87,24],s,[86,24],s,[88,24],s,[104,24],s,[105,24],s,[106,4],s,[113,8],s,[117,8],s,[118,8],55,107,176,c,[198,3],s,[135,7],177,c,[394,6],178,179,s,[41,26],s,[127,5],s,[128,5],180,c,[45,6],s,[131,5],181,c,[927,14],55,55,183,s,[55,24],s,[56,26],184,c,[80,6],s,[63,27],185,c,[34,6],s,[64,27],186,c,[34,6],s,[62,27],187,s,[74,16],s,[134,7],188,s,[26,13],s,[27,13],s,[130,5],s,[53,26],s,[57,15],s,[54,26],s,[59,27],s,[60,27],s,[61,27],s,[73,16],s,[25,13]])}),defaultActions:bda({idx:u([0,2,5,11,14,s,[17,8,1],28,s,[37,9,1],47,48,50,51,s,[54,4,1],59,61,62,64,69,70,71,73,s,[75,6,1],84,86,87,88,s,[92,5,1],s,[103,4,1],108,s,[110,9,1],s,[120,4,1],126,128,129,131,132,134,135,136,142,s,[145,10,1],156,160,161,162,164,s,[167,5,2],176,s,[178,11,1]]),goto:u([7,9,8,17,22,29,37,34,35,30,31,32,1,11,94,s,[96,8,1],111,112,13,115,s,[120,4,1],15,18,19,21,2,39,40,42,s,[45,6,1],38,36,3,10,89,90,91,95,110,107,108,109,12,114,119,14,16,s,[66,6,1],33,20,23,24,28,43,44,126,129,132,133,52,65,85,87,86,88,104,105,106,113,117,118,135,41,127,128,131,56,63,64,62,74,134,26,27,130,53,57,54,59,60,61,73,25])}),parseError:function parseError(str,hash,ExceptionClass){if(hash.recoverable){if(typeof this.trace==='function'){this.trace(str);}hash.destroy();// destroy... well, *almost*! -}else{if(typeof this.trace==='function'){this.trace(str);}if(!ExceptionClass){ExceptionClass=this.JisonParserError;}throw new ExceptionClass(str,hash);}},parse:function parse(input){var self=this;var stack=new Array(128);// token stack: stores token which leads to state at the same index (column storage) -var sstack=new Array(128);// state stack: stores states (column storage) -var vstack=new Array(128);// semantic value stack -var lstack=new Array(128);// location stack -var table=this.table;var sp=0;// 'stack pointer': index into the stacks -var yyloc;var symbol=0;var preErrorSymbol=0;var lastEofErrorStateDepth=Infinity;var recoveringErrorInfo=null;var recovering=0;// (only used when the grammar contains error recovery rules) -var TERROR=this.TERROR;var EOF=this.EOF;var ERROR_RECOVERY_TOKEN_DISCARD_COUNT=this.options.errorRecoveryTokenDiscardCount|0||3;var NO_ACTION=[0,189/* === table.length :: ensures that anyone using this new state will fail dramatically! */];var lexer;if(this.__lexer__){lexer=this.__lexer__;}else{lexer=this.__lexer__=Object.create(this.lexer);}var sharedState_yy={parseError:undefined,quoteName:undefined,lexer:undefined,parser:undefined,pre_parse:undefined,post_parse:undefined,pre_lex:undefined,post_lex:undefined// WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! -};var ASSERT;if(typeof assert!=='function'){ASSERT=function JisonAssert(cond,msg){if(!cond){throw new Error('assertion failed: '+(msg||'***'));}};}else{ASSERT=assert;}this.yyGetSharedState=function yyGetSharedState(){return sharedState_yy;};this.yyGetErrorInfoTrack=function yyGetErrorInfoTrack(){return recoveringErrorInfo;};// shallow clone objects & arrays, straight copy of simple `src` values +}else{if(typeof this.trace==='function'){this.trace(str);}if(!ExceptionClass){ExceptionClass=this.JisonParserError;}throw new ExceptionClass(str,hash);}},parse:function parse(input){let self=this;let stack=new Array(128);// token stack: stores token which leads to state at the same index (column storage) +let sstack=new Array(128);// state stack: stores states (column storage) +let vstack=new Array(128);// semantic value stack +let lstack=new Array(128);// location stack +let table=this.table;let sp=0;// 'stack pointer': index into the stacks +let yyloc;let symbol=0;let preErrorSymbol=0;let lastEofErrorStateDepth=Infinity;let recoveringErrorInfo=null;let recovering=0;// (only used when the grammar contains error recovery rules) +const TERROR=this.TERROR;const EOF=this.EOF;const ERROR_RECOVERY_TOKEN_DISCARD_COUNT=this.options.errorRecoveryTokenDiscardCount|0||3;const NO_ACTION=[0,189/* === table.length :: ensures that anyone using this new state will fail dramatically! */];let lexer;if(this.__lexer__){lexer=this.__lexer__;}else{lexer=this.__lexer__=Object.create(this.lexer);}let sharedState_yy={parseError:undefined,quoteName:undefined,lexer:undefined,parser:undefined,pre_parse:undefined,post_parse:undefined,pre_lex:undefined,post_lex:undefined// WARNING: must be written this way for the code expanders to work correctly! +};const ASSERT=typeof assert!=='function'?function JisonAssert(cond,msg){if(!cond){throw new Error('assertion failed: '+(msg||'***'));}}:assert;this.yyGetSharedState=function yyGetSharedState(){return sharedState_yy;};this.yyGetErrorInfoTrack=function yyGetErrorInfoTrack(){return recoveringErrorInfo;};// shallow clone objects & arrays, straight copy of simple `src` values // e.g. `lexer.yytext` MAY be a complex value object, // rather than a simple string/value. // @@ -1609,14 +1632,13 @@ var TERROR=this.TERROR;var EOF=this.EOF;var ERROR_RECOVERY_TOKEN_DISCARD_COUNT=t // function shallow_copy(src){if(src&&typeof src==='object'){// non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: -if(src.constructor!==Object){if(Array.isArray(src)){return src.slice();}var dst=new src.constructor(src);// and make sure all custom attributes are added to the clone: +if(src.constructor!==Object){if(Array.isArray(src)){return src.slice();}let dst=new src.constructor(src);// and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst,src);return dst;}// native objects must be cloned a different way: -// -//return Object.assign({}, src); -var dst={};shallow_copy_noclobber(dst,src);return dst;}return src;}// add elements from `src` to `dst` when: +{//return Object.assign({}, src); +let dst={};shallow_copy_noclobber(dst,src);return dst;}}return src;}// add elements from `src` to `dst` when: // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` -function shallow_copy_noclobber(dst,src){const chk=Object.prototype.hasOwnProperty;for(var k in src){if(!(k in dst)){if(chk.call(src,k)){dst[k]=src[k];}}else{if(src[k]!=null&&dst[k]==null&&chk.call(src,k)){dst[k]=src[k];}}}}function copy_yylloc_native(loc){var rv=shallow_copy(loc);// shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: +function shallow_copy_noclobber(dst,src){const chk=Object.prototype.hasOwnProperty;for(let k in src){if(!(k in dst)){if(chk.call(src,k)){dst[k]=src[k];}}else if(src[k]!=null&&dst[k]==null&&chk.call(src,k)){dst[k]=src[k];}}}function copy_yylloc_native(loc){let rv=shallow_copy(loc);// shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if(rv){rv.range=rv.range.slice();}return rv;}// copy state shallow_copy_noclobber(sharedState_yy,this.yy);sharedState_yy.lexer=lexer;sharedState_yy.parser=this;// allow userland code to override the yytext and yylloc copy/clone functions: this.copy_yytext=this.options.copy_yytext||sharedState_yy.copy_yytext||shallow_copy;this.copy_yylloc=this.options.copy_yylloc||sharedState_yy.copy_yylloc||copy_yylloc_native;// *Always* setup `yyError`, `YYRECOVERING`, `yyErrOk` and `yyClearIn` functions as it is paramount @@ -1625,10 +1647,10 @@ this.copy_yytext=this.options.copy_yytext||sharedState_yy.copy_yytext||shallow_c // these functions are invoked in the user action code block(s) as // their closure will still refer to the `parse()` instance which set // them up. Hence we MUST set them up at the start of every `parse()` run! -if(this.yyError){this.yyError=function yyError(str/*, ...args */){var error_rule_depth=this.options.parserErrorsAreRecoverable?locateNearestErrorRecoveryRule(state):-1;var expected=this.collect_expected_token_set(state);var hash=this.constructParseErrorInfo(str,null,expected,error_rule_depth>=0);// append to the old one? -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; +if(this.yyError){this.yyError=function yyError(str/*, ...args */){let error_rule_depth=this.options.parserErrorsAreRecoverable?locateNearestErrorRecoveryRule(state):-1;let expected=this.collect_expected_token_set(state);let hash=this.constructParseErrorInfo(str,null,expected,error_rule_depth>=0);// append to the old one? +if(recoveringErrorInfo){let esp=recoveringErrorInfo.info_stack_pointer;recoveringErrorInfo.symbol_stack[esp]=symbol;let 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;recoveringErrorInfo.info_stack_pointer=esp;}else{recoveringErrorInfo=this.shallowCopyErrorInfo(hash);recoveringErrorInfo.yyError=true;recoveringErrorInfo.errorRuleDepth=error_rule_depth;recoveringErrorInfo.recovering=recovering;}// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){hash.extra_error_attributes=args;}return this.parseError(str,hash,this.JisonParserError);};}// Does the shared state override the default `parseError` that already comes with this instance? +let args=Array.prototype.slice.call(arguments,1);if(args.length){hash.extra_error_attributes=args;}return this.parseError(str,hash,this.JisonParserError);};}// Does the shared state override the default `parseError` that already comes with this instance? if(typeof sharedState_yy.parseError==='function'){this.parseError=function parseErrorAlt(str,hash,ExceptionClass){if(!ExceptionClass){ExceptionClass=this.JisonParserError;}return sharedState_yy.parseError.call(this,str,hash,ExceptionClass);};}else{this.parseError=this.originalParseError;}// Does the shared state override the default `quoteName` that already comes with this instance? if(typeof sharedState_yy.quoteName==='function'){this.quoteName=function quoteNameAlt(id_str){return sharedState_yy.quoteName.call(this,id_str);};}else{this.quoteName=this.originalQuoteName;}// set up the cleanup function; make it an API so that external code can re-use this one in case of // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which @@ -1636,7 +1658,7 @@ if(typeof sharedState_yy.quoteName==='function'){this.quoteName=function quoteNa // // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! -this.cleanupAfterParse=function parser_cleanupAfterParse(resultValue,invoke_post_methods,do_not_nuke_errorinfos){var rv;if(invoke_post_methods){var hash;if(sharedState_yy.post_parse||this.post_parse){// create an error hash info instance: we re-use this API in a **non-error situation** +this.cleanupAfterParse=function parser_cleanupAfterParse(resultValue,invoke_post_methods,do_not_nuke_errorinfos){let rv;if(invoke_post_methods){let hash;if(sharedState_yy.post_parse||this.post_parse){// create an error hash info instance: we re-use this API in a **non-error situation** // as this one delivers all parser internals ready for access by userland code. hash=this.constructParseErrorInfo(null/* no error! */,null/* no exception! */,null,false);}if(sharedState_yy.post_parse){rv=sharedState_yy.post_parse.call(this,sharedState_yy,resultValue,hash);if(typeof rv!=='undefined')resultValue=rv;}if(this.post_parse){rv=this.post_parse.call(this,sharedState_yy,resultValue,hash);if(typeof rv!=='undefined')resultValue=rv;}// cleanup: if(hash&&hash.destroy){hash.destroy();}}if(this.__reentrant_call_depth>1)return resultValue;// do not (yet) kill the sharedState when this is a reentrant run. @@ -1648,7 +1670,7 @@ stack.length=0;// fastest way to nuke an array without overly bothering the GC sstack.length=0;lstack.length=0;vstack.length=0;sp=0;// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;for(var i=this.__error_recovery_infos.length-1;i>=0;i--){var el=this.__error_recovery_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_recovery_infos.length=0;// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array, +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;for(let i=this.__error_recovery_infos.length-1;i>=0;i--){let el=this.__error_recovery_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_recovery_infos.length=0;// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array, // hence has been destroyed already: no need to do that *twice*. if(recoveringErrorInfo){recoveringErrorInfo=undefined;}}return resultValue;};// merge yylloc info into a new yylloc instance. // @@ -1662,32 +1684,38 @@ if(recoveringErrorInfo){recoveringErrorInfo=undefined;}}return resultValue;};// // yylloc info. // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. -this.yyMergeLocationInfo=function parser_yyMergeLocationInfo(first_index,last_index,first_yylloc,last_yylloc,dont_look_back){var i1=first_index|0,i2=last_index|0;var l1=first_yylloc,l2=last_yylloc;var rv;// rules: +this.yyMergeLocationInfo=function parser_yyMergeLocationInfo(first_index,last_index,first_yylloc,last_yylloc,dont_look_back){let i1=first_index|0;let i2=last_index|0;let l1=first_yylloc;let l2=last_yylloc;let rv;// rules: // - first/last yylloc entries override first/last indexes -if(!l1){if(first_index!=null){for(var i=i1;i<=i2;i++){l1=lstack[i];if(l1){break;}}}}if(!l2){if(last_index!=null){for(var i=i2;i>=i1;i--){l2=lstack[i];if(l2){break;}}}}// - detect if an epsilon rule is being processed and act accordingly: +if(!l1){if(first_index!=null){for(let i=i1;i<=i2;i++){l1=lstack[i];if(l1){break;}}}}if(!l2){if(last_index!=null){for(let i=i2;i>=i1;i--){l2=lstack[i];if(l2){break;}}}}// - detect if an epsilon rule is being processed and act accordingly: if(!l1&&first_index==null){// epsilon rule span merger. With optional look-ahead in l2. -if(!dont_look_back){for(var i=(i1||sp)-1;i>=0;i--){l1=lstack[i];if(l1){break;}}}if(!l1){if(!l2){// when we still don't have any valid yylloc info, we're looking at an epsilon rule +if(!dont_look_back){for(let i=(i1||sp)-1;i>=0;i--){l1=lstack[i];if(l1){break;}}}if(!l1){if(!l2){// when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: -return undefined;}else{// shallow-copy L2: after all, we MAY be looking +return null;}// shallow-copy L2: after all, we MAY be looking // at unconventional yylloc info objects... -rv=this.copy_yylloc(l2);return rv;}}else{// shallow-copy L1, then adjust first col/row 1 column past the end. +rv=this.copy_yylloc(l2);return rv;}// shallow-copy L1, then adjust first col/row 1 column past the end. rv=this.copy_yylloc(l1);rv.first_line=rv.last_line;rv.first_column=rv.last_column;rv.range[0]=rv.range[1];if(l2){// shallow-mixin L2, then adjust last col/row accordingly. -shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;}}if(!l1){l1=l2;l2=null;}if(!l1){return undefined;}// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking +shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;}if(!l1){l1=l2;l2=null;}if(!l1){return null;}// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... rv=this.copy_yylloc(l1);if(l2){shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;};// NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! -this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){var pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,loc:this.copy_yylloc(lexer.yylloc),expected:expected,recoverable:recoverable,state:state,action:action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,location_stack:lstack,stack_pointer:sp,yy:sharedState_yy,lexer:lexer,parser:this,// and make sure the error info doesn't stay due to potential +this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){const pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,loc:this.copy_yylloc(lexer.yylloc),expected,recoverable,state,action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,location_stack:lstack,stack_pointer:sp,yy:sharedState_yy,lexer,parser:this,// and make sure the error info doesn't stay due to potential // ref cycle via userland code manipulations. // These would otherwise all be memory leak opportunities! // // Note that only array and object references are nuked as those // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. -destroy:function destructParseErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +destroy:function destructParseErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// info.value = null; +// info.value_stack = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;};// clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. -this.shallowCopyErrorInfo=function parser_shallowCopyErrorInfo(p){var rv=shallow_copy(p);// remove the large parts which can only cause cyclic references +this.shallowCopyErrorInfo=function parser_shallowCopyErrorInfo(p){let rv=shallow_copy(p);// remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. delete rv.sharedState_yy;delete rv.parser;delete rv.lexer;// lexer.yytext MAY be a complex value object, rather than a simple string/value: rv.value=this.copy_yytext(rv.value);// yylloc info: @@ -1739,15 +1767,15 @@ rv.value_stack=rv.value_stack.map(this.copy_yytext);// and we don't bother with // - root_failure_pointer: // copy of the `stack_pointer`... // -for(var i=rv.stack_pointer;rv.state_stack[i]!=null;i++){// empty -}rv.base_pointer=i;rv.info_stack_pointer=i;rv.root_failure_pointer=rv.stack_pointer;// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! -this.__error_recovery_infos.push(rv);return rv;};function getNonTerminalFromCode(symbol){var tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){var token=lexer.lex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){var token=lexer.fastLex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}var lex=stdLex;var state,action,r,t;var yyval={$:true,_$:undefined,yy:sharedState_yy};var p;var yyrulelen;var this_production;var newState;var retval=false;// Return the rule stack depth where the nearest error rule can be found. +{let i;for(i=rv.stack_pointer;rv.state_stack[i]!=null;i++){// empty +}rv.base_pointer=i;rv.info_stack_pointer=i;}rv.root_failure_pointer=rv.stack_pointer;// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +this.__error_recovery_infos.push(rv);return rv;};function getNonTerminalFromCode(symbol){let tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){let token=lexer.lex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){let token=lexer.fastLex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}let lex=stdLex;let state,action,r,t;let yyval={$:true,_$:undefined,yy:sharedState_yy};let p;let yyrulelen;let this_production;let newState;let retval=false;// Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. -function locateNearestErrorRecoveryRule(state){var stack_probe=sp-1;var depth=0;// try to recover from error +function locateNearestErrorRecoveryRule(state){let stack_probe=sp-1;let depth=0;// try to recover from error while(stack_probe>=0){// check for error recovery rule in this state -var t=table[state]&&table[state][TERROR]||NO_ACTION;if(t[0]){// We need to make sure we're not cycling forever: +const t=table[state]&&table[state][TERROR]||NO_ACTION;if(t[0]){// We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must // prevent the core from running forever, // e.g. when parent rules are still expecting certain input to @@ -1768,7 +1796,7 @@ state=sstack[stack_probe];++depth;}return-1;// No suitable error recovery rule a // this initial `setInput()` call: hence we can now check and decide // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: -if(typeof lexer.canIUse==='function'){var lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}yyloc=this.copy_yylloc(lexer.yylloc);lstack[sp]=yyloc;vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack +if(typeof lexer.canIUse==='function'){let lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}yyloc=this.copy_yylloc(lexer.yylloc);lstack[sp]=yyloc;vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack state=newState;// sstack[sp - 1]; // use default actions if available if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}else{// The single `==` condition below covers both these `===` comparisons in a single @@ -1778,7 +1806,7 @@ if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}els if(!symbol){symbol=lex();}// read action for current state and first input t=table[state]&&table[state][symbol]||NO_ACTION;newState=t[1];action=t[0];// handle parse error if(!action){// first see if there's any chance at hitting an error recovery rule: -var error_rule_depth=locateNearestErrorRecoveryRule(state);var errStr=null;var errSymbolDescr=this.describeSymbol(symbol)||symbol;var expected=this.collect_expected_token_set(state);if(!recovering){// Report error +let error_rule_depth=locateNearestErrorRecoveryRule(state);let errStr=null;let errSymbolDescr=this.describeSymbol(symbol)||symbol;let expected=this.collect_expected_token_set(state);if(!recovering){// Report error errStr='Parse error';if(typeof lexer.yylineno==='number'){errStr+=' on line '+(lexer.yylineno+1);}if(typeof lexer.showPosition==='function'){errStr+=':\n'+lexer.showPosition(79-10,10)+'\n';}else{errStr+=': ';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}p=this.constructParseErrorInfo(errStr,null,expected,error_rule_depth>=0);// DO NOT cleanup the old one before we start the new error info track: // the old one will *linger* on the error stack and stay alive until we // invoke the parser's cleanup API! @@ -1786,20 +1814,20 @@ recoveringErrorInfo=this.shallowCopyErrorInfo(p);r=this.parseError(p.errStr,p,th // the `recoverable` flag without properly checking first: // we always terminate the parse when there's no recovery rule available anyhow! if(!p.recoverable||error_rule_depth<0){break;}else{// TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process... -}}var esp=recoveringErrorInfo.info_stack_pointer;// just recovered from another error +}}let esp=recoveringErrorInfo.info_stack_pointer;// just recovered from another error if(recovering===ERROR_RECOVERY_TOKEN_DISCARD_COUNT&&error_rule_depth>=0){// Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc=this.copy_yylloc(lexer.yylloc);// SHIFT current lookahead and grab another recoveringErrorInfo.symbol_stack[esp]=symbol;recoveringErrorInfo.location_stack[esp]=yyloc;recoveringErrorInfo.state_stack[esp]=newState;// push state ++esp;preErrorSymbol=0;symbol=lex();}// try to recover from error -if(error_rule_depth<0){ASSERT(recovering>0,"line 897");recoveringErrorInfo.info_stack_pointer=esp;// barf a fatal hairball when we're out of look-ahead symbols and none hit a match +if(error_rule_depth<0){ASSERT(recovering>0,'Line 1048');recoveringErrorInfo.info_stack_pointer=esp;// barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: -var po=this.__error_infos[this.__error_infos.length-1];// Report error +let po=this.__error_infos[this.__error_infos.length-1];// Report error if(typeof lexer.yylineno==='number'){errStr='Parsing halted on line '+(lexer.yylineno+1)+' while starting to recover from another error';}else{errStr='Parsing halted while starting to recover from another error';}if(po){errStr+=' -- previous error which resulted in this fatal result: '+po.errStr;}else{errStr+=': ';}if(typeof lexer.showPosition==='function'){errStr+='\n'+lexer.showPosition(79-10,10)+'\n';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}p=this.constructParseErrorInfo(errStr,null,expected,false);if(po){p.extra_error_attributes=po;}r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}preErrorSymbol=symbol===TERROR?0:symbol;// save the lookahead token symbol=TERROR;// insert generic error symbol as new lookahead const EXTRA_STACK_SAMPLE_DEPTH=3;// REDUCE/COMBINE the pushed terms/tokens to a new ERROR token: -recoveringErrorInfo.symbol_stack[esp]=preErrorSymbol;if(errStr){recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,errStr:errStr,errorSymbolDescr:errSymbolDescr,expectedStr:expected,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}else{recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}recoveringErrorInfo.location_stack[esp]=this.copy_yylloc(lexer.yylloc);recoveringErrorInfo.state_stack[esp]=newState||NO_ACTION[1];++esp;recoveringErrorInfo.info_stack_pointer=esp;yyval.$=recoveringErrorInfo;yyval._$=undefined;yyrulelen=error_rule_depth;r=this.performAction.call(yyval,yyloc,NO_ACTION[1],sp-1,vstack,lstack);if(typeof r!=='undefined'){retval=r;break;}// pop off stack +recoveringErrorInfo.symbol_stack[esp]=preErrorSymbol;if(errStr){recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,errStr,errSymbolDescr,expectedStr:expected,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}else{recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}recoveringErrorInfo.location_stack[esp]=this.copy_yylloc(lexer.yylloc);recoveringErrorInfo.state_stack[esp]=newState||NO_ACTION[1];++esp;recoveringErrorInfo.info_stack_pointer=esp;yyval.$=recoveringErrorInfo;yyval._$=undefined;yyrulelen=error_rule_depth;let combineState=NO_ACTION[1];r=this.performAction.call(yyval,yyloc,combineState,sp-1,vstack,lstack);if(typeof r!=='undefined'){retval=r;break;}// pop off stack sp-=yyrulelen;// and move the top entries + discarded part of the parse stacks onto the error info stack: -for(var idx=sp-EXTRA_STACK_SAMPLE_DEPTH,top=idx+yyrulelen;idx0){recovering--;}}else{// error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: -ASSERT(recovering>0,"line 1163");symbol=preErrorSymbol;preErrorSymbol=0;// read action for current state and first input +ASSERT(recovering>0,'Line 1352');symbol=preErrorSymbol;preErrorSymbol=0;// read action for current state and first input t=table[newState]&&table[newState][symbol]||NO_ACTION;if(!t[0]||symbol===TERROR){// forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where // (simple) stuff might have been missing before the token which caused the error we're // recovering from now... @@ -1890,17 +1918,17 @@ symbol=0;}}// once we have pushed the special ERROR token value, // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! -ASSERT(preErrorSymbol===0,"line 1194");if(recovering===0){break;}continue;// reduce: +ASSERT(preErrorSymbol===0,'Line 1383');if(recovering===0){break;}continue;// reduce: case 2:this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){// signal end of error recovery loop AND end of outer parse loop +yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){// signal end of error recovery loop AND end of outer parse loop action=3;retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}sp=-2;// magic number: signal outer "fast parse loop" ACCEPT state that we already have a properly set up `retval` parser return value. break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;lstack[sp]=yyval._$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -1928,26 +1956,26 @@ break;}// should we also break out of the regular/outer parse loop, // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? -ASSERT(action!==2,"line 1272");if(!action||action===1){continue;}}}switch(action){// catch misc. parse failures: +ASSERT(action!==2,'Line 1509');if(!action||action===1){continue;}}}switch(action){// catch misc. parse failures: default:// this shouldn't happen, unless resolve defaults are off if(action instanceof Array){p=this.constructParseErrorInfo('Parse Error: multiple actions possible at state: '+state+', token: '+symbol,null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}// Another case of better safe than sorry: in case state transitions come out of another error recovery process // or a buggy LUT (LookUp Table): p=this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.',null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;// shift: case 1:stack[sp]=symbol;vstack[sp]=lexer.yytext;lstack[sp]=this.copy_yylloc(lexer.yylloc);sstack[sp]=newState;// push state -if(typeof Jison!=='undefined'&&Jison.parserDebugger){var tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;ASSERT(preErrorSymbol===0,"line 1352");// normal execution / no error -ASSERT(recovering===0,"line 1353");// normal execution / no error +if(typeof Jison!=='undefined'&&Jison.parserDebugger){let tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;ASSERT(preErrorSymbol===0,'Line 1619');// normal execution / no error +ASSERT(recovering===0,'Line 1620');// normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc=this.copy_yylloc(lexer.yylloc);continue;// reduce: -case 2:ASSERT(preErrorSymbol===0,"line 1364");// normal execution / no error -ASSERT(recovering===0,"line 1365");// normal execution / no error +case 2:ASSERT(preErrorSymbol===0,'Line 1631');// normal execution / no error +ASSERT(recovering===0,'Line 1632');// normal execution / no error this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack +yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;lstack[sp]=yyval._$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:if(sp!==-2){retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -2196,8 +2224,8 @@ return retval;},yyError:1};parser.originalParseError=parser.parseError;parser.or * @public * @constructor * @nocollapse - */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 -Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';var lexer={// Code Generator Information Report + */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){const ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 +Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';const lexer={// Code Generator Information Report // --------------------------------- // // Options: @@ -2266,7 +2294,7 @@ CRLF_Re:/\r\n?|\n/,/** * @this {RegExpLexer} */constructLexErrorInfo:function lexer_constructLexErrorInfo(msg,recoverable,show_input_position){msg=''+msg;// heuristic to determine if the error message already contains a (partial) source code dump // as produced by either `showPosition()` or `prettyPrintRange()`: -if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){var pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){var pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */var pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... +if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){const pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){const pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */const pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:this,/** * and make sure the error info doesn't stay due to potential * ref cycle via userland code manipulations. @@ -2278,7 +2306,11 @@ text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:t * * @public * @this {LexErrorInfo} - */destroy:function destructLexErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! + */destroy:function destructLexErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;},/** * handler which is invoked when a lexer error occurs. * @@ -2289,8 +2321,8 @@ this.__error_infos.push(pei);return pei;},/** * * @public * @this {RegExpLexer} - */yyerror:function yyError(str/*, ...args */){var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** + */yyerror:function yyError(str/*, ...args */){let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: +let args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** * final cleanup function for when we have completed lexing the input; * make it an API so that external code can use this one once userland * code has decided it's time to destroy any lingering lexer error @@ -2305,13 +2337,13 @@ var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_a this.setInput('',{});// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** * clear the lexer token context; intended for internal use only * * @public * @this {RegExpLexer} */clear:function lexer_clear(){this.yytext='';this.yyleng=0;this.match='';// - DO NOT reset `this.matched` -this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** +this.matches=false;this._more=false;this._backtrack=false;const col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** * resets the lexer, sets new input * * @public @@ -2320,10 +2352,10 @@ this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.la // including expansion work to be done to go from a loaded // lexer to a usable lexer: if(!this.__decompressed){// step 1: decompress the regex list: -var rules=this.rules;for(var i=0,len=rules.length;i> tokens and perform user action code for a <> match, but only does so *once*) -return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}var ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). +return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}let ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. -var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;var ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** +let slice_len=1;let lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;const ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** * unshifts one char (or an entire string) into the input * * @public * @this {RegExpLexer} - */unput:function lexer_unput(ch){var len=ch.length;var lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** + */unput:function lexer_unput(ch){let len=ch.length;let lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** // The `offset` value MAY be negative if you `unput()` more text than you have already lexed. // This type of behaviour is generally observed for one kind of 'lexer/parser hack' // where custom token-illiciting characters are pushed in front of the input stream to help @@ -2393,11 +2425,11 @@ var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lin if(-this.offset>this.base_position){this.base_position=-this.offset;}this.match=this.match.substr(0,this.match.length-len);this.matched=this.matched.substr(0,this.matched.length-len);if(lines.length>1){this.yylineno-=lines.length-1;this.yylloc.last_line=this.yylineno+1;// Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. -var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** +let pre=this.match;let pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -2407,8 +2439,8 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */lookAhead:function lexer_lookAhead(){return this._input||'';},/** @@ -2425,7 +2457,7 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 */reject:function lexer_reject(){if(this.options.backtrack_lexer){this._backtrack=true;}else{// when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. -var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** +let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** * retain first n characters of the match * * @public @@ -2447,17 +2479,17 @@ var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yyl * * @public * @this {RegExpLexer} - */pastInput:function lexer_pastInput(maxSize,maxLines){var past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0)maxSize=Infinity;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=Infinity;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substr` anticipation: treat \r\n as a single character and take a little + */pastInput:function lexer_pastInput(maxSize,maxLines){let past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0){maxSize=Infinity;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=Infinity;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past=past.substr(-maxSize*2-2);// now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: -var a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, +let a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, // do add an ellipsis prefix... if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -2483,18 +2515,18 @@ if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} - */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){var next=this.match;var source=this._input||'';if(maxSize<0)maxSize=next.length+source.length;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=maxSize;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substring` anticipation: treat \r\n as a single character and take a little + */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){let next=this.match;let source=this._input||'';if(maxSize<0){maxSize=next.length+source.length;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=maxSize;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: if(next.lengthmaxSize){next=next.substring(0,maxSize)+'...';}return next;},/** @@ -2503,7 +2535,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){var pre=this.pastInput(maxPrefix).replace(/\s/g,' ');var c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** + */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){const pre=this.pastInput(maxPrefix).replace(/\s/g,' ');let c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** * return an YYLLOC info object derived off the given context (actual, preceding, following, current). * Use this method when the given `actual` location is not guaranteed to exist (i.e. when * it MAY be NULL) and you MUST have a valid location info object anyway: @@ -2519,7 +2551,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */deriveLocationInfo:function lexer_deriveYYLLOC(actual,preceding,following,current){var loc={first_line:1,first_column:0,last_line:1,last_column:0,range:[0,0]};if(actual){loc.first_line=actual.first_line|0;loc.last_line=actual.last_line|0;loc.first_column=actual.first_column|0;loc.last_column=actual.last_column|0;if(actual.range){loc.range[0]=actual.range[0]|0;loc.range[1]=actual.range[1]|0;}}if(loc.first_line<=0||loc.last_line=loc.first_line)){loc.last_line=current.last_line|0;loc.last_column=current.last_column|0;if(current.range){loc.range[1]=current.range[1]|0;}}}// sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter // or plan D heuristics to produce a 'sensible' last_line value: @@ -2568,9 +2600,9 @@ loc.range[1]=loc.range[0];}if(loc.first_column<0){loc.first_column=0;}if(loc.las * * @public * @this {RegExpLexer} - */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;var input=this.matched+(this._input||'');var lines=input.split('\n');var l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);var l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);var lineno_display_width=1+Math.log10(l1|1)|0;var ws_prefix=new Array(lineno_display_width).join(' ');var nonempty_line_indexes=[[],[],[]];var rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){var lno=index+l0;var lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);var rv=lno_pfx+': '+line;var errpfx=new Array(lineno_display_width+1).join('^');var offset=2+1;var len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it + */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;let input=this.matched+(this._input||'');let lines=input.split('\n');let l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);let l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);let lineno_display_width=1+Math.log10(l1|1)|0;let ws_prefix=new Array(lineno_display_width).join(' ');let nonempty_line_indexes=[[],[],[]];let rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){let lno=index+l0;let lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);let rv=lno_pfx+': '+line;let errpfx=new Array(lineno_display_width+1).join('^');let offset=2+1;let len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: -for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){var clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;var clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;var intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** +for(let i=0;i<=2;i++){let line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){let clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;let clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;let intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** * helper function, used to produce a human readable description as a string, given * the input `yylloc` location object. * @@ -2579,7 +2611,7 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){var l1=yylloc.first_line;var l2=yylloc.last_line;var c1=yylloc.first_column;var c2=yylloc.last_column;var dl=l2-l1;var dc=c2-c1;var rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){var r1=yylloc.range[0];var r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** + */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){let l1=yylloc.first_line;let l2=yylloc.last_line;let c1=yylloc.first_column;let c2=yylloc.last_column;let dl=l2-l1;let dc=c2-c1;let rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){let r1=yylloc.range[0];let r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** * test the lexed token: return FALSE when not a match, otherwise return token. * * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]` @@ -2596,18 +2628,18 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */test_match:function lexer_test_match(match,indexed_rule){var token,lines,backup,match_str,match_str_len;if(this.options.backtrack_lexer){// save context + */test_match:function lexer_test_match(match,indexed_rule){let backup;if(this.options.backtrack_lexer){// save context backup={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.yylloc.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column,range:this.yylloc.range.slice()},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,//_signaled_error_token: this._signaled_error_token, -yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}match_str=match[0];match_str_len=match_str.length;lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: +yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}let match_str=match[0];let match_str_len=match_str.length;let lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: // those rules will already have moved this `offset` forward matching their match lengths, // hence we must only add our own match length now: this.offset+=match_str_len;this._more=false;this._backtrack=false;this._input=this._input.slice(match_str_len);// calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} -token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: +let token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; if(this.done&&this._input){this.done=false;}if(token){return token;}else if(this._backtrack){// recover context -for(var k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. +for(let k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. }else if(this._signaled_error_token){// produce one 'error' token as `.parseError()` in `reject()` // did not guarantee a failure signal by throwing an exception! token=this._signaled_error_token;this._signaled_error_token=false;return token;}return false;},/** @@ -2615,19 +2647,19 @@ token=this._signaled_error_token;this._signaled_error_token=false;return token;} * * @public * @this {RegExpLexer} - */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}var token,match,tempMatch,index;if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}var spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. + */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}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();// Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 -if(!spec||!spec.rules){var lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! -return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}var rule_ids=spec.rules;var regexes=spec.__rule_regexes;var len=spec.__rule_count;// Note: the arrays are 1-based, while `len` itself is a valid index, +if(!spec||!spec.rules){let lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! +return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}{let rule_ids=spec.rules;let regexes=spec.__rule_regexes;let len=spec.__rule_count;let match;let index;// 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(var i=1;i<=len;i++){tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. +for(let i=1;i<=len;i++){let tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){let token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. }else{// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}}else if(!this.options.flex){break;}}}if(match){token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}if(!this._input){this.done=true;this.clear();return this.EOF;}else{var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);var pendingInput=this._input;var activeCondition=this.topState();var conditionStackDepth=this.conditionStack.length;token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us +return false;}}else if(!this.options.flex){break;}}}if(match){let token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) +return false;}}if(!this._input){this.done=true;this.clear();return this.EOF;}{let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);let pendingInput=this._input;let activeCondition=this.topState();let conditionStackDepth=this.conditionStack.length;let token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: if(!this.matches&&// and make sure the input has been modified/consumed ... @@ -2638,7 +2670,7 @@ activeCondition===this.topState()&&conditionStackDepth===this.conditionStack.len * * @public * @this {RegExpLexer} - */lex:function lexer_lex(){var r;//this._clear_state = 0; + */lex:function lexer_lex(){let r;//this._clear_state = 0; if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}// allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer: if(typeof this.pre_lex==='function'){r=this.pre_lex.call(this,0);}if(typeof this.options.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.pre_lex.call(this,r)||r;}if(this.yy&&typeof this.yy.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) @@ -2646,50 +2678,50 @@ r=this.yy.pre_lex.call(this,r)||r;}while(!r){r=this.next();}if(this.yy&&typeof t r=this.yy.post_lex.call(this,r)||r;}if(typeof this.options.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.post_lex.call(this,r)||r;}if(typeof this.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.post_lex.call(this,r)||r;}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return next match that has a token. Identical to the `lex()` API but does not invoke any of the * `pre_lex()` nor any of the `post_lex()` callbacks. * * @public * @this {RegExpLexer} - */fastLex:function lexer_fastLex(){var r;//this._clear_state = 0; + */fastLex:function lexer_fastLex(){let r;//this._clear_state = 0; while(!r){r=this.next();}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return info about the lexer state that can help a parser or other lexer API user to use the * most efficient means available. This API is provided to aid run-time performance for larger @@ -2697,7 +2729,7 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */canIUse:function lexer_canIUse(){var rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** + */canIUse:function lexer_canIUse(){const rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** * backwards compatible alias for `pushState()`; * the latter is symmetrical with `popState()` and we advise to use * those APIs in any modern lexer code, rather than `begin()`. @@ -2716,20 +2748,20 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */popState:function lexer_popState(){var n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}else{return this.conditionStack[0];}},/** + */popState:function lexer_popState(){const n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}return this.conditionStack[0];},/** * return the currently active lexer condition state; when an index * argument is provided it produces the N-th previous condition state, * if available * * @public * @this {RegExpLexer} - */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}else{return'INITIAL';}},/** + */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}return'INITIAL';},/** * (internal) determine the lexer rule set which is active for the * currently active lexer condition state * * @public * @this {RegExpLexer} - */_currentRules:function lexer__currentRules(){var n=this.conditionStack.length-1;var state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions['INITIAL'];},/** + */_currentRules:function lexer__currentRules(){const n=this.conditionStack.length-1;let state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions.INITIAL;},/** * return the number of states currently on the stack * * @public @@ -2996,7 +3028,7 @@ const CHR_RE=/^(?:[^\\]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[ const WHITESPACE_SETSTR=' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff';// `/\d/`: const DIGIT_SETSTR='0-9';// `/\w/`: const WORDCHAR_SETSTR='A-Za-z0-9_';// Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex -function i2c(i){var c,x;switch(i){case 10:return'\\n';case 13:return'\\r';case 9:return'\\t';case 8:return'\\b';case 12:return'\\f';case 11:return'\\v';case 45:// ASCII/Unicode for '-' dash +function i2c(i){let c,x;switch(i){case 10:return'\\n';case 13:return'\\r';case 9:return'\\t';case 8:return'\\b';case 12:return'\\f';case 11:return'\\v';case 45:// ASCII/Unicode for '-' dash return'\\-';case 91:// '[' return'\\[';case 92:// '\\' return'\\\\';case 93:// ']' @@ -3006,13 +3038,13 @@ return'\\^';}if(i<32||i>0xFFF0/* Unicode Specials, also in UTF16 */||i>=0xD800&& // source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report // a b0rked generated parser, as the generated code would include this regex right here. // Hence we MUST escape these buggers everywhere we go... -x=i.toString(16);if(x.length>=1&&i<=0xFFFF){c='0000'+x;return'\\u'+c.substr(c.length-4);}else{return'\\u{'+x+'}';}}return String.fromCharCode(i);}// Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating +x=i.toString(16);if(x.length>=1&&i<=0xFFFF){c='0000'+x;return'\\u'+c.substr(c.length-4);}return'\\u{'+x+'}';}return String.fromCharCode(i);}// Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating // this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a // `\\p{NAME}` shorthand to represent [part of] the bitarray: -var Pcodes_bitarray_cache={};var Pcodes_bitarray_cache_test_order=[];// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by +let Pcodes_bitarray_cache={};let Pcodes_bitarray_cache_test_order=[];// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. -var EscCode_bitarray_output_refs;// now initialize the EscCodes_... table above: -init_EscCode_lookup_table();function init_EscCode_lookup_table(){var s,bitarr,set2esc={},esc2bitarr={};// patch global lookup tables for the time being, while we calculate their *real* content in this function: +let EscCode_bitarray_output_refs;// now initialize the EscCodes_... table above: +init_EscCode_lookup_table();function init_EscCode_lookup_table(){let s,bitarr,set2esc={},esc2bitarr={};// patch global lookup tables for the time being, while we calculate their *real* content in this function: EscCode_bitarray_output_refs={esc2bitarr:{},set2esc:{}};Pcodes_bitarray_cache_test_order=[];// `/\S': bitarr=[];set2bitarray(bitarr,'^'+WHITESPACE_SETSTR);s=bitarray2set(bitarr);esc2bitarr['S']=bitarr;set2esc[s]='S';// set2esc['^' + s] = 's'; Pcodes_bitarray_cache['\\S']=bitarr;// `/\s': @@ -3025,34 +3057,34 @@ Pcodes_bitarray_cache['\\d']=bitarr;// `/\W': bitarr=[];set2bitarray(bitarr,'^'+WORDCHAR_SETSTR);s=bitarray2set(bitarr);esc2bitarr['W']=bitarr;set2esc[s]='W';// set2esc['^' + s] = 'w'; Pcodes_bitarray_cache['\\W']=bitarr;// `/\w': bitarr=[];set2bitarray(bitarr,WORDCHAR_SETSTR);s=bitarray2set(bitarr);esc2bitarr['w']=bitarr;set2esc[s]='w';// set2esc['^' + s] = 'W'; -Pcodes_bitarray_cache['\\w']=bitarr;EscCode_bitarray_output_refs={esc2bitarr:esc2bitarr,set2esc:set2esc};updatePcodesBitarrayCacheTestOrder();}function updatePcodesBitarrayCacheTestOrder(opts){var t=new Array(UNICODE_BASE_PLANE_MAX_CP+1);var l={};var user_has_xregexp=opts&&opts.options&&opts.options.xregexp;var i,j,k,ba;// mark every character with which regex pcodes they are part of: -for(k in Pcodes_bitarray_cache){ba=Pcodes_bitarray_cache[k];if(!user_has_xregexp&&k.indexOf('\\p{')>=0){continue;}var cnt=0;for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(ba[i]){cnt++;if(!t[i]){t[i]=[k];}else{t[i].push(k);}}}l[k]=cnt;}// now dig out the unique ones: only need one per pcode. -// +Pcodes_bitarray_cache['\\w']=bitarr;EscCode_bitarray_output_refs={esc2bitarr:esc2bitarr,set2esc:set2esc};updatePcodesBitarrayCacheTestOrder();}function updatePcodesBitarrayCacheTestOrder(opts){let t=new Array(UNICODE_BASE_PLANE_MAX_CP+1);let l={};let user_has_xregexp=opts&&opts.options&&opts.options.xregexp;let i,j,k,ba;// mark every character with which regex pcodes they are part of: +for(k in Pcodes_bitarray_cache){ba=Pcodes_bitarray_cache[k];if(!user_has_xregexp&&k.indexOf('\\p{')>=0){continue;}let cnt=0;for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(ba[i]){cnt++;if(!t[i]){t[i]=[k];}else{t[i].push(k);}}}l[k]=cnt;}// now dig out the unique ones: only need one per pcode. +// // We ASSUME every \\p{NAME} 'pcode' has at least ONE character -// in it that is ONLY matched by that particular pcode. +// in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode -// won't be tested during optimization. -// +// won't be tested during optimization. +// // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to // look for markers which match multiple escapes/pcodes for those // ones where a unique item isn't available... -var lut=[];var done={};var keys=Object.keys(Pcodes_bitarray_cache);for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){k=t[i][0];if(t[i].length===1&&!done[k]){assert__default['default'](l[k]>0);lut.push([i,k]);done[k]=true;}}for(j=0;keys[j];j++){k=keys[j];if(!user_has_xregexp&&k.indexOf('\\p{')>=0){continue;}if(!done[k]){assert__default['default'](l[k]>0);// find a minimum span character to mark this one: -var w=Infinity;var rv;ba=Pcodes_bitarray_cache[k];for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(ba[i]){var tl=t[i].length;if(tl>1&&tl0);rv=[i,k];w=tl;}}}if(rv){done[k]=true;lut.push(rv);}}}// order from large set to small set so that small sets don't gobble +let lut=[];let done={};let keys=Object.keys(Pcodes_bitarray_cache);for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){k=t[i][0];if(t[i].length===1&&!done[k]){assert__default['default'](l[k]>0);lut.push([i,k]);done[k]=true;}}for(j=0;keys[j];j++){k=keys[j];if(!user_has_xregexp&&k.indexOf('\\p{')>=0){continue;}if(!done[k]){assert__default['default'](l[k]>0);// find a minimum span character to mark this one: +let w=Infinity;var rv;ba=Pcodes_bitarray_cache[k];for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(ba[i]){let tl=t[i].length;if(tl>1&&tl0);rv=[i,k];w=tl;}}}if(rv){done[k]=true;lut.push(rv);}}}// order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. -// +// // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more -// optimal minification of the regex set expression. -// +// optimal minification of the regex set expression. +// // This is a guestimate/heuristic only! -lut.sort(function(a,b){var k1=a[1];var k2=b[1];var ld=l[k2]-l[k1];if(ld){return ld;}// and for same-size sets, order from high to low unique identifier. +lut.sort(function(a,b){let k1=a[1];let k2=b[1];let ld=l[k2]-l[k1];if(ld){return ld;}// and for same-size sets, order from high to low unique identifier. return b[0]-a[0];});Pcodes_bitarray_cache_test_order=lut;}// 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set. -function set2bitarray(bitarr,s,opts){var orig=s;var set_is_inverted=false;var bitarr_orig;function mark(d1,d2){if(d2==null)d2=d1;for(var i=d1;i<=d2;i++){bitarr[i]=true;}}function add2bitarray(dst,src){for(var i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(src[i]){dst[i]=true;}}}function eval_escaped_code(s){var c;// decode escaped code? If none, just take the character as-is -if(s.indexOf('\\')===0){var l=s.substr(0,2);switch(l){case'\\c':c=s.charCodeAt(2)-'A'.charCodeAt(0)+1;return String.fromCharCode(c);case'\\x':s=s.substr(2);c=parseInt(s,16);return String.fromCharCode(c);case'\\u':s=s.substr(2);if(s[0]==='{'){s=s.substr(1,s.length-2);}c=parseInt(s,16);if(c>=0x10000){return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{'+s+'}');}return String.fromCharCode(c);case'\\0':case'\\1':case'\\2':case'\\3':case'\\4':case'\\5':case'\\6':case'\\7':s=s.substr(1);c=parseInt(s,8);return String.fromCharCode(c);case'\\r':return'\r';case'\\n':return'\n';case'\\v':return'\v';case'\\f':return'\f';case'\\t':return'\t';case'\\b':return'\b';default:// just the character itself: -return s.substr(1);}}else{return s;}}if(s&&s.length){var c1,c2;// inverted set? +function set2bitarray(bitarr,s,opts){let orig=s;let set_is_inverted=false;let bitarr_orig;function mark(d1,d2){if(d2==null)d2=d1;for(let i=d1;i<=d2;i++){bitarr[i]=true;}}function add2bitarray(dst,src){for(let i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(src[i]){dst[i]=true;}}}function eval_escaped_code(s){let c;// decode escaped code? If none, just take the character as-is +if(s.indexOf('\\')===0){let l=s.substr(0,2);switch(l){case'\\c':c=s.charCodeAt(2)-'A'.charCodeAt(0)+1;return String.fromCharCode(c);case'\\x':s=s.substr(2);c=parseInt(s,16);return String.fromCharCode(c);case'\\u':s=s.substr(2);if(s[0]==='{'){s=s.substr(1,s.length-2);}c=parseInt(s,16);if(c>=0x10000){return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{'+s+'}');}return String.fromCharCode(c);case'\\0':case'\\1':case'\\2':case'\\3':case'\\4':case'\\5':case'\\6':case'\\7':s=s.substr(1);c=parseInt(s,8);return String.fromCharCode(c);case'\\r':return'\r';case'\\n':return'\n';case'\\v':return'\v';case'\\f':return'\f';case'\\t':return'\t';case'\\b':return'\b';default:// just the character itself: +return s.substr(1);}}else{return s;}}if(s&&s.length){let c1,c2;// inverted set? if(s[0]==='^'){set_is_inverted=true;s=s.substr(1);bitarr_orig=bitarr;bitarr=new Array(UNICODE_BASE_PLANE_MAX_CP+1);}// BITARR collects flags for characters set. Inversion means the complement set of character is st instead. // This results in an OR operations when sets are joined/chained. while(s.length){c1=s.match(CHR_RE);if(!c1){// hit an illegal escape sequence? cope anyway! @@ -3060,31 +3092,31 @@ c1=s[0];}else{c1=c1[0];// Quick hack for XRegExp escapes inside a regex `[...]` // intact but it's easier to unfold them here; this is not nice for when the grammar specifies explicit // XRegExp support, but alas, we'll get there when we get there... ;-) switch(c1){case'\\p':s=s.substr(c1.length);c2=s.match(XREGEXP_UNICODE_ESCAPE_RE);if(c2){c2=c2[0];s=s.substr(c2.length);// do we have this one cached already? -var pex=c1+c2;var ba4p=Pcodes_bitarray_cache[pex];if(!ba4p){// expand escape: -var xr=new XRegExp__default['default']('['+pex+']');// TODO: case-insensitive grammar??? +let pex=c1+c2;let ba4p=Pcodes_bitarray_cache[pex];if(!ba4p){// expand escape: +let xr=new XRegExp__default['default']('['+pex+']');// TODO: case-insensitive grammar??? // rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`: -var xs=''+xr;// remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: +let xs=''+xr;// remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: xs=xs.substr(1,xs.length-2);ba4p=reduceRegexToSetBitArray(xs,pex,opts);Pcodes_bitarray_cache[pex]=ba4p;updatePcodesBitarrayCacheTestOrder(opts);}// merge bitarrays: add2bitarray(bitarr,ba4p);continue;}break;case'\\S':case'\\s':case'\\W':case'\\w':case'\\d':case'\\D':// these can't participate in a range, but need to be treated special: s=s.substr(c1.length);// check for \S, \s, \D, \d, \W, \w and expand them: var ba4e=EscCode_bitarray_output_refs.esc2bitarr[c1[1]];assert__default['default'](ba4e);add2bitarray(bitarr,ba4e);continue;case'\\b':// matches a backspace: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions#special-backspace -c1='\u0008';break;}}var v1=eval_escaped_code(c1);// propagate deferred exceptions = error reports. +c1='\u0008';break;}}let v1=eval_escaped_code(c1);// propagate deferred exceptions = error reports. if(v1 instanceof Error){return v1;}v1=v1.charCodeAt(0);s=s.substr(c1.length);if(s[0]==='-'&&s.length>=2){// we can expect a range like 'a-z': s=s.substr(1);c2=s.match(CHR_RE);if(!c2){// hit an illegal escape sequence? cope anyway! -c2=s[0];}else{c2=c2[0];}var v2=eval_escaped_code(c2);// propagate deferred exceptions = error reports. +c2=s[0];}else{c2=c2[0];}let v2=eval_escaped_code(c2);// propagate deferred exceptions = error reports. if(v2 instanceof Error){return v1;}v2=v2.charCodeAt(0);s=s.substr(c2.length);// legal ranges go UP, not /DOWN! if(v1<=v2){mark(v1,v2);}else{console.warn('INVALID CHARACTER RANGE found in regex: ',{re:orig,start:c1,start_n:v1,end:c2,end_n:v2});mark(v1);mark('-'.charCodeAt(0));mark(v2);}continue;}mark(v1);}// When we have marked all slots, '^' NEGATES the set, hence we flip all slots. -// +// // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. -if(set_is_inverted){for(var i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(!bitarr[i]){bitarr_orig[i]=true;}}}}return false;}// convert a simple bitarray back into a regex set `[...]` content: +if(set_is_inverted){for(let i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(!bitarr[i]){bitarr_orig[i]=true;}}}}return false;}// convert a simple bitarray back into a regex set `[...]` content: function bitarray2set(l,output_inverted_variant,output_minimized){// construct the inverse(?) set from the mark-set: // // Before we do that, we inject a sentinel so that our inner loops // below can be simple and fast: l[UNICODE_BASE_PLANE_MAX_CP+1]=1;// now reconstruct the regex set: -var rv=[];var i,j,cnt,lut,tn,tspec,match,pcode,ba4pcode,l2;var bitarr_is_cloned=false;var l_orig=l;if(output_inverted_variant){// generate the inverted set, hence all unmarked slots are part of the output range: +let rv=[];let i,j,cnt,lut,tn,tspec,match,pcode,ba4pcode,l2;let bitarr_is_cloned=false;let l_orig=l;if(output_inverted_variant){// generate the inverted set, hence all unmarked slots are part of the output range: cnt=0;for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(!l[i]){cnt++;}}if(cnt===UNICODE_BASE_PLANE_MAX_CP+1){// When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. // BUT... since we output the INVERTED set, we output the match-all set instead: return'\\S\\s';}else if(cnt===0){// When we find the entire Unicode range is in the output match set, we replace this with @@ -3096,9 +3128,9 @@ if(!l[tspec[0]]){// check if the pcode is covered by the inverted set: pcode=tspec[1];ba4pcode=Pcodes_bitarray_cache[pcode];match=0;for(j=0;j<=UNICODE_BASE_PLANE_MAX_CP;j++){if(ba4pcode[j]){if(!l[j]){// match in current inverted bitset, i.e. there's at // least one 'new' bit covered by this pcode/escape: match++;}else if(l_orig[j]){// mismatch! -match=false;break;}}}// We're only interested in matches which actually cover some +match=false;break;}}}// We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. -// +// // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if(match&&match>pcode.length){rv.push(pcode);// and nuke the bits in the array which match the given pcode: @@ -3119,9 +3151,9 @@ if(l[tspec[0]]){// check if the pcode is covered by the set: pcode=tspec[1];ba4pcode=Pcodes_bitarray_cache[pcode];match=0;for(j=0;j<=UNICODE_BASE_PLANE_MAX_CP;j++){if(ba4pcode[j]){if(l[j]){// match in current bitset, i.e. there's at // least one 'new' bit covered by this pcode/escape: match++;}else if(!l_orig[j]){// mismatch! -match=false;break;}}}// We're only interested in matches which actually cover some +match=false;break;}}}// We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. -// +// // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if(match&&match>pcode.length){rv.push(pcode);// and nuke the bits in the array which match the given pcode: @@ -3131,17 +3163,17 @@ if(!bitarr_is_cloned){l2=new Array(UNICODE_BASE_PLANE_MAX_CP+1);for(j=0;j<=UNICO l2[UNICODE_BASE_PLANE_MAX_CP+1]=1;l=l2;bitarr_is_cloned=true;}else{for(j=0;j<=UNICODE_BASE_PLANE_MAX_CP;j++){l[j]=l[j]&&!ba4pcode[j];}}}}}}i=0;while(i<=UNICODE_BASE_PLANE_MAX_CP){// find first character not in original set: while(!l[i]){i++;}if(i>=UNICODE_BASE_PLANE_MAX_CP+1){break;}// find next character not in original set: for(j=i+1;l[j];j++){}/* empty loop */if(j>UNICODE_BASE_PLANE_MAX_CP+1){j=UNICODE_BASE_PLANE_MAX_CP+1;}// generate subset: -rv.push(i2c(i));if(j-1>i){rv.push((j-2>i?'-':'')+i2c(j-1));}i=j;}}assert__default['default'](rv.length);var s=rv.join('');assert__default['default'](s);// Check if the set is better represented by one of the regex escapes: -var esc4s=EscCode_bitarray_output_refs.set2esc[s];if(esc4s){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! +rv.push(i2c(i));if(j-1>i){rv.push((j-2>i?'-':'')+i2c(j-1));}i=j;}}assert__default['default'](rv.length);let s=rv.join('');assert__default['default'](s);// Check if the set is better represented by one of the regex escapes: +let esc4s=EscCode_bitarray_output_refs.set2esc[s];if(esc4s){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return'\\'+esc4s;}return s;}// Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there; // ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`. -function reduceRegexToSetBitArray(s,name,opts){var orig=s;// propagate deferred exceptions = error reports. -if(s instanceof Error){return s;}var l=new Array(UNICODE_BASE_PLANE_MAX_CP+1);var internal_state=0;var derr;while(s.length){var c1=s.match(CHR_RE);if(!c1){// cope with illegal escape sequences too! -return new Error('illegal escape sequence at start of regex part: "'+s+'" of regex "'+orig+'"');}else{c1=c1[0];}s=s.substr(c1.length);switch(c1){case'[':// this is starting a set within the regex: scan until end of set! -var set_content=[];while(s.length){var inner=s.match(SET_PART_RE);if(!inner){inner=s.match(CHR_RE);if(!inner){// cope with illegal escape sequences too! -return new Error('illegal escape sequence at start of regex part: '+s+'" of regex "'+orig+'"');}else{inner=inner[0];}if(inner===']')break;}else{inner=inner[0];}set_content.push(inner);s=s.substr(inner.length);}// ensure that we hit the terminating ']': +function reduceRegexToSetBitArray(s,name,opts){let orig=s;// propagate deferred exceptions = error reports. +if(s instanceof Error){return s;}let l=new Array(UNICODE_BASE_PLANE_MAX_CP+1);let internal_state=0;let derr;while(s.length){let c1=s.match(CHR_RE);if(!c1){// cope with illegal escape sequences too! +return new Error('illegal escape sequence at start of regex part: "'+s+'" of regex "'+orig+'"');}c1=c1[0];s=s.substr(c1.length);switch(c1){case'[':// this is starting a set within the regex: scan until end of set! +var set_content=[];while(s.length){let inner=s.match(SET_PART_RE);if(!inner){inner=s.match(CHR_RE);if(!inner){// cope with illegal escape sequences too! +return new Error('illegal escape sequence at start of regex part: '+s+'" of regex "'+orig+'"');}inner=inner[0];if(inner===']')break;}else{inner=inner[0];}set_content.push(inner);s=s.substr(inner.length);}// ensure that we hit the terminating ']': var c2=s.match(CHR_RE);if(!c2){// cope with illegal escape sequences too! -return new Error('regex set expression is broken in regex: "'+orig+'" --> "'+s+'"');}else{c2=c2[0];}if(c2!==']'){return new Error('regex set expression is broken in regex: '+orig);}s=s.substr(c2.length);var se=set_content.join('');if(!internal_state){derr=set2bitarray(l,se,opts);// propagate deferred exceptions = error reports. +return new Error('regex set expression is broken in regex: "'+orig+'" --> "'+s+'"');}c2=c2[0];if(c2!==']'){return new Error('regex set expression is broken in regex: '+orig);}s=s.substr(c2.length);var se=set_content.join('');if(!internal_state){derr=set2bitarray(l,se,opts);// propagate deferred exceptions = error reports. if(derr instanceof Error){return derr;}// a set is to use like a single character in a longer literal phrase, hence input `[abc]word[def]` would thus produce output `[abc]`: internal_state=1;}break;// Strip unescaped pipes to catch constructs like `\\r|\\n` and turn them into // something ready for use inside a regex set, e.g. `\\r\\n`. @@ -3175,34 +3207,34 @@ if(!internal_state){derr=set2bitarray(l,c1,opts);// propagate deferred exception if(derr instanceof Error){return derr;}internal_state=2;}break;}}s=bitarray2set(l);// When this result is suitable for use in a set, than we should be able to compile // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: -try{var re;assert__default['default'](s);assert__default['default'](!(s instanceof Error));re=new XRegExp__default['default']('['+s+']');re.test(s[0]);// One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` +try{assert__default['default'](s);assert__default['default'](!(s instanceof Error));let re=new XRegExp__default['default']('['+s+']');re.test(s[0]);// One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` // so we check for lingering UNESCAPED brackets in here as those cannot be: if(/[^\\][\[\]]/.exec(s)){throw new Error('unescaped brackets in set data');}}catch(ex){// make sure we produce a set range expression which will fail badly when it is used // in actual code: s=new Error('[macro ['+name+'] is unsuitable for use inside regex set expressions: "['+s+']"]: '+ex.message);}assert__default['default'](s);// propagate deferred exceptions = error reports. -if(s instanceof Error){return s;}return l;}// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` +if(s instanceof Error){return s;}return l;}// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! function produceOptimizedRegex4Set(bitarr){// First try to produce a minimum regex from the bitarray directly: -var s1=bitarray2set(bitarr,false,true);// and when the regex set turns out to match a single pcode/escape, then +let s1=bitarray2set(bitarr,false,true);// and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if(s1.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! -return s1;}else{s1='['+s1+']';}// Now try to produce a minimum regex from the *inverted* bitarray via negation: +return s1;}s1='['+s1+']';// Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. -var s2=bitarray2set(bitarr,true,true);if(s2[0]==='^'){s2=s2.substr(1);if(s2.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! +let s2=bitarray2set(bitarr,true,true);if(s2[0]==='^'){s2=s2.substr(1);if(s2.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s2;}}else{s2='^'+s2;}s2='['+s2+']';// Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: -// +// // First try to produce a minimum regex from the bitarray directly: -var s3=bitarray2set(bitarr,false,false);// and when the regex set turns out to match a single pcode/escape, then +let s3=bitarray2set(bitarr,false,false);// and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if(s3.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! -return s3;}else{s3='['+s3+']';}// Now try to produce a minimum regex from the *inverted* bitarray via negation: +return s3;}s3='['+s3+']';// Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. -var s4=bitarray2set(bitarr,true,false);if(s4[0]==='^'){s4=s4.substr(1);if(s4.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! +let s4=bitarray2set(bitarr,true,false);if(s4[0]==='^'){s4=s4.substr(1);if(s4.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s4;}}else{s4='^'+s4;}s4='['+s4+']';if(s2.length0){err=e;}else{err=new Error('Could not parse jison lexer spec in JSON AUTODETECT mode:\nin JISON Mode we get Error: '+e.message+'\n\nwhile JSON5 Mode produces Error: '+ex1.message);err.secondary_exception=e;err.stack=ex1.stack;}}else{err=new Error('Could not parse lexer spec\nError: '+e.message);err.stack=e.stack;}throw err;}}}else{chk_l=lexerSpec;}// Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: +const commonErrors=[/does not compile/,/you did not correctly separate trailing code/,/You did not specify/,/You cannot specify/,/must be qualified/,/%start/,/%token/,/%import/,/%include/,/%options/,/%parse-params/,/%parser-type/,/%epsilon/,/definition list error/,/token list error/,/declaration error/,/should be followed/,/should be separated/,/an error in one or more of your lexer regex rules/,/an error in your lexer epilogue/,/unsupported definition type/];let cmnerr=commonErrors.filter(function check(re){return e.message.match(re);});if(cmnerr.length>0){err=e;}else{err=new Error('Could not parse jison lexer spec in JSON AUTODETECT mode:\nin JISON Mode we get Error: '+e.message+'\n\nwhile JSON5 Mode produces Error: '+ex1.message);err.secondary_exception=e;err.stack=ex1.stack;}}else{err=new Error('Could not parse lexer spec\nError: '+e.message);err.stack=e.stack;}throw err;}}}else{chk_l=lexerSpec;}// Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: return chk_l;}// expand macros and convert matchers to RegExp's -function prepareRules(dict,actions,caseHelper,tokens,startConditions,opts){var m,i,k,rule,action,conditions;var active_conditions;assert__default['default'](Array.isArray(dict.rules));var rules=dict.rules.slice(0);// shallow copy of the rules array as we MAY modify it in here! -var newRules=[];var macros={};var regular_rule_count=0;var simple_rule_count=0;// Assure all options are camelCased: +function prepareRules(dict,actions,caseHelper,tokens,startConditions,opts){let m,i,k,rule,action,conditions;let active_conditions;assert__default['default'](Array.isArray(dict.rules));let rules=dict.rules.slice(0);// shallow copy of the rules array as we MAY modify it in here! +let newRules=[];let macros={};let regular_rule_count=0;let simple_rule_count=0;// Assure all options are camelCased: assert__default['default'](typeof opts.options['case-insensitive']==='undefined');if(!tokens){tokens={};}if(opts.options.flex&&rules.length>0){rules.push(['.','console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']);}// Depending on the location within the regex we need different expansions of the macros: // one expansion for when a macro is *inside* a `[...]` and another expansion when a macro // is anywhere else in a regex: if(dict.macros){macros=prepareMacros(dict.macros,opts);}function tokenNumberReplacement(str,token){return'return '+(tokens[token]||'\''+token.replace(/'/g,'\\\'')+'\'');}// Make sure a comment does not contain any embedded '*/' end-of-comment marker // as that would break the generated code function postprocessComment(str){if(Array.isArray(str)){str=str.join(' ');}str=str.replace(/\*\//g,'*\\/');// destroy any inner `*/` comment terminator sequence. -return str;}var routingCode=['switch(yyrulenumber) {'];for(i=0;i0){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. -function reduceRegex(s,name,opts,expandAllMacrosInSet_cb,expandAllMacrosElsewhere_cb){var orig=s;function errinfo(){if(name){return'macro [['+name+']]';}else{return'regex [['+orig+']]';}}// propagate deferred exceptions = error reports. -if(s instanceof Error){return s;}var c1,c2;var rv=[];var derr;var se;while(s.length){c1=s.match(CHR_RE$1);if(!c1){// cope with illegal escape sequences too! -return new Error(errinfo()+': illegal escape sequence at start of regex part: '+s);}else{c1=c1[0];}s=s.substr(c1.length);switch(c1){case'[':// this is starting a set within the regex: scan until end of set! -var set_content=[];var l=new Array(UNICODE_BASE_PLANE_MAX_CP$1+1);while(s.length){var inner=s.match(SET_PART_RE$1);if(!inner){inner=s.match(CHR_RE$1);if(!inner){// cope with illegal escape sequences too! -return new Error(errinfo()+': illegal escape sequence at start of regex part: '+s);}else{inner=inner[0];}if(inner===']')break;}else{inner=inner[0];}set_content.push(inner);s=s.substr(inner.length);}// ensure that we hit the terminating ']': +function reduceRegex(s,name,opts,expandAllMacrosInSet_cb,expandAllMacrosElsewhere_cb){let orig=s;function errinfo(){if(name){return'macro [['+name+']]';}return'regex [['+orig+']]';}// propagate deferred exceptions = error reports. +if(s instanceof Error){return s;}let c1,c2;let rv=[];let derr;let se;while(s.length){c1=s.match(CHR_RE$1);if(!c1){// cope with illegal escape sequences too! +return new Error(errinfo()+': illegal escape sequence at start of regex part: '+s);}c1=c1[0];s=s.substr(c1.length);switch(c1){case'[':// this is starting a set within the regex: scan until end of set! +var set_content=[];var l=new Array(UNICODE_BASE_PLANE_MAX_CP$1+1);while(s.length){let inner=s.match(SET_PART_RE$1);if(!inner){inner=s.match(CHR_RE$1);if(!inner){// cope with illegal escape sequences too! +return new Error(errinfo()+': illegal escape sequence at start of regex part: '+s);}inner=inner[0];if(inner===']')break;}else{inner=inner[0];}set_content.push(inner);s=s.substr(inner.length);}// ensure that we hit the terminating ']': c2=s.match(CHR_RE$1);if(!c2){// cope with illegal escape sequences too! -return new Error(errinfo()+': regex set expression is broken: "'+s+'"');}else{c2=c2[0];}if(c2!==']'){return new Error(errinfo()+': regex set expression is broken: apparently unterminated');}s=s.substr(c2.length);se=set_content.join('');// expand any macros in here: +return new Error(errinfo()+': regex set expression is broken: "'+s+'"');}c2=c2[0];if(c2!==']'){return new Error(errinfo()+': regex set expression is broken: apparently unterminated');}s=s.substr(c2.length);se=set_content.join('');// expand any macros in here: if(expandAllMacrosInSet_cb){se=expandAllMacrosInSet_cb(se);assert__default['default'](se);if(se instanceof Error){return new Error(errinfo()+': '+se.message);}}derr=setmgmt.set2bitarray(l,se,opts);if(derr instanceof Error){return new Error(errinfo()+': '+derr.message);}// find out which set expression is optimal in size: var s1=setmgmt.produceOptimizedRegex4Set(l);// check if the source regex set potentially has any expansions (guestimate!) // @@ -3311,7 +3343,7 @@ case'\\p':c2=s.match(XREGEXP_UNICODE_ESCAPE_RE$1);if(c2){c2=c2[0];s=s.substr(c2. rv.push(c1+c2);}else{// nothing to stretch this match, hence nothing to expand. rv.push(c1);}break;// Either a range expression or the start of a macro reference: `.{1,3}` or `{NAME}`. // Treat it as a macro reference and see if it will expand to anything: -case'{':c2=s.match(NOTHING_SPECIAL_RE$1);if(c2){c2=c2[0];s=s.substr(c2.length);var c3=s[0];s=s.substr(c3.length);if(c3==='}'){// possibly a macro name in there... Expand if possible: +case'{':c2=s.match(NOTHING_SPECIAL_RE$1);if(c2){c2=c2[0];s=s.substr(c2.length);let c3=s[0];s=s.substr(c3.length);if(c3==='}'){// possibly a macro name in there... Expand if possible: c2=c1+c2+c3;if(expandAllMacrosElsewhere_cb){c2=expandAllMacrosElsewhere_cb(c2);assert__default['default'](c2);if(c2 instanceof Error){return new Error(errinfo()+': '+c2.message);}}}else{// not a well-terminated macro reference or something completely different: // we do not even attempt to expand this as there's guaranteed nothing to expand // in this bit. @@ -3327,11 +3359,11 @@ rv.push(c1+c2);}else{// nothing to stretch this match, hence nothing to expand. rv.push(c1);}break;}}s=rv.join('');// When this result is suitable for use in a set, than we should be able to compile // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: -try{var re;re=new XRegExp__default['default'](s);re.test(s[0]);}catch(ex){// make sure we produce a regex expression which will fail badly when it is used +try{let re;re=new XRegExp__default['default'](s);re.test(s[0]);}catch(ex){// make sure we produce a regex expression which will fail badly when it is used // in actual code: return new Error(errinfo()+': expands to an invalid regex: /'+s+'/');}assert__default['default'](s);return s;}// expand macros within macros and cache the result -function prepareMacros(dict_macros,opts){var macros={};// expand a `{NAME}` macro which exists inside a `[...]` set: -function expandMacroInSet(i){var k,a,m;if(!macros[i]){m=dict_macros[i];if(m.indexOf('{')>=0){// set up our own record so we can detect definition loops: +function prepareMacros(dict_macros,opts){let macros={};// expand a `{NAME}` macro which exists inside a `[...]` set: +function expandMacroInSet(i){let k,a,m;if(!macros[i]){m=dict_macros[i];if(m.indexOf('{')>=0){// set up our own record so we can detect definition loops: macros[i]={in_set:false,elsewhere:null,raw:dict_macros[i]};for(k in dict_macros){if(dict_macros.hasOwnProperty(k)&&i!==k){// it doesn't matter if the lexer recognized that the inner macro(s) // were sitting inside a `[...]` set or not: the fact that they are used // here in macro `i` which itself sits in a set, makes them *all* live in @@ -3343,18 +3375,18 @@ if(XRegExp__default['default']._getUnicodeProperty(k)){// Work-around so that yo // Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories, // while using `\p{ASCII}` as a *macro expansion* of the `ASCII` // macro: -if(k.toUpperCase()!==k){m=new Error('Cannot use name "'+k+'" as a macro name as it clashes with the same XRegExp "\\p{..}" Unicode \'General Category\' Property name. Use all-uppercase macro names, e.g. name your macro "'+k.toUpperCase()+'" to work around this issue or give your offending macro a different name.');break;}}a=m.split('{'+k+'}');if(a.length>1){var x=expandMacroInSet(k);assert__default['default'](x);if(x instanceof Error){m=x;break;}m=a.join(x);}}}}var mba=setmgmt.reduceRegexToSetBitArray(m,i,opts);var s1;// propagate deferred exceptions = error reports. +if(k.toUpperCase()!==k){m=new Error('Cannot use name "'+k+'" as a macro name as it clashes with the same XRegExp "\\p{..}" Unicode \'General Category\' Property name. Use all-uppercase macro names, e.g. name your macro "'+k.toUpperCase()+'" to work around this issue or give your offending macro a different name.');break;}}a=m.split('{'+k+'}');if(a.length>1){let x=expandMacroInSet(k);assert__default['default'](x);if(x instanceof Error){m=x;break;}m=a.join(x);}}}}let mba=setmgmt.reduceRegexToSetBitArray(m,i,opts);let s1;// propagate deferred exceptions = error reports. if(mba instanceof Error){s1=mba;}else{s1=setmgmt.bitarray2set(mba,false);m=s1;}macros[i]={in_set:s1,elsewhere:null,raw:dict_macros[i]};}else{m=macros[i].in_set;if(m instanceof Error){// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away! return new Error(m.message);}// detect definition loop: -if(m===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}}return m;}function expandMacroElsewhere(i){var m;if(macros[i].elsewhere==null){m=dict_macros[i];// set up our own record so we can detect definition loops: +if(m===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}}return m;}function expandMacroElsewhere(i){let m;if(macros[i].elsewhere==null){m=dict_macros[i];// set up our own record so we can detect definition loops: macros[i].elsewhere=false;// the macro MAY contain other macros which MAY be inside a `[...]` set in this // macro or elsewhere, hence we must parse the regex: m=reduceRegex(m,i,opts,expandAllMacrosInSet,expandAllMacrosElsewhere);// propagate deferred exceptions = error reports. if(m instanceof Error){return m;}macros[i].elsewhere=m;}else{m=macros[i].elsewhere;if(m instanceof Error){// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away! return m;}// detect definition loop: -if(m===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}}return m;}function expandAllMacrosInSet(s){var i,x;// process *all* the macros inside [...] set: -if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){var a=s.split('{'+i+'}');if(a.length>1){x=expandMacroInSet(i);assert__default['default'](x);if(x instanceof Error){return new Error('failure to expand the macro ['+i+'] in set ['+s+']: '+x.message);}s=a.join(x);}// stop the brute-force expansion attempt when we done 'em all: -if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s){var i,x;// When we process the remaining macro occurrences in the regex +if(m===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}}return m;}function expandAllMacrosInSet(s){let i,x;// process *all* the macros inside [...] set: +if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){let a=s.split('{'+i+'}');if(a.length>1){x=expandMacroInSet(i);assert__default['default'](x);if(x instanceof Error){return new Error('failure to expand the macro ['+i+'] in set ['+s+']: '+x.message);}s=a.join(x);}// stop the brute-force expansion attempt when we done 'em all: +if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s){let i,x;// When we process the remaining macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. // // Meanwhile the cached expansion will expand any submacros into @@ -3364,21 +3396,21 @@ if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s) // // This is a BREAKING CHANGE from vanilla jison 0.4.15! if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){// These are all submacro expansions, hence non-capturing grouping is applied: -var a=s.split('{'+i+'}');if(a.length>1){x=expandMacroElsewhere(i);assert__default['default'](x);if(x instanceof Error){return new Error('failure to expand the macro ['+i+'] in regex /'+s+'/: '+x.message);}s=a.join('(?:'+x+')');}// stop the brute-force expansion attempt when we done 'em all: -if(s.indexOf('{')===-1){break;}}}}return s;}var i;if(opts.debug)console.log('\n############## RAW macros: ',dict_macros);// first we create the part of the dictionary which is targeting the use of macros +let a=s.split('{'+i+'}');if(a.length>1){x=expandMacroElsewhere(i);assert__default['default'](x);if(x instanceof Error){return new Error('failure to expand the macro ['+i+'] in regex /'+s+'/: '+x.message);}s=a.join('(?:'+x+')');}// stop the brute-force expansion attempt when we done 'em all: +if(s.indexOf('{')===-1){break;}}}}return s;}let i;if(opts.debug)console.log('\n############## RAW macros: ',dict_macros);// first we create the part of the dictionary which is targeting the use of macros // *inside* `[...]` sets; once we have completed that half of the expansions work, // we then go and expand the macros for when they are used elsewhere in a regex: // iff we encounter submacros then which are used *inside* a set, we can use that // first half dictionary to speed things up a bit as we can use those expansions // straight away! for(i in dict_macros){if(dict_macros.hasOwnProperty(i)){expandMacroInSet(i);}}for(i in dict_macros){if(dict_macros.hasOwnProperty(i)){expandMacroElsewhere(i);}}if(opts.debug)console.log('\n############### expanded macros: ',macros);return macros;}// expand macros in a regex; expands them recursively -function expandMacros(src,macros,opts){var expansion_count=0;// By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! +function expandMacros(src,macros,opts){let expansion_count=0;// By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! // Hence things should be easy in there: -function expandAllMacrosInSet(s){var i,m,x;// process *all* the macros inside [...] set: -if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){m=macros[i];var a=s.split('{'+i+'}');if(a.length>1){x=m.in_set;assert__default['default'](x);if(x instanceof Error){// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away! +function expandAllMacrosInSet(s){let i,m,x;// process *all* the macros inside [...] set: +if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){m=macros[i];let a=s.split('{'+i+'}');if(a.length>1){x=m.in_set;assert__default['default'](x);if(x instanceof Error){// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away! throw x;}// detect definition loop: if(x===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}s=a.join(x);expansion_count++;}// stop the brute-force expansion attempt when we done 'em all: -if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s){var i,m,x;// When we process the main macro occurrences in the regex +if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s){let i,m,x;// When we process the main macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. // // Meanwhile the cached expansion will expand any submacros into @@ -3387,7 +3419,7 @@ if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s) // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! -if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){m=macros[i];var a=s.split('{'+i+'}');if(a.length>1){// These are all main macro expansions, hence CAPTURING grouping is applied: +if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){m=macros[i];let a=s.split('{'+i+'}');if(a.length>1){// These are all main macro expansions, hence CAPTURING grouping is applied: x=m.elsewhere;assert__default['default'](x);// detect definition loop: if(x===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}s=a.join('('+x+')');expansion_count++;}// stop the brute-force expansion attempt when we done 'em all: if(s.indexOf('{')===-1){break;}}}}return s;}// When we process the macro occurrences in the regex @@ -3399,7 +3431,7 @@ if(s.indexOf('{')===-1){break;}}}}return s;}// When we process the macro occurre // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! -var s2=reduceRegex(src,null,opts,expandAllMacrosInSet,expandAllMacrosElsewhere);// propagate deferred exceptions = error reports. +let s2=reduceRegex(src,null,opts,expandAllMacrosInSet,expandAllMacrosElsewhere);// propagate deferred exceptions = error reports. if(s2 instanceof Error){throw s2;}// only when we did expand some actual macros do we take the re-interpreted/optimized/regenerated regex from reduceRegex() // in order to keep our test cases simple and rules recognizable. This assumes the user can code good regexes on his own, // as long as no macros are involved... @@ -3407,8 +3439,8 @@ if(s2 instanceof Error){throw s2;}// only when we did expand some actual macros // Also pick the reduced regex when there (potentially) are XRegExp extensions in the original, e.g. `\\p{Number}`, // unless the `xregexp` output option has been enabled. if(expansion_count>0||src.indexOf('\\p{')>=0&&!opts.options.xregexp){src=s2;}else{// Check if the reduced regex is smaller in size; when it is, we still go with the new one! -if(s2.length0){toks[tokens[tok]]=idx;}}var gen=prepareRules(dict,actions,caseHelper,tokens&&toks,opts.conditions,opts);var code=actions.join('\n');'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function(yy){code=code.replace(new RegExp('\\b('+yy+')\\b','g'),'yy_.$1');});return{caseHelperInclude:'{\n'+caseHelper.join(',')+'\n}',actions:`function lexer__performAction(yy, yyrulenumber, YY_START) { +if(s2.length0){toks[tokens[tok]]=idx;}}let gen=prepareRules(dict,actions,caseHelper,tokens&&toks,opts.conditions,opts);let code=actions.join('\n');'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function(yy){code=code.replace(new RegExp('\\b('+yy+')\\b','g'),'yy_.$1');});return{caseHelperInclude:'{\n'+caseHelper.join(',')+'\n}',actions:`function lexer__performAction(yy, yyrulenumber, YY_START) { var yy_ = this; ${code} @@ -3418,7 +3450,7 @@ regular_rule_count:gen.regular_rule_count,simple_rule_count:gen.simple_rule_coun // jison/lib/jison.js @ line 2304:lrGeneratorMixin.generateErrorClass // function generateErrorClass(){// --- START lexer error class --- -var prelude=`/** +const prelude=`/** * 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 @@ -3429,8 +3461,6 @@ var prelude=`/** * @nocollapse */ function JisonLexerError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -3447,9 +3477,9 @@ function JisonLexerError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -3492,43 +3522,59 @@ return prelude;}const jisonLexerErrorDefinition=generateErrorClass();function ge fake.__hacky_backy__ = __hacky_counter__; return fake; } - `;}/** @constructor */function RegExpLexer(dict,input,tokens,build_options){var opts;var dump=false;function test_me(tweak_cb,description,src_exception,ex_callback){opts=processGrammar(dict,tokens,build_options);opts.__in_rules_failure_analysis_mode__=false;prepExportStructures(opts);assert__default['default'](opts.options);if(tweak_cb){tweak_cb();}var source=generateModuleBody(opts);try{// The generated code will always have the `lexer` variable declared at local scope + `;}/** @constructor */function RegExpLexer(dict,input,tokens,build_options){let opts;let dump=false;function test_me(tweak_cb,description,src_exception,ex_callback){opts=processGrammar(dict,tokens,build_options);opts.__in_rules_failure_analysis_mode__=false;prepExportStructures(opts);assert__default['default'](opts.options);if(tweak_cb){tweak_cb();}let source=generateModuleBody(opts);try{// The generated code will always have the `lexer` variable declared at local scope // as `eval()` will use the local scope. // // The compiled code will look something like this: // // ``` -// var lexer; +// let lexer; // bla bla... // ``` // // or // // ``` -// var lexer = { bla... }; +// const lexer = { bla... }; // ``` -var testcode=['// provide a local version for test purposes:',jisonLexerErrorDefinition,'',generateFakeXRegExpClassSrcCode(),'',source,'','return lexer;'].join('\n');var lexer=code_exec$1(testcode,function generated_code_exec_wrapper_regexp_lexer(sourcecode){//console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); -chkBugger$2(sourcecode);var lexer_f=new Function('',sourcecode);return lexer_f();},opts.options,"lexer");if(!lexer){throw new Error('no lexer defined *at all*?!');}if(typeof lexer.options!=='object'||lexer.options==null){throw new Error('your lexer class MUST have an .options member object or it won\'t fly!');}if(typeof lexer.setInput!=='function'){throw new Error('your lexer class MUST have a .setInput function member or it won\'t fly!');}if(lexer.EOF!==1&&lexer.ERROR!==2){throw new Error('your lexer class MUST have these constants defined: lexer.EOF = 1 and lexer.ERROR = 2 or it won\'t fly!');}// When we do NOT crash, we found/killed the problem area just before this call! -if(src_exception&&description){var msg=description;if(typeof description==='function'){msg=description();}src_exception.message+='\n ('+msg+')';}// patch the pre and post handlers in there, now that we have some live code to work with: -if(opts.options){var pre=opts.options.pre_lex;var post=opts.options.post_lex;// since JSON cannot encode functions, we'll have to do it manually now: -if(typeof pre==='function'){lexer.options.pre_lex=pre;}if(typeof post==='function'){lexer.options.post_lex=post;}}if(opts.options.showSource){if(typeof opts.options.showSource==='function'){opts.options.showSource(lexer,source,opts,RegExpLexer);}else{console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n",source,"\n----------------------------------------\n");}}return lexer;}catch(ex){// if (src_exception) { +let testcode=['// provide a local version for test purposes:',jisonLexerErrorDefinition,'',generateFakeXRegExpClassSrcCode(),'',source,'',rmCommonWS$2` + // JISON INJECTED VALIDATION CODE + // which attempts to ascertain you have defined a minimal viable lexer at least: + if (typeof lexer === "undefined") { + throw new SyntaxError("user-defined lexer does not define the required 'lexer' instance."); + } + if (!lexer) { + throw new SyntaxError("user-defined lexer does not define a non-NULL 'lexer' instance."); + } + if (typeof lexer.setInput !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.setInput()' API function."); + } + if (typeof lexer.lex !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.lex()' API function."); + } + // END OF JISON INJECTED VALIDATION CODE + `,'return lexer;'].join('\n');let lexer=code_exec(testcode,function generated_code_exec_wrapper_regexp_lexer(sourcecode){//console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); +chkBugger$2(sourcecode);let lexer_f=new Function('',sourcecode);return lexer_f();},Object.assign({},opts.options,{throwErrorOnCompileFailure:true}),'lexer');if(!lexer){throw new Error('no lexer defined *at all*?!');}if(typeof lexer.options!=='object'||lexer.options==null){throw new Error('your lexer class MUST have an .options member object or it won\'t fly!');}if(typeof lexer.setInput!=='function'){throw new Error('your lexer class MUST have a .setInput function member or it won\'t fly!');}if(lexer.EOF!==1&&lexer.ERROR!==2){throw new Error('your lexer class MUST have these constants defined: lexer.EOF = 1 and lexer.ERROR = 2 or it won\'t fly!');}// When we do NOT crash, we found/killed the problem area just before this call! +if(src_exception&&description){let msg=description;if(typeof description==='function'){msg=description();}src_exception.message+='\n ('+msg+')';}// patch the pre and post handlers in there, now that we have some live code to work with: +if(opts.options){let pre=opts.options.pre_lex;let post=opts.options.post_lex;// since JSON cannot encode functions, we'll have to do it manually now: +if(typeof pre==='function'){lexer.options.pre_lex=pre;}if(typeof post==='function'){lexer.options.post_lex=post;}}if(opts.options.showSource){if(typeof opts.options.showSource==='function'){opts.options.showSource(lexer,source,opts,RegExpLexer);}else{console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n',source,'\n----------------------------------------\n');}}return lexer;}catch(ex){// if (src_exception) { // src_exception.message += '\n (' + description + ': ' + ex.message + ')'; // } -if(ex_callback){ex_callback(ex);}else if(dump){console.log('source code:\n',source);}return false;}}/** @constructor */var lexer=test_me(null,null,null,function(ex){// When we get an exception here, it means some part of the user-specified lexer is botched. +if(ex_callback){ex_callback(ex);}else if(dump){console.log('source code:\n',source);}return false;}}/** @constructor */let lexer=test_me(null,null,null,function(ex){// When we get an exception here, it means some part of the user-specified lexer is botched. // // Now we go and try to narrow down the problem area/category: -assert__default['default'](opts.options);assert__default['default'](opts.options.xregexp!==undefined);var orig_xregexp_opt=!!opts.options.xregexp;if(!test_me(function(){assert__default['default'](opts.options.xregexp!==undefined);opts.options.xregexp=false;opts.showSource=false;},'When you have specified %option xregexp, you must also properly IMPORT the XRegExp library in the generated lexer.',ex,null)){if(!test_me(function(){// restore xregexp option setting: the trouble wasn't caused by the xregexp flag i.c.w. incorrect XRegExp library importing! -opts.options.xregexp=orig_xregexp_opt;opts.conditions=[];opts.showSource=false;},function(){assert__default['default'](Array.isArray(opts.rules));return opts.rules.length>0?'One or more of your lexer state names are possibly botched?':'Your custom lexer is somehow botched.';},ex,null)){var rulesSpecSize;if(!test_me(function(){// store the parsed rule set size so we can use that info in case +assert__default['default'](opts.options);assert__default['default'](opts.options.xregexp!==undefined);let orig_xregexp_opt=!!opts.options.xregexp;if(!test_me(function(){assert__default['default'](opts.options.xregexp!==undefined);opts.options.xregexp=false;opts.showSource=false;},'When you have specified %option xregexp, you must also properly IMPORT the XRegExp library in the generated lexer.',ex,null)){if(!test_me(function(){// restore xregexp option setting: the trouble wasn't caused by the xregexp flag i.c.w. incorrect XRegExp library importing! +opts.options.xregexp=orig_xregexp_opt;opts.conditions=[];opts.showSource=false;},function(){assert__default['default'](Array.isArray(opts.rules));return opts.rules.length>0?'One or more of your lexer state names are possibly botched?':'Your custom lexer is somehow botched.';},ex,null)){let rulesSpecSize;if(!test_me(function(){// store the parsed rule set size so we can use that info in case // this attempt also fails: assert__default['default'](Array.isArray(opts.rules));rulesSpecSize=opts.rules.length;// opts.conditions = []; opts.rules=[];opts.showSource=false;opts.__in_rules_failure_analysis_mode__=true;},'One or more of your lexer rules are possibly botched?',ex,null)){// kill each rule action block, one at a time and test again after each 'edit': -var rv=false;for(var i=0,len=rulesSpecSize;i= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -3755,8 +3792,6 @@ return`{ * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -3766,14 +3801,14 @@ return`{ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -3784,8 +3819,6 @@ return`{ * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -3793,40 +3826,40 @@ return`{ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -3838,7 +3871,7 @@ return`{ this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -3846,7 +3879,7 @@ return`{ last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -3907,9 +3940,7 @@ return`{ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -3928,8 +3959,6 @@ return`{ * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set \`done\` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -3938,7 +3967,7 @@ return`{ this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -3948,13 +3977,13 @@ return`{ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\\n') { lines = true; } else if (ch === '\\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\\n') { slice_len++; ch += ch2; @@ -3986,10 +4015,8 @@ return`{ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -4021,8 +4048,8 @@ return`{ // Get last entirely matched line into the \`pre_lines[]\` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -4040,9 +4067,9 @@ return`{ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -4052,14 +4079,12 @@ return`{ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -4070,8 +4095,6 @@ return`{ * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -4084,19 +4107,17 @@ return`{ * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the \`parseError()\` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // \`.lex()\` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -4109,8 +4130,6 @@ return`{ * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -4133,24 +4152,24 @@ return`{ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substr\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -4162,8 +4181,8 @@ return`{ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to \`maxSize\` (default: 20). @@ -4189,24 +4208,25 @@ return`{ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > \`lookAhead()\` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substring\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -4215,7 +4235,7 @@ return`{ } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -4234,10 +4254,8 @@ return`{ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^'; }, @@ -4259,15 +4277,13 @@ return`{ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -4398,58 +4414,54 @@ return`{ * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\\t/g, ' '); @@ -4458,13 +4470,13 @@ return`{ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -4486,15 +4498,13 @@ return`{ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -4506,8 +4516,8 @@ return`{ rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -4536,13 +4546,7 @@ return`{ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -4571,10 +4575,10 @@ return`{ }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -4602,7 +4606,7 @@ return`{ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -4613,7 +4617,7 @@ return`{ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -4635,8 +4639,6 @@ return`{ * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -4645,17 +4647,13 @@ return`{ this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -4665,67 +4663,75 @@ return`{ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that \`parseError()\` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) \`parseError()\` @@ -4752,9 +4758,7 @@ return`{ * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -4797,24 +4801,24 @@ return`{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -4834,9 +4838,7 @@ return`{ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -4846,24 +4848,24 @@ return`{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -4871,7 +4873,7 @@ return`{ this._clear_state = 0; } - + return r; }, @@ -4884,9 +4886,7 @@ return`{ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -4894,7 +4894,7 @@ return`{ (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -4909,8 +4909,6 @@ return`{ * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -4922,8 +4920,6 @@ return`{ * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -4937,15 +4933,12 @@ return`{ * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -4957,14 +4950,11 @@ return`{ * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -4975,16 +4965,14 @@ return`{ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -4994,8 +4982,6 @@ return`{ * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; } }`;// --- END lexer kernel --- @@ -5018,7 +5004,7 @@ function stripUnusedLexerCode(src,opt){// uses yyleng: ..................... $ // uses display APIs pastInput(), upcomingInput(), showPosition(): // ............................. ${opt.lexerActionsUseDisplayAPIs} // uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC} -var new_src;try{var ast=helpers.parseCodeChunkToAST(src,opt);new_src=helpers.prettyPrintAST(ast,opt);}catch(ex){let line=ex.lineNumber||0;let a=src.split(/\r?\n/g);let len=a.length;let minl=Math.max(0,line-10);let b=a.slice(minl,line+10);let c=b.splice(line-minl,0,"","^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^","");let offendingChunk=' '+b.join('\n ');console.error(rmCommonWS$2` +let new_src;try{let ast=helpers.parseCodeChunkToAST(src,opt);new_src=helpers.prettyPrintAST(ast,opt);}catch(ex){let line=ex.lineNumber||0;let a=src.split(/\r?\n/g);let len=a.length;let minl=Math.max(0,line-10);let b=a.slice(minl,line+10);let c=b.splice(line-minl,0,'','^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^','');let offendingChunk=' '+b.join('\n ');console.error(rmCommonWS$2` stripUnusedLexerCode WARNING: JISON failed to reformat the generated lexer. @@ -5074,8 +5060,8 @@ new_src=new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g,rmCommonWS$2 // --------- END OF REPORT ----------- `);return new_src;}// generate lexer source from a grammar -/** @public */function generate(dict,tokens,build_options){var opt=processGrammar(dict,tokens,build_options);return generateFromOpts(opt);}// process the grammar and build final data structures and functions -/** @public */function processGrammar(dict,tokens,build_options){build_options=build_options||{};var opts={// include the knowledge passed through `build_options` about which lexer +/** @public */function generate(dict,tokens,build_options){let opt=processGrammar(dict,tokens,build_options);return generateFromOpts(opt);}// process the grammar and build final data structures and functions +/** @public */function processGrammar(dict,tokens,build_options){build_options=build_options||{};let opts={// include the knowledge passed through `build_options` about which lexer // features will actually be *used* by the environment (which in 99.9% // of cases is a jison *parser*): // @@ -5088,22 +5074,22 @@ opts.lex_rule_dictionary=dict;// Always provide the lexer with an options object opts.options=mkStdOptions(build_options,dict.options);opts.moduleType=opts.options.moduleType;opts.moduleName=opts.options.moduleName;opts.conditions=prepareStartConditions(dict.startConditions);opts.conditions.INITIAL={rules:[],inclusive:true};// only produce rule action code blocks when there are any rules at all; // a "custom lexer" has ZERO rules and must be defined entirely in // other code blocks: -var code=dict.rules?buildActions(dict,tokens,opts):{};opts.performAction=code.actions;opts.caseHelperInclude=code.caseHelperInclude;opts.rules=code.rules||[];opts.macros=code.macros;opts.regular_rule_count=code.regular_rule_count;opts.simple_rule_count=code.simple_rule_count;opts.conditionStack=['INITIAL'];opts.actionInclude=dict.actionInclude||'';opts.moduleInclude=(opts.moduleInclude||'')+(dict.moduleInclude||'').trim();return opts;}// Assemble the final source from the processed grammar -/** @public */function generateFromOpts(opt){var code='';switch(opt.moduleType){case'js':code=generateModule(opt);break;case'amd':code=generateAMDModule(opt);break;case'es':code=generateESModule(opt);break;case'commonjs':code=generateCommonJSModule(opt);break;default:throw new Error('unsupported moduleType: '+opt.moduleType);}return code;}function generateRegexesInitTableCode(opt){var a=opt.rules;var print_xregexp=opt.options&&opt.options.xregexp;var id_display_width=1+Math.log10(a.length|1)|0;var ws_prefix=new Array(id_display_width).join(' ');var b=a.map(function generateXRegExpInitCode(re,idx){var idx_str=(ws_prefix+idx).substr(-id_display_width);if(re instanceof XRegExp__default['default']){// When we don't need the special XRegExp sauce at run-time, we do with the original +let code=dict.rules?buildActions(dict,tokens,opts):{};opts.performAction=code.actions;opts.caseHelperInclude=code.caseHelperInclude;opts.rules=code.rules||[];opts.macros=code.macros;opts.regular_rule_count=code.regular_rule_count;opts.simple_rule_count=code.simple_rule_count;opts.conditionStack=['INITIAL'];opts.actionInclude=dict.actionInclude||'';opts.moduleInclude=(opts.moduleInclude||'')+(dict.moduleInclude||'').trim();return opts;}// Assemble the final source from the processed grammar +/** @public */function generateFromOpts(opt){let code='';switch(opt.moduleType){case'js':code=generateModule(opt);break;case'amd':code=generateAMDModule(opt);break;case'es':code=generateESModule(opt);break;case'commonjs':code=generateCommonJSModule(opt);break;default:throw new Error('unsupported moduleType: '+opt.moduleType);}return code;}function generateRegexesInitTableCode(opt){let a=opt.rules;let print_xregexp=opt.options&&opt.options.xregexp;let id_display_width=1+Math.log10(a.length|1)|0;let ws_prefix=new Array(id_display_width).join(' ');let b=a.map(function generateXRegExpInitCode(re,idx){let idx_str=(ws_prefix+idx).substr(-id_display_width);if(re instanceof XRegExp__default['default']){// When we don't need the special XRegExp sauce at run-time, we do with the original // JavaScript RegExp instance a.k.a. 'native regex': if(re.xregexp.isNative||!print_xregexp){return`/* ${idx_str}: */ ${re}`;}// And make sure to escape the regex to make it suitable for placement inside a *string* // as it is passed as a string argument to the XRegExp constructor here. -var re_src=re.xregexp.source.replace(/[\\"]/g,'\\$&');return`/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`;}else{return`/* ${idx_str}: */ ${re}`;}});return b.join(',\n');}function generateModuleBody(opt){// make the JSON output look more like JavaScript: -function cleanupJSON(str){str=str.replace(/ "rules": \[/g,' rules: [');str=str.replace(/ "inclusive": /g,' inclusive: ');return str;}function produceOptions(opts){var obj={};var do_not_pass={debug:!opts.debug,// do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! -enableDebugLogs:1,json:1,_:1,noMain:1,dumpSourceCodeOnFailure:1,throwErrorOnCompileFailure:1,reportStats:1,file:1,outfile:1,inputPath:1,inputFilename:1,defaultModuleName:1,moduleName:1,moduleType:1,lexerErrorsAreRecoverable:0,flex:0,backtrack_lexer:0,caseInsensitive:0,showSource:1,exportAST:1,exportAllTables:1,exportSourceCode:1,prettyCfg:1,parseActionsUseYYLENG:1,parseActionsUseYYLINENO:1,parseActionsUseYYTEXT:1,parseActionsUseYYLOC:1,parseActionsUseParseError:1,parseActionsUseYYERROR:1,parseActionsUseYYRECOVERING:1,parseActionsUseYYERROK:1,parseActionsUseYYCLEARIN:1,parseActionsUseValueTracking:1,parseActionsUseValueAssignment:1,parseActionsUseLocationTracking:1,parseActionsUseLocationAssignment:1,parseActionsUseYYSTACK:1,parseActionsUseYYSSTACK:1,parseActionsUseYYSTACKPOINTER:1,parseActionsUseYYRULELENGTH:1,parseActionsUseYYMERGELOCATIONINFO:1,parserHasErrorRecovery:1,parserHasErrorReporting:1,lexerActionsUseYYLENG:1,lexerActionsUseYYLINENO:1,lexerActionsUseYYTEXT:1,lexerActionsUseYYLOC:1,lexerActionsUseParseError:1,lexerActionsUseYYERROR:1,lexerActionsUseLocationTracking:1,lexerActionsUseMore:1,lexerActionsUseUnput:1,lexerActionsUseReject:1,lexerActionsUseLess:1,lexerActionsUseDisplayAPIs:1,lexerActionsUseDescribeYYLOC:1};for(var k in opts){if(!do_not_pass[k]&&opts[k]!=null&&opts[k]!==false){// make sure numeric values are encoded as numeric, the rest as boolean/string. -if(typeof opts[k]==='string'){var f=parseFloat(opts[k]);if(f==opts[k]){obj[k]=f;continue;}}obj[k]=opts[k];}}// And now some options which should receive some special processing: -var pre=obj.pre_lex;var post=obj.post_lex;// since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: -if(pre){obj.pre_lex=true;}if(post){obj.post_lex=true;}var js=JSON.stringify(obj,null,2);js=js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$1})": `,'g'),' $1: ');js=js.replace(/^( +)pre_lex: true(,)?$/gm,function(m,ls,tc){return ls+'pre_lex: '+String(pre)+(tc||'');});js=js.replace(/^( +)post_lex: true(,)?$/gm,function(m,ls,tc){return ls+'post_lex: '+String(post)+(tc||'');});return js;}var out;if(opt.rules.length>0||opt.__in_rules_failure_analysis_mode__){// we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: +let re_src=re.xregexp.source.replace(/[\\"]/g,'\\$&');return`/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`;}return`/* ${idx_str}: */ ${re}`;});return b.join(',\n');}function generateModuleBody(opt){// make the JSON output look more like JavaScript: +function cleanupJSON(str){str=str.replace(/ {2}"rules": \[/g,' rules: [');str=str.replace(/ {2}"inclusive": /g,' inclusive: ');return str;}function produceOptions(opts){let obj={};const do_not_pass={debug:!opts.debug,// do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! +enableDebugLogs:1,json:1,_:1,noMain:1,dumpSourceCodeOnFailure:1,throwErrorOnCompileFailure:1,reportStats:1,file:1,outfile:1,inputPath:1,inputFilename:1,defaultModuleName:1,moduleName:1,moduleType:1,lexerErrorsAreRecoverable:0,flex:0,backtrack_lexer:0,caseInsensitive:0,showSource:1,exportAST:1,exportAllTables:1,exportSourceCode:1,prettyCfg:1,parseActionsUseYYLENG:1,parseActionsUseYYLINENO:1,parseActionsUseYYTEXT:1,parseActionsUseYYLOC:1,parseActionsUseParseError:1,parseActionsUseYYERROR:1,parseActionsUseYYRECOVERING:1,parseActionsUseYYERROK:1,parseActionsUseYYCLEARIN:1,parseActionsUseValueTracking:1,parseActionsUseValueAssignment:1,parseActionsUseLocationTracking:1,parseActionsUseLocationAssignment:1,parseActionsUseYYSTACK:1,parseActionsUseYYSSTACK:1,parseActionsUseYYSTACKPOINTER:1,parseActionsUseYYRULELENGTH:1,parseActionsUseYYMERGELOCATIONINFO:1,parserHasErrorRecovery:1,parserHasErrorReporting:1,lexerActionsUseYYLENG:1,lexerActionsUseYYLINENO:1,lexerActionsUseYYTEXT:1,lexerActionsUseYYLOC:1,lexerActionsUseParseError:1,lexerActionsUseYYERROR:1,lexerActionsUseLocationTracking:1,lexerActionsUseMore:1,lexerActionsUseUnput:1,lexerActionsUseReject:1,lexerActionsUseLess:1,lexerActionsUseDisplayAPIs:1,lexerActionsUseDescribeYYLOC:1};for(let k in opts){if(!do_not_pass[k]&&opts[k]!=null&&opts[k]!==false){// make sure numeric values are encoded as numeric, the rest as boolean/string. +if(typeof opts[k]==='string'){let f=parseFloat(opts[k]);if(f==opts[k]){obj[k]=f;continue;}}obj[k]=opts[k];}}// And now some options which should receive some special processing: +let pre=obj.pre_lex;let post=obj.post_lex;// since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: +if(pre){obj.pre_lex=true;}if(post){obj.post_lex=true;}let js=JSON.stringify(obj,null,2);js=js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$1})": `,'g'),' $1: ');js=js.replace(/^( +)pre_lex: true(,)?$/gm,function(m,ls,tc){return ls+'pre_lex: '+String(pre)+(tc||'');});js=js.replace(/^( +)post_lex: true(,)?$/gm,function(m,ls,tc){return ls+'post_lex: '+String(post)+(tc||'');});return js;}let out;if(opt.rules.length>0||opt.__in_rules_failure_analysis_mode__){// we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. -var code=[rmCommonWS$2` - var lexer = { - `,'/*JISON-LEX-ANALYTICS-REPORT*/'/* slot #1: placeholder for analysis report further below */];// get the RegExpLexer.prototype in source code form: -var protosrc=getRegExpLexerPrototype();// and strip off the surrounding bits we don't want: +let code=[rmCommonWS$2` + const lexer = { + `,'/* JISON-LEX-ANALYTICS-REPORT */\n'/* slot #1: placeholder for analysis report further below */];// get the RegExpLexer.prototype in source code form: +let protosrc=getRegExpLexerPrototype();// and strip off the surrounding bits we don't want: protosrc=protosrc.replace(/^[\s\r\n]*\{/,'').replace(/\s*\}[\s\r\n]*$/,'').trim();code.push(protosrc+',\n');assert__default['default'](opt.options);// Assure all options are camelCased: assert__default['default'](typeof opt.options['case-insensitive']==='undefined');code.push(' options: '+produceOptions(opt.options));/* function isEmpty(code) { @@ -5116,7 +5102,7 @@ assert__default['default'](typeof opt.options['case-insensitive']==='undefined') } } - */var performActionCode=String(opt.performAction);var simpleCaseActionClustersCode=String(opt.caseHelperInclude);var rulesCode=generateRegexesInitTableCode(opt);var conditionsCode=cleanupJSON(JSON.stringify(opt.conditions,null,2));code.push(rmCommonWS$2`, + */let performActionCode=String(opt.performAction);let simpleCaseActionClustersCode=String(opt.caseHelperInclude);let rulesCode=generateRegexesInitTableCode(opt);let conditionsCode=cleanupJSON(JSON.stringify(opt.conditions,null,2));code.push(rmCommonWS$2`, JisonLexerError: JisonLexerError, performAction: ${performActionCode}, simpleCaseActionClusters: ${simpleCaseActionClustersCode}, @@ -5129,18 +5115,16 @@ assert__default['default'](typeof opt.options['case-insensitive']==='undefined') // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // -// Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter +// Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. -out='var lexer;\n';assert__default['default'](opt.regular_rule_count===0);assert__default['default'](opt.simple_rule_count===0);opt.is_custom_lexer=true;if(opt.actionInclude){out+=opt.actionInclude+(!opt.actionInclude.match(/;[\s\r\n]*$/)?';':'')+'\n';}}// The output of this function is guaranteed to read something like this: +out='\n';assert__default['default'](opt.regular_rule_count===0);assert__default['default'](opt.simple_rule_count===0);opt.is_custom_lexer=true;if(opt.actionInclude){out+=opt.actionInclude+(!opt.actionInclude.match(/;[\s\r\n]*$/)?';':'')+'\n';}}// The output of this function is guaranteed to read something like this: // // ``` -// var lexer; -// // bla bla bla bla ... lotsa bla bla; // ``` // // and that should work nicely as an `eval()`-able piece of source code. -return out;}function generateGenericHeaderComment(){var out=rmCommonWS$2` +return out;}function generateGenericHeaderComment(){let out=rmCommonWS$2` /* lexer generated by jison-lex ${version} */ /* @@ -5359,8 +5343,8 @@ return out;}function generateGenericHeaderComment(){var out=rmCommonWS$2` * } */ `;return out;}function prepareOptions(opt){opt=opt||{};// check for illegal identifier -if(!opt.moduleName||!opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)){if(opt.moduleName){var msg='WARNING: The specified moduleName "'+opt.moduleName+'" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.';if(typeof opt.warn_cb==='function'){opt.warn_cb(msg);}else{// do not treat as warning; barf hairball instead so that this oddity gets noticed right away! -throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return opt;}function generateModule(opt){opt=prepareOptions(opt);var modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';var src=rmCommonWS$2` +if(!opt.moduleName||!opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)){if(opt.moduleName){let msg='WARNING: The specified moduleName "'+opt.moduleName+'" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.';if(typeof opt.warn_cb==='function'){opt.warn_cb(msg);}else{// do not treat as warning; barf hairball instead so that this oddity gets noticed right away! +throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return opt;}function generateModule(opt){opt=prepareOptions(opt);let modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';let src=rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -5374,7 +5358,7 @@ throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return return lexer; })(); - `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateAMDModule(opt){opt=prepareOptions(opt);var modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';var src=rmCommonWS$2` + `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateAMDModule(opt){opt=prepareOptions(opt);let modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';let src=rmCommonWS$2` ${generateGenericHeaderComment()} define([], function () { @@ -5388,10 +5372,10 @@ throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return return lexer; }); - `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateESModule(opt){opt=prepareOptions(opt);var modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';var src=rmCommonWS$2` + `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateESModule(opt){opt=prepareOptions(opt);let modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';let src=rmCommonWS$2` ${generateGenericHeaderComment()} - var lexer = (function () { + const lexer = (function () { "use strict"; ${jisonLexerErrorDefinition} @@ -5411,7 +5395,7 @@ throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return lexer, yylex as lex }; - `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateCommonJSModule(opt){opt=prepareOptions(opt);var modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';var src=rmCommonWS$2` + `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateCommonJSModule(opt){opt=prepareOptions(opt);let modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';let src=rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -5432,21 +5416,21 @@ throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return return ${opt.moduleName}.lex.apply(lexer, arguments); }; } - `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}RegExpLexer.generate=generate;RegExpLexer.version=version;RegExpLexer.defaultJisonLexOptions=defaultJisonLexOptions;RegExpLexer.mkStdOptions=mkStdOptions;RegExpLexer.camelCase=helpers.camelCase;RegExpLexer.mkIdentifier=mkIdentifier$2;RegExpLexer.autodetectAndConvertToJSONformat=autodetectAndConvertToJSONformat;var mkIdentifier$3=helpers.mkIdentifier;var version$1='0.6.2-220';// require('./package.json').version; -function getCommandlineOptions(){var opts=nomnom__default['default'].script('jison-lex').unknownOptionTreatment(false)// do not accept unknown options! -.options({file:{flag:true,position:0,help:'file containing a lexical grammar.'},json:{abbr:'j',flag:true,default:false,help:'jison will expect a grammar in either JSON/JSON5 or JISON format: the precise format is autodetected.'},outfile:{abbr:'o',metavar:'FILE',help:'Filepath and base module name of the generated parser. When terminated with a "/" (dir separator) it is treated as the destination directory where the generated output will be stored.'},debug:{abbr:'t',flag:true,default:false,help:'Debug mode.'},dumpSourceCodeOnFailure:{full:'dump-sourcecode-on-failure',flag:true,default:true,help:'Dump the generated source code to a special named file when the internal generator tests fail, i.e. when the generated source code does not compile in the JavaScript engine. Enabling this option helps you to diagnose/debug crashes (thrown exceptions) in the code generator due to various reasons: you can, for example, load the dumped sourcecode in another environment (e.g. NodeJS) to get more info on the precise location and cause of the compile failure.'},throwErrorOnCompileFailure:{full:'throw-on-compile-failure',flag:true,default:true,help:'Throw an exception when the generated source code fails to compile in the JavaScript engine. **WARNING**: Turning this feature OFF permits the code generator to produce non-working source code and treat that as SUCCESS. This MAY be desirable code generator behaviour, but only rarely.'},reportStats:{full:'info',abbr:'I',flag:true,default:false,help:'Report some statistics about the generated parser.'},moduleType:{full:'module-type',abbr:'m',default:'commonjs',metavar:'TYPE',choices:['commonjs','amd','js','es'],help:'The type of module to generate (commonjs, amd, es, js)'},moduleName:{full:'module-name',abbr:'n',metavar:'NAME',help:'The name of the generated parser object, namespace supported.'},main:{full:'main',abbr:'x',flag:true,default:false,help:'Include .main() entry point in generated commonjs module.'},moduleMain:{full:'module-main',abbr:'y',metavar:'NAME',help:'The main module function definition.'},version:{abbr:'V',flag:true,help:'Print version and exit.',callback:function(){console.log(version$1);process.exit(0);}}}).parse();if(opts.debug){console.log("JISON-LEX CLI options:\n",opts);}return opts;}function cliMain(opts){opts=RegExpLexer.mkStdOptions(opts);function isDirectory(fp){try{return fs__default['default'].lstatSync(fp).isDirectory();}catch(e){return false;}}function mkdirp(fp){if(!fp||fp==='.'||fp.length===0){return false;}try{fs__default['default'].mkdirSync(fp);return true;}catch(e){if(e.code==='ENOENT'){var parent=path__default['default'].dirname(fp);// Did we hit the root directory by now? If so, abort! + `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}RegExpLexer.generate=generate;RegExpLexer.version=version;RegExpLexer.defaultJisonLexOptions=defaultJisonLexOptions;RegExpLexer.mkStdOptions=mkStdOptions;RegExpLexer.camelCase=helpers.camelCase;RegExpLexer.mkIdentifier=mkIdentifier$2;RegExpLexer.autodetectAndConvertToJSONformat=autodetectAndConvertToJSONformat;const mkIdentifier$3=helpers.mkIdentifier;const version$1='0.6.2-220';// require('./package.json').version; +function getCommandlineOptions(){let opts=nomnom__default['default'].script('jison-lex').unknownOptionTreatment(false)// do not accept unknown options! +.options({file:{flag:true,position:0,help:'file containing a lexical grammar.'},json:{abbr:'j',flag:true,default:false,help:'jison will expect a grammar in either JSON/JSON5 or JISON format: the precise format is autodetected.'},outfile:{abbr:'o',metavar:'FILE',help:'Filepath and base module name of the generated parser. When terminated with a "/" (dir separator) it is treated as the destination directory where the generated output will be stored.'},debug:{abbr:'t',flag:true,default:false,help:'Debug mode.'},dumpSourceCodeOnFailure:{full:'dump-sourcecode-on-failure',flag:true,default:true,help:'Dump the generated source code to a special named file when the internal generator tests fail, i.e. when the generated source code does not compile in the JavaScript engine. Enabling this option helps you to diagnose/debug crashes (thrown exceptions) in the code generator due to various reasons: you can, for example, load the dumped sourcecode in another environment (e.g. NodeJS) to get more info on the precise location and cause of the compile failure.'},throwErrorOnCompileFailure:{full:'throw-on-compile-failure',flag:true,default:true,help:'Throw an exception when the generated source code fails to compile in the JavaScript engine. **WARNING**: Turning this feature OFF permits the code generator to produce non-working source code and treat that as SUCCESS. This MAY be desirable code generator behaviour, but only rarely.'},reportStats:{full:'info',abbr:'I',flag:true,default:false,help:'Report some statistics about the generated parser.'},moduleType:{full:'module-type',abbr:'m',default:'commonjs',metavar:'TYPE',choices:['commonjs','amd','js','es'],help:'The type of module to generate (commonjs, amd, es, js)'},moduleName:{full:'module-name',abbr:'n',metavar:'NAME',help:'The name of the generated parser object, namespace supported.'},main:{full:'main',abbr:'x',flag:true,default:false,help:'Include .main() entry point in generated commonjs module.'},moduleMain:{full:'module-main',abbr:'y',metavar:'NAME',help:'The main module function definition.'},version:{abbr:'V',flag:true,help:'Print version and exit.',callback:function(){console.log(version$1);process.exit(0);}}}).parse();if(opts.debug){console.log('JISON-LEX CLI options:\n',opts);}return opts;}function cliMain(opts){opts=RegExpLexer.mkStdOptions(opts);function isDirectory(fp){try{return fs__default['default'].lstatSync(fp).isDirectory();}catch(e){return false;}}function mkdirp(fp){if(!fp||fp==='.'||fp.length===0){return false;}try{fs__default['default'].mkdirSync(fp);return true;}catch(e){if(e.code==='ENOENT'){let parent=path__default['default'].dirname(fp);// Did we hit the root directory by now? If so, abort! // Else, create the parent; iff that fails, we fail too... if(parent!==fp&&mkdirp(parent)){try{// Retry creating the original directory: it should succeed now -fs__default['default'].mkdirSync(fp);return true;}catch(e){return false;}}}}return false;}function processInputFile(){var original_cwd=process.cwd();var raw=fs__default['default'].readFileSync(path__default['default'].normalize(opts.file),'utf8');// making best guess at json mode +fs__default['default'].mkdirSync(fp);return true;}catch(e){return false;}}}}return false;}function processInputFile(){let original_cwd=process.cwd();let raw=fs__default['default'].readFileSync(path__default['default'].normalize(opts.file),'utf8');// making best guess at json mode opts.json=path__default['default'].extname(opts.file)==='.json'||opts.json;// When only the directory part of the output path was specified, then we // do NOT have the target module name in there as well! -var outpath=opts.outfile;if(typeof outpath==='string'){if(/[\\\/]$/.test(outpath)||isDirectory(outpath)){opts.outfile=null;outpath=outpath.replace(/[\\\/]$/,'');}else{outpath=path__default['default'].dirname(outpath);}}else{outpath=null;}if(outpath&&outpath.length>0){outpath+='/';}else{outpath='';}// setting output file name and module name based on input file name +let outpath=opts.outfile;if(typeof outpath==='string'){if(/[\\\/]$/.test(outpath)||isDirectory(outpath)){opts.outfile=null;outpath=outpath.replace(/[\\\/]$/,'');}else{outpath=path__default['default'].dirname(outpath);}}else{outpath=null;}if(outpath&&outpath.length>0){outpath+='/';}else{outpath='';}// setting output file name and module name based on input file name // if they aren't specified. -var name=path__default['default'].basename(opts.outfile||opts.file);// get the base name (i.e. the file name without extension) +let name=path__default['default'].basename(opts.outfile||opts.file);// get the base name (i.e. the file name without extension) // i.e. strip off only the extension and keep any other dots in the filename name=path__default['default'].basename(name,path__default['default'].extname(name));opts.outfile=opts.outfile||outpath+name+'.js';if(!opts.moduleName&&name){opts.moduleName=opts.defaultModuleName=mkIdentifier$3(name);}// Change CWD to the directory where the source grammar resides: this helps us properly // %include any files mentioned in the grammar with relative paths: -var new_cwd=path__default['default'].dirname(path__default['default'].normalize(opts.file));process.chdir(new_cwd);var lexer=cli.generateLexerString(raw,opts);// and change back to the CWD we started out with: -process.chdir(original_cwd);opts.outfile=path__default['default'].normalize(opts.outfile);mkdirp(path__default['default'].dirname(opts.outfile));fs__default['default'].writeFileSync(opts.outfile,lexer);console.log('JISON-LEX output for module ['+opts.moduleName+'] has been written to file:',opts.outfile);}function readin(cb){var stdin=process.openStdin(),data='';stdin.setEncoding('utf8');stdin.addListener('data',function(chunk){data+=chunk;});stdin.addListener('end',function(){cb(data);});}function processStdin(){readin(function processStdinReadInCallback(raw){console.log(cli.generateLexerString(raw,opts));});}// if an input file wasn't given, assume input on stdin +let new_cwd=path__default['default'].dirname(path__default['default'].normalize(opts.file));process.chdir(new_cwd);let lexer=cli.generateLexerString(raw,opts);// and change back to the CWD we started out with: +process.chdir(original_cwd);opts.outfile=path__default['default'].normalize(opts.outfile);mkdirp(path__default['default'].dirname(opts.outfile));fs__default['default'].writeFileSync(opts.outfile,lexer);console.log('JISON-LEX output for module ['+opts.moduleName+'] has been written to file:',opts.outfile);}function readin(cb){const stdin=process.openStdin();let data='';stdin.setEncoding('utf8');stdin.addListener('data',function(chunk){data+=chunk;});stdin.addListener('end',function(){cb(data);});}function processStdin(){readin(function processStdinReadInCallback(raw){console.log(cli.generateLexerString(raw,opts));});}// if an input file wasn't given, assume input on stdin if(opts.file){processInputFile();}else{processStdin();}}function generateLexerString(lexerSpec,opts){// var settings = RegExpLexer.mkStdOptions(opts); -var predefined_tokens=null;return RegExpLexer.generate(lexerSpec,predefined_tokens,opts);}var cli={main:cliMain,generateLexerString:generateLexerString};if(require.main===module){var opts=getCommandlineOptions();cli.main(opts);}return cli;}); +let predefined_tokens=null;return RegExpLexer.generate(lexerSpec,predefined_tokens,opts);}var cli={main:cliMain,generateLexerString:generateLexerString};if(require.main===module){const opts=getCommandlineOptions();cli.main(opts);}return cli;}); diff --git a/packages/jison-lex/dist/cli-umd.js b/packages/jison-lex/dist/cli-umd.js index d99fe275f..b95473653 100644 --- a/packages/jison-lex/dist/cli-umd.js +++ b/packages/jison-lex/dist/cli-umd.js @@ -2,10 +2,10 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('fs'), require('path'), require('@gerhobbelt/nomnom'), require('@gerhobbelt/json5'), require('@gerhobbelt/xregexp'), require('recast'), require('@babel/core'), require('assert')) : - typeof define === 'function' && define.amd ? define(['fs', 'path', '@gerhobbelt/nomnom', '@gerhobbelt/json5', '@gerhobbelt/xregexp', 'recast', '@babel/core', 'assert'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['jison-lex'] = factory(global.fs, global.path$1, global.nomnom, global.JSON5, global.XRegExp, global.recast, global.babel, global.assert$1)); -}(this, (function (fs, path$1, nomnom, JSON5, XRegExp, recast, babel, assert$1) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('fs'), require('path'), require('@gerhobbelt/nomnom'), require('@gerhobbelt/json5'), require('mkdirp'), require('@gerhobbelt/xregexp'), require('recast'), require('@babel/core'), require('assert')) : + typeof define === 'function' && define.amd ? define(['fs', 'path', '@gerhobbelt/nomnom', '@gerhobbelt/json5', 'mkdirp', '@gerhobbelt/xregexp', 'recast', '@babel/core', 'assert'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['jison-lex'] = factory(global.fs, global.path$1, global.nomnom, global.JSON5, global.mkdirp, global.XRegExp, global.recast, global.babel, global.assert$1)); +}(this, (function (fs, path$1, nomnom, JSON5, mkdirp, XRegExp, recast, babel, assert$1) { 'use strict'; function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } @@ -13,11 +13,12 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); var nomnom__default = /*#__PURE__*/_interopDefaultLegacy(nomnom); var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); + var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); - // Return TRUE if `src` starts with `searchString`. + // Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -40,19 +41,19 @@ // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -71,19 +72,21 @@ // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -92,16 +95,19 @@ } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -112,27 +118,79 @@ return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } + // https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words + const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; + })([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' + ]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -150,6 +208,11 @@ .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -158,13 +221,13 @@ function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -175,23 +238,17 @@ break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -214,34 +271,33 @@ /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -264,28 +320,76 @@ // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } + function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; + } + + + function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); + } + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -296,27 +400,37 @@ dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -326,7 +440,7 @@ } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -334,7 +448,7 @@ ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -360,27 +474,43 @@ // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -393,9 +523,10 @@ - var code_exec = { + var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -417,22 +548,22 @@ // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; - // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries + // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; - // Determine which Unicode NonAsciiIdentifierStart characters + // Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. - // + // // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action - // code chunks. - // + // code chunks. + // // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -440,40 +571,40 @@ function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -481,30 +612,30 @@ // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -515,59 +646,59 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -609,38 +740,38 @@ return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -652,18 +783,18 @@ // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -674,56 +805,56 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -731,97 +862,97 @@ typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -829,7 +960,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -842,7 +973,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -855,7 +986,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -868,7 +999,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -887,37 +1018,37 @@ let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -949,7 +1080,7 @@ // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -966,37 +1097,37 @@ .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return babel.transformSync(src, options); // => { code, map, ast } @@ -1004,8 +1135,8 @@ function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1014,7 +1145,7 @@ // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1037,25 +1168,25 @@ // validate the given JISON+JavaScript snippet: does it compile? - // - // Return either the parsed AST (object) or an error message (string). + // + // Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1066,9 +1197,9 @@ // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. - // + // // Returns the trimmed sourcecode which was provided via `src`. - // + // // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1076,7 +1207,7 @@ // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: - // + // // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1085,14 +1216,14 @@ // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} - // + // // Of course the example would be 'ludicrous' action code but the - // key point here is that users will certainly be able to come up with + // key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! - // + // function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1146,7 +1277,7 @@ trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1160,7 +1291,7 @@ /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1172,24 +1303,24 @@ /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. - /// + /// /// Also supports ES6's Arrow Functions: - /// + /// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' - /// + /// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1206,8 +1337,8 @@ if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1218,14 +1349,14 @@ action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1236,17 +1367,17 @@ var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; - // - // - // + // + // + // function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1272,7 +1403,7 @@ // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1320,7 +1451,7 @@ // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1383,13 +1514,13 @@ getRegExpInfo: getRegExpInfo }; - var cycleref = []; - var cyclerefpath = []; + let cycleref = []; + let cyclerefpath = []; - var linkref = []; - var linkrefpath = []; + let linkref = []; + let linkrefpath = []; - var path = []; + let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1397,14 +1528,14 @@ return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1417,11 +1548,11 @@ function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1434,9 +1565,9 @@ dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1451,16 +1582,52 @@ } + // strip developer machine specific parts off any paths in a given stacktrace (string) + // to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } + // strip off the line/position info from any stacktrace as a assert.deepEqual() on these + // will otherwise FAIL due to us running this stuff through both regular `node` and + // the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing + // exceptions and stacktraces which point completely somewhere else and this would b0rk + // our test rigs for the jison subpackages. + function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; + } + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1475,7 +1642,7 @@ function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1501,10 +1668,10 @@ } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1602,7 +1769,7 @@ function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1619,7 +1786,7 @@ path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1647,7 +1814,7 @@ function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1663,7 +1830,7 @@ linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1675,14 +1842,14 @@ // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. - // + // // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1692,7 +1859,7 @@ cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1706,12 +1873,14 @@ dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1726,7 +1895,7 @@ printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; // See also: @@ -1734,7 +1903,6 @@ // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1751,9 +1919,9 @@ this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -1786,10 +1954,10 @@ // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -1802,11 +1970,11 @@ // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -1816,18 +1984,18 @@ // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -1858,7 +2026,7 @@ // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -1875,9 +2043,9 @@ // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -1890,7 +2058,7 @@ } - var parser = { + let parser = { // Code Generator Information Report // --------------------------------- // @@ -2140,7 +2308,6 @@ // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2148,7 +2315,6 @@ // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2160,8 +2326,8 @@ // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2174,14 +2340,13 @@ // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2197,10 +2362,10 @@ // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2208,10 +2373,10 @@ this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2366,9 +2531,9 @@ /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -2380,18 +2545,18 @@ case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2421,9 +2586,9 @@ case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -2436,10 +2601,10 @@ case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2466,9 +2631,9 @@ case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -2477,10 +2642,10 @@ case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2508,9 +2673,9 @@ case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -2519,10 +2684,10 @@ case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -2561,9 +2726,9 @@ case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2628,9 +2793,9 @@ case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2645,9 +2810,9 @@ case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -2682,10 +2847,10 @@ case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2702,9 +2867,9 @@ case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2721,10 +2886,10 @@ case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2741,9 +2906,9 @@ case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2760,10 +2925,10 @@ case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2780,9 +2945,9 @@ case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -2806,9 +2971,9 @@ case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -2819,9 +2984,9 @@ case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2841,9 +3006,9 @@ case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2867,9 +3032,9 @@ case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2882,10 +3047,10 @@ case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2902,9 +3067,9 @@ case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2916,9 +3081,9 @@ case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -2958,10 +3123,10 @@ case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2981,9 +3146,9 @@ case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3033,10 +3198,10 @@ case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -3060,10 +3225,10 @@ case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3083,10 +3248,10 @@ case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3110,10 +3275,10 @@ case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3134,10 +3299,10 @@ case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3149,10 +3314,10 @@ case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3162,10 +3327,10 @@ case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3175,10 +3340,10 @@ case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3188,10 +3353,10 @@ case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3201,10 +3366,10 @@ case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -3214,10 +3379,10 @@ case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3227,10 +3392,10 @@ case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3240,9 +3405,9 @@ case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -3251,9 +3416,9 @@ case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -3262,9 +3427,9 @@ case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3286,9 +3451,9 @@ case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3299,9 +3464,9 @@ case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3321,9 +3486,9 @@ case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3377,9 +3542,9 @@ case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3399,9 +3564,9 @@ case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -3410,9 +3575,9 @@ case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -3424,9 +3589,9 @@ case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -3440,10 +3605,10 @@ case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3463,10 +3628,10 @@ case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3486,10 +3651,10 @@ case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3509,9 +3674,9 @@ case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3522,9 +3687,9 @@ case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3543,9 +3708,9 @@ case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -3586,9 +3751,9 @@ case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3612,9 +3777,9 @@ case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3640,9 +3805,9 @@ case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3687,9 +3852,9 @@ case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -3715,9 +3880,9 @@ case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -3726,9 +3891,9 @@ case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -3737,10 +3902,10 @@ case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3754,10 +3919,10 @@ case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3771,10 +3936,10 @@ case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3788,10 +3953,10 @@ case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3810,9 +3975,9 @@ case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -3821,9 +3986,9 @@ case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -3861,10 +4026,10 @@ case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -3888,9 +4053,9 @@ case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -3969,9 +4134,9 @@ case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -3980,9 +4145,9 @@ case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -3991,9 +4156,9 @@ case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -4002,9 +4167,9 @@ case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -4013,9 +4178,9 @@ case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -4024,9 +4189,9 @@ case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -4035,9 +4200,9 @@ case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -4048,10 +4213,10 @@ case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4068,9 +4233,9 @@ case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -4079,9 +4244,9 @@ case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -4090,9 +4255,9 @@ case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -4101,9 +4266,9 @@ case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -4112,9 +4277,9 @@ case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -4133,18 +4298,18 @@ case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -4153,9 +4318,9 @@ case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -4164,9 +4329,9 @@ case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -4175,9 +4340,9 @@ case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -4186,9 +4351,9 @@ case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -4197,10 +4362,10 @@ case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4217,9 +4382,9 @@ case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -4236,9 +4401,9 @@ case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -4250,9 +4415,9 @@ case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -4262,9 +4427,9 @@ case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4299,9 +4464,9 @@ case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4320,9 +4485,9 @@ case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -4331,9 +4496,9 @@ case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -4342,9 +4507,9 @@ case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4362,10 +4527,10 @@ case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -4383,10 +4548,10 @@ case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -4407,9 +4572,9 @@ case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4442,9 +4607,9 @@ case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4470,9 +4635,9 @@ case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5__default['default'].parse(yyvstack[yysp]); @@ -4481,9 +4646,9 @@ case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue(yyvstack[yysp]); @@ -4492,9 +4657,9 @@ case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4503,9 +4668,9 @@ case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -4526,10 +4691,10 @@ case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4546,9 +4711,9 @@ case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -4567,9 +4732,9 @@ case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4593,9 +4758,9 @@ case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -4615,9 +4780,9 @@ case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4628,9 +4793,9 @@ case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -4686,10 +4851,10 @@ case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6292,7 +6457,6 @@ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -6309,38 +6473,34 @@ } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -6348,20 +6508,18 @@ pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -6383,7 +6541,6 @@ // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -6391,18 +6548,19 @@ if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -6410,24 +6568,19 @@ // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -6465,18 +6618,15 @@ - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); + let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -6497,7 +6647,7 @@ // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -6515,7 +6665,6 @@ // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -6528,7 +6677,6 @@ // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -6542,11 +6690,10 @@ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -6600,8 +6747,8 @@ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6609,8 +6756,8 @@ this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6642,19 +6789,18 @@ // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -6665,7 +6811,7 @@ if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -6678,7 +6824,7 @@ if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -6690,29 +6836,27 @@ // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -6720,7 +6864,7 @@ l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -6740,8 +6884,7 @@ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -6750,10 +6893,10 @@ token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -6761,7 +6904,7 @@ location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -6772,9 +6915,14 @@ // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -6790,8 +6938,7 @@ // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -6860,11 +7007,14 @@ // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -6875,8 +7025,7 @@ }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -6885,21 +7034,20 @@ function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6909,21 +7057,20 @@ } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6932,28 +7079,27 @@ return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -6966,8 +7112,7 @@ - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; + const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -6990,8 +7135,7 @@ - - if (symbol === EOF) { + if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -7003,8 +7147,7 @@ - - --stack_probe; // popStack(1): [symbol, action] + --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -7021,8 +7164,7 @@ - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -7036,8 +7178,7 @@ - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } @@ -7051,7 +7192,7 @@ // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -7104,16 +7245,13 @@ - - - - // handle parse error + // handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -7147,9 +7285,7 @@ - - - r = this.parseError(p.errStr, p, this.JisonParserError); + r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -7172,9 +7308,7 @@ - - - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -7201,17 +7335,16 @@ - - } + } // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -7258,8 +7391,8 @@ recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -7271,8 +7404,7 @@ - - } else { + } else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -7290,6 +7422,7 @@ yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -7298,7 +7431,7 @@ - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -7309,7 +7442,7 @@ sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -7369,10 +7502,10 @@ // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -7407,9 +7540,7 @@ - - - // encountered another parse error? If so, break out to main loop + // encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -7422,7 +7553,7 @@ - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -7443,9 +7574,7 @@ - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7467,12 +7596,12 @@ // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -7481,7 +7610,7 @@ ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7522,7 +7651,7 @@ } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -7569,7 +7698,7 @@ // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -7587,21 +7716,19 @@ - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7635,14 +7762,15 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7652,6 +7780,7 @@ + } continue; // accept: @@ -7703,7 +7832,7 @@ // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -7719,9 +7848,7 @@ - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7750,7 +7877,7 @@ sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7767,8 +7894,8 @@ symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -7779,8 +7906,8 @@ // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -7792,21 +7919,19 @@ - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7837,14 +7962,15 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7854,6 +7980,7 @@ + } continue; // accept: @@ -7906,8 +8033,7 @@ // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -8168,7 +8294,6 @@ * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -8185,10 +8310,10 @@ }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -8220,7 +8345,7 @@ JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -8262,7 +8387,9 @@ // // --------- END OF REPORT ----------- - EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -8348,7 +8475,7 @@ if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -8356,7 +8483,7 @@ msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -8369,7 +8496,7 @@ } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -8395,10 +8522,13 @@ * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -8421,7 +8551,6 @@ * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -8444,16 +8573,16 @@ * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -8475,7 +8604,6 @@ * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -8483,8 +8611,8 @@ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -8513,7 +8641,7 @@ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -8538,7 +8666,7 @@ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -8550,17 +8678,17 @@ } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -8654,7 +8782,7 @@ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -8675,7 +8803,6 @@ * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -8686,7 +8813,7 @@ this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -8697,15 +8824,15 @@ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -8739,8 +8866,8 @@ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -8773,9 +8900,9 @@ // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -8794,9 +8921,9 @@ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -8806,8 +8933,8 @@ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -8834,20 +8961,19 @@ * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -8887,17 +9013,19 @@ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8906,7 +9034,7 @@ // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -8921,8 +9049,8 @@ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -8948,24 +9076,26 @@ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8976,7 +9106,7 @@ // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -8998,8 +9128,8 @@ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -9021,8 +9151,7 @@ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -9166,21 +9295,21 @@ const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -9195,11 +9324,11 @@ len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -9218,13 +9347,13 @@ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -9248,13 +9377,13 @@ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -9269,8 +9398,8 @@ } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -9301,7 +9430,7 @@ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -9333,9 +9462,9 @@ }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -9364,7 +9493,7 @@ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -9382,7 +9511,7 @@ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -9407,7 +9536,6 @@ * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -9417,8 +9545,6 @@ this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -9427,7 +9553,7 @@ this.clear(); } - 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. @@ -9439,13 +9565,13 @@ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -9455,68 +9581,74 @@ } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -9541,7 +9673,7 @@ * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -9589,24 +9721,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9626,7 +9758,7 @@ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -9636,24 +9768,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9674,8 +9806,7 @@ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -9715,14 +9846,14 @@ * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -9738,9 +9869,9 @@ if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -9751,8 +9882,8 @@ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -9760,7 +9891,7 @@ state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -11450,7 +11581,7 @@ // The expanded regex sets which are equivalent to the given `\\{c}` escapes: // // `/\s/`: - const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; + const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; // `/\d/`: const DIGIT_SETSTR = '0-9'; // `/\w/`: @@ -11462,7 +11593,7 @@ // Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex function i2c(i) { - var c, x; + let c, x; switch (i) { case 10: @@ -11502,7 +11633,7 @@ || i > 0xFFF0 /* Unicode Specials, also in UTF16 */ || (i >= 0xD800 && i <= 0xDFFF) /* Unicode Supplementary Planes; we're TOAST in JavaScript as we're NOT UTF-16 but UCS-2! */ || String.fromCharCode(i).match(/[\u2028\u2029]/) /* Code compilation via `new Function()` does not like to see these, or rather: treats them as just another form of CRLF, which breaks your generated regex code! */ - ) { + ) { // Detail about a detail: // U+2028 and U+2029 are part of the `\s` regex escape code (`\s` and `[\s]` match either of these) and when placed in a JavaScript // source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report @@ -11510,11 +11641,10 @@ // Hence we MUST escape these buggers everywhere we go... x = i.toString(16); if (x.length >= 1 && i <= 0xFFFF) { - c = '0000' + x; - return '\\u' + c.substr(c.length - 4); - } else { - return '\\u{' + x + '}'; + c = '0000' + x; + return '\\u' + c.substr(c.length - 4); } + return '\\u{' + x + '}'; } return String.fromCharCode(i); } @@ -11523,18 +11653,18 @@ // Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating // this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a // `\\p{NAME}` shorthand to represent [part of] the bitarray: - var Pcodes_bitarray_cache = {}; - var Pcodes_bitarray_cache_test_order = []; + let Pcodes_bitarray_cache = {}; + let Pcodes_bitarray_cache_test_order = []; - // Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by + // Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. - var EscCode_bitarray_output_refs; + let EscCode_bitarray_output_refs; // now initialize the EscCodes_... table above: init_EscCode_lookup_table(); function init_EscCode_lookup_table() { - var s, bitarr, set2esc = {}, esc2bitarr = {}; + let s, bitarr, set2esc = {}, esc2bitarr = {}; // patch global lookup tables for the time being, while we calculate their *real* content in this function: EscCode_bitarray_output_refs = { @@ -11603,13 +11733,13 @@ }; updatePcodesBitarrayCacheTestOrder(); - } + } function updatePcodesBitarrayCacheTestOrder(opts) { - var t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var l = {}; - var user_has_xregexp = opts && opts.options && opts.options.xregexp; - var i, j, k, ba; + let t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let l = {}; + let user_has_xregexp = opts && opts.options && opts.options.xregexp; + let i, j, k, ba; // mark every character with which regex pcodes they are part of: for (k in Pcodes_bitarray_cache) { @@ -11619,12 +11749,12 @@ continue; } - var cnt = 0; + let cnt = 0; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { cnt++; if (!t[i]) { - t[i] = [k]; + t[i] = [ k ]; } else { t[i].push(k); } @@ -11634,27 +11764,27 @@ } // now dig out the unique ones: only need one per pcode. - // + // // We ASSUME every \\p{NAME} 'pcode' has at least ONE character - // in it that is ONLY matched by that particular pcode. + // in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode - // won't be tested during optimization. - // + // won't be tested during optimization. + // // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to // look for markers which match multiple escapes/pcodes for those // ones where a unique item isn't available... - var lut = []; - var done = {}; - var keys = Object.keys(Pcodes_bitarray_cache); + let lut = []; + let done = {}; + let keys = Object.keys(Pcodes_bitarray_cache); for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { k = t[i][0]; if (t[i].length === 1 && !done[k]) { assert__default['default'](l[k] > 0); - lut.push([i, k]); + lut.push([ i, k ]); done[k] = true; } } @@ -11665,19 +11795,19 @@ if (!user_has_xregexp && k.indexOf('\\p{') >= 0) { continue; } - + if (!done[k]) { assert__default['default'](l[k] > 0); // find a minimum span character to mark this one: - var w = Infinity; + let w = Infinity; var rv; ba = Pcodes_bitarray_cache[k]; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { - var tl = t[i].length; + let tl = t[i].length; if (tl > 1 && tl < w) { assert__default['default'](l[k] > 0); - rv = [i, k]; + rv = [ i, k ]; w = tl; } } @@ -11691,16 +11821,16 @@ // order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. - // + // // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more - // optimal minification of the regex set expression. - // + // optimal minification of the regex set expression. + // // This is a guestimate/heuristic only! lut.sort(function (a, b) { - var k1 = a[1]; - var k2 = b[1]; - var ld = l[k2] - l[k1]; + let k1 = a[1]; + let k2 = b[1]; + let ld = l[k2] - l[k1]; if (ld) { return ld; } @@ -11718,19 +11848,19 @@ // 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set. function set2bitarray(bitarr, s, opts) { - var orig = s; - var set_is_inverted = false; - var bitarr_orig; + let orig = s; + let set_is_inverted = false; + let bitarr_orig; function mark(d1, d2) { if (d2 == null) d2 = d1; - for (var i = d1; i <= d2; i++) { + for (let i = d1; i <= d2; i++) { bitarr[i] = true; } } function add2bitarray(dst, src) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (src[i]) { dst[i] = true; } @@ -11738,10 +11868,10 @@ } function eval_escaped_code(s) { - var c; + let c; // decode escaped code? If none, just take the character as-is if (s.indexOf('\\') === 0) { - var l = s.substr(0, 2); + let l = s.substr(0, 2); switch (l) { case '\\c': c = s.charCodeAt(2) - 'A'.charCodeAt(0) + 1; @@ -11759,7 +11889,7 @@ } c = parseInt(s, 16); if (c >= 0x10000) { - return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); + return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); } return String.fromCharCode(c); @@ -11803,7 +11933,7 @@ } if (s && s.length) { - var c1, c2; + let c1, c2; // inverted set? if (s[0] === '^') { @@ -11834,13 +11964,13 @@ c2 = c2[0]; s = s.substr(c2.length); // do we have this one cached already? - var pex = c1 + c2; - var ba4p = Pcodes_bitarray_cache[pex]; + let pex = c1 + c2; + let ba4p = Pcodes_bitarray_cache[pex]; if (!ba4p) { // expand escape: - var xr = new XRegExp__default['default']('[' + pex + ']'); // TODO: case-insensitive grammar??? + let xr = new XRegExp__default['default']('[' + pex + ']'); // TODO: case-insensitive grammar??? // rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`: - var xs = '' + xr; + let xs = '' + xr; // remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: xs = xs.substr(1, xs.length - 2); @@ -11875,7 +12005,7 @@ break; } } - var v1 = eval_escaped_code(c1); + let v1 = eval_escaped_code(c1); // propagate deferred exceptions = error reports. if (v1 instanceof Error) { return v1; @@ -11893,7 +12023,7 @@ } else { c2 = c2[0]; } - var v2 = eval_escaped_code(c2); + let v2 = eval_escaped_code(c2); // propagate deferred exceptions = error reports. if (v2 instanceof Error) { return v1; @@ -11916,12 +12046,12 @@ } // When we have marked all slots, '^' NEGATES the set, hence we flip all slots. - // + // // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. if (set_is_inverted) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (!bitarr[i]) { bitarr_orig[i] = true; } @@ -11940,10 +12070,10 @@ // below can be simple and fast: l[UNICODE_BASE_PLANE_MAX_CP + 1] = 1; // now reconstruct the regex set: - var rv = []; - var i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; - var bitarr_is_cloned = false; - var l_orig = l; + let rv = []; + let i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; + let bitarr_is_cloned = false; + let l_orig = l; if (output_inverted_variant) { // generate the inverted set, hence all unmarked slots are part of the output range: @@ -11957,8 +12087,7 @@ // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. // BUT... since we output the INVERTED set, we output the match-all set instead: return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` // BUT... since we output the INVERTED set, we output the match-nothing set instead: @@ -11990,9 +12119,9 @@ } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12019,7 +12148,7 @@ } } } - + i = 0; while (i <= UNICODE_BASE_PLANE_MAX_CP) { // find first character not in original set: @@ -12050,8 +12179,7 @@ // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. return '^\\S\\s'; } @@ -12081,9 +12209,9 @@ } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12135,11 +12263,11 @@ } assert__default['default'](rv.length); - var s = rv.join(''); + let s = rv.join(''); assert__default['default'](s); // Check if the set is better represented by one of the regex escapes: - var esc4s = EscCode_bitarray_output_refs.set2esc[s]; + let esc4s = EscCode_bitarray_output_refs.set2esc[s]; if (esc4s) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return '\\' + esc4s; @@ -12154,25 +12282,24 @@ // Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there; // ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`. function reduceRegexToSetBitArray(s, name, opts) { - var orig = s; + let orig = s; // propagate deferred exceptions = error reports. if (s instanceof Error) { return s; } - var l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var internal_state = 0; - var derr; + let l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let internal_state = 0; + let derr; while (s.length) { - var c1 = s.match(CHR_RE); + let c1 = s.match(CHR_RE); if (!c1) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"'); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12180,15 +12307,14 @@ // this is starting a set within the regex: scan until end of set! var set_content = []; while (s.length) { - var inner = s.match(SET_PART_RE); + let inner = s.match(SET_PART_RE); if (!inner) { inner = s.match(CHR_RE); if (!inner) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"'); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12202,9 +12328,8 @@ if (!c2) { // cope with illegal escape sequences too! return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error('regex set expression is broken in regex: ' + orig); } @@ -12288,10 +12413,9 @@ // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; assert__default['default'](s); assert__default['default'](!(s instanceof Error)); - re = new XRegExp__default['default']('[' + s + ']'); + let re = new XRegExp__default['default']('[' + s + ']'); re.test(s[0]); // One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` @@ -12316,25 +12440,24 @@ - // Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` + // Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! function produceOptimizedRegex4Set(bitarr) { // First try to produce a minimum regex from the bitarray directly: - var s1 = bitarray2set(bitarr, false, true); + let s1 = bitarray2set(bitarr, false, true); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s1.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s1; - } else { - s1 = '[' + s1 + ']'; } + s1 = '[' + s1 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s2 = bitarray2set(bitarr, true, true); + let s2 = bitarray2set(bitarr, true, true); if (s2[0] === '^') { s2 = s2.substr(1); @@ -12349,23 +12472,22 @@ // Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: - // + // // First try to produce a minimum regex from the bitarray directly: - var s3 = bitarray2set(bitarr, false, false); + let s3 = bitarray2set(bitarr, false, false); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s3.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s3; - } else { - s3 = '[' + s3 + ']'; } + s3 = '[' + s3 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s4 = bitarray2set(bitarr, true, false); + let s4 = bitarray2set(bitarr, true, false); if (s4[0] === '^') { s4 = s4.substr(1); @@ -12397,30 +12519,30 @@ var setmgmt = { - XREGEXP_UNICODE_ESCAPE_RE, - CHR_RE, - SET_PART_RE, - NOTHING_SPECIAL_RE, - SET_IS_SINGLE_PCODE_RE, - - UNICODE_BASE_PLANE_MAX_CP, - - WHITESPACE_SETSTR, - DIGIT_SETSTR, - WORDCHAR_SETSTR, - - set2bitarray, - bitarray2set, - produceOptimizedRegex4Set, - reduceRegexToSetBitArray, + XREGEXP_UNICODE_ESCAPE_RE, + CHR_RE, + SET_PART_RE, + NOTHING_SPECIAL_RE, + SET_IS_SINGLE_PCODE_RE, + + UNICODE_BASE_PLANE_MAX_CP, + + WHITESPACE_SETSTR, + DIGIT_SETSTR, + WORDCHAR_SETSTR, + + set2bitarray, + bitarray2set, + produceOptimizedRegex4Set, + reduceRegexToSetBitArray }; // Basic Lexer implemented using JavaScript regular expressions - var rmCommonWS$2 = helpers.rmCommonWS; - var mkIdentifier$2 = helpers.mkIdentifier; - var code_exec$1 = helpers.exec; + const rmCommonWS$2 = helpers.rmCommonWS; + const mkIdentifier$2 = helpers.mkIdentifier; + const code_exec = helpers.exec; - var version = '0.6.2-220'; // require('./package.json').version; + const version = '0.6.2-220'; // require('./package.json').version; @@ -12481,7 +12603,7 @@ exportAST: false, prettyCfg: true, pre_lex: undefined, - post_lex: undefined, + post_lex: undefined }; @@ -12499,23 +12621,23 @@ // Return a fresh set of options. /** @public */ function mkStdOptions(/*...args*/) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - var args = [].concat.apply([], arguments); + let opts = {}; + let args = [].concat.apply([], arguments); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(defaultJisonLexOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; for (var p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { @@ -12553,7 +12675,7 @@ function prepExportStructures(options) { // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -12574,8 +12696,8 @@ // Otherwise return the *parsed* lexer spec as it has // been processed through LexParser. function autodetectAndConvertToJSONformat(lexerSpec, options) { - var chk_l = null; - var ex1, err; + let chk_l = null; + let ex1, err; if (typeof lexerSpec === 'string') { if (options.json) { @@ -12627,9 +12749,9 @@ /should be separated/, /an error in one or more of your lexer regex rules/, /an error in your lexer epilogue/, - /unsupported definition type/, + /unsupported definition type/ ]; - var cmnerr = commonErrors.filter(function check(re) { + let cmnerr = commonErrors.filter(function check(re) { return e.message.match(re); }); if (cmnerr.length > 0) { @@ -12658,14 +12780,14 @@ // expand macros and convert matchers to RegExp's function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) { - var m, i, k, rule, action, conditions; - var active_conditions; + let m, i, k, rule, action, conditions; + let active_conditions; assert__default['default'](Array.isArray(dict.rules)); - var rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! - var newRules = []; - var macros = {}; - var regular_rule_count = 0; - var simple_rule_count = 0; + let rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! + let newRules = []; + let macros = {}; + let regular_rule_count = 0; + let simple_rule_count = 0; // Assure all options are camelCased: assert__default['default'](typeof opts.options['case-insensitive'] === 'undefined'); @@ -12675,7 +12797,7 @@ } if (opts.options.flex && rules.length > 0) { - rules.push(['.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']); + rules.push([ '.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */' ]); } // Depending on the location within the regex we need different expansions of the macros: @@ -12699,7 +12821,7 @@ return str; } - var routingCode = ['switch(yyrulenumber) {']; + let routingCode = [ 'switch(yyrulenumber) {' ]; for (i = 0; i < rules.length; i++) { rule = rules[i].slice(0); // shallow copy: do not modify input rules @@ -12753,7 +12875,7 @@ action = action.replace(/return\s*\(?'((?:\\'|[^']+)+)'\)?/g, tokenNumberReplacement); action = action.replace(/return\s*\(?"((?:\\"|[^"]+)+)"\)?/g, tokenNumberReplacement); - var code = ['\n/*! Conditions::']; + let code = [ '\n/*! Conditions::' ]; code.push(postprocessComment(active_conditions)); code.push('*/', '\n/*! Rule:: '); code.push(postprocessComment(rule[0])); @@ -12774,7 +12896,7 @@ // 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'. - var match_nr = /^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim()); + 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 ')); @@ -12801,7 +12923,7 @@ macros: macros, regular_rule_count: regular_rule_count, - simple_rule_count: simple_rule_count, + simple_rule_count: simple_rule_count }; } @@ -12814,14 +12936,13 @@ // 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. function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElsewhere_cb) { - var orig = s; + let orig = s; function errinfo() { if (name) { return 'macro [[' + name + ']]'; - } else { - return 'regex [[' + orig + ']]'; } + return 'regex [[' + orig + ']]'; } // propagate deferred exceptions = error reports. @@ -12829,19 +12950,18 @@ return s; } - var c1, c2; - var rv = []; - var derr; - var se; + let c1, c2; + let rv = []; + let derr; + let se; while (s.length) { c1 = s.match(CHR_RE$1); if (!c1) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12851,15 +12971,14 @@ var l = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1); while (s.length) { - var inner = s.match(SET_PART_RE$1); + let inner = s.match(SET_PART_RE$1); if (!inner) { inner = s.match(CHR_RE$1); if (!inner) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12873,9 +12992,8 @@ if (!c2) { // cope with illegal escape sequences too! return new Error(errinfo() + ': regex set expression is broken: "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error(errinfo() + ': regex set expression is broken: apparently unterminated'); } @@ -12936,7 +13054,7 @@ c2 = c2[0]; s = s.substr(c2.length); - var c3 = s[0]; + let c3 = s[0]; s = s.substr(c3.length); if (c3 === '}') { // possibly a macro name in there... Expand if possible: @@ -12989,7 +13107,7 @@ // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; + let re; re = new XRegExp__default['default'](s); re.test(s[0]); } catch (ex) { @@ -13005,11 +13123,11 @@ // expand macros within macros and cache the result function prepareMacros(dict_macros, opts) { - var macros = {}; + let macros = {}; // expand a `{NAME}` macro which exists inside a `[...]` set: function expandMacroInSet(i) { - var k, a, m; + let k, a, m; if (!macros[i]) { m = dict_macros[i]; @@ -13043,7 +13161,7 @@ a = m.split('{' + k + '}'); if (a.length > 1) { - var x = expandMacroInSet(k); + let x = expandMacroInSet(k); assert__default['default'](x); if (x instanceof Error) { m = x; @@ -13055,9 +13173,9 @@ } } - var mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); + let mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); - var s1; + let s1; // propagate deferred exceptions = error reports. if (mba instanceof Error) { @@ -13091,7 +13209,7 @@ } function expandMacroElsewhere(i) { - var m; + let m; if (macros[i].elsewhere == null) { m = dict_macros[i]; @@ -13126,13 +13244,13 @@ } function expandAllMacrosInSet(s) { - var i, x; + let i, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { for (i in macros) { if (macros.hasOwnProperty(i)) { - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroInSet(i); assert__default['default'](x); @@ -13154,7 +13272,7 @@ } function expandAllMacrosElsewhere(s) { - var i, x; + let i, x; // When we process the remaining macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13169,7 +13287,7 @@ for (i in macros) { if (macros.hasOwnProperty(i)) { // These are all submacro expansions, hence non-capturing grouping is applied: - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroElsewhere(i); assert__default['default'](x); @@ -13191,7 +13309,7 @@ } - var i; + let i; if (opts.debug) console.log('\n############## RAW macros: ', dict_macros); @@ -13222,13 +13340,13 @@ // expand macros in a regex; expands them recursively function expandMacros(src, macros, opts) { - var expansion_count = 0; + let expansion_count = 0; // By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! // Hence things should be easy in there: function expandAllMacrosInSet(s) { - var i, m, x; + let i, m, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { @@ -13236,7 +13354,7 @@ if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = m.in_set; @@ -13267,7 +13385,7 @@ } function expandAllMacrosElsewhere(s) { - var i, m, x; + let i, m, x; // When we process the main macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13283,7 +13401,7 @@ if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { // These are all main macro expansions, hence CAPTURING grouping is applied: x = m.elsewhere; @@ -13319,7 +13437,7 @@ // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! - var s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); + let s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); // propagate deferred exceptions = error reports. if (s2 instanceof Error) { throw s2; @@ -13344,8 +13462,8 @@ } function prepareStartConditions(conditions) { - var sc; - var hash = {}; + let sc; + let hash = {}; for (sc in conditions) { if (conditions.hasOwnProperty(sc)) { @@ -13359,22 +13477,22 @@ } function buildActions(dict, tokens, opts) { - var actions = [dict.actionInclude || '', 'var YYSTATE = YY_START;']; - var tok; - var toks = {}; - var caseHelper = []; + let actions = [ dict.actionInclude || '', 'var YYSTATE = YY_START;' ]; + let tok; + let toks = {}; + let caseHelper = []; // tokens: map/array of token numbers to token names for (tok in tokens) { - var idx = parseInt(tok); + let idx = parseInt(tok); if (idx && idx > 0) { toks[tokens[tok]] = idx; } } - var gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); + let gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); - var code = actions.join('\n'); + let code = actions.join('\n'); 'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function (yy) { code = code.replace(new RegExp('\\b(' + yy + ')\\b', 'g'), 'yy_.$1'); }); @@ -13392,7 +13510,7 @@ macros: gen.macros, // propagate these for debugging/diagnostic purposes regular_rule_count: gen.regular_rule_count, - simple_rule_count: gen.simple_rule_count, + simple_rule_count: gen.simple_rule_count }; } @@ -13403,7 +13521,7 @@ function generateErrorClass() { // --- START lexer error class --- - var prelude = `/** + const prelude = `/** * 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 @@ -13414,8 +13532,6 @@ * @nocollapse */ function JisonLexerError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -13432,9 +13548,9 @@ function JisonLexerError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -13495,8 +13611,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /** @constructor */ function RegExpLexer(dict, input, tokens, build_options) { - var opts; - var dump = false; + let opts; + let dump = false; function test_me(tweak_cb, description, src_exception, ex_callback) { opts = processGrammar(dict, tokens, build_options); @@ -13506,7 +13622,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (tweak_cb) { tweak_cb(); } - var source = generateModuleBody(opts); + let source = generateModuleBody(opts); try { // The generated code will always have the `lexer` variable declared at local scope // as `eval()` will use the local scope. @@ -13514,16 +13630,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // The compiled code will look something like this: // // ``` - // var lexer; + // let lexer; // bla bla... // ``` // // or // // ``` - // var lexer = { bla... }; + // const lexer = { bla... }; // ``` - var testcode = [ + let testcode = [ '// provide a local version for test purposes:', jisonLexerErrorDefinition, '', @@ -13531,14 +13647,33 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; '', source, '', + rmCommonWS$2` + // JISON INJECTED VALIDATION CODE + // which attempts to ascertain you have defined a minimal viable lexer at least: + if (typeof lexer === "undefined") { + throw new SyntaxError("user-defined lexer does not define the required 'lexer' instance."); + } + if (!lexer) { + throw new SyntaxError("user-defined lexer does not define a non-NULL 'lexer' instance."); + } + if (typeof lexer.setInput !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.setInput()' API function."); + } + if (typeof lexer.lex !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.lex()' API function."); + } + // END OF JISON INJECTED VALIDATION CODE + `, 'return lexer;' ].join('\n'); - var lexer = code_exec$1(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { + let lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { //console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$2(sourcecode); - var lexer_f = new Function('', sourcecode); + let lexer_f = new Function('', sourcecode); return lexer_f(); - }, opts.options, "lexer"); + }, Object.assign({}, opts.options, { + throwErrorOnCompileFailure: true + }), 'lexer'); if (!lexer) { throw new Error('no lexer defined *at all*?!'); @@ -13555,7 +13690,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // When we do NOT crash, we found/killed the problem area just before this call! if (src_exception && description) { - var msg = description; + let msg = description; if (typeof description === 'function') { msg = description(); } @@ -13564,8 +13699,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // patch the pre and post handlers in there, now that we have some live code to work with: if (opts.options) { - var pre = opts.options.pre_lex; - var post = opts.options.post_lex; + let pre = opts.options.pre_lex; + let post = opts.options.post_lex; // since JSON cannot encode functions, we'll have to do it manually now: if (typeof pre === 'function') { lexer.options.pre_lex = pre; @@ -13579,7 +13714,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (typeof opts.options.showSource === 'function') { opts.options.showSource(lexer, source, opts, RegExpLexer); } else { - console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n"); + console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n', source, '\n----------------------------------------\n'); } } return lexer; @@ -13598,13 +13733,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } /** @constructor */ - var lexer = test_me(null, null, null, function (ex) { + let lexer = test_me(null, null, null, function (ex) { // When we get an exception here, it means some part of the user-specified lexer is botched. // // Now we go and try to narrow down the problem area/category: assert__default['default'](opts.options); assert__default['default'](opts.options.xregexp !== undefined); - var orig_xregexp_opt = !!opts.options.xregexp; + let orig_xregexp_opt = !!opts.options.xregexp; if (!test_me(function () { assert__default['default'](opts.options.xregexp !== undefined); opts.options.xregexp = false; @@ -13623,7 +13758,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; 'Your custom lexer is somehow botched.' ); }, ex, null)) { - var rulesSpecSize; + let rulesSpecSize; if (!test_me(function () { // store the parsed rule set size so we can use that info in case // this attempt also fails: @@ -13636,7 +13771,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; opts.__in_rules_failure_analysis_mode__ = true; }, 'One or more of your lexer rules are possibly botched?', ex, null)) { // kill each rule action block, one at a time and test again after each 'edit': - var rv = false; + let rv = false; for (var i = 0, len = rulesSpecSize; i < len; i++) { var lastEditedRuleSpec; rv = test_me(function () { @@ -13648,10 +13783,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // opts.__in_rules_failure_analysis_mode__ = true; // nuke all rules' actions up to and including rule numero `i`: - for (var j = 0; j <= i; j++) { + for (let j = 0; j <= i; j++) { // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; // now we want to edit the *action* part: - var rule = opts.rules[j]; + let rule = opts.rules[j]; assert__default['default'](Array.isArray(rule)); assert__default['default'](rule.length === 2 || rule.length === 3); rule.pop(); @@ -13785,8 +13920,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -13796,14 +13929,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\\n\\s*$/.test(msg)) { msg += '\\n'; } msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') { msg += '\\n' + pos_str; @@ -13814,14 +13947,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the \`upcomingInput\` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -13841,9 +13974,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -13863,8 +13995,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -13885,16 +14015,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -13915,8 +14043,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -13924,8 +14050,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -13943,8 +14069,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -13954,14 +14078,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -13972,8 +14096,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -13981,40 +14103,40 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -14026,7 +14148,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -14034,7 +14156,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -14095,9 +14217,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -14116,8 +14236,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set \`done\` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -14126,7 +14244,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -14136,13 +14254,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\\n') { lines = true; } else if (ch === '\\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\\n') { slice_len++; ch += ch2; @@ -14174,10 +14292,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -14209,8 +14325,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Get last entirely matched line into the \`pre_lines[]\` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -14228,9 +14344,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -14240,14 +14356,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -14258,8 +14372,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -14272,19 +14384,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the \`parseError()\` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // \`.lex()\` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -14297,8 +14407,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -14321,24 +14429,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substr\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14350,8 +14458,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to \`maxSize\` (default: 20). @@ -14377,24 +14485,25 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > \`lookAhead()\` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substring\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -14403,7 +14512,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14422,10 +14531,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^'; }, @@ -14447,15 +14554,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -14586,58 +14691,54 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\\t/g, ' '); @@ -14646,13 +14747,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -14674,15 +14775,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -14694,8 +14793,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -14724,13 +14823,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -14759,10 +14852,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -14790,7 +14883,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -14801,7 +14894,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -14823,8 +14916,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -14833,17 +14924,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -14853,67 +14940,75 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that \`parseError()\` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) \`parseError()\` @@ -14940,9 +15035,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -14985,24 +15078,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15022,9 +15115,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15034,24 +15125,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15059,7 +15150,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this._clear_state = 0; } - + return r; }, @@ -15072,9 +15163,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -15082,7 +15171,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -15097,8 +15186,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -15110,8 +15197,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -15125,15 +15210,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -15145,14 +15227,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -15163,16 +15242,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -15182,8 +15259,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; } }`; @@ -15215,18 +15290,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // ............................. ${opt.lexerActionsUseDisplayAPIs} // uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC} - var new_src; + let new_src; try { - var ast = helpers.parseCodeChunkToAST(src, opt); + let ast = helpers.parseCodeChunkToAST(src, opt); new_src = helpers.prettyPrintAST(ast, opt); - } - catch (ex) { + } catch (ex) { let line = ex.lineNumber || 0; let a = src.split(/\r?\n/g); let len = a.length; let minl = Math.max(0, line - 10); let b = a.slice(minl, line + 10); - let c = b.splice(line - minl, 0, "", "^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", ""); + let c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); let offendingChunk = ' ' + b.join('\n '); console.error(rmCommonWS$2` stripUnusedLexerCode WARNING: @@ -15242,17 +15316,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; ${offendingChunk} `); - + new_src = src; } - - - - - - // inject analysis report now: new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2` // Code Generator Information Report @@ -15307,7 +15375,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // generate lexer source from a grammar /** @public */ function generate(dict, tokens, build_options) { - var opt = processGrammar(dict, tokens, build_options); + let opt = processGrammar(dict, tokens, build_options); return generateFromOpts(opt); } @@ -15316,7 +15384,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /** @public */ function processGrammar(dict, tokens, build_options) { build_options = build_options || {}; - var opts = { + let opts = { // include the knowledge passed through `build_options` about which lexer // features will actually be *used* by the environment (which in 99.9% // of cases is a jison *parser*): @@ -15356,7 +15424,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; lexerActionsUseReject: '???', lexerActionsUseLess: '???', lexerActionsUseDisplayAPIs: '???', - lexerActionsUseDescribeYYLOC: '???', + lexerActionsUseDescribeYYLOC: '???' }; dict = autodetectAndConvertToJSONformat(dict, build_options) || {}; @@ -15381,7 +15449,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // only produce rule action code blocks when there are any rules at all; // a "custom lexer" has ZERO rules and must be defined entirely in // other code blocks: - var code = (dict.rules ? buildActions(dict, tokens, opts) : {}); + let code = (dict.rules ? buildActions(dict, tokens, opts) : {}); opts.performAction = code.actions; opts.caseHelperInclude = code.caseHelperInclude; opts.rules = code.rules || []; @@ -15390,7 +15458,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; opts.regular_rule_count = code.regular_rule_count; opts.simple_rule_count = code.simple_rule_count; - opts.conditionStack = ['INITIAL']; + opts.conditionStack = [ 'INITIAL' ]; opts.actionInclude = (dict.actionInclude || ''); opts.moduleInclude = (opts.moduleInclude || '') + (dict.moduleInclude || '').trim(); @@ -15401,7 +15469,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Assemble the final source from the processed grammar /** @public */ function generateFromOpts(opt) { - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -15424,12 +15492,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function generateRegexesInitTableCode(opt) { - var a = opt.rules; - var print_xregexp = opt.options && opt.options.xregexp; - var id_display_width = (1 + Math.log10(a.length | 1) | 0); - var ws_prefix = new Array(id_display_width).join(' '); - var b = a.map(function generateXRegExpInitCode(re, idx) { - var idx_str = (ws_prefix + idx).substr(-id_display_width); + let a = opt.rules; + let print_xregexp = opt.options && opt.options.xregexp; + let id_display_width = (1 + Math.log10(a.length | 1) | 0); + let ws_prefix = new Array(id_display_width).join(' '); + let b = a.map(function generateXRegExpInitCode(re, idx) { + let idx_str = (ws_prefix + idx).substr(-id_display_width); if (re instanceof XRegExp__default['default']) { // When we don't need the special XRegExp sauce at run-time, we do with the original @@ -15439,11 +15507,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // And make sure to escape the regex to make it suitable for placement inside a *string* // as it is passed as a string argument to the XRegExp constructor here. - var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); + let re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); return `/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`; - } else { - return `/* ${idx_str}: */ ${re}`; } + return `/* ${idx_str}: */ ${re}`; + }); return b.join(',\n'); } @@ -15451,77 +15519,77 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateModuleBody(opt) { // make the JSON output look more like JavaScript: function cleanupJSON(str) { - str = str.replace(/ "rules": \[/g, ' rules: ['); - str = str.replace(/ "inclusive": /g, ' inclusive: '); + str = str.replace(/ {2}"rules": \[/g, ' rules: ['); + str = str.replace(/ {2}"inclusive": /g, ' inclusive: '); return str; } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - json: 1, - _: 1, - noMain: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - lexerErrorsAreRecoverable: 0, - flex: 0, - backtrack_lexer: 0, - caseInsensitive: 0, - showSource: 1, - exportAST: 1, - exportAllTables: 1, - exportSourceCode: 1, - prettyCfg: 1, - parseActionsUseYYLENG: 1, - parseActionsUseYYLINENO: 1, - parseActionsUseYYTEXT: 1, - parseActionsUseYYLOC: 1, - parseActionsUseParseError: 1, - parseActionsUseYYERROR: 1, - parseActionsUseYYRECOVERING: 1, - parseActionsUseYYERROK: 1, - parseActionsUseYYCLEARIN: 1, - parseActionsUseValueTracking: 1, - parseActionsUseValueAssignment: 1, - parseActionsUseLocationTracking: 1, - parseActionsUseLocationAssignment: 1, - parseActionsUseYYSTACK: 1, - parseActionsUseYYSSTACK: 1, - parseActionsUseYYSTACKPOINTER: 1, - parseActionsUseYYRULELENGTH: 1, - parseActionsUseYYMERGELOCATIONINFO: 1, - parserHasErrorRecovery: 1, - parserHasErrorReporting: 1, - lexerActionsUseYYLENG: 1, - lexerActionsUseYYLINENO: 1, - lexerActionsUseYYTEXT: 1, - lexerActionsUseYYLOC: 1, - lexerActionsUseParseError: 1, - lexerActionsUseYYERROR: 1, - lexerActionsUseLocationTracking: 1, - lexerActionsUseMore: 1, - lexerActionsUseUnput: 1, - lexerActionsUseReject: 1, - lexerActionsUseLess: 1, - lexerActionsUseDisplayAPIs: 1, - lexerActionsUseDescribeYYLOC: 1, + let obj = {}; + const do_not_pass = { + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + json: 1, + _: 1, + noMain: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + lexerErrorsAreRecoverable: 0, + flex: 0, + backtrack_lexer: 0, + caseInsensitive: 0, + showSource: 1, + exportAST: 1, + exportAllTables: 1, + exportSourceCode: 1, + prettyCfg: 1, + parseActionsUseYYLENG: 1, + parseActionsUseYYLINENO: 1, + parseActionsUseYYTEXT: 1, + parseActionsUseYYLOC: 1, + parseActionsUseParseError: 1, + parseActionsUseYYERROR: 1, + parseActionsUseYYRECOVERING: 1, + parseActionsUseYYERROK: 1, + parseActionsUseYYCLEARIN: 1, + parseActionsUseValueTracking: 1, + parseActionsUseValueAssignment: 1, + parseActionsUseLocationTracking: 1, + parseActionsUseLocationAssignment: 1, + parseActionsUseYYSTACK: 1, + parseActionsUseYYSSTACK: 1, + parseActionsUseYYSTACKPOINTER: 1, + parseActionsUseYYRULELENGTH: 1, + parseActionsUseYYMERGELOCATIONINFO: 1, + parserHasErrorRecovery: 1, + parserHasErrorReporting: 1, + lexerActionsUseYYLENG: 1, + lexerActionsUseYYLINENO: 1, + lexerActionsUseYYTEXT: 1, + lexerActionsUseYYLOC: 1, + lexerActionsUseParseError: 1, + lexerActionsUseYYERROR: 1, + lexerActionsUseLocationTracking: 1, + lexerActionsUseMore: 1, + lexerActionsUseUnput: 1, + lexerActionsUseReject: 1, + lexerActionsUseLess: 1, + lexerActionsUseDisplayAPIs: 1, + lexerActionsUseDescribeYYLOC: 1 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -15532,8 +15600,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // And now some options which should receive some special processing: - var pre = obj.pre_lex; - var post = obj.post_lex; + let pre = obj.pre_lex; + let post = obj.post_lex; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_lex = true; @@ -15542,7 +15610,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; obj.post_lex = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$1})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_lex: true(,)?$/gm, function (m, ls, tc) { @@ -15555,17 +15623,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } - var out; + let out; if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) { // we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. - var code = [rmCommonWS$2` - var lexer = { - `, '/*JISON-LEX-ANALYTICS-REPORT*/' /* slot #1: placeholder for analysis report further below */ + let code = [ rmCommonWS$2` + const lexer = { + `, '/* JISON-LEX-ANALYTICS-REPORT */\n' /* slot #1: placeholder for analysis report further below */ ]; // get the RegExpLexer.prototype in source code form: - var protosrc = getRegExpLexerPrototype(); + let protosrc = getRegExpLexerPrototype(); // and strip off the surrounding bits we don't want: protosrc = protosrc .replace(/^[\s\r\n]*\{/, '') @@ -15592,10 +15660,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } */ - var performActionCode = String(opt.performAction); - var simpleCaseActionClustersCode = String(opt.caseHelperInclude); - var rulesCode = generateRegexesInitTableCode(opt); - var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); + let performActionCode = String(opt.performAction); + let simpleCaseActionClustersCode = String(opt.caseHelperInclude); + let rulesCode = generateRegexesInitTableCode(opt); + let conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); code.push(rmCommonWS$2`, JisonLexerError: JisonLexerError, performAction: ${performActionCode}, @@ -15615,9 +15683,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // - // Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter + // Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. - out = 'var lexer;\n'; + out = '\n'; assert__default['default'](opt.regular_rule_count === 0); assert__default['default'](opt.simple_rule_count === 0); @@ -15631,8 +15699,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // The output of this function is guaranteed to read something like this: // // ``` - // var lexer; - // // bla bla bla bla ... lotsa bla bla; // ``` // @@ -15641,7 +15707,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function generateGenericHeaderComment() { - var out = rmCommonWS$2` + let out = rmCommonWS$2` /* lexer generated by jison-lex ${version} */ /* @@ -15870,7 +15936,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else { @@ -15888,9 +15954,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -15913,9 +15979,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateAMDModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} define([], function () { @@ -15938,12 +16004,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateESModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} - var lexer = (function () { + const lexer = (function () { "use strict"; ${jisonLexerErrorDefinition} @@ -15972,9 +16038,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateCommonJSModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -16011,14 +16077,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; RegExpLexer.mkIdentifier = mkIdentifier$2; RegExpLexer.autodetectAndConvertToJSONformat = autodetectAndConvertToJSONformat; - var mkIdentifier$3 = helpers.mkIdentifier; + const mkIdentifier$3 = helpers.mkIdentifier; - var version$1 = '0.6.2-220'; // require('./package.json').version; + const version$1 = '0.6.2-220'; // require('./package.json').version; function getCommandlineOptions() { - - var opts = nomnom__default['default'] + let opts = nomnom__default['default'] .script('jison-lex') .unknownOptionTreatment(false) // do not accept unknown options! .options({ @@ -16068,7 +16133,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; abbr: 'm', default: 'commonjs', metavar: 'TYPE', - choices: ['commonjs', 'amd', 'js', 'es'], + choices: [ 'commonjs', 'amd', 'js', 'es' ], help: 'The type of module to generate (commonjs, amd, es, js)' }, moduleName: { @@ -16102,7 +16167,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }).parse(); if (opts.debug) { - console.log("JISON-LEX CLI options:\n", opts); + console.log('JISON-LEX CLI options:\n', opts); } return opts; @@ -16130,7 +16195,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return true; } catch (e) { if (e.code === 'ENOENT') { - var parent = path__default['default'].dirname(fp); + let parent = path__default['default'].dirname(fp); // Did we hit the root directory by now? If so, abort! // Else, create the parent; iff that fails, we fail too... if (parent !== fp && mkdirp(parent)) { @@ -16148,16 +16213,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function processInputFile() { - var original_cwd = process.cwd(); + let original_cwd = process.cwd(); - var raw = fs__default['default'].readFileSync(path__default['default'].normalize(opts.file), 'utf8'); + let raw = fs__default['default'].readFileSync(path__default['default'].normalize(opts.file), 'utf8'); // making best guess at json mode opts.json = path__default['default'].extname(opts.file) === '.json' || opts.json; // When only the directory part of the output path was specified, then we // do NOT have the target module name in there as well! - var outpath = opts.outfile; + let outpath = opts.outfile; if (typeof outpath === 'string') { if (/[\\\/]$/.test(outpath) || isDirectory(outpath)) { opts.outfile = null; @@ -16176,7 +16241,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // setting output file name and module name based on input file name // if they aren't specified. - var name = path__default['default'].basename(opts.outfile || opts.file); + let name = path__default['default'].basename(opts.outfile || opts.file); // get the base name (i.e. the file name without extension) // i.e. strip off only the extension and keep any other dots in the filename @@ -16189,10 +16254,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Change CWD to the directory where the source grammar resides: this helps us properly // %include any files mentioned in the grammar with relative paths: - var new_cwd = path__default['default'].dirname(path__default['default'].normalize(opts.file)); + let new_cwd = path__default['default'].dirname(path__default['default'].normalize(opts.file)); process.chdir(new_cwd); - var lexer = cli.generateLexerString(raw, opts); + let lexer = cli.generateLexerString(raw, opts); // and change back to the CWD we started out with: process.chdir(original_cwd); @@ -16204,8 +16269,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function readin(cb) { - var stdin = process.openStdin(), - data = ''; + const stdin = process.openStdin(); + let data = ''; stdin.setEncoding('utf8'); stdin.addListener('data', function (chunk) { @@ -16232,9 +16297,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateLexerString(lexerSpec, opts) { - // var settings = RegExpLexer.mkStdOptions(opts); - var predefined_tokens = null; + let predefined_tokens = null; return RegExpLexer.generate(lexerSpec, predefined_tokens, opts); } @@ -16246,7 +16310,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (require.main === module) { - var opts = getCommandlineOptions(); + const opts = getCommandlineOptions(); cli.main(opts); } diff --git a/packages/jison-lex/dist/regexp-lexer-cjs-es5.js b/packages/jison-lex/dist/regexp-lexer-cjs-es5.js index f1d7b76b1..c6ed50807 100644 --- a/packages/jison-lex/dist/regexp-lexer-cjs-es5.js +++ b/packages/jison-lex/dist/regexp-lexer-cjs-es5.js @@ -1,4 +1,4 @@ -'use strict';var XRegExp=require('@gerhobbelt/xregexp');var JSON5=require('@gerhobbelt/json5');var fs=require('fs');var path$1=require('path');var recast=require('recast');var babel=require('@babel/core');var assert$1=require('assert');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e};}var XRegExp__default=/*#__PURE__*/_interopDefaultLegacy(XRegExp);var JSON5__default=/*#__PURE__*/_interopDefaultLegacy(JSON5);var fs__default=/*#__PURE__*/_interopDefaultLegacy(fs);var path__default=/*#__PURE__*/_interopDefaultLegacy(path$1);var recast__default=/*#__PURE__*/_interopDefaultLegacy(recast);var assert__default=/*#__PURE__*/_interopDefaultLegacy(assert$1);// Return TRUE if `src` starts with `searchString`. +'use strict';var XRegExp=require('@gerhobbelt/xregexp');var JSON5=require('@gerhobbelt/json5');var fs=require('fs');var path$1=require('path');var mkdirp=require('mkdirp');var recast=require('recast');var babel=require('@babel/core');var assert$1=require('assert');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e};}var XRegExp__default=/*#__PURE__*/_interopDefaultLegacy(XRegExp);var JSON5__default=/*#__PURE__*/_interopDefaultLegacy(JSON5);var fs__default=/*#__PURE__*/_interopDefaultLegacy(fs);var path__default=/*#__PURE__*/_interopDefaultLegacy(path$1);var mkdirp__default=/*#__PURE__*/_interopDefaultLegacy(mkdirp);var recast__default=/*#__PURE__*/_interopDefaultLegacy(recast);var assert__default=/*#__PURE__*/_interopDefaultLegacy(assert$1);// Return TRUE if `src` starts with `searchString`. function startsWith(src,searchString){return src.substr(0,searchString.length)===searchString;}// tagged template string helper which removes the indentation common to all // non-empty lines: that indentation was added as part of the source code // formatting of this lexer spec file and must be removed to produce what @@ -14,62 +14,72 @@ function startsWith(src,searchString){return src.substr(0,searchString.length)== function rmCommonWS(strings,...values){// As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. -// +// // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. -var indent_str=null;var src=strings.map(function splitIntoLines(s){var a=s.split('\n');indent_str=a.reduce(function analyzeLine(indent_str,line,index){// only check indentation of parts which follow a NEWLINE: -if(index!==0){var m=/^(\s*)\S/.exec(line);// only non-empty ~ content-carrying lines matter re common indent calculus: +let indent_str=null;let src=strings.map(function splitIntoLines(s){let a=s.split('\n');indent_str=a.reduce(function analyzeLine(indent_str,line,index){// only check indentation of parts which follow a NEWLINE: +if(index!==0){let m=/^(\s*)\S/.exec(line);// only non-empty ~ content-carrying lines matter re common indent calculus: if(m){if(indent_str==null){indent_str=m[1];}else if(m[1].length start at j=1 rather than j=0 -for(var j=1,linecnt=a.length;j `'camelsHaveOneHump'` +for(let j=1,linecnt=a.length;j `'camelsHaveOneHump'` /** @public */function camelCase(s){// Convert first character to lowercase -return s.replace(/^\w/,function(match){return match.toLowerCase();}).replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// do not mutate 'a-2' to 'a2': -if(c===rv&&c.match(/\d/)){return match;}return rv;});}// Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers -/** @public */function mkIdentifier(s){s=''+s;return s// Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), +return s.replace(/^\w/,function(match){return match.toLowerCase();}).replace(/-\w/g,function(match){const c=match.charAt(1);const rv=c.toUpperCase();// do not mutate 'a-2' to 'a2': +if(c===rv&&c.match(/\d/)){return match;}return rv;});}// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords=(list=>{let rv=new Set();for(let w of list){//console.error('reserved word:', w); +rv.add(w);}return rv;})(['await','break','case','catch','class','const','continue','debugger','default','delete','do','else','enum','export','extends','finally','for','function','if','implements','import','in','instanceof','interface','new','package','private','protected','public','return','super','switch','this','throw','try','typeof','var','void','while','with','yield']);// Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers +/** @public */function mkIdentifier(s){s=''+s;let rv=s// Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` -.replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// mutate 'a-2' to 'a_2': +.replace(/-\w/g,function(match){let c=match.charAt(1);let rv=c.toUpperCase();// mutate 'a-2' to 'a_2': if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;})// cleanup: replace any non-suitable character series to a single underscore: .replace(/^([\d])/,'_$1')// where leading numbers are prefixed by an underscore: '1' --> '_1' .replace(/^[^\w_]/,'_')// do not accept numerics at the leading position, despite those matching regex `\w`: .replace(/^\d/,'_').replace(/[^\w\d_]/g,'_')// and only accept multiple (double, not triple) underscores at start or end of identifier name: -.replace(/^__+/,'#').replace(/__+$/,'#').replace(/_+/g,'_').replace(/#/g,'__');}// Check if the start of the given input matches a regex expression. +.replace(/^__+/,'#').replace(/__+$/,'#').replace(/_+/g,'_').replace(/#/g,'__');if(reservedWords.has(rv)){rv='_'+rv;}return rv;}// Check if the start of the given input matches a regex expression. // Return the length of the regex expression or -1 if none was found. /** @public */function scanRegExp(s){s=''+s;// code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` -var index=0;var length=s.length;var ch=s[index];//assert.assert(ch === '/', 'Regular expression literal must start with a slash'); -var str=s[index++];var classMarker=false;var terminated=false;while(index `'camelsHaveOneHump'` -let ref=s.replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// mutate 'a-2' to 'a_2': -if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;});var alt=mkIdentifier(s);return alt===ref;}// properly quote and escape the given input string -function dquote(s){var sq=s.indexOf('\'')>=0;var dq=s.indexOf('"')>=0;if(sq&&dq){s=s.replace(/"/g,'\\"');dq=false;}if(dq){s='\''+s+'\'';}else{s='"'+s+'"';}return s;}// +let ref=s.replace(/-\w/g,function(match){let c=match.charAt(1);let rv=c.toUpperCase();// mutate 'a-2' to 'a_2': +if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;});let alt=mkIdentifier(s);return alt===ref;}// properly quote and escape the given input string +function dquote(s){let sq=s.indexOf('\'')>=0;let dq=s.indexOf('"')>=0;if(sq&&dq){s=s.replace(/"/g,'\\"');dq=false;}if(dq){s='\''+s+'\'';}else{s='"'+s+'"';}return s;}// function chkBugger(src){src=String(src);if(src.match(/\bcov_\w+/)){console.error('### ISTANBUL COVERAGE CODE DETECTED ###\n',src);}}// Helper function: pad number with leading zeroes -function pad(n,p){p=p||2;var rv='0000'+n;return rv.slice(-p);}// attempt to dump in one of several locations: first winner is *it*! -function dumpSourceToFile(sourcecode,errname,err_id,options,ex){var dumpfile;options=options||{};try{var dumpPaths=[options.outfile?path__default['default'].dirname(options.outfile):null,options.inputPath,process.cwd()];var dumpName=path__default['default'].basename(options.inputFilename||options.moduleName||(options.outfile?path__default['default'].dirname(options.outfile):null)||options.defaultModuleName||errname).replace(/\.[a-z]{1,5}$/i,'')// remove extension .y, .yacc, .jison, ...whatever -.replace(/[^a-z0-9_]/ig,'_');// make sure it's legal in the destination filesystem: the least common denominator. -if(dumpName===''||dumpName==='_'){dumpName='__bugger__';}err_id=err_id||'XXX';var ts=new Date();var tm=ts.getUTCFullYear()+'_'+pad(ts.getUTCMonth()+1)+'_'+pad(ts.getUTCDate())+'T'+pad(ts.getUTCHours())+''+pad(ts.getUTCMinutes())+''+pad(ts.getUTCSeconds())+'.'+pad(ts.getUTCMilliseconds(),3)+'Z';dumpName+='.fatal_'+err_id+'_dump_'+tm+'.js';for(var i=0,l=dumpPaths.length;i'// '+l);d=d.join('\n');fs__default['default'].writeFileSync(dumpfile,sourcecode+'\n\n\n'+d,'utf8');console.error("****** offending generated "+errname+" source code dumped into file: ",dumpfile);break;// abort loop once a dump action was successful! +function pad(n,p){p=p||2;let rv='0000'+n;return rv.slice(-p);}function convertExceptionToObject(ex){if(!ex)return ex;// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error +// +// - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) +let rv=Object.assign({},ex);// - Set up the default fields which should ALWAYS be present: +rv.message=ex.message;rv.name=ex.name;rv.stack=ex.stack;// this assignment stringifies the stack trace in ex.stack. +// - Set the optional fields: +if(ex.code!==undefined)rv.code=ex.code;if(ex.type!==undefined)rv.type=ex.type;if(ex.fileName!==undefined)rv.fileName=ex.fileName;if(ex.lineNumber!==undefined)rv.lineNumber=ex.lineNumber;if(ex.columnNumber!==undefined)rv.columnNumber=ex.columnNumber;if(Array.isArray(ex.errors)){rv.errors=[];for(let se of ex.errors){rv.errors.push(convertExceptionToObject(se));}}return rv;}function find_suitable_app_dump_path(){return process.cwd().replace(/\\/g,'/').replace(/\/node_modules\/.*$/,m=>'/___nm___/').replace(/(\/jison\/)(.*)$/,(m,p1,p2)=>p1+'___'+p2.split('/').map(d=>d.charAt(0).toUpperCase()).join('_'));}// attempt to dump in one of several locations: first winner is *it*! +function dumpSourceToFile(sourcecode,errname,err_id,options,ex){let dumpfile;options=options||{};try{const dumpPaths=[options.outfile?path__default['default'].dirname(options.outfile):null,options.inputPath,find_suitable_app_dump_path()];let dumpName=path__default['default'].basename(options.inputFilename||options.moduleName||(options.outfile?path__default['default'].dirname(options.outfile):null)||options.defaultModuleName||errname).replace(/\.[a-z]{1,5}$/i,'')// remove extension .y, .yacc, .jison, ...whatever +.replace(/[^a-z0-9_]/ig,'_')// make sure it's legal in the destination filesystem: the least common denominator. +.substr(0,100);if(dumpName===''||dumpName==='_'){dumpName='__bugger__';}// generate a stacktrace for the dump no matter what: +if(!ex){try{throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this.");}catch(ex2){ex=ex2;}}err_id=err_id||'XXX';err_id=err_id.replace(/[^a-z0-9_]/ig,'_')// make sure it's legal in the destination filesystem: the least common denominator. +.substr(0,50);const ts=new Date();const tm=ts.getUTCFullYear()+'_'+pad(ts.getUTCMonth()+1)+'_'+pad(ts.getUTCDate())+'T'+pad(ts.getUTCHours())+''+pad(ts.getUTCMinutes())+''+pad(ts.getUTCSeconds())+'.'+pad(ts.getUTCMilliseconds(),3)+'Z';dumpName+='.fatal_'+err_id+'_dump_'+tm+'.js';for(let i=0,l=dumpPaths.length;i'[!circular ref!]'});// make sure each line is a comment line: +d=d.split('\n').map(l=>'// '+l);d=d.join('\n');mkdirp__default['default'](path__default['default'].dirname(dumpfile));fs__default['default'].writeFileSync(dumpfile,sourcecode+'\n\n\n'+d,'utf8');console.error('****** offending generated '+errname+' source code dumped into file: ',dumpfile);break;// abort loop once a dump action was successful! }catch(ex3){//console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); -if(i===l-1){throw ex3;}}}}catch(ex2){console.error("generated "+errname+" source code fatal DUMPING error: ",ex2.message," -- while attempting to dump into file: ",dumpfile,"\n",ex2.stack);}// augment the exception info, when available: +if(i===l-1){throw ex3;}}}}catch(ex2){console.error('generated '+errname+' source code fatal DUMPING error: ',ex2.message,' -- while attempting to dump into file: ',dumpfile,'\n',ex2.stack);}// augment the exception info, when available: if(ex){ex.offending_source_code=sourcecode;ex.offending_source_title=errname;ex.offending_source_dumpfile=dumpfile;}}// // `code_execution_rig` is a function which gets executed, while it is fed the `sourcecode` as a parameter. // When the `code_execution_rig` crashes, its failure is caught and (using the `options`) the sourcecode @@ -88,8 +98,12 @@ if(ex){ex.offending_source_code=sourcecode;ex.offending_source_title=errname;ex. // - options.moduleName // - options.defaultModuleName // -function exec_and_diagnose_this_stuff(sourcecode,code_execution_rig,options,title){options=options||{};var errname=""+(title||"exec_test");var err_id=errname.replace(/[^a-z0-9_]/ig,"_");if(err_id.length===0){err_id="exec_crash";}const debug=0;var p;try{// p = eval(sourcecode); -if(typeof code_execution_rig!=='function'){throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function");}chkBugger(sourcecode);p=code_execution_rig.call(this,sourcecode,options,errname,debug);}catch(ex){if(options.dumpSourceCodeOnFailure||1){dumpSourceToFile(sourcecode,errname,err_id,options,ex);}if(options.throwErrorOnCompileFailure){throw ex;}}return p;}var code_exec={exec:exec_and_diagnose_this_stuff,dump:dumpSourceToFile};// +function exec_and_diagnose_this_stuff(sourcecode,code_execution_rig,options,title){options=options||{};let errname=''+(title||'exec_test');let err_id=errname.replace(/[^a-z0-9_]/ig,'_');if(err_id.length===0){err_id='exec_crash';}const debug=options.debug||0;if(debug)console.warn('generated '+errname+' code under EXEC TEST.');if(debug>1){console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `);}let p;try{// p = eval(sourcecode); +if(typeof code_execution_rig!=='function'){throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function');}chkBugger(sourcecode);p=code_execution_rig.call(this,sourcecode,options,errname,debug);}catch(ex){if(debug>1)console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@');if(debug)console.log('generated '+errname+' source code fatal error: ',ex.message);if(debug>1)console.log('exec-and-diagnose options:',options);if(debug>1)console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@');if(options.dumpSourceCodeOnFailure||1){dumpSourceToFile(sourcecode,errname,err_id,options,ex);}if(options.throwErrorOnCompileFailure){throw ex;}}return p;}var exec={exec:exec_and_diagnose_this_stuff,dump:dumpSourceToFile,convertExceptionToObject};// assert__default['default'](recast__default['default']);//var types = recast.types; //assert(types); //var namedTypes = types.namedTypes; @@ -100,17 +114,17 @@ assert__default['default'](recast__default['default']);//var types = recast.type // WARNING: this regex MUST match the regex for `ID` in ebnf-parser::bnf.l jison language lexer spec! (`ID = [{ALPHA}]{ALNUM}*`) // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! -const ID_REGEX_BASE='[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*';// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +const ID_REGEX_BASE='[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*';// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: -const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode NonAsciiIdentifierStart characters +const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -118,37 +132,37 @@ const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode Non function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); -// As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode +// As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: -// +// // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything -// between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is +// between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. -// +// // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. -// +// // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: -// +// // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A -// +// // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. -// -// To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to +// +// To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the -// first character is fixed and the second character is chosen such that the escape code -// DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input +// first character is fixed and the second character is chosen such that the escape code +// DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: -// -// - the first character is ဩ which is highly visible and allows us to quickly search through a +// +// - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -156,30 +170,30 @@ function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only wan // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will -// pick a different base shape from that CANADIAN SYLLABICS charset. -// - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to +// pick a different base shape from that CANADIAN SYLLABICS charset. +// - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ -// - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered +// - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: -// +// // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 -// - 1489-14A0: ᒉ 5 -// - 14A3-14BA: ᒣ 6 -// - 14C0-14CF: ᓀ +// - 1489-14A0: ᒉ 5 +// - 14A3-14BA: ᒣ 6 +// - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 -// - 1526-153D: ᔦ +// - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -190,58 +204,58 @@ function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only wan // - 1622-162D: ᘢ // // ## JISON identifier formats ## -// +// // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. -// +// // -> (1+2) start-# + end-# -// +// // - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ -// +// // - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# -// +// // - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# -// +// // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - result location reference `@$` -// +// // -> (6) single-@ -// +// // - rule id number `#$` -// +// // -> (3) single-# -// +// // - result stack index `##$` -// +// // -> (4) double-# -// +// // - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -// +// // - 'negative index' location reference, e.g. `@-2` -// +// // -> (7) single-negative-@ -// +// // - 'negative index' stack indexes, e.g. `##-2` -// +// // -> (5) double-negative-# -// +// // count the number of occurrences of ch in src: -// +// // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -258,38 +272,38 @@ function countOccurrences(ch,src){let i=ch.codePointAt(0);return hash[i]||0;}// // Preferrably has ZERO occurrences in the given `input`, but otherwise // deliver the one with the least number of occurrences. function pickChar(set,input){// strip out the spaces: -set=set.replace(/\s+/g,'');assert__default['default'](set.length>=1);let lsidx=0;let lsfreq=Infinity;for(let i=0,l=set.length;i=1);let lsidx=0;let lsfreq=Infinity;for(let i=0,l=set.length;i (1+2) start-# + end-# -// +// // - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ -// +// // - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# -// +// // - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# -// +// // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - result location reference `@$` -// +// // -> (6) single-@ -// +// // - rule id number `#$` -// +// // -> (3) single-# -// +// // - result stack index `##$` -// +// // -> (4) double-# -// +// // - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -// +// // - 'negative index' location reference, e.g. `@-2` -// +// // -> (7) single-negative-@ -// +// // - 'negative index' stack indexes, e.g. `##-2` -// +// // -> (5) double-negative-# -// -const escChar=pickChar(escCharSet);let typeIdChar=[];for(let i=0,l=typeIdCharSets.length;i (1) start-# tokenDirectIdentifierStart:escChar+typeIdChar[0],tokenDirectIdentifierRe:new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`,'g'),// - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart:'$',tokenValueReferenceRe:new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`,'g'),// - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ // - result location reference `@$` -// +// // -> (6) single-@ tokenLocationStart:escChar+typeIdChar[1],tokenLocationRe:new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`,'g'),// - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# // - rule id number `#$` -// +// // -> (3) single-# tokenIdentifierStart:escChar+typeIdChar[2],tokenIdentifierRe:new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`,'g'),// - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# // - result stack index `##$` -// +// // -> (4) double-# tokenStackIndexStart:escChar+typeIdChar[3],tokenStackIndexRe:new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`,'g'),// - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -tokenNegativeValueReferenceStart:escChar+typeIdChar[4],tokenValueReferenceRe:new XRegExp__default['default'](`$-([0-9]+)`,'g'),// - 'negative index' location reference, e.g. `@-2` -// +tokenNegativeValueReferenceStart:escChar+typeIdChar[4],tokenValueReferenceRe:new XRegExp__default['default']('$-([0-9]+)','g'),// - 'negative index' location reference, e.g. `@-2` +// // -> (7) single-negative-@ -tokenNegativeLocationStart:escChar+typeIdChar[5],tokenNegativeLocationRe:new XRegExp__default['default'](`@-([0-9]+)`,'g'),// - 'negative index' stack indexes, e.g. `##-2` -// +tokenNegativeLocationStart:escChar+typeIdChar[5],tokenNegativeLocationRe:new XRegExp__default['default']('@-([0-9]+)','g'),// - 'negative index' stack indexes, e.g. `##-2` +// // -> (5) double-negative-# -tokenNegativeStackIndexStart:escChar+typeIdChar[6],tokenNegativeStackIndexRe:new XRegExp__default['default'](`#-([0-9]+)`,'g'),// combined regex for encoding direction +tokenNegativeStackIndexStart:escChar+typeIdChar[6],tokenNegativeStackIndexRe:new XRegExp__default['default']('#-([0-9]+)','g'),// combined regex for encoding direction tokenDetect4EncodeRe:new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`,'g'),// combined regex for decoding direction tokenDetect4DecodeRe:new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`,'g'),encode:function encodeJisonTokens(src,locationOffsetSpec){let re=this.tokenDetect4EncodeRe;// reset regex re.lastIndex=0;// patch `src` for the lookbehind emulation in the main regex used: src=' '+src;// Perform the encoding, one token at a time via callback function. -// +// // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. -// This is a tad sub-optimal as we won't be able to report errors early +// This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -412,35 +426,35 @@ if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax return src.substring(1);},decode:function decodeJisonTokens(src,locationOffsetSpec){let re=this.tokenDetect4DecodeRe;// reset regex re.lastIndex=0;// patch `src` for the lookbehind emulation in the main regex used: src=' '+src;// Perform the encoding, one token at a time via callback function. -// +// // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. -// This is a tad sub-optimal as we won't be able to report errors early +// This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src=src.replace(re,(m,p1,p2,p3,offset)=>{// p1 is only serving as lookbehind emulation -switch(p2){case this.tokenNegativeValueReferenceStart:return p1+"$-"+p3;case this.tokenNegativeStackIndexStart:return p1+"##-"+p3;case this.tokenStackIndexStart:return p1+"##"+p3;case this.tokenNegativeLocationStart:return p1+"@-"+p3;case this.tokenLocationStart:return p1+"@"+p3;case this.tokenDirectIdentifierStart:// p3 CANNOT be a negative value or token ID +switch(p2){case this.tokenNegativeValueReferenceStart:return p1+'$-'+p3;case this.tokenNegativeStackIndexStart:return p1+'##-'+p3;case this.tokenStackIndexStart:return p1+'##'+p3;case this.tokenNegativeLocationStart:return p1+'@-'+p3;case this.tokenLocationStart:return p1+'@'+p3;case this.tokenDirectIdentifierStart:// p3 CANNOT be a negative value or token ID if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: ${p2+p3+p4} is an illegal negative reference type`,src,offset+p1.length+p2.length);}return p1+p2+p3;}return p1+'#'+p3+'#';case this.tokenIdentifierStart:// p3 CANNOT be a negative value or token ID if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: ${p2+p3+p4} is an illegal negative reference type`,src,offset+p1.length+p2.length);}return p1+p2+p3;}return p1+'#'+p3;default:if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: unexpected jison token sentinel escape ${p2} at ${p2+p3}`,src,offset+p1.length);}return p1+p2+p3;}});// and remove the added prefix which was used for lookbehind emulation: -return src.substring(1);}};}function parseCodeChunkToAST(src,options){src=src.replace(/@/g,'\uFFDA').replace(/#/g,'\uFFDB');var ast=recast__default['default'].parse(src);return ast;}function compileCodeToES5(src,options){options=Object.assign({},{ast:true,code:true,sourceMaps:true,comments:true,filename:'compileCodeToES5.js',sourceFileName:'compileCodeToES5.js',sourceRoot:'.',sourceType:'module',babelrc:false,ignore:["node_modules/**/*.js"],compact:false,retainLines:false,presets:[["@babel/preset-env",{targets:{browsers:["last 2 versions"],node:"8.0"}}]]},options);return babel.transformSync(src,options);// => { code, map, ast } -}function prettyPrintAST(ast,options){var options=options||{};const defaultOptions={tabWidth:2,quote:'single',arrowParensAlways:true,// Do not reuse whitespace (or anything else, for that matter) +return src.substring(1);}};}function parseCodeChunkToAST(src,options){src=src.replace(/@/g,'\uFFDA').replace(/#/g,'\uFFDB');const ast=recast__default['default'].parse(src);return ast;}function compileCodeToES5(src,options){options=Object.assign({},{ast:true,code:true,sourceMaps:true,comments:true,filename:'compileCodeToES5.js',sourceFileName:'compileCodeToES5.js',sourceRoot:'.',sourceType:'module',babelrc:false,ignore:['node_modules/**/*.js'],compact:false,retainLines:false,presets:[['@babel/preset-env',{targets:{browsers:['last 2 versions'],node:'8.0'}}]]},options);return babel.transformSync(src,options);// => { code, map, ast } +}function prettyPrintAST(ast,options){options=options||{};const defaultOptions={tabWidth:2,quote:'single',arrowParensAlways:true,// Do not reuse whitespace (or anything else, for that matter) // when printing generically. -reuseWhitespace:false};for(var key in defaultOptions){if(options[key]===undefined){options[key]=defaultOptions[key];}}let s=recast__default['default'].prettyPrint(ast,defaultOptions);let new_src=s.code;new_src=new_src.replace(/\r\n|\n|\r/g,'\n')// platform dependent EOL fixup +reuseWhitespace:false};for(let key in defaultOptions){if(options[key]===undefined){options[key]=defaultOptions[key];}}let s=recast__default['default'].prettyPrint(ast,defaultOptions);let new_src=s.code;new_src=new_src.replace(/\r\n|\n|\r/g,'\n')// platform dependent EOL fixup // backpatch possible jison variables extant in the prettified code: .replace(/\uFFDA/g,'@').replace(/\uFFDB/g,'#');return new_src;}// validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src,yylloc,options){// make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: -if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cnt);src=lines.join('\n')+src;}if(!src.trim()){return false;}try{var rv=parseCodeChunkToAST(src,options);return false;}catch(ex){return ex.message||"code snippet cannot be parsed";}}// The rough-and-ready preprocessor for any action code block: +if(yylloc&&yylloc.first_line>0){let cnt=yylloc.first_line;let lines=new Array(cnt);src=lines.join('\n')+src;}if(!src.trim()){return false;}try{let rv=parseCodeChunkToAST(src,options);return false;}catch(ex){return ex.message||'code snippet cannot be parsed';}}// The rough-and-ready preprocessor for any action code block: // this one trims off any surplus whitespace and removes any // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -448,7 +462,7 @@ if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cn // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -457,13 +471,13 @@ if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cn // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// -function trimActionCode(src,startMarker){var s=src.trim();// remove outermost set of braces UNLESS there's +// +function trimActionCode(src,startMarker){let s=src.trim();// remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated // code analyzer to simplify the code! @@ -495,34 +509,34 @@ s=s.replace(/^\{([^]*?)\}$/,'$1').trim();}else{// code may not be wrapped or oth // wrapping braces when we can guarantee they're the only ones there, // i.e. only exist as outer wrapping. s=s.replace(/^\{([^}]*)\}$/,'$1').trim();}s=s.replace(/;+$/,'').trim();return s;}var parse2AST={generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST,compileCodeToES5,prettyPrintAST,checkActionBlock,trimActionCode,ID_REGEX_BASE,IN_ID_CHARSET};function chkBugger$1(src){src=String(src);if(src.match(/\bcov_\w+/)){console.error('### ISTANBUL COVERAGE CODE DETECTED ###\n',src);}}/// HELPER FUNCTION: print the function in source code form, properly indented. -/** @public */function printFunctionSourceCode(f){var src=String(f);chkBugger$1(src);return src;}const funcRe=/^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/;const arrowFuncRe=/^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/;/// HELPER FUNCTION: print the function **content** in source code form, properly indented, +/** @public */function printFunctionSourceCode(f){const src=String(f);chkBugger$1(src);return src;}const funcRe=/^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/;const arrowFuncRe=/^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/;/// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// -/** @public */function printFunctionSourceCodeContainer(f){var action=printFunctionSourceCode(f).trim();var args;// Also cope with Arrow Functions (and inline those as well?). +/// +/** @public */function printFunctionSourceCodeContainer(f){let action=printFunctionSourceCode(f).trim();let args;// Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 -var m=funcRe.exec(action);if(m){args=m[1].trim();action=m[2].trim();}else{m=arrowFuncRe.exec(action);if(m){if(m[2]){// non-bracketed arguments: +let m=funcRe.exec(action);if(m){args=m[1].trim();action=m[2].trim();}else{m=arrowFuncRe.exec(action);if(m){if(m[2]){// non-bracketed arguments: args=m[2].trim();}else{// bracketed arguments: may be empty args list! args=m[1].trim();}if(m[5]){// non-bracketed version: implicit `return` statement! // -// Q: Must we make sure we have extra braces around the return value -// to prevent JavaScript from inserting implit EOS (End Of Statement) +// Q: Must we make sure we have extra braces around the return value +// to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already // have formatted the code correctly. -action=m[4].trim();action='return '+action+';';}else{action=m[3].trim();}}else{var e=new Error('Cannot extract code from function');e.subject=action;throw e;}}return{args:args,code:action};}var stringifier={printFunctionSourceCode,printFunctionSourceCodeContainer};// -// -// -function detectIstanbulGlobal(){const gcv="__coverage__";const globalvar=new Function('return this')();var coverage=globalvar[gcv];return coverage||false;}// +action=m[4].trim();action='return '+action+';';}else{action=m[3].trim();}}else{const e=new Error('Cannot extract code from function');e.subject=action;throw e;}}return{args:args,code:action};}var stringifier={printFunctionSourceCode,printFunctionSourceCodeContainer};// +// +// +function detectIstanbulGlobal(){const gcv='__coverage__';const globalvar=new Function('return this')();const coverage=globalvar[gcv];return coverage||false;}// // Helper library for safe code execution/compilation // // MIT Licensed @@ -540,7 +554,7 @@ function detectIstanbulGlobal(){const gcv="__coverage__";const globalvar=new Fun // The default assumed is the standard JavaScript `RegExp` class. // // Return FALSE when there's no failure, otherwise return an `Error` info object. -function checkRegExp(re_src,re_flags,XRegExp){var re;// were we fed a RegExp object or a string? +function checkRegExp(re_src,re_flags,XRegExp){let re;// were we fed a RegExp object or a string? if(re_src&&typeof re_src.source==='string'&&typeof re_src.flags==='string'&&typeof re_src.toString==='function'&&typeof re_src.test==='function'&&typeof re_src.exec==='function'){// we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member // and the `.toString()` method to produce something that's compileable by XRegExp // at least... @@ -554,7 +568,7 @@ if(re_src==null){return new Error('invalid regular expression source: '+re_src); // The default assumed is the standard JavaScript `RegExp` class. // // Return FALSE when the input is not a legal regex. -function getRegExpInfo(re_src,re_flags,XRegExp){var re1,re2,m1,m2;// were we fed a RegExp object or a string? +function getRegExpInfo(re_src,re_flags,XRegExp){let re1,re2,m1,m2;// were we fed a RegExp object or a string? if(re_src&&typeof re_src.source==='string'&&typeof re_src.flags==='string'&&typeof re_src.toString==='function'&&typeof re_src.test==='function'&&typeof re_src.exec==='function'){// we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member // and the `.toString()` method to produce something that's compileable by XRegExp // at least... @@ -566,33 +580,42 @@ return false;}else{re_src=''+re_src;if(re_flags==null){re_flags=undefined;// `ne // wrap it and append `(?:)` to ensure it matches // the empty string, then match it against it to // obtain the `match` array. -re1=new XRegExp(re_src,re_flags);re2=new XRegExp('(?:'+re_src+')|(?:)',re_flags);m1=re1.exec('');m2=re2.exec('');return{acceptsEmptyString:!!m1,captureCount:m2.length-1};}catch(ex){return false;}}var reHelpers={checkRegExp:checkRegExp,getRegExpInfo:getRegExpInfo};var cycleref=[];var cyclerefpath=[];var linkref=[];var linkrefpath=[];var path=[];function shallow_copy(src){if(typeof src==='object'){if(src instanceof Array){return src.slice();}var dst={};if(src instanceof Error){dst.name=src.name;dst.message=src.message;dst.stack=src.stack;}for(var k in src){if(Object.prototype.hasOwnProperty.call(src,k)){dst[k]=src[k];}}return dst;}return src;}function shallow_copy_and_strip_depth(src,parentKey){if(typeof src==='object'){var dst;if(src instanceof Array){dst=src.slice();for(var i=0,len=dst.length;i '+parentKey+'.'+k+']';}else{dst[k]=src[k];}}}}return dst;}return src;}function stripErrorStackPaths(msg){// strip away devbox-specific paths in error stack traces in the output: -msg=msg.replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi,'at $1(/$2)').replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi,'at /$1');return msg;}function trim_array_tail(arr){if(arr instanceof Array){for(var len=arr.length;len>0;len--){if(arr[len-1]!=null){break;}}arr.length=len;}}function treat_value_stack(v){if(v instanceof Array){var idx=cycleref.indexOf(v);if(idx>=0){v='[cyclic reference to parent array --> '+cyclerefpath[idx]+']';}else{idx=linkref.indexOf(v);if(idx>=0){v='[reference to sibling array --> '+linkrefpath[idx]+', length = '+v.length+']';}else{cycleref.push(v);cyclerefpath.push(path.join('.'));linkref.push(v);linkrefpath.push(path.join('.'));v=treat_error_infos_array(v);cycleref.pop();cyclerefpath.pop();}}}else if(v){v=treat_object(v);}return v;}function treat_error_infos_array(arr){var inf=arr.slice();trim_array_tail(inf);for(var key=0,len=inf.length;key '+parentKey+'.'+k+']';}else{dst[k]=src[k];}}}}return dst;}return src;}// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. +function stripErrorStackPaths(msg){// strip away devbox-specific paths in error stack traces in the output: +// and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': +msg=msg.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi,'at $1(/$2:$3)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi,'at /$1:$2');return msg;}// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj){if(typeof obj==='string'){// and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': +let msg=obj.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi,'at $1(/$2)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi,'at /$1');return msg;}if(obj){if(obj.stack){obj.stack=cleanStackTrace4Comparison(obj.stack);}let keys=Object.keys(obj);for(let i in keys){let key=keys[i];let el=obj[key];cleanStackTrace4Comparison(el);}}return obj;}function trim_array_tail(arr){if(arr instanceof Array){for(var len=arr.length;len>0;len--){if(arr[len-1]!=null){break;}}arr.length=len;}}function treat_value_stack(v){if(v instanceof Array){let idx=cycleref.indexOf(v);if(idx>=0){v='[cyclic reference to parent array --> '+cyclerefpath[idx]+']';}else{idx=linkref.indexOf(v);if(idx>=0){v='[reference to sibling array --> '+linkrefpath[idx]+', length = '+v.length+']';}else{cycleref.push(v);cyclerefpath.push(path.join('.'));linkref.push(v);linkrefpath.push(path.join('.'));v=treat_error_infos_array(v);cycleref.pop();cyclerefpath.pop();}}}else if(v){v=treat_object(v);}return v;}function treat_error_infos_array(arr){let inf=arr.slice();trim_array_tail(inf);for(let key=0,len=inf.length;key=0){// cyclic reference, most probably an error instance. +e=shallow_copy(e);if(e&&e.hash){path.push('hash');e.hash=treat_hash(e.hash);path.pop();}if(e.parser){path.push('parser');e.parser=treat_parser(e.parser);path.pop();}if(e.lexer){path.push('lexer');e.lexer=treat_lexer(e.lexer);path.pop();}if(e.__error_infos){path.push('__error_infos');e.__error_infos=treat_value_stack(e.__error_infos);path.pop();}if(e.__error_recovery_infos){path.push('__error_recovery_infos');e.__error_recovery_infos=treat_value_stack(e.__error_recovery_infos);path.pop();}trim_array_tail(e.symbol_stack);trim_array_tail(e.state_stack);trim_array_tail(e.location_stack);if(e.value_stack){path.push('value_stack');e.value_stack=treat_value_stack(e.value_stack);path.pop();}return e;}function treat_object(e){if(e&&typeof e==='object'){let idx=cycleref.indexOf(e);if(idx>=0){// cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: e=shallow_copy_and_strip_depth(e,cyclerefpath[idx]);}else{idx=linkref.indexOf(e);if(idx>=0){e='[reference to sibling --> '+linkrefpath[idx]+']';}else{cycleref.push(e);cyclerefpath.push(path.join('.'));linkref.push(e);linkrefpath.push(path.join('.'));e=treat_error_report_info(e);cycleref.pop();cyclerefpath.pop();}}}return e;}// strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. -function trimErrorForTestReporting(e){cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];if(e){e=treat_object(e);}cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];return e;}var helpers={rmCommonWS,camelCase,mkIdentifier,isLegalIdentifierInput,scanRegExp,dquote,trimErrorForTestReporting,stripErrorStackPaths,checkRegExp:reHelpers.checkRegExp,getRegExpInfo:reHelpers.getRegExpInfo,exec:code_exec.exec,dump:code_exec.dump,generateMapper4JisonGrammarIdentifiers:parse2AST.generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST:parse2AST.parseCodeChunkToAST,compileCodeToES5:parse2AST.compileCodeToES5,prettyPrintAST:parse2AST.prettyPrintAST,checkActionBlock:parse2AST.checkActionBlock,trimActionCode:parse2AST.trimActionCode,ID_REGEX_BASE:parse2AST.ID_REGEX_BASE,IN_ID_CHARSET:parse2AST.IN_ID_CHARSET,printFunctionSourceCode:stringifier.printFunctionSourceCode,printFunctionSourceCodeContainer:stringifier.printFunctionSourceCodeContainer,detectIstanbulGlobal};// See also: +function trimErrorForTestReporting(e){cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];if(e){e=treat_object(e);}cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];return e;}var helpers={rmCommonWS,camelCase,mkIdentifier,isLegalIdentifierInput,scanRegExp,dquote,trimErrorForTestReporting,stripErrorStackPaths,cleanStackTrace4Comparison,checkRegExp:reHelpers.checkRegExp,getRegExpInfo:reHelpers.getRegExpInfo,exec:exec.exec,dump:exec.dump,convertExceptionToObject:exec.convertExceptionToObject,generateMapper4JisonGrammarIdentifiers:parse2AST.generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST:parse2AST.parseCodeChunkToAST,compileCodeToES5:parse2AST.compileCodeToES5,prettyPrintAST:parse2AST.prettyPrintAST,checkActionBlock:parse2AST.checkActionBlock,trimActionCode:parse2AST.trimActionCode,ID_REGEX_BASE:parse2AST.ID_REGEX_BASE,IN_ID_CHARSET:parse2AST.IN_ID_CHARSET,printFunctionSourceCode:stringifier.printFunctionSourceCode,printFunctionSourceCodeContainer:stringifier.printFunctionSourceCodeContainer,detectIstanbulGlobal};// 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. -function JisonParserError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonParserError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8/Chrome engine +function JisonParserError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonParserError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){let ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8/Chrome engine Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonParserError.prototype,Error.prototype);}else{JisonParserError.prototype=Object.create(Error.prototype);}JisonParserError.prototype.constructor=JisonParserError;JisonParserError.prototype.name='JisonParserError';// helper: reconstruct the productions[] table -function bp(s){var rv=[];var p=s.pop;var r=s.rule;for(var i=0,l=p.length;i1){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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) +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 delimited set of lexer start conditions';break;case 37:/*! Production:: start_productions_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -yy.__options_flags__=0;yy.__options_category_description__='the lexer rules definition section';break;case 38:/*! Production:: start_epilogue_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -yy.__options_flags__=0;yy.__options_category_description__='the lexer epilogue section';break;case 39:/*! Production:: rules : rules scoped_rules_collective */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1].concat(yyvstack[yysp]);break;case 40:/*! Production:: rules : rules rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1].concat([yyvstack[yysp]]);break;case 41:/*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 30:/*! Production:: option_keyword : OPTIONS */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__=yyvstack[yysp];break;case 31:/*! Production:: import_keyword : IMPORT */case 33:/*! Production:: include_keyword : INCLUDE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS;yy.__options_category_description__=yyvstack[yysp];break;case 32:/*! Production:: init_code_keyword : CODE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS|OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS;yy.__options_category_description__=yyvstack[yysp];break;case 34:/*! Production:: start_inclusive_keyword : START_INC */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__='the inclusive lexer start conditions set (%s)';break;case 35:/*! Production:: start_exclusive_keyword : START_EXC */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__='the exclusive lexer start conditions set (%x)';break;case 36:/*! Production:: start_conditions_marker : "<" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES|OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME;yy.__options_category_description__='the <...> delimited set of lexer start conditions';break;case 37:/*! Production:: start_productions_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=0;yy.__options_category_description__='the lexer rules definition section';break;case 38:/*! Production:: start_epilogue_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=0;yy.__options_category_description__='the lexer epilogue section';break;case 39:/*! Production:: rules : rules scoped_rules_collective */ // 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].concat(yyvstack[yysp]);break;case 40:/*! Production:: rules : rules rule */ // 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].concat([yyvstack[yysp]]);break;case 41:/*! Production:: rules : rules 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]);if(srcCode){var rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);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);}this.$=yyvstack[yysp-3];break;case 42:/*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);}yy.actionInclude.push(srcCode);}this.$=yyvstack[yysp-3];break;case 42:/*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. -this.$=yyvstack[yysp-1];break;case 43:/*! Production:: rules : rules ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) +this.$=yyvstack[yysp-1];break;case 43:/*! Production:: rules : rules ACTION_START_AT_SOL 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,-,-) 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. @@ -1036,8 +1059,8 @@ var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or simila Technical error report: ${yyvstack[yysp].errStr} - `);this.$=yyvstack[yysp-2];break;case 44:/*! Production:: rules : rules ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);this.$=yyvstack[yysp-2];break;case 44:/*! Production:: rules : rules 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,-,-) 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: @@ -1065,8 +1088,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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 the top section of the lexer spec file, above the first '%%' @@ -1075,14 +1098,14 @@ yyparser.yyError(rmCommonWS$1` Erroneous code: ${yylexer.prettyPrintRange(yylstack[yysp])} - `);this.$=yyvstack[yysp-1];break;case 51:/*! Production:: rules : %epsilon */case 58:/*! Production:: rule_block : %epsilon */ // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) -this.$=[];break;case 52:/*! Production:: scoped_rules_collective : start_conditions rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -if(yyvstack[yysp-1]){yyvstack[yysp].unshift(yyvstack[yysp-1]);}this.$=[yyvstack[yysp]];break;case 53:/*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) -if(yyvstack[yysp-3]){yyvstack[yysp-1].forEach(function(d){d.unshift(yyvstack[yysp-3]);});}this.$=yyvstack[yysp-1];break;case 54:/*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp-3];this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + `);this.$=yyvstack[yysp-1];break;case 51:/*! Production:: rules : %epsilon */case 58:/*! Production:: rule_block : %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 52:/*! Production:: scoped_rules_collective : start_conditions rule */ // 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,-,-) +if(yyvstack[yysp-1]){yyvstack[yysp].unshift(yyvstack[yysp-1]);}this.$=[yyvstack[yysp]];break;case 53:/*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ // 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,-,-) +if(yyvstack[yysp-3]){yyvstack[yysp-1].forEach(function(d){d.unshift(yyvstack[yysp-3]);});}this.$=yyvstack[yysp-1];break;case 54:/*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): +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$1` Seems you made a mistake while specifying one of the lexer rules inside the start condition @@ -1094,8 +1117,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp-1].errStr} - `);break;case 55:/*! Production:: scoped_rules_collective : start_conditions "{" error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 55:/*! Production:: scoped_rules_collective : start_conditions "{" 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,-,-) yyparser.yyError(rmCommonWS$1` Seems you did not correctly bracket a lexer rules set inside the start condition @@ -1107,8 +1130,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 56:/*! Production:: scoped_rules_collective : start_conditions error "}" */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 56:/*! Production:: scoped_rules_collective : start_conditions 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,-,-) yyparser.yyError(rmCommonWS$1` Seems you did not correctly bracket a lexer rules set inside the start condition @@ -1120,17 +1143,17 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp-1].errStr} - `);break;case 57:/*! Production:: rule_block : rule_block rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 57:/*! Production:: rule_block : rule_block rule */ // 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.$.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` 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 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 // will uncover any illegal action code following the arrow operator, e.g. // multiple statements separated by semicolon. @@ -1151,8 +1174,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 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.: @@ -1167,8 +1190,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 63:/*! Production:: rule : regex ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);break;case 63:/*! Production:: rule : regex 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,-,-) // TODO: REWRITE this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` A lexer rule regex action code must be properly terminated and must contain a JavaScript statement block (or anything that does parse as such), e.g.: @@ -1185,8 +1208,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 64:/*! Production:: rule : regex ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);break;case 64:/*! Production:: rule : regex ACTION_START_AT_SOL 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,-,-) // TODO: REWRITE this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` A lexer rule regex action code must be properly terminated and must contain a JavaScript statement block (or anything that does parse as such), e.g.: @@ -1222,8 +1245,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 65:/*! Production:: rule : regex error */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);break;case 65:/*! Production:: rule : regex 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,-,-) this.$=[yyvstack[yysp-1],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Lexer rule regex action code declaration error? @@ -1232,33 +1255,33 @@ this.$=[yyvstack[yysp-1],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 66:/*! Production:: action : action ACTION_BODY */case 83:/*! Production:: regex_concat : regex_concat regex_base */case 95:/*! Production:: regex_base : regex_base range_regex */case 106:/*! Production:: regex_set : regex_set regex_set_atom */case 127:/*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+yyvstack[yysp];break;case 67:/*! Production:: action : action include_macro_code */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'\n\n'+yyvstack[yysp]+'\n\n';break;case 68:/*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 66:/*! Production:: action : action ACTION_BODY */case 83:/*! Production:: regex_concat : regex_concat regex_base */case 95:/*! Production:: regex_base : regex_base range_regex */case 106:/*! Production:: regex_set : regex_set regex_set_atom */case 127:/*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ // 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]+yyvstack[yysp];break;case 67:/*! Production:: action : action 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]+'\n\n'+yyvstack[yysp]+'\n\n';break;case 68:/*! Production:: action : action INCLUDE_PLACEMENT_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` You may place the '%include' instruction only at the start/front of a line. Its use is not permitted at this position: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 69:/*! Production:: action : action BRACKET_MISSING */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 69:/*! Production:: action : action BRACKET_MISSING */ // 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` Missing curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: '{ ... }'. Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 70:/*! Production:: action : action BRACKET_SURPLUS */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 70:/*! Production:: action : action BRACKET_SURPLUS */ // 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` Too many curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: '{ ... }'. Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 71:/*! Production:: action : action UNTERMINATED_STRING_ERROR */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 71:/*! Production:: action : action UNTERMINATED_STRING_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` Unterminated string constant in lexer rule action block. @@ -1267,10 +1290,10 @@ yyparser.yyError(rmCommonWS$1` Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 72:/*! Production:: action : %epsilon */case 77:/*! Production:: regex_list : %epsilon */ // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0,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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 72:/*! Production:: action : %epsilon */case 77:/*! Production:: regex_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 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 // accordingly: @@ -1291,8 +1314,8 @@ 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,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,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` Seems you did not correctly terminate the start condition set @@ -1304,8 +1327,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -1344,22 +1367,22 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+'|'+yyvstack[yysp];break;case 79:/*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'|';break;case 80:/*! Production:: nonempty_regex_list : "|" regex_concat */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='|'+yyvstack[yysp];break;case 81:/*! Production:: nonempty_regex_list : "|" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='|';break;case 85:/*! Production:: regex_base : "(" regex_list ")" */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$='('+yyvstack[yysp-1]+')';break;case 86:/*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+')';break;case 87:/*! Production:: regex_base : "(" regex_list error */case 88:/*! Production:: regex_base : SPECIAL_GROUP regex_list error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) +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,-,-): +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,-,-) +this.$=yyvstack[yysp-2]+'|'+yyvstack[yysp];break;case 79:/*! Production:: nonempty_regex_list : nonempty_regex_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,-,-) +this.$=yyvstack[yysp-1]+'|';break;case 80:/*! Production:: nonempty_regex_list : "|" regex_concat */ // 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];break;case 81:/*! Production:: 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,-,-) +this.$='|';break;case 85:/*! Production:: regex_base : "(" regex_list ")" */ // 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-1]+')';break;case 86:/*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ // 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-1]+')';break;case 87:/*! Production:: regex_base : "(" regex_list error */case 88:/*! Production:: regex_base : SPECIAL_GROUP regex_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,-,-) yyparser.yyError(rmCommonWS$1` Seems you did not correctly bracket a lex rule regex part in '(...)' braces. @@ -1368,30 +1391,30 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 89:/*! Production:: regex_base : regex_base "+" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'+';break;case 90:/*! Production:: regex_base : regex_base "*" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'*';break;case 91:/*! Production:: regex_base : regex_base "?" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'?';break;case 92:/*! Production:: regex_base : "/" regex_base */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='(?='+yyvstack[yysp]+')';break;case 93:/*! Production:: regex_base : "/!" regex_base */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='(?!'+yyvstack[yysp]+')';break;case 94:/*! Production:: regex_base : name_expansion */case 96:/*! Production:: regex_base : any_group_regex */case 100:/*! Production:: regex_base : REGEX_SPECIAL_CHAR */case 101:/*! Production:: regex_base : literal_string */case 107:/*! Production:: regex_set : regex_set_atom */case 108:/*! Production:: regex_set_atom : REGEX_SET */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -break;case 97:/*! Production:: regex_base : "." */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='.';break;case 98:/*! Production:: regex_base : "^" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='^';break;case 99:/*! Production:: regex_base : "$" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='$';break;case 102:/*! Production:: regex_base : ESCAPED_CHAR */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp]));break;case 104:/*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+yyvstack[yysp];break;case 105:/*! Production:: any_group_regex : REGEX_SET_START regex_set error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 89:/*! Production:: regex_base : regex_base "+" */ // 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]+'+';break;case 90:/*! Production:: regex_base : regex_base "*" */ // 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]+'*';break;case 91:/*! Production:: regex_base : regex_base "?" */ // 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]+'?';break;case 92:/*! Production:: regex_base : "/" regex_base */ // 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]+')';break;case 93:/*! Production:: regex_base : "/!" regex_base */ // 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]+')';break;case 94:/*! Production:: regex_base : name_expansion */case 96:/*! Production:: regex_base : any_group_regex */case 100:/*! Production:: regex_base : REGEX_SPECIAL_CHAR */case 101:/*! Production:: regex_base : literal_string */case 107:/*! Production:: regex_set : regex_set_atom */case 108:/*! Production:: regex_set_atom : REGEX_SET */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +break;case 97:/*! Production:: regex_base : "." */ // 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.$='.';break;case 98:/*! Production:: regex_base : "^" */ // 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.$='^';break;case 99:/*! Production:: regex_base : "$" */ // 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.$='$';break;case 102:/*! Production:: regex_base : ESCAPED_CHAR */ // 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.$=encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp]));break;case 104:/*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_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,-,-) +this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+yyvstack[yysp];break;case 105:/*! Production:: any_group_regex : REGEX_SET_START regex_set 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,-,-) yyparser.yyError(rmCommonWS$1` Seems you did not correctly bracket a lex rule regex set in '[...]' brackets. @@ -1400,16 +1423,16 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 109:/*! Production:: regex_set_atom : name_expansion */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + `);break;case 109:/*! Production:: regex_set_atom : name_expansion */ // 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,-,-) if(XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g,''))&&yyvstack[yysp].toUpperCase()!==yyvstack[yysp]){// treat this as part of an XRegExp `\p{...}` Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) +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,-,-): +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,-,-): +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` You may only specify one name/argument in a ${yy.__options_category_description__} statement. @@ -1424,28 +1447,28 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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` You may only specify one name/argument in a ${yy.__options_category_description__} statement. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp]),yylstack[yysp-3])} - `);}this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 115:/*! Production:: option_list : option */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=[yyvstack[yysp]];break;case 116:/*! Production:: option : option_name */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=[yyvstack[yysp],true];break;case 117:/*! Production:: option : option_name "=" option_value */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);}this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 115:/*! Production:: option_list : option */ // 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 116:/*! Production:: option : 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,-,-) +this.$=[yyvstack[yysp],true];break;case 117:/*! Production:: option : option_name "=" option_value */ // 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_VALUE){yyparser.yyError(rmCommonWS$1` The entries in a ${yy.__options_category_description__} statement MUST NOT be assigned values, such as '${$option_name}=${$option_value}'. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp],yylstack[yysp-2]),yylstack[yysp-4])} - `);}this.$=[yyvstack[yysp-2],yyvstack[yysp]];break;case 118:/*! Production:: option : option_name "=" error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);}this.$=[yyvstack[yysp-2],yyvstack[yysp]];break;case 118:/*! Production:: option : option_name "=" 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$1` Internal error: option "${$option}" value assignment failure in a ${yy.__options_category_description__} statement. @@ -1455,8 +1478,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 119:/*! Production:: option : DUMMY3 error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);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` Expected a valid option name${with_value_msg} in a ${yy.__options_category_description__} statement. @@ -1465,8 +1488,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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: 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 @@ -1480,8 +1503,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. @@ -1491,21 +1514,21 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=parseValue(yyvstack[yysp]);break;case 124:/*! Production:: epilogue : start_epilogue_marker */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,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,-,-) +this.$=parseValue(yyvstack[yysp]);break;case 124:/*! Production:: epilogue : start_epilogue_marker */ // 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.$='';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` 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,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,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. @@ -1514,8 +1537,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 128:/*! Production:: epilogue_chunks : epilogue_chunks error */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);break;case 128:/*! Production:: epilogue_chunks : epilogue_chunks 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$1` Module code declaration error? @@ -1525,8 +1548,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);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` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -1535,8 +1558,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -1545,12 +1568,12 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,LU,LUbA): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA) +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`: path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$1` @@ -1577,8 +1600,8 @@ var fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});var 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,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,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. @@ -1588,14 +1611,14 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} `);break;}},table:bt({len:u([15,1,14,21,1,13,28,22,s,[9,3],13,1,9,13,c,[6,3],27,s,[31,5],1,44,4,1,13,6,25,24,25,23,23,17,17,s,[24,8],26,5,24,24,9,13,8,9,1,s,[9,5],13,9,13,c,[3,3],c,[13,3],2,1,26,26,9,26,c,[5,3],s,[26,4],7,24,4,5,8,c,[60,3],c,[59,3],s,[24,5],2,3,2,25,25,6,s,[4,3],13,7,8,4,8,13,13,s,[7,6],9,5,s,[13,3],9,1,13,9,26,26,6,1,5,9,5,5,26,17,c,[85,4],27,10,s,[24,7],4,s,[8,3],9,7,9,1,1,26,5,c,[30,3],23,27,26,9,27,9,27,9,27,1,16,7,1,13,13,5,26,15,26,s,[27,3],16,13]),symbol:u([1,2,19,22,s,[24,6,1],31,32,33,55,57,1,c,[16,13],58,c,[14,13],56,s,[59,4,1],64,65,67,c,[36,14],1,2,3,7,8,s,[13,4,1],c,[19,10],s,[40,6,1],49,50,69,2,c,[26,6],c,[16,8],75,s,[77,5,1],85,2,11,51,52,53,s,[86,4,1],c,[9,10],23,30,s,[35,5,1],73,c,[90,13],2,c,[32,9],c,[23,14],c,[63,17],c,[144,40],c,[27,5],11,c,[28,22],c,[75,3],c,[31,125],1,c,[182,25],c,[373,5],s,[66,5,2],c,[320,7],90,1,33,68,90,20,c,[276,14],7,20,22,25,34,c,[367,3],9,c,[68,4],c,[12,4],c,[62,8],c,[370,6],c,[25,19],c,[24,8],s,[10,7,1],c,[27,10],48,49,50,84,c,[49,8],c,[45,8],s,[76,6,1],c,[72,9],c,[23,15],c,[485,13],c,[17,21],c,[105,24],c,[24,189],s,[46,5,1],44,47,80,82,83,c,[79,48],11,17,21,c,[500,3],c,[729,18],17,21,25,c,[24,3],c,[8,3],18,c,[9,6],c,[10,10],c,[9,26],c,[76,22],c,[849,7],63,93,c,[796,15],c,[13,11],c,[57,22],c,[22,9],21,11,17,c,[95,4],c,[10,4],25,c,[670,27],c,[26,26],c,[981,10],c,[35,26],c,[88,52],c,[26,105],2,22,24,54,91,92,2,4,c,[1221,14],72,c,[1222,8],c,[465,3],c,[35,5],c,[1158,8],c,[8,4],c,[1307,14],c,[912,78],c,[760,117],9,2,7,9,c,[5,4],c,[152,47],84,2,44,46,47,80,83,c,[6,4],c,[4,8],c,[614,14],c,[602,6],c,[754,9],52,53,c,[12,9],c,[689,26],c,[592,7],c,[7,35],c,[1571,14],c,[82,26],c,[430,14],c,[688,8],2,c,[842,23],c,[580,56],92,c,[534,3],c,[7,3],c,[1765,11],c,[14,3],c,[5,6],c,[794,26],5,c,[630,14],71,5,c,[159,10],c,[9,17],s,[1,4,2],c,[72,24],c,[976,9],c,[628,48],c,[24,121],c,[560,4],c,[1290,10],c,[8,13],c,[205,9],c,[495,14],63,93,21,21,c,[388,31],c,[5,5],c,[1301,11],c,[14,3],c,[354,15],c,[984,8],c,[333,27],c,[100,26],c,[549,11],c,[62,25],c,[36,72],6,c,[1170,16],c,[53,7],21,c,[744,28],c,[621,29],c,[266,15],c,[745,28],c,[284,27],c,[27,52],c,[203,16],c,[182,13]]),type:u([s,[2,13],0,0,1,c,[16,14],c,[30,15],s,[0,6],s,[2,41],c,[42,16],c,[64,12],c,[9,18],c,[49,19],c,[32,16],c,[22,19],c,[145,45],s,[2,181],s,[0,18],c,[20,4],c,[62,45],c,[25,24],c,[441,40],c,[442,13],c,[23,31],c,[17,34],c,[416,210],c,[57,111],c,[76,42],c,[98,34],c,[57,22],c,[22,10],c,[165,66],c,[509,189],c,[756,25],c,[740,56],c,[912,70],c,[286,136],c,[25,29],c,[275,31],c,[240,14],c,[227,82],c,[1144,56],c,[53,22],c,[775,59],c,[58,15],c,[149,63],c,[1837,18],c,[81,35],c,[628,51],c,[1393,171],c,[197,47],c,[268,26],c,[272,64],c,[62,36],c,[36,72],s,[2,226]]),state:u([s,[1,5,1],13,15,16,8,9,6,s,[25,4,2],32,37,38,43,49,51,52,54,58,c,[4,3],60,63,c,[5,3],65,c,[4,3],67,c,[4,3],77,79,80,75,76,85,81,70,71,82,83,c,[38,6],69,81,87,90,c,[8,4],91,c,[4,3],95,97,98,c,[20,5],99,c,[7,6],100,c,[4,3],101,c,[4,3],105,102,103,108,52,54,c,[3,3],119,114,c,[8,6],c,[3,3],127,130,132,136,c,[66,7],143,c,[87,3],144,c,[67,9],95,95,105,151,152,52,54,153,155,c,[22,3],157,119,114,161,163,165,168,170,172,c,[49,3],c,[29,4],c,[67,5],119,114,182,c,[57,7],c,[12,4],119,114]),mode:u([s,[2,27],s,[1,13],c,[27,15],c,[53,38],c,[66,27],c,[46,12],c,[65,23],s,[2,197],c,[271,26],c,[340,23],c,[25,4],c,[27,6],c,[264,10],c,[20,20],c,[12,5],c,[66,18],c,[89,5],c,[102,14],s,[1,38],s,[2,218],c,[220,50],c,[274,30],c,[25,6],c,[85,37],c,[736,26],c,[52,52],c,[427,61],c,[54,34],c,[515,158],c,[696,29],c,[1120,25],c,[845,62],c,[689,122],c,[1055,8],c,[151,24],c,[24,20],c,[539,29],c,[29,12],c,[1006,79],c,[660,49],c,[45,8],c,[793,47],c,[131,31],c,[439,50],c,[44,16],c,[125,9],c,[161,22],c,[663,28],c,[599,24],c,[1703,174],c,[875,16],c,[920,43],c,[1192,22],c,[260,51],c,[123,34],c,[34,69],c,[1284,181],s,[2,51]]),goto:u([s,[7,13],s,[9,13],6,17,7,10,11,12,14,21,22,23,19,20,18,24,s,[8,13],51,26,s,[51,25],28,30,33,35,39,40,41,34,36,42,s,[44,5,1],50,55,53,56,57,59,c,[5,4],61,s,[72,7],s,[17,13],62,64,c,[27,4],s,[22,13],66,c,[18,4],68,c,[5,4],s,[29,13],s,[37,27],s,[34,31],s,[35,31],s,[30,31],s,[31,31],s,[32,31],1,4,86,c,[272,6],72,73,74,78,c,[330,5],84,c,[282,8],5,84,88,s,[11,13],75,89,s,[75,4],81,81,33,81,c,[48,4],s,[81,4],c,[42,8],82,82,33,82,c,[20,4],s,[82,4],c,[20,8],s,[84,4],92,93,94,s,[84,14],96,84,84,77,30,33,77,c,[384,12],c,[16,16],c,[413,13],c,[13,13],s,[94,24],s,[96,24],s,[97,24],s,[98,24],s,[99,24],s,[100,24],s,[101,24],s,[102,24],s,[103,26],45,104,s,[111,24],s,[112,24],55,107,106,c,[640,3],s,[13,13],s,[115,8],s,[116,3],109,s,[116,5],110,s,[120,9],s,[121,9],s,[122,9],s,[123,9],55,107,111,c,[73,3],s,[15,13],112,120,113,s,[115,4,1],s,[18,13],s,[19,13],55,107,121,c,[52,3],s,[21,13],55,107,122,c,[19,3],c,[78,3],124,c,[7,3],126,125,2,s,[39,26],s,[40,26],128,s,[72,7],s,[42,26],129,s,[45,26],s,[46,26],s,[47,26],s,[48,26],s,[49,26],s,[50,26],124,131,133,134,135,138,137,c,[1118,14],142,140,139,141,s,[38,5],c,[1071,4],s,[36,4],3,s,[10,13],79,79,33,79,c,[47,4],s,[79,4],c,[51,8],80,80,33,80,c,[20,4],s,[80,4],c,[20,8],s,[83,4],c,[845,3],s,[83,14],96,83,83,s,[89,24],s,[90,24],s,[91,24],s,[95,24],s,[110,24],146,145,76,89,76,148,147,s,[92,5],93,94,s,[92,14],96,c,[19,3],s,[93,3],c,[24,3],s,[93,14],96,93,93,150,45,149,104,s,[107,4],s,[108,4],s,[109,4],s,[12,13],c,[290,4],s,[114,8],154,56,57,s,[119,8],s,[14,13],s,[16,13],s,[66,7],s,[67,7],s,[68,7],s,[69,7],s,[70,7],s,[71,7],156,c,[92,4],s,[33,5],s,[20,13],s,[23,13],s,[24,13],158,s,[72,7],159,s,[28,13],160,c,[793,6],s,[43,26],s,[44,26],125,162,c,[541,3],126,s,[129,5],164,s,[72,7],s,[132,5],s,[133,5],s,[52,26],166,s,[58,15],167,169,s,[72,7],171,s,[72,7],173,s,[72,7],s,[65,27],175,55,107,174,c,[255,3],78,78,33,78,c,[599,4],s,[78,4],c,[599,8],s,[85,24],s,[87,24],s,[86,24],s,[88,24],s,[104,24],s,[105,24],s,[106,4],s,[113,8],s,[117,8],s,[118,8],55,107,176,c,[198,3],s,[135,7],177,c,[394,6],178,179,s,[41,26],s,[127,5],s,[128,5],180,c,[45,6],s,[131,5],181,c,[927,14],55,55,183,s,[55,24],s,[56,26],184,c,[80,6],s,[63,27],185,c,[34,6],s,[64,27],186,c,[34,6],s,[62,27],187,s,[74,16],s,[134,7],188,s,[26,13],s,[27,13],s,[130,5],s,[53,26],s,[57,15],s,[54,26],s,[59,27],s,[60,27],s,[61,27],s,[73,16],s,[25,13]])}),defaultActions:bda({idx:u([0,2,5,11,14,s,[17,8,1],28,s,[37,9,1],47,48,50,51,s,[54,4,1],59,61,62,64,69,70,71,73,s,[75,6,1],84,86,87,88,s,[92,5,1],s,[103,4,1],108,s,[110,9,1],s,[120,4,1],126,128,129,131,132,134,135,136,142,s,[145,10,1],156,160,161,162,164,s,[167,5,2],176,s,[178,11,1]]),goto:u([7,9,8,17,22,29,37,34,35,30,31,32,1,11,94,s,[96,8,1],111,112,13,115,s,[120,4,1],15,18,19,21,2,39,40,42,s,[45,6,1],38,36,3,10,89,90,91,95,110,107,108,109,12,114,119,14,16,s,[66,6,1],33,20,23,24,28,43,44,126,129,132,133,52,65,85,87,86,88,104,105,106,113,117,118,135,41,127,128,131,56,63,64,62,74,134,26,27,130,53,57,54,59,60,61,73,25])}),parseError:function parseError(str,hash,ExceptionClass){if(hash.recoverable){if(typeof this.trace==='function'){this.trace(str);}hash.destroy();// destroy... well, *almost*! -}else{if(typeof this.trace==='function'){this.trace(str);}if(!ExceptionClass){ExceptionClass=this.JisonParserError;}throw new ExceptionClass(str,hash);}},parse:function parse(input){var self=this;var stack=new Array(128);// token stack: stores token which leads to state at the same index (column storage) -var sstack=new Array(128);// state stack: stores states (column storage) -var vstack=new Array(128);// semantic value stack -var lstack=new Array(128);// location stack -var table=this.table;var sp=0;// 'stack pointer': index into the stacks -var yyloc;var symbol=0;var preErrorSymbol=0;var lastEofErrorStateDepth=Infinity;var recoveringErrorInfo=null;var recovering=0;// (only used when the grammar contains error recovery rules) -var TERROR=this.TERROR;var EOF=this.EOF;var ERROR_RECOVERY_TOKEN_DISCARD_COUNT=this.options.errorRecoveryTokenDiscardCount|0||3;var NO_ACTION=[0,189/* === table.length :: ensures that anyone using this new state will fail dramatically! */];var lexer;if(this.__lexer__){lexer=this.__lexer__;}else{lexer=this.__lexer__=Object.create(this.lexer);}var sharedState_yy={parseError:undefined,quoteName:undefined,lexer:undefined,parser:undefined,pre_parse:undefined,post_parse:undefined,pre_lex:undefined,post_lex:undefined// WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! -};var ASSERT;if(typeof assert!=='function'){ASSERT=function JisonAssert(cond,msg){if(!cond){throw new Error('assertion failed: '+(msg||'***'));}};}else{ASSERT=assert;}this.yyGetSharedState=function yyGetSharedState(){return sharedState_yy;};this.yyGetErrorInfoTrack=function yyGetErrorInfoTrack(){return recoveringErrorInfo;};// shallow clone objects & arrays, straight copy of simple `src` values +}else{if(typeof this.trace==='function'){this.trace(str);}if(!ExceptionClass){ExceptionClass=this.JisonParserError;}throw new ExceptionClass(str,hash);}},parse:function parse(input){let self=this;let stack=new Array(128);// token stack: stores token which leads to state at the same index (column storage) +let sstack=new Array(128);// state stack: stores states (column storage) +let vstack=new Array(128);// semantic value stack +let lstack=new Array(128);// location stack +let table=this.table;let sp=0;// 'stack pointer': index into the stacks +let yyloc;let symbol=0;let preErrorSymbol=0;let lastEofErrorStateDepth=Infinity;let recoveringErrorInfo=null;let recovering=0;// (only used when the grammar contains error recovery rules) +const TERROR=this.TERROR;const EOF=this.EOF;const ERROR_RECOVERY_TOKEN_DISCARD_COUNT=this.options.errorRecoveryTokenDiscardCount|0||3;const NO_ACTION=[0,189/* === table.length :: ensures that anyone using this new state will fail dramatically! */];let lexer;if(this.__lexer__){lexer=this.__lexer__;}else{lexer=this.__lexer__=Object.create(this.lexer);}let sharedState_yy={parseError:undefined,quoteName:undefined,lexer:undefined,parser:undefined,pre_parse:undefined,post_parse:undefined,pre_lex:undefined,post_lex:undefined// WARNING: must be written this way for the code expanders to work correctly! +};const ASSERT=typeof assert!=='function'?function JisonAssert(cond,msg){if(!cond){throw new Error('assertion failed: '+(msg||'***'));}}:assert;this.yyGetSharedState=function yyGetSharedState(){return sharedState_yy;};this.yyGetErrorInfoTrack=function yyGetErrorInfoTrack(){return recoveringErrorInfo;};// shallow clone objects & arrays, straight copy of simple `src` values // e.g. `lexer.yytext` MAY be a complex value object, // rather than a simple string/value. // @@ -1606,14 +1629,13 @@ var TERROR=this.TERROR;var EOF=this.EOF;var ERROR_RECOVERY_TOKEN_DISCARD_COUNT=t // function shallow_copy(src){if(src&&typeof src==='object'){// non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: -if(src.constructor!==Object){if(Array.isArray(src)){return src.slice();}var dst=new src.constructor(src);// and make sure all custom attributes are added to the clone: +if(src.constructor!==Object){if(Array.isArray(src)){return src.slice();}let dst=new src.constructor(src);// and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst,src);return dst;}// native objects must be cloned a different way: -// -//return Object.assign({}, src); -var dst={};shallow_copy_noclobber(dst,src);return dst;}return src;}// add elements from `src` to `dst` when: +{//return Object.assign({}, src); +let dst={};shallow_copy_noclobber(dst,src);return dst;}}return src;}// add elements from `src` to `dst` when: // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` -function shallow_copy_noclobber(dst,src){const chk=Object.prototype.hasOwnProperty;for(var k in src){if(!(k in dst)){if(chk.call(src,k)){dst[k]=src[k];}}else{if(src[k]!=null&&dst[k]==null&&chk.call(src,k)){dst[k]=src[k];}}}}function copy_yylloc_native(loc){var rv=shallow_copy(loc);// shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: +function shallow_copy_noclobber(dst,src){const chk=Object.prototype.hasOwnProperty;for(let k in src){if(!(k in dst)){if(chk.call(src,k)){dst[k]=src[k];}}else if(src[k]!=null&&dst[k]==null&&chk.call(src,k)){dst[k]=src[k];}}}function copy_yylloc_native(loc){let rv=shallow_copy(loc);// shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if(rv){rv.range=rv.range.slice();}return rv;}// copy state shallow_copy_noclobber(sharedState_yy,this.yy);sharedState_yy.lexer=lexer;sharedState_yy.parser=this;// allow userland code to override the yytext and yylloc copy/clone functions: this.copy_yytext=this.options.copy_yytext||sharedState_yy.copy_yytext||shallow_copy;this.copy_yylloc=this.options.copy_yylloc||sharedState_yy.copy_yylloc||copy_yylloc_native;// *Always* setup `yyError`, `YYRECOVERING`, `yyErrOk` and `yyClearIn` functions as it is paramount @@ -1622,10 +1644,10 @@ this.copy_yytext=this.options.copy_yytext||sharedState_yy.copy_yytext||shallow_c // these functions are invoked in the user action code block(s) as // their closure will still refer to the `parse()` instance which set // them up. Hence we MUST set them up at the start of every `parse()` run! -if(this.yyError){this.yyError=function yyError(str/*, ...args */){var error_rule_depth=this.options.parserErrorsAreRecoverable?locateNearestErrorRecoveryRule(state):-1;var expected=this.collect_expected_token_set(state);var hash=this.constructParseErrorInfo(str,null,expected,error_rule_depth>=0);// append to the old one? -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; +if(this.yyError){this.yyError=function yyError(str/*, ...args */){let error_rule_depth=this.options.parserErrorsAreRecoverable?locateNearestErrorRecoveryRule(state):-1;let expected=this.collect_expected_token_set(state);let hash=this.constructParseErrorInfo(str,null,expected,error_rule_depth>=0);// append to the old one? +if(recoveringErrorInfo){let esp=recoveringErrorInfo.info_stack_pointer;recoveringErrorInfo.symbol_stack[esp]=symbol;let 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;recoveringErrorInfo.info_stack_pointer=esp;}else{recoveringErrorInfo=this.shallowCopyErrorInfo(hash);recoveringErrorInfo.yyError=true;recoveringErrorInfo.errorRuleDepth=error_rule_depth;recoveringErrorInfo.recovering=recovering;}// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){hash.extra_error_attributes=args;}return this.parseError(str,hash,this.JisonParserError);};}// Does the shared state override the default `parseError` that already comes with this instance? +let args=Array.prototype.slice.call(arguments,1);if(args.length){hash.extra_error_attributes=args;}return this.parseError(str,hash,this.JisonParserError);};}// Does the shared state override the default `parseError` that already comes with this instance? if(typeof sharedState_yy.parseError==='function'){this.parseError=function parseErrorAlt(str,hash,ExceptionClass){if(!ExceptionClass){ExceptionClass=this.JisonParserError;}return sharedState_yy.parseError.call(this,str,hash,ExceptionClass);};}else{this.parseError=this.originalParseError;}// Does the shared state override the default `quoteName` that already comes with this instance? if(typeof sharedState_yy.quoteName==='function'){this.quoteName=function quoteNameAlt(id_str){return sharedState_yy.quoteName.call(this,id_str);};}else{this.quoteName=this.originalQuoteName;}// set up the cleanup function; make it an API so that external code can re-use this one in case of // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which @@ -1633,7 +1655,7 @@ if(typeof sharedState_yy.quoteName==='function'){this.quoteName=function quoteNa // // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! -this.cleanupAfterParse=function parser_cleanupAfterParse(resultValue,invoke_post_methods,do_not_nuke_errorinfos){var rv;if(invoke_post_methods){var hash;if(sharedState_yy.post_parse||this.post_parse){// create an error hash info instance: we re-use this API in a **non-error situation** +this.cleanupAfterParse=function parser_cleanupAfterParse(resultValue,invoke_post_methods,do_not_nuke_errorinfos){let rv;if(invoke_post_methods){let hash;if(sharedState_yy.post_parse||this.post_parse){// create an error hash info instance: we re-use this API in a **non-error situation** // as this one delivers all parser internals ready for access by userland code. hash=this.constructParseErrorInfo(null/* no error! */,null/* no exception! */,null,false);}if(sharedState_yy.post_parse){rv=sharedState_yy.post_parse.call(this,sharedState_yy,resultValue,hash);if(typeof rv!=='undefined')resultValue=rv;}if(this.post_parse){rv=this.post_parse.call(this,sharedState_yy,resultValue,hash);if(typeof rv!=='undefined')resultValue=rv;}// cleanup: if(hash&&hash.destroy){hash.destroy();}}if(this.__reentrant_call_depth>1)return resultValue;// do not (yet) kill the sharedState when this is a reentrant run. @@ -1645,7 +1667,7 @@ stack.length=0;// fastest way to nuke an array without overly bothering the GC sstack.length=0;lstack.length=0;vstack.length=0;sp=0;// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;for(var i=this.__error_recovery_infos.length-1;i>=0;i--){var el=this.__error_recovery_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_recovery_infos.length=0;// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array, +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;for(let i=this.__error_recovery_infos.length-1;i>=0;i--){let el=this.__error_recovery_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_recovery_infos.length=0;// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array, // hence has been destroyed already: no need to do that *twice*. if(recoveringErrorInfo){recoveringErrorInfo=undefined;}}return resultValue;};// merge yylloc info into a new yylloc instance. // @@ -1659,32 +1681,38 @@ if(recoveringErrorInfo){recoveringErrorInfo=undefined;}}return resultValue;};// // yylloc info. // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. -this.yyMergeLocationInfo=function parser_yyMergeLocationInfo(first_index,last_index,first_yylloc,last_yylloc,dont_look_back){var i1=first_index|0,i2=last_index|0;var l1=first_yylloc,l2=last_yylloc;var rv;// rules: +this.yyMergeLocationInfo=function parser_yyMergeLocationInfo(first_index,last_index,first_yylloc,last_yylloc,dont_look_back){let i1=first_index|0;let i2=last_index|0;let l1=first_yylloc;let l2=last_yylloc;let rv;// rules: // - first/last yylloc entries override first/last indexes -if(!l1){if(first_index!=null){for(var i=i1;i<=i2;i++){l1=lstack[i];if(l1){break;}}}}if(!l2){if(last_index!=null){for(var i=i2;i>=i1;i--){l2=lstack[i];if(l2){break;}}}}// - detect if an epsilon rule is being processed and act accordingly: +if(!l1){if(first_index!=null){for(let i=i1;i<=i2;i++){l1=lstack[i];if(l1){break;}}}}if(!l2){if(last_index!=null){for(let i=i2;i>=i1;i--){l2=lstack[i];if(l2){break;}}}}// - detect if an epsilon rule is being processed and act accordingly: if(!l1&&first_index==null){// epsilon rule span merger. With optional look-ahead in l2. -if(!dont_look_back){for(var i=(i1||sp)-1;i>=0;i--){l1=lstack[i];if(l1){break;}}}if(!l1){if(!l2){// when we still don't have any valid yylloc info, we're looking at an epsilon rule +if(!dont_look_back){for(let i=(i1||sp)-1;i>=0;i--){l1=lstack[i];if(l1){break;}}}if(!l1){if(!l2){// when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: -return undefined;}else{// shallow-copy L2: after all, we MAY be looking +return null;}// shallow-copy L2: after all, we MAY be looking // at unconventional yylloc info objects... -rv=this.copy_yylloc(l2);return rv;}}else{// shallow-copy L1, then adjust first col/row 1 column past the end. +rv=this.copy_yylloc(l2);return rv;}// shallow-copy L1, then adjust first col/row 1 column past the end. rv=this.copy_yylloc(l1);rv.first_line=rv.last_line;rv.first_column=rv.last_column;rv.range[0]=rv.range[1];if(l2){// shallow-mixin L2, then adjust last col/row accordingly. -shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;}}if(!l1){l1=l2;l2=null;}if(!l1){return undefined;}// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking +shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;}if(!l1){l1=l2;l2=null;}if(!l1){return null;}// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... rv=this.copy_yylloc(l1);if(l2){shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;};// NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! -this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){var pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,loc:this.copy_yylloc(lexer.yylloc),expected:expected,recoverable:recoverable,state:state,action:action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,location_stack:lstack,stack_pointer:sp,yy:sharedState_yy,lexer:lexer,parser:this,// and make sure the error info doesn't stay due to potential +this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){const pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,loc:this.copy_yylloc(lexer.yylloc),expected,recoverable,state,action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,location_stack:lstack,stack_pointer:sp,yy:sharedState_yy,lexer,parser:this,// and make sure the error info doesn't stay due to potential // ref cycle via userland code manipulations. // These would otherwise all be memory leak opportunities! // // Note that only array and object references are nuked as those // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. -destroy:function destructParseErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +destroy:function destructParseErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// info.value = null; +// info.value_stack = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;};// clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. -this.shallowCopyErrorInfo=function parser_shallowCopyErrorInfo(p){var rv=shallow_copy(p);// remove the large parts which can only cause cyclic references +this.shallowCopyErrorInfo=function parser_shallowCopyErrorInfo(p){let rv=shallow_copy(p);// remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. delete rv.sharedState_yy;delete rv.parser;delete rv.lexer;// lexer.yytext MAY be a complex value object, rather than a simple string/value: rv.value=this.copy_yytext(rv.value);// yylloc info: @@ -1736,15 +1764,15 @@ rv.value_stack=rv.value_stack.map(this.copy_yytext);// and we don't bother with // - root_failure_pointer: // copy of the `stack_pointer`... // -for(var i=rv.stack_pointer;rv.state_stack[i]!=null;i++){// empty -}rv.base_pointer=i;rv.info_stack_pointer=i;rv.root_failure_pointer=rv.stack_pointer;// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! -this.__error_recovery_infos.push(rv);return rv;};function getNonTerminalFromCode(symbol){var tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){var token=lexer.lex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){var token=lexer.fastLex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}var lex=stdLex;var state,action,r,t;var yyval={$:true,_$:undefined,yy:sharedState_yy};var p;var yyrulelen;var this_production;var newState;var retval=false;// Return the rule stack depth where the nearest error rule can be found. +{let i;for(i=rv.stack_pointer;rv.state_stack[i]!=null;i++){// empty +}rv.base_pointer=i;rv.info_stack_pointer=i;}rv.root_failure_pointer=rv.stack_pointer;// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +this.__error_recovery_infos.push(rv);return rv;};function getNonTerminalFromCode(symbol){let tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){let token=lexer.lex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){let token=lexer.fastLex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}let lex=stdLex;let state,action,r,t;let yyval={$:true,_$:undefined,yy:sharedState_yy};let p;let yyrulelen;let this_production;let newState;let retval=false;// Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. -function locateNearestErrorRecoveryRule(state){var stack_probe=sp-1;var depth=0;// try to recover from error +function locateNearestErrorRecoveryRule(state){let stack_probe=sp-1;let depth=0;// try to recover from error while(stack_probe>=0){// check for error recovery rule in this state -var t=table[state]&&table[state][TERROR]||NO_ACTION;if(t[0]){// We need to make sure we're not cycling forever: +const t=table[state]&&table[state][TERROR]||NO_ACTION;if(t[0]){// We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must // prevent the core from running forever, // e.g. when parent rules are still expecting certain input to @@ -1765,7 +1793,7 @@ state=sstack[stack_probe];++depth;}return-1;// No suitable error recovery rule a // this initial `setInput()` call: hence we can now check and decide // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: -if(typeof lexer.canIUse==='function'){var lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}yyloc=this.copy_yylloc(lexer.yylloc);lstack[sp]=yyloc;vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack +if(typeof lexer.canIUse==='function'){let lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}yyloc=this.copy_yylloc(lexer.yylloc);lstack[sp]=yyloc;vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack state=newState;// sstack[sp - 1]; // use default actions if available if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}else{// The single `==` condition below covers both these `===` comparisons in a single @@ -1775,7 +1803,7 @@ if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}els if(!symbol){symbol=lex();}// read action for current state and first input t=table[state]&&table[state][symbol]||NO_ACTION;newState=t[1];action=t[0];// handle parse error if(!action){// first see if there's any chance at hitting an error recovery rule: -var error_rule_depth=locateNearestErrorRecoveryRule(state);var errStr=null;var errSymbolDescr=this.describeSymbol(symbol)||symbol;var expected=this.collect_expected_token_set(state);if(!recovering){// Report error +let error_rule_depth=locateNearestErrorRecoveryRule(state);let errStr=null;let errSymbolDescr=this.describeSymbol(symbol)||symbol;let expected=this.collect_expected_token_set(state);if(!recovering){// Report error errStr='Parse error';if(typeof lexer.yylineno==='number'){errStr+=' on line '+(lexer.yylineno+1);}if(typeof lexer.showPosition==='function'){errStr+=':\n'+lexer.showPosition(79-10,10)+'\n';}else{errStr+=': ';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}p=this.constructParseErrorInfo(errStr,null,expected,error_rule_depth>=0);// DO NOT cleanup the old one before we start the new error info track: // the old one will *linger* on the error stack and stay alive until we // invoke the parser's cleanup API! @@ -1783,20 +1811,20 @@ recoveringErrorInfo=this.shallowCopyErrorInfo(p);r=this.parseError(p.errStr,p,th // the `recoverable` flag without properly checking first: // we always terminate the parse when there's no recovery rule available anyhow! if(!p.recoverable||error_rule_depth<0){break;}else{// TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process... -}}var esp=recoveringErrorInfo.info_stack_pointer;// just recovered from another error +}}let esp=recoveringErrorInfo.info_stack_pointer;// just recovered from another error if(recovering===ERROR_RECOVERY_TOKEN_DISCARD_COUNT&&error_rule_depth>=0){// Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc=this.copy_yylloc(lexer.yylloc);// SHIFT current lookahead and grab another recoveringErrorInfo.symbol_stack[esp]=symbol;recoveringErrorInfo.location_stack[esp]=yyloc;recoveringErrorInfo.state_stack[esp]=newState;// push state ++esp;preErrorSymbol=0;symbol=lex();}// try to recover from error -if(error_rule_depth<0){ASSERT(recovering>0,"line 897");recoveringErrorInfo.info_stack_pointer=esp;// barf a fatal hairball when we're out of look-ahead symbols and none hit a match +if(error_rule_depth<0){ASSERT(recovering>0,'Line 1048');recoveringErrorInfo.info_stack_pointer=esp;// barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: -var po=this.__error_infos[this.__error_infos.length-1];// Report error +let po=this.__error_infos[this.__error_infos.length-1];// Report error if(typeof lexer.yylineno==='number'){errStr='Parsing halted on line '+(lexer.yylineno+1)+' while starting to recover from another error';}else{errStr='Parsing halted while starting to recover from another error';}if(po){errStr+=' -- previous error which resulted in this fatal result: '+po.errStr;}else{errStr+=': ';}if(typeof lexer.showPosition==='function'){errStr+='\n'+lexer.showPosition(79-10,10)+'\n';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}p=this.constructParseErrorInfo(errStr,null,expected,false);if(po){p.extra_error_attributes=po;}r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}preErrorSymbol=symbol===TERROR?0:symbol;// save the lookahead token symbol=TERROR;// insert generic error symbol as new lookahead const EXTRA_STACK_SAMPLE_DEPTH=3;// REDUCE/COMBINE the pushed terms/tokens to a new ERROR token: -recoveringErrorInfo.symbol_stack[esp]=preErrorSymbol;if(errStr){recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,errStr:errStr,errorSymbolDescr:errSymbolDescr,expectedStr:expected,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}else{recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}recoveringErrorInfo.location_stack[esp]=this.copy_yylloc(lexer.yylloc);recoveringErrorInfo.state_stack[esp]=newState||NO_ACTION[1];++esp;recoveringErrorInfo.info_stack_pointer=esp;yyval.$=recoveringErrorInfo;yyval._$=undefined;yyrulelen=error_rule_depth;r=this.performAction.call(yyval,yyloc,NO_ACTION[1],sp-1,vstack,lstack);if(typeof r!=='undefined'){retval=r;break;}// pop off stack +recoveringErrorInfo.symbol_stack[esp]=preErrorSymbol;if(errStr){recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,errStr,errSymbolDescr,expectedStr:expected,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}else{recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}recoveringErrorInfo.location_stack[esp]=this.copy_yylloc(lexer.yylloc);recoveringErrorInfo.state_stack[esp]=newState||NO_ACTION[1];++esp;recoveringErrorInfo.info_stack_pointer=esp;yyval.$=recoveringErrorInfo;yyval._$=undefined;yyrulelen=error_rule_depth;let combineState=NO_ACTION[1];r=this.performAction.call(yyval,yyloc,combineState,sp-1,vstack,lstack);if(typeof r!=='undefined'){retval=r;break;}// pop off stack sp-=yyrulelen;// and move the top entries + discarded part of the parse stacks onto the error info stack: -for(var idx=sp-EXTRA_STACK_SAMPLE_DEPTH,top=idx+yyrulelen;idx0){recovering--;}}else{// error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: -ASSERT(recovering>0,"line 1163");symbol=preErrorSymbol;preErrorSymbol=0;// read action for current state and first input +ASSERT(recovering>0,'Line 1352');symbol=preErrorSymbol;preErrorSymbol=0;// read action for current state and first input t=table[newState]&&table[newState][symbol]||NO_ACTION;if(!t[0]||symbol===TERROR){// forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where // (simple) stuff might have been missing before the token which caused the error we're // recovering from now... @@ -1887,17 +1915,17 @@ symbol=0;}}// once we have pushed the special ERROR token value, // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! -ASSERT(preErrorSymbol===0,"line 1194");if(recovering===0){break;}continue;// reduce: +ASSERT(preErrorSymbol===0,'Line 1383');if(recovering===0){break;}continue;// reduce: case 2:this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){// signal end of error recovery loop AND end of outer parse loop +yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){// signal end of error recovery loop AND end of outer parse loop action=3;retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}sp=-2;// magic number: signal outer "fast parse loop" ACCEPT state that we already have a properly set up `retval` parser return value. break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;lstack[sp]=yyval._$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -1925,26 +1953,26 @@ break;}// should we also break out of the regular/outer parse loop, // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? -ASSERT(action!==2,"line 1272");if(!action||action===1){continue;}}}switch(action){// catch misc. parse failures: +ASSERT(action!==2,'Line 1509');if(!action||action===1){continue;}}}switch(action){// catch misc. parse failures: default:// this shouldn't happen, unless resolve defaults are off if(action instanceof Array){p=this.constructParseErrorInfo('Parse Error: multiple actions possible at state: '+state+', token: '+symbol,null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}// Another case of better safe than sorry: in case state transitions come out of another error recovery process // or a buggy LUT (LookUp Table): p=this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.',null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;// shift: case 1:stack[sp]=symbol;vstack[sp]=lexer.yytext;lstack[sp]=this.copy_yylloc(lexer.yylloc);sstack[sp]=newState;// push state -if(typeof Jison!=='undefined'&&Jison.parserDebugger){var tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;ASSERT(preErrorSymbol===0,"line 1352");// normal execution / no error -ASSERT(recovering===0,"line 1353");// normal execution / no error +if(typeof Jison!=='undefined'&&Jison.parserDebugger){let tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;ASSERT(preErrorSymbol===0,'Line 1619');// normal execution / no error +ASSERT(recovering===0,'Line 1620');// normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc=this.copy_yylloc(lexer.yylloc);continue;// reduce: -case 2:ASSERT(preErrorSymbol===0,"line 1364");// normal execution / no error -ASSERT(recovering===0,"line 1365");// normal execution / no error +case 2:ASSERT(preErrorSymbol===0,'Line 1631');// normal execution / no error +ASSERT(recovering===0,'Line 1632');// normal execution / no error this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack +yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;lstack[sp]=yyval._$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:if(sp!==-2){retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -2193,8 +2221,8 @@ return retval;},yyError:1};parser.originalParseError=parser.parseError;parser.or * @public * @constructor * @nocollapse - */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 -Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';var lexer={// Code Generator Information Report + */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){const ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 +Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';const lexer={// Code Generator Information Report // --------------------------------- // // Options: @@ -2263,7 +2291,7 @@ CRLF_Re:/\r\n?|\n/,/** * @this {RegExpLexer} */constructLexErrorInfo:function lexer_constructLexErrorInfo(msg,recoverable,show_input_position){msg=''+msg;// heuristic to determine if the error message already contains a (partial) source code dump // as produced by either `showPosition()` or `prettyPrintRange()`: -if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){var pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){var pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */var pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... +if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){const pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){const pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */const pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:this,/** * and make sure the error info doesn't stay due to potential * ref cycle via userland code manipulations. @@ -2275,7 +2303,11 @@ text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:t * * @public * @this {LexErrorInfo} - */destroy:function destructLexErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! + */destroy:function destructLexErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;},/** * handler which is invoked when a lexer error occurs. * @@ -2286,8 +2318,8 @@ this.__error_infos.push(pei);return pei;},/** * * @public * @this {RegExpLexer} - */yyerror:function yyError(str/*, ...args */){var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** + */yyerror:function yyError(str/*, ...args */){let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: +let args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** * final cleanup function for when we have completed lexing the input; * make it an API so that external code can use this one once userland * code has decided it's time to destroy any lingering lexer error @@ -2302,13 +2334,13 @@ var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_a this.setInput('',{});// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** * clear the lexer token context; intended for internal use only * * @public * @this {RegExpLexer} */clear:function lexer_clear(){this.yytext='';this.yyleng=0;this.match='';// - DO NOT reset `this.matched` -this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** +this.matches=false;this._more=false;this._backtrack=false;const col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** * resets the lexer, sets new input * * @public @@ -2317,10 +2349,10 @@ this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.la // including expansion work to be done to go from a loaded // lexer to a usable lexer: if(!this.__decompressed){// step 1: decompress the regex list: -var rules=this.rules;for(var i=0,len=rules.length;i> tokens and perform user action code for a <> match, but only does so *once*) -return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}var ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). +return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}let ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. -var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;var ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** +let slice_len=1;let lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;const ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** * unshifts one char (or an entire string) into the input * * @public * @this {RegExpLexer} - */unput:function lexer_unput(ch){var len=ch.length;var lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** + */unput:function lexer_unput(ch){let len=ch.length;let lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** // The `offset` value MAY be negative if you `unput()` more text than you have already lexed. // This type of behaviour is generally observed for one kind of 'lexer/parser hack' // where custom token-illiciting characters are pushed in front of the input stream to help @@ -2390,11 +2422,11 @@ var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lin if(-this.offset>this.base_position){this.base_position=-this.offset;}this.match=this.match.substr(0,this.match.length-len);this.matched=this.matched.substr(0,this.matched.length-len);if(lines.length>1){this.yylineno-=lines.length-1;this.yylloc.last_line=this.yylineno+1;// Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. -var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** +let pre=this.match;let pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -2404,8 +2436,8 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */lookAhead:function lexer_lookAhead(){return this._input||'';},/** @@ -2422,7 +2454,7 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 */reject:function lexer_reject(){if(this.options.backtrack_lexer){this._backtrack=true;}else{// when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. -var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** +let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** * retain first n characters of the match * * @public @@ -2444,17 +2476,17 @@ var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yyl * * @public * @this {RegExpLexer} - */pastInput:function lexer_pastInput(maxSize,maxLines){var past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0)maxSize=Infinity;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=Infinity;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substr` anticipation: treat \r\n as a single character and take a little + */pastInput:function lexer_pastInput(maxSize,maxLines){let past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0){maxSize=Infinity;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=Infinity;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past=past.substr(-maxSize*2-2);// now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: -var a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, +let a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, // do add an ellipsis prefix... if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -2480,18 +2512,18 @@ if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} - */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){var next=this.match;var source=this._input||'';if(maxSize<0)maxSize=next.length+source.length;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=maxSize;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substring` anticipation: treat \r\n as a single character and take a little + */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){let next=this.match;let source=this._input||'';if(maxSize<0){maxSize=next.length+source.length;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=maxSize;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: if(next.lengthmaxSize){next=next.substring(0,maxSize)+'...';}return next;},/** @@ -2500,7 +2532,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){var pre=this.pastInput(maxPrefix).replace(/\s/g,' ');var c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** + */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){const pre=this.pastInput(maxPrefix).replace(/\s/g,' ');let c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** * return an YYLLOC info object derived off the given context (actual, preceding, following, current). * Use this method when the given `actual` location is not guaranteed to exist (i.e. when * it MAY be NULL) and you MUST have a valid location info object anyway: @@ -2516,7 +2548,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */deriveLocationInfo:function lexer_deriveYYLLOC(actual,preceding,following,current){var loc={first_line:1,first_column:0,last_line:1,last_column:0,range:[0,0]};if(actual){loc.first_line=actual.first_line|0;loc.last_line=actual.last_line|0;loc.first_column=actual.first_column|0;loc.last_column=actual.last_column|0;if(actual.range){loc.range[0]=actual.range[0]|0;loc.range[1]=actual.range[1]|0;}}if(loc.first_line<=0||loc.last_line=loc.first_line)){loc.last_line=current.last_line|0;loc.last_column=current.last_column|0;if(current.range){loc.range[1]=current.range[1]|0;}}}// sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter // or plan D heuristics to produce a 'sensible' last_line value: @@ -2565,9 +2597,9 @@ loc.range[1]=loc.range[0];}if(loc.first_column<0){loc.first_column=0;}if(loc.las * * @public * @this {RegExpLexer} - */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;var input=this.matched+(this._input||'');var lines=input.split('\n');var l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);var l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);var lineno_display_width=1+Math.log10(l1|1)|0;var ws_prefix=new Array(lineno_display_width).join(' ');var nonempty_line_indexes=[[],[],[]];var rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){var lno=index+l0;var lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);var rv=lno_pfx+': '+line;var errpfx=new Array(lineno_display_width+1).join('^');var offset=2+1;var len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it + */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;let input=this.matched+(this._input||'');let lines=input.split('\n');let l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);let l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);let lineno_display_width=1+Math.log10(l1|1)|0;let ws_prefix=new Array(lineno_display_width).join(' ');let nonempty_line_indexes=[[],[],[]];let rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){let lno=index+l0;let lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);let rv=lno_pfx+': '+line;let errpfx=new Array(lineno_display_width+1).join('^');let offset=2+1;let len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: -for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){var clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;var clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;var intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** +for(let i=0;i<=2;i++){let line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){let clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;let clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;let intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** * helper function, used to produce a human readable description as a string, given * the input `yylloc` location object. * @@ -2576,7 +2608,7 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){var l1=yylloc.first_line;var l2=yylloc.last_line;var c1=yylloc.first_column;var c2=yylloc.last_column;var dl=l2-l1;var dc=c2-c1;var rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){var r1=yylloc.range[0];var r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** + */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){let l1=yylloc.first_line;let l2=yylloc.last_line;let c1=yylloc.first_column;let c2=yylloc.last_column;let dl=l2-l1;let dc=c2-c1;let rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){let r1=yylloc.range[0];let r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** * test the lexed token: return FALSE when not a match, otherwise return token. * * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]` @@ -2593,18 +2625,18 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */test_match:function lexer_test_match(match,indexed_rule){var token,lines,backup,match_str,match_str_len;if(this.options.backtrack_lexer){// save context + */test_match:function lexer_test_match(match,indexed_rule){let backup;if(this.options.backtrack_lexer){// save context backup={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.yylloc.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column,range:this.yylloc.range.slice()},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,//_signaled_error_token: this._signaled_error_token, -yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}match_str=match[0];match_str_len=match_str.length;lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: +yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}let match_str=match[0];let match_str_len=match_str.length;let lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: // those rules will already have moved this `offset` forward matching their match lengths, // hence we must only add our own match length now: this.offset+=match_str_len;this._more=false;this._backtrack=false;this._input=this._input.slice(match_str_len);// calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} -token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: +let token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; if(this.done&&this._input){this.done=false;}if(token){return token;}else if(this._backtrack){// recover context -for(var k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. +for(let k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. }else if(this._signaled_error_token){// produce one 'error' token as `.parseError()` in `reject()` // did not guarantee a failure signal by throwing an exception! token=this._signaled_error_token;this._signaled_error_token=false;return token;}return false;},/** @@ -2612,19 +2644,19 @@ token=this._signaled_error_token;this._signaled_error_token=false;return token;} * * @public * @this {RegExpLexer} - */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}var token,match,tempMatch,index;if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}var spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. + */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}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();// Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 -if(!spec||!spec.rules){var lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! -return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}var rule_ids=spec.rules;var regexes=spec.__rule_regexes;var len=spec.__rule_count;// Note: the arrays are 1-based, while `len` itself is a valid index, +if(!spec||!spec.rules){let lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! +return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}{let rule_ids=spec.rules;let regexes=spec.__rule_regexes;let len=spec.__rule_count;let match;let index;// 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(var i=1;i<=len;i++){tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. +for(let i=1;i<=len;i++){let tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){let token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. }else{// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}}else if(!this.options.flex){break;}}}if(match){token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}if(!this._input){this.done=true;this.clear();return this.EOF;}else{var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);var pendingInput=this._input;var activeCondition=this.topState();var conditionStackDepth=this.conditionStack.length;token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us +return false;}}else if(!this.options.flex){break;}}}if(match){let token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) +return false;}}if(!this._input){this.done=true;this.clear();return this.EOF;}{let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);let pendingInput=this._input;let activeCondition=this.topState();let conditionStackDepth=this.conditionStack.length;let token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: if(!this.matches&&// and make sure the input has been modified/consumed ... @@ -2635,7 +2667,7 @@ activeCondition===this.topState()&&conditionStackDepth===this.conditionStack.len * * @public * @this {RegExpLexer} - */lex:function lexer_lex(){var r;//this._clear_state = 0; + */lex:function lexer_lex(){let r;//this._clear_state = 0; if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}// allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer: if(typeof this.pre_lex==='function'){r=this.pre_lex.call(this,0);}if(typeof this.options.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.pre_lex.call(this,r)||r;}if(this.yy&&typeof this.yy.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) @@ -2643,50 +2675,50 @@ r=this.yy.pre_lex.call(this,r)||r;}while(!r){r=this.next();}if(this.yy&&typeof t r=this.yy.post_lex.call(this,r)||r;}if(typeof this.options.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.post_lex.call(this,r)||r;}if(typeof this.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.post_lex.call(this,r)||r;}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return next match that has a token. Identical to the `lex()` API but does not invoke any of the * `pre_lex()` nor any of the `post_lex()` callbacks. * * @public * @this {RegExpLexer} - */fastLex:function lexer_fastLex(){var r;//this._clear_state = 0; + */fastLex:function lexer_fastLex(){let r;//this._clear_state = 0; while(!r){r=this.next();}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return info about the lexer state that can help a parser or other lexer API user to use the * most efficient means available. This API is provided to aid run-time performance for larger @@ -2694,7 +2726,7 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */canIUse:function lexer_canIUse(){var rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** + */canIUse:function lexer_canIUse(){const rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** * backwards compatible alias for `pushState()`; * the latter is symmetrical with `popState()` and we advise to use * those APIs in any modern lexer code, rather than `begin()`. @@ -2713,20 +2745,20 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */popState:function lexer_popState(){var n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}else{return this.conditionStack[0];}},/** + */popState:function lexer_popState(){const n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}return this.conditionStack[0];},/** * return the currently active lexer condition state; when an index * argument is provided it produces the N-th previous condition state, * if available * * @public * @this {RegExpLexer} - */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}else{return'INITIAL';}},/** + */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}return'INITIAL';},/** * (internal) determine the lexer rule set which is active for the * currently active lexer condition state * * @public * @this {RegExpLexer} - */_currentRules:function lexer__currentRules(){var n=this.conditionStack.length-1;var state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions['INITIAL'];},/** + */_currentRules:function lexer__currentRules(){const n=this.conditionStack.length-1;let state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions.INITIAL;},/** * return the number of states currently on the stack * * @public @@ -2993,7 +3025,7 @@ const CHR_RE=/^(?:[^\\]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[ const WHITESPACE_SETSTR=' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff';// `/\d/`: const DIGIT_SETSTR='0-9';// `/\w/`: const WORDCHAR_SETSTR='A-Za-z0-9_';// Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex -function i2c(i){var c,x;switch(i){case 10:return'\\n';case 13:return'\\r';case 9:return'\\t';case 8:return'\\b';case 12:return'\\f';case 11:return'\\v';case 45:// ASCII/Unicode for '-' dash +function i2c(i){let c,x;switch(i){case 10:return'\\n';case 13:return'\\r';case 9:return'\\t';case 8:return'\\b';case 12:return'\\f';case 11:return'\\v';case 45:// ASCII/Unicode for '-' dash return'\\-';case 91:// '[' return'\\[';case 92:// '\\' return'\\\\';case 93:// ']' @@ -3003,13 +3035,13 @@ return'\\^';}if(i<32||i>0xFFF0/* Unicode Specials, also in UTF16 */||i>=0xD800&& // source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report // a b0rked generated parser, as the generated code would include this regex right here. // Hence we MUST escape these buggers everywhere we go... -x=i.toString(16);if(x.length>=1&&i<=0xFFFF){c='0000'+x;return'\\u'+c.substr(c.length-4);}else{return'\\u{'+x+'}';}}return String.fromCharCode(i);}// Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating +x=i.toString(16);if(x.length>=1&&i<=0xFFFF){c='0000'+x;return'\\u'+c.substr(c.length-4);}return'\\u{'+x+'}';}return String.fromCharCode(i);}// Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating // this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a // `\\p{NAME}` shorthand to represent [part of] the bitarray: -var Pcodes_bitarray_cache={};var Pcodes_bitarray_cache_test_order=[];// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by +let Pcodes_bitarray_cache={};let Pcodes_bitarray_cache_test_order=[];// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. -var EscCode_bitarray_output_refs;// now initialize the EscCodes_... table above: -init_EscCode_lookup_table();function init_EscCode_lookup_table(){var s,bitarr,set2esc={},esc2bitarr={};// patch global lookup tables for the time being, while we calculate their *real* content in this function: +let EscCode_bitarray_output_refs;// now initialize the EscCodes_... table above: +init_EscCode_lookup_table();function init_EscCode_lookup_table(){let s,bitarr,set2esc={},esc2bitarr={};// patch global lookup tables for the time being, while we calculate their *real* content in this function: EscCode_bitarray_output_refs={esc2bitarr:{},set2esc:{}};Pcodes_bitarray_cache_test_order=[];// `/\S': bitarr=[];set2bitarray(bitarr,'^'+WHITESPACE_SETSTR);s=bitarray2set(bitarr);esc2bitarr['S']=bitarr;set2esc[s]='S';// set2esc['^' + s] = 's'; Pcodes_bitarray_cache['\\S']=bitarr;// `/\s': @@ -3022,34 +3054,34 @@ Pcodes_bitarray_cache['\\d']=bitarr;// `/\W': bitarr=[];set2bitarray(bitarr,'^'+WORDCHAR_SETSTR);s=bitarray2set(bitarr);esc2bitarr['W']=bitarr;set2esc[s]='W';// set2esc['^' + s] = 'w'; Pcodes_bitarray_cache['\\W']=bitarr;// `/\w': bitarr=[];set2bitarray(bitarr,WORDCHAR_SETSTR);s=bitarray2set(bitarr);esc2bitarr['w']=bitarr;set2esc[s]='w';// set2esc['^' + s] = 'W'; -Pcodes_bitarray_cache['\\w']=bitarr;EscCode_bitarray_output_refs={esc2bitarr:esc2bitarr,set2esc:set2esc};updatePcodesBitarrayCacheTestOrder();}function updatePcodesBitarrayCacheTestOrder(opts){var t=new Array(UNICODE_BASE_PLANE_MAX_CP+1);var l={};var user_has_xregexp=opts&&opts.options&&opts.options.xregexp;var i,j,k,ba;// mark every character with which regex pcodes they are part of: -for(k in Pcodes_bitarray_cache){ba=Pcodes_bitarray_cache[k];if(!user_has_xregexp&&k.indexOf('\\p{')>=0){continue;}var cnt=0;for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(ba[i]){cnt++;if(!t[i]){t[i]=[k];}else{t[i].push(k);}}}l[k]=cnt;}// now dig out the unique ones: only need one per pcode. -// +Pcodes_bitarray_cache['\\w']=bitarr;EscCode_bitarray_output_refs={esc2bitarr:esc2bitarr,set2esc:set2esc};updatePcodesBitarrayCacheTestOrder();}function updatePcodesBitarrayCacheTestOrder(opts){let t=new Array(UNICODE_BASE_PLANE_MAX_CP+1);let l={};let user_has_xregexp=opts&&opts.options&&opts.options.xregexp;let i,j,k,ba;// mark every character with which regex pcodes they are part of: +for(k in Pcodes_bitarray_cache){ba=Pcodes_bitarray_cache[k];if(!user_has_xregexp&&k.indexOf('\\p{')>=0){continue;}let cnt=0;for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(ba[i]){cnt++;if(!t[i]){t[i]=[k];}else{t[i].push(k);}}}l[k]=cnt;}// now dig out the unique ones: only need one per pcode. +// // We ASSUME every \\p{NAME} 'pcode' has at least ONE character -// in it that is ONLY matched by that particular pcode. +// in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode -// won't be tested during optimization. -// +// won't be tested during optimization. +// // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to // look for markers which match multiple escapes/pcodes for those // ones where a unique item isn't available... -var lut=[];var done={};var keys=Object.keys(Pcodes_bitarray_cache);for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){k=t[i][0];if(t[i].length===1&&!done[k]){assert__default['default'](l[k]>0);lut.push([i,k]);done[k]=true;}}for(j=0;keys[j];j++){k=keys[j];if(!user_has_xregexp&&k.indexOf('\\p{')>=0){continue;}if(!done[k]){assert__default['default'](l[k]>0);// find a minimum span character to mark this one: -var w=Infinity;var rv;ba=Pcodes_bitarray_cache[k];for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(ba[i]){var tl=t[i].length;if(tl>1&&tl0);rv=[i,k];w=tl;}}}if(rv){done[k]=true;lut.push(rv);}}}// order from large set to small set so that small sets don't gobble +let lut=[];let done={};let keys=Object.keys(Pcodes_bitarray_cache);for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){k=t[i][0];if(t[i].length===1&&!done[k]){assert__default['default'](l[k]>0);lut.push([i,k]);done[k]=true;}}for(j=0;keys[j];j++){k=keys[j];if(!user_has_xregexp&&k.indexOf('\\p{')>=0){continue;}if(!done[k]){assert__default['default'](l[k]>0);// find a minimum span character to mark this one: +let w=Infinity;var rv;ba=Pcodes_bitarray_cache[k];for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(ba[i]){let tl=t[i].length;if(tl>1&&tl0);rv=[i,k];w=tl;}}}if(rv){done[k]=true;lut.push(rv);}}}// order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. -// +// // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more -// optimal minification of the regex set expression. -// +// optimal minification of the regex set expression. +// // This is a guestimate/heuristic only! -lut.sort(function(a,b){var k1=a[1];var k2=b[1];var ld=l[k2]-l[k1];if(ld){return ld;}// and for same-size sets, order from high to low unique identifier. +lut.sort(function(a,b){let k1=a[1];let k2=b[1];let ld=l[k2]-l[k1];if(ld){return ld;}// and for same-size sets, order from high to low unique identifier. return b[0]-a[0];});Pcodes_bitarray_cache_test_order=lut;}// 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set. -function set2bitarray(bitarr,s,opts){var orig=s;var set_is_inverted=false;var bitarr_orig;function mark(d1,d2){if(d2==null)d2=d1;for(var i=d1;i<=d2;i++){bitarr[i]=true;}}function add2bitarray(dst,src){for(var i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(src[i]){dst[i]=true;}}}function eval_escaped_code(s){var c;// decode escaped code? If none, just take the character as-is -if(s.indexOf('\\')===0){var l=s.substr(0,2);switch(l){case'\\c':c=s.charCodeAt(2)-'A'.charCodeAt(0)+1;return String.fromCharCode(c);case'\\x':s=s.substr(2);c=parseInt(s,16);return String.fromCharCode(c);case'\\u':s=s.substr(2);if(s[0]==='{'){s=s.substr(1,s.length-2);}c=parseInt(s,16);if(c>=0x10000){return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{'+s+'}');}return String.fromCharCode(c);case'\\0':case'\\1':case'\\2':case'\\3':case'\\4':case'\\5':case'\\6':case'\\7':s=s.substr(1);c=parseInt(s,8);return String.fromCharCode(c);case'\\r':return'\r';case'\\n':return'\n';case'\\v':return'\v';case'\\f':return'\f';case'\\t':return'\t';case'\\b':return'\b';default:// just the character itself: -return s.substr(1);}}else{return s;}}if(s&&s.length){var c1,c2;// inverted set? +function set2bitarray(bitarr,s,opts){let orig=s;let set_is_inverted=false;let bitarr_orig;function mark(d1,d2){if(d2==null)d2=d1;for(let i=d1;i<=d2;i++){bitarr[i]=true;}}function add2bitarray(dst,src){for(let i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(src[i]){dst[i]=true;}}}function eval_escaped_code(s){let c;// decode escaped code? If none, just take the character as-is +if(s.indexOf('\\')===0){let l=s.substr(0,2);switch(l){case'\\c':c=s.charCodeAt(2)-'A'.charCodeAt(0)+1;return String.fromCharCode(c);case'\\x':s=s.substr(2);c=parseInt(s,16);return String.fromCharCode(c);case'\\u':s=s.substr(2);if(s[0]==='{'){s=s.substr(1,s.length-2);}c=parseInt(s,16);if(c>=0x10000){return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{'+s+'}');}return String.fromCharCode(c);case'\\0':case'\\1':case'\\2':case'\\3':case'\\4':case'\\5':case'\\6':case'\\7':s=s.substr(1);c=parseInt(s,8);return String.fromCharCode(c);case'\\r':return'\r';case'\\n':return'\n';case'\\v':return'\v';case'\\f':return'\f';case'\\t':return'\t';case'\\b':return'\b';default:// just the character itself: +return s.substr(1);}}else{return s;}}if(s&&s.length){let c1,c2;// inverted set? if(s[0]==='^'){set_is_inverted=true;s=s.substr(1);bitarr_orig=bitarr;bitarr=new Array(UNICODE_BASE_PLANE_MAX_CP+1);}// BITARR collects flags for characters set. Inversion means the complement set of character is st instead. // This results in an OR operations when sets are joined/chained. while(s.length){c1=s.match(CHR_RE);if(!c1){// hit an illegal escape sequence? cope anyway! @@ -3057,31 +3089,31 @@ c1=s[0];}else{c1=c1[0];// Quick hack for XRegExp escapes inside a regex `[...]` // intact but it's easier to unfold them here; this is not nice for when the grammar specifies explicit // XRegExp support, but alas, we'll get there when we get there... ;-) switch(c1){case'\\p':s=s.substr(c1.length);c2=s.match(XREGEXP_UNICODE_ESCAPE_RE);if(c2){c2=c2[0];s=s.substr(c2.length);// do we have this one cached already? -var pex=c1+c2;var ba4p=Pcodes_bitarray_cache[pex];if(!ba4p){// expand escape: -var xr=new XRegExp__default['default']('['+pex+']');// TODO: case-insensitive grammar??? +let pex=c1+c2;let ba4p=Pcodes_bitarray_cache[pex];if(!ba4p){// expand escape: +let xr=new XRegExp__default['default']('['+pex+']');// TODO: case-insensitive grammar??? // rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`: -var xs=''+xr;// remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: +let xs=''+xr;// remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: xs=xs.substr(1,xs.length-2);ba4p=reduceRegexToSetBitArray(xs,pex,opts);Pcodes_bitarray_cache[pex]=ba4p;updatePcodesBitarrayCacheTestOrder(opts);}// merge bitarrays: add2bitarray(bitarr,ba4p);continue;}break;case'\\S':case'\\s':case'\\W':case'\\w':case'\\d':case'\\D':// these can't participate in a range, but need to be treated special: s=s.substr(c1.length);// check for \S, \s, \D, \d, \W, \w and expand them: var ba4e=EscCode_bitarray_output_refs.esc2bitarr[c1[1]];assert__default['default'](ba4e);add2bitarray(bitarr,ba4e);continue;case'\\b':// matches a backspace: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions#special-backspace -c1='\u0008';break;}}var v1=eval_escaped_code(c1);// propagate deferred exceptions = error reports. +c1='\u0008';break;}}let v1=eval_escaped_code(c1);// propagate deferred exceptions = error reports. if(v1 instanceof Error){return v1;}v1=v1.charCodeAt(0);s=s.substr(c1.length);if(s[0]==='-'&&s.length>=2){// we can expect a range like 'a-z': s=s.substr(1);c2=s.match(CHR_RE);if(!c2){// hit an illegal escape sequence? cope anyway! -c2=s[0];}else{c2=c2[0];}var v2=eval_escaped_code(c2);// propagate deferred exceptions = error reports. +c2=s[0];}else{c2=c2[0];}let v2=eval_escaped_code(c2);// propagate deferred exceptions = error reports. if(v2 instanceof Error){return v1;}v2=v2.charCodeAt(0);s=s.substr(c2.length);// legal ranges go UP, not /DOWN! if(v1<=v2){mark(v1,v2);}else{console.warn('INVALID CHARACTER RANGE found in regex: ',{re:orig,start:c1,start_n:v1,end:c2,end_n:v2});mark(v1);mark('-'.charCodeAt(0));mark(v2);}continue;}mark(v1);}// When we have marked all slots, '^' NEGATES the set, hence we flip all slots. -// +// // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. -if(set_is_inverted){for(var i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(!bitarr[i]){bitarr_orig[i]=true;}}}}return false;}// convert a simple bitarray back into a regex set `[...]` content: +if(set_is_inverted){for(let i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(!bitarr[i]){bitarr_orig[i]=true;}}}}return false;}// convert a simple bitarray back into a regex set `[...]` content: function bitarray2set(l,output_inverted_variant,output_minimized){// construct the inverse(?) set from the mark-set: // // Before we do that, we inject a sentinel so that our inner loops // below can be simple and fast: l[UNICODE_BASE_PLANE_MAX_CP+1]=1;// now reconstruct the regex set: -var rv=[];var i,j,cnt,lut,tn,tspec,match,pcode,ba4pcode,l2;var bitarr_is_cloned=false;var l_orig=l;if(output_inverted_variant){// generate the inverted set, hence all unmarked slots are part of the output range: +let rv=[];let i,j,cnt,lut,tn,tspec,match,pcode,ba4pcode,l2;let bitarr_is_cloned=false;let l_orig=l;if(output_inverted_variant){// generate the inverted set, hence all unmarked slots are part of the output range: cnt=0;for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(!l[i]){cnt++;}}if(cnt===UNICODE_BASE_PLANE_MAX_CP+1){// When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. // BUT... since we output the INVERTED set, we output the match-all set instead: return'\\S\\s';}else if(cnt===0){// When we find the entire Unicode range is in the output match set, we replace this with @@ -3093,9 +3125,9 @@ if(!l[tspec[0]]){// check if the pcode is covered by the inverted set: pcode=tspec[1];ba4pcode=Pcodes_bitarray_cache[pcode];match=0;for(j=0;j<=UNICODE_BASE_PLANE_MAX_CP;j++){if(ba4pcode[j]){if(!l[j]){// match in current inverted bitset, i.e. there's at // least one 'new' bit covered by this pcode/escape: match++;}else if(l_orig[j]){// mismatch! -match=false;break;}}}// We're only interested in matches which actually cover some +match=false;break;}}}// We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. -// +// // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if(match&&match>pcode.length){rv.push(pcode);// and nuke the bits in the array which match the given pcode: @@ -3116,9 +3148,9 @@ if(l[tspec[0]]){// check if the pcode is covered by the set: pcode=tspec[1];ba4pcode=Pcodes_bitarray_cache[pcode];match=0;for(j=0;j<=UNICODE_BASE_PLANE_MAX_CP;j++){if(ba4pcode[j]){if(l[j]){// match in current bitset, i.e. there's at // least one 'new' bit covered by this pcode/escape: match++;}else if(!l_orig[j]){// mismatch! -match=false;break;}}}// We're only interested in matches which actually cover some +match=false;break;}}}// We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. -// +// // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if(match&&match>pcode.length){rv.push(pcode);// and nuke the bits in the array which match the given pcode: @@ -3128,17 +3160,17 @@ if(!bitarr_is_cloned){l2=new Array(UNICODE_BASE_PLANE_MAX_CP+1);for(j=0;j<=UNICO l2[UNICODE_BASE_PLANE_MAX_CP+1]=1;l=l2;bitarr_is_cloned=true;}else{for(j=0;j<=UNICODE_BASE_PLANE_MAX_CP;j++){l[j]=l[j]&&!ba4pcode[j];}}}}}}i=0;while(i<=UNICODE_BASE_PLANE_MAX_CP){// find first character not in original set: while(!l[i]){i++;}if(i>=UNICODE_BASE_PLANE_MAX_CP+1){break;}// find next character not in original set: for(j=i+1;l[j];j++){}/* empty loop */if(j>UNICODE_BASE_PLANE_MAX_CP+1){j=UNICODE_BASE_PLANE_MAX_CP+1;}// generate subset: -rv.push(i2c(i));if(j-1>i){rv.push((j-2>i?'-':'')+i2c(j-1));}i=j;}}assert__default['default'](rv.length);var s=rv.join('');assert__default['default'](s);// Check if the set is better represented by one of the regex escapes: -var esc4s=EscCode_bitarray_output_refs.set2esc[s];if(esc4s){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! +rv.push(i2c(i));if(j-1>i){rv.push((j-2>i?'-':'')+i2c(j-1));}i=j;}}assert__default['default'](rv.length);let s=rv.join('');assert__default['default'](s);// Check if the set is better represented by one of the regex escapes: +let esc4s=EscCode_bitarray_output_refs.set2esc[s];if(esc4s){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return'\\'+esc4s;}return s;}// Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there; // ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`. -function reduceRegexToSetBitArray(s,name,opts){var orig=s;// propagate deferred exceptions = error reports. -if(s instanceof Error){return s;}var l=new Array(UNICODE_BASE_PLANE_MAX_CP+1);var internal_state=0;var derr;while(s.length){var c1=s.match(CHR_RE);if(!c1){// cope with illegal escape sequences too! -return new Error('illegal escape sequence at start of regex part: "'+s+'" of regex "'+orig+'"');}else{c1=c1[0];}s=s.substr(c1.length);switch(c1){case'[':// this is starting a set within the regex: scan until end of set! -var set_content=[];while(s.length){var inner=s.match(SET_PART_RE);if(!inner){inner=s.match(CHR_RE);if(!inner){// cope with illegal escape sequences too! -return new Error('illegal escape sequence at start of regex part: '+s+'" of regex "'+orig+'"');}else{inner=inner[0];}if(inner===']')break;}else{inner=inner[0];}set_content.push(inner);s=s.substr(inner.length);}// ensure that we hit the terminating ']': +function reduceRegexToSetBitArray(s,name,opts){let orig=s;// propagate deferred exceptions = error reports. +if(s instanceof Error){return s;}let l=new Array(UNICODE_BASE_PLANE_MAX_CP+1);let internal_state=0;let derr;while(s.length){let c1=s.match(CHR_RE);if(!c1){// cope with illegal escape sequences too! +return new Error('illegal escape sequence at start of regex part: "'+s+'" of regex "'+orig+'"');}c1=c1[0];s=s.substr(c1.length);switch(c1){case'[':// this is starting a set within the regex: scan until end of set! +var set_content=[];while(s.length){let inner=s.match(SET_PART_RE);if(!inner){inner=s.match(CHR_RE);if(!inner){// cope with illegal escape sequences too! +return new Error('illegal escape sequence at start of regex part: '+s+'" of regex "'+orig+'"');}inner=inner[0];if(inner===']')break;}else{inner=inner[0];}set_content.push(inner);s=s.substr(inner.length);}// ensure that we hit the terminating ']': var c2=s.match(CHR_RE);if(!c2){// cope with illegal escape sequences too! -return new Error('regex set expression is broken in regex: "'+orig+'" --> "'+s+'"');}else{c2=c2[0];}if(c2!==']'){return new Error('regex set expression is broken in regex: '+orig);}s=s.substr(c2.length);var se=set_content.join('');if(!internal_state){derr=set2bitarray(l,se,opts);// propagate deferred exceptions = error reports. +return new Error('regex set expression is broken in regex: "'+orig+'" --> "'+s+'"');}c2=c2[0];if(c2!==']'){return new Error('regex set expression is broken in regex: '+orig);}s=s.substr(c2.length);var se=set_content.join('');if(!internal_state){derr=set2bitarray(l,se,opts);// propagate deferred exceptions = error reports. if(derr instanceof Error){return derr;}// a set is to use like a single character in a longer literal phrase, hence input `[abc]word[def]` would thus produce output `[abc]`: internal_state=1;}break;// Strip unescaped pipes to catch constructs like `\\r|\\n` and turn them into // something ready for use inside a regex set, e.g. `\\r\\n`. @@ -3172,34 +3204,34 @@ if(!internal_state){derr=set2bitarray(l,c1,opts);// propagate deferred exception if(derr instanceof Error){return derr;}internal_state=2;}break;}}s=bitarray2set(l);// When this result is suitable for use in a set, than we should be able to compile // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: -try{var re;assert__default['default'](s);assert__default['default'](!(s instanceof Error));re=new XRegExp__default['default']('['+s+']');re.test(s[0]);// One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` +try{assert__default['default'](s);assert__default['default'](!(s instanceof Error));let re=new XRegExp__default['default']('['+s+']');re.test(s[0]);// One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` // so we check for lingering UNESCAPED brackets in here as those cannot be: if(/[^\\][\[\]]/.exec(s)){throw new Error('unescaped brackets in set data');}}catch(ex){// make sure we produce a set range expression which will fail badly when it is used // in actual code: s=new Error('[macro ['+name+'] is unsuitable for use inside regex set expressions: "['+s+']"]: '+ex.message);}assert__default['default'](s);// propagate deferred exceptions = error reports. -if(s instanceof Error){return s;}return l;}// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` +if(s instanceof Error){return s;}return l;}// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! function produceOptimizedRegex4Set(bitarr){// First try to produce a minimum regex from the bitarray directly: -var s1=bitarray2set(bitarr,false,true);// and when the regex set turns out to match a single pcode/escape, then +let s1=bitarray2set(bitarr,false,true);// and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if(s1.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! -return s1;}else{s1='['+s1+']';}// Now try to produce a minimum regex from the *inverted* bitarray via negation: +return s1;}s1='['+s1+']';// Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. -var s2=bitarray2set(bitarr,true,true);if(s2[0]==='^'){s2=s2.substr(1);if(s2.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! +let s2=bitarray2set(bitarr,true,true);if(s2[0]==='^'){s2=s2.substr(1);if(s2.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s2;}}else{s2='^'+s2;}s2='['+s2+']';// Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: -// +// // First try to produce a minimum regex from the bitarray directly: -var s3=bitarray2set(bitarr,false,false);// and when the regex set turns out to match a single pcode/escape, then +let s3=bitarray2set(bitarr,false,false);// and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if(s3.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! -return s3;}else{s3='['+s3+']';}// Now try to produce a minimum regex from the *inverted* bitarray via negation: +return s3;}s3='['+s3+']';// Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. -var s4=bitarray2set(bitarr,true,false);if(s4[0]==='^'){s4=s4.substr(1);if(s4.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! +let s4=bitarray2set(bitarr,true,false);if(s4[0]==='^'){s4=s4.substr(1);if(s4.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s4;}}else{s4='^'+s4;}s4='['+s4+']';if(s2.length0){err=e;}else{err=new Error('Could not parse jison lexer spec in JSON AUTODETECT mode:\nin JISON Mode we get Error: '+e.message+'\n\nwhile JSON5 Mode produces Error: '+ex1.message);err.secondary_exception=e;err.stack=ex1.stack;}}else{err=new Error('Could not parse lexer spec\nError: '+e.message);err.stack=e.stack;}throw err;}}}else{chk_l=lexerSpec;}// Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: +const commonErrors=[/does not compile/,/you did not correctly separate trailing code/,/You did not specify/,/You cannot specify/,/must be qualified/,/%start/,/%token/,/%import/,/%include/,/%options/,/%parse-params/,/%parser-type/,/%epsilon/,/definition list error/,/token list error/,/declaration error/,/should be followed/,/should be separated/,/an error in one or more of your lexer regex rules/,/an error in your lexer epilogue/,/unsupported definition type/];let cmnerr=commonErrors.filter(function check(re){return e.message.match(re);});if(cmnerr.length>0){err=e;}else{err=new Error('Could not parse jison lexer spec in JSON AUTODETECT mode:\nin JISON Mode we get Error: '+e.message+'\n\nwhile JSON5 Mode produces Error: '+ex1.message);err.secondary_exception=e;err.stack=ex1.stack;}}else{err=new Error('Could not parse lexer spec\nError: '+e.message);err.stack=e.stack;}throw err;}}}else{chk_l=lexerSpec;}// Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: return chk_l;}// expand macros and convert matchers to RegExp's -function prepareRules(dict,actions,caseHelper,tokens,startConditions,opts){var m,i,k,rule,action,conditions;var active_conditions;assert__default['default'](Array.isArray(dict.rules));var rules=dict.rules.slice(0);// shallow copy of the rules array as we MAY modify it in here! -var newRules=[];var macros={};var regular_rule_count=0;var simple_rule_count=0;// Assure all options are camelCased: +function prepareRules(dict,actions,caseHelper,tokens,startConditions,opts){let m,i,k,rule,action,conditions;let active_conditions;assert__default['default'](Array.isArray(dict.rules));let rules=dict.rules.slice(0);// shallow copy of the rules array as we MAY modify it in here! +let newRules=[];let macros={};let regular_rule_count=0;let simple_rule_count=0;// Assure all options are camelCased: assert__default['default'](typeof opts.options['case-insensitive']==='undefined');if(!tokens){tokens={};}if(opts.options.flex&&rules.length>0){rules.push(['.','console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']);}// Depending on the location within the regex we need different expansions of the macros: // one expansion for when a macro is *inside* a `[...]` and another expansion when a macro // is anywhere else in a regex: if(dict.macros){macros=prepareMacros(dict.macros,opts);}function tokenNumberReplacement(str,token){return'return '+(tokens[token]||'\''+token.replace(/'/g,'\\\'')+'\'');}// Make sure a comment does not contain any embedded '*/' end-of-comment marker // as that would break the generated code function postprocessComment(str){if(Array.isArray(str)){str=str.join(' ');}str=str.replace(/\*\//g,'*\\/');// destroy any inner `*/` comment terminator sequence. -return str;}var routingCode=['switch(yyrulenumber) {'];for(i=0;i0){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. -function reduceRegex(s,name,opts,expandAllMacrosInSet_cb,expandAllMacrosElsewhere_cb){var orig=s;function errinfo(){if(name){return'macro [['+name+']]';}else{return'regex [['+orig+']]';}}// propagate deferred exceptions = error reports. -if(s instanceof Error){return s;}var c1,c2;var rv=[];var derr;var se;while(s.length){c1=s.match(CHR_RE$1);if(!c1){// cope with illegal escape sequences too! -return new Error(errinfo()+': illegal escape sequence at start of regex part: '+s);}else{c1=c1[0];}s=s.substr(c1.length);switch(c1){case'[':// this is starting a set within the regex: scan until end of set! -var set_content=[];var l=new Array(UNICODE_BASE_PLANE_MAX_CP$1+1);while(s.length){var inner=s.match(SET_PART_RE$1);if(!inner){inner=s.match(CHR_RE$1);if(!inner){// cope with illegal escape sequences too! -return new Error(errinfo()+': illegal escape sequence at start of regex part: '+s);}else{inner=inner[0];}if(inner===']')break;}else{inner=inner[0];}set_content.push(inner);s=s.substr(inner.length);}// ensure that we hit the terminating ']': +function reduceRegex(s,name,opts,expandAllMacrosInSet_cb,expandAllMacrosElsewhere_cb){let orig=s;function errinfo(){if(name){return'macro [['+name+']]';}return'regex [['+orig+']]';}// propagate deferred exceptions = error reports. +if(s instanceof Error){return s;}let c1,c2;let rv=[];let derr;let se;while(s.length){c1=s.match(CHR_RE$1);if(!c1){// cope with illegal escape sequences too! +return new Error(errinfo()+': illegal escape sequence at start of regex part: '+s);}c1=c1[0];s=s.substr(c1.length);switch(c1){case'[':// this is starting a set within the regex: scan until end of set! +var set_content=[];var l=new Array(UNICODE_BASE_PLANE_MAX_CP$1+1);while(s.length){let inner=s.match(SET_PART_RE$1);if(!inner){inner=s.match(CHR_RE$1);if(!inner){// cope with illegal escape sequences too! +return new Error(errinfo()+': illegal escape sequence at start of regex part: '+s);}inner=inner[0];if(inner===']')break;}else{inner=inner[0];}set_content.push(inner);s=s.substr(inner.length);}// ensure that we hit the terminating ']': c2=s.match(CHR_RE$1);if(!c2){// cope with illegal escape sequences too! -return new Error(errinfo()+': regex set expression is broken: "'+s+'"');}else{c2=c2[0];}if(c2!==']'){return new Error(errinfo()+': regex set expression is broken: apparently unterminated');}s=s.substr(c2.length);se=set_content.join('');// expand any macros in here: +return new Error(errinfo()+': regex set expression is broken: "'+s+'"');}c2=c2[0];if(c2!==']'){return new Error(errinfo()+': regex set expression is broken: apparently unterminated');}s=s.substr(c2.length);se=set_content.join('');// expand any macros in here: if(expandAllMacrosInSet_cb){se=expandAllMacrosInSet_cb(se);assert__default['default'](se);if(se instanceof Error){return new Error(errinfo()+': '+se.message);}}derr=setmgmt.set2bitarray(l,se,opts);if(derr instanceof Error){return new Error(errinfo()+': '+derr.message);}// find out which set expression is optimal in size: var s1=setmgmt.produceOptimizedRegex4Set(l);// check if the source regex set potentially has any expansions (guestimate!) // @@ -3308,7 +3340,7 @@ case'\\p':c2=s.match(XREGEXP_UNICODE_ESCAPE_RE$1);if(c2){c2=c2[0];s=s.substr(c2. rv.push(c1+c2);}else{// nothing to stretch this match, hence nothing to expand. rv.push(c1);}break;// Either a range expression or the start of a macro reference: `.{1,3}` or `{NAME}`. // Treat it as a macro reference and see if it will expand to anything: -case'{':c2=s.match(NOTHING_SPECIAL_RE$1);if(c2){c2=c2[0];s=s.substr(c2.length);var c3=s[0];s=s.substr(c3.length);if(c3==='}'){// possibly a macro name in there... Expand if possible: +case'{':c2=s.match(NOTHING_SPECIAL_RE$1);if(c2){c2=c2[0];s=s.substr(c2.length);let c3=s[0];s=s.substr(c3.length);if(c3==='}'){// possibly a macro name in there... Expand if possible: c2=c1+c2+c3;if(expandAllMacrosElsewhere_cb){c2=expandAllMacrosElsewhere_cb(c2);assert__default['default'](c2);if(c2 instanceof Error){return new Error(errinfo()+': '+c2.message);}}}else{// not a well-terminated macro reference or something completely different: // we do not even attempt to expand this as there's guaranteed nothing to expand // in this bit. @@ -3324,11 +3356,11 @@ rv.push(c1+c2);}else{// nothing to stretch this match, hence nothing to expand. rv.push(c1);}break;}}s=rv.join('');// When this result is suitable for use in a set, than we should be able to compile // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: -try{var re;re=new XRegExp__default['default'](s);re.test(s[0]);}catch(ex){// make sure we produce a regex expression which will fail badly when it is used +try{let re;re=new XRegExp__default['default'](s);re.test(s[0]);}catch(ex){// make sure we produce a regex expression which will fail badly when it is used // in actual code: return new Error(errinfo()+': expands to an invalid regex: /'+s+'/');}assert__default['default'](s);return s;}// expand macros within macros and cache the result -function prepareMacros(dict_macros,opts){var macros={};// expand a `{NAME}` macro which exists inside a `[...]` set: -function expandMacroInSet(i){var k,a,m;if(!macros[i]){m=dict_macros[i];if(m.indexOf('{')>=0){// set up our own record so we can detect definition loops: +function prepareMacros(dict_macros,opts){let macros={};// expand a `{NAME}` macro which exists inside a `[...]` set: +function expandMacroInSet(i){let k,a,m;if(!macros[i]){m=dict_macros[i];if(m.indexOf('{')>=0){// set up our own record so we can detect definition loops: macros[i]={in_set:false,elsewhere:null,raw:dict_macros[i]};for(k in dict_macros){if(dict_macros.hasOwnProperty(k)&&i!==k){// it doesn't matter if the lexer recognized that the inner macro(s) // were sitting inside a `[...]` set or not: the fact that they are used // here in macro `i` which itself sits in a set, makes them *all* live in @@ -3340,18 +3372,18 @@ if(XRegExp__default['default']._getUnicodeProperty(k)){// Work-around so that yo // Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories, // while using `\p{ASCII}` as a *macro expansion* of the `ASCII` // macro: -if(k.toUpperCase()!==k){m=new Error('Cannot use name "'+k+'" as a macro name as it clashes with the same XRegExp "\\p{..}" Unicode \'General Category\' Property name. Use all-uppercase macro names, e.g. name your macro "'+k.toUpperCase()+'" to work around this issue or give your offending macro a different name.');break;}}a=m.split('{'+k+'}');if(a.length>1){var x=expandMacroInSet(k);assert__default['default'](x);if(x instanceof Error){m=x;break;}m=a.join(x);}}}}var mba=setmgmt.reduceRegexToSetBitArray(m,i,opts);var s1;// propagate deferred exceptions = error reports. +if(k.toUpperCase()!==k){m=new Error('Cannot use name "'+k+'" as a macro name as it clashes with the same XRegExp "\\p{..}" Unicode \'General Category\' Property name. Use all-uppercase macro names, e.g. name your macro "'+k.toUpperCase()+'" to work around this issue or give your offending macro a different name.');break;}}a=m.split('{'+k+'}');if(a.length>1){let x=expandMacroInSet(k);assert__default['default'](x);if(x instanceof Error){m=x;break;}m=a.join(x);}}}}let mba=setmgmt.reduceRegexToSetBitArray(m,i,opts);let s1;// propagate deferred exceptions = error reports. if(mba instanceof Error){s1=mba;}else{s1=setmgmt.bitarray2set(mba,false);m=s1;}macros[i]={in_set:s1,elsewhere:null,raw:dict_macros[i]};}else{m=macros[i].in_set;if(m instanceof Error){// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away! return new Error(m.message);}// detect definition loop: -if(m===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}}return m;}function expandMacroElsewhere(i){var m;if(macros[i].elsewhere==null){m=dict_macros[i];// set up our own record so we can detect definition loops: +if(m===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}}return m;}function expandMacroElsewhere(i){let m;if(macros[i].elsewhere==null){m=dict_macros[i];// set up our own record so we can detect definition loops: macros[i].elsewhere=false;// the macro MAY contain other macros which MAY be inside a `[...]` set in this // macro or elsewhere, hence we must parse the regex: m=reduceRegex(m,i,opts,expandAllMacrosInSet,expandAllMacrosElsewhere);// propagate deferred exceptions = error reports. if(m instanceof Error){return m;}macros[i].elsewhere=m;}else{m=macros[i].elsewhere;if(m instanceof Error){// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away! return m;}// detect definition loop: -if(m===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}}return m;}function expandAllMacrosInSet(s){var i,x;// process *all* the macros inside [...] set: -if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){var a=s.split('{'+i+'}');if(a.length>1){x=expandMacroInSet(i);assert__default['default'](x);if(x instanceof Error){return new Error('failure to expand the macro ['+i+'] in set ['+s+']: '+x.message);}s=a.join(x);}// stop the brute-force expansion attempt when we done 'em all: -if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s){var i,x;// When we process the remaining macro occurrences in the regex +if(m===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}}return m;}function expandAllMacrosInSet(s){let i,x;// process *all* the macros inside [...] set: +if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){let a=s.split('{'+i+'}');if(a.length>1){x=expandMacroInSet(i);assert__default['default'](x);if(x instanceof Error){return new Error('failure to expand the macro ['+i+'] in set ['+s+']: '+x.message);}s=a.join(x);}// stop the brute-force expansion attempt when we done 'em all: +if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s){let i,x;// When we process the remaining macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. // // Meanwhile the cached expansion will expand any submacros into @@ -3361,21 +3393,21 @@ if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s) // // This is a BREAKING CHANGE from vanilla jison 0.4.15! if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){// These are all submacro expansions, hence non-capturing grouping is applied: -var a=s.split('{'+i+'}');if(a.length>1){x=expandMacroElsewhere(i);assert__default['default'](x);if(x instanceof Error){return new Error('failure to expand the macro ['+i+'] in regex /'+s+'/: '+x.message);}s=a.join('(?:'+x+')');}// stop the brute-force expansion attempt when we done 'em all: -if(s.indexOf('{')===-1){break;}}}}return s;}var i;if(opts.debug)console.log('\n############## RAW macros: ',dict_macros);// first we create the part of the dictionary which is targeting the use of macros +let a=s.split('{'+i+'}');if(a.length>1){x=expandMacroElsewhere(i);assert__default['default'](x);if(x instanceof Error){return new Error('failure to expand the macro ['+i+'] in regex /'+s+'/: '+x.message);}s=a.join('(?:'+x+')');}// stop the brute-force expansion attempt when we done 'em all: +if(s.indexOf('{')===-1){break;}}}}return s;}let i;if(opts.debug)console.log('\n############## RAW macros: ',dict_macros);// first we create the part of the dictionary which is targeting the use of macros // *inside* `[...]` sets; once we have completed that half of the expansions work, // we then go and expand the macros for when they are used elsewhere in a regex: // iff we encounter submacros then which are used *inside* a set, we can use that // first half dictionary to speed things up a bit as we can use those expansions // straight away! for(i in dict_macros){if(dict_macros.hasOwnProperty(i)){expandMacroInSet(i);}}for(i in dict_macros){if(dict_macros.hasOwnProperty(i)){expandMacroElsewhere(i);}}if(opts.debug)console.log('\n############### expanded macros: ',macros);return macros;}// expand macros in a regex; expands them recursively -function expandMacros(src,macros,opts){var expansion_count=0;// By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! +function expandMacros(src,macros,opts){let expansion_count=0;// By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! // Hence things should be easy in there: -function expandAllMacrosInSet(s){var i,m,x;// process *all* the macros inside [...] set: -if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){m=macros[i];var a=s.split('{'+i+'}');if(a.length>1){x=m.in_set;assert__default['default'](x);if(x instanceof Error){// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away! +function expandAllMacrosInSet(s){let i,m,x;// process *all* the macros inside [...] set: +if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){m=macros[i];let a=s.split('{'+i+'}');if(a.length>1){x=m.in_set;assert__default['default'](x);if(x instanceof Error){// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away! throw x;}// detect definition loop: if(x===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}s=a.join(x);expansion_count++;}// stop the brute-force expansion attempt when we done 'em all: -if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s){var i,m,x;// When we process the main macro occurrences in the regex +if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s){let i,m,x;// When we process the main macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. // // Meanwhile the cached expansion will expand any submacros into @@ -3384,7 +3416,7 @@ if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s) // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! -if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){m=macros[i];var a=s.split('{'+i+'}');if(a.length>1){// These are all main macro expansions, hence CAPTURING grouping is applied: +if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){m=macros[i];let a=s.split('{'+i+'}');if(a.length>1){// These are all main macro expansions, hence CAPTURING grouping is applied: x=m.elsewhere;assert__default['default'](x);// detect definition loop: if(x===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}s=a.join('('+x+')');expansion_count++;}// stop the brute-force expansion attempt when we done 'em all: if(s.indexOf('{')===-1){break;}}}}return s;}// When we process the macro occurrences in the regex @@ -3396,7 +3428,7 @@ if(s.indexOf('{')===-1){break;}}}}return s;}// When we process the macro occurre // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! -var s2=reduceRegex(src,null,opts,expandAllMacrosInSet,expandAllMacrosElsewhere);// propagate deferred exceptions = error reports. +let s2=reduceRegex(src,null,opts,expandAllMacrosInSet,expandAllMacrosElsewhere);// propagate deferred exceptions = error reports. if(s2 instanceof Error){throw s2;}// only when we did expand some actual macros do we take the re-interpreted/optimized/regenerated regex from reduceRegex() // in order to keep our test cases simple and rules recognizable. This assumes the user can code good regexes on his own, // as long as no macros are involved... @@ -3404,8 +3436,8 @@ if(s2 instanceof Error){throw s2;}// only when we did expand some actual macros // Also pick the reduced regex when there (potentially) are XRegExp extensions in the original, e.g. `\\p{Number}`, // unless the `xregexp` output option has been enabled. if(expansion_count>0||src.indexOf('\\p{')>=0&&!opts.options.xregexp){src=s2;}else{// Check if the reduced regex is smaller in size; when it is, we still go with the new one! -if(s2.length0){toks[tokens[tok]]=idx;}}var gen=prepareRules(dict,actions,caseHelper,tokens&&toks,opts.conditions,opts);var code=actions.join('\n');'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function(yy){code=code.replace(new RegExp('\\b('+yy+')\\b','g'),'yy_.$1');});return{caseHelperInclude:'{\n'+caseHelper.join(',')+'\n}',actions:`function lexer__performAction(yy, yyrulenumber, YY_START) { +if(s2.length0){toks[tokens[tok]]=idx;}}let gen=prepareRules(dict,actions,caseHelper,tokens&&toks,opts.conditions,opts);let code=actions.join('\n');'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function(yy){code=code.replace(new RegExp('\\b('+yy+')\\b','g'),'yy_.$1');});return{caseHelperInclude:'{\n'+caseHelper.join(',')+'\n}',actions:`function lexer__performAction(yy, yyrulenumber, YY_START) { var yy_ = this; ${code} @@ -3415,7 +3447,7 @@ regular_rule_count:gen.regular_rule_count,simple_rule_count:gen.simple_rule_coun // jison/lib/jison.js @ line 2304:lrGeneratorMixin.generateErrorClass // function generateErrorClass(){// --- START lexer error class --- -var prelude=`/** +const prelude=`/** * 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 @@ -3426,8 +3458,6 @@ var prelude=`/** * @nocollapse */ function JisonLexerError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -3444,9 +3474,9 @@ function JisonLexerError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -3489,43 +3519,59 @@ return prelude;}const jisonLexerErrorDefinition=generateErrorClass();function ge fake.__hacky_backy__ = __hacky_counter__; return fake; } - `;}/** @constructor */function RegExpLexer(dict,input,tokens,build_options){var opts;var dump=false;function test_me(tweak_cb,description,src_exception,ex_callback){opts=processGrammar(dict,tokens,build_options);opts.__in_rules_failure_analysis_mode__=false;prepExportStructures(opts);assert__default['default'](opts.options);if(tweak_cb){tweak_cb();}var source=generateModuleBody(opts);try{// The generated code will always have the `lexer` variable declared at local scope + `;}/** @constructor */function RegExpLexer(dict,input,tokens,build_options){let opts;let dump=false;function test_me(tweak_cb,description,src_exception,ex_callback){opts=processGrammar(dict,tokens,build_options);opts.__in_rules_failure_analysis_mode__=false;prepExportStructures(opts);assert__default['default'](opts.options);if(tweak_cb){tweak_cb();}let source=generateModuleBody(opts);try{// The generated code will always have the `lexer` variable declared at local scope // as `eval()` will use the local scope. // // The compiled code will look something like this: // // ``` -// var lexer; +// let lexer; // bla bla... // ``` // // or // // ``` -// var lexer = { bla... }; +// const lexer = { bla... }; // ``` -var testcode=['// provide a local version for test purposes:',jisonLexerErrorDefinition,'',generateFakeXRegExpClassSrcCode(),'',source,'','return lexer;'].join('\n');var lexer=code_exec$1(testcode,function generated_code_exec_wrapper_regexp_lexer(sourcecode){//console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); -chkBugger$2(sourcecode);var lexer_f=new Function('',sourcecode);return lexer_f();},opts.options,"lexer");if(!lexer){throw new Error('no lexer defined *at all*?!');}if(typeof lexer.options!=='object'||lexer.options==null){throw new Error('your lexer class MUST have an .options member object or it won\'t fly!');}if(typeof lexer.setInput!=='function'){throw new Error('your lexer class MUST have a .setInput function member or it won\'t fly!');}if(lexer.EOF!==1&&lexer.ERROR!==2){throw new Error('your lexer class MUST have these constants defined: lexer.EOF = 1 and lexer.ERROR = 2 or it won\'t fly!');}// When we do NOT crash, we found/killed the problem area just before this call! -if(src_exception&&description){var msg=description;if(typeof description==='function'){msg=description();}src_exception.message+='\n ('+msg+')';}// patch the pre and post handlers in there, now that we have some live code to work with: -if(opts.options){var pre=opts.options.pre_lex;var post=opts.options.post_lex;// since JSON cannot encode functions, we'll have to do it manually now: -if(typeof pre==='function'){lexer.options.pre_lex=pre;}if(typeof post==='function'){lexer.options.post_lex=post;}}if(opts.options.showSource){if(typeof opts.options.showSource==='function'){opts.options.showSource(lexer,source,opts,RegExpLexer);}else{console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n",source,"\n----------------------------------------\n");}}return lexer;}catch(ex){// if (src_exception) { +let testcode=['// provide a local version for test purposes:',jisonLexerErrorDefinition,'',generateFakeXRegExpClassSrcCode(),'',source,'',rmCommonWS$2` + // JISON INJECTED VALIDATION CODE + // which attempts to ascertain you have defined a minimal viable lexer at least: + if (typeof lexer === "undefined") { + throw new SyntaxError("user-defined lexer does not define the required 'lexer' instance."); + } + if (!lexer) { + throw new SyntaxError("user-defined lexer does not define a non-NULL 'lexer' instance."); + } + if (typeof lexer.setInput !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.setInput()' API function."); + } + if (typeof lexer.lex !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.lex()' API function."); + } + // END OF JISON INJECTED VALIDATION CODE + `,'return lexer;'].join('\n');let lexer=code_exec(testcode,function generated_code_exec_wrapper_regexp_lexer(sourcecode){//console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); +chkBugger$2(sourcecode);let lexer_f=new Function('',sourcecode);return lexer_f();},Object.assign({},opts.options,{throwErrorOnCompileFailure:true}),'lexer');if(!lexer){throw new Error('no lexer defined *at all*?!');}if(typeof lexer.options!=='object'||lexer.options==null){throw new Error('your lexer class MUST have an .options member object or it won\'t fly!');}if(typeof lexer.setInput!=='function'){throw new Error('your lexer class MUST have a .setInput function member or it won\'t fly!');}if(lexer.EOF!==1&&lexer.ERROR!==2){throw new Error('your lexer class MUST have these constants defined: lexer.EOF = 1 and lexer.ERROR = 2 or it won\'t fly!');}// When we do NOT crash, we found/killed the problem area just before this call! +if(src_exception&&description){let msg=description;if(typeof description==='function'){msg=description();}src_exception.message+='\n ('+msg+')';}// patch the pre and post handlers in there, now that we have some live code to work with: +if(opts.options){let pre=opts.options.pre_lex;let post=opts.options.post_lex;// since JSON cannot encode functions, we'll have to do it manually now: +if(typeof pre==='function'){lexer.options.pre_lex=pre;}if(typeof post==='function'){lexer.options.post_lex=post;}}if(opts.options.showSource){if(typeof opts.options.showSource==='function'){opts.options.showSource(lexer,source,opts,RegExpLexer);}else{console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n',source,'\n----------------------------------------\n');}}return lexer;}catch(ex){// if (src_exception) { // src_exception.message += '\n (' + description + ': ' + ex.message + ')'; // } -if(ex_callback){ex_callback(ex);}else if(dump){console.log('source code:\n',source);}return false;}}/** @constructor */var lexer=test_me(null,null,null,function(ex){// When we get an exception here, it means some part of the user-specified lexer is botched. +if(ex_callback){ex_callback(ex);}else if(dump){console.log('source code:\n',source);}return false;}}/** @constructor */let lexer=test_me(null,null,null,function(ex){// When we get an exception here, it means some part of the user-specified lexer is botched. // // Now we go and try to narrow down the problem area/category: -assert__default['default'](opts.options);assert__default['default'](opts.options.xregexp!==undefined);var orig_xregexp_opt=!!opts.options.xregexp;if(!test_me(function(){assert__default['default'](opts.options.xregexp!==undefined);opts.options.xregexp=false;opts.showSource=false;},'When you have specified %option xregexp, you must also properly IMPORT the XRegExp library in the generated lexer.',ex,null)){if(!test_me(function(){// restore xregexp option setting: the trouble wasn't caused by the xregexp flag i.c.w. incorrect XRegExp library importing! -opts.options.xregexp=orig_xregexp_opt;opts.conditions=[];opts.showSource=false;},function(){assert__default['default'](Array.isArray(opts.rules));return opts.rules.length>0?'One or more of your lexer state names are possibly botched?':'Your custom lexer is somehow botched.';},ex,null)){var rulesSpecSize;if(!test_me(function(){// store the parsed rule set size so we can use that info in case +assert__default['default'](opts.options);assert__default['default'](opts.options.xregexp!==undefined);let orig_xregexp_opt=!!opts.options.xregexp;if(!test_me(function(){assert__default['default'](opts.options.xregexp!==undefined);opts.options.xregexp=false;opts.showSource=false;},'When you have specified %option xregexp, you must also properly IMPORT the XRegExp library in the generated lexer.',ex,null)){if(!test_me(function(){// restore xregexp option setting: the trouble wasn't caused by the xregexp flag i.c.w. incorrect XRegExp library importing! +opts.options.xregexp=orig_xregexp_opt;opts.conditions=[];opts.showSource=false;},function(){assert__default['default'](Array.isArray(opts.rules));return opts.rules.length>0?'One or more of your lexer state names are possibly botched?':'Your custom lexer is somehow botched.';},ex,null)){let rulesSpecSize;if(!test_me(function(){// store the parsed rule set size so we can use that info in case // this attempt also fails: assert__default['default'](Array.isArray(opts.rules));rulesSpecSize=opts.rules.length;// opts.conditions = []; opts.rules=[];opts.showSource=false;opts.__in_rules_failure_analysis_mode__=true;},'One or more of your lexer rules are possibly botched?',ex,null)){// kill each rule action block, one at a time and test again after each 'edit': -var rv=false;for(var i=0,len=rulesSpecSize;i= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -3752,8 +3789,6 @@ return`{ * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -3763,14 +3798,14 @@ return`{ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -3781,8 +3816,6 @@ return`{ * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -3790,40 +3823,40 @@ return`{ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -3835,7 +3868,7 @@ return`{ this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -3843,7 +3876,7 @@ return`{ last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -3904,9 +3937,7 @@ return`{ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -3925,8 +3956,6 @@ return`{ * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set \`done\` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -3935,7 +3964,7 @@ return`{ this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -3945,13 +3974,13 @@ return`{ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\\n') { lines = true; } else if (ch === '\\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\\n') { slice_len++; ch += ch2; @@ -3983,10 +4012,8 @@ return`{ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -4018,8 +4045,8 @@ return`{ // Get last entirely matched line into the \`pre_lines[]\` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -4037,9 +4064,9 @@ return`{ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -4049,14 +4076,12 @@ return`{ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -4067,8 +4092,6 @@ return`{ * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -4081,19 +4104,17 @@ return`{ * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the \`parseError()\` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // \`.lex()\` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -4106,8 +4127,6 @@ return`{ * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -4130,24 +4149,24 @@ return`{ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substr\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -4159,8 +4178,8 @@ return`{ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to \`maxSize\` (default: 20). @@ -4186,24 +4205,25 @@ return`{ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > \`lookAhead()\` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substring\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -4212,7 +4232,7 @@ return`{ } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -4231,10 +4251,8 @@ return`{ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^'; }, @@ -4256,15 +4274,13 @@ return`{ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -4395,58 +4411,54 @@ return`{ * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\\t/g, ' '); @@ -4455,13 +4467,13 @@ return`{ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -4483,15 +4495,13 @@ return`{ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -4503,8 +4513,8 @@ return`{ rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -4533,13 +4543,7 @@ return`{ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -4568,10 +4572,10 @@ return`{ }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -4599,7 +4603,7 @@ return`{ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -4610,7 +4614,7 @@ return`{ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -4632,8 +4636,6 @@ return`{ * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -4642,17 +4644,13 @@ return`{ this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -4662,67 +4660,75 @@ return`{ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that \`parseError()\` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) \`parseError()\` @@ -4749,9 +4755,7 @@ return`{ * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -4794,24 +4798,24 @@ return`{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -4831,9 +4835,7 @@ return`{ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -4843,24 +4845,24 @@ return`{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -4868,7 +4870,7 @@ return`{ this._clear_state = 0; } - + return r; }, @@ -4881,9 +4883,7 @@ return`{ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -4891,7 +4891,7 @@ return`{ (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -4906,8 +4906,6 @@ return`{ * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -4919,8 +4917,6 @@ return`{ * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -4934,15 +4930,12 @@ return`{ * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -4954,14 +4947,11 @@ return`{ * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -4972,16 +4962,14 @@ return`{ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -4991,8 +4979,6 @@ return`{ * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; } }`;// --- END lexer kernel --- @@ -5015,7 +5001,7 @@ function stripUnusedLexerCode(src,opt){// uses yyleng: ..................... $ // uses display APIs pastInput(), upcomingInput(), showPosition(): // ............................. ${opt.lexerActionsUseDisplayAPIs} // uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC} -var new_src;try{var ast=helpers.parseCodeChunkToAST(src,opt);new_src=helpers.prettyPrintAST(ast,opt);}catch(ex){let line=ex.lineNumber||0;let a=src.split(/\r?\n/g);let len=a.length;let minl=Math.max(0,line-10);let b=a.slice(minl,line+10);let c=b.splice(line-minl,0,"","^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^","");let offendingChunk=' '+b.join('\n ');console.error(rmCommonWS$2` +let new_src;try{let ast=helpers.parseCodeChunkToAST(src,opt);new_src=helpers.prettyPrintAST(ast,opt);}catch(ex){let line=ex.lineNumber||0;let a=src.split(/\r?\n/g);let len=a.length;let minl=Math.max(0,line-10);let b=a.slice(minl,line+10);let c=b.splice(line-minl,0,'','^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^','');let offendingChunk=' '+b.join('\n ');console.error(rmCommonWS$2` stripUnusedLexerCode WARNING: JISON failed to reformat the generated lexer. @@ -5071,8 +5057,8 @@ new_src=new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g,rmCommonWS$2 // --------- END OF REPORT ----------- `);return new_src;}// generate lexer source from a grammar -/** @public */function generate(dict,tokens,build_options){var opt=processGrammar(dict,tokens,build_options);return generateFromOpts(opt);}// process the grammar and build final data structures and functions -/** @public */function processGrammar(dict,tokens,build_options){build_options=build_options||{};var opts={// include the knowledge passed through `build_options` about which lexer +/** @public */function generate(dict,tokens,build_options){let opt=processGrammar(dict,tokens,build_options);return generateFromOpts(opt);}// process the grammar and build final data structures and functions +/** @public */function processGrammar(dict,tokens,build_options){build_options=build_options||{};let opts={// include the knowledge passed through `build_options` about which lexer // features will actually be *used* by the environment (which in 99.9% // of cases is a jison *parser*): // @@ -5085,22 +5071,22 @@ opts.lex_rule_dictionary=dict;// Always provide the lexer with an options object opts.options=mkStdOptions(build_options,dict.options);opts.moduleType=opts.options.moduleType;opts.moduleName=opts.options.moduleName;opts.conditions=prepareStartConditions(dict.startConditions);opts.conditions.INITIAL={rules:[],inclusive:true};// only produce rule action code blocks when there are any rules at all; // a "custom lexer" has ZERO rules and must be defined entirely in // other code blocks: -var code=dict.rules?buildActions(dict,tokens,opts):{};opts.performAction=code.actions;opts.caseHelperInclude=code.caseHelperInclude;opts.rules=code.rules||[];opts.macros=code.macros;opts.regular_rule_count=code.regular_rule_count;opts.simple_rule_count=code.simple_rule_count;opts.conditionStack=['INITIAL'];opts.actionInclude=dict.actionInclude||'';opts.moduleInclude=(opts.moduleInclude||'')+(dict.moduleInclude||'').trim();return opts;}// Assemble the final source from the processed grammar -/** @public */function generateFromOpts(opt){var code='';switch(opt.moduleType){case'js':code=generateModule(opt);break;case'amd':code=generateAMDModule(opt);break;case'es':code=generateESModule(opt);break;case'commonjs':code=generateCommonJSModule(opt);break;default:throw new Error('unsupported moduleType: '+opt.moduleType);}return code;}function generateRegexesInitTableCode(opt){var a=opt.rules;var print_xregexp=opt.options&&opt.options.xregexp;var id_display_width=1+Math.log10(a.length|1)|0;var ws_prefix=new Array(id_display_width).join(' ');var b=a.map(function generateXRegExpInitCode(re,idx){var idx_str=(ws_prefix+idx).substr(-id_display_width);if(re instanceof XRegExp__default['default']){// When we don't need the special XRegExp sauce at run-time, we do with the original +let code=dict.rules?buildActions(dict,tokens,opts):{};opts.performAction=code.actions;opts.caseHelperInclude=code.caseHelperInclude;opts.rules=code.rules||[];opts.macros=code.macros;opts.regular_rule_count=code.regular_rule_count;opts.simple_rule_count=code.simple_rule_count;opts.conditionStack=['INITIAL'];opts.actionInclude=dict.actionInclude||'';opts.moduleInclude=(opts.moduleInclude||'')+(dict.moduleInclude||'').trim();return opts;}// Assemble the final source from the processed grammar +/** @public */function generateFromOpts(opt){let code='';switch(opt.moduleType){case'js':code=generateModule(opt);break;case'amd':code=generateAMDModule(opt);break;case'es':code=generateESModule(opt);break;case'commonjs':code=generateCommonJSModule(opt);break;default:throw new Error('unsupported moduleType: '+opt.moduleType);}return code;}function generateRegexesInitTableCode(opt){let a=opt.rules;let print_xregexp=opt.options&&opt.options.xregexp;let id_display_width=1+Math.log10(a.length|1)|0;let ws_prefix=new Array(id_display_width).join(' ');let b=a.map(function generateXRegExpInitCode(re,idx){let idx_str=(ws_prefix+idx).substr(-id_display_width);if(re instanceof XRegExp__default['default']){// When we don't need the special XRegExp sauce at run-time, we do with the original // JavaScript RegExp instance a.k.a. 'native regex': if(re.xregexp.isNative||!print_xregexp){return`/* ${idx_str}: */ ${re}`;}// And make sure to escape the regex to make it suitable for placement inside a *string* // as it is passed as a string argument to the XRegExp constructor here. -var re_src=re.xregexp.source.replace(/[\\"]/g,'\\$&');return`/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`;}else{return`/* ${idx_str}: */ ${re}`;}});return b.join(',\n');}function generateModuleBody(opt){// make the JSON output look more like JavaScript: -function cleanupJSON(str){str=str.replace(/ "rules": \[/g,' rules: [');str=str.replace(/ "inclusive": /g,' inclusive: ');return str;}function produceOptions(opts){var obj={};var do_not_pass={debug:!opts.debug,// do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! -enableDebugLogs:1,json:1,_:1,noMain:1,dumpSourceCodeOnFailure:1,throwErrorOnCompileFailure:1,reportStats:1,file:1,outfile:1,inputPath:1,inputFilename:1,defaultModuleName:1,moduleName:1,moduleType:1,lexerErrorsAreRecoverable:0,flex:0,backtrack_lexer:0,caseInsensitive:0,showSource:1,exportAST:1,exportAllTables:1,exportSourceCode:1,prettyCfg:1,parseActionsUseYYLENG:1,parseActionsUseYYLINENO:1,parseActionsUseYYTEXT:1,parseActionsUseYYLOC:1,parseActionsUseParseError:1,parseActionsUseYYERROR:1,parseActionsUseYYRECOVERING:1,parseActionsUseYYERROK:1,parseActionsUseYYCLEARIN:1,parseActionsUseValueTracking:1,parseActionsUseValueAssignment:1,parseActionsUseLocationTracking:1,parseActionsUseLocationAssignment:1,parseActionsUseYYSTACK:1,parseActionsUseYYSSTACK:1,parseActionsUseYYSTACKPOINTER:1,parseActionsUseYYRULELENGTH:1,parseActionsUseYYMERGELOCATIONINFO:1,parserHasErrorRecovery:1,parserHasErrorReporting:1,lexerActionsUseYYLENG:1,lexerActionsUseYYLINENO:1,lexerActionsUseYYTEXT:1,lexerActionsUseYYLOC:1,lexerActionsUseParseError:1,lexerActionsUseYYERROR:1,lexerActionsUseLocationTracking:1,lexerActionsUseMore:1,lexerActionsUseUnput:1,lexerActionsUseReject:1,lexerActionsUseLess:1,lexerActionsUseDisplayAPIs:1,lexerActionsUseDescribeYYLOC:1};for(var k in opts){if(!do_not_pass[k]&&opts[k]!=null&&opts[k]!==false){// make sure numeric values are encoded as numeric, the rest as boolean/string. -if(typeof opts[k]==='string'){var f=parseFloat(opts[k]);if(f==opts[k]){obj[k]=f;continue;}}obj[k]=opts[k];}}// And now some options which should receive some special processing: -var pre=obj.pre_lex;var post=obj.post_lex;// since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: -if(pre){obj.pre_lex=true;}if(post){obj.post_lex=true;}var js=JSON.stringify(obj,null,2);js=js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$1})": `,'g'),' $1: ');js=js.replace(/^( +)pre_lex: true(,)?$/gm,function(m,ls,tc){return ls+'pre_lex: '+String(pre)+(tc||'');});js=js.replace(/^( +)post_lex: true(,)?$/gm,function(m,ls,tc){return ls+'post_lex: '+String(post)+(tc||'');});return js;}var out;if(opt.rules.length>0||opt.__in_rules_failure_analysis_mode__){// we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: +let re_src=re.xregexp.source.replace(/[\\"]/g,'\\$&');return`/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`;}return`/* ${idx_str}: */ ${re}`;});return b.join(',\n');}function generateModuleBody(opt){// make the JSON output look more like JavaScript: +function cleanupJSON(str){str=str.replace(/ {2}"rules": \[/g,' rules: [');str=str.replace(/ {2}"inclusive": /g,' inclusive: ');return str;}function produceOptions(opts){let obj={};const do_not_pass={debug:!opts.debug,// do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! +enableDebugLogs:1,json:1,_:1,noMain:1,dumpSourceCodeOnFailure:1,throwErrorOnCompileFailure:1,reportStats:1,file:1,outfile:1,inputPath:1,inputFilename:1,defaultModuleName:1,moduleName:1,moduleType:1,lexerErrorsAreRecoverable:0,flex:0,backtrack_lexer:0,caseInsensitive:0,showSource:1,exportAST:1,exportAllTables:1,exportSourceCode:1,prettyCfg:1,parseActionsUseYYLENG:1,parseActionsUseYYLINENO:1,parseActionsUseYYTEXT:1,parseActionsUseYYLOC:1,parseActionsUseParseError:1,parseActionsUseYYERROR:1,parseActionsUseYYRECOVERING:1,parseActionsUseYYERROK:1,parseActionsUseYYCLEARIN:1,parseActionsUseValueTracking:1,parseActionsUseValueAssignment:1,parseActionsUseLocationTracking:1,parseActionsUseLocationAssignment:1,parseActionsUseYYSTACK:1,parseActionsUseYYSSTACK:1,parseActionsUseYYSTACKPOINTER:1,parseActionsUseYYRULELENGTH:1,parseActionsUseYYMERGELOCATIONINFO:1,parserHasErrorRecovery:1,parserHasErrorReporting:1,lexerActionsUseYYLENG:1,lexerActionsUseYYLINENO:1,lexerActionsUseYYTEXT:1,lexerActionsUseYYLOC:1,lexerActionsUseParseError:1,lexerActionsUseYYERROR:1,lexerActionsUseLocationTracking:1,lexerActionsUseMore:1,lexerActionsUseUnput:1,lexerActionsUseReject:1,lexerActionsUseLess:1,lexerActionsUseDisplayAPIs:1,lexerActionsUseDescribeYYLOC:1};for(let k in opts){if(!do_not_pass[k]&&opts[k]!=null&&opts[k]!==false){// make sure numeric values are encoded as numeric, the rest as boolean/string. +if(typeof opts[k]==='string'){let f=parseFloat(opts[k]);if(f==opts[k]){obj[k]=f;continue;}}obj[k]=opts[k];}}// And now some options which should receive some special processing: +let pre=obj.pre_lex;let post=obj.post_lex;// since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: +if(pre){obj.pre_lex=true;}if(post){obj.post_lex=true;}let js=JSON.stringify(obj,null,2);js=js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$1})": `,'g'),' $1: ');js=js.replace(/^( +)pre_lex: true(,)?$/gm,function(m,ls,tc){return ls+'pre_lex: '+String(pre)+(tc||'');});js=js.replace(/^( +)post_lex: true(,)?$/gm,function(m,ls,tc){return ls+'post_lex: '+String(post)+(tc||'');});return js;}let out;if(opt.rules.length>0||opt.__in_rules_failure_analysis_mode__){// we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. -var code=[rmCommonWS$2` - var lexer = { - `,'/*JISON-LEX-ANALYTICS-REPORT*/'/* slot #1: placeholder for analysis report further below */];// get the RegExpLexer.prototype in source code form: -var protosrc=getRegExpLexerPrototype();// and strip off the surrounding bits we don't want: +let code=[rmCommonWS$2` + const lexer = { + `,'/* JISON-LEX-ANALYTICS-REPORT */\n'/* slot #1: placeholder for analysis report further below */];// get the RegExpLexer.prototype in source code form: +let protosrc=getRegExpLexerPrototype();// and strip off the surrounding bits we don't want: protosrc=protosrc.replace(/^[\s\r\n]*\{/,'').replace(/\s*\}[\s\r\n]*$/,'').trim();code.push(protosrc+',\n');assert__default['default'](opt.options);// Assure all options are camelCased: assert__default['default'](typeof opt.options['case-insensitive']==='undefined');code.push(' options: '+produceOptions(opt.options));/* function isEmpty(code) { @@ -5113,7 +5099,7 @@ assert__default['default'](typeof opt.options['case-insensitive']==='undefined') } } -*/var performActionCode=String(opt.performAction);var simpleCaseActionClustersCode=String(opt.caseHelperInclude);var rulesCode=generateRegexesInitTableCode(opt);var conditionsCode=cleanupJSON(JSON.stringify(opt.conditions,null,2));code.push(rmCommonWS$2`, +*/let performActionCode=String(opt.performAction);let simpleCaseActionClustersCode=String(opt.caseHelperInclude);let rulesCode=generateRegexesInitTableCode(opt);let conditionsCode=cleanupJSON(JSON.stringify(opt.conditions,null,2));code.push(rmCommonWS$2`, JisonLexerError: JisonLexerError, performAction: ${performActionCode}, simpleCaseActionClusters: ${simpleCaseActionClustersCode}, @@ -5126,18 +5112,16 @@ assert__default['default'](typeof opt.options['case-insensitive']==='undefined') // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // -// Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter +// Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. -out='var lexer;\n';assert__default['default'](opt.regular_rule_count===0);assert__default['default'](opt.simple_rule_count===0);opt.is_custom_lexer=true;if(opt.actionInclude){out+=opt.actionInclude+(!opt.actionInclude.match(/;[\s\r\n]*$/)?';':'')+'\n';}}// The output of this function is guaranteed to read something like this: +out='\n';assert__default['default'](opt.regular_rule_count===0);assert__default['default'](opt.simple_rule_count===0);opt.is_custom_lexer=true;if(opt.actionInclude){out+=opt.actionInclude+(!opt.actionInclude.match(/;[\s\r\n]*$/)?';':'')+'\n';}}// The output of this function is guaranteed to read something like this: // // ``` -// var lexer; -// // bla bla bla bla ... lotsa bla bla; // ``` // // and that should work nicely as an `eval()`-able piece of source code. -return out;}function generateGenericHeaderComment(){var out=rmCommonWS$2` +return out;}function generateGenericHeaderComment(){let out=rmCommonWS$2` /* lexer generated by jison-lex ${version} */ /* @@ -5356,8 +5340,8 @@ return out;}function generateGenericHeaderComment(){var out=rmCommonWS$2` * } */ `;return out;}function prepareOptions(opt){opt=opt||{};// check for illegal identifier -if(!opt.moduleName||!opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)){if(opt.moduleName){var msg='WARNING: The specified moduleName "'+opt.moduleName+'" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.';if(typeof opt.warn_cb==='function'){opt.warn_cb(msg);}else{// do not treat as warning; barf hairball instead so that this oddity gets noticed right away! -throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return opt;}function generateModule(opt){opt=prepareOptions(opt);var modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';var src=rmCommonWS$2` +if(!opt.moduleName||!opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)){if(opt.moduleName){let msg='WARNING: The specified moduleName "'+opt.moduleName+'" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.';if(typeof opt.warn_cb==='function'){opt.warn_cb(msg);}else{// do not treat as warning; barf hairball instead so that this oddity gets noticed right away! +throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return opt;}function generateModule(opt){opt=prepareOptions(opt);let modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';let src=rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -5371,7 +5355,7 @@ throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return return lexer; })(); - `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateAMDModule(opt){opt=prepareOptions(opt);var modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';var src=rmCommonWS$2` + `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateAMDModule(opt){opt=prepareOptions(opt);let modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';let src=rmCommonWS$2` ${generateGenericHeaderComment()} define([], function () { @@ -5385,10 +5369,10 @@ throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return return lexer; }); - `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateESModule(opt){opt=prepareOptions(opt);var modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';var src=rmCommonWS$2` + `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateESModule(opt){opt=prepareOptions(opt);let modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';let src=rmCommonWS$2` ${generateGenericHeaderComment()} - var lexer = (function () { + const lexer = (function () { "use strict"; ${jisonLexerErrorDefinition} @@ -5408,7 +5392,7 @@ throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return lexer, yylex as lex }; - `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateCommonJSModule(opt){opt=prepareOptions(opt);var modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';var src=rmCommonWS$2` + `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateCommonJSModule(opt){opt=prepareOptions(opt);let modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';let src=rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { diff --git a/packages/jison-lex/dist/regexp-lexer-cjs.js b/packages/jison-lex/dist/regexp-lexer-cjs.js index f2128b93c..c19d64f21 100644 --- a/packages/jison-lex/dist/regexp-lexer-cjs.js +++ b/packages/jison-lex/dist/regexp-lexer-cjs.js @@ -4,6 +4,7 @@ var XRegExp = require('@gerhobbelt/xregexp'); var JSON5 = require('@gerhobbelt/json5'); var fs = require('fs'); var path$1 = require('path'); +var mkdirp = require('mkdirp'); var recast = require('recast'); var babel = require('@babel/core'); var assert$1 = require('assert'); @@ -14,10 +15,11 @@ var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); +var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); -// Return TRUE if `src` starts with `searchString`. +// Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -40,19 +42,19 @@ function rmCommonWS(strings, ...values) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -71,19 +73,21 @@ function rmCommonWS(strings, ...values) { // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -92,16 +96,19 @@ function rmCommonWS(strings, ...values) { } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -112,27 +119,79 @@ function camelCase(s) { return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } +// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; +})([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' +]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -150,6 +209,11 @@ function mkIdentifier(s) { .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -158,13 +222,13 @@ function mkIdentifier(s) { function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -175,23 +239,17 @@ function scanRegExp(s) { break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -214,34 +272,33 @@ function isLineTerminator(cp) { /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -264,28 +321,76 @@ function chkBugger(src) { // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } +function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; +} + + +function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); +} + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -296,27 +401,37 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -326,7 +441,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -334,7 +449,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -360,27 +475,43 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -393,9 +524,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -417,22 +549,22 @@ assert__default['default'](recast__default['default']); // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; -// Determine which Unicode NonAsciiIdentifierStart characters +// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -440,40 +572,40 @@ const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -481,30 +613,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -515,59 +647,59 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -609,38 +741,38 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -652,18 +784,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -674,56 +806,56 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -731,97 +863,97 @@ function generateMapper4JisonGrammarIdentifiers(input) { typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -829,7 +961,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -842,7 +974,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -855,7 +987,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -868,7 +1000,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -887,37 +1019,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -949,7 +1081,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -966,37 +1098,37 @@ function parseCodeChunkToAST(src, options) { .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return babel.transformSync(src, options); // => { code, map, ast } @@ -1004,8 +1136,8 @@ function compileCodeToES5(src, options) { function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1014,7 +1146,7 @@ function prettyPrintAST(ast, options) { // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1037,25 +1169,25 @@ function prettyPrintAST(ast, options) { // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1066,9 +1198,9 @@ function checkActionBlock(src, yylloc, options) { // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1076,7 +1208,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1085,14 +1217,14 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1146,7 +1278,7 @@ var parse2AST = { trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1160,7 +1292,7 @@ function chkBugger$1(src) { /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1172,24 +1304,24 @@ const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?: /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1206,8 +1338,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1218,14 +1350,14 @@ function printFunctionSourceCodeContainer(f) { action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1236,17 +1368,17 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; -// -// -// +// +// +// function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1272,7 +1404,7 @@ function detectIstanbulGlobal() { // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1320,7 +1452,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1383,13 +1515,13 @@ var reHelpers = { getRegExpInfo: getRegExpInfo }; -var cycleref = []; -var cyclerefpath = []; +let cycleref = []; +let cyclerefpath = []; -var linkref = []; -var linkrefpath = []; +let linkref = []; +let linkrefpath = []; -var path = []; +let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1397,14 +1529,14 @@ function shallow_copy(src) { return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1417,11 +1549,11 @@ function shallow_copy(src) { function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1434,9 +1566,9 @@ function shallow_copy_and_strip_depth(src, parentKey) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1451,16 +1583,52 @@ function shallow_copy_and_strip_depth(src, parentKey) { } +// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } +// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; +} + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1475,7 +1643,7 @@ function trim_array_tail(arr) { function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1501,10 +1669,10 @@ function treat_value_stack(v) { } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1602,7 +1770,7 @@ function treat_hash(h) { function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1619,7 +1787,7 @@ function treat_error_report_info(e) { path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1647,7 +1815,7 @@ function treat_error_report_info(e) { function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1663,7 +1831,7 @@ function treat_object(e) { linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1675,14 +1843,14 @@ function treat_object(e) { // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1692,7 +1860,7 @@ function trimErrorForTestReporting(e) { cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1706,12 +1874,14 @@ var helpers = { dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1726,7 +1896,7 @@ var helpers = { printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; // See also: @@ -1734,7 +1904,6 @@ var helpers = { // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1751,9 +1920,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -1786,10 +1955,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -1802,11 +1971,11 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -1816,18 +1985,18 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -1858,7 +2027,7 @@ JisonParserError.prototype.name = 'JisonParserError'; // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -1875,9 +2044,9 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -1890,7 +2059,7 @@ JisonParserError.prototype.name = 'JisonParserError'; } -var parser = { +let parser = { // Code Generator Information Report // --------------------------------- // @@ -2140,7 +2309,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2148,7 +2316,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2160,8 +2327,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2174,14 +2341,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2197,10 +2363,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2208,10 +2374,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2366,9 +2532,9 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -2380,18 +2546,18 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2421,9 +2587,9 @@ case 1: case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -2436,10 +2602,10 @@ case 2: case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2466,9 +2632,9 @@ case 3: case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -2477,10 +2643,10 @@ case 4: case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2508,9 +2674,9 @@ case 5: case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -2519,10 +2685,10 @@ case 6: case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -2561,9 +2727,9 @@ case 7: case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2628,9 +2794,9 @@ case 8: case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2645,9 +2811,9 @@ case 9: case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -2682,10 +2848,10 @@ case 10: case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2702,9 +2868,9 @@ case 11: case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2721,10 +2887,10 @@ case 12: case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2741,9 +2907,9 @@ case 13: case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2760,10 +2926,10 @@ case 14: case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2780,9 +2946,9 @@ case 15: case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -2806,9 +2972,9 @@ case 17: case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -2819,9 +2985,9 @@ case 132: case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2841,9 +3007,9 @@ case 18: case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2867,9 +3033,9 @@ case 19: case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2882,10 +3048,10 @@ case 20: case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2902,9 +3068,9 @@ case 21: case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2916,9 +3082,9 @@ case 22: case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -2958,10 +3124,10 @@ case 23: case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2981,9 +3147,9 @@ case 24: case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3033,10 +3199,10 @@ case 25: case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -3060,10 +3226,10 @@ case 26: case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3083,10 +3249,10 @@ case 27: case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3110,10 +3276,10 @@ case 28: case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3134,10 +3300,10 @@ case 29: case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3149,10 +3315,10 @@ case 31: case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3162,10 +3328,10 @@ case 33: case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3175,10 +3341,10 @@ case 32: case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3188,10 +3354,10 @@ case 34: case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3201,10 +3367,10 @@ case 35: case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -3214,10 +3380,10 @@ case 36: case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3227,10 +3393,10 @@ case 37: case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3240,9 +3406,9 @@ case 38: case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -3251,9 +3417,9 @@ case 39: case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -3262,9 +3428,9 @@ case 40: case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3286,9 +3452,9 @@ case 41: case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3299,9 +3465,9 @@ case 42: case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3321,9 +3487,9 @@ case 43: case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3377,9 +3543,9 @@ case 49: case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3399,9 +3565,9 @@ case 51: case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -3410,9 +3576,9 @@ case 58: case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -3424,9 +3590,9 @@ case 52: case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -3440,10 +3606,10 @@ case 53: case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3463,10 +3629,10 @@ case 54: case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3486,10 +3652,10 @@ case 55: case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3509,9 +3675,9 @@ case 56: case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3522,9 +3688,9 @@ case 59: case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3543,9 +3709,9 @@ case 60: case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -3586,9 +3752,9 @@ case 61: case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3612,9 +3778,9 @@ case 62: case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3640,9 +3806,9 @@ case 63: case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3687,9 +3853,9 @@ case 64: case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -3715,9 +3881,9 @@ case 106: case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -3726,9 +3892,9 @@ case 127: case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -3737,10 +3903,10 @@ case 67: case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3754,10 +3920,10 @@ case 68: case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3771,10 +3937,10 @@ case 69: case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3788,10 +3954,10 @@ case 70: case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3810,9 +3976,9 @@ case 72: case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -3821,9 +3987,9 @@ case 77: case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -3861,10 +4027,10 @@ case 73: case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -3888,9 +4054,9 @@ case 74: case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -3969,9 +4135,9 @@ case 110: case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -3980,9 +4146,9 @@ case 129: case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -3991,9 +4157,9 @@ case 78: case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -4002,9 +4168,9 @@ case 79: case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -4013,9 +4179,9 @@ case 80: case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -4024,9 +4190,9 @@ case 81: case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -4035,9 +4201,9 @@ case 85: case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -4048,10 +4214,10 @@ case 87: case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4068,9 +4234,9 @@ case 88: case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -4079,9 +4245,9 @@ case 89: case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -4090,9 +4256,9 @@ case 90: case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -4101,9 +4267,9 @@ case 91: case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -4112,9 +4278,9 @@ case 92: case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -4133,18 +4299,18 @@ case 107: case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -4153,9 +4319,9 @@ case 97: case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -4164,9 +4330,9 @@ case 98: case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -4175,9 +4341,9 @@ case 99: case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -4186,9 +4352,9 @@ case 102: case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -4197,10 +4363,10 @@ case 104: case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4217,9 +4383,9 @@ case 105: case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -4236,9 +4402,9 @@ case 109: case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -4250,9 +4416,9 @@ case 111: case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -4262,9 +4428,9 @@ case 112: case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4299,9 +4465,9 @@ case 113: case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4320,9 +4486,9 @@ case 114: case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -4331,9 +4497,9 @@ case 115: case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -4342,9 +4508,9 @@ case 116: case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4362,10 +4528,10 @@ case 117: case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -4383,10 +4549,10 @@ case 118: case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -4407,9 +4573,9 @@ case 119: case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4442,9 +4608,9 @@ case 120: case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4470,9 +4636,9 @@ case 121: case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5__default['default'].parse(yyvstack[yysp]); @@ -4481,9 +4647,9 @@ case 122: case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue(yyvstack[yysp]); @@ -4492,9 +4658,9 @@ case 123: case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4503,9 +4669,9 @@ case 124: case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -4526,10 +4692,10 @@ case 125: case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4546,9 +4712,9 @@ case 126: case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -4567,9 +4733,9 @@ case 128: case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4593,9 +4759,9 @@ case 130: case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -4615,9 +4781,9 @@ case 131: case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4628,9 +4794,9 @@ case 133: case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -4686,10 +4852,10 @@ case 134: case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6292,7 +6458,6 @@ defaultActions: bda({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -6309,38 +6474,34 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -6348,20 +6509,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -6383,7 +6542,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -6391,18 +6549,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -6410,24 +6569,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -6465,18 +6619,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -6497,7 +6648,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -6515,7 +6666,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -6528,7 +6678,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -6542,11 +6691,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -6600,8 +6748,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6609,8 +6757,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6642,19 +6790,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -6665,7 +6812,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -6678,7 +6825,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -6690,29 +6837,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -6720,7 +6865,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -6740,8 +6885,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -6750,10 +6894,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -6761,7 +6905,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -6772,9 +6916,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -6790,8 +6939,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -6860,11 +7008,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -6875,8 +7026,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -6885,21 +7035,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6909,21 +7058,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6932,28 +7080,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -6966,8 +7113,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -6990,8 +7136,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -7003,8 +7148,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -7021,8 +7165,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -7036,8 +7179,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -7051,7 +7193,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -7104,16 +7246,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -7147,9 +7286,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -7172,9 +7309,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -7201,17 +7336,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -7258,8 +7392,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -7271,8 +7405,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -7290,6 +7423,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -7298,7 +7432,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -7309,7 +7443,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -7369,10 +7503,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -7407,9 +7541,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -7422,7 +7554,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -7443,9 +7575,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7467,12 +7597,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -7481,7 +7611,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7522,7 +7652,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -7569,7 +7699,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -7587,21 +7717,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7635,14 +7763,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7652,6 +7781,7 @@ parse: function parse(input) { + } continue; // accept: @@ -7703,7 +7833,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -7719,9 +7849,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7750,7 +7878,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7767,8 +7895,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -7779,8 +7907,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -7792,21 +7920,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7837,14 +7963,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7854,6 +7981,7 @@ parse: function parse(input) { + } continue; // accept: @@ -7906,8 +8034,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -8168,7 +8295,6 @@ var lexer = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -8185,10 +8311,10 @@ var lexer = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -8220,7 +8346,7 @@ var lexer = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -8262,7 +8388,9 @@ var lexer = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -8348,7 +8476,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -8356,7 +8484,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -8369,7 +8497,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -8395,10 +8523,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -8421,7 +8552,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -8444,16 +8574,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -8475,7 +8605,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -8483,8 +8612,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -8513,7 +8642,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -8538,7 +8667,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -8550,17 +8679,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -8654,7 +8783,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -8675,7 +8804,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -8686,7 +8814,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -8697,15 +8825,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -8739,8 +8867,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -8773,9 +8901,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -8794,9 +8922,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -8806,8 +8934,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -8834,20 +8962,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -8887,17 +9014,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8906,7 +9035,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -8921,8 +9050,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -8948,24 +9077,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8976,7 +9107,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -8998,8 +9129,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -9021,8 +9152,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -9166,21 +9296,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -9195,11 +9325,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -9218,13 +9348,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -9248,13 +9378,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -9269,8 +9399,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -9301,7 +9431,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -9333,9 +9463,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -9364,7 +9494,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -9382,7 +9512,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -9407,7 +9537,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -9417,8 +9546,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -9427,7 +9554,7 @@ EOF: 1, this.clear(); } - 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. @@ -9439,13 +9566,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -9455,68 +9582,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -9541,7 +9674,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -9589,24 +9722,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9626,7 +9759,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -9636,24 +9769,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9674,8 +9807,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -9715,14 +9847,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -9738,9 +9870,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -9751,8 +9883,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -9760,7 +9892,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -11450,7 +11582,7 @@ const UNICODE_BASE_PLANE_MAX_CP = 65535; // The expanded regex sets which are equivalent to the given `\\{c}` escapes: // // `/\s/`: -const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; +const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; // `/\d/`: const DIGIT_SETSTR = '0-9'; // `/\w/`: @@ -11462,7 +11594,7 @@ const WORDCHAR_SETSTR = 'A-Za-z0-9_'; // Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex function i2c(i) { - var c, x; + let c, x; switch (i) { case 10: @@ -11502,7 +11634,7 @@ function i2c(i) { || i > 0xFFF0 /* Unicode Specials, also in UTF16 */ || (i >= 0xD800 && i <= 0xDFFF) /* Unicode Supplementary Planes; we're TOAST in JavaScript as we're NOT UTF-16 but UCS-2! */ || String.fromCharCode(i).match(/[\u2028\u2029]/) /* Code compilation via `new Function()` does not like to see these, or rather: treats them as just another form of CRLF, which breaks your generated regex code! */ - ) { + ) { // Detail about a detail: // U+2028 and U+2029 are part of the `\s` regex escape code (`\s` and `[\s]` match either of these) and when placed in a JavaScript // source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report @@ -11510,11 +11642,10 @@ function i2c(i) { // Hence we MUST escape these buggers everywhere we go... x = i.toString(16); if (x.length >= 1 && i <= 0xFFFF) { - c = '0000' + x; - return '\\u' + c.substr(c.length - 4); - } else { - return '\\u{' + x + '}'; + c = '0000' + x; + return '\\u' + c.substr(c.length - 4); } + return '\\u{' + x + '}'; } return String.fromCharCode(i); } @@ -11523,18 +11654,18 @@ function i2c(i) { // Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating // this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a // `\\p{NAME}` shorthand to represent [part of] the bitarray: -var Pcodes_bitarray_cache = {}; -var Pcodes_bitarray_cache_test_order = []; +let Pcodes_bitarray_cache = {}; +let Pcodes_bitarray_cache_test_order = []; -// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by +// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. -var EscCode_bitarray_output_refs; +let EscCode_bitarray_output_refs; // now initialize the EscCodes_... table above: init_EscCode_lookup_table(); function init_EscCode_lookup_table() { - var s, bitarr, set2esc = {}, esc2bitarr = {}; + let s, bitarr, set2esc = {}, esc2bitarr = {}; // patch global lookup tables for the time being, while we calculate their *real* content in this function: EscCode_bitarray_output_refs = { @@ -11603,13 +11734,13 @@ function init_EscCode_lookup_table() { }; updatePcodesBitarrayCacheTestOrder(); -} +} function updatePcodesBitarrayCacheTestOrder(opts) { - var t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var l = {}; - var user_has_xregexp = opts && opts.options && opts.options.xregexp; - var i, j, k, ba; + let t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let l = {}; + let user_has_xregexp = opts && opts.options && opts.options.xregexp; + let i, j, k, ba; // mark every character with which regex pcodes they are part of: for (k in Pcodes_bitarray_cache) { @@ -11619,12 +11750,12 @@ function updatePcodesBitarrayCacheTestOrder(opts) { continue; } - var cnt = 0; + let cnt = 0; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { cnt++; if (!t[i]) { - t[i] = [k]; + t[i] = [ k ]; } else { t[i].push(k); } @@ -11634,27 +11765,27 @@ function updatePcodesBitarrayCacheTestOrder(opts) { } // now dig out the unique ones: only need one per pcode. - // + // // We ASSUME every \\p{NAME} 'pcode' has at least ONE character - // in it that is ONLY matched by that particular pcode. + // in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode - // won't be tested during optimization. - // + // won't be tested during optimization. + // // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to // look for markers which match multiple escapes/pcodes for those // ones where a unique item isn't available... - var lut = []; - var done = {}; - var keys = Object.keys(Pcodes_bitarray_cache); + let lut = []; + let done = {}; + let keys = Object.keys(Pcodes_bitarray_cache); for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { k = t[i][0]; if (t[i].length === 1 && !done[k]) { assert__default['default'](l[k] > 0); - lut.push([i, k]); + lut.push([ i, k ]); done[k] = true; } } @@ -11665,19 +11796,19 @@ function updatePcodesBitarrayCacheTestOrder(opts) { if (!user_has_xregexp && k.indexOf('\\p{') >= 0) { continue; } - + if (!done[k]) { assert__default['default'](l[k] > 0); // find a minimum span character to mark this one: - var w = Infinity; + let w = Infinity; var rv; ba = Pcodes_bitarray_cache[k]; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { - var tl = t[i].length; + let tl = t[i].length; if (tl > 1 && tl < w) { assert__default['default'](l[k] > 0); - rv = [i, k]; + rv = [ i, k ]; w = tl; } } @@ -11691,16 +11822,16 @@ function updatePcodesBitarrayCacheTestOrder(opts) { // order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. - // + // // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more - // optimal minification of the regex set expression. - // + // optimal minification of the regex set expression. + // // This is a guestimate/heuristic only! lut.sort(function (a, b) { - var k1 = a[1]; - var k2 = b[1]; - var ld = l[k2] - l[k1]; + let k1 = a[1]; + let k2 = b[1]; + let ld = l[k2] - l[k1]; if (ld) { return ld; } @@ -11718,19 +11849,19 @@ function updatePcodesBitarrayCacheTestOrder(opts) { // 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set. function set2bitarray(bitarr, s, opts) { - var orig = s; - var set_is_inverted = false; - var bitarr_orig; + let orig = s; + let set_is_inverted = false; + let bitarr_orig; function mark(d1, d2) { if (d2 == null) d2 = d1; - for (var i = d1; i <= d2; i++) { + for (let i = d1; i <= d2; i++) { bitarr[i] = true; } } function add2bitarray(dst, src) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (src[i]) { dst[i] = true; } @@ -11738,10 +11869,10 @@ function set2bitarray(bitarr, s, opts) { } function eval_escaped_code(s) { - var c; + let c; // decode escaped code? If none, just take the character as-is if (s.indexOf('\\') === 0) { - var l = s.substr(0, 2); + let l = s.substr(0, 2); switch (l) { case '\\c': c = s.charCodeAt(2) - 'A'.charCodeAt(0) + 1; @@ -11759,7 +11890,7 @@ function set2bitarray(bitarr, s, opts) { } c = parseInt(s, 16); if (c >= 0x10000) { - return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); + return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); } return String.fromCharCode(c); @@ -11803,7 +11934,7 @@ function set2bitarray(bitarr, s, opts) { } if (s && s.length) { - var c1, c2; + let c1, c2; // inverted set? if (s[0] === '^') { @@ -11834,13 +11965,13 @@ function set2bitarray(bitarr, s, opts) { c2 = c2[0]; s = s.substr(c2.length); // do we have this one cached already? - var pex = c1 + c2; - var ba4p = Pcodes_bitarray_cache[pex]; + let pex = c1 + c2; + let ba4p = Pcodes_bitarray_cache[pex]; if (!ba4p) { // expand escape: - var xr = new XRegExp__default['default']('[' + pex + ']'); // TODO: case-insensitive grammar??? + let xr = new XRegExp__default['default']('[' + pex + ']'); // TODO: case-insensitive grammar??? // rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`: - var xs = '' + xr; + let xs = '' + xr; // remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: xs = xs.substr(1, xs.length - 2); @@ -11875,7 +12006,7 @@ function set2bitarray(bitarr, s, opts) { break; } } - var v1 = eval_escaped_code(c1); + let v1 = eval_escaped_code(c1); // propagate deferred exceptions = error reports. if (v1 instanceof Error) { return v1; @@ -11893,7 +12024,7 @@ function set2bitarray(bitarr, s, opts) { } else { c2 = c2[0]; } - var v2 = eval_escaped_code(c2); + let v2 = eval_escaped_code(c2); // propagate deferred exceptions = error reports. if (v2 instanceof Error) { return v1; @@ -11916,12 +12047,12 @@ function set2bitarray(bitarr, s, opts) { } // When we have marked all slots, '^' NEGATES the set, hence we flip all slots. - // + // // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. if (set_is_inverted) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (!bitarr[i]) { bitarr_orig[i] = true; } @@ -11940,10 +12071,10 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // below can be simple and fast: l[UNICODE_BASE_PLANE_MAX_CP + 1] = 1; // now reconstruct the regex set: - var rv = []; - var i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; - var bitarr_is_cloned = false; - var l_orig = l; + let rv = []; + let i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; + let bitarr_is_cloned = false; + let l_orig = l; if (output_inverted_variant) { // generate the inverted set, hence all unmarked slots are part of the output range: @@ -11957,8 +12088,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. // BUT... since we output the INVERTED set, we output the match-all set instead: return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` // BUT... since we output the INVERTED set, we output the match-nothing set instead: @@ -11990,9 +12120,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12019,7 +12149,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } } - + i = 0; while (i <= UNICODE_BASE_PLANE_MAX_CP) { // find first character not in original set: @@ -12050,8 +12180,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. return '^\\S\\s'; } @@ -12081,9 +12210,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12135,11 +12264,11 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } assert__default['default'](rv.length); - var s = rv.join(''); + let s = rv.join(''); assert__default['default'](s); // Check if the set is better represented by one of the regex escapes: - var esc4s = EscCode_bitarray_output_refs.set2esc[s]; + let esc4s = EscCode_bitarray_output_refs.set2esc[s]; if (esc4s) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return '\\' + esc4s; @@ -12154,25 +12283,24 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there; // ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`. function reduceRegexToSetBitArray(s, name, opts) { - var orig = s; + let orig = s; // propagate deferred exceptions = error reports. if (s instanceof Error) { return s; } - var l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var internal_state = 0; - var derr; + let l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let internal_state = 0; + let derr; while (s.length) { - var c1 = s.match(CHR_RE); + let c1 = s.match(CHR_RE); if (!c1) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"'); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12180,15 +12308,14 @@ function reduceRegexToSetBitArray(s, name, opts) { // this is starting a set within the regex: scan until end of set! var set_content = []; while (s.length) { - var inner = s.match(SET_PART_RE); + let inner = s.match(SET_PART_RE); if (!inner) { inner = s.match(CHR_RE); if (!inner) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"'); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12202,9 +12329,8 @@ function reduceRegexToSetBitArray(s, name, opts) { if (!c2) { // cope with illegal escape sequences too! return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error('regex set expression is broken in regex: ' + orig); } @@ -12288,10 +12414,9 @@ function reduceRegexToSetBitArray(s, name, opts) { // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; assert__default['default'](s); assert__default['default'](!(s instanceof Error)); - re = new XRegExp__default['default']('[' + s + ']'); + let re = new XRegExp__default['default']('[' + s + ']'); re.test(s[0]); // One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` @@ -12316,25 +12441,24 @@ function reduceRegexToSetBitArray(s, name, opts) { -// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` +// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! function produceOptimizedRegex4Set(bitarr) { // First try to produce a minimum regex from the bitarray directly: - var s1 = bitarray2set(bitarr, false, true); + let s1 = bitarray2set(bitarr, false, true); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s1.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s1; - } else { - s1 = '[' + s1 + ']'; } + s1 = '[' + s1 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s2 = bitarray2set(bitarr, true, true); + let s2 = bitarray2set(bitarr, true, true); if (s2[0] === '^') { s2 = s2.substr(1); @@ -12349,23 +12473,22 @@ function produceOptimizedRegex4Set(bitarr) { // Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: - // + // // First try to produce a minimum regex from the bitarray directly: - var s3 = bitarray2set(bitarr, false, false); + let s3 = bitarray2set(bitarr, false, false); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s3.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s3; - } else { - s3 = '[' + s3 + ']'; } + s3 = '[' + s3 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s4 = bitarray2set(bitarr, true, false); + let s4 = bitarray2set(bitarr, true, false); if (s4[0] === '^') { s4 = s4.substr(1); @@ -12397,30 +12520,30 @@ function produceOptimizedRegex4Set(bitarr) { var setmgmt = { - XREGEXP_UNICODE_ESCAPE_RE, - CHR_RE, - SET_PART_RE, - NOTHING_SPECIAL_RE, - SET_IS_SINGLE_PCODE_RE, - - UNICODE_BASE_PLANE_MAX_CP, - - WHITESPACE_SETSTR, - DIGIT_SETSTR, - WORDCHAR_SETSTR, - - set2bitarray, - bitarray2set, - produceOptimizedRegex4Set, - reduceRegexToSetBitArray, + XREGEXP_UNICODE_ESCAPE_RE, + CHR_RE, + SET_PART_RE, + NOTHING_SPECIAL_RE, + SET_IS_SINGLE_PCODE_RE, + + UNICODE_BASE_PLANE_MAX_CP, + + WHITESPACE_SETSTR, + DIGIT_SETSTR, + WORDCHAR_SETSTR, + + set2bitarray, + bitarray2set, + produceOptimizedRegex4Set, + reduceRegexToSetBitArray }; // Basic Lexer implemented using JavaScript regular expressions -var rmCommonWS$2 = helpers.rmCommonWS; -var mkIdentifier$2 = helpers.mkIdentifier; -var code_exec$1 = helpers.exec; +const rmCommonWS$2 = helpers.rmCommonWS; +const mkIdentifier$2 = helpers.mkIdentifier; +const code_exec = helpers.exec; -var version = '0.6.2-220'; // require('./package.json').version; +const version = '0.6.2-220'; // require('./package.json').version; @@ -12481,7 +12604,7 @@ const defaultJisonLexOptions = { exportAST: false, prettyCfg: true, pre_lex: undefined, - post_lex: undefined, + post_lex: undefined }; @@ -12499,23 +12622,23 @@ const defaultJisonLexOptions = { // Return a fresh set of options. /** @public */ function mkStdOptions(/*...args*/) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - var args = [].concat.apply([], arguments); + let opts = {}; + let args = [].concat.apply([], arguments); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(defaultJisonLexOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; for (var p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { @@ -12553,7 +12676,7 @@ function mkStdOptions(/*...args*/) { function prepExportStructures(options) { // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -12574,8 +12697,8 @@ function prepExportStructures(options) { // Otherwise return the *parsed* lexer spec as it has // been processed through LexParser. function autodetectAndConvertToJSONformat(lexerSpec, options) { - var chk_l = null; - var ex1, err; + let chk_l = null; + let ex1, err; if (typeof lexerSpec === 'string') { if (options.json) { @@ -12627,9 +12750,9 @@ function autodetectAndConvertToJSONformat(lexerSpec, options) { /should be separated/, /an error in one or more of your lexer regex rules/, /an error in your lexer epilogue/, - /unsupported definition type/, + /unsupported definition type/ ]; - var cmnerr = commonErrors.filter(function check(re) { + let cmnerr = commonErrors.filter(function check(re) { return e.message.match(re); }); if (cmnerr.length > 0) { @@ -12658,14 +12781,14 @@ function autodetectAndConvertToJSONformat(lexerSpec, options) { // expand macros and convert matchers to RegExp's function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) { - var m, i, k, rule, action, conditions; - var active_conditions; + let m, i, k, rule, action, conditions; + let active_conditions; assert__default['default'](Array.isArray(dict.rules)); - var rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! - var newRules = []; - var macros = {}; - var regular_rule_count = 0; - var simple_rule_count = 0; + let rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! + let newRules = []; + let macros = {}; + let regular_rule_count = 0; + let simple_rule_count = 0; // Assure all options are camelCased: assert__default['default'](typeof opts.options['case-insensitive'] === 'undefined'); @@ -12675,7 +12798,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) } if (opts.options.flex && rules.length > 0) { - rules.push(['.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']); + rules.push([ '.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */' ]); } // Depending on the location within the regex we need different expansions of the macros: @@ -12699,7 +12822,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) return str; } - var routingCode = ['switch(yyrulenumber) {']; + let routingCode = [ 'switch(yyrulenumber) {' ]; for (i = 0; i < rules.length; i++) { rule = rules[i].slice(0); // shallow copy: do not modify input rules @@ -12753,7 +12876,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) action = action.replace(/return\s*\(?'((?:\\'|[^']+)+)'\)?/g, tokenNumberReplacement); action = action.replace(/return\s*\(?"((?:\\"|[^"]+)+)"\)?/g, tokenNumberReplacement); - var code = ['\n/*! Conditions::']; + let code = [ '\n/*! Conditions::' ]; code.push(postprocessComment(active_conditions)); code.push('*/', '\n/*! Rule:: '); code.push(postprocessComment(rule[0])); @@ -12774,7 +12897,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) // 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'. - var match_nr = /^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim()); + 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 ')); @@ -12801,7 +12924,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) macros: macros, regular_rule_count: regular_rule_count, - simple_rule_count: simple_rule_count, + simple_rule_count: simple_rule_count }; } @@ -12814,14 +12937,13 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) // 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. function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElsewhere_cb) { - var orig = s; + let orig = s; function errinfo() { if (name) { return 'macro [[' + name + ']]'; - } else { - return 'regex [[' + orig + ']]'; } + return 'regex [[' + orig + ']]'; } // propagate deferred exceptions = error reports. @@ -12829,19 +12951,18 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse return s; } - var c1, c2; - var rv = []; - var derr; - var se; + let c1, c2; + let rv = []; + let derr; + let se; while (s.length) { c1 = s.match(CHR_RE$1); if (!c1) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12851,15 +12972,14 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse var l = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1); while (s.length) { - var inner = s.match(SET_PART_RE$1); + let inner = s.match(SET_PART_RE$1); if (!inner) { inner = s.match(CHR_RE$1); if (!inner) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12873,9 +12993,8 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse if (!c2) { // cope with illegal escape sequences too! return new Error(errinfo() + ': regex set expression is broken: "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error(errinfo() + ': regex set expression is broken: apparently unterminated'); } @@ -12936,7 +13055,7 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse c2 = c2[0]; s = s.substr(c2.length); - var c3 = s[0]; + let c3 = s[0]; s = s.substr(c3.length); if (c3 === '}') { // possibly a macro name in there... Expand if possible: @@ -12989,7 +13108,7 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; + let re; re = new XRegExp__default['default'](s); re.test(s[0]); } catch (ex) { @@ -13005,11 +13124,11 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse // expand macros within macros and cache the result function prepareMacros(dict_macros, opts) { - var macros = {}; + let macros = {}; // expand a `{NAME}` macro which exists inside a `[...]` set: function expandMacroInSet(i) { - var k, a, m; + let k, a, m; if (!macros[i]) { m = dict_macros[i]; @@ -13043,7 +13162,7 @@ function prepareMacros(dict_macros, opts) { a = m.split('{' + k + '}'); if (a.length > 1) { - var x = expandMacroInSet(k); + let x = expandMacroInSet(k); assert__default['default'](x); if (x instanceof Error) { m = x; @@ -13055,9 +13174,9 @@ function prepareMacros(dict_macros, opts) { } } - var mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); + let mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); - var s1; + let s1; // propagate deferred exceptions = error reports. if (mba instanceof Error) { @@ -13091,7 +13210,7 @@ function prepareMacros(dict_macros, opts) { } function expandMacroElsewhere(i) { - var m; + let m; if (macros[i].elsewhere == null) { m = dict_macros[i]; @@ -13126,13 +13245,13 @@ function prepareMacros(dict_macros, opts) { } function expandAllMacrosInSet(s) { - var i, x; + let i, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { for (i in macros) { if (macros.hasOwnProperty(i)) { - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroInSet(i); assert__default['default'](x); @@ -13154,7 +13273,7 @@ function prepareMacros(dict_macros, opts) { } function expandAllMacrosElsewhere(s) { - var i, x; + let i, x; // When we process the remaining macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13169,7 +13288,7 @@ function prepareMacros(dict_macros, opts) { for (i in macros) { if (macros.hasOwnProperty(i)) { // These are all submacro expansions, hence non-capturing grouping is applied: - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroElsewhere(i); assert__default['default'](x); @@ -13191,7 +13310,7 @@ function prepareMacros(dict_macros, opts) { } - var i; + let i; if (opts.debug) console.log('\n############## RAW macros: ', dict_macros); @@ -13222,13 +13341,13 @@ function prepareMacros(dict_macros, opts) { // expand macros in a regex; expands them recursively function expandMacros(src, macros, opts) { - var expansion_count = 0; + let expansion_count = 0; // By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! // Hence things should be easy in there: function expandAllMacrosInSet(s) { - var i, m, x; + let i, m, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { @@ -13236,7 +13355,7 @@ function expandMacros(src, macros, opts) { if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = m.in_set; @@ -13267,7 +13386,7 @@ function expandMacros(src, macros, opts) { } function expandAllMacrosElsewhere(s) { - var i, m, x; + let i, m, x; // When we process the main macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13283,7 +13402,7 @@ function expandMacros(src, macros, opts) { if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { // These are all main macro expansions, hence CAPTURING grouping is applied: x = m.elsewhere; @@ -13319,7 +13438,7 @@ function expandMacros(src, macros, opts) { // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! - var s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); + let s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); // propagate deferred exceptions = error reports. if (s2 instanceof Error) { throw s2; @@ -13344,8 +13463,8 @@ function expandMacros(src, macros, opts) { } function prepareStartConditions(conditions) { - var sc; - var hash = {}; + let sc; + let hash = {}; for (sc in conditions) { if (conditions.hasOwnProperty(sc)) { @@ -13359,22 +13478,22 @@ function prepareStartConditions(conditions) { } function buildActions(dict, tokens, opts) { - var actions = [dict.actionInclude || '', 'var YYSTATE = YY_START;']; - var tok; - var toks = {}; - var caseHelper = []; + let actions = [ dict.actionInclude || '', 'var YYSTATE = YY_START;' ]; + let tok; + let toks = {}; + let caseHelper = []; // tokens: map/array of token numbers to token names for (tok in tokens) { - var idx = parseInt(tok); + let idx = parseInt(tok); if (idx && idx > 0) { toks[tokens[tok]] = idx; } } - var gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); + let gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); - var code = actions.join('\n'); + let code = actions.join('\n'); 'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function (yy) { code = code.replace(new RegExp('\\b(' + yy + ')\\b', 'g'), 'yy_.$1'); }); @@ -13392,7 +13511,7 @@ function buildActions(dict, tokens, opts) { macros: gen.macros, // propagate these for debugging/diagnostic purposes regular_rule_count: gen.regular_rule_count, - simple_rule_count: gen.simple_rule_count, + simple_rule_count: gen.simple_rule_count }; } @@ -13403,7 +13522,7 @@ function buildActions(dict, tokens, opts) { function generateErrorClass() { // --- START lexer error class --- -var prelude = `/** +const prelude = `/** * 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 @@ -13414,8 +13533,6 @@ var prelude = `/** * @nocollapse */ function JisonLexerError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -13432,9 +13549,9 @@ function JisonLexerError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -13495,8 +13612,8 @@ function generateFakeXRegExpClassSrcCode() { /** @constructor */ function RegExpLexer(dict, input, tokens, build_options) { - var opts; - var dump = false; + let opts; + let dump = false; function test_me(tweak_cb, description, src_exception, ex_callback) { opts = processGrammar(dict, tokens, build_options); @@ -13506,7 +13623,7 @@ function RegExpLexer(dict, input, tokens, build_options) { if (tweak_cb) { tweak_cb(); } - var source = generateModuleBody(opts); + let source = generateModuleBody(opts); try { // The generated code will always have the `lexer` variable declared at local scope // as `eval()` will use the local scope. @@ -13514,16 +13631,16 @@ function RegExpLexer(dict, input, tokens, build_options) { // The compiled code will look something like this: // // ``` - // var lexer; + // let lexer; // bla bla... // ``` // // or // // ``` - // var lexer = { bla... }; + // const lexer = { bla... }; // ``` - var testcode = [ + let testcode = [ '// provide a local version for test purposes:', jisonLexerErrorDefinition, '', @@ -13531,14 +13648,33 @@ function RegExpLexer(dict, input, tokens, build_options) { '', source, '', + rmCommonWS$2` + // JISON INJECTED VALIDATION CODE + // which attempts to ascertain you have defined a minimal viable lexer at least: + if (typeof lexer === "undefined") { + throw new SyntaxError("user-defined lexer does not define the required 'lexer' instance."); + } + if (!lexer) { + throw new SyntaxError("user-defined lexer does not define a non-NULL 'lexer' instance."); + } + if (typeof lexer.setInput !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.setInput()' API function."); + } + if (typeof lexer.lex !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.lex()' API function."); + } + // END OF JISON INJECTED VALIDATION CODE + `, 'return lexer;' ].join('\n'); - var lexer = code_exec$1(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { + let lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { //console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$2(sourcecode); - var lexer_f = new Function('', sourcecode); + let lexer_f = new Function('', sourcecode); return lexer_f(); - }, opts.options, "lexer"); + }, Object.assign({}, opts.options, { + throwErrorOnCompileFailure: true + }), 'lexer'); if (!lexer) { throw new Error('no lexer defined *at all*?!'); @@ -13555,7 +13691,7 @@ function RegExpLexer(dict, input, tokens, build_options) { // When we do NOT crash, we found/killed the problem area just before this call! if (src_exception && description) { - var msg = description; + let msg = description; if (typeof description === 'function') { msg = description(); } @@ -13564,8 +13700,8 @@ function RegExpLexer(dict, input, tokens, build_options) { // patch the pre and post handlers in there, now that we have some live code to work with: if (opts.options) { - var pre = opts.options.pre_lex; - var post = opts.options.post_lex; + let pre = opts.options.pre_lex; + let post = opts.options.post_lex; // since JSON cannot encode functions, we'll have to do it manually now: if (typeof pre === 'function') { lexer.options.pre_lex = pre; @@ -13579,7 +13715,7 @@ function RegExpLexer(dict, input, tokens, build_options) { if (typeof opts.options.showSource === 'function') { opts.options.showSource(lexer, source, opts, RegExpLexer); } else { - console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n"); + console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n', source, '\n----------------------------------------\n'); } } return lexer; @@ -13598,13 +13734,13 @@ function RegExpLexer(dict, input, tokens, build_options) { } /** @constructor */ - var lexer = test_me(null, null, null, function (ex) { + let lexer = test_me(null, null, null, function (ex) { // When we get an exception here, it means some part of the user-specified lexer is botched. // // Now we go and try to narrow down the problem area/category: assert__default['default'](opts.options); assert__default['default'](opts.options.xregexp !== undefined); - var orig_xregexp_opt = !!opts.options.xregexp; + let orig_xregexp_opt = !!opts.options.xregexp; if (!test_me(function () { assert__default['default'](opts.options.xregexp !== undefined); opts.options.xregexp = false; @@ -13623,7 +13759,7 @@ function RegExpLexer(dict, input, tokens, build_options) { 'Your custom lexer is somehow botched.' ); }, ex, null)) { - var rulesSpecSize; + let rulesSpecSize; if (!test_me(function () { // store the parsed rule set size so we can use that info in case // this attempt also fails: @@ -13636,7 +13772,7 @@ function RegExpLexer(dict, input, tokens, build_options) { opts.__in_rules_failure_analysis_mode__ = true; }, 'One or more of your lexer rules are possibly botched?', ex, null)) { // kill each rule action block, one at a time and test again after each 'edit': - var rv = false; + let rv = false; for (var i = 0, len = rulesSpecSize; i < len; i++) { var lastEditedRuleSpec; rv = test_me(function () { @@ -13648,10 +13784,10 @@ function RegExpLexer(dict, input, tokens, build_options) { // opts.__in_rules_failure_analysis_mode__ = true; // nuke all rules' actions up to and including rule numero `i`: - for (var j = 0; j <= i; j++) { + for (let j = 0; j <= i; j++) { // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; // now we want to edit the *action* part: - var rule = opts.rules[j]; + let rule = opts.rules[j]; assert__default['default'](Array.isArray(rule)); assert__default['default'](rule.length === 2 || rule.length === 3); rule.pop(); @@ -13785,8 +13921,6 @@ return `{ * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -13796,14 +13930,14 @@ return `{ } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\\n\\s*$/.test(msg)) { msg += '\\n'; } msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') { msg += '\\n' + pos_str; @@ -13814,14 +13948,14 @@ return `{ } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the \`upcomingInput\` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -13841,9 +13975,8 @@ return `{ // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -13863,8 +13996,6 @@ return `{ * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -13885,16 +14016,14 @@ return `{ * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -13915,8 +14044,6 @@ return `{ * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -13924,8 +14051,8 @@ return `{ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -13943,8 +14070,6 @@ return `{ * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -13954,14 +14079,14 @@ return `{ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -13972,8 +14097,6 @@ return `{ * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -13981,40 +14104,40 @@ return `{ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -14026,7 +14149,7 @@ return `{ this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -14034,7 +14157,7 @@ return `{ last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -14095,9 +14218,7 @@ return `{ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -14116,8 +14237,6 @@ return `{ * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set \`done\` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -14126,7 +14245,7 @@ return `{ this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -14136,13 +14255,13 @@ return `{ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\\n') { lines = true; } else if (ch === '\\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\\n') { slice_len++; ch += ch2; @@ -14174,10 +14293,8 @@ return `{ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -14209,8 +14326,8 @@ return `{ // Get last entirely matched line into the \`pre_lines[]\` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -14228,9 +14345,9 @@ return `{ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -14240,14 +14357,12 @@ return `{ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -14258,8 +14373,6 @@ return `{ * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -14272,19 +14385,17 @@ return `{ * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the \`parseError()\` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // \`.lex()\` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -14297,8 +14408,6 @@ return `{ * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -14321,24 +14430,24 @@ return `{ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substr\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14350,8 +14459,8 @@ return `{ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to \`maxSize\` (default: 20). @@ -14377,24 +14486,25 @@ return `{ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > \`lookAhead()\` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substring\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -14403,7 +14513,7 @@ return `{ } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14422,10 +14532,8 @@ return `{ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^'; }, @@ -14447,15 +14555,13 @@ return `{ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -14586,58 +14692,54 @@ return `{ * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\\t/g, ' '); @@ -14646,13 +14748,13 @@ return `{ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -14674,15 +14776,13 @@ return `{ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -14694,8 +14794,8 @@ return `{ rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -14724,13 +14824,7 @@ return `{ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -14759,10 +14853,10 @@ return `{ }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -14790,7 +14884,7 @@ return `{ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -14801,7 +14895,7 @@ return `{ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -14823,8 +14917,6 @@ return `{ * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -14833,17 +14925,13 @@ return `{ this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -14853,67 +14941,75 @@ return `{ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that \`parseError()\` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) \`parseError()\` @@ -14940,9 +15036,7 @@ return `{ * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -14985,24 +15079,24 @@ return `{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15022,9 +15116,7 @@ return `{ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15034,24 +15126,24 @@ return `{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15059,7 +15151,7 @@ return `{ this._clear_state = 0; } - + return r; }, @@ -15072,9 +15164,7 @@ return `{ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -15082,7 +15172,7 @@ return `{ (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -15097,8 +15187,6 @@ return `{ * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -15110,8 +15198,6 @@ return `{ * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -15125,15 +15211,12 @@ return `{ * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -15145,14 +15228,11 @@ return `{ * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -15163,16 +15243,14 @@ return `{ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -15182,8 +15260,6 @@ return `{ * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; } }`; @@ -15215,18 +15291,17 @@ function stripUnusedLexerCode(src, opt) { // ............................. ${opt.lexerActionsUseDisplayAPIs} // uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC} - var new_src; + let new_src; try { - var ast = helpers.parseCodeChunkToAST(src, opt); + let ast = helpers.parseCodeChunkToAST(src, opt); new_src = helpers.prettyPrintAST(ast, opt); - } - catch (ex) { + } catch (ex) { let line = ex.lineNumber || 0; let a = src.split(/\r?\n/g); let len = a.length; let minl = Math.max(0, line - 10); let b = a.slice(minl, line + 10); - let c = b.splice(line - minl, 0, "", "^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", ""); + let c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); let offendingChunk = ' ' + b.join('\n '); console.error(rmCommonWS$2` stripUnusedLexerCode WARNING: @@ -15242,17 +15317,11 @@ function stripUnusedLexerCode(src, opt) { ${offendingChunk} `); - + new_src = src; } - - - - - - // inject analysis report now: new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2` // Code Generator Information Report @@ -15307,7 +15376,7 @@ function stripUnusedLexerCode(src, opt) { // generate lexer source from a grammar /** @public */ function generate(dict, tokens, build_options) { - var opt = processGrammar(dict, tokens, build_options); + let opt = processGrammar(dict, tokens, build_options); return generateFromOpts(opt); } @@ -15316,7 +15385,7 @@ function generate(dict, tokens, build_options) { /** @public */ function processGrammar(dict, tokens, build_options) { build_options = build_options || {}; - var opts = { + let opts = { // include the knowledge passed through `build_options` about which lexer // features will actually be *used* by the environment (which in 99.9% // of cases is a jison *parser*): @@ -15356,7 +15425,7 @@ function processGrammar(dict, tokens, build_options) { lexerActionsUseReject: '???', lexerActionsUseLess: '???', lexerActionsUseDisplayAPIs: '???', - lexerActionsUseDescribeYYLOC: '???', + lexerActionsUseDescribeYYLOC: '???' }; dict = autodetectAndConvertToJSONformat(dict, build_options) || {}; @@ -15381,7 +15450,7 @@ function processGrammar(dict, tokens, build_options) { // only produce rule action code blocks when there are any rules at all; // a "custom lexer" has ZERO rules and must be defined entirely in // other code blocks: - var code = (dict.rules ? buildActions(dict, tokens, opts) : {}); + let code = (dict.rules ? buildActions(dict, tokens, opts) : {}); opts.performAction = code.actions; opts.caseHelperInclude = code.caseHelperInclude; opts.rules = code.rules || []; @@ -15390,7 +15459,7 @@ function processGrammar(dict, tokens, build_options) { opts.regular_rule_count = code.regular_rule_count; opts.simple_rule_count = code.simple_rule_count; - opts.conditionStack = ['INITIAL']; + opts.conditionStack = [ 'INITIAL' ]; opts.actionInclude = (dict.actionInclude || ''); opts.moduleInclude = (opts.moduleInclude || '') + (dict.moduleInclude || '').trim(); @@ -15401,7 +15470,7 @@ function processGrammar(dict, tokens, build_options) { // Assemble the final source from the processed grammar /** @public */ function generateFromOpts(opt) { - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -15424,12 +15493,12 @@ function generateFromOpts(opt) { } function generateRegexesInitTableCode(opt) { - var a = opt.rules; - var print_xregexp = opt.options && opt.options.xregexp; - var id_display_width = (1 + Math.log10(a.length | 1) | 0); - var ws_prefix = new Array(id_display_width).join(' '); - var b = a.map(function generateXRegExpInitCode(re, idx) { - var idx_str = (ws_prefix + idx).substr(-id_display_width); + let a = opt.rules; + let print_xregexp = opt.options && opt.options.xregexp; + let id_display_width = (1 + Math.log10(a.length | 1) | 0); + let ws_prefix = new Array(id_display_width).join(' '); + let b = a.map(function generateXRegExpInitCode(re, idx) { + let idx_str = (ws_prefix + idx).substr(-id_display_width); if (re instanceof XRegExp__default['default']) { // When we don't need the special XRegExp sauce at run-time, we do with the original @@ -15439,11 +15508,11 @@ function generateRegexesInitTableCode(opt) { } // And make sure to escape the regex to make it suitable for placement inside a *string* // as it is passed as a string argument to the XRegExp constructor here. - var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); + let re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); return `/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`; - } else { - return `/* ${idx_str}: */ ${re}`; } + return `/* ${idx_str}: */ ${re}`; + }); return b.join(',\n'); } @@ -15451,77 +15520,77 @@ function generateRegexesInitTableCode(opt) { function generateModuleBody(opt) { // make the JSON output look more like JavaScript: function cleanupJSON(str) { - str = str.replace(/ "rules": \[/g, ' rules: ['); - str = str.replace(/ "inclusive": /g, ' inclusive: '); + str = str.replace(/ {2}"rules": \[/g, ' rules: ['); + str = str.replace(/ {2}"inclusive": /g, ' inclusive: '); return str; } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - json: 1, - _: 1, - noMain: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - lexerErrorsAreRecoverable: 0, - flex: 0, - backtrack_lexer: 0, - caseInsensitive: 0, - showSource: 1, - exportAST: 1, - exportAllTables: 1, - exportSourceCode: 1, - prettyCfg: 1, - parseActionsUseYYLENG: 1, - parseActionsUseYYLINENO: 1, - parseActionsUseYYTEXT: 1, - parseActionsUseYYLOC: 1, - parseActionsUseParseError: 1, - parseActionsUseYYERROR: 1, - parseActionsUseYYRECOVERING: 1, - parseActionsUseYYERROK: 1, - parseActionsUseYYCLEARIN: 1, - parseActionsUseValueTracking: 1, - parseActionsUseValueAssignment: 1, - parseActionsUseLocationTracking: 1, - parseActionsUseLocationAssignment: 1, - parseActionsUseYYSTACK: 1, - parseActionsUseYYSSTACK: 1, - parseActionsUseYYSTACKPOINTER: 1, - parseActionsUseYYRULELENGTH: 1, - parseActionsUseYYMERGELOCATIONINFO: 1, - parserHasErrorRecovery: 1, - parserHasErrorReporting: 1, - lexerActionsUseYYLENG: 1, - lexerActionsUseYYLINENO: 1, - lexerActionsUseYYTEXT: 1, - lexerActionsUseYYLOC: 1, - lexerActionsUseParseError: 1, - lexerActionsUseYYERROR: 1, - lexerActionsUseLocationTracking: 1, - lexerActionsUseMore: 1, - lexerActionsUseUnput: 1, - lexerActionsUseReject: 1, - lexerActionsUseLess: 1, - lexerActionsUseDisplayAPIs: 1, - lexerActionsUseDescribeYYLOC: 1, + let obj = {}; + const do_not_pass = { + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + json: 1, + _: 1, + noMain: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + lexerErrorsAreRecoverable: 0, + flex: 0, + backtrack_lexer: 0, + caseInsensitive: 0, + showSource: 1, + exportAST: 1, + exportAllTables: 1, + exportSourceCode: 1, + prettyCfg: 1, + parseActionsUseYYLENG: 1, + parseActionsUseYYLINENO: 1, + parseActionsUseYYTEXT: 1, + parseActionsUseYYLOC: 1, + parseActionsUseParseError: 1, + parseActionsUseYYERROR: 1, + parseActionsUseYYRECOVERING: 1, + parseActionsUseYYERROK: 1, + parseActionsUseYYCLEARIN: 1, + parseActionsUseValueTracking: 1, + parseActionsUseValueAssignment: 1, + parseActionsUseLocationTracking: 1, + parseActionsUseLocationAssignment: 1, + parseActionsUseYYSTACK: 1, + parseActionsUseYYSSTACK: 1, + parseActionsUseYYSTACKPOINTER: 1, + parseActionsUseYYRULELENGTH: 1, + parseActionsUseYYMERGELOCATIONINFO: 1, + parserHasErrorRecovery: 1, + parserHasErrorReporting: 1, + lexerActionsUseYYLENG: 1, + lexerActionsUseYYLINENO: 1, + lexerActionsUseYYTEXT: 1, + lexerActionsUseYYLOC: 1, + lexerActionsUseParseError: 1, + lexerActionsUseYYERROR: 1, + lexerActionsUseLocationTracking: 1, + lexerActionsUseMore: 1, + lexerActionsUseUnput: 1, + lexerActionsUseReject: 1, + lexerActionsUseLess: 1, + lexerActionsUseDisplayAPIs: 1, + lexerActionsUseDescribeYYLOC: 1 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -15532,8 +15601,8 @@ function generateModuleBody(opt) { } // And now some options which should receive some special processing: - var pre = obj.pre_lex; - var post = obj.post_lex; + let pre = obj.pre_lex; + let post = obj.post_lex; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_lex = true; @@ -15542,7 +15611,7 @@ function generateModuleBody(opt) { obj.post_lex = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$1})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_lex: true(,)?$/gm, function (m, ls, tc) { @@ -15555,17 +15624,17 @@ function generateModuleBody(opt) { } - var out; + let out; if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) { // we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. - var code = [rmCommonWS$2` - var lexer = { - `, '/*JISON-LEX-ANALYTICS-REPORT*/' /* slot #1: placeholder for analysis report further below */ + let code = [ rmCommonWS$2` + const lexer = { + `, '/* JISON-LEX-ANALYTICS-REPORT */\n' /* slot #1: placeholder for analysis report further below */ ]; // get the RegExpLexer.prototype in source code form: - var protosrc = getRegExpLexerPrototype(); + let protosrc = getRegExpLexerPrototype(); // and strip off the surrounding bits we don't want: protosrc = protosrc .replace(/^[\s\r\n]*\{/, '') @@ -15592,10 +15661,10 @@ function generateModuleBody(opt) { } */ - var performActionCode = String(opt.performAction); - var simpleCaseActionClustersCode = String(opt.caseHelperInclude); - var rulesCode = generateRegexesInitTableCode(opt); - var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); + let performActionCode = String(opt.performAction); + let simpleCaseActionClustersCode = String(opt.caseHelperInclude); + let rulesCode = generateRegexesInitTableCode(opt); + let conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); code.push(rmCommonWS$2`, JisonLexerError: JisonLexerError, performAction: ${performActionCode}, @@ -15615,9 +15684,9 @@ function generateModuleBody(opt) { // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // - // Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter + // Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. - out = 'var lexer;\n'; + out = '\n'; assert__default['default'](opt.regular_rule_count === 0); assert__default['default'](opt.simple_rule_count === 0); @@ -15631,8 +15700,6 @@ function generateModuleBody(opt) { // The output of this function is guaranteed to read something like this: // // ``` - // var lexer; - // // bla bla bla bla ... lotsa bla bla; // ``` // @@ -15641,7 +15708,7 @@ function generateModuleBody(opt) { } function generateGenericHeaderComment() { - var out = rmCommonWS$2` + let out = rmCommonWS$2` /* lexer generated by jison-lex ${version} */ /* @@ -15870,7 +15937,7 @@ function prepareOptions(opt) { // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else { @@ -15888,9 +15955,9 @@ function prepareOptions(opt) { function generateModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -15913,9 +15980,9 @@ function generateModule(opt) { function generateAMDModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} define([], function () { @@ -15938,12 +16005,12 @@ function generateAMDModule(opt) { function generateESModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} - var lexer = (function () { + const lexer = (function () { "use strict"; ${jisonLexerErrorDefinition} @@ -15972,9 +16039,9 @@ function generateESModule(opt) { function generateCommonJSModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { diff --git a/packages/jison-lex/dist/regexp-lexer-es6.js b/packages/jison-lex/dist/regexp-lexer-es6.js index 1200b109a..b7a7507ae 100644 --- a/packages/jison-lex/dist/regexp-lexer-es6.js +++ b/packages/jison-lex/dist/regexp-lexer-es6.js @@ -2,11 +2,12 @@ import XRegExp from '@gerhobbelt/xregexp'; import JSON5 from '@gerhobbelt/json5'; import fs from 'fs'; import path$1 from 'path'; +import mkdirp from 'mkdirp'; import recast from 'recast'; import { transformSync } from '@babel/core'; import assert$1 from 'assert'; -// Return TRUE if `src` starts with `searchString`. +// Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -29,19 +30,19 @@ function rmCommonWS(strings, ...values) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -60,19 +61,21 @@ function rmCommonWS(strings, ...values) { // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -81,16 +84,19 @@ function rmCommonWS(strings, ...values) { } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -101,27 +107,79 @@ function camelCase(s) { return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } +// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; +})([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' +]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -139,6 +197,11 @@ function mkIdentifier(s) { .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -147,13 +210,13 @@ function mkIdentifier(s) { function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -164,23 +227,17 @@ function scanRegExp(s) { break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -203,34 +260,33 @@ function isLineTerminator(cp) { /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -253,28 +309,76 @@ function chkBugger(src) { // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } +function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; +} + + +function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); +} + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path$1.dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path$1.basename(options.inputFilename || options.moduleName || (options.outfile ? path$1.dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path$1.dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path$1.basename(options.inputFilename || options.moduleName || (options.outfile ? path$1.dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -285,27 +389,37 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path$1.normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path$1.normalize(path$1.join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5.stringify(dump, null, 2); + let d = JSON5.stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp(path$1.dirname(dumpfile)); fs.writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -315,7 +429,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -323,7 +437,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -349,27 +463,43 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -382,9 +512,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -406,22 +537,22 @@ assert$1(recast); // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; -// Determine which Unicode NonAsciiIdentifierStart characters +// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -429,40 +560,40 @@ const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -470,30 +601,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -504,59 +635,59 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -598,38 +729,38 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -641,18 +772,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -663,56 +794,56 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -720,97 +851,97 @@ function generateMapper4JisonGrammarIdentifiers(input) { typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp(`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp(`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp(`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp(`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp(`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp(`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp(`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp(`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp(`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp(`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp(`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -818,7 +949,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -831,7 +962,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -844,7 +975,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -857,7 +988,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -876,37 +1007,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -938,7 +1069,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -955,37 +1086,37 @@ function parseCodeChunkToAST(src, options) { .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast.parse(src); + const ast = recast.parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return transformSync(src, options); // => { code, map, ast } @@ -993,8 +1124,8 @@ function compileCodeToES5(src, options) { function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1003,7 +1134,7 @@ function prettyPrintAST(ast, options) { // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1026,25 +1157,25 @@ function prettyPrintAST(ast, options) { // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1055,9 +1186,9 @@ function checkActionBlock(src, yylloc, options) { // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1065,7 +1196,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1074,14 +1205,14 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1135,7 +1266,7 @@ var parse2AST = { trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1149,7 +1280,7 @@ function chkBugger$1(src) { /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1161,24 +1292,24 @@ const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?: /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1195,8 +1326,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1207,14 +1338,14 @@ function printFunctionSourceCodeContainer(f) { action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1225,17 +1356,17 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; -// -// -// +// +// +// function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1261,7 +1392,7 @@ function detectIstanbulGlobal() { // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1309,7 +1440,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1372,13 +1503,13 @@ var reHelpers = { getRegExpInfo: getRegExpInfo }; -var cycleref = []; -var cyclerefpath = []; +let cycleref = []; +let cyclerefpath = []; -var linkref = []; -var linkrefpath = []; +let linkref = []; +let linkrefpath = []; -var path = []; +let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1386,14 +1517,14 @@ function shallow_copy(src) { return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1406,11 +1537,11 @@ function shallow_copy(src) { function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1423,9 +1554,9 @@ function shallow_copy_and_strip_depth(src, parentKey) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1440,16 +1571,52 @@ function shallow_copy_and_strip_depth(src, parentKey) { } +// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } +// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; +} + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1464,7 +1631,7 @@ function trim_array_tail(arr) { function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1490,10 +1657,10 @@ function treat_value_stack(v) { } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1591,7 +1758,7 @@ function treat_hash(h) { function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1608,7 +1775,7 @@ function treat_error_report_info(e) { path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1636,7 +1803,7 @@ function treat_error_report_info(e) { function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1652,7 +1819,7 @@ function treat_object(e) { linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1664,14 +1831,14 @@ function treat_object(e) { // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1681,7 +1848,7 @@ function trimErrorForTestReporting(e) { cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1695,12 +1862,14 @@ var helpers = { dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1715,7 +1884,7 @@ var helpers = { printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; // See also: @@ -1723,7 +1892,6 @@ var helpers = { // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1740,9 +1908,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -1775,10 +1943,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -1791,11 +1959,11 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -1805,18 +1973,18 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -1847,7 +2015,7 @@ JisonParserError.prototype.name = 'JisonParserError'; // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -1864,9 +2032,9 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -1879,7 +2047,7 @@ JisonParserError.prototype.name = 'JisonParserError'; } -var parser = { +let parser = { // Code Generator Information Report // --------------------------------- // @@ -2129,7 +2297,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2137,7 +2304,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2149,8 +2315,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2163,14 +2329,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2186,10 +2351,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2197,10 +2362,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2355,9 +2520,9 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -2369,18 +2534,18 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2410,9 +2575,9 @@ case 1: case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -2425,10 +2590,10 @@ case 2: case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2455,9 +2620,9 @@ case 3: case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -2466,10 +2631,10 @@ case 4: case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2497,9 +2662,9 @@ case 5: case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -2508,10 +2673,10 @@ case 6: case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -2550,9 +2715,9 @@ case 7: case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2617,9 +2782,9 @@ case 8: case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2634,9 +2799,9 @@ case 9: case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -2671,10 +2836,10 @@ case 10: case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2691,9 +2856,9 @@ case 11: case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2710,10 +2875,10 @@ case 12: case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2730,9 +2895,9 @@ case 13: case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2749,10 +2914,10 @@ case 14: case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2769,9 +2934,9 @@ case 15: case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -2795,9 +2960,9 @@ case 17: case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -2808,9 +2973,9 @@ case 132: case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2830,9 +2995,9 @@ case 18: case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2856,9 +3021,9 @@ case 19: case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2871,10 +3036,10 @@ case 20: case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2891,9 +3056,9 @@ case 21: case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2905,9 +3070,9 @@ case 22: case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -2947,10 +3112,10 @@ case 23: case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2970,9 +3135,9 @@ case 24: case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3022,10 +3187,10 @@ case 25: case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -3049,10 +3214,10 @@ case 26: case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3072,10 +3237,10 @@ case 27: case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3099,10 +3264,10 @@ case 28: case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3123,10 +3288,10 @@ case 29: case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3138,10 +3303,10 @@ case 31: case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3151,10 +3316,10 @@ case 33: case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3164,10 +3329,10 @@ case 32: case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3177,10 +3342,10 @@ case 34: case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3190,10 +3355,10 @@ case 35: case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -3203,10 +3368,10 @@ case 36: case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3216,10 +3381,10 @@ case 37: case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3229,9 +3394,9 @@ case 38: case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -3240,9 +3405,9 @@ case 39: case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -3251,9 +3416,9 @@ case 40: case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3275,9 +3440,9 @@ case 41: case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3288,9 +3453,9 @@ case 42: case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3310,9 +3475,9 @@ case 43: case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3366,9 +3531,9 @@ case 49: case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3388,9 +3553,9 @@ case 51: case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -3399,9 +3564,9 @@ case 58: case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -3413,9 +3578,9 @@ case 52: case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -3429,10 +3594,10 @@ case 53: case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3452,10 +3617,10 @@ case 54: case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3475,10 +3640,10 @@ case 55: case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3498,9 +3663,9 @@ case 56: case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3511,9 +3676,9 @@ case 59: case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3532,9 +3697,9 @@ case 60: case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -3575,9 +3740,9 @@ case 61: case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3601,9 +3766,9 @@ case 62: case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3629,9 +3794,9 @@ case 63: case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3676,9 +3841,9 @@ case 64: case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -3704,9 +3869,9 @@ case 106: case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -3715,9 +3880,9 @@ case 127: case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -3726,10 +3891,10 @@ case 67: case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3743,10 +3908,10 @@ case 68: case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3760,10 +3925,10 @@ case 69: case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3777,10 +3942,10 @@ case 70: case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3799,9 +3964,9 @@ case 72: case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -3810,9 +3975,9 @@ case 77: case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -3850,10 +4015,10 @@ case 73: case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -3877,9 +4042,9 @@ case 74: case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -3958,9 +4123,9 @@ case 110: case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -3969,9 +4134,9 @@ case 129: case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -3980,9 +4145,9 @@ case 78: case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -3991,9 +4156,9 @@ case 79: case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -4002,9 +4167,9 @@ case 80: case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -4013,9 +4178,9 @@ case 81: case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -4024,9 +4189,9 @@ case 85: case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -4037,10 +4202,10 @@ case 87: case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4057,9 +4222,9 @@ case 88: case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -4068,9 +4233,9 @@ case 89: case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -4079,9 +4244,9 @@ case 90: case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -4090,9 +4255,9 @@ case 91: case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -4101,9 +4266,9 @@ case 92: case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -4122,18 +4287,18 @@ case 107: case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -4142,9 +4307,9 @@ case 97: case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -4153,9 +4318,9 @@ case 98: case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -4164,9 +4329,9 @@ case 99: case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -4175,9 +4340,9 @@ case 102: case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -4186,10 +4351,10 @@ case 104: case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4206,9 +4371,9 @@ case 105: case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -4225,9 +4390,9 @@ case 109: case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -4239,9 +4404,9 @@ case 111: case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -4251,9 +4416,9 @@ case 112: case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4288,9 +4453,9 @@ case 113: case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4309,9 +4474,9 @@ case 114: case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -4320,9 +4485,9 @@ case 115: case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -4331,9 +4496,9 @@ case 116: case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4351,10 +4516,10 @@ case 117: case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -4372,10 +4537,10 @@ case 118: case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -4396,9 +4561,9 @@ case 119: case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4431,9 +4596,9 @@ case 120: case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4459,9 +4624,9 @@ case 121: case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5.parse(yyvstack[yysp]); @@ -4470,9 +4635,9 @@ case 122: case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue(yyvstack[yysp]); @@ -4481,9 +4646,9 @@ case 123: case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4492,9 +4657,9 @@ case 124: case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -4515,10 +4680,10 @@ case 125: case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4535,9 +4700,9 @@ case 126: case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -4556,9 +4721,9 @@ case 128: case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4582,9 +4747,9 @@ case 130: case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -4604,9 +4769,9 @@ case 131: case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4617,9 +4782,9 @@ case 133: case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -4675,10 +4840,10 @@ case 134: case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6281,7 +6446,6 @@ defaultActions: bda({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -6298,38 +6462,34 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -6337,20 +6497,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -6372,7 +6530,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -6380,18 +6537,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -6399,24 +6557,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -6454,18 +6607,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -6486,7 +6636,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -6504,7 +6654,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -6517,7 +6666,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -6531,11 +6679,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -6589,8 +6736,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6598,8 +6745,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6631,19 +6778,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -6654,7 +6800,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -6667,7 +6813,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -6679,29 +6825,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -6709,7 +6853,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -6729,8 +6873,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -6739,10 +6882,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -6750,7 +6893,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -6761,9 +6904,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -6779,8 +6927,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -6849,11 +6996,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -6864,8 +7014,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -6874,21 +7023,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6898,21 +7046,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6921,28 +7068,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -6955,8 +7101,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -6979,8 +7124,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -6992,8 +7136,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -7010,8 +7153,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -7025,8 +7167,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -7040,7 +7181,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -7093,16 +7234,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -7136,9 +7274,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -7161,9 +7297,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -7190,17 +7324,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -7247,8 +7380,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -7260,8 +7393,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -7279,6 +7411,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -7287,7 +7420,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -7298,7 +7431,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -7358,10 +7491,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -7396,9 +7529,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -7411,7 +7542,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -7432,9 +7563,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7456,12 +7585,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -7470,7 +7599,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7511,7 +7640,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -7558,7 +7687,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -7576,21 +7705,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7624,14 +7751,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7641,6 +7769,7 @@ parse: function parse(input) { + } continue; // accept: @@ -7692,7 +7821,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -7708,9 +7837,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7739,7 +7866,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7756,8 +7883,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -7768,8 +7895,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -7781,21 +7908,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7826,14 +7951,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7843,6 +7969,7 @@ parse: function parse(input) { + } continue; // accept: @@ -7895,8 +8022,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -8157,7 +8283,6 @@ var lexer = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -8174,10 +8299,10 @@ var lexer = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -8209,7 +8334,7 @@ var lexer = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -8251,7 +8376,9 @@ var lexer = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -8337,7 +8464,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -8345,7 +8472,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -8358,7 +8485,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -8384,10 +8511,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -8410,7 +8540,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -8433,16 +8562,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -8464,7 +8593,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -8472,8 +8600,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -8502,7 +8630,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -8527,7 +8655,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -8539,17 +8667,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -8643,7 +8771,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -8664,7 +8792,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -8675,7 +8802,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -8686,15 +8813,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -8728,8 +8855,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -8762,9 +8889,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -8783,9 +8910,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -8795,8 +8922,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -8823,20 +8950,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -8876,17 +9002,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8895,7 +9023,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -8910,8 +9038,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -8937,24 +9065,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8965,7 +9095,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -8987,8 +9117,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -9010,8 +9140,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -9155,21 +9284,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -9184,11 +9313,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -9207,13 +9336,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -9237,13 +9366,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -9258,8 +9387,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -9290,7 +9419,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -9322,9 +9451,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -9353,7 +9482,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -9371,7 +9500,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -9396,7 +9525,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -9406,8 +9534,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -9416,7 +9542,7 @@ EOF: 1, this.clear(); } - 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. @@ -9428,13 +9554,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -9444,68 +9570,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -9530,7 +9662,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -9578,24 +9710,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9615,7 +9747,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -9625,24 +9757,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9663,8 +9795,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -9704,14 +9835,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -9727,9 +9858,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -9740,8 +9871,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -9749,7 +9880,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -11439,7 +11570,7 @@ const UNICODE_BASE_PLANE_MAX_CP = 65535; // The expanded regex sets which are equivalent to the given `\\{c}` escapes: // // `/\s/`: -const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; +const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; // `/\d/`: const DIGIT_SETSTR = '0-9'; // `/\w/`: @@ -11451,7 +11582,7 @@ const WORDCHAR_SETSTR = 'A-Za-z0-9_'; // Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex function i2c(i) { - var c, x; + let c, x; switch (i) { case 10: @@ -11491,7 +11622,7 @@ function i2c(i) { || i > 0xFFF0 /* Unicode Specials, also in UTF16 */ || (i >= 0xD800 && i <= 0xDFFF) /* Unicode Supplementary Planes; we're TOAST in JavaScript as we're NOT UTF-16 but UCS-2! */ || String.fromCharCode(i).match(/[\u2028\u2029]/) /* Code compilation via `new Function()` does not like to see these, or rather: treats them as just another form of CRLF, which breaks your generated regex code! */ - ) { + ) { // Detail about a detail: // U+2028 and U+2029 are part of the `\s` regex escape code (`\s` and `[\s]` match either of these) and when placed in a JavaScript // source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report @@ -11499,11 +11630,10 @@ function i2c(i) { // Hence we MUST escape these buggers everywhere we go... x = i.toString(16); if (x.length >= 1 && i <= 0xFFFF) { - c = '0000' + x; - return '\\u' + c.substr(c.length - 4); - } else { - return '\\u{' + x + '}'; + c = '0000' + x; + return '\\u' + c.substr(c.length - 4); } + return '\\u{' + x + '}'; } return String.fromCharCode(i); } @@ -11512,18 +11642,18 @@ function i2c(i) { // Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating // this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a // `\\p{NAME}` shorthand to represent [part of] the bitarray: -var Pcodes_bitarray_cache = {}; -var Pcodes_bitarray_cache_test_order = []; +let Pcodes_bitarray_cache = {}; +let Pcodes_bitarray_cache_test_order = []; -// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by +// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. -var EscCode_bitarray_output_refs; +let EscCode_bitarray_output_refs; // now initialize the EscCodes_... table above: init_EscCode_lookup_table(); function init_EscCode_lookup_table() { - var s, bitarr, set2esc = {}, esc2bitarr = {}; + let s, bitarr, set2esc = {}, esc2bitarr = {}; // patch global lookup tables for the time being, while we calculate their *real* content in this function: EscCode_bitarray_output_refs = { @@ -11592,13 +11722,13 @@ function init_EscCode_lookup_table() { }; updatePcodesBitarrayCacheTestOrder(); -} +} function updatePcodesBitarrayCacheTestOrder(opts) { - var t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var l = {}; - var user_has_xregexp = opts && opts.options && opts.options.xregexp; - var i, j, k, ba; + let t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let l = {}; + let user_has_xregexp = opts && opts.options && opts.options.xregexp; + let i, j, k, ba; // mark every character with which regex pcodes they are part of: for (k in Pcodes_bitarray_cache) { @@ -11608,12 +11738,12 @@ function updatePcodesBitarrayCacheTestOrder(opts) { continue; } - var cnt = 0; + let cnt = 0; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { cnt++; if (!t[i]) { - t[i] = [k]; + t[i] = [ k ]; } else { t[i].push(k); } @@ -11623,27 +11753,27 @@ function updatePcodesBitarrayCacheTestOrder(opts) { } // now dig out the unique ones: only need one per pcode. - // + // // We ASSUME every \\p{NAME} 'pcode' has at least ONE character - // in it that is ONLY matched by that particular pcode. + // in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode - // won't be tested during optimization. - // + // won't be tested during optimization. + // // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to // look for markers which match multiple escapes/pcodes for those // ones where a unique item isn't available... - var lut = []; - var done = {}; - var keys = Object.keys(Pcodes_bitarray_cache); + let lut = []; + let done = {}; + let keys = Object.keys(Pcodes_bitarray_cache); for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { k = t[i][0]; if (t[i].length === 1 && !done[k]) { assert$1(l[k] > 0); - lut.push([i, k]); + lut.push([ i, k ]); done[k] = true; } } @@ -11654,19 +11784,19 @@ function updatePcodesBitarrayCacheTestOrder(opts) { if (!user_has_xregexp && k.indexOf('\\p{') >= 0) { continue; } - + if (!done[k]) { assert$1(l[k] > 0); // find a minimum span character to mark this one: - var w = Infinity; + let w = Infinity; var rv; ba = Pcodes_bitarray_cache[k]; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { - var tl = t[i].length; + let tl = t[i].length; if (tl > 1 && tl < w) { assert$1(l[k] > 0); - rv = [i, k]; + rv = [ i, k ]; w = tl; } } @@ -11680,16 +11810,16 @@ function updatePcodesBitarrayCacheTestOrder(opts) { // order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. - // + // // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more - // optimal minification of the regex set expression. - // + // optimal minification of the regex set expression. + // // This is a guestimate/heuristic only! lut.sort(function (a, b) { - var k1 = a[1]; - var k2 = b[1]; - var ld = l[k2] - l[k1]; + let k1 = a[1]; + let k2 = b[1]; + let ld = l[k2] - l[k1]; if (ld) { return ld; } @@ -11707,19 +11837,19 @@ function updatePcodesBitarrayCacheTestOrder(opts) { // 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set. function set2bitarray(bitarr, s, opts) { - var orig = s; - var set_is_inverted = false; - var bitarr_orig; + let orig = s; + let set_is_inverted = false; + let bitarr_orig; function mark(d1, d2) { if (d2 == null) d2 = d1; - for (var i = d1; i <= d2; i++) { + for (let i = d1; i <= d2; i++) { bitarr[i] = true; } } function add2bitarray(dst, src) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (src[i]) { dst[i] = true; } @@ -11727,10 +11857,10 @@ function set2bitarray(bitarr, s, opts) { } function eval_escaped_code(s) { - var c; + let c; // decode escaped code? If none, just take the character as-is if (s.indexOf('\\') === 0) { - var l = s.substr(0, 2); + let l = s.substr(0, 2); switch (l) { case '\\c': c = s.charCodeAt(2) - 'A'.charCodeAt(0) + 1; @@ -11748,7 +11878,7 @@ function set2bitarray(bitarr, s, opts) { } c = parseInt(s, 16); if (c >= 0x10000) { - return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); + return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); } return String.fromCharCode(c); @@ -11792,7 +11922,7 @@ function set2bitarray(bitarr, s, opts) { } if (s && s.length) { - var c1, c2; + let c1, c2; // inverted set? if (s[0] === '^') { @@ -11823,13 +11953,13 @@ function set2bitarray(bitarr, s, opts) { c2 = c2[0]; s = s.substr(c2.length); // do we have this one cached already? - var pex = c1 + c2; - var ba4p = Pcodes_bitarray_cache[pex]; + let pex = c1 + c2; + let ba4p = Pcodes_bitarray_cache[pex]; if (!ba4p) { // expand escape: - var xr = new XRegExp('[' + pex + ']'); // TODO: case-insensitive grammar??? + let xr = new XRegExp('[' + pex + ']'); // TODO: case-insensitive grammar??? // rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`: - var xs = '' + xr; + let xs = '' + xr; // remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: xs = xs.substr(1, xs.length - 2); @@ -11864,7 +11994,7 @@ function set2bitarray(bitarr, s, opts) { break; } } - var v1 = eval_escaped_code(c1); + let v1 = eval_escaped_code(c1); // propagate deferred exceptions = error reports. if (v1 instanceof Error) { return v1; @@ -11882,7 +12012,7 @@ function set2bitarray(bitarr, s, opts) { } else { c2 = c2[0]; } - var v2 = eval_escaped_code(c2); + let v2 = eval_escaped_code(c2); // propagate deferred exceptions = error reports. if (v2 instanceof Error) { return v1; @@ -11905,12 +12035,12 @@ function set2bitarray(bitarr, s, opts) { } // When we have marked all slots, '^' NEGATES the set, hence we flip all slots. - // + // // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. if (set_is_inverted) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (!bitarr[i]) { bitarr_orig[i] = true; } @@ -11929,10 +12059,10 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // below can be simple and fast: l[UNICODE_BASE_PLANE_MAX_CP + 1] = 1; // now reconstruct the regex set: - var rv = []; - var i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; - var bitarr_is_cloned = false; - var l_orig = l; + let rv = []; + let i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; + let bitarr_is_cloned = false; + let l_orig = l; if (output_inverted_variant) { // generate the inverted set, hence all unmarked slots are part of the output range: @@ -11946,8 +12076,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. // BUT... since we output the INVERTED set, we output the match-all set instead: return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` // BUT... since we output the INVERTED set, we output the match-nothing set instead: @@ -11979,9 +12108,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12008,7 +12137,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } } - + i = 0; while (i <= UNICODE_BASE_PLANE_MAX_CP) { // find first character not in original set: @@ -12039,8 +12168,7 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. return '^\\S\\s'; } @@ -12070,9 +12198,9 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12124,11 +12252,11 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { } assert$1(rv.length); - var s = rv.join(''); + let s = rv.join(''); assert$1(s); // Check if the set is better represented by one of the regex escapes: - var esc4s = EscCode_bitarray_output_refs.set2esc[s]; + let esc4s = EscCode_bitarray_output_refs.set2esc[s]; if (esc4s) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return '\\' + esc4s; @@ -12143,25 +12271,24 @@ function bitarray2set(l, output_inverted_variant, output_minimized) { // Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there; // ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`. function reduceRegexToSetBitArray(s, name, opts) { - var orig = s; + let orig = s; // propagate deferred exceptions = error reports. if (s instanceof Error) { return s; } - var l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var internal_state = 0; - var derr; + let l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let internal_state = 0; + let derr; while (s.length) { - var c1 = s.match(CHR_RE); + let c1 = s.match(CHR_RE); if (!c1) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"'); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12169,15 +12296,14 @@ function reduceRegexToSetBitArray(s, name, opts) { // this is starting a set within the regex: scan until end of set! var set_content = []; while (s.length) { - var inner = s.match(SET_PART_RE); + let inner = s.match(SET_PART_RE); if (!inner) { inner = s.match(CHR_RE); if (!inner) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"'); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12191,9 +12317,8 @@ function reduceRegexToSetBitArray(s, name, opts) { if (!c2) { // cope with illegal escape sequences too! return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error('regex set expression is broken in regex: ' + orig); } @@ -12277,10 +12402,9 @@ function reduceRegexToSetBitArray(s, name, opts) { // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; assert$1(s); assert$1(!(s instanceof Error)); - re = new XRegExp('[' + s + ']'); + let re = new XRegExp('[' + s + ']'); re.test(s[0]); // One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` @@ -12305,25 +12429,24 @@ function reduceRegexToSetBitArray(s, name, opts) { -// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` +// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! function produceOptimizedRegex4Set(bitarr) { // First try to produce a minimum regex from the bitarray directly: - var s1 = bitarray2set(bitarr, false, true); + let s1 = bitarray2set(bitarr, false, true); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s1.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s1; - } else { - s1 = '[' + s1 + ']'; } + s1 = '[' + s1 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s2 = bitarray2set(bitarr, true, true); + let s2 = bitarray2set(bitarr, true, true); if (s2[0] === '^') { s2 = s2.substr(1); @@ -12338,23 +12461,22 @@ function produceOptimizedRegex4Set(bitarr) { // Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: - // + // // First try to produce a minimum regex from the bitarray directly: - var s3 = bitarray2set(bitarr, false, false); + let s3 = bitarray2set(bitarr, false, false); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s3.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s3; - } else { - s3 = '[' + s3 + ']'; } + s3 = '[' + s3 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s4 = bitarray2set(bitarr, true, false); + let s4 = bitarray2set(bitarr, true, false); if (s4[0] === '^') { s4 = s4.substr(1); @@ -12386,30 +12508,30 @@ function produceOptimizedRegex4Set(bitarr) { var setmgmt = { - XREGEXP_UNICODE_ESCAPE_RE, - CHR_RE, - SET_PART_RE, - NOTHING_SPECIAL_RE, - SET_IS_SINGLE_PCODE_RE, - - UNICODE_BASE_PLANE_MAX_CP, - - WHITESPACE_SETSTR, - DIGIT_SETSTR, - WORDCHAR_SETSTR, - - set2bitarray, - bitarray2set, - produceOptimizedRegex4Set, - reduceRegexToSetBitArray, + XREGEXP_UNICODE_ESCAPE_RE, + CHR_RE, + SET_PART_RE, + NOTHING_SPECIAL_RE, + SET_IS_SINGLE_PCODE_RE, + + UNICODE_BASE_PLANE_MAX_CP, + + WHITESPACE_SETSTR, + DIGIT_SETSTR, + WORDCHAR_SETSTR, + + set2bitarray, + bitarray2set, + produceOptimizedRegex4Set, + reduceRegexToSetBitArray }; // Basic Lexer implemented using JavaScript regular expressions -var rmCommonWS$2 = helpers.rmCommonWS; -var mkIdentifier$2 = helpers.mkIdentifier; -var code_exec$1 = helpers.exec; +const rmCommonWS$2 = helpers.rmCommonWS; +const mkIdentifier$2 = helpers.mkIdentifier; +const code_exec = helpers.exec; -var version = '0.6.2-220'; // require('./package.json').version; +const version = '0.6.2-220'; // require('./package.json').version; @@ -12470,7 +12592,7 @@ const defaultJisonLexOptions = { exportAST: false, prettyCfg: true, pre_lex: undefined, - post_lex: undefined, + post_lex: undefined }; @@ -12488,23 +12610,23 @@ const defaultJisonLexOptions = { // Return a fresh set of options. /** @public */ function mkStdOptions(/*...args*/) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - var args = [].concat.apply([], arguments); + let opts = {}; + let args = [].concat.apply([], arguments); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(defaultJisonLexOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; for (var p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { @@ -12542,7 +12664,7 @@ function mkStdOptions(/*...args*/) { function prepExportStructures(options) { // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -12563,8 +12685,8 @@ function prepExportStructures(options) { // Otherwise return the *parsed* lexer spec as it has // been processed through LexParser. function autodetectAndConvertToJSONformat(lexerSpec, options) { - var chk_l = null; - var ex1, err; + let chk_l = null; + let ex1, err; if (typeof lexerSpec === 'string') { if (options.json) { @@ -12616,9 +12738,9 @@ function autodetectAndConvertToJSONformat(lexerSpec, options) { /should be separated/, /an error in one or more of your lexer regex rules/, /an error in your lexer epilogue/, - /unsupported definition type/, + /unsupported definition type/ ]; - var cmnerr = commonErrors.filter(function check(re) { + let cmnerr = commonErrors.filter(function check(re) { return e.message.match(re); }); if (cmnerr.length > 0) { @@ -12647,14 +12769,14 @@ function autodetectAndConvertToJSONformat(lexerSpec, options) { // expand macros and convert matchers to RegExp's function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) { - var m, i, k, rule, action, conditions; - var active_conditions; + let m, i, k, rule, action, conditions; + let active_conditions; assert$1(Array.isArray(dict.rules)); - var rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! - var newRules = []; - var macros = {}; - var regular_rule_count = 0; - var simple_rule_count = 0; + let rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! + let newRules = []; + let macros = {}; + let regular_rule_count = 0; + let simple_rule_count = 0; // Assure all options are camelCased: assert$1(typeof opts.options['case-insensitive'] === 'undefined'); @@ -12664,7 +12786,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) } if (opts.options.flex && rules.length > 0) { - rules.push(['.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']); + rules.push([ '.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */' ]); } // Depending on the location within the regex we need different expansions of the macros: @@ -12688,7 +12810,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) return str; } - var routingCode = ['switch(yyrulenumber) {']; + let routingCode = [ 'switch(yyrulenumber) {' ]; for (i = 0; i < rules.length; i++) { rule = rules[i].slice(0); // shallow copy: do not modify input rules @@ -12742,7 +12864,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) action = action.replace(/return\s*\(?'((?:\\'|[^']+)+)'\)?/g, tokenNumberReplacement); action = action.replace(/return\s*\(?"((?:\\"|[^"]+)+)"\)?/g, tokenNumberReplacement); - var code = ['\n/*! Conditions::']; + let code = [ '\n/*! Conditions::' ]; code.push(postprocessComment(active_conditions)); code.push('*/', '\n/*! Rule:: '); code.push(postprocessComment(rule[0])); @@ -12763,7 +12885,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) // 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'. - var match_nr = /^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim()); + 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 ')); @@ -12790,7 +12912,7 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) macros: macros, regular_rule_count: regular_rule_count, - simple_rule_count: simple_rule_count, + simple_rule_count: simple_rule_count }; } @@ -12803,14 +12925,13 @@ function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) // 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. function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElsewhere_cb) { - var orig = s; + let orig = s; function errinfo() { if (name) { return 'macro [[' + name + ']]'; - } else { - return 'regex [[' + orig + ']]'; } + return 'regex [[' + orig + ']]'; } // propagate deferred exceptions = error reports. @@ -12818,19 +12939,18 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse return s; } - var c1, c2; - var rv = []; - var derr; - var se; + let c1, c2; + let rv = []; + let derr; + let se; while (s.length) { c1 = s.match(CHR_RE$1); if (!c1) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12840,15 +12960,14 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse var l = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1); while (s.length) { - var inner = s.match(SET_PART_RE$1); + let inner = s.match(SET_PART_RE$1); if (!inner) { inner = s.match(CHR_RE$1); if (!inner) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12862,9 +12981,8 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse if (!c2) { // cope with illegal escape sequences too! return new Error(errinfo() + ': regex set expression is broken: "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error(errinfo() + ': regex set expression is broken: apparently unterminated'); } @@ -12925,7 +13043,7 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse c2 = c2[0]; s = s.substr(c2.length); - var c3 = s[0]; + let c3 = s[0]; s = s.substr(c3.length); if (c3 === '}') { // possibly a macro name in there... Expand if possible: @@ -12978,7 +13096,7 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; + let re; re = new XRegExp(s); re.test(s[0]); } catch (ex) { @@ -12994,11 +13112,11 @@ function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElse // expand macros within macros and cache the result function prepareMacros(dict_macros, opts) { - var macros = {}; + let macros = {}; // expand a `{NAME}` macro which exists inside a `[...]` set: function expandMacroInSet(i) { - var k, a, m; + let k, a, m; if (!macros[i]) { m = dict_macros[i]; @@ -13032,7 +13150,7 @@ function prepareMacros(dict_macros, opts) { a = m.split('{' + k + '}'); if (a.length > 1) { - var x = expandMacroInSet(k); + let x = expandMacroInSet(k); assert$1(x); if (x instanceof Error) { m = x; @@ -13044,9 +13162,9 @@ function prepareMacros(dict_macros, opts) { } } - var mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); + let mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); - var s1; + let s1; // propagate deferred exceptions = error reports. if (mba instanceof Error) { @@ -13080,7 +13198,7 @@ function prepareMacros(dict_macros, opts) { } function expandMacroElsewhere(i) { - var m; + let m; if (macros[i].elsewhere == null) { m = dict_macros[i]; @@ -13115,13 +13233,13 @@ function prepareMacros(dict_macros, opts) { } function expandAllMacrosInSet(s) { - var i, x; + let i, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { for (i in macros) { if (macros.hasOwnProperty(i)) { - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroInSet(i); assert$1(x); @@ -13143,7 +13261,7 @@ function prepareMacros(dict_macros, opts) { } function expandAllMacrosElsewhere(s) { - var i, x; + let i, x; // When we process the remaining macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13158,7 +13276,7 @@ function prepareMacros(dict_macros, opts) { for (i in macros) { if (macros.hasOwnProperty(i)) { // These are all submacro expansions, hence non-capturing grouping is applied: - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroElsewhere(i); assert$1(x); @@ -13180,7 +13298,7 @@ function prepareMacros(dict_macros, opts) { } - var i; + let i; if (opts.debug) console.log('\n############## RAW macros: ', dict_macros); @@ -13211,13 +13329,13 @@ function prepareMacros(dict_macros, opts) { // expand macros in a regex; expands them recursively function expandMacros(src, macros, opts) { - var expansion_count = 0; + let expansion_count = 0; // By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! // Hence things should be easy in there: function expandAllMacrosInSet(s) { - var i, m, x; + let i, m, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { @@ -13225,7 +13343,7 @@ function expandMacros(src, macros, opts) { if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = m.in_set; @@ -13256,7 +13374,7 @@ function expandMacros(src, macros, opts) { } function expandAllMacrosElsewhere(s) { - var i, m, x; + let i, m, x; // When we process the main macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13272,7 +13390,7 @@ function expandMacros(src, macros, opts) { if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { // These are all main macro expansions, hence CAPTURING grouping is applied: x = m.elsewhere; @@ -13308,7 +13426,7 @@ function expandMacros(src, macros, opts) { // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! - var s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); + let s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); // propagate deferred exceptions = error reports. if (s2 instanceof Error) { throw s2; @@ -13333,8 +13451,8 @@ function expandMacros(src, macros, opts) { } function prepareStartConditions(conditions) { - var sc; - var hash = {}; + let sc; + let hash = {}; for (sc in conditions) { if (conditions.hasOwnProperty(sc)) { @@ -13348,22 +13466,22 @@ function prepareStartConditions(conditions) { } function buildActions(dict, tokens, opts) { - var actions = [dict.actionInclude || '', 'var YYSTATE = YY_START;']; - var tok; - var toks = {}; - var caseHelper = []; + let actions = [ dict.actionInclude || '', 'var YYSTATE = YY_START;' ]; + let tok; + let toks = {}; + let caseHelper = []; // tokens: map/array of token numbers to token names for (tok in tokens) { - var idx = parseInt(tok); + let idx = parseInt(tok); if (idx && idx > 0) { toks[tokens[tok]] = idx; } } - var gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); + let gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); - var code = actions.join('\n'); + let code = actions.join('\n'); 'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function (yy) { code = code.replace(new RegExp('\\b(' + yy + ')\\b', 'g'), 'yy_.$1'); }); @@ -13381,7 +13499,7 @@ function buildActions(dict, tokens, opts) { macros: gen.macros, // propagate these for debugging/diagnostic purposes regular_rule_count: gen.regular_rule_count, - simple_rule_count: gen.simple_rule_count, + simple_rule_count: gen.simple_rule_count }; } @@ -13392,7 +13510,7 @@ function buildActions(dict, tokens, opts) { function generateErrorClass() { // --- START lexer error class --- -var prelude = `/** +const prelude = `/** * 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 @@ -13403,8 +13521,6 @@ var prelude = `/** * @nocollapse */ function JisonLexerError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -13421,9 +13537,9 @@ function JisonLexerError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -13484,8 +13600,8 @@ function generateFakeXRegExpClassSrcCode() { /** @constructor */ function RegExpLexer(dict, input, tokens, build_options) { - var opts; - var dump = false; + let opts; + let dump = false; function test_me(tweak_cb, description, src_exception, ex_callback) { opts = processGrammar(dict, tokens, build_options); @@ -13495,7 +13611,7 @@ function RegExpLexer(dict, input, tokens, build_options) { if (tweak_cb) { tweak_cb(); } - var source = generateModuleBody(opts); + let source = generateModuleBody(opts); try { // The generated code will always have the `lexer` variable declared at local scope // as `eval()` will use the local scope. @@ -13503,16 +13619,16 @@ function RegExpLexer(dict, input, tokens, build_options) { // The compiled code will look something like this: // // ``` - // var lexer; + // let lexer; // bla bla... // ``` // // or // // ``` - // var lexer = { bla... }; + // const lexer = { bla... }; // ``` - var testcode = [ + let testcode = [ '// provide a local version for test purposes:', jisonLexerErrorDefinition, '', @@ -13520,14 +13636,33 @@ function RegExpLexer(dict, input, tokens, build_options) { '', source, '', + rmCommonWS$2` + // JISON INJECTED VALIDATION CODE + // which attempts to ascertain you have defined a minimal viable lexer at least: + if (typeof lexer === "undefined") { + throw new SyntaxError("user-defined lexer does not define the required 'lexer' instance."); + } + if (!lexer) { + throw new SyntaxError("user-defined lexer does not define a non-NULL 'lexer' instance."); + } + if (typeof lexer.setInput !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.setInput()' API function."); + } + if (typeof lexer.lex !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.lex()' API function."); + } + // END OF JISON INJECTED VALIDATION CODE + `, 'return lexer;' ].join('\n'); - var lexer = code_exec$1(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { + let lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { //console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$2(sourcecode); - var lexer_f = new Function('', sourcecode); + let lexer_f = new Function('', sourcecode); return lexer_f(); - }, opts.options, "lexer"); + }, Object.assign({}, opts.options, { + throwErrorOnCompileFailure: true + }), 'lexer'); if (!lexer) { throw new Error('no lexer defined *at all*?!'); @@ -13544,7 +13679,7 @@ function RegExpLexer(dict, input, tokens, build_options) { // When we do NOT crash, we found/killed the problem area just before this call! if (src_exception && description) { - var msg = description; + let msg = description; if (typeof description === 'function') { msg = description(); } @@ -13553,8 +13688,8 @@ function RegExpLexer(dict, input, tokens, build_options) { // patch the pre and post handlers in there, now that we have some live code to work with: if (opts.options) { - var pre = opts.options.pre_lex; - var post = opts.options.post_lex; + let pre = opts.options.pre_lex; + let post = opts.options.post_lex; // since JSON cannot encode functions, we'll have to do it manually now: if (typeof pre === 'function') { lexer.options.pre_lex = pre; @@ -13568,7 +13703,7 @@ function RegExpLexer(dict, input, tokens, build_options) { if (typeof opts.options.showSource === 'function') { opts.options.showSource(lexer, source, opts, RegExpLexer); } else { - console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n"); + console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n', source, '\n----------------------------------------\n'); } } return lexer; @@ -13587,13 +13722,13 @@ function RegExpLexer(dict, input, tokens, build_options) { } /** @constructor */ - var lexer = test_me(null, null, null, function (ex) { + let lexer = test_me(null, null, null, function (ex) { // When we get an exception here, it means some part of the user-specified lexer is botched. // // Now we go and try to narrow down the problem area/category: assert$1(opts.options); assert$1(opts.options.xregexp !== undefined); - var orig_xregexp_opt = !!opts.options.xregexp; + let orig_xregexp_opt = !!opts.options.xregexp; if (!test_me(function () { assert$1(opts.options.xregexp !== undefined); opts.options.xregexp = false; @@ -13612,7 +13747,7 @@ function RegExpLexer(dict, input, tokens, build_options) { 'Your custom lexer is somehow botched.' ); }, ex, null)) { - var rulesSpecSize; + let rulesSpecSize; if (!test_me(function () { // store the parsed rule set size so we can use that info in case // this attempt also fails: @@ -13625,7 +13760,7 @@ function RegExpLexer(dict, input, tokens, build_options) { opts.__in_rules_failure_analysis_mode__ = true; }, 'One or more of your lexer rules are possibly botched?', ex, null)) { // kill each rule action block, one at a time and test again after each 'edit': - var rv = false; + let rv = false; for (var i = 0, len = rulesSpecSize; i < len; i++) { var lastEditedRuleSpec; rv = test_me(function () { @@ -13637,10 +13772,10 @@ function RegExpLexer(dict, input, tokens, build_options) { // opts.__in_rules_failure_analysis_mode__ = true; // nuke all rules' actions up to and including rule numero `i`: - for (var j = 0; j <= i; j++) { + for (let j = 0; j <= i; j++) { // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; // now we want to edit the *action* part: - var rule = opts.rules[j]; + let rule = opts.rules[j]; assert$1(Array.isArray(rule)); assert$1(rule.length === 2 || rule.length === 3); rule.pop(); @@ -13774,8 +13909,6 @@ return `{ * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -13785,14 +13918,14 @@ return `{ } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\\n\\s*$/.test(msg)) { msg += '\\n'; } msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') { msg += '\\n' + pos_str; @@ -13803,14 +13936,14 @@ return `{ } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the \`upcomingInput\` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -13830,9 +13963,8 @@ return `{ // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -13852,8 +13984,6 @@ return `{ * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -13874,16 +14004,14 @@ return `{ * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -13904,8 +14032,6 @@ return `{ * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -13913,8 +14039,8 @@ return `{ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -13932,8 +14058,6 @@ return `{ * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -13943,14 +14067,14 @@ return `{ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -13961,8 +14085,6 @@ return `{ * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -13970,40 +14092,40 @@ return `{ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -14015,7 +14137,7 @@ return `{ this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -14023,7 +14145,7 @@ return `{ last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -14084,9 +14206,7 @@ return `{ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -14105,8 +14225,6 @@ return `{ * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set \`done\` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -14115,7 +14233,7 @@ return `{ this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -14125,13 +14243,13 @@ return `{ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\\n') { lines = true; } else if (ch === '\\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\\n') { slice_len++; ch += ch2; @@ -14163,10 +14281,8 @@ return `{ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -14198,8 +14314,8 @@ return `{ // Get last entirely matched line into the \`pre_lines[]\` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -14217,9 +14333,9 @@ return `{ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -14229,14 +14345,12 @@ return `{ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -14247,8 +14361,6 @@ return `{ * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -14261,19 +14373,17 @@ return `{ * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the \`parseError()\` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // \`.lex()\` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -14286,8 +14396,6 @@ return `{ * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -14310,24 +14418,24 @@ return `{ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substr\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14339,8 +14447,8 @@ return `{ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to \`maxSize\` (default: 20). @@ -14366,24 +14474,25 @@ return `{ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > \`lookAhead()\` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substring\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -14392,7 +14501,7 @@ return `{ } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14411,10 +14520,8 @@ return `{ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^'; }, @@ -14436,15 +14543,13 @@ return `{ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -14575,58 +14680,54 @@ return `{ * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\\t/g, ' '); @@ -14635,13 +14736,13 @@ return `{ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -14663,15 +14764,13 @@ return `{ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -14683,8 +14782,8 @@ return `{ rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -14713,13 +14812,7 @@ return `{ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -14748,10 +14841,10 @@ return `{ }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -14779,7 +14872,7 @@ return `{ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -14790,7 +14883,7 @@ return `{ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -14812,8 +14905,6 @@ return `{ * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -14822,17 +14913,13 @@ return `{ this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -14842,67 +14929,75 @@ return `{ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that \`parseError()\` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) \`parseError()\` @@ -14929,9 +15024,7 @@ return `{ * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -14974,24 +15067,24 @@ return `{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15011,9 +15104,7 @@ return `{ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15023,24 +15114,24 @@ return `{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15048,7 +15139,7 @@ return `{ this._clear_state = 0; } - + return r; }, @@ -15061,9 +15152,7 @@ return `{ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -15071,7 +15160,7 @@ return `{ (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -15086,8 +15175,6 @@ return `{ * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -15099,8 +15186,6 @@ return `{ * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -15114,15 +15199,12 @@ return `{ * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -15134,14 +15216,11 @@ return `{ * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -15152,16 +15231,14 @@ return `{ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -15171,8 +15248,6 @@ return `{ * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; } }`; @@ -15204,18 +15279,17 @@ function stripUnusedLexerCode(src, opt) { // ............................. ${opt.lexerActionsUseDisplayAPIs} // uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC} - var new_src; + let new_src; try { - var ast = helpers.parseCodeChunkToAST(src, opt); + let ast = helpers.parseCodeChunkToAST(src, opt); new_src = helpers.prettyPrintAST(ast, opt); - } - catch (ex) { + } catch (ex) { let line = ex.lineNumber || 0; let a = src.split(/\r?\n/g); let len = a.length; let minl = Math.max(0, line - 10); let b = a.slice(minl, line + 10); - let c = b.splice(line - minl, 0, "", "^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", ""); + let c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); let offendingChunk = ' ' + b.join('\n '); console.error(rmCommonWS$2` stripUnusedLexerCode WARNING: @@ -15231,17 +15305,11 @@ function stripUnusedLexerCode(src, opt) { ${offendingChunk} `); - + new_src = src; } - - - - - - // inject analysis report now: new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2` // Code Generator Information Report @@ -15296,7 +15364,7 @@ function stripUnusedLexerCode(src, opt) { // generate lexer source from a grammar /** @public */ function generate(dict, tokens, build_options) { - var opt = processGrammar(dict, tokens, build_options); + let opt = processGrammar(dict, tokens, build_options); return generateFromOpts(opt); } @@ -15305,7 +15373,7 @@ function generate(dict, tokens, build_options) { /** @public */ function processGrammar(dict, tokens, build_options) { build_options = build_options || {}; - var opts = { + let opts = { // include the knowledge passed through `build_options` about which lexer // features will actually be *used* by the environment (which in 99.9% // of cases is a jison *parser*): @@ -15345,7 +15413,7 @@ function processGrammar(dict, tokens, build_options) { lexerActionsUseReject: '???', lexerActionsUseLess: '???', lexerActionsUseDisplayAPIs: '???', - lexerActionsUseDescribeYYLOC: '???', + lexerActionsUseDescribeYYLOC: '???' }; dict = autodetectAndConvertToJSONformat(dict, build_options) || {}; @@ -15370,7 +15438,7 @@ function processGrammar(dict, tokens, build_options) { // only produce rule action code blocks when there are any rules at all; // a "custom lexer" has ZERO rules and must be defined entirely in // other code blocks: - var code = (dict.rules ? buildActions(dict, tokens, opts) : {}); + let code = (dict.rules ? buildActions(dict, tokens, opts) : {}); opts.performAction = code.actions; opts.caseHelperInclude = code.caseHelperInclude; opts.rules = code.rules || []; @@ -15379,7 +15447,7 @@ function processGrammar(dict, tokens, build_options) { opts.regular_rule_count = code.regular_rule_count; opts.simple_rule_count = code.simple_rule_count; - opts.conditionStack = ['INITIAL']; + opts.conditionStack = [ 'INITIAL' ]; opts.actionInclude = (dict.actionInclude || ''); opts.moduleInclude = (opts.moduleInclude || '') + (dict.moduleInclude || '').trim(); @@ -15390,7 +15458,7 @@ function processGrammar(dict, tokens, build_options) { // Assemble the final source from the processed grammar /** @public */ function generateFromOpts(opt) { - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -15413,12 +15481,12 @@ function generateFromOpts(opt) { } function generateRegexesInitTableCode(opt) { - var a = opt.rules; - var print_xregexp = opt.options && opt.options.xregexp; - var id_display_width = (1 + Math.log10(a.length | 1) | 0); - var ws_prefix = new Array(id_display_width).join(' '); - var b = a.map(function generateXRegExpInitCode(re, idx) { - var idx_str = (ws_prefix + idx).substr(-id_display_width); + let a = opt.rules; + let print_xregexp = opt.options && opt.options.xregexp; + let id_display_width = (1 + Math.log10(a.length | 1) | 0); + let ws_prefix = new Array(id_display_width).join(' '); + let b = a.map(function generateXRegExpInitCode(re, idx) { + let idx_str = (ws_prefix + idx).substr(-id_display_width); if (re instanceof XRegExp) { // When we don't need the special XRegExp sauce at run-time, we do with the original @@ -15428,11 +15496,11 @@ function generateRegexesInitTableCode(opt) { } // And make sure to escape the regex to make it suitable for placement inside a *string* // as it is passed as a string argument to the XRegExp constructor here. - var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); + let re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); return `/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`; - } else { - return `/* ${idx_str}: */ ${re}`; } + return `/* ${idx_str}: */ ${re}`; + }); return b.join(',\n'); } @@ -15440,77 +15508,77 @@ function generateRegexesInitTableCode(opt) { function generateModuleBody(opt) { // make the JSON output look more like JavaScript: function cleanupJSON(str) { - str = str.replace(/ "rules": \[/g, ' rules: ['); - str = str.replace(/ "inclusive": /g, ' inclusive: '); + str = str.replace(/ {2}"rules": \[/g, ' rules: ['); + str = str.replace(/ {2}"inclusive": /g, ' inclusive: '); return str; } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - json: 1, - _: 1, - noMain: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - lexerErrorsAreRecoverable: 0, - flex: 0, - backtrack_lexer: 0, - caseInsensitive: 0, - showSource: 1, - exportAST: 1, - exportAllTables: 1, - exportSourceCode: 1, - prettyCfg: 1, - parseActionsUseYYLENG: 1, - parseActionsUseYYLINENO: 1, - parseActionsUseYYTEXT: 1, - parseActionsUseYYLOC: 1, - parseActionsUseParseError: 1, - parseActionsUseYYERROR: 1, - parseActionsUseYYRECOVERING: 1, - parseActionsUseYYERROK: 1, - parseActionsUseYYCLEARIN: 1, - parseActionsUseValueTracking: 1, - parseActionsUseValueAssignment: 1, - parseActionsUseLocationTracking: 1, - parseActionsUseLocationAssignment: 1, - parseActionsUseYYSTACK: 1, - parseActionsUseYYSSTACK: 1, - parseActionsUseYYSTACKPOINTER: 1, - parseActionsUseYYRULELENGTH: 1, - parseActionsUseYYMERGELOCATIONINFO: 1, - parserHasErrorRecovery: 1, - parserHasErrorReporting: 1, - lexerActionsUseYYLENG: 1, - lexerActionsUseYYLINENO: 1, - lexerActionsUseYYTEXT: 1, - lexerActionsUseYYLOC: 1, - lexerActionsUseParseError: 1, - lexerActionsUseYYERROR: 1, - lexerActionsUseLocationTracking: 1, - lexerActionsUseMore: 1, - lexerActionsUseUnput: 1, - lexerActionsUseReject: 1, - lexerActionsUseLess: 1, - lexerActionsUseDisplayAPIs: 1, - lexerActionsUseDescribeYYLOC: 1, + let obj = {}; + const do_not_pass = { + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + json: 1, + _: 1, + noMain: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + lexerErrorsAreRecoverable: 0, + flex: 0, + backtrack_lexer: 0, + caseInsensitive: 0, + showSource: 1, + exportAST: 1, + exportAllTables: 1, + exportSourceCode: 1, + prettyCfg: 1, + parseActionsUseYYLENG: 1, + parseActionsUseYYLINENO: 1, + parseActionsUseYYTEXT: 1, + parseActionsUseYYLOC: 1, + parseActionsUseParseError: 1, + parseActionsUseYYERROR: 1, + parseActionsUseYYRECOVERING: 1, + parseActionsUseYYERROK: 1, + parseActionsUseYYCLEARIN: 1, + parseActionsUseValueTracking: 1, + parseActionsUseValueAssignment: 1, + parseActionsUseLocationTracking: 1, + parseActionsUseLocationAssignment: 1, + parseActionsUseYYSTACK: 1, + parseActionsUseYYSSTACK: 1, + parseActionsUseYYSTACKPOINTER: 1, + parseActionsUseYYRULELENGTH: 1, + parseActionsUseYYMERGELOCATIONINFO: 1, + parserHasErrorRecovery: 1, + parserHasErrorReporting: 1, + lexerActionsUseYYLENG: 1, + lexerActionsUseYYLINENO: 1, + lexerActionsUseYYTEXT: 1, + lexerActionsUseYYLOC: 1, + lexerActionsUseParseError: 1, + lexerActionsUseYYERROR: 1, + lexerActionsUseLocationTracking: 1, + lexerActionsUseMore: 1, + lexerActionsUseUnput: 1, + lexerActionsUseReject: 1, + lexerActionsUseLess: 1, + lexerActionsUseDisplayAPIs: 1, + lexerActionsUseDescribeYYLOC: 1 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -15521,8 +15589,8 @@ function generateModuleBody(opt) { } // And now some options which should receive some special processing: - var pre = obj.pre_lex; - var post = obj.post_lex; + let pre = obj.pre_lex; + let post = obj.post_lex; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_lex = true; @@ -15531,7 +15599,7 @@ function generateModuleBody(opt) { obj.post_lex = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp(` "(${ID_REGEX_BASE$1})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_lex: true(,)?$/gm, function (m, ls, tc) { @@ -15544,17 +15612,17 @@ function generateModuleBody(opt) { } - var out; + let out; if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) { // we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. - var code = [rmCommonWS$2` - var lexer = { - `, '/*JISON-LEX-ANALYTICS-REPORT*/' /* slot #1: placeholder for analysis report further below */ + let code = [ rmCommonWS$2` + const lexer = { + `, '/* JISON-LEX-ANALYTICS-REPORT */\n' /* slot #1: placeholder for analysis report further below */ ]; // get the RegExpLexer.prototype in source code form: - var protosrc = getRegExpLexerPrototype(); + let protosrc = getRegExpLexerPrototype(); // and strip off the surrounding bits we don't want: protosrc = protosrc .replace(/^[\s\r\n]*\{/, '') @@ -15581,10 +15649,10 @@ function generateModuleBody(opt) { } */ - var performActionCode = String(opt.performAction); - var simpleCaseActionClustersCode = String(opt.caseHelperInclude); - var rulesCode = generateRegexesInitTableCode(opt); - var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); + let performActionCode = String(opt.performAction); + let simpleCaseActionClustersCode = String(opt.caseHelperInclude); + let rulesCode = generateRegexesInitTableCode(opt); + let conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); code.push(rmCommonWS$2`, JisonLexerError: JisonLexerError, performAction: ${performActionCode}, @@ -15604,9 +15672,9 @@ function generateModuleBody(opt) { // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // - // Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter + // Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. - out = 'var lexer;\n'; + out = '\n'; assert$1(opt.regular_rule_count === 0); assert$1(opt.simple_rule_count === 0); @@ -15620,8 +15688,6 @@ function generateModuleBody(opt) { // The output of this function is guaranteed to read something like this: // // ``` - // var lexer; - // // bla bla bla bla ... lotsa bla bla; // ``` // @@ -15630,7 +15696,7 @@ function generateModuleBody(opt) { } function generateGenericHeaderComment() { - var out = rmCommonWS$2` + let out = rmCommonWS$2` /* lexer generated by jison-lex ${version} */ /* @@ -15859,7 +15925,7 @@ function prepareOptions(opt) { // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else { @@ -15877,9 +15943,9 @@ function prepareOptions(opt) { function generateModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -15902,9 +15968,9 @@ function generateModule(opt) { function generateAMDModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} define([], function () { @@ -15927,12 +15993,12 @@ function generateAMDModule(opt) { function generateESModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} - var lexer = (function () { + const lexer = (function () { "use strict"; ${jisonLexerErrorDefinition} @@ -15961,9 +16027,9 @@ function generateESModule(opt) { function generateCommonJSModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { diff --git a/packages/jison-lex/dist/regexp-lexer-umd-es5.js b/packages/jison-lex/dist/regexp-lexer-umd-es5.js index e935b1306..a0d5e333e 100644 --- a/packages/jison-lex/dist/regexp-lexer-umd-es5.js +++ b/packages/jison-lex/dist/regexp-lexer-umd-es5.js @@ -1,4 +1,4 @@ -(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?module.exports=factory(require('@gerhobbelt/xregexp'),require('@gerhobbelt/json5'),require('fs'),require('path'),require('recast'),require('@babel/core'),require('assert')):typeof define==='function'&&define.amd?define(['@gerhobbelt/xregexp','@gerhobbelt/json5','fs','path','recast','@babel/core','assert'],factory):(global=typeof globalThis!=='undefined'?globalThis:global||self,global['regexp-lexer']=factory(global.XRegExp,global.JSON5,global.fs,global.path$1,global.recast,global.babel,global.assert$1));})(this,function(XRegExp,JSON5,fs,path$1,recast,babel,assert$1){'use strict';function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e};}var XRegExp__default=/*#__PURE__*/_interopDefaultLegacy(XRegExp);var JSON5__default=/*#__PURE__*/_interopDefaultLegacy(JSON5);var fs__default=/*#__PURE__*/_interopDefaultLegacy(fs);var path__default=/*#__PURE__*/_interopDefaultLegacy(path$1);var recast__default=/*#__PURE__*/_interopDefaultLegacy(recast);var assert__default=/*#__PURE__*/_interopDefaultLegacy(assert$1);// Return TRUE if `src` starts with `searchString`. +(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?module.exports=factory(require('@gerhobbelt/xregexp'),require('@gerhobbelt/json5'),require('fs'),require('path'),require('mkdirp'),require('recast'),require('@babel/core'),require('assert')):typeof define==='function'&&define.amd?define(['@gerhobbelt/xregexp','@gerhobbelt/json5','fs','path','mkdirp','recast','@babel/core','assert'],factory):(global=typeof globalThis!=='undefined'?globalThis:global||self,global['regexp-lexer']=factory(global.XRegExp,global.JSON5,global.fs,global.path$1,global.mkdirp,global.recast,global.babel,global.assert$1));})(this,function(XRegExp,JSON5,fs,path$1,mkdirp,recast,babel,assert$1){'use strict';function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e};}var XRegExp__default=/*#__PURE__*/_interopDefaultLegacy(XRegExp);var JSON5__default=/*#__PURE__*/_interopDefaultLegacy(JSON5);var fs__default=/*#__PURE__*/_interopDefaultLegacy(fs);var path__default=/*#__PURE__*/_interopDefaultLegacy(path$1);var mkdirp__default=/*#__PURE__*/_interopDefaultLegacy(mkdirp);var recast__default=/*#__PURE__*/_interopDefaultLegacy(recast);var assert__default=/*#__PURE__*/_interopDefaultLegacy(assert$1);// Return TRUE if `src` starts with `searchString`. function startsWith(src,searchString){return src.substr(0,searchString.length)===searchString;}// tagged template string helper which removes the indentation common to all // non-empty lines: that indentation was added as part of the source code // formatting of this lexer spec file and must be removed to produce what @@ -14,62 +14,72 @@ function startsWith(src,searchString){return src.substr(0,searchString.length)== function rmCommonWS(strings,...values){// As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. -// +// // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. -var indent_str=null;var src=strings.map(function splitIntoLines(s){var a=s.split('\n');indent_str=a.reduce(function analyzeLine(indent_str,line,index){// only check indentation of parts which follow a NEWLINE: -if(index!==0){var m=/^(\s*)\S/.exec(line);// only non-empty ~ content-carrying lines matter re common indent calculus: +let indent_str=null;let src=strings.map(function splitIntoLines(s){let a=s.split('\n');indent_str=a.reduce(function analyzeLine(indent_str,line,index){// only check indentation of parts which follow a NEWLINE: +if(index!==0){let m=/^(\s*)\S/.exec(line);// only non-empty ~ content-carrying lines matter re common indent calculus: if(m){if(indent_str==null){indent_str=m[1];}else if(m[1].length start at j=1 rather than j=0 -for(var j=1,linecnt=a.length;j `'camelsHaveOneHump'` +for(let j=1,linecnt=a.length;j `'camelsHaveOneHump'` /** @public */function camelCase(s){// Convert first character to lowercase -return s.replace(/^\w/,function(match){return match.toLowerCase();}).replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// do not mutate 'a-2' to 'a2': -if(c===rv&&c.match(/\d/)){return match;}return rv;});}// Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers -/** @public */function mkIdentifier(s){s=''+s;return s// Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), +return s.replace(/^\w/,function(match){return match.toLowerCase();}).replace(/-\w/g,function(match){const c=match.charAt(1);const rv=c.toUpperCase();// do not mutate 'a-2' to 'a2': +if(c===rv&&c.match(/\d/)){return match;}return rv;});}// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords=(list=>{let rv=new Set();for(let w of list){//console.error('reserved word:', w); +rv.add(w);}return rv;})(['await','break','case','catch','class','const','continue','debugger','default','delete','do','else','enum','export','extends','finally','for','function','if','implements','import','in','instanceof','interface','new','package','private','protected','public','return','super','switch','this','throw','try','typeof','var','void','while','with','yield']);// Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers +/** @public */function mkIdentifier(s){s=''+s;let rv=s// Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` -.replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// mutate 'a-2' to 'a_2': +.replace(/-\w/g,function(match){let c=match.charAt(1);let rv=c.toUpperCase();// mutate 'a-2' to 'a_2': if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;})// cleanup: replace any non-suitable character series to a single underscore: .replace(/^([\d])/,'_$1')// where leading numbers are prefixed by an underscore: '1' --> '_1' .replace(/^[^\w_]/,'_')// do not accept numerics at the leading position, despite those matching regex `\w`: .replace(/^\d/,'_').replace(/[^\w\d_]/g,'_')// and only accept multiple (double, not triple) underscores at start or end of identifier name: -.replace(/^__+/,'#').replace(/__+$/,'#').replace(/_+/g,'_').replace(/#/g,'__');}// Check if the start of the given input matches a regex expression. +.replace(/^__+/,'#').replace(/__+$/,'#').replace(/_+/g,'_').replace(/#/g,'__');if(reservedWords.has(rv)){rv='_'+rv;}return rv;}// Check if the start of the given input matches a regex expression. // Return the length of the regex expression or -1 if none was found. /** @public */function scanRegExp(s){s=''+s;// code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` -var index=0;var length=s.length;var ch=s[index];//assert.assert(ch === '/', 'Regular expression literal must start with a slash'); -var str=s[index++];var classMarker=false;var terminated=false;while(index `'camelsHaveOneHump'` -let ref=s.replace(/-\w/g,function(match){var c=match.charAt(1);var rv=c.toUpperCase();// mutate 'a-2' to 'a_2': -if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;});var alt=mkIdentifier(s);return alt===ref;}// properly quote and escape the given input string -function dquote(s){var sq=s.indexOf('\'')>=0;var dq=s.indexOf('"')>=0;if(sq&&dq){s=s.replace(/"/g,'\\"');dq=false;}if(dq){s='\''+s+'\'';}else{s='"'+s+'"';}return s;}// +let ref=s.replace(/-\w/g,function(match){let c=match.charAt(1);let rv=c.toUpperCase();// mutate 'a-2' to 'a_2': +if(c===rv&&c.match(/\d/)){return'_'+match.substr(1);}return rv;});let alt=mkIdentifier(s);return alt===ref;}// properly quote and escape the given input string +function dquote(s){let sq=s.indexOf('\'')>=0;let dq=s.indexOf('"')>=0;if(sq&&dq){s=s.replace(/"/g,'\\"');dq=false;}if(dq){s='\''+s+'\'';}else{s='"'+s+'"';}return s;}// function chkBugger(src){src=String(src);if(src.match(/\bcov_\w+/)){console.error('### ISTANBUL COVERAGE CODE DETECTED ###\n',src);}}// Helper function: pad number with leading zeroes -function pad(n,p){p=p||2;var rv='0000'+n;return rv.slice(-p);}// attempt to dump in one of several locations: first winner is *it*! -function dumpSourceToFile(sourcecode,errname,err_id,options,ex){var dumpfile;options=options||{};try{var dumpPaths=[options.outfile?path__default['default'].dirname(options.outfile):null,options.inputPath,process.cwd()];var dumpName=path__default['default'].basename(options.inputFilename||options.moduleName||(options.outfile?path__default['default'].dirname(options.outfile):null)||options.defaultModuleName||errname).replace(/\.[a-z]{1,5}$/i,'')// remove extension .y, .yacc, .jison, ...whatever -.replace(/[^a-z0-9_]/ig,'_');// make sure it's legal in the destination filesystem: the least common denominator. -if(dumpName===''||dumpName==='_'){dumpName='__bugger__';}err_id=err_id||'XXX';var ts=new Date();var tm=ts.getUTCFullYear()+'_'+pad(ts.getUTCMonth()+1)+'_'+pad(ts.getUTCDate())+'T'+pad(ts.getUTCHours())+''+pad(ts.getUTCMinutes())+''+pad(ts.getUTCSeconds())+'.'+pad(ts.getUTCMilliseconds(),3)+'Z';dumpName+='.fatal_'+err_id+'_dump_'+tm+'.js';for(var i=0,l=dumpPaths.length;i'// '+l);d=d.join('\n');fs__default['default'].writeFileSync(dumpfile,sourcecode+'\n\n\n'+d,'utf8');console.error("****** offending generated "+errname+" source code dumped into file: ",dumpfile);break;// abort loop once a dump action was successful! +function pad(n,p){p=p||2;let rv='0000'+n;return rv.slice(-p);}function convertExceptionToObject(ex){if(!ex)return ex;// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error +// +// - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) +let rv=Object.assign({},ex);// - Set up the default fields which should ALWAYS be present: +rv.message=ex.message;rv.name=ex.name;rv.stack=ex.stack;// this assignment stringifies the stack trace in ex.stack. +// - Set the optional fields: +if(ex.code!==undefined)rv.code=ex.code;if(ex.type!==undefined)rv.type=ex.type;if(ex.fileName!==undefined)rv.fileName=ex.fileName;if(ex.lineNumber!==undefined)rv.lineNumber=ex.lineNumber;if(ex.columnNumber!==undefined)rv.columnNumber=ex.columnNumber;if(Array.isArray(ex.errors)){rv.errors=[];for(let se of ex.errors){rv.errors.push(convertExceptionToObject(se));}}return rv;}function find_suitable_app_dump_path(){return process.cwd().replace(/\\/g,'/').replace(/\/node_modules\/.*$/,m=>'/___nm___/').replace(/(\/jison\/)(.*)$/,(m,p1,p2)=>p1+'___'+p2.split('/').map(d=>d.charAt(0).toUpperCase()).join('_'));}// attempt to dump in one of several locations: first winner is *it*! +function dumpSourceToFile(sourcecode,errname,err_id,options,ex){let dumpfile;options=options||{};try{const dumpPaths=[options.outfile?path__default['default'].dirname(options.outfile):null,options.inputPath,find_suitable_app_dump_path()];let dumpName=path__default['default'].basename(options.inputFilename||options.moduleName||(options.outfile?path__default['default'].dirname(options.outfile):null)||options.defaultModuleName||errname).replace(/\.[a-z]{1,5}$/i,'')// remove extension .y, .yacc, .jison, ...whatever +.replace(/[^a-z0-9_]/ig,'_')// make sure it's legal in the destination filesystem: the least common denominator. +.substr(0,100);if(dumpName===''||dumpName==='_'){dumpName='__bugger__';}// generate a stacktrace for the dump no matter what: +if(!ex){try{throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this.");}catch(ex2){ex=ex2;}}err_id=err_id||'XXX';err_id=err_id.replace(/[^a-z0-9_]/ig,'_')// make sure it's legal in the destination filesystem: the least common denominator. +.substr(0,50);const ts=new Date();const tm=ts.getUTCFullYear()+'_'+pad(ts.getUTCMonth()+1)+'_'+pad(ts.getUTCDate())+'T'+pad(ts.getUTCHours())+''+pad(ts.getUTCMinutes())+''+pad(ts.getUTCSeconds())+'.'+pad(ts.getUTCMilliseconds(),3)+'Z';dumpName+='.fatal_'+err_id+'_dump_'+tm+'.js';for(let i=0,l=dumpPaths.length;i'[!circular ref!]'});// make sure each line is a comment line: +d=d.split('\n').map(l=>'// '+l);d=d.join('\n');mkdirp__default['default'](path__default['default'].dirname(dumpfile));fs__default['default'].writeFileSync(dumpfile,sourcecode+'\n\n\n'+d,'utf8');console.error('****** offending generated '+errname+' source code dumped into file: ',dumpfile);break;// abort loop once a dump action was successful! }catch(ex3){//console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); -if(i===l-1){throw ex3;}}}}catch(ex2){console.error("generated "+errname+" source code fatal DUMPING error: ",ex2.message," -- while attempting to dump into file: ",dumpfile,"\n",ex2.stack);}// augment the exception info, when available: +if(i===l-1){throw ex3;}}}}catch(ex2){console.error('generated '+errname+' source code fatal DUMPING error: ',ex2.message,' -- while attempting to dump into file: ',dumpfile,'\n',ex2.stack);}// augment the exception info, when available: if(ex){ex.offending_source_code=sourcecode;ex.offending_source_title=errname;ex.offending_source_dumpfile=dumpfile;}}// // `code_execution_rig` is a function which gets executed, while it is fed the `sourcecode` as a parameter. // When the `code_execution_rig` crashes, its failure is caught and (using the `options`) the sourcecode @@ -88,8 +98,12 @@ if(ex){ex.offending_source_code=sourcecode;ex.offending_source_title=errname;ex. // - options.moduleName // - options.defaultModuleName // -function exec_and_diagnose_this_stuff(sourcecode,code_execution_rig,options,title){options=options||{};var errname=""+(title||"exec_test");var err_id=errname.replace(/[^a-z0-9_]/ig,"_");if(err_id.length===0){err_id="exec_crash";}const debug=0;var p;try{// p = eval(sourcecode); -if(typeof code_execution_rig!=='function'){throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function");}chkBugger(sourcecode);p=code_execution_rig.call(this,sourcecode,options,errname,debug);}catch(ex){if(options.dumpSourceCodeOnFailure||1){dumpSourceToFile(sourcecode,errname,err_id,options,ex);}if(options.throwErrorOnCompileFailure){throw ex;}}return p;}var code_exec={exec:exec_and_diagnose_this_stuff,dump:dumpSourceToFile};// +function exec_and_diagnose_this_stuff(sourcecode,code_execution_rig,options,title){options=options||{};let errname=''+(title||'exec_test');let err_id=errname.replace(/[^a-z0-9_]/ig,'_');if(err_id.length===0){err_id='exec_crash';}const debug=options.debug||0;if(debug)console.warn('generated '+errname+' code under EXEC TEST.');if(debug>1){console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `);}let p;try{// p = eval(sourcecode); +if(typeof code_execution_rig!=='function'){throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function');}chkBugger(sourcecode);p=code_execution_rig.call(this,sourcecode,options,errname,debug);}catch(ex){if(debug>1)console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@');if(debug)console.log('generated '+errname+' source code fatal error: ',ex.message);if(debug>1)console.log('exec-and-diagnose options:',options);if(debug>1)console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@');if(options.dumpSourceCodeOnFailure||1){dumpSourceToFile(sourcecode,errname,err_id,options,ex);}if(options.throwErrorOnCompileFailure){throw ex;}}return p;}var exec={exec:exec_and_diagnose_this_stuff,dump:dumpSourceToFile,convertExceptionToObject};// assert__default['default'](recast__default['default']);//var types = recast.types; //assert(types); //var namedTypes = types.namedTypes; @@ -100,17 +114,17 @@ assert__default['default'](recast__default['default']);//var types = recast.type // WARNING: this regex MUST match the regex for `ID` in ebnf-parser::bnf.l jison language lexer spec! (`ID = [{ALPHA}]{ALNUM}*`) // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! -const ID_REGEX_BASE='[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*';// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +const ID_REGEX_BASE='[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*';// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: -const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode NonAsciiIdentifierStart characters +const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -118,37 +132,37 @@ const IN_ID_CHARSET='\\p{Alphabetic}_\\p{Number}';// Determine which Unicode Non function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); -// As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode +// As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: -// +// // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything -// between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is +// between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. -// +// // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. -// +// // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: -// +// // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A -// +// // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. -// -// To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to +// +// To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the -// first character is fixed and the second character is chosen such that the escape code -// DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input +// first character is fixed and the second character is chosen such that the escape code +// DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: -// -// - the first character is ဩ which is highly visible and allows us to quickly search through a +// +// - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -156,30 +170,30 @@ function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only wan // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will -// pick a different base shape from that CANADIAN SYLLABICS charset. -// - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to +// pick a different base shape from that CANADIAN SYLLABICS charset. +// - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ -// - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered +// - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: -// +// // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 -// - 1489-14A0: ᒉ 5 -// - 14A3-14BA: ᒣ 6 -// - 14C0-14CF: ᓀ +// - 1489-14A0: ᒉ 5 +// - 14A3-14BA: ᒣ 6 +// - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 -// - 1526-153D: ᔦ +// - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -190,58 +204,58 @@ function generateMapper4JisonGrammarIdentifiers(input){// IMPORTANT: we only wan // - 1622-162D: ᘢ // // ## JISON identifier formats ## -// +// // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. -// +// // -> (1+2) start-# + end-# -// +// // - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ -// +// // - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# -// +// // - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# -// +// // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - result location reference `@$` -// +// // -> (6) single-@ -// +// // - rule id number `#$` -// +// // -> (3) single-# -// +// // - result stack index `##$` -// +// // -> (4) double-# -// +// // - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -// +// // - 'negative index' location reference, e.g. `@-2` -// +// // -> (7) single-negative-@ -// +// // - 'negative index' stack indexes, e.g. `##-2` -// +// // -> (5) double-negative-# -// +// // count the number of occurrences of ch in src: -// +// // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -258,38 +272,38 @@ function countOccurrences(ch,src){let i=ch.codePointAt(0);return hash[i]||0;}// // Preferrably has ZERO occurrences in the given `input`, but otherwise // deliver the one with the least number of occurrences. function pickChar(set,input){// strip out the spaces: -set=set.replace(/\s+/g,'');assert__default['default'](set.length>=1);let lsidx=0;let lsfreq=Infinity;for(let i=0,l=set.length;i=1);let lsidx=0;let lsfreq=Infinity;for(let i=0,l=set.length;i (1+2) start-# + end-# -// +// // - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ -// +// // - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# -// +// // - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# -// +// // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required -// +// // - result location reference `@$` -// +// // -> (6) single-@ -// +// // - rule id number `#$` -// +// // -> (3) single-# -// +// // - result stack index `##$` -// +// // -> (4) double-# -// +// // - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -// +// // - 'negative index' location reference, e.g. `@-2` -// +// // -> (7) single-negative-@ -// +// // - 'negative index' stack indexes, e.g. `##-2` -// +// // -> (5) double-negative-# -// -const escChar=pickChar(escCharSet);let typeIdChar=[];for(let i=0,l=typeIdCharSets.length;i (1) start-# tokenDirectIdentifierStart:escChar+typeIdChar[0],tokenDirectIdentifierRe:new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`,'g'),// - alias/token value references, e.g. `$token`, `$2` -// +// // -> $ is an accepted starter, so no encoding required // - result value reference `$$` -// +// // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart:'$',tokenValueReferenceRe:new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`,'g'),// - alias/token location reference, e.g. `@token`, `@2` -// +// // -> (6) single-@ // - result location reference `@$` -// +// // -> (6) single-@ tokenLocationStart:escChar+typeIdChar[1],tokenLocationRe:new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`,'g'),// - alias/token id numbers, e.g. `#token`, `#2` -// +// // -> (3) single-# // - rule id number `#$` -// +// // -> (3) single-# tokenIdentifierStart:escChar+typeIdChar[2],tokenIdentifierRe:new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`,'g'),// - alias/token stack indexes, e.g. `##token`, `##2` -// +// // -> (4) double-# // - result stack index `##$` -// +// // -> (4) double-# tokenStackIndexStart:escChar+typeIdChar[3],tokenStackIndexRe:new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`,'g'),// - 'negative index' value references, e.g. `$-2` -// +// // -> (8) single-negative-$ -tokenNegativeValueReferenceStart:escChar+typeIdChar[4],tokenValueReferenceRe:new XRegExp__default['default'](`$-([0-9]+)`,'g'),// - 'negative index' location reference, e.g. `@-2` -// +tokenNegativeValueReferenceStart:escChar+typeIdChar[4],tokenValueReferenceRe:new XRegExp__default['default']('$-([0-9]+)','g'),// - 'negative index' location reference, e.g. `@-2` +// // -> (7) single-negative-@ -tokenNegativeLocationStart:escChar+typeIdChar[5],tokenNegativeLocationRe:new XRegExp__default['default'](`@-([0-9]+)`,'g'),// - 'negative index' stack indexes, e.g. `##-2` -// +tokenNegativeLocationStart:escChar+typeIdChar[5],tokenNegativeLocationRe:new XRegExp__default['default']('@-([0-9]+)','g'),// - 'negative index' stack indexes, e.g. `##-2` +// // -> (5) double-negative-# -tokenNegativeStackIndexStart:escChar+typeIdChar[6],tokenNegativeStackIndexRe:new XRegExp__default['default'](`#-([0-9]+)`,'g'),// combined regex for encoding direction +tokenNegativeStackIndexStart:escChar+typeIdChar[6],tokenNegativeStackIndexRe:new XRegExp__default['default']('#-([0-9]+)','g'),// combined regex for encoding direction tokenDetect4EncodeRe:new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`,'g'),// combined regex for decoding direction tokenDetect4DecodeRe:new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`,'g'),encode:function encodeJisonTokens(src,locationOffsetSpec){let re=this.tokenDetect4EncodeRe;// reset regex re.lastIndex=0;// patch `src` for the lookbehind emulation in the main regex used: src=' '+src;// Perform the encoding, one token at a time via callback function. -// +// // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. -// This is a tad sub-optimal as we won't be able to report errors early +// This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -412,35 +426,35 @@ if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax return src.substring(1);},decode:function decodeJisonTokens(src,locationOffsetSpec){let re=this.tokenDetect4DecodeRe;// reset regex re.lastIndex=0;// patch `src` for the lookbehind emulation in the main regex used: src=' '+src;// Perform the encoding, one token at a time via callback function. -// +// // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. -// This is a tad sub-optimal as we won't be able to report errors early +// This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src=src.replace(re,(m,p1,p2,p3,offset)=>{// p1 is only serving as lookbehind emulation -switch(p2){case this.tokenNegativeValueReferenceStart:return p1+"$-"+p3;case this.tokenNegativeStackIndexStart:return p1+"##-"+p3;case this.tokenStackIndexStart:return p1+"##"+p3;case this.tokenNegativeLocationStart:return p1+"@-"+p3;case this.tokenLocationStart:return p1+"@"+p3;case this.tokenDirectIdentifierStart:// p3 CANNOT be a negative value or token ID +switch(p2){case this.tokenNegativeValueReferenceStart:return p1+'$-'+p3;case this.tokenNegativeStackIndexStart:return p1+'##-'+p3;case this.tokenStackIndexStart:return p1+'##'+p3;case this.tokenNegativeLocationStart:return p1+'@-'+p3;case this.tokenLocationStart:return p1+'@'+p3;case this.tokenDirectIdentifierStart:// p3 CANNOT be a negative value or token ID if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: ${p2+p3+p4} is an illegal negative reference type`,src,offset+p1.length+p2.length);}return p1+p2+p3;}return p1+'#'+p3+'#';case this.tokenIdentifierStart:// p3 CANNOT be a negative value or token ID if(p3[0]==='-'){if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: ${p2+p3+p4} is an illegal negative reference type`,src,offset+p1.length+p2.length);}return p1+p2+p3;}return p1+'#'+p3;default:if(locationOffsetSpec){locationOffsetSpec.reportLocation(`syntax error: unexpected jison token sentinel escape ${p2} at ${p2+p3}`,src,offset+p1.length);}return p1+p2+p3;}});// and remove the added prefix which was used for lookbehind emulation: -return src.substring(1);}};}function parseCodeChunkToAST(src,options){src=src.replace(/@/g,'\uFFDA').replace(/#/g,'\uFFDB');var ast=recast__default['default'].parse(src);return ast;}function compileCodeToES5(src,options){options=Object.assign({},{ast:true,code:true,sourceMaps:true,comments:true,filename:'compileCodeToES5.js',sourceFileName:'compileCodeToES5.js',sourceRoot:'.',sourceType:'module',babelrc:false,ignore:["node_modules/**/*.js"],compact:false,retainLines:false,presets:[["@babel/preset-env",{targets:{browsers:["last 2 versions"],node:"8.0"}}]]},options);return babel.transformSync(src,options);// => { code, map, ast } -}function prettyPrintAST(ast,options){var options=options||{};const defaultOptions={tabWidth:2,quote:'single',arrowParensAlways:true,// Do not reuse whitespace (or anything else, for that matter) +return src.substring(1);}};}function parseCodeChunkToAST(src,options){src=src.replace(/@/g,'\uFFDA').replace(/#/g,'\uFFDB');const ast=recast__default['default'].parse(src);return ast;}function compileCodeToES5(src,options){options=Object.assign({},{ast:true,code:true,sourceMaps:true,comments:true,filename:'compileCodeToES5.js',sourceFileName:'compileCodeToES5.js',sourceRoot:'.',sourceType:'module',babelrc:false,ignore:['node_modules/**/*.js'],compact:false,retainLines:false,presets:[['@babel/preset-env',{targets:{browsers:['last 2 versions'],node:'8.0'}}]]},options);return babel.transformSync(src,options);// => { code, map, ast } +}function prettyPrintAST(ast,options){options=options||{};const defaultOptions={tabWidth:2,quote:'single',arrowParensAlways:true,// Do not reuse whitespace (or anything else, for that matter) // when printing generically. -reuseWhitespace:false};for(var key in defaultOptions){if(options[key]===undefined){options[key]=defaultOptions[key];}}let s=recast__default['default'].prettyPrint(ast,defaultOptions);let new_src=s.code;new_src=new_src.replace(/\r\n|\n|\r/g,'\n')// platform dependent EOL fixup +reuseWhitespace:false};for(let key in defaultOptions){if(options[key]===undefined){options[key]=defaultOptions[key];}}let s=recast__default['default'].prettyPrint(ast,defaultOptions);let new_src=s.code;new_src=new_src.replace(/\r\n|\n|\r/g,'\n')// platform dependent EOL fixup // backpatch possible jison variables extant in the prettified code: .replace(/\uFFDA/g,'@').replace(/\uFFDB/g,'#');return new_src;}// validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src,yylloc,options){// make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: -if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cnt);src=lines.join('\n')+src;}if(!src.trim()){return false;}try{var rv=parseCodeChunkToAST(src,options);return false;}catch(ex){return ex.message||"code snippet cannot be parsed";}}// The rough-and-ready preprocessor for any action code block: +if(yylloc&&yylloc.first_line>0){let cnt=yylloc.first_line;let lines=new Array(cnt);src=lines.join('\n')+src;}if(!src.trim()){return false;}try{let rv=parseCodeChunkToAST(src,options);return false;}catch(ex){return ex.message||'code snippet cannot be parsed';}}// The rough-and-ready preprocessor for any action code block: // this one trims off any surplus whitespace and removes any // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -448,7 +462,7 @@ if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cn // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -457,13 +471,13 @@ if(yylloc&&yylloc.first_line>0){var cnt=yylloc.first_line;var lines=new Array(cn // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// -function trimActionCode(src,startMarker){var s=src.trim();// remove outermost set of braces UNLESS there's +// +function trimActionCode(src,startMarker){let s=src.trim();// remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated // code analyzer to simplify the code! @@ -495,34 +509,34 @@ s=s.replace(/^\{([^]*?)\}$/,'$1').trim();}else{// code may not be wrapped or oth // wrapping braces when we can guarantee they're the only ones there, // i.e. only exist as outer wrapping. s=s.replace(/^\{([^}]*)\}$/,'$1').trim();}s=s.replace(/;+$/,'').trim();return s;}var parse2AST={generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST,compileCodeToES5,prettyPrintAST,checkActionBlock,trimActionCode,ID_REGEX_BASE,IN_ID_CHARSET};function chkBugger$1(src){src=String(src);if(src.match(/\bcov_\w+/)){console.error('### ISTANBUL COVERAGE CODE DETECTED ###\n',src);}}/// HELPER FUNCTION: print the function in source code form, properly indented. -/** @public */function printFunctionSourceCode(f){var src=String(f);chkBugger$1(src);return src;}const funcRe=/^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/;const arrowFuncRe=/^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/;/// HELPER FUNCTION: print the function **content** in source code form, properly indented, +/** @public */function printFunctionSourceCode(f){const src=String(f);chkBugger$1(src);return src;}const funcRe=/^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/;const arrowFuncRe=/^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/;/// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// -/** @public */function printFunctionSourceCodeContainer(f){var action=printFunctionSourceCode(f).trim();var args;// Also cope with Arrow Functions (and inline those as well?). +/// +/** @public */function printFunctionSourceCodeContainer(f){let action=printFunctionSourceCode(f).trim();let args;// Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 -var m=funcRe.exec(action);if(m){args=m[1].trim();action=m[2].trim();}else{m=arrowFuncRe.exec(action);if(m){if(m[2]){// non-bracketed arguments: +let m=funcRe.exec(action);if(m){args=m[1].trim();action=m[2].trim();}else{m=arrowFuncRe.exec(action);if(m){if(m[2]){// non-bracketed arguments: args=m[2].trim();}else{// bracketed arguments: may be empty args list! args=m[1].trim();}if(m[5]){// non-bracketed version: implicit `return` statement! // -// Q: Must we make sure we have extra braces around the return value -// to prevent JavaScript from inserting implit EOS (End Of Statement) +// Q: Must we make sure we have extra braces around the return value +// to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already // have formatted the code correctly. -action=m[4].trim();action='return '+action+';';}else{action=m[3].trim();}}else{var e=new Error('Cannot extract code from function');e.subject=action;throw e;}}return{args:args,code:action};}var stringifier={printFunctionSourceCode,printFunctionSourceCodeContainer};// -// -// -function detectIstanbulGlobal(){const gcv="__coverage__";const globalvar=new Function('return this')();var coverage=globalvar[gcv];return coverage||false;}// +action=m[4].trim();action='return '+action+';';}else{action=m[3].trim();}}else{const e=new Error('Cannot extract code from function');e.subject=action;throw e;}}return{args:args,code:action};}var stringifier={printFunctionSourceCode,printFunctionSourceCodeContainer};// +// +// +function detectIstanbulGlobal(){const gcv='__coverage__';const globalvar=new Function('return this')();const coverage=globalvar[gcv];return coverage||false;}// // Helper library for safe code execution/compilation // // MIT Licensed @@ -540,7 +554,7 @@ function detectIstanbulGlobal(){const gcv="__coverage__";const globalvar=new Fun // The default assumed is the standard JavaScript `RegExp` class. // // Return FALSE when there's no failure, otherwise return an `Error` info object. -function checkRegExp(re_src,re_flags,XRegExp){var re;// were we fed a RegExp object or a string? +function checkRegExp(re_src,re_flags,XRegExp){let re;// were we fed a RegExp object or a string? if(re_src&&typeof re_src.source==='string'&&typeof re_src.flags==='string'&&typeof re_src.toString==='function'&&typeof re_src.test==='function'&&typeof re_src.exec==='function'){// we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member // and the `.toString()` method to produce something that's compileable by XRegExp // at least... @@ -554,7 +568,7 @@ if(re_src==null){return new Error('invalid regular expression source: '+re_src); // The default assumed is the standard JavaScript `RegExp` class. // // Return FALSE when the input is not a legal regex. -function getRegExpInfo(re_src,re_flags,XRegExp){var re1,re2,m1,m2;// were we fed a RegExp object or a string? +function getRegExpInfo(re_src,re_flags,XRegExp){let re1,re2,m1,m2;// were we fed a RegExp object or a string? if(re_src&&typeof re_src.source==='string'&&typeof re_src.flags==='string'&&typeof re_src.toString==='function'&&typeof re_src.test==='function'&&typeof re_src.exec==='function'){// we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member // and the `.toString()` method to produce something that's compileable by XRegExp // at least... @@ -566,33 +580,42 @@ return false;}else{re_src=''+re_src;if(re_flags==null){re_flags=undefined;// `ne // wrap it and append `(?:)` to ensure it matches // the empty string, then match it against it to // obtain the `match` array. -re1=new XRegExp(re_src,re_flags);re2=new XRegExp('(?:'+re_src+')|(?:)',re_flags);m1=re1.exec('');m2=re2.exec('');return{acceptsEmptyString:!!m1,captureCount:m2.length-1};}catch(ex){return false;}}var reHelpers={checkRegExp:checkRegExp,getRegExpInfo:getRegExpInfo};var cycleref=[];var cyclerefpath=[];var linkref=[];var linkrefpath=[];var path=[];function shallow_copy(src){if(typeof src==='object'){if(src instanceof Array){return src.slice();}var dst={};if(src instanceof Error){dst.name=src.name;dst.message=src.message;dst.stack=src.stack;}for(var k in src){if(Object.prototype.hasOwnProperty.call(src,k)){dst[k]=src[k];}}return dst;}return src;}function shallow_copy_and_strip_depth(src,parentKey){if(typeof src==='object'){var dst;if(src instanceof Array){dst=src.slice();for(var i=0,len=dst.length;i '+parentKey+'.'+k+']';}else{dst[k]=src[k];}}}}return dst;}return src;}function stripErrorStackPaths(msg){// strip away devbox-specific paths in error stack traces in the output: -msg=msg.replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi,'at $1(/$2)').replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi,'at /$1');return msg;}function trim_array_tail(arr){if(arr instanceof Array){for(var len=arr.length;len>0;len--){if(arr[len-1]!=null){break;}}arr.length=len;}}function treat_value_stack(v){if(v instanceof Array){var idx=cycleref.indexOf(v);if(idx>=0){v='[cyclic reference to parent array --> '+cyclerefpath[idx]+']';}else{idx=linkref.indexOf(v);if(idx>=0){v='[reference to sibling array --> '+linkrefpath[idx]+', length = '+v.length+']';}else{cycleref.push(v);cyclerefpath.push(path.join('.'));linkref.push(v);linkrefpath.push(path.join('.'));v=treat_error_infos_array(v);cycleref.pop();cyclerefpath.pop();}}}else if(v){v=treat_object(v);}return v;}function treat_error_infos_array(arr){var inf=arr.slice();trim_array_tail(inf);for(var key=0,len=inf.length;key '+parentKey+'.'+k+']';}else{dst[k]=src[k];}}}}return dst;}return src;}// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. +function stripErrorStackPaths(msg){// strip away devbox-specific paths in error stack traces in the output: +// and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': +msg=msg.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi,'at $1(/$2:$3)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi,'at /$1:$2');return msg;}// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj){if(typeof obj==='string'){// and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': +let msg=obj.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi,'at $1(/$2)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi,'at /$1');return msg;}if(obj){if(obj.stack){obj.stack=cleanStackTrace4Comparison(obj.stack);}let keys=Object.keys(obj);for(let i in keys){let key=keys[i];let el=obj[key];cleanStackTrace4Comparison(el);}}return obj;}function trim_array_tail(arr){if(arr instanceof Array){for(var len=arr.length;len>0;len--){if(arr[len-1]!=null){break;}}arr.length=len;}}function treat_value_stack(v){if(v instanceof Array){let idx=cycleref.indexOf(v);if(idx>=0){v='[cyclic reference to parent array --> '+cyclerefpath[idx]+']';}else{idx=linkref.indexOf(v);if(idx>=0){v='[reference to sibling array --> '+linkrefpath[idx]+', length = '+v.length+']';}else{cycleref.push(v);cyclerefpath.push(path.join('.'));linkref.push(v);linkrefpath.push(path.join('.'));v=treat_error_infos_array(v);cycleref.pop();cyclerefpath.pop();}}}else if(v){v=treat_object(v);}return v;}function treat_error_infos_array(arr){let inf=arr.slice();trim_array_tail(inf);for(let key=0,len=inf.length;key=0){// cyclic reference, most probably an error instance. +e=shallow_copy(e);if(e&&e.hash){path.push('hash');e.hash=treat_hash(e.hash);path.pop();}if(e.parser){path.push('parser');e.parser=treat_parser(e.parser);path.pop();}if(e.lexer){path.push('lexer');e.lexer=treat_lexer(e.lexer);path.pop();}if(e.__error_infos){path.push('__error_infos');e.__error_infos=treat_value_stack(e.__error_infos);path.pop();}if(e.__error_recovery_infos){path.push('__error_recovery_infos');e.__error_recovery_infos=treat_value_stack(e.__error_recovery_infos);path.pop();}trim_array_tail(e.symbol_stack);trim_array_tail(e.state_stack);trim_array_tail(e.location_stack);if(e.value_stack){path.push('value_stack');e.value_stack=treat_value_stack(e.value_stack);path.pop();}return e;}function treat_object(e){if(e&&typeof e==='object'){let idx=cycleref.indexOf(e);if(idx>=0){// cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: e=shallow_copy_and_strip_depth(e,cyclerefpath[idx]);}else{idx=linkref.indexOf(e);if(idx>=0){e='[reference to sibling --> '+linkrefpath[idx]+']';}else{cycleref.push(e);cyclerefpath.push(path.join('.'));linkref.push(e);linkrefpath.push(path.join('.'));e=treat_error_report_info(e);cycleref.pop();cyclerefpath.pop();}}}return e;}// strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. -function trimErrorForTestReporting(e){cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];if(e){e=treat_object(e);}cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];return e;}var helpers={rmCommonWS,camelCase,mkIdentifier,isLegalIdentifierInput,scanRegExp,dquote,trimErrorForTestReporting,stripErrorStackPaths,checkRegExp:reHelpers.checkRegExp,getRegExpInfo:reHelpers.getRegExpInfo,exec:code_exec.exec,dump:code_exec.dump,generateMapper4JisonGrammarIdentifiers:parse2AST.generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST:parse2AST.parseCodeChunkToAST,compileCodeToES5:parse2AST.compileCodeToES5,prettyPrintAST:parse2AST.prettyPrintAST,checkActionBlock:parse2AST.checkActionBlock,trimActionCode:parse2AST.trimActionCode,ID_REGEX_BASE:parse2AST.ID_REGEX_BASE,IN_ID_CHARSET:parse2AST.IN_ID_CHARSET,printFunctionSourceCode:stringifier.printFunctionSourceCode,printFunctionSourceCodeContainer:stringifier.printFunctionSourceCodeContainer,detectIstanbulGlobal};// See also: +function trimErrorForTestReporting(e){cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];if(e){e=treat_object(e);}cycleref.length=0;cyclerefpath.length=0;linkref.length=0;linkrefpath.length=0;path=['*'];return e;}var helpers={rmCommonWS,camelCase,mkIdentifier,isLegalIdentifierInput,scanRegExp,dquote,trimErrorForTestReporting,stripErrorStackPaths,cleanStackTrace4Comparison,checkRegExp:reHelpers.checkRegExp,getRegExpInfo:reHelpers.getRegExpInfo,exec:exec.exec,dump:exec.dump,convertExceptionToObject:exec.convertExceptionToObject,generateMapper4JisonGrammarIdentifiers:parse2AST.generateMapper4JisonGrammarIdentifiers,parseCodeChunkToAST:parse2AST.parseCodeChunkToAST,compileCodeToES5:parse2AST.compileCodeToES5,prettyPrintAST:parse2AST.prettyPrintAST,checkActionBlock:parse2AST.checkActionBlock,trimActionCode:parse2AST.trimActionCode,ID_REGEX_BASE:parse2AST.ID_REGEX_BASE,IN_ID_CHARSET:parse2AST.IN_ID_CHARSET,printFunctionSourceCode:stringifier.printFunctionSourceCode,printFunctionSourceCodeContainer:stringifier.printFunctionSourceCodeContainer,detectIstanbulGlobal};// 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. -function JisonParserError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonParserError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8/Chrome engine +function JisonParserError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonParserError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){let ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8/Chrome engine Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonParserError.prototype,Error.prototype);}else{JisonParserError.prototype=Object.create(Error.prototype);}JisonParserError.prototype.constructor=JisonParserError;JisonParserError.prototype.name='JisonParserError';// helper: reconstruct the productions[] table -function bp(s){var rv=[];var p=s.pop;var r=s.rule;for(var i=0,l=p.length;i1){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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) +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 delimited set of lexer start conditions';break;case 37:/*! Production:: start_productions_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -yy.__options_flags__=0;yy.__options_category_description__='the lexer rules definition section';break;case 38:/*! Production:: start_epilogue_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -yy.__options_flags__=0;yy.__options_category_description__='the lexer epilogue section';break;case 39:/*! Production:: rules : rules scoped_rules_collective */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1].concat(yyvstack[yysp]);break;case 40:/*! Production:: rules : rules rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1].concat([yyvstack[yysp]]);break;case 41:/*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 30:/*! Production:: option_keyword : OPTIONS */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__=yyvstack[yysp];break;case 31:/*! Production:: import_keyword : IMPORT */case 33:/*! Production:: include_keyword : INCLUDE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS;yy.__options_category_description__=yyvstack[yysp];break;case 32:/*! Production:: init_code_keyword : CODE */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS|OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS;yy.__options_category_description__=yyvstack[yysp];break;case 34:/*! Production:: start_inclusive_keyword : START_INC */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__='the inclusive lexer start conditions set (%s)';break;case 35:/*! Production:: start_exclusive_keyword : START_EXC */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES;yy.__options_category_description__='the exclusive lexer start conditions set (%x)';break;case 36:/*! Production:: start_conditions_marker : "<" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=OPTION_DOES_NOT_ACCEPT_VALUE|OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES|OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME;yy.__options_category_description__='the <...> delimited set of lexer start conditions';break;case 37:/*! Production:: start_productions_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=0;yy.__options_category_description__='the lexer rules definition section';break;case 38:/*! Production:: start_epilogue_marker : "%%" */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +yy.__options_flags__=0;yy.__options_category_description__='the lexer epilogue section';break;case 39:/*! Production:: rules : rules scoped_rules_collective */ // 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].concat(yyvstack[yysp]);break;case 40:/*! Production:: rules : rules rule */ // 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].concat([yyvstack[yysp]]);break;case 41:/*! Production:: rules : rules 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]);if(srcCode){var rv=checkActionBlock$1(srcCode,yylstack[yysp-1],yy);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);}this.$=yyvstack[yysp-3];break;case 42:/*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);}yy.actionInclude.push(srcCode);}this.$=yyvstack[yysp-3];break;case 42:/*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. -this.$=yyvstack[yysp-1];break;case 43:/*! Production:: rules : rules ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) +this.$=yyvstack[yysp-1];break;case 43:/*! Production:: rules : rules ACTION_START_AT_SOL 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,-,-) 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. @@ -1036,8 +1059,8 @@ var start_marker=yyvstack[yysp-1].trim();var marker_msg=start_marker?' or simila Technical error report: ${yyvstack[yysp].errStr} - `);this.$=yyvstack[yysp-2];break;case 44:/*! Production:: rules : rules ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);this.$=yyvstack[yysp-2];break;case 44:/*! Production:: rules : rules 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,-,-) 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: @@ -1065,8 +1088,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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 the top section of the lexer spec file, above the first '%%' @@ -1075,14 +1098,14 @@ yyparser.yyError(rmCommonWS$1` Erroneous code: ${yylexer.prettyPrintRange(yylstack[yysp])} - `);this.$=yyvstack[yysp-1];break;case 51:/*! Production:: rules : %epsilon */case 58:/*! Production:: rule_block : %epsilon */ // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) -this.$=[];break;case 52:/*! Production:: scoped_rules_collective : start_conditions rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -if(yyvstack[yysp-1]){yyvstack[yysp].unshift(yyvstack[yysp-1]);}this.$=[yyvstack[yysp]];break;case 53:/*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) -if(yyvstack[yysp-3]){yyvstack[yysp-1].forEach(function(d){d.unshift(yyvstack[yysp-3]);});}this.$=yyvstack[yysp-1];break;case 54:/*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp-3];this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + `);this.$=yyvstack[yysp-1];break;case 51:/*! Production:: rules : %epsilon */case 58:/*! Production:: rule_block : %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 52:/*! Production:: scoped_rules_collective : start_conditions rule */ // 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,-,-) +if(yyvstack[yysp-1]){yyvstack[yysp].unshift(yyvstack[yysp-1]);}this.$=[yyvstack[yysp]];break;case 53:/*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ // 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,-,-) +if(yyvstack[yysp-3]){yyvstack[yysp-1].forEach(function(d){d.unshift(yyvstack[yysp-3]);});}this.$=yyvstack[yysp-1];break;case 54:/*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): +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$1` Seems you made a mistake while specifying one of the lexer rules inside the start condition @@ -1094,8 +1117,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp-1].errStr} - `);break;case 55:/*! Production:: scoped_rules_collective : start_conditions "{" error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 55:/*! Production:: scoped_rules_collective : start_conditions "{" 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,-,-) yyparser.yyError(rmCommonWS$1` Seems you did not correctly bracket a lexer rules set inside the start condition @@ -1107,8 +1130,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 56:/*! Production:: scoped_rules_collective : start_conditions error "}" */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 56:/*! Production:: scoped_rules_collective : start_conditions 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,-,-) yyparser.yyError(rmCommonWS$1` Seems you did not correctly bracket a lexer rules set inside the start condition @@ -1120,17 +1143,17 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp-1].errStr} - `);break;case 57:/*! Production:: rule_block : rule_block rule */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 57:/*! Production:: rule_block : rule_block rule */ // 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.$.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` 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 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 // will uncover any illegal action code following the arrow operator, e.g. // multiple statements separated by semicolon. @@ -1151,8 +1174,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 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.: @@ -1167,8 +1190,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 63:/*! Production:: rule : regex ACTION_START error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);break;case 63:/*! Production:: rule : regex 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,-,-) // TODO: REWRITE this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` A lexer rule regex action code must be properly terminated and must contain a JavaScript statement block (or anything that does parse as such), e.g.: @@ -1185,8 +1208,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 64:/*! Production:: rule : regex ACTION_START_AT_SOL error */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);break;case 64:/*! Production:: rule : regex ACTION_START_AT_SOL 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,-,-) // TODO: REWRITE this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` A lexer rule regex action code must be properly terminated and must contain a JavaScript statement block (or anything that does parse as such), e.g.: @@ -1222,8 +1245,8 @@ this.$=[yyvstack[yysp-2],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 65:/*! Production:: rule : regex error */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);break;case 65:/*! Production:: rule : regex 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,-,-) this.$=[yyvstack[yysp-1],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Lexer rule regex action code declaration error? @@ -1232,33 +1255,33 @@ this.$=[yyvstack[yysp-1],yyvstack[yysp]];yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 66:/*! Production:: action : action ACTION_BODY */case 83:/*! Production:: regex_concat : regex_concat regex_base */case 95:/*! Production:: regex_base : regex_base range_regex */case 106:/*! Production:: regex_set : regex_set regex_set_atom */case 127:/*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+yyvstack[yysp];break;case 67:/*! Production:: action : action include_macro_code */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'\n\n'+yyvstack[yysp]+'\n\n';break;case 68:/*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 66:/*! Production:: action : action ACTION_BODY */case 83:/*! Production:: regex_concat : regex_concat regex_base */case 95:/*! Production:: regex_base : regex_base range_regex */case 106:/*! Production:: regex_set : regex_set regex_set_atom */case 127:/*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ // 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]+yyvstack[yysp];break;case 67:/*! Production:: action : action 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]+'\n\n'+yyvstack[yysp]+'\n\n';break;case 68:/*! Production:: action : action INCLUDE_PLACEMENT_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` You may place the '%include' instruction only at the start/front of a line. Its use is not permitted at this position: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 69:/*! Production:: action : action BRACKET_MISSING */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 69:/*! Production:: action : action BRACKET_MISSING */ // 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` Missing curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: '{ ... }'. Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 70:/*! Production:: action : action BRACKET_SURPLUS */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 70:/*! Production:: action : action BRACKET_SURPLUS */ // 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` Too many curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: '{ ... }'. Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 71:/*! Production:: action : action UNTERMINATED_STRING_ERROR */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 71:/*! Production:: action : action UNTERMINATED_STRING_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` Unterminated string constant in lexer rule action block. @@ -1267,10 +1290,10 @@ yyparser.yyError(rmCommonWS$1` Offending action body: ${yylexer.prettyPrintRange(yylstack[yysp],yylstack[yysp-3])} - `);break;case 72:/*! Production:: action : %epsilon */case 77:/*! Production:: regex_list : %epsilon */ // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(null,null,null,null,true);// END of default action (generated by JISON mode classic/merge :: 0,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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-3,yysp);// END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + `);break;case 72:/*! Production:: action : %epsilon */case 77:/*! Production:: regex_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 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 // accordingly: @@ -1291,8 +1314,8 @@ 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,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,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` Seems you did not correctly terminate the start condition set @@ -1304,8 +1327,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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; // we *do* consider escaped characters which are 'alphanumeric' // to be equivalent to their non-escaped version, hence these are @@ -1344,22 +1367,22 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+'|'+yyvstack[yysp];break;case 79:/*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'|';break;case 80:/*! Production:: nonempty_regex_list : "|" regex_concat */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='|'+yyvstack[yysp];break;case 81:/*! Production:: nonempty_regex_list : "|" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='|';break;case 85:/*! Production:: regex_base : "(" regex_list ")" */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$='('+yyvstack[yysp-1]+')';break;case 86:/*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+')';break;case 87:/*! Production:: regex_base : "(" regex_list error */case 88:/*! Production:: regex_base : SPECIAL_GROUP regex_list error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) +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,-,-): +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,-,-) +this.$=yyvstack[yysp-2]+'|'+yyvstack[yysp];break;case 79:/*! Production:: nonempty_regex_list : nonempty_regex_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,-,-) +this.$=yyvstack[yysp-1]+'|';break;case 80:/*! Production:: nonempty_regex_list : "|" regex_concat */ // 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];break;case 81:/*! Production:: 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,-,-) +this.$='|';break;case 85:/*! Production:: regex_base : "(" regex_list ")" */ // 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-1]+')';break;case 86:/*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ // 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-1]+')';break;case 87:/*! Production:: regex_base : "(" regex_list error */case 88:/*! Production:: regex_base : SPECIAL_GROUP regex_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,-,-) yyparser.yyError(rmCommonWS$1` Seems you did not correctly bracket a lex rule regex part in '(...)' braces. @@ -1368,30 +1391,30 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 89:/*! Production:: regex_base : regex_base "+" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'+';break;case 90:/*! Production:: regex_base : regex_base "*" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'*';break;case 91:/*! Production:: regex_base : regex_base "?" */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-1]+'?';break;case 92:/*! Production:: regex_base : "/" regex_base */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='(?='+yyvstack[yysp]+')';break;case 93:/*! Production:: regex_base : "/!" regex_base */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) -this.$='(?!'+yyvstack[yysp]+')';break;case 94:/*! Production:: regex_base : name_expansion */case 96:/*! Production:: regex_base : any_group_regex */case 100:/*! Production:: regex_base : REGEX_SPECIAL_CHAR */case 101:/*! Production:: regex_base : literal_string */case 107:/*! Production:: regex_set : regex_set_atom */case 108:/*! Production:: regex_set_atom : REGEX_SET */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): -this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) -break;case 97:/*! Production:: regex_base : "." */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='.';break;case 98:/*! Production:: regex_base : "^" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='^';break;case 99:/*! Production:: regex_base : "$" */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$='$';break;case 102:/*! Production:: regex_base : ESCAPED_CHAR */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp]));break;case 104:/*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) -this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+yyvstack[yysp];break;case 105:/*! Production:: any_group_regex : REGEX_SET_START regex_set error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);break;case 89:/*! Production:: regex_base : regex_base "+" */ // 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]+'+';break;case 90:/*! Production:: regex_base : regex_base "*" */ // 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]+'*';break;case 91:/*! Production:: regex_base : regex_base "?" */ // 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]+'?';break;case 92:/*! Production:: regex_base : "/" regex_base */ // 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]+')';break;case 93:/*! Production:: regex_base : "/!" regex_base */ // 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]+')';break;case 94:/*! Production:: regex_base : name_expansion */case 96:/*! Production:: regex_base : any_group_regex */case 100:/*! Production:: regex_base : REGEX_SPECIAL_CHAR */case 101:/*! Production:: regex_base : literal_string */case 107:/*! Production:: regex_set : regex_set_atom */case 108:/*! Production:: regex_set_atom : REGEX_SET */ // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): +this.$=yyvstack[yysp];this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) +break;case 97:/*! Production:: regex_base : "." */ // 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.$='.';break;case 98:/*! Production:: regex_base : "^" */ // 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.$='^';break;case 99:/*! Production:: regex_base : "$" */ // 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.$='$';break;case 102:/*! Production:: regex_base : ESCAPED_CHAR */ // 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.$=encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp]));break;case 104:/*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_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,-,-) +this.$=yyvstack[yysp-2]+yyvstack[yysp-1]+yyvstack[yysp];break;case 105:/*! Production:: any_group_regex : REGEX_SET_START regex_set 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,-,-) yyparser.yyError(rmCommonWS$1` Seems you did not correctly bracket a lex rule regex set in '[...]' brackets. @@ -1400,16 +1423,16 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 109:/*! Production:: regex_set_atom : name_expansion */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + `);break;case 109:/*! Production:: regex_set_atom : name_expansion */ // 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,-,-) if(XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g,''))&&yyvstack[yysp].toUpperCase()!==yyvstack[yysp]){// treat this as part of an XRegExp `\p{...}` Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) +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,-,-): +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,-,-): +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` You may only specify one name/argument in a ${yy.__options_category_description__} statement. @@ -1424,28 +1447,28 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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` You may only specify one name/argument in a ${yy.__options_category_description__} statement. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp]),yylstack[yysp-3])} - `);}this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 115:/*! Production:: option_list : option */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=[yyvstack[yysp]];break;case 116:/*! Production:: option : option_name */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=[yyvstack[yysp],true];break;case 117:/*! Production:: option : option_name "=" option_value */ // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);}this.$=yyvstack[yysp-1];this.$.push(yyvstack[yysp]);break;case 115:/*! Production:: option_list : option */ // 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 116:/*! Production:: option : 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,-,-) +this.$=[yyvstack[yysp],true];break;case 117:/*! Production:: option : option_name "=" option_value */ // 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_VALUE){yyparser.yyError(rmCommonWS$1` The entries in a ${yy.__options_category_description__} statement MUST NOT be assigned values, such as '${$option_name}=${$option_value}'. Erroneous area: ${yylexer.prettyPrintRange(yylexer.deriveLocationInfo(yylstack[yysp],yylstack[yysp-2]),yylstack[yysp-4])} - `);}this.$=[yyvstack[yysp-2],yyvstack[yysp]];break;case 118:/*! Production:: option : option_name "=" error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);}this.$=[yyvstack[yysp-2],yyvstack[yysp]];break;case 118:/*! Production:: option : option_name "=" 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$1` Internal error: option "${$option}" value assignment failure in a ${yy.__options_category_description__} statement. @@ -1455,8 +1478,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 119:/*! Production:: option : DUMMY3 error */ // default action (generated by JISON mode classic/merge :: 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,VT,VA,-,-,LT,LA,-,-) + `);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` Expected a valid option name${with_value_msg} in a ${yy.__options_category_description__} statement. @@ -1465,8 +1488,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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: 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 @@ -1480,8 +1503,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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` Expected a valid name/argument${with_value_msg} in a ${yy.__options_category_description__} statement. @@ -1491,21 +1514,21 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) -this.$=parseValue(yyvstack[yysp]);break;case 124:/*! Production:: epilogue : start_epilogue_marker */ // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,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,-,-) +this.$=parseValue(yyvstack[yysp]);break;case 124:/*! Production:: epilogue : start_epilogue_marker */ // 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.$='';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` 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,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,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. @@ -1514,8 +1537,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} - `);break;case 128:/*! Production:: epilogue_chunks : epilogue_chunks error */ // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + `);break;case 128:/*! Production:: epilogue_chunks : epilogue_chunks 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$1` Module code declaration error? @@ -1525,8 +1548,8 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + `);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` The '%{...%}' lexer epilogue code chunk does not compile: ${rv} @@ -1535,8 +1558,8 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yyparser.yyMergeLocationInfo(yysp-1,yysp);// END of default action (generated by JISON mode classic/merge :: 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` There's very probably a problem with this '%{...%}' lexer setup action code section. @@ -1545,12 +1568,12 @@ 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,VT,VA,VU,-,LT,LA,-,-): -this._$=yylstack[yysp];// END of default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,LU,LUbA): -this._$=yyparser.yyMergeLocationInfo(yysp-2,yysp);// END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA) +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`: path=lst[0][0];}else if(len<=1){yyparser.yyError(rmCommonWS$1` @@ -1577,8 +1600,8 @@ var fileContent=fs__default['default'].readFileSync(path,{encoding:'utf-8'});var 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,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,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. @@ -1588,14 +1611,14 @@ yyparser.yyError(rmCommonWS$1` Technical error report: ${yyvstack[yysp].errStr} `);break;}},table:bt({len:u([15,1,14,21,1,13,28,22,s,[9,3],13,1,9,13,c,[6,3],27,s,[31,5],1,44,4,1,13,6,25,24,25,23,23,17,17,s,[24,8],26,5,24,24,9,13,8,9,1,s,[9,5],13,9,13,c,[3,3],c,[13,3],2,1,26,26,9,26,c,[5,3],s,[26,4],7,24,4,5,8,c,[60,3],c,[59,3],s,[24,5],2,3,2,25,25,6,s,[4,3],13,7,8,4,8,13,13,s,[7,6],9,5,s,[13,3],9,1,13,9,26,26,6,1,5,9,5,5,26,17,c,[85,4],27,10,s,[24,7],4,s,[8,3],9,7,9,1,1,26,5,c,[30,3],23,27,26,9,27,9,27,9,27,1,16,7,1,13,13,5,26,15,26,s,[27,3],16,13]),symbol:u([1,2,19,22,s,[24,6,1],31,32,33,55,57,1,c,[16,13],58,c,[14,13],56,s,[59,4,1],64,65,67,c,[36,14],1,2,3,7,8,s,[13,4,1],c,[19,10],s,[40,6,1],49,50,69,2,c,[26,6],c,[16,8],75,s,[77,5,1],85,2,11,51,52,53,s,[86,4,1],c,[9,10],23,30,s,[35,5,1],73,c,[90,13],2,c,[32,9],c,[23,14],c,[63,17],c,[144,40],c,[27,5],11,c,[28,22],c,[75,3],c,[31,125],1,c,[182,25],c,[373,5],s,[66,5,2],c,[320,7],90,1,33,68,90,20,c,[276,14],7,20,22,25,34,c,[367,3],9,c,[68,4],c,[12,4],c,[62,8],c,[370,6],c,[25,19],c,[24,8],s,[10,7,1],c,[27,10],48,49,50,84,c,[49,8],c,[45,8],s,[76,6,1],c,[72,9],c,[23,15],c,[485,13],c,[17,21],c,[105,24],c,[24,189],s,[46,5,1],44,47,80,82,83,c,[79,48],11,17,21,c,[500,3],c,[729,18],17,21,25,c,[24,3],c,[8,3],18,c,[9,6],c,[10,10],c,[9,26],c,[76,22],c,[849,7],63,93,c,[796,15],c,[13,11],c,[57,22],c,[22,9],21,11,17,c,[95,4],c,[10,4],25,c,[670,27],c,[26,26],c,[981,10],c,[35,26],c,[88,52],c,[26,105],2,22,24,54,91,92,2,4,c,[1221,14],72,c,[1222,8],c,[465,3],c,[35,5],c,[1158,8],c,[8,4],c,[1307,14],c,[912,78],c,[760,117],9,2,7,9,c,[5,4],c,[152,47],84,2,44,46,47,80,83,c,[6,4],c,[4,8],c,[614,14],c,[602,6],c,[754,9],52,53,c,[12,9],c,[689,26],c,[592,7],c,[7,35],c,[1571,14],c,[82,26],c,[430,14],c,[688,8],2,c,[842,23],c,[580,56],92,c,[534,3],c,[7,3],c,[1765,11],c,[14,3],c,[5,6],c,[794,26],5,c,[630,14],71,5,c,[159,10],c,[9,17],s,[1,4,2],c,[72,24],c,[976,9],c,[628,48],c,[24,121],c,[560,4],c,[1290,10],c,[8,13],c,[205,9],c,[495,14],63,93,21,21,c,[388,31],c,[5,5],c,[1301,11],c,[14,3],c,[354,15],c,[984,8],c,[333,27],c,[100,26],c,[549,11],c,[62,25],c,[36,72],6,c,[1170,16],c,[53,7],21,c,[744,28],c,[621,29],c,[266,15],c,[745,28],c,[284,27],c,[27,52],c,[203,16],c,[182,13]]),type:u([s,[2,13],0,0,1,c,[16,14],c,[30,15],s,[0,6],s,[2,41],c,[42,16],c,[64,12],c,[9,18],c,[49,19],c,[32,16],c,[22,19],c,[145,45],s,[2,181],s,[0,18],c,[20,4],c,[62,45],c,[25,24],c,[441,40],c,[442,13],c,[23,31],c,[17,34],c,[416,210],c,[57,111],c,[76,42],c,[98,34],c,[57,22],c,[22,10],c,[165,66],c,[509,189],c,[756,25],c,[740,56],c,[912,70],c,[286,136],c,[25,29],c,[275,31],c,[240,14],c,[227,82],c,[1144,56],c,[53,22],c,[775,59],c,[58,15],c,[149,63],c,[1837,18],c,[81,35],c,[628,51],c,[1393,171],c,[197,47],c,[268,26],c,[272,64],c,[62,36],c,[36,72],s,[2,226]]),state:u([s,[1,5,1],13,15,16,8,9,6,s,[25,4,2],32,37,38,43,49,51,52,54,58,c,[4,3],60,63,c,[5,3],65,c,[4,3],67,c,[4,3],77,79,80,75,76,85,81,70,71,82,83,c,[38,6],69,81,87,90,c,[8,4],91,c,[4,3],95,97,98,c,[20,5],99,c,[7,6],100,c,[4,3],101,c,[4,3],105,102,103,108,52,54,c,[3,3],119,114,c,[8,6],c,[3,3],127,130,132,136,c,[66,7],143,c,[87,3],144,c,[67,9],95,95,105,151,152,52,54,153,155,c,[22,3],157,119,114,161,163,165,168,170,172,c,[49,3],c,[29,4],c,[67,5],119,114,182,c,[57,7],c,[12,4],119,114]),mode:u([s,[2,27],s,[1,13],c,[27,15],c,[53,38],c,[66,27],c,[46,12],c,[65,23],s,[2,197],c,[271,26],c,[340,23],c,[25,4],c,[27,6],c,[264,10],c,[20,20],c,[12,5],c,[66,18],c,[89,5],c,[102,14],s,[1,38],s,[2,218],c,[220,50],c,[274,30],c,[25,6],c,[85,37],c,[736,26],c,[52,52],c,[427,61],c,[54,34],c,[515,158],c,[696,29],c,[1120,25],c,[845,62],c,[689,122],c,[1055,8],c,[151,24],c,[24,20],c,[539,29],c,[29,12],c,[1006,79],c,[660,49],c,[45,8],c,[793,47],c,[131,31],c,[439,50],c,[44,16],c,[125,9],c,[161,22],c,[663,28],c,[599,24],c,[1703,174],c,[875,16],c,[920,43],c,[1192,22],c,[260,51],c,[123,34],c,[34,69],c,[1284,181],s,[2,51]]),goto:u([s,[7,13],s,[9,13],6,17,7,10,11,12,14,21,22,23,19,20,18,24,s,[8,13],51,26,s,[51,25],28,30,33,35,39,40,41,34,36,42,s,[44,5,1],50,55,53,56,57,59,c,[5,4],61,s,[72,7],s,[17,13],62,64,c,[27,4],s,[22,13],66,c,[18,4],68,c,[5,4],s,[29,13],s,[37,27],s,[34,31],s,[35,31],s,[30,31],s,[31,31],s,[32,31],1,4,86,c,[272,6],72,73,74,78,c,[330,5],84,c,[282,8],5,84,88,s,[11,13],75,89,s,[75,4],81,81,33,81,c,[48,4],s,[81,4],c,[42,8],82,82,33,82,c,[20,4],s,[82,4],c,[20,8],s,[84,4],92,93,94,s,[84,14],96,84,84,77,30,33,77,c,[384,12],c,[16,16],c,[413,13],c,[13,13],s,[94,24],s,[96,24],s,[97,24],s,[98,24],s,[99,24],s,[100,24],s,[101,24],s,[102,24],s,[103,26],45,104,s,[111,24],s,[112,24],55,107,106,c,[640,3],s,[13,13],s,[115,8],s,[116,3],109,s,[116,5],110,s,[120,9],s,[121,9],s,[122,9],s,[123,9],55,107,111,c,[73,3],s,[15,13],112,120,113,s,[115,4,1],s,[18,13],s,[19,13],55,107,121,c,[52,3],s,[21,13],55,107,122,c,[19,3],c,[78,3],124,c,[7,3],126,125,2,s,[39,26],s,[40,26],128,s,[72,7],s,[42,26],129,s,[45,26],s,[46,26],s,[47,26],s,[48,26],s,[49,26],s,[50,26],124,131,133,134,135,138,137,c,[1118,14],142,140,139,141,s,[38,5],c,[1071,4],s,[36,4],3,s,[10,13],79,79,33,79,c,[47,4],s,[79,4],c,[51,8],80,80,33,80,c,[20,4],s,[80,4],c,[20,8],s,[83,4],c,[845,3],s,[83,14],96,83,83,s,[89,24],s,[90,24],s,[91,24],s,[95,24],s,[110,24],146,145,76,89,76,148,147,s,[92,5],93,94,s,[92,14],96,c,[19,3],s,[93,3],c,[24,3],s,[93,14],96,93,93,150,45,149,104,s,[107,4],s,[108,4],s,[109,4],s,[12,13],c,[290,4],s,[114,8],154,56,57,s,[119,8],s,[14,13],s,[16,13],s,[66,7],s,[67,7],s,[68,7],s,[69,7],s,[70,7],s,[71,7],156,c,[92,4],s,[33,5],s,[20,13],s,[23,13],s,[24,13],158,s,[72,7],159,s,[28,13],160,c,[793,6],s,[43,26],s,[44,26],125,162,c,[541,3],126,s,[129,5],164,s,[72,7],s,[132,5],s,[133,5],s,[52,26],166,s,[58,15],167,169,s,[72,7],171,s,[72,7],173,s,[72,7],s,[65,27],175,55,107,174,c,[255,3],78,78,33,78,c,[599,4],s,[78,4],c,[599,8],s,[85,24],s,[87,24],s,[86,24],s,[88,24],s,[104,24],s,[105,24],s,[106,4],s,[113,8],s,[117,8],s,[118,8],55,107,176,c,[198,3],s,[135,7],177,c,[394,6],178,179,s,[41,26],s,[127,5],s,[128,5],180,c,[45,6],s,[131,5],181,c,[927,14],55,55,183,s,[55,24],s,[56,26],184,c,[80,6],s,[63,27],185,c,[34,6],s,[64,27],186,c,[34,6],s,[62,27],187,s,[74,16],s,[134,7],188,s,[26,13],s,[27,13],s,[130,5],s,[53,26],s,[57,15],s,[54,26],s,[59,27],s,[60,27],s,[61,27],s,[73,16],s,[25,13]])}),defaultActions:bda({idx:u([0,2,5,11,14,s,[17,8,1],28,s,[37,9,1],47,48,50,51,s,[54,4,1],59,61,62,64,69,70,71,73,s,[75,6,1],84,86,87,88,s,[92,5,1],s,[103,4,1],108,s,[110,9,1],s,[120,4,1],126,128,129,131,132,134,135,136,142,s,[145,10,1],156,160,161,162,164,s,[167,5,2],176,s,[178,11,1]]),goto:u([7,9,8,17,22,29,37,34,35,30,31,32,1,11,94,s,[96,8,1],111,112,13,115,s,[120,4,1],15,18,19,21,2,39,40,42,s,[45,6,1],38,36,3,10,89,90,91,95,110,107,108,109,12,114,119,14,16,s,[66,6,1],33,20,23,24,28,43,44,126,129,132,133,52,65,85,87,86,88,104,105,106,113,117,118,135,41,127,128,131,56,63,64,62,74,134,26,27,130,53,57,54,59,60,61,73,25])}),parseError:function parseError(str,hash,ExceptionClass){if(hash.recoverable){if(typeof this.trace==='function'){this.trace(str);}hash.destroy();// destroy... well, *almost*! -}else{if(typeof this.trace==='function'){this.trace(str);}if(!ExceptionClass){ExceptionClass=this.JisonParserError;}throw new ExceptionClass(str,hash);}},parse:function parse(input){var self=this;var stack=new Array(128);// token stack: stores token which leads to state at the same index (column storage) -var sstack=new Array(128);// state stack: stores states (column storage) -var vstack=new Array(128);// semantic value stack -var lstack=new Array(128);// location stack -var table=this.table;var sp=0;// 'stack pointer': index into the stacks -var yyloc;var symbol=0;var preErrorSymbol=0;var lastEofErrorStateDepth=Infinity;var recoveringErrorInfo=null;var recovering=0;// (only used when the grammar contains error recovery rules) -var TERROR=this.TERROR;var EOF=this.EOF;var ERROR_RECOVERY_TOKEN_DISCARD_COUNT=this.options.errorRecoveryTokenDiscardCount|0||3;var NO_ACTION=[0,189/* === table.length :: ensures that anyone using this new state will fail dramatically! */];var lexer;if(this.__lexer__){lexer=this.__lexer__;}else{lexer=this.__lexer__=Object.create(this.lexer);}var sharedState_yy={parseError:undefined,quoteName:undefined,lexer:undefined,parser:undefined,pre_parse:undefined,post_parse:undefined,pre_lex:undefined,post_lex:undefined// WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! -};var ASSERT;if(typeof assert!=='function'){ASSERT=function JisonAssert(cond,msg){if(!cond){throw new Error('assertion failed: '+(msg||'***'));}};}else{ASSERT=assert;}this.yyGetSharedState=function yyGetSharedState(){return sharedState_yy;};this.yyGetErrorInfoTrack=function yyGetErrorInfoTrack(){return recoveringErrorInfo;};// shallow clone objects & arrays, straight copy of simple `src` values +}else{if(typeof this.trace==='function'){this.trace(str);}if(!ExceptionClass){ExceptionClass=this.JisonParserError;}throw new ExceptionClass(str,hash);}},parse:function parse(input){let self=this;let stack=new Array(128);// token stack: stores token which leads to state at the same index (column storage) +let sstack=new Array(128);// state stack: stores states (column storage) +let vstack=new Array(128);// semantic value stack +let lstack=new Array(128);// location stack +let table=this.table;let sp=0;// 'stack pointer': index into the stacks +let yyloc;let symbol=0;let preErrorSymbol=0;let lastEofErrorStateDepth=Infinity;let recoveringErrorInfo=null;let recovering=0;// (only used when the grammar contains error recovery rules) +const TERROR=this.TERROR;const EOF=this.EOF;const ERROR_RECOVERY_TOKEN_DISCARD_COUNT=this.options.errorRecoveryTokenDiscardCount|0||3;const NO_ACTION=[0,189/* === table.length :: ensures that anyone using this new state will fail dramatically! */];let lexer;if(this.__lexer__){lexer=this.__lexer__;}else{lexer=this.__lexer__=Object.create(this.lexer);}let sharedState_yy={parseError:undefined,quoteName:undefined,lexer:undefined,parser:undefined,pre_parse:undefined,post_parse:undefined,pre_lex:undefined,post_lex:undefined// WARNING: must be written this way for the code expanders to work correctly! +};const ASSERT=typeof assert!=='function'?function JisonAssert(cond,msg){if(!cond){throw new Error('assertion failed: '+(msg||'***'));}}:assert;this.yyGetSharedState=function yyGetSharedState(){return sharedState_yy;};this.yyGetErrorInfoTrack=function yyGetErrorInfoTrack(){return recoveringErrorInfo;};// shallow clone objects & arrays, straight copy of simple `src` values // e.g. `lexer.yytext` MAY be a complex value object, // rather than a simple string/value. // @@ -1606,14 +1629,13 @@ var TERROR=this.TERROR;var EOF=this.EOF;var ERROR_RECOVERY_TOKEN_DISCARD_COUNT=t // function shallow_copy(src){if(src&&typeof src==='object'){// non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: -if(src.constructor!==Object){if(Array.isArray(src)){return src.slice();}var dst=new src.constructor(src);// and make sure all custom attributes are added to the clone: +if(src.constructor!==Object){if(Array.isArray(src)){return src.slice();}let dst=new src.constructor(src);// and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst,src);return dst;}// native objects must be cloned a different way: -// -//return Object.assign({}, src); -var dst={};shallow_copy_noclobber(dst,src);return dst;}return src;}// add elements from `src` to `dst` when: +{//return Object.assign({}, src); +let dst={};shallow_copy_noclobber(dst,src);return dst;}}return src;}// add elements from `src` to `dst` when: // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` -function shallow_copy_noclobber(dst,src){const chk=Object.prototype.hasOwnProperty;for(var k in src){if(!(k in dst)){if(chk.call(src,k)){dst[k]=src[k];}}else{if(src[k]!=null&&dst[k]==null&&chk.call(src,k)){dst[k]=src[k];}}}}function copy_yylloc_native(loc){var rv=shallow_copy(loc);// shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: +function shallow_copy_noclobber(dst,src){const chk=Object.prototype.hasOwnProperty;for(let k in src){if(!(k in dst)){if(chk.call(src,k)){dst[k]=src[k];}}else if(src[k]!=null&&dst[k]==null&&chk.call(src,k)){dst[k]=src[k];}}}function copy_yylloc_native(loc){let rv=shallow_copy(loc);// shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if(rv){rv.range=rv.range.slice();}return rv;}// copy state shallow_copy_noclobber(sharedState_yy,this.yy);sharedState_yy.lexer=lexer;sharedState_yy.parser=this;// allow userland code to override the yytext and yylloc copy/clone functions: this.copy_yytext=this.options.copy_yytext||sharedState_yy.copy_yytext||shallow_copy;this.copy_yylloc=this.options.copy_yylloc||sharedState_yy.copy_yylloc||copy_yylloc_native;// *Always* setup `yyError`, `YYRECOVERING`, `yyErrOk` and `yyClearIn` functions as it is paramount @@ -1622,10 +1644,10 @@ this.copy_yytext=this.options.copy_yytext||sharedState_yy.copy_yytext||shallow_c // these functions are invoked in the user action code block(s) as // their closure will still refer to the `parse()` instance which set // them up. Hence we MUST set them up at the start of every `parse()` run! -if(this.yyError){this.yyError=function yyError(str/*, ...args */){var error_rule_depth=this.options.parserErrorsAreRecoverable?locateNearestErrorRecoveryRule(state):-1;var expected=this.collect_expected_token_set(state);var hash=this.constructParseErrorInfo(str,null,expected,error_rule_depth>=0);// append to the old one? -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; +if(this.yyError){this.yyError=function yyError(str/*, ...args */){let error_rule_depth=this.options.parserErrorsAreRecoverable?locateNearestErrorRecoveryRule(state):-1;let expected=this.collect_expected_token_set(state);let hash=this.constructParseErrorInfo(str,null,expected,error_rule_depth>=0);// append to the old one? +if(recoveringErrorInfo){let esp=recoveringErrorInfo.info_stack_pointer;recoveringErrorInfo.symbol_stack[esp]=symbol;let 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;recoveringErrorInfo.info_stack_pointer=esp;}else{recoveringErrorInfo=this.shallowCopyErrorInfo(hash);recoveringErrorInfo.yyError=true;recoveringErrorInfo.errorRuleDepth=error_rule_depth;recoveringErrorInfo.recovering=recovering;}// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){hash.extra_error_attributes=args;}return this.parseError(str,hash,this.JisonParserError);};}// Does the shared state override the default `parseError` that already comes with this instance? +let args=Array.prototype.slice.call(arguments,1);if(args.length){hash.extra_error_attributes=args;}return this.parseError(str,hash,this.JisonParserError);};}// Does the shared state override the default `parseError` that already comes with this instance? if(typeof sharedState_yy.parseError==='function'){this.parseError=function parseErrorAlt(str,hash,ExceptionClass){if(!ExceptionClass){ExceptionClass=this.JisonParserError;}return sharedState_yy.parseError.call(this,str,hash,ExceptionClass);};}else{this.parseError=this.originalParseError;}// Does the shared state override the default `quoteName` that already comes with this instance? if(typeof sharedState_yy.quoteName==='function'){this.quoteName=function quoteNameAlt(id_str){return sharedState_yy.quoteName.call(this,id_str);};}else{this.quoteName=this.originalQuoteName;}// set up the cleanup function; make it an API so that external code can re-use this one in case of // calamities or when the `%options no-try-catch` option has been specified for the grammar, in which @@ -1633,7 +1655,7 @@ if(typeof sharedState_yy.quoteName==='function'){this.quoteName=function quoteNa // // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! -this.cleanupAfterParse=function parser_cleanupAfterParse(resultValue,invoke_post_methods,do_not_nuke_errorinfos){var rv;if(invoke_post_methods){var hash;if(sharedState_yy.post_parse||this.post_parse){// create an error hash info instance: we re-use this API in a **non-error situation** +this.cleanupAfterParse=function parser_cleanupAfterParse(resultValue,invoke_post_methods,do_not_nuke_errorinfos){let rv;if(invoke_post_methods){let hash;if(sharedState_yy.post_parse||this.post_parse){// create an error hash info instance: we re-use this API in a **non-error situation** // as this one delivers all parser internals ready for access by userland code. hash=this.constructParseErrorInfo(null/* no error! */,null/* no exception! */,null,false);}if(sharedState_yy.post_parse){rv=sharedState_yy.post_parse.call(this,sharedState_yy,resultValue,hash);if(typeof rv!=='undefined')resultValue=rv;}if(this.post_parse){rv=this.post_parse.call(this,sharedState_yy,resultValue,hash);if(typeof rv!=='undefined')resultValue=rv;}// cleanup: if(hash&&hash.destroy){hash.destroy();}}if(this.__reentrant_call_depth>1)return resultValue;// do not (yet) kill the sharedState when this is a reentrant run. @@ -1645,7 +1667,7 @@ stack.length=0;// fastest way to nuke an array without overly bothering the GC sstack.length=0;lstack.length=0;vstack.length=0;sp=0;// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;for(var i=this.__error_recovery_infos.length-1;i>=0;i--){var el=this.__error_recovery_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_recovery_infos.length=0;// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array, +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;for(let i=this.__error_recovery_infos.length-1;i>=0;i--){let el=this.__error_recovery_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_recovery_infos.length=0;// `recoveringErrorInfo` is also part of the `__error_recovery_infos` array, // hence has been destroyed already: no need to do that *twice*. if(recoveringErrorInfo){recoveringErrorInfo=undefined;}}return resultValue;};// merge yylloc info into a new yylloc instance. // @@ -1659,32 +1681,38 @@ if(recoveringErrorInfo){recoveringErrorInfo=undefined;}}return resultValue;};// // yylloc info. // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. -this.yyMergeLocationInfo=function parser_yyMergeLocationInfo(first_index,last_index,first_yylloc,last_yylloc,dont_look_back){var i1=first_index|0,i2=last_index|0;var l1=first_yylloc,l2=last_yylloc;var rv;// rules: +this.yyMergeLocationInfo=function parser_yyMergeLocationInfo(first_index,last_index,first_yylloc,last_yylloc,dont_look_back){let i1=first_index|0;let i2=last_index|0;let l1=first_yylloc;let l2=last_yylloc;let rv;// rules: // - first/last yylloc entries override first/last indexes -if(!l1){if(first_index!=null){for(var i=i1;i<=i2;i++){l1=lstack[i];if(l1){break;}}}}if(!l2){if(last_index!=null){for(var i=i2;i>=i1;i--){l2=lstack[i];if(l2){break;}}}}// - detect if an epsilon rule is being processed and act accordingly: +if(!l1){if(first_index!=null){for(let i=i1;i<=i2;i++){l1=lstack[i];if(l1){break;}}}}if(!l2){if(last_index!=null){for(let i=i2;i>=i1;i--){l2=lstack[i];if(l2){break;}}}}// - detect if an epsilon rule is being processed and act accordingly: if(!l1&&first_index==null){// epsilon rule span merger. With optional look-ahead in l2. -if(!dont_look_back){for(var i=(i1||sp)-1;i>=0;i--){l1=lstack[i];if(l1){break;}}}if(!l1){if(!l2){// when we still don't have any valid yylloc info, we're looking at an epsilon rule +if(!dont_look_back){for(let i=(i1||sp)-1;i>=0;i--){l1=lstack[i];if(l1){break;}}}if(!l1){if(!l2){// when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: -return undefined;}else{// shallow-copy L2: after all, we MAY be looking +return null;}// shallow-copy L2: after all, we MAY be looking // at unconventional yylloc info objects... -rv=this.copy_yylloc(l2);return rv;}}else{// shallow-copy L1, then adjust first col/row 1 column past the end. +rv=this.copy_yylloc(l2);return rv;}// shallow-copy L1, then adjust first col/row 1 column past the end. rv=this.copy_yylloc(l1);rv.first_line=rv.last_line;rv.first_column=rv.last_column;rv.range[0]=rv.range[1];if(l2){// shallow-mixin L2, then adjust last col/row accordingly. -shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;}}if(!l1){l1=l2;l2=null;}if(!l1){return undefined;}// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking +shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;}if(!l1){l1=l2;l2=null;}if(!l1){return null;}// shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... rv=this.copy_yylloc(l1);if(l2){shallow_copy_noclobber(rv,l2);rv.last_line=l2.last_line;rv.last_column=l2.last_column;rv.range[1]=l2.range[1];}return rv;};// NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! -this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){var pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,loc:this.copy_yylloc(lexer.yylloc),expected:expected,recoverable:recoverable,state:state,action:action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,location_stack:lstack,stack_pointer:sp,yy:sharedState_yy,lexer:lexer,parser:this,// and make sure the error info doesn't stay due to potential +this.constructParseErrorInfo=function parser_constructParseErrorInfo(msg,ex,expected,recoverable){const pei={errStr:msg,exception:ex,text:lexer.match,value:this.copy_yytext(lexer.yytext),token:this.describeSymbol(symbol)||symbol,token_id:symbol,line:lexer.yylineno,loc:this.copy_yylloc(lexer.yylloc),expected,recoverable,state,action,new_state:newState,symbol_stack:stack,state_stack:sstack,value_stack:vstack,location_stack:lstack,stack_pointer:sp,yy:sharedState_yy,lexer,parser:this,// and make sure the error info doesn't stay due to potential // ref cycle via userland code manipulations. // These would otherwise all be memory leak opportunities! // // Note that only array and object references are nuked as those // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. -destroy:function destructParseErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +destroy:function destructParseErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// info.value = null; +// info.value_stack = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;};// clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. -this.shallowCopyErrorInfo=function parser_shallowCopyErrorInfo(p){var rv=shallow_copy(p);// remove the large parts which can only cause cyclic references +this.shallowCopyErrorInfo=function parser_shallowCopyErrorInfo(p){let rv=shallow_copy(p);// remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. delete rv.sharedState_yy;delete rv.parser;delete rv.lexer;// lexer.yytext MAY be a complex value object, rather than a simple string/value: rv.value=this.copy_yytext(rv.value);// yylloc info: @@ -1736,15 +1764,15 @@ rv.value_stack=rv.value_stack.map(this.copy_yytext);// and we don't bother with // - root_failure_pointer: // copy of the `stack_pointer`... // -for(var i=rv.stack_pointer;rv.state_stack[i]!=null;i++){// empty -}rv.base_pointer=i;rv.info_stack_pointer=i;rv.root_failure_pointer=rv.stack_pointer;// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! -this.__error_recovery_infos.push(rv);return rv;};function getNonTerminalFromCode(symbol){var tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){var token=lexer.lex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){var token=lexer.fastLex();// if token isn't its numeric value, convert -if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){var tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName:tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}var lex=stdLex;var state,action,r,t;var yyval={$:true,_$:undefined,yy:sharedState_yy};var p;var yyrulelen;var this_production;var newState;var retval=false;// Return the rule stack depth where the nearest error rule can be found. +{let i;for(i=rv.stack_pointer;rv.state_stack[i]!=null;i++){// empty +}rv.base_pointer=i;rv.info_stack_pointer=i;}rv.root_failure_pointer=rv.stack_pointer;// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! +this.__error_recovery_infos.push(rv);return rv;};function getNonTerminalFromCode(symbol){let tokenName=self.getSymbolName(symbol);if(!tokenName){tokenName=symbol;}return tokenName;}function stdLex(){let token=lexer.lex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}function fastLex(){let token=lexer.fastLex();// if token isn't its numeric value, convert +if(typeof token!=='number'){token=self.symbols_[token]||token;}if(typeof Jison!=='undefined'&&Jison.lexDebugger){let tokenName=self.getSymbolName(token||EOF);if(!tokenName){tokenName=token;}Jison.lexDebugger.push({tokenName,tokenText:lexer.match,tokenValue:lexer.yytext});}return token||EOF;}let lex=stdLex;let state,action,r,t;let yyval={$:true,_$:undefined,yy:sharedState_yy};let p;let yyrulelen;let this_production;let newState;let retval=false;// Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. -function locateNearestErrorRecoveryRule(state){var stack_probe=sp-1;var depth=0;// try to recover from error +function locateNearestErrorRecoveryRule(state){let stack_probe=sp-1;let depth=0;// try to recover from error while(stack_probe>=0){// check for error recovery rule in this state -var t=table[state]&&table[state][TERROR]||NO_ACTION;if(t[0]){// We need to make sure we're not cycling forever: +const t=table[state]&&table[state][TERROR]||NO_ACTION;if(t[0]){// We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must // prevent the core from running forever, // e.g. when parent rules are still expecting certain input to @@ -1765,7 +1793,7 @@ state=sstack[stack_probe];++depth;}return-1;// No suitable error recovery rule a // this initial `setInput()` call: hence we can now check and decide // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: -if(typeof lexer.canIUse==='function'){var lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}yyloc=this.copy_yylloc(lexer.yylloc);lstack[sp]=yyloc;vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack +if(typeof lexer.canIUse==='function'){let lexerInfo=lexer.canIUse();if(lexerInfo.fastLex&&typeof fastLex==='function'){lex=fastLex;}}yyloc=this.copy_yylloc(lexer.yylloc);lstack[sp]=yyloc;vstack[sp]=null;sstack[sp]=0;stack[sp]=0;++sp;if(this.pre_parse){this.pre_parse.call(this,sharedState_yy);}if(sharedState_yy.pre_parse){sharedState_yy.pre_parse.call(this,sharedState_yy);}newState=sstack[sp-1];for(;;){// retrieve state number from top of stack state=newState;// sstack[sp - 1]; // use default actions if available if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}else{// The single `==` condition below covers both these `===` comparisons in a single @@ -1775,7 +1803,7 @@ if(this.defaultActions[state]){action=2;newState=this.defaultActions[state];}els if(!symbol){symbol=lex();}// read action for current state and first input t=table[state]&&table[state][symbol]||NO_ACTION;newState=t[1];action=t[0];// handle parse error if(!action){// first see if there's any chance at hitting an error recovery rule: -var error_rule_depth=locateNearestErrorRecoveryRule(state);var errStr=null;var errSymbolDescr=this.describeSymbol(symbol)||symbol;var expected=this.collect_expected_token_set(state);if(!recovering){// Report error +let error_rule_depth=locateNearestErrorRecoveryRule(state);let errStr=null;let errSymbolDescr=this.describeSymbol(symbol)||symbol;let expected=this.collect_expected_token_set(state);if(!recovering){// Report error errStr='Parse error';if(typeof lexer.yylineno==='number'){errStr+=' on line '+(lexer.yylineno+1);}if(typeof lexer.showPosition==='function'){errStr+=':\n'+lexer.showPosition(79-10,10)+'\n';}else{errStr+=': ';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}p=this.constructParseErrorInfo(errStr,null,expected,error_rule_depth>=0);// DO NOT cleanup the old one before we start the new error info track: // the old one will *linger* on the error stack and stay alive until we // invoke the parser's cleanup API! @@ -1783,20 +1811,20 @@ recoveringErrorInfo=this.shallowCopyErrorInfo(p);r=this.parseError(p.errStr,p,th // the `recoverable` flag without properly checking first: // we always terminate the parse when there's no recovery rule available anyhow! if(!p.recoverable||error_rule_depth<0){break;}else{// TODO: allow parseError callback to edit symbol and or state at the start of the error recovery process... -}}var esp=recoveringErrorInfo.info_stack_pointer;// just recovered from another error +}}let esp=recoveringErrorInfo.info_stack_pointer;// just recovered from another error if(recovering===ERROR_RECOVERY_TOKEN_DISCARD_COUNT&&error_rule_depth>=0){// Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc=this.copy_yylloc(lexer.yylloc);// SHIFT current lookahead and grab another recoveringErrorInfo.symbol_stack[esp]=symbol;recoveringErrorInfo.location_stack[esp]=yyloc;recoveringErrorInfo.state_stack[esp]=newState;// push state ++esp;preErrorSymbol=0;symbol=lex();}// try to recover from error -if(error_rule_depth<0){ASSERT(recovering>0,"line 897");recoveringErrorInfo.info_stack_pointer=esp;// barf a fatal hairball when we're out of look-ahead symbols and none hit a match +if(error_rule_depth<0){ASSERT(recovering>0,'Line 1048');recoveringErrorInfo.info_stack_pointer=esp;// barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: -var po=this.__error_infos[this.__error_infos.length-1];// Report error +let po=this.__error_infos[this.__error_infos.length-1];// Report error if(typeof lexer.yylineno==='number'){errStr='Parsing halted on line '+(lexer.yylineno+1)+' while starting to recover from another error';}else{errStr='Parsing halted while starting to recover from another error';}if(po){errStr+=' -- previous error which resulted in this fatal result: '+po.errStr;}else{errStr+=': ';}if(typeof lexer.showPosition==='function'){errStr+='\n'+lexer.showPosition(79-10,10)+'\n';}if(expected.length){errStr+='Expecting '+expected.join(', ')+', got unexpected '+errSymbolDescr;}else{errStr+='Unexpected '+errSymbolDescr;}p=this.constructParseErrorInfo(errStr,null,expected,false);if(po){p.extra_error_attributes=po;}r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}preErrorSymbol=symbol===TERROR?0:symbol;// save the lookahead token symbol=TERROR;// insert generic error symbol as new lookahead const EXTRA_STACK_SAMPLE_DEPTH=3;// REDUCE/COMBINE the pushed terms/tokens to a new ERROR token: -recoveringErrorInfo.symbol_stack[esp]=preErrorSymbol;if(errStr){recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,errStr:errStr,errorSymbolDescr:errSymbolDescr,expectedStr:expected,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}else{recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}recoveringErrorInfo.location_stack[esp]=this.copy_yylloc(lexer.yylloc);recoveringErrorInfo.state_stack[esp]=newState||NO_ACTION[1];++esp;recoveringErrorInfo.info_stack_pointer=esp;yyval.$=recoveringErrorInfo;yyval._$=undefined;yyrulelen=error_rule_depth;r=this.performAction.call(yyval,yyloc,NO_ACTION[1],sp-1,vstack,lstack);if(typeof r!=='undefined'){retval=r;break;}// pop off stack +recoveringErrorInfo.symbol_stack[esp]=preErrorSymbol;if(errStr){recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,errStr,errSymbolDescr,expectedStr:expected,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}else{recoveringErrorInfo.value_stack[esp]={yytext:this.copy_yytext(lexer.yytext),errorRuleDepth:error_rule_depth,stackSampleLength:error_rule_depth+EXTRA_STACK_SAMPLE_DEPTH};}recoveringErrorInfo.location_stack[esp]=this.copy_yylloc(lexer.yylloc);recoveringErrorInfo.state_stack[esp]=newState||NO_ACTION[1];++esp;recoveringErrorInfo.info_stack_pointer=esp;yyval.$=recoveringErrorInfo;yyval._$=undefined;yyrulelen=error_rule_depth;let combineState=NO_ACTION[1];r=this.performAction.call(yyval,yyloc,combineState,sp-1,vstack,lstack);if(typeof r!=='undefined'){retval=r;break;}// pop off stack sp-=yyrulelen;// and move the top entries + discarded part of the parse stacks onto the error info stack: -for(var idx=sp-EXTRA_STACK_SAMPLE_DEPTH,top=idx+yyrulelen;idx0){recovering--;}}else{// error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: -ASSERT(recovering>0,"line 1163");symbol=preErrorSymbol;preErrorSymbol=0;// read action for current state and first input +ASSERT(recovering>0,'Line 1352');symbol=preErrorSymbol;preErrorSymbol=0;// read action for current state and first input t=table[newState]&&table[newState][symbol]||NO_ACTION;if(!t[0]||symbol===TERROR){// forget about that symbol and move forward: this wasn't a 'forgot to insert' error type where // (simple) stuff might have been missing before the token which caused the error we're // recovering from now... @@ -1887,17 +1915,17 @@ symbol=0;}}// once we have pushed the special ERROR token value, // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! -ASSERT(preErrorSymbol===0,"line 1194");if(recovering===0){break;}continue;// reduce: +ASSERT(preErrorSymbol===0,'Line 1383');if(recovering===0){break;}continue;// reduce: case 2:this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){// signal end of error recovery loop AND end of outer parse loop +yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){// signal end of error recovery loop AND end of outer parse loop action=3;retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}sp=-2;// magic number: signal outer "fast parse loop" ACCEPT state that we already have a properly set up `retval` parser return value. break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;lstack[sp]=yyval._$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -1925,26 +1953,26 @@ break;}// should we also break out of the regular/outer parse loop, // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? -ASSERT(action!==2,"line 1272");if(!action||action===1){continue;}}}switch(action){// catch misc. parse failures: +ASSERT(action!==2,'Line 1509');if(!action||action===1){continue;}}}switch(action){// catch misc. parse failures: default:// this shouldn't happen, unless resolve defaults are off if(action instanceof Array){p=this.constructParseErrorInfo('Parse Error: multiple actions possible at state: '+state+', token: '+symbol,null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;}// Another case of better safe than sorry: in case state transitions come out of another error recovery process // or a buggy LUT (LookUp Table): p=this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.',null,null,false);r=this.parseError(p.errStr,p,this.JisonParserError);if(typeof r!=='undefined'){retval=r;}break;// shift: case 1:stack[sp]=symbol;vstack[sp]=lexer.yytext;lstack[sp]=this.copy_yylloc(lexer.yylloc);sstack[sp]=newState;// push state -if(typeof Jison!=='undefined'&&Jison.parserDebugger){var tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;ASSERT(preErrorSymbol===0,"line 1352");// normal execution / no error -ASSERT(recovering===0,"line 1353");// normal execution / no error +if(typeof Jison!=='undefined'&&Jison.parserDebugger){let tokenName=this.getSymbolName(symbol||EOF);if(!tokenName){tokenName=symbol;}Jison.parserDebugger.push({action:'shift',text:lexer.yytext,terminal:tokenName,terminal_id:symbol});}++sp;symbol=0;ASSERT(preErrorSymbol===0,'Line 1619');// normal execution / no error +ASSERT(recovering===0,'Line 1620');// normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc=this.copy_yylloc(lexer.yylloc);continue;// reduce: -case 2:ASSERT(preErrorSymbol===0,"line 1364");// normal execution / no error -ASSERT(recovering===0,"line 1365");// normal execution / no error +case 2:ASSERT(preErrorSymbol===0,'Line 1631');// normal execution / no error +ASSERT(recovering===0,'Line 1632');// normal execution / no error this_production=this.productions_[newState-1];// `this.productions_[]` is zero-based indexed while states start from 1 upwards... -yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){var prereduceValue=vstack.slice(sp-yyrulelen,sp);var debuggableProductions=[];for(var debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){var debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) -var currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; -var currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack +yyrulelen=this_production[1];r=this.performAction.call(yyval,yyloc,newState,sp-1,vstack,lstack);if(typeof Jison!=='undefined'&&Jison.parserDebugger){let prereduceValue=vstack.slice(sp-yyrulelen,sp);let debuggableProductions=[];for(let debugIdx=yyrulelen-1;debugIdx>=0;debugIdx--){let debuggableProduction=getNonTerminalFromCode(stack[sp-debugIdx]);debuggableProductions.push(debuggableProduction);}// find the current nonterminal name (- nolan) +let currentNonterminalCode=this_production[0];// WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; +let currentNonterminal=getNonTerminalFromCode(currentNonterminalCode);Jison.parserDebugger.push({action:'reduce',nonterminal:currentNonterminal,nonterminal_id:currentNonterminalCode,prereduce:prereduceValue,result:r,productions:debuggableProductions,text:yyval.$});}if(typeof r!=='undefined'){retval=r;if(typeof Jison!=='undefined'&&Jison.parserDebugger){Jison.parserDebugger.push({action:'accept',text:retval});console.log(Jison.parserDebugger[Jison.parserDebugger.length-1]);}break;}// pop off stack sp-=yyrulelen;// don't overwrite the `symbol` variable: use a local var to speed things up: -var ntsymbol=this_production[0];// push nonterminal (reduce) +{let ntsymbol=this_production[0];// push nonterminal (reduce) stack[sp]=ntsymbol;vstack[sp]=yyval.$;lstack[sp]=yyval._$;// goto new state = table[STATE][NONTERMINAL] -newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;continue;// accept: +newState=table[sstack[sp-1]][ntsymbol];sstack[sp]=newState;++sp;}continue;// accept: case 3:if(sp!==-2){retval=true;// Return the `$accept` rule's `$$` result, if available. // // Also note that JISON always adds this top-most `$accept` rule (with implicit, @@ -2193,8 +2221,8 @@ return retval;},yyError:1};parser.originalParseError=parser.parseError;parser.or * @public * @constructor * @nocollapse - */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;var stacktrace;if(hash&&hash.exception instanceof Error){var ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 -Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';var lexer={// Code Generator Information Report + */function JisonLexerError(msg,hash){Object.defineProperty(this,'name',{enumerable:false,writable:false,value:'JisonLexerError'});if(msg==null)msg='???';Object.defineProperty(this,'message',{enumerable:false,writable:true,value:msg});this.hash=hash;let stacktrace;if(hash&&hash.exception instanceof Error){const ex2=hash.exception;this.message=ex2.message||msg;stacktrace=ex2.stack;}if(!stacktrace){if(Error.hasOwnProperty('captureStackTrace')){// V8 +Error.captureStackTrace(this,this.constructor);}else{stacktrace=new Error(msg).stack;}}if(stacktrace){Object.defineProperty(this,'stack',{enumerable:false,writable:false,value:stacktrace});}}if(typeof Object.setPrototypeOf==='function'){Object.setPrototypeOf(JisonLexerError.prototype,Error.prototype);}else{JisonLexerError.prototype=Object.create(Error.prototype);}JisonLexerError.prototype.constructor=JisonLexerError;JisonLexerError.prototype.name='JisonLexerError';const lexer={// Code Generator Information Report // --------------------------------- // // Options: @@ -2263,7 +2291,7 @@ CRLF_Re:/\r\n?|\n/,/** * @this {RegExpLexer} */constructLexErrorInfo:function lexer_constructLexErrorInfo(msg,recoverable,show_input_position){msg=''+msg;// heuristic to determine if the error message already contains a (partial) source code dump // as produced by either `showPosition()` or `prettyPrintRange()`: -if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){var pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){var pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */var pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... +if(show_input_position==undefined){show_input_position=!(msg.indexOf('\n')>0&&msg.indexOf('^')>0);}if(this.yylloc&&show_input_position){if(typeof this.prettyPrintRange==='function'){const pretty_src=this.prettyPrintRange(this.yylloc);if(!/\n\s*$/.test(msg)){msg+='\n';}msg+='\n Erroneous area:\n'+this.prettyPrintRange(this.yylloc);}else if(typeof this.showPosition==='function'){const pos_str=this.showPosition();if(pos_str){if(msg.length&&msg[msg.length-1]!=='\n'&&pos_str[0]!=='\n'){msg+='\n'+pos_str;}else{msg+=pos_str;}}}}/** @constructor */const pei={errStr:msg,recoverable:!!recoverable,// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:this,/** * and make sure the error info doesn't stay due to potential * ref cycle via userland code manipulations. @@ -2275,7 +2303,11 @@ text:this.match,token:null,line:this.yylineno,loc:this.yylloc,yy:this.yy,lexer:t * * @public * @this {LexErrorInfo} - */destroy:function destructLexErrorInfo(){var rec=!!this.recoverable;for(var key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! + */destroy:function destructLexErrorInfo(){// remove cyclic references added to error info: +// info.yy = null; +// info.lexer = null; +// ... +const rec=!!this.recoverable;for(let key in this){if(this[key]&&this.hasOwnProperty(key)&&typeof this[key]==='object'){this[key]=undefined;}}this.recoverable=rec;}};// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_infos.push(pei);return pei;},/** * handler which is invoked when a lexer error occurs. * @@ -2286,8 +2318,8 @@ this.__error_infos.push(pei);return pei;},/** * * @public * @this {RegExpLexer} - */yyerror:function yyError(str/*, ...args */){var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: -var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** + */yyerror:function yyError(str/*, ...args */){let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': '+str,this.options.lexerErrorsAreRecoverable);// Add any extra args to the hash under the name `extra_error_attributes`: +let args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_attributes=args;}return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;},/** * final cleanup function for when we have completed lexing the input; * make it an API so that external code can use this one once userland * code has decided it's time to destroy any lingering lexer error @@ -2302,13 +2334,13 @@ var args=Array.prototype.slice.call(arguments,1);if(args.length){p.extra_error_a this.setInput('',{});// nuke the error hash info instances created during this run. // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. -if(!do_not_nuke_errorinfos){for(var i=this.__error_infos.length-1;i>=0;i--){var el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** +if(!do_not_nuke_errorinfos){for(let i=this.__error_infos.length-1;i>=0;i--){let el=this.__error_infos[i];if(el&&typeof el.destroy==='function'){el.destroy();}}this.__error_infos.length=0;}return this;},/** * clear the lexer token context; intended for internal use only * * @public * @this {RegExpLexer} */clear:function lexer_clear(){this.yytext='';this.yyleng=0;this.match='';// - DO NOT reset `this.matched` -this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** +this.matches=false;this._more=false;this._backtrack=false;const col=this.yylloc.last_column;this.yylloc={first_line:this.yylineno+1,first_column:col,last_line:this.yylineno+1,last_column:col,range:[this.offset,this.offset]};},/** * resets the lexer, sets new input * * @public @@ -2317,10 +2349,10 @@ this.matches=false;this._more=false;this._backtrack=false;var col=this.yylloc.la // including expansion work to be done to go from a loaded // lexer to a usable lexer: if(!this.__decompressed){// step 1: decompress the regex list: -var rules=this.rules;for(var i=0,len=rules.length;i> tokens and perform user action code for a <> match, but only does so *once*) -return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}var ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). +return null;}if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}let ch=this._input[0];this.yytext+=ch;this.yyleng++;this.offset++;this.match+=ch;this.matched+=ch;// Count the linenumber up when we hit the LF (or a stand-alone CR). // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. -var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;var ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** +let slice_len=1;let lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lines=true;const ch2=this._input[1];if(ch2==='\n'){slice_len++;ch+=ch2;this.yytext+=ch2;this.yyleng++;this.offset++;this.match+=ch2;this.matched+=ch2;this.yylloc.range[1]++;}}if(lines){this.yylineno++;this.yylloc.last_line++;this.yylloc.last_column=0;}else{this.yylloc.last_column++;}this.yylloc.range[1]++;this._input=this._input.slice(slice_len);return ch;},/** * unshifts one char (or an entire string) into the input * * @public * @this {RegExpLexer} - */unput:function lexer_unput(ch){var len=ch.length;var lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** + */unput:function lexer_unput(ch){let len=ch.length;let lines=ch.split(this.CRLF_Re);if(!this._clear_state&&!this._more){this._clear_state=-1;this.clear();}this._input=ch+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-len);this.yyleng=this.yytext.length;this.offset-=len;// **WARNING:** // The `offset` value MAY be negative if you `unput()` more text than you have already lexed. // This type of behaviour is generally observed for one kind of 'lexer/parser hack' // where custom token-illiciting characters are pushed in front of the input stream to help @@ -2390,11 +2422,11 @@ var slice_len=1;var lines=false;if(ch==='\n'){lines=true;}else if(ch==='\r'){lin if(-this.offset>this.base_position){this.base_position=-this.offset;}this.match=this.match.substr(0,this.match.length-len);this.matched=this.matched.substr(0,this.matched.length-len);if(lines.length>1){this.yylineno-=lines.length-1;this.yylloc.last_line=this.yylineno+1;// Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. -var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** +let pre=this.match;let pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1){pre=this.matched;pre_lines=pre.split(this.CRLF_Re);}this.yylloc.last_column=pre_lines[pre_lines.length-1].length;}else{this.yylloc.last_column-=len;}this.yylloc.range[1]=this.yylloc.range[0]+this.yyleng;this.done=false;return this;},/** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -2404,8 +2436,8 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */lookAhead:function lexer_lookAhead(){return this._input||'';},/** @@ -2422,7 +2454,7 @@ var pre=this.match;var pre_lines=pre.split(this.CRLF_Re);if(pre_lines.length===1 */reject:function lexer_reject(){if(this.options.backtrack_lexer){this._backtrack=true;}else{// when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. -var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** +let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',false);this._signaled_error_token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}return this;},/** * retain first n characters of the match * * @public @@ -2444,17 +2476,17 @@ var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yyl * * @public * @this {RegExpLexer} - */pastInput:function lexer_pastInput(maxSize,maxLines){var past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0)maxSize=Infinity;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=Infinity;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substr` anticipation: treat \r\n as a single character and take a little + */pastInput:function lexer_pastInput(maxSize,maxLines){let past=this.matched.substring(0,this.matched.length-this.match.length);if(maxSize<0){maxSize=Infinity;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=Infinity;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past=past.substr(-maxSize*2-2);// now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: -var a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, +let a=past.split(this.CRLF_Re);a=a.slice(-maxLines);past=a.join('\n');// When, after limiting to maxLines, we still have too much to return, // do add an ellipsis prefix... if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -2480,18 +2512,18 @@ if(past.length>maxSize){past='...'+past.substr(-maxSize);}return past;},/** * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} - */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){var next=this.match;var source=this._input||'';if(maxSize<0)maxSize=next.length+source.length;else if(!maxSize)maxSize=20;if(maxLines<0)maxLines=maxSize;// can't ever have more input lines than this!; -else if(!maxLines)maxLines=1;// `substring` anticipation: treat \r\n as a single character and take a little + */upcomingInput:function lexer_upcomingInput(maxSize,maxLines){let next=this.match;let source=this._input||'';if(maxSize<0){maxSize=next.length+source.length;}else if(!maxSize){maxSize=20;}if(maxLines<0){maxLines=maxSize;// can't ever have more input lines than this! +}else if(!maxLines){maxLines=1;}// `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: if(next.lengthmaxSize){next=next.substring(0,maxSize)+'...';}return next;},/** @@ -2500,7 +2532,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){var pre=this.pastInput(maxPrefix).replace(/\s/g,' ');var c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** + */showPosition:function lexer_showPosition(maxPrefix,maxPostfix){const pre=this.pastInput(maxPrefix).replace(/\s/g,' ');let c=new Array(pre.length+1).join('-');return pre+this.upcomingInput(maxPostfix).replace(/\s/g,' ')+'\n'+c+'^';},/** * return an YYLLOC info object derived off the given context (actual, preceding, following, current). * Use this method when the given `actual` location is not guaranteed to exist (i.e. when * it MAY be NULL) and you MUST have a valid location info object anyway: @@ -2516,7 +2548,7 @@ if(next.length>maxSize){next=next.substring(0,maxSize)+'...';}return next;},/** * * @public * @this {RegExpLexer} - */deriveLocationInfo:function lexer_deriveYYLLOC(actual,preceding,following,current){var loc={first_line:1,first_column:0,last_line:1,last_column:0,range:[0,0]};if(actual){loc.first_line=actual.first_line|0;loc.last_line=actual.last_line|0;loc.first_column=actual.first_column|0;loc.last_column=actual.last_column|0;if(actual.range){loc.range[0]=actual.range[0]|0;loc.range[1]=actual.range[1]|0;}}if(loc.first_line<=0||loc.last_line=loc.first_line)){loc.last_line=current.last_line|0;loc.last_column=current.last_column|0;if(current.range){loc.range[1]=current.range[1]|0;}}}// sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter // or plan D heuristics to produce a 'sensible' last_line value: @@ -2565,9 +2597,9 @@ loc.range[1]=loc.range[0];}if(loc.first_column<0){loc.first_column=0;}if(loc.las * * @public * @this {RegExpLexer} - */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;var input=this.matched+(this._input||'');var lines=input.split('\n');var l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);var l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);var lineno_display_width=1+Math.log10(l1|1)|0;var ws_prefix=new Array(lineno_display_width).join(' ');var nonempty_line_indexes=[[],[],[]];var rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){var lno=index+l0;var lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);var rv=lno_pfx+': '+line;var errpfx=new Array(lineno_display_width+1).join('^');var offset=2+1;var len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it + */prettyPrintRange:function lexer_prettyPrintRange(loc,context_loc,context_loc2){loc=this.deriveLocationInfo(loc,context_loc,context_loc2);const CONTEXT=3;const CONTEXT_TAIL=1;const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT=2;let input=this.matched+(this._input||'');let lines=input.split('\n');let l0=Math.max(1,context_loc?context_loc.first_line:loc.first_line-CONTEXT);let l1=Math.max(1,context_loc2?context_loc2.last_line:loc.last_line+CONTEXT_TAIL);let lineno_display_width=1+Math.log10(l1|1)|0;let ws_prefix=new Array(lineno_display_width).join(' ');let nonempty_line_indexes=[[],[],[]];let rv=lines.slice(l0-1,l1+1).map(function injectLineNumber(line,index){let lno=index+l0;let lno_pfx=(ws_prefix+lno).substr(-lineno_display_width);let rv=lno_pfx+': '+line;let errpfx=new Array(lineno_display_width+1).join('^');let offset=2+1;let len=0;if(lno===loc.first_line){offset+=loc.first_column;len=Math.max(2,(lno===loc.last_line?loc.last_column:line.length)-loc.first_column+1);}else if(lno===loc.last_line){len=Math.max(2,loc.last_column+1);}else if(lno>loc.first_line&&lnoloc.last_line){nli=2;}if(line.trim().length>0){nonempty_line_indexes[nli].push(index);}rv=rv.replace(/\t/g,' ');return rv;});// now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: -for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){var clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;var clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;var intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** +for(let i=0;i<=2;i++){let line_arr=nonempty_line_indexes[i];if(line_arr.length>2*MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT){let clip_start=line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT-1]+1;let clip_end=line_arr[line_arr.length-MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT]-1;let intermediate_line=new Array(lineno_display_width+1).join(' ')+' (...continued...)';if(i===1){intermediate_line+='\n'+new Array(lineno_display_width+1).join('-')+' (---------------)';}rv.splice(clip_start,clip_end-clip_start+1,intermediate_line);}}return rv.join('\n');},/** * helper function, used to produce a human readable description as a string, given * the input `yylloc` location object. * @@ -2576,7 +2608,7 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){var l1=yylloc.first_line;var l2=yylloc.last_line;var c1=yylloc.first_column;var c2=yylloc.last_column;var dl=l2-l1;var dc=c2-c1;var rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){var r1=yylloc.range[0];var r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** + */describeYYLLOC:function lexer_describe_yylloc(yylloc,display_range_too){let l1=yylloc.first_line;let l2=yylloc.last_line;let c1=yylloc.first_column;let c2=yylloc.last_column;let dl=l2-l1;let dc=c2-c1;let rv;if(dl===0){rv='line '+l1+', ';if(dc<=1){rv+='column '+c1;}else{rv+='columns '+c1+' .. '+c2;}}else{rv='lines '+l1+'(column '+c1+') .. '+l2+'(column '+c2+')';}if(yylloc.range&&display_range_too){let r1=yylloc.range[0];let r2=yylloc.range[1]-1;if(r2<=r1){rv+=' {String Offset: '+r1+'}';}else{rv+=' {String Offset range: '+r1+' .. '+r2+'}';}}return rv;},/** * test the lexed token: return FALSE when not a match, otherwise return token. * * `match` is supposed to be an array coming out of a regex match, i.e. `match[0]` @@ -2593,18 +2625,18 @@ for(var i=0;i<=2;i++){var line_arr=nonempty_line_indexes[i];if(line_arr.length>2 * * @public * @this {RegExpLexer} - */test_match:function lexer_test_match(match,indexed_rule){var token,lines,backup,match_str,match_str_len;if(this.options.backtrack_lexer){// save context + */test_match:function lexer_test_match(match,indexed_rule){let backup;if(this.options.backtrack_lexer){// save context backup={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.yylloc.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column,range:this.yylloc.range.slice()},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,//_signaled_error_token: this._signaled_error_token, -yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}match_str=match[0];match_str_len=match_str.length;lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: +yy:this.yy,conditionStack:this.conditionStack.slice(),done:this.done};}let match_str=match[0];let match_str_len=match_str.length;let lines=match_str.split(this.CRLF_Re);if(lines.length>1){this.yylineno+=lines.length-1;this.yylloc.last_line=this.yylineno+1;this.yylloc.last_column=lines[lines.length-1].length;}else{this.yylloc.last_column+=match_str_len;}this.yytext+=match_str;this.match+=match_str;this.matched+=match_str;this.matches=match;this.yyleng=this.yytext.length;this.yylloc.range[1]+=match_str_len;// previous lex rules MAY have invoked the `more()` API rather than producing a token: // those rules will already have moved this `offset` forward matching their match lengths, // hence we must only add our own match length now: this.offset+=match_str_len;this._more=false;this._backtrack=false;this._input=this._input.slice(match_str_len);// calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} -token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: +let token=this.performAction.call(this,this.yy,indexed_rule,this.conditionStack[this.conditionStack.length-1]/* = YY_START */);// otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; if(this.done&&this._input){this.done=false;}if(token){return token;}else if(this._backtrack){// recover context -for(var k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. +for(let k in backup){this[k]=backup[k];}this.__currentRuleSet__=null;return false;// rule action called reject() implying the next rule should be tested instead. }else if(this._signaled_error_token){// produce one 'error' token as `.parseError()` in `reject()` // did not guarantee a failure signal by throwing an exception! token=this._signaled_error_token;this._signaled_error_token=false;return token;}return false;},/** @@ -2612,19 +2644,19 @@ token=this._signaled_error_token;this._signaled_error_token=false;return token;} * * @public * @this {RegExpLexer} - */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}var token,match,tempMatch,index;if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}var spec=this.__currentRuleSet__;if(!spec){// Update the ruleset cache as we apparently encountered a state change or just started lexing. + */next:function lexer_next(){if(this.done){this.clear();return this.EOF;}if(!this._input){this.done=true;}if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}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();// Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 -if(!spec||!spec.rules){var lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! -return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}var rule_ids=spec.rules;var regexes=spec.__rule_regexes;var len=spec.__rule_count;// Note: the arrays are 1-based, while `len` itself is a valid index, +if(!spec||!spec.rules){let lineno_msg='';if(this.yylloc){lineno_msg=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo('Internal lexer engine error'+lineno_msg+': The lex grammar programmer pushed a non-existing condition name "'+this.topState()+'"; this is a fatal error and should be reported to the application programmer team!',false);// produce one 'error' token until this situation has been resolved, most probably by parse termination! +return this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;}}{let rule_ids=spec.rules;let regexes=spec.__rule_regexes;let len=spec.__rule_count;let match;let index;// 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(var i=1;i<=len;i++){tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. +for(let i=1;i<=len;i++){let tempMatch=this._input.match(regexes[i]);if(tempMatch&&(!match||tempMatch[0].length>match[0].length)){match=tempMatch;index=i;if(this.options.backtrack_lexer){let token=this.test_match(tempMatch,rule_ids[i]);if(token!==false){return token;}else if(this._backtrack){match=undefined;continue;// rule action called reject() implying a rule MISmatch. }else{// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}}else if(!this.options.flex){break;}}}if(match){token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) -return false;}if(!this._input){this.done=true;this.clear();return this.EOF;}else{var lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}var p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);var pendingInput=this._input;var activeCondition=this.topState();var conditionStackDepth=this.conditionStack.length;token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us +return false;}}else if(!this.options.flex){break;}}}if(match){let token=this.test_match(match,rule_ids[index]);if(token!==false){return token;}// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) +return false;}}if(!this._input){this.done=true;this.clear();return this.EOF;}{let lineno_msg='Lexical error';if(this.yylloc){lineno_msg+=' on line '+(this.yylineno+1);}const p=this.constructLexErrorInfo(lineno_msg+': Unrecognized text.',this.options.lexerErrorsAreRecoverable);let pendingInput=this._input;let activeCondition=this.topState();let conditionStackDepth=this.conditionStack.length;let token=this.parseError(p.errStr,p,this.JisonLexerError)||this.ERROR;if(token===this.ERROR){// we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` // has not consumed/modified any pending input or changed state in the error handler: if(!this.matches&&// and make sure the input has been modified/consumed ... @@ -2635,7 +2667,7 @@ activeCondition===this.topState()&&conditionStackDepth===this.conditionStack.len * * @public * @this {RegExpLexer} - */lex:function lexer_lex(){var r;//this._clear_state = 0; + */lex:function lexer_lex(){let r;//this._clear_state = 0; if(!this._more){if(!this._clear_state){this._clear_state=1;}this.clear();}// allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer: if(typeof this.pre_lex==='function'){r=this.pre_lex.call(this,0);}if(typeof this.options.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.pre_lex.call(this,r)||r;}if(this.yy&&typeof this.yy.pre_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) @@ -2643,50 +2675,50 @@ r=this.yy.pre_lex.call(this,r)||r;}while(!r){r=this.next();}if(this.yy&&typeof t r=this.yy.post_lex.call(this,r)||r;}if(typeof this.options.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.options.post_lex.call(this,r)||r;}if(typeof this.post_lex==='function'){// (also account for a userdef function which does not return any value: keep the token as is) r=this.post_lex.call(this,r)||r;}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return next match that has a token. Identical to the `lex()` API but does not invoke any of the * `pre_lex()` nor any of the `post_lex()` callbacks. * * @public * @this {RegExpLexer} - */fastLex:function lexer_fastLex(){var r;//this._clear_state = 0; + */fastLex:function lexer_fastLex(){let r;//this._clear_state = 0; while(!r){r=this.next();}if(!this._more){// -// 1) make sure any outside interference is detected ASAP: +// 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: -// +// // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); -// +// // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. -// +// this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches);this.yylloc.range=Object.freeze(this.yylloc.range);this.yylloc=Object.freeze(this.yylloc);this._clear_state=0;}return r;},/** * return info about the lexer state that can help a parser or other lexer API user to use the * most efficient means available. This API is provided to aid run-time performance for larger @@ -2694,7 +2726,7 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */canIUse:function lexer_canIUse(){var rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** + */canIUse:function lexer_canIUse(){const rv={fastLex:!(typeof this.pre_lex==='function'||typeof this.options.pre_lex==='function'||this.yy&&typeof this.yy.pre_lex==='function'||this.yy&&typeof this.yy.post_lex==='function'||typeof this.options.post_lex==='function'||typeof this.post_lex==='function')&&typeof this.fastLex==='function'};return rv;},/** * backwards compatible alias for `pushState()`; * the latter is symmetrical with `popState()` and we advise to use * those APIs in any modern lexer code, rather than `begin()`. @@ -2713,20 +2745,20 @@ this.yytext=Object.freeze(this.yytext);this.matches=Object.freeze(this.matches); * * @public * @this {RegExpLexer} - */popState:function lexer_popState(){var n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}else{return this.conditionStack[0];}},/** + */popState:function lexer_popState(){const n=this.conditionStack.length-1;if(n>0){this.__currentRuleSet__=null;return this.conditionStack.pop();}return this.conditionStack[0];},/** * return the currently active lexer condition state; when an index * argument is provided it produces the N-th previous condition state, * if available * * @public * @this {RegExpLexer} - */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}else{return'INITIAL';}},/** + */topState:function lexer_topState(n){n=this.conditionStack.length-1-Math.abs(n||0);if(n>=0){return this.conditionStack[n];}return'INITIAL';},/** * (internal) determine the lexer rule set which is active for the * currently active lexer condition state * * @public * @this {RegExpLexer} - */_currentRules:function lexer__currentRules(){var n=this.conditionStack.length-1;var state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions['INITIAL'];},/** + */_currentRules:function lexer__currentRules(){const n=this.conditionStack.length-1;let state;if(n>=0){state=this.conditionStack[n];}else{state='INITIAL';}return this.conditions[state]||this.conditions.INITIAL;},/** * return the number of states currently on the stack * * @public @@ -2993,7 +3025,7 @@ const CHR_RE=/^(?:[^\\]|\\[^cxu0-9]|\\[0-9]{1,3}|\\c[A-Z]|\\x[0-9a-fA-F]{2}|\\u[ const WHITESPACE_SETSTR=' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff';// `/\d/`: const DIGIT_SETSTR='0-9';// `/\w/`: const WORDCHAR_SETSTR='A-Za-z0-9_';// Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex -function i2c(i){var c,x;switch(i){case 10:return'\\n';case 13:return'\\r';case 9:return'\\t';case 8:return'\\b';case 12:return'\\f';case 11:return'\\v';case 45:// ASCII/Unicode for '-' dash +function i2c(i){let c,x;switch(i){case 10:return'\\n';case 13:return'\\r';case 9:return'\\t';case 8:return'\\b';case 12:return'\\f';case 11:return'\\v';case 45:// ASCII/Unicode for '-' dash return'\\-';case 91:// '[' return'\\[';case 92:// '\\' return'\\\\';case 93:// ']' @@ -3003,13 +3035,13 @@ return'\\^';}if(i<32||i>0xFFF0/* Unicode Specials, also in UTF16 */||i>=0xD800&& // source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report // a b0rked generated parser, as the generated code would include this regex right here. // Hence we MUST escape these buggers everywhere we go... -x=i.toString(16);if(x.length>=1&&i<=0xFFFF){c='0000'+x;return'\\u'+c.substr(c.length-4);}else{return'\\u{'+x+'}';}}return String.fromCharCode(i);}// Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating +x=i.toString(16);if(x.length>=1&&i<=0xFFFF){c='0000'+x;return'\\u'+c.substr(c.length-4);}return'\\u{'+x+'}';}return String.fromCharCode(i);}// Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating // this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a // `\\p{NAME}` shorthand to represent [part of] the bitarray: -var Pcodes_bitarray_cache={};var Pcodes_bitarray_cache_test_order=[];// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by +let Pcodes_bitarray_cache={};let Pcodes_bitarray_cache_test_order=[];// Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. -var EscCode_bitarray_output_refs;// now initialize the EscCodes_... table above: -init_EscCode_lookup_table();function init_EscCode_lookup_table(){var s,bitarr,set2esc={},esc2bitarr={};// patch global lookup tables for the time being, while we calculate their *real* content in this function: +let EscCode_bitarray_output_refs;// now initialize the EscCodes_... table above: +init_EscCode_lookup_table();function init_EscCode_lookup_table(){let s,bitarr,set2esc={},esc2bitarr={};// patch global lookup tables for the time being, while we calculate their *real* content in this function: EscCode_bitarray_output_refs={esc2bitarr:{},set2esc:{}};Pcodes_bitarray_cache_test_order=[];// `/\S': bitarr=[];set2bitarray(bitarr,'^'+WHITESPACE_SETSTR);s=bitarray2set(bitarr);esc2bitarr['S']=bitarr;set2esc[s]='S';// set2esc['^' + s] = 's'; Pcodes_bitarray_cache['\\S']=bitarr;// `/\s': @@ -3022,34 +3054,34 @@ Pcodes_bitarray_cache['\\d']=bitarr;// `/\W': bitarr=[];set2bitarray(bitarr,'^'+WORDCHAR_SETSTR);s=bitarray2set(bitarr);esc2bitarr['W']=bitarr;set2esc[s]='W';// set2esc['^' + s] = 'w'; Pcodes_bitarray_cache['\\W']=bitarr;// `/\w': bitarr=[];set2bitarray(bitarr,WORDCHAR_SETSTR);s=bitarray2set(bitarr);esc2bitarr['w']=bitarr;set2esc[s]='w';// set2esc['^' + s] = 'W'; -Pcodes_bitarray_cache['\\w']=bitarr;EscCode_bitarray_output_refs={esc2bitarr:esc2bitarr,set2esc:set2esc};updatePcodesBitarrayCacheTestOrder();}function updatePcodesBitarrayCacheTestOrder(opts){var t=new Array(UNICODE_BASE_PLANE_MAX_CP+1);var l={};var user_has_xregexp=opts&&opts.options&&opts.options.xregexp;var i,j,k,ba;// mark every character with which regex pcodes they are part of: -for(k in Pcodes_bitarray_cache){ba=Pcodes_bitarray_cache[k];if(!user_has_xregexp&&k.indexOf('\\p{')>=0){continue;}var cnt=0;for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(ba[i]){cnt++;if(!t[i]){t[i]=[k];}else{t[i].push(k);}}}l[k]=cnt;}// now dig out the unique ones: only need one per pcode. -// +Pcodes_bitarray_cache['\\w']=bitarr;EscCode_bitarray_output_refs={esc2bitarr:esc2bitarr,set2esc:set2esc};updatePcodesBitarrayCacheTestOrder();}function updatePcodesBitarrayCacheTestOrder(opts){let t=new Array(UNICODE_BASE_PLANE_MAX_CP+1);let l={};let user_has_xregexp=opts&&opts.options&&opts.options.xregexp;let i,j,k,ba;// mark every character with which regex pcodes they are part of: +for(k in Pcodes_bitarray_cache){ba=Pcodes_bitarray_cache[k];if(!user_has_xregexp&&k.indexOf('\\p{')>=0){continue;}let cnt=0;for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(ba[i]){cnt++;if(!t[i]){t[i]=[k];}else{t[i].push(k);}}}l[k]=cnt;}// now dig out the unique ones: only need one per pcode. +// // We ASSUME every \\p{NAME} 'pcode' has at least ONE character -// in it that is ONLY matched by that particular pcode. +// in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode -// won't be tested during optimization. -// +// won't be tested during optimization. +// // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to // look for markers which match multiple escapes/pcodes for those // ones where a unique item isn't available... -var lut=[];var done={};var keys=Object.keys(Pcodes_bitarray_cache);for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){k=t[i][0];if(t[i].length===1&&!done[k]){assert__default['default'](l[k]>0);lut.push([i,k]);done[k]=true;}}for(j=0;keys[j];j++){k=keys[j];if(!user_has_xregexp&&k.indexOf('\\p{')>=0){continue;}if(!done[k]){assert__default['default'](l[k]>0);// find a minimum span character to mark this one: -var w=Infinity;var rv;ba=Pcodes_bitarray_cache[k];for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(ba[i]){var tl=t[i].length;if(tl>1&&tl0);rv=[i,k];w=tl;}}}if(rv){done[k]=true;lut.push(rv);}}}// order from large set to small set so that small sets don't gobble +let lut=[];let done={};let keys=Object.keys(Pcodes_bitarray_cache);for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){k=t[i][0];if(t[i].length===1&&!done[k]){assert__default['default'](l[k]>0);lut.push([i,k]);done[k]=true;}}for(j=0;keys[j];j++){k=keys[j];if(!user_has_xregexp&&k.indexOf('\\p{')>=0){continue;}if(!done[k]){assert__default['default'](l[k]>0);// find a minimum span character to mark this one: +let w=Infinity;var rv;ba=Pcodes_bitarray_cache[k];for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(ba[i]){let tl=t[i].length;if(tl>1&&tl0);rv=[i,k];w=tl;}}}if(rv){done[k]=true;lut.push(rv);}}}// order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. -// +// // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more -// optimal minification of the regex set expression. -// +// optimal minification of the regex set expression. +// // This is a guestimate/heuristic only! -lut.sort(function(a,b){var k1=a[1];var k2=b[1];var ld=l[k2]-l[k1];if(ld){return ld;}// and for same-size sets, order from high to low unique identifier. +lut.sort(function(a,b){let k1=a[1];let k2=b[1];let ld=l[k2]-l[k1];if(ld){return ld;}// and for same-size sets, order from high to low unique identifier. return b[0]-a[0];});Pcodes_bitarray_cache_test_order=lut;}// 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set. -function set2bitarray(bitarr,s,opts){var orig=s;var set_is_inverted=false;var bitarr_orig;function mark(d1,d2){if(d2==null)d2=d1;for(var i=d1;i<=d2;i++){bitarr[i]=true;}}function add2bitarray(dst,src){for(var i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(src[i]){dst[i]=true;}}}function eval_escaped_code(s){var c;// decode escaped code? If none, just take the character as-is -if(s.indexOf('\\')===0){var l=s.substr(0,2);switch(l){case'\\c':c=s.charCodeAt(2)-'A'.charCodeAt(0)+1;return String.fromCharCode(c);case'\\x':s=s.substr(2);c=parseInt(s,16);return String.fromCharCode(c);case'\\u':s=s.substr(2);if(s[0]==='{'){s=s.substr(1,s.length-2);}c=parseInt(s,16);if(c>=0x10000){return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{'+s+'}');}return String.fromCharCode(c);case'\\0':case'\\1':case'\\2':case'\\3':case'\\4':case'\\5':case'\\6':case'\\7':s=s.substr(1);c=parseInt(s,8);return String.fromCharCode(c);case'\\r':return'\r';case'\\n':return'\n';case'\\v':return'\v';case'\\f':return'\f';case'\\t':return'\t';case'\\b':return'\b';default:// just the character itself: -return s.substr(1);}}else{return s;}}if(s&&s.length){var c1,c2;// inverted set? +function set2bitarray(bitarr,s,opts){let orig=s;let set_is_inverted=false;let bitarr_orig;function mark(d1,d2){if(d2==null)d2=d1;for(let i=d1;i<=d2;i++){bitarr[i]=true;}}function add2bitarray(dst,src){for(let i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(src[i]){dst[i]=true;}}}function eval_escaped_code(s){let c;// decode escaped code? If none, just take the character as-is +if(s.indexOf('\\')===0){let l=s.substr(0,2);switch(l){case'\\c':c=s.charCodeAt(2)-'A'.charCodeAt(0)+1;return String.fromCharCode(c);case'\\x':s=s.substr(2);c=parseInt(s,16);return String.fromCharCode(c);case'\\u':s=s.substr(2);if(s[0]==='{'){s=s.substr(1,s.length-2);}c=parseInt(s,16);if(c>=0x10000){return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{'+s+'}');}return String.fromCharCode(c);case'\\0':case'\\1':case'\\2':case'\\3':case'\\4':case'\\5':case'\\6':case'\\7':s=s.substr(1);c=parseInt(s,8);return String.fromCharCode(c);case'\\r':return'\r';case'\\n':return'\n';case'\\v':return'\v';case'\\f':return'\f';case'\\t':return'\t';case'\\b':return'\b';default:// just the character itself: +return s.substr(1);}}else{return s;}}if(s&&s.length){let c1,c2;// inverted set? if(s[0]==='^'){set_is_inverted=true;s=s.substr(1);bitarr_orig=bitarr;bitarr=new Array(UNICODE_BASE_PLANE_MAX_CP+1);}// BITARR collects flags for characters set. Inversion means the complement set of character is st instead. // This results in an OR operations when sets are joined/chained. while(s.length){c1=s.match(CHR_RE);if(!c1){// hit an illegal escape sequence? cope anyway! @@ -3057,31 +3089,31 @@ c1=s[0];}else{c1=c1[0];// Quick hack for XRegExp escapes inside a regex `[...]` // intact but it's easier to unfold them here; this is not nice for when the grammar specifies explicit // XRegExp support, but alas, we'll get there when we get there... ;-) switch(c1){case'\\p':s=s.substr(c1.length);c2=s.match(XREGEXP_UNICODE_ESCAPE_RE);if(c2){c2=c2[0];s=s.substr(c2.length);// do we have this one cached already? -var pex=c1+c2;var ba4p=Pcodes_bitarray_cache[pex];if(!ba4p){// expand escape: -var xr=new XRegExp__default['default']('['+pex+']');// TODO: case-insensitive grammar??? +let pex=c1+c2;let ba4p=Pcodes_bitarray_cache[pex];if(!ba4p){// expand escape: +let xr=new XRegExp__default['default']('['+pex+']');// TODO: case-insensitive grammar??? // rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`: -var xs=''+xr;// remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: +let xs=''+xr;// remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: xs=xs.substr(1,xs.length-2);ba4p=reduceRegexToSetBitArray(xs,pex,opts);Pcodes_bitarray_cache[pex]=ba4p;updatePcodesBitarrayCacheTestOrder(opts);}// merge bitarrays: add2bitarray(bitarr,ba4p);continue;}break;case'\\S':case'\\s':case'\\W':case'\\w':case'\\d':case'\\D':// these can't participate in a range, but need to be treated special: s=s.substr(c1.length);// check for \S, \s, \D, \d, \W, \w and expand them: var ba4e=EscCode_bitarray_output_refs.esc2bitarr[c1[1]];assert__default['default'](ba4e);add2bitarray(bitarr,ba4e);continue;case'\\b':// matches a backspace: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions#special-backspace -c1='\u0008';break;}}var v1=eval_escaped_code(c1);// propagate deferred exceptions = error reports. +c1='\u0008';break;}}let v1=eval_escaped_code(c1);// propagate deferred exceptions = error reports. if(v1 instanceof Error){return v1;}v1=v1.charCodeAt(0);s=s.substr(c1.length);if(s[0]==='-'&&s.length>=2){// we can expect a range like 'a-z': s=s.substr(1);c2=s.match(CHR_RE);if(!c2){// hit an illegal escape sequence? cope anyway! -c2=s[0];}else{c2=c2[0];}var v2=eval_escaped_code(c2);// propagate deferred exceptions = error reports. +c2=s[0];}else{c2=c2[0];}let v2=eval_escaped_code(c2);// propagate deferred exceptions = error reports. if(v2 instanceof Error){return v1;}v2=v2.charCodeAt(0);s=s.substr(c2.length);// legal ranges go UP, not /DOWN! if(v1<=v2){mark(v1,v2);}else{console.warn('INVALID CHARACTER RANGE found in regex: ',{re:orig,start:c1,start_n:v1,end:c2,end_n:v2});mark(v1);mark('-'.charCodeAt(0));mark(v2);}continue;}mark(v1);}// When we have marked all slots, '^' NEGATES the set, hence we flip all slots. -// +// // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. -if(set_is_inverted){for(var i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(!bitarr[i]){bitarr_orig[i]=true;}}}}return false;}// convert a simple bitarray back into a regex set `[...]` content: +if(set_is_inverted){for(let i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(!bitarr[i]){bitarr_orig[i]=true;}}}}return false;}// convert a simple bitarray back into a regex set `[...]` content: function bitarray2set(l,output_inverted_variant,output_minimized){// construct the inverse(?) set from the mark-set: // // Before we do that, we inject a sentinel so that our inner loops // below can be simple and fast: l[UNICODE_BASE_PLANE_MAX_CP+1]=1;// now reconstruct the regex set: -var rv=[];var i,j,cnt,lut,tn,tspec,match,pcode,ba4pcode,l2;var bitarr_is_cloned=false;var l_orig=l;if(output_inverted_variant){// generate the inverted set, hence all unmarked slots are part of the output range: +let rv=[];let i,j,cnt,lut,tn,tspec,match,pcode,ba4pcode,l2;let bitarr_is_cloned=false;let l_orig=l;if(output_inverted_variant){// generate the inverted set, hence all unmarked slots are part of the output range: cnt=0;for(i=0;i<=UNICODE_BASE_PLANE_MAX_CP;i++){if(!l[i]){cnt++;}}if(cnt===UNICODE_BASE_PLANE_MAX_CP+1){// When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. // BUT... since we output the INVERTED set, we output the match-all set instead: return'\\S\\s';}else if(cnt===0){// When we find the entire Unicode range is in the output match set, we replace this with @@ -3093,9 +3125,9 @@ if(!l[tspec[0]]){// check if the pcode is covered by the inverted set: pcode=tspec[1];ba4pcode=Pcodes_bitarray_cache[pcode];match=0;for(j=0;j<=UNICODE_BASE_PLANE_MAX_CP;j++){if(ba4pcode[j]){if(!l[j]){// match in current inverted bitset, i.e. there's at // least one 'new' bit covered by this pcode/escape: match++;}else if(l_orig[j]){// mismatch! -match=false;break;}}}// We're only interested in matches which actually cover some +match=false;break;}}}// We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. -// +// // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if(match&&match>pcode.length){rv.push(pcode);// and nuke the bits in the array which match the given pcode: @@ -3116,9 +3148,9 @@ if(l[tspec[0]]){// check if the pcode is covered by the set: pcode=tspec[1];ba4pcode=Pcodes_bitarray_cache[pcode];match=0;for(j=0;j<=UNICODE_BASE_PLANE_MAX_CP;j++){if(ba4pcode[j]){if(l[j]){// match in current bitset, i.e. there's at // least one 'new' bit covered by this pcode/escape: match++;}else if(!l_orig[j]){// mismatch! -match=false;break;}}}// We're only interested in matches which actually cover some +match=false;break;}}}// We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. -// +// // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if(match&&match>pcode.length){rv.push(pcode);// and nuke the bits in the array which match the given pcode: @@ -3128,17 +3160,17 @@ if(!bitarr_is_cloned){l2=new Array(UNICODE_BASE_PLANE_MAX_CP+1);for(j=0;j<=UNICO l2[UNICODE_BASE_PLANE_MAX_CP+1]=1;l=l2;bitarr_is_cloned=true;}else{for(j=0;j<=UNICODE_BASE_PLANE_MAX_CP;j++){l[j]=l[j]&&!ba4pcode[j];}}}}}}i=0;while(i<=UNICODE_BASE_PLANE_MAX_CP){// find first character not in original set: while(!l[i]){i++;}if(i>=UNICODE_BASE_PLANE_MAX_CP+1){break;}// find next character not in original set: for(j=i+1;l[j];j++){}/* empty loop */if(j>UNICODE_BASE_PLANE_MAX_CP+1){j=UNICODE_BASE_PLANE_MAX_CP+1;}// generate subset: -rv.push(i2c(i));if(j-1>i){rv.push((j-2>i?'-':'')+i2c(j-1));}i=j;}}assert__default['default'](rv.length);var s=rv.join('');assert__default['default'](s);// Check if the set is better represented by one of the regex escapes: -var esc4s=EscCode_bitarray_output_refs.set2esc[s];if(esc4s){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! +rv.push(i2c(i));if(j-1>i){rv.push((j-2>i?'-':'')+i2c(j-1));}i=j;}}assert__default['default'](rv.length);let s=rv.join('');assert__default['default'](s);// Check if the set is better represented by one of the regex escapes: +let esc4s=EscCode_bitarray_output_refs.set2esc[s];if(esc4s){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return'\\'+esc4s;}return s;}// Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there; // ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`. -function reduceRegexToSetBitArray(s,name,opts){var orig=s;// propagate deferred exceptions = error reports. -if(s instanceof Error){return s;}var l=new Array(UNICODE_BASE_PLANE_MAX_CP+1);var internal_state=0;var derr;while(s.length){var c1=s.match(CHR_RE);if(!c1){// cope with illegal escape sequences too! -return new Error('illegal escape sequence at start of regex part: "'+s+'" of regex "'+orig+'"');}else{c1=c1[0];}s=s.substr(c1.length);switch(c1){case'[':// this is starting a set within the regex: scan until end of set! -var set_content=[];while(s.length){var inner=s.match(SET_PART_RE);if(!inner){inner=s.match(CHR_RE);if(!inner){// cope with illegal escape sequences too! -return new Error('illegal escape sequence at start of regex part: '+s+'" of regex "'+orig+'"');}else{inner=inner[0];}if(inner===']')break;}else{inner=inner[0];}set_content.push(inner);s=s.substr(inner.length);}// ensure that we hit the terminating ']': +function reduceRegexToSetBitArray(s,name,opts){let orig=s;// propagate deferred exceptions = error reports. +if(s instanceof Error){return s;}let l=new Array(UNICODE_BASE_PLANE_MAX_CP+1);let internal_state=0;let derr;while(s.length){let c1=s.match(CHR_RE);if(!c1){// cope with illegal escape sequences too! +return new Error('illegal escape sequence at start of regex part: "'+s+'" of regex "'+orig+'"');}c1=c1[0];s=s.substr(c1.length);switch(c1){case'[':// this is starting a set within the regex: scan until end of set! +var set_content=[];while(s.length){let inner=s.match(SET_PART_RE);if(!inner){inner=s.match(CHR_RE);if(!inner){// cope with illegal escape sequences too! +return new Error('illegal escape sequence at start of regex part: '+s+'" of regex "'+orig+'"');}inner=inner[0];if(inner===']')break;}else{inner=inner[0];}set_content.push(inner);s=s.substr(inner.length);}// ensure that we hit the terminating ']': var c2=s.match(CHR_RE);if(!c2){// cope with illegal escape sequences too! -return new Error('regex set expression is broken in regex: "'+orig+'" --> "'+s+'"');}else{c2=c2[0];}if(c2!==']'){return new Error('regex set expression is broken in regex: '+orig);}s=s.substr(c2.length);var se=set_content.join('');if(!internal_state){derr=set2bitarray(l,se,opts);// propagate deferred exceptions = error reports. +return new Error('regex set expression is broken in regex: "'+orig+'" --> "'+s+'"');}c2=c2[0];if(c2!==']'){return new Error('regex set expression is broken in regex: '+orig);}s=s.substr(c2.length);var se=set_content.join('');if(!internal_state){derr=set2bitarray(l,se,opts);// propagate deferred exceptions = error reports. if(derr instanceof Error){return derr;}// a set is to use like a single character in a longer literal phrase, hence input `[abc]word[def]` would thus produce output `[abc]`: internal_state=1;}break;// Strip unescaped pipes to catch constructs like `\\r|\\n` and turn them into // something ready for use inside a regex set, e.g. `\\r\\n`. @@ -3172,34 +3204,34 @@ if(!internal_state){derr=set2bitarray(l,c1,opts);// propagate deferred exception if(derr instanceof Error){return derr;}internal_state=2;}break;}}s=bitarray2set(l);// When this result is suitable for use in a set, than we should be able to compile // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: -try{var re;assert__default['default'](s);assert__default['default'](!(s instanceof Error));re=new XRegExp__default['default']('['+s+']');re.test(s[0]);// One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` +try{assert__default['default'](s);assert__default['default'](!(s instanceof Error));let re=new XRegExp__default['default']('['+s+']');re.test(s[0]);// One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` // so we check for lingering UNESCAPED brackets in here as those cannot be: if(/[^\\][\[\]]/.exec(s)){throw new Error('unescaped brackets in set data');}}catch(ex){// make sure we produce a set range expression which will fail badly when it is used // in actual code: s=new Error('[macro ['+name+'] is unsuitable for use inside regex set expressions: "['+s+']"]: '+ex.message);}assert__default['default'](s);// propagate deferred exceptions = error reports. -if(s instanceof Error){return s;}return l;}// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` +if(s instanceof Error){return s;}return l;}// Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! function produceOptimizedRegex4Set(bitarr){// First try to produce a minimum regex from the bitarray directly: -var s1=bitarray2set(bitarr,false,true);// and when the regex set turns out to match a single pcode/escape, then +let s1=bitarray2set(bitarr,false,true);// and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if(s1.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! -return s1;}else{s1='['+s1+']';}// Now try to produce a minimum regex from the *inverted* bitarray via negation: +return s1;}s1='['+s1+']';// Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. -var s2=bitarray2set(bitarr,true,true);if(s2[0]==='^'){s2=s2.substr(1);if(s2.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! +let s2=bitarray2set(bitarr,true,true);if(s2[0]==='^'){s2=s2.substr(1);if(s2.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s2;}}else{s2='^'+s2;}s2='['+s2+']';// Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: -// +// // First try to produce a minimum regex from the bitarray directly: -var s3=bitarray2set(bitarr,false,false);// and when the regex set turns out to match a single pcode/escape, then +let s3=bitarray2set(bitarr,false,false);// and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if(s3.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! -return s3;}else{s3='['+s3+']';}// Now try to produce a minimum regex from the *inverted* bitarray via negation: +return s3;}s3='['+s3+']';// Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. -var s4=bitarray2set(bitarr,true,false);if(s4[0]==='^'){s4=s4.substr(1);if(s4.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! +let s4=bitarray2set(bitarr,true,false);if(s4[0]==='^'){s4=s4.substr(1);if(s4.match(SET_IS_SINGLE_PCODE_RE)){// When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s4;}}else{s4='^'+s4;}s4='['+s4+']';if(s2.length0){err=e;}else{err=new Error('Could not parse jison lexer spec in JSON AUTODETECT mode:\nin JISON Mode we get Error: '+e.message+'\n\nwhile JSON5 Mode produces Error: '+ex1.message);err.secondary_exception=e;err.stack=ex1.stack;}}else{err=new Error('Could not parse lexer spec\nError: '+e.message);err.stack=e.stack;}throw err;}}}else{chk_l=lexerSpec;}// Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: +const commonErrors=[/does not compile/,/you did not correctly separate trailing code/,/You did not specify/,/You cannot specify/,/must be qualified/,/%start/,/%token/,/%import/,/%include/,/%options/,/%parse-params/,/%parser-type/,/%epsilon/,/definition list error/,/token list error/,/declaration error/,/should be followed/,/should be separated/,/an error in one or more of your lexer regex rules/,/an error in your lexer epilogue/,/unsupported definition type/];let cmnerr=commonErrors.filter(function check(re){return e.message.match(re);});if(cmnerr.length>0){err=e;}else{err=new Error('Could not parse jison lexer spec in JSON AUTODETECT mode:\nin JISON Mode we get Error: '+e.message+'\n\nwhile JSON5 Mode produces Error: '+ex1.message);err.secondary_exception=e;err.stack=ex1.stack;}}else{err=new Error('Could not parse lexer spec\nError: '+e.message);err.stack=e.stack;}throw err;}}}else{chk_l=lexerSpec;}// Save time! Don't reparse the entire lexer spec *again* inside the code generators when that's not necessary: return chk_l;}// expand macros and convert matchers to RegExp's -function prepareRules(dict,actions,caseHelper,tokens,startConditions,opts){var m,i,k,rule,action,conditions;var active_conditions;assert__default['default'](Array.isArray(dict.rules));var rules=dict.rules.slice(0);// shallow copy of the rules array as we MAY modify it in here! -var newRules=[];var macros={};var regular_rule_count=0;var simple_rule_count=0;// Assure all options are camelCased: +function prepareRules(dict,actions,caseHelper,tokens,startConditions,opts){let m,i,k,rule,action,conditions;let active_conditions;assert__default['default'](Array.isArray(dict.rules));let rules=dict.rules.slice(0);// shallow copy of the rules array as we MAY modify it in here! +let newRules=[];let macros={};let regular_rule_count=0;let simple_rule_count=0;// Assure all options are camelCased: assert__default['default'](typeof opts.options['case-insensitive']==='undefined');if(!tokens){tokens={};}if(opts.options.flex&&rules.length>0){rules.push(['.','console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']);}// Depending on the location within the regex we need different expansions of the macros: // one expansion for when a macro is *inside* a `[...]` and another expansion when a macro // is anywhere else in a regex: if(dict.macros){macros=prepareMacros(dict.macros,opts);}function tokenNumberReplacement(str,token){return'return '+(tokens[token]||'\''+token.replace(/'/g,'\\\'')+'\'');}// Make sure a comment does not contain any embedded '*/' end-of-comment marker // as that would break the generated code function postprocessComment(str){if(Array.isArray(str)){str=str.join(' ');}str=str.replace(/\*\//g,'*\\/');// destroy any inner `*/` comment terminator sequence. -return str;}var routingCode=['switch(yyrulenumber) {'];for(i=0;i0){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. -function reduceRegex(s,name,opts,expandAllMacrosInSet_cb,expandAllMacrosElsewhere_cb){var orig=s;function errinfo(){if(name){return'macro [['+name+']]';}else{return'regex [['+orig+']]';}}// propagate deferred exceptions = error reports. -if(s instanceof Error){return s;}var c1,c2;var rv=[];var derr;var se;while(s.length){c1=s.match(CHR_RE$1);if(!c1){// cope with illegal escape sequences too! -return new Error(errinfo()+': illegal escape sequence at start of regex part: '+s);}else{c1=c1[0];}s=s.substr(c1.length);switch(c1){case'[':// this is starting a set within the regex: scan until end of set! -var set_content=[];var l=new Array(UNICODE_BASE_PLANE_MAX_CP$1+1);while(s.length){var inner=s.match(SET_PART_RE$1);if(!inner){inner=s.match(CHR_RE$1);if(!inner){// cope with illegal escape sequences too! -return new Error(errinfo()+': illegal escape sequence at start of regex part: '+s);}else{inner=inner[0];}if(inner===']')break;}else{inner=inner[0];}set_content.push(inner);s=s.substr(inner.length);}// ensure that we hit the terminating ']': +function reduceRegex(s,name,opts,expandAllMacrosInSet_cb,expandAllMacrosElsewhere_cb){let orig=s;function errinfo(){if(name){return'macro [['+name+']]';}return'regex [['+orig+']]';}// propagate deferred exceptions = error reports. +if(s instanceof Error){return s;}let c1,c2;let rv=[];let derr;let se;while(s.length){c1=s.match(CHR_RE$1);if(!c1){// cope with illegal escape sequences too! +return new Error(errinfo()+': illegal escape sequence at start of regex part: '+s);}c1=c1[0];s=s.substr(c1.length);switch(c1){case'[':// this is starting a set within the regex: scan until end of set! +var set_content=[];var l=new Array(UNICODE_BASE_PLANE_MAX_CP$1+1);while(s.length){let inner=s.match(SET_PART_RE$1);if(!inner){inner=s.match(CHR_RE$1);if(!inner){// cope with illegal escape sequences too! +return new Error(errinfo()+': illegal escape sequence at start of regex part: '+s);}inner=inner[0];if(inner===']')break;}else{inner=inner[0];}set_content.push(inner);s=s.substr(inner.length);}// ensure that we hit the terminating ']': c2=s.match(CHR_RE$1);if(!c2){// cope with illegal escape sequences too! -return new Error(errinfo()+': regex set expression is broken: "'+s+'"');}else{c2=c2[0];}if(c2!==']'){return new Error(errinfo()+': regex set expression is broken: apparently unterminated');}s=s.substr(c2.length);se=set_content.join('');// expand any macros in here: +return new Error(errinfo()+': regex set expression is broken: "'+s+'"');}c2=c2[0];if(c2!==']'){return new Error(errinfo()+': regex set expression is broken: apparently unterminated');}s=s.substr(c2.length);se=set_content.join('');// expand any macros in here: if(expandAllMacrosInSet_cb){se=expandAllMacrosInSet_cb(se);assert__default['default'](se);if(se instanceof Error){return new Error(errinfo()+': '+se.message);}}derr=setmgmt.set2bitarray(l,se,opts);if(derr instanceof Error){return new Error(errinfo()+': '+derr.message);}// find out which set expression is optimal in size: var s1=setmgmt.produceOptimizedRegex4Set(l);// check if the source regex set potentially has any expansions (guestimate!) // @@ -3308,7 +3340,7 @@ case'\\p':c2=s.match(XREGEXP_UNICODE_ESCAPE_RE$1);if(c2){c2=c2[0];s=s.substr(c2. rv.push(c1+c2);}else{// nothing to stretch this match, hence nothing to expand. rv.push(c1);}break;// Either a range expression or the start of a macro reference: `.{1,3}` or `{NAME}`. // Treat it as a macro reference and see if it will expand to anything: -case'{':c2=s.match(NOTHING_SPECIAL_RE$1);if(c2){c2=c2[0];s=s.substr(c2.length);var c3=s[0];s=s.substr(c3.length);if(c3==='}'){// possibly a macro name in there... Expand if possible: +case'{':c2=s.match(NOTHING_SPECIAL_RE$1);if(c2){c2=c2[0];s=s.substr(c2.length);let c3=s[0];s=s.substr(c3.length);if(c3==='}'){// possibly a macro name in there... Expand if possible: c2=c1+c2+c3;if(expandAllMacrosElsewhere_cb){c2=expandAllMacrosElsewhere_cb(c2);assert__default['default'](c2);if(c2 instanceof Error){return new Error(errinfo()+': '+c2.message);}}}else{// not a well-terminated macro reference or something completely different: // we do not even attempt to expand this as there's guaranteed nothing to expand // in this bit. @@ -3324,11 +3356,11 @@ rv.push(c1+c2);}else{// nothing to stretch this match, hence nothing to expand. rv.push(c1);}break;}}s=rv.join('');// When this result is suitable for use in a set, than we should be able to compile // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: -try{var re;re=new XRegExp__default['default'](s);re.test(s[0]);}catch(ex){// make sure we produce a regex expression which will fail badly when it is used +try{let re;re=new XRegExp__default['default'](s);re.test(s[0]);}catch(ex){// make sure we produce a regex expression which will fail badly when it is used // in actual code: return new Error(errinfo()+': expands to an invalid regex: /'+s+'/');}assert__default['default'](s);return s;}// expand macros within macros and cache the result -function prepareMacros(dict_macros,opts){var macros={};// expand a `{NAME}` macro which exists inside a `[...]` set: -function expandMacroInSet(i){var k,a,m;if(!macros[i]){m=dict_macros[i];if(m.indexOf('{')>=0){// set up our own record so we can detect definition loops: +function prepareMacros(dict_macros,opts){let macros={};// expand a `{NAME}` macro which exists inside a `[...]` set: +function expandMacroInSet(i){let k,a,m;if(!macros[i]){m=dict_macros[i];if(m.indexOf('{')>=0){// set up our own record so we can detect definition loops: macros[i]={in_set:false,elsewhere:null,raw:dict_macros[i]};for(k in dict_macros){if(dict_macros.hasOwnProperty(k)&&i!==k){// it doesn't matter if the lexer recognized that the inner macro(s) // were sitting inside a `[...]` set or not: the fact that they are used // here in macro `i` which itself sits in a set, makes them *all* live in @@ -3340,18 +3372,18 @@ if(XRegExp__default['default']._getUnicodeProperty(k)){// Work-around so that yo // Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories, // while using `\p{ASCII}` as a *macro expansion* of the `ASCII` // macro: -if(k.toUpperCase()!==k){m=new Error('Cannot use name "'+k+'" as a macro name as it clashes with the same XRegExp "\\p{..}" Unicode \'General Category\' Property name. Use all-uppercase macro names, e.g. name your macro "'+k.toUpperCase()+'" to work around this issue or give your offending macro a different name.');break;}}a=m.split('{'+k+'}');if(a.length>1){var x=expandMacroInSet(k);assert__default['default'](x);if(x instanceof Error){m=x;break;}m=a.join(x);}}}}var mba=setmgmt.reduceRegexToSetBitArray(m,i,opts);var s1;// propagate deferred exceptions = error reports. +if(k.toUpperCase()!==k){m=new Error('Cannot use name "'+k+'" as a macro name as it clashes with the same XRegExp "\\p{..}" Unicode \'General Category\' Property name. Use all-uppercase macro names, e.g. name your macro "'+k.toUpperCase()+'" to work around this issue or give your offending macro a different name.');break;}}a=m.split('{'+k+'}');if(a.length>1){let x=expandMacroInSet(k);assert__default['default'](x);if(x instanceof Error){m=x;break;}m=a.join(x);}}}}let mba=setmgmt.reduceRegexToSetBitArray(m,i,opts);let s1;// propagate deferred exceptions = error reports. if(mba instanceof Error){s1=mba;}else{s1=setmgmt.bitarray2set(mba,false);m=s1;}macros[i]={in_set:s1,elsewhere:null,raw:dict_macros[i]};}else{m=macros[i].in_set;if(m instanceof Error){// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away! return new Error(m.message);}// detect definition loop: -if(m===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}}return m;}function expandMacroElsewhere(i){var m;if(macros[i].elsewhere==null){m=dict_macros[i];// set up our own record so we can detect definition loops: +if(m===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}}return m;}function expandMacroElsewhere(i){let m;if(macros[i].elsewhere==null){m=dict_macros[i];// set up our own record so we can detect definition loops: macros[i].elsewhere=false;// the macro MAY contain other macros which MAY be inside a `[...]` set in this // macro or elsewhere, hence we must parse the regex: m=reduceRegex(m,i,opts,expandAllMacrosInSet,expandAllMacrosElsewhere);// propagate deferred exceptions = error reports. if(m instanceof Error){return m;}macros[i].elsewhere=m;}else{m=macros[i].elsewhere;if(m instanceof Error){// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away! return m;}// detect definition loop: -if(m===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}}return m;}function expandAllMacrosInSet(s){var i,x;// process *all* the macros inside [...] set: -if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){var a=s.split('{'+i+'}');if(a.length>1){x=expandMacroInSet(i);assert__default['default'](x);if(x instanceof Error){return new Error('failure to expand the macro ['+i+'] in set ['+s+']: '+x.message);}s=a.join(x);}// stop the brute-force expansion attempt when we done 'em all: -if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s){var i,x;// When we process the remaining macro occurrences in the regex +if(m===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}}return m;}function expandAllMacrosInSet(s){let i,x;// process *all* the macros inside [...] set: +if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){let a=s.split('{'+i+'}');if(a.length>1){x=expandMacroInSet(i);assert__default['default'](x);if(x instanceof Error){return new Error('failure to expand the macro ['+i+'] in set ['+s+']: '+x.message);}s=a.join(x);}// stop the brute-force expansion attempt when we done 'em all: +if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s){let i,x;// When we process the remaining macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. // // Meanwhile the cached expansion will expand any submacros into @@ -3361,21 +3393,21 @@ if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s) // // This is a BREAKING CHANGE from vanilla jison 0.4.15! if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){// These are all submacro expansions, hence non-capturing grouping is applied: -var a=s.split('{'+i+'}');if(a.length>1){x=expandMacroElsewhere(i);assert__default['default'](x);if(x instanceof Error){return new Error('failure to expand the macro ['+i+'] in regex /'+s+'/: '+x.message);}s=a.join('(?:'+x+')');}// stop the brute-force expansion attempt when we done 'em all: -if(s.indexOf('{')===-1){break;}}}}return s;}var i;if(opts.debug)console.log('\n############## RAW macros: ',dict_macros);// first we create the part of the dictionary which is targeting the use of macros +let a=s.split('{'+i+'}');if(a.length>1){x=expandMacroElsewhere(i);assert__default['default'](x);if(x instanceof Error){return new Error('failure to expand the macro ['+i+'] in regex /'+s+'/: '+x.message);}s=a.join('(?:'+x+')');}// stop the brute-force expansion attempt when we done 'em all: +if(s.indexOf('{')===-1){break;}}}}return s;}let i;if(opts.debug)console.log('\n############## RAW macros: ',dict_macros);// first we create the part of the dictionary which is targeting the use of macros // *inside* `[...]` sets; once we have completed that half of the expansions work, // we then go and expand the macros for when they are used elsewhere in a regex: // iff we encounter submacros then which are used *inside* a set, we can use that // first half dictionary to speed things up a bit as we can use those expansions // straight away! for(i in dict_macros){if(dict_macros.hasOwnProperty(i)){expandMacroInSet(i);}}for(i in dict_macros){if(dict_macros.hasOwnProperty(i)){expandMacroElsewhere(i);}}if(opts.debug)console.log('\n############### expanded macros: ',macros);return macros;}// expand macros in a regex; expands them recursively -function expandMacros(src,macros,opts){var expansion_count=0;// By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! +function expandMacros(src,macros,opts){let expansion_count=0;// By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! // Hence things should be easy in there: -function expandAllMacrosInSet(s){var i,m,x;// process *all* the macros inside [...] set: -if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){m=macros[i];var a=s.split('{'+i+'}');if(a.length>1){x=m.in_set;assert__default['default'](x);if(x instanceof Error){// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away! +function expandAllMacrosInSet(s){let i,m,x;// process *all* the macros inside [...] set: +if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){m=macros[i];let a=s.split('{'+i+'}');if(a.length>1){x=m.in_set;assert__default['default'](x);if(x instanceof Error){// this turns out to be an macro with 'issues' and it is used, so the 'issues' do matter: bombs away! throw x;}// detect definition loop: if(x===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}s=a.join(x);expansion_count++;}// stop the brute-force expansion attempt when we done 'em all: -if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s){var i,m,x;// When we process the main macro occurrences in the regex +if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s){let i,m,x;// When we process the main macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. // // Meanwhile the cached expansion will expand any submacros into @@ -3384,7 +3416,7 @@ if(s.indexOf('{')===-1){break;}}}}return s;}function expandAllMacrosElsewhere(s) // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! -if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){m=macros[i];var a=s.split('{'+i+'}');if(a.length>1){// These are all main macro expansions, hence CAPTURING grouping is applied: +if(s.indexOf('{')>=0){for(i in macros){if(macros.hasOwnProperty(i)){m=macros[i];let a=s.split('{'+i+'}');if(a.length>1){// These are all main macro expansions, hence CAPTURING grouping is applied: x=m.elsewhere;assert__default['default'](x);// detect definition loop: if(x===false){return new Error('Macro name "'+i+'" has an illegal, looping, definition, i.e. it\'s definition references itself, either directly or indirectly, via other macros.');}s=a.join('('+x+')');expansion_count++;}// stop the brute-force expansion attempt when we done 'em all: if(s.indexOf('{')===-1){break;}}}}return s;}// When we process the macro occurrences in the regex @@ -3396,7 +3428,7 @@ if(s.indexOf('{')===-1){break;}}}}return s;}// When we process the macro occurre // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! -var s2=reduceRegex(src,null,opts,expandAllMacrosInSet,expandAllMacrosElsewhere);// propagate deferred exceptions = error reports. +let s2=reduceRegex(src,null,opts,expandAllMacrosInSet,expandAllMacrosElsewhere);// propagate deferred exceptions = error reports. if(s2 instanceof Error){throw s2;}// only when we did expand some actual macros do we take the re-interpreted/optimized/regenerated regex from reduceRegex() // in order to keep our test cases simple and rules recognizable. This assumes the user can code good regexes on his own, // as long as no macros are involved... @@ -3404,8 +3436,8 @@ if(s2 instanceof Error){throw s2;}// only when we did expand some actual macros // Also pick the reduced regex when there (potentially) are XRegExp extensions in the original, e.g. `\\p{Number}`, // unless the `xregexp` output option has been enabled. if(expansion_count>0||src.indexOf('\\p{')>=0&&!opts.options.xregexp){src=s2;}else{// Check if the reduced regex is smaller in size; when it is, we still go with the new one! -if(s2.length0){toks[tokens[tok]]=idx;}}var gen=prepareRules(dict,actions,caseHelper,tokens&&toks,opts.conditions,opts);var code=actions.join('\n');'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function(yy){code=code.replace(new RegExp('\\b('+yy+')\\b','g'),'yy_.$1');});return{caseHelperInclude:'{\n'+caseHelper.join(',')+'\n}',actions:`function lexer__performAction(yy, yyrulenumber, YY_START) { +if(s2.length0){toks[tokens[tok]]=idx;}}let gen=prepareRules(dict,actions,caseHelper,tokens&&toks,opts.conditions,opts);let code=actions.join('\n');'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function(yy){code=code.replace(new RegExp('\\b('+yy+')\\b','g'),'yy_.$1');});return{caseHelperInclude:'{\n'+caseHelper.join(',')+'\n}',actions:`function lexer__performAction(yy, yyrulenumber, YY_START) { var yy_ = this; ${code} @@ -3415,7 +3447,7 @@ regular_rule_count:gen.regular_rule_count,simple_rule_count:gen.simple_rule_coun // jison/lib/jison.js @ line 2304:lrGeneratorMixin.generateErrorClass // function generateErrorClass(){// --- START lexer error class --- -var prelude=`/** +const prelude=`/** * 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 @@ -3426,8 +3458,6 @@ var prelude=`/** * @nocollapse */ function JisonLexerError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -3444,9 +3474,9 @@ function JisonLexerError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -3489,43 +3519,59 @@ return prelude;}const jisonLexerErrorDefinition=generateErrorClass();function ge fake.__hacky_backy__ = __hacky_counter__; return fake; } - `;}/** @constructor */function RegExpLexer(dict,input,tokens,build_options){var opts;var dump=false;function test_me(tweak_cb,description,src_exception,ex_callback){opts=processGrammar(dict,tokens,build_options);opts.__in_rules_failure_analysis_mode__=false;prepExportStructures(opts);assert__default['default'](opts.options);if(tweak_cb){tweak_cb();}var source=generateModuleBody(opts);try{// The generated code will always have the `lexer` variable declared at local scope + `;}/** @constructor */function RegExpLexer(dict,input,tokens,build_options){let opts;let dump=false;function test_me(tweak_cb,description,src_exception,ex_callback){opts=processGrammar(dict,tokens,build_options);opts.__in_rules_failure_analysis_mode__=false;prepExportStructures(opts);assert__default['default'](opts.options);if(tweak_cb){tweak_cb();}let source=generateModuleBody(opts);try{// The generated code will always have the `lexer` variable declared at local scope // as `eval()` will use the local scope. // // The compiled code will look something like this: // // ``` -// var lexer; +// let lexer; // bla bla... // ``` // // or // // ``` -// var lexer = { bla... }; +// const lexer = { bla... }; // ``` -var testcode=['// provide a local version for test purposes:',jisonLexerErrorDefinition,'',generateFakeXRegExpClassSrcCode(),'',source,'','return lexer;'].join('\n');var lexer=code_exec$1(testcode,function generated_code_exec_wrapper_regexp_lexer(sourcecode){//console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); -chkBugger$2(sourcecode);var lexer_f=new Function('',sourcecode);return lexer_f();},opts.options,"lexer");if(!lexer){throw new Error('no lexer defined *at all*?!');}if(typeof lexer.options!=='object'||lexer.options==null){throw new Error('your lexer class MUST have an .options member object or it won\'t fly!');}if(typeof lexer.setInput!=='function'){throw new Error('your lexer class MUST have a .setInput function member or it won\'t fly!');}if(lexer.EOF!==1&&lexer.ERROR!==2){throw new Error('your lexer class MUST have these constants defined: lexer.EOF = 1 and lexer.ERROR = 2 or it won\'t fly!');}// When we do NOT crash, we found/killed the problem area just before this call! -if(src_exception&&description){var msg=description;if(typeof description==='function'){msg=description();}src_exception.message+='\n ('+msg+')';}// patch the pre and post handlers in there, now that we have some live code to work with: -if(opts.options){var pre=opts.options.pre_lex;var post=opts.options.post_lex;// since JSON cannot encode functions, we'll have to do it manually now: -if(typeof pre==='function'){lexer.options.pre_lex=pre;}if(typeof post==='function'){lexer.options.post_lex=post;}}if(opts.options.showSource){if(typeof opts.options.showSource==='function'){opts.options.showSource(lexer,source,opts,RegExpLexer);}else{console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n",source,"\n----------------------------------------\n");}}return lexer;}catch(ex){// if (src_exception) { +let testcode=['// provide a local version for test purposes:',jisonLexerErrorDefinition,'',generateFakeXRegExpClassSrcCode(),'',source,'',rmCommonWS$2` + // JISON INJECTED VALIDATION CODE + // which attempts to ascertain you have defined a minimal viable lexer at least: + if (typeof lexer === "undefined") { + throw new SyntaxError("user-defined lexer does not define the required 'lexer' instance."); + } + if (!lexer) { + throw new SyntaxError("user-defined lexer does not define a non-NULL 'lexer' instance."); + } + if (typeof lexer.setInput !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.setInput()' API function."); + } + if (typeof lexer.lex !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.lex()' API function."); + } + // END OF JISON INJECTED VALIDATION CODE + `,'return lexer;'].join('\n');let lexer=code_exec(testcode,function generated_code_exec_wrapper_regexp_lexer(sourcecode){//console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); +chkBugger$2(sourcecode);let lexer_f=new Function('',sourcecode);return lexer_f();},Object.assign({},opts.options,{throwErrorOnCompileFailure:true}),'lexer');if(!lexer){throw new Error('no lexer defined *at all*?!');}if(typeof lexer.options!=='object'||lexer.options==null){throw new Error('your lexer class MUST have an .options member object or it won\'t fly!');}if(typeof lexer.setInput!=='function'){throw new Error('your lexer class MUST have a .setInput function member or it won\'t fly!');}if(lexer.EOF!==1&&lexer.ERROR!==2){throw new Error('your lexer class MUST have these constants defined: lexer.EOF = 1 and lexer.ERROR = 2 or it won\'t fly!');}// When we do NOT crash, we found/killed the problem area just before this call! +if(src_exception&&description){let msg=description;if(typeof description==='function'){msg=description();}src_exception.message+='\n ('+msg+')';}// patch the pre and post handlers in there, now that we have some live code to work with: +if(opts.options){let pre=opts.options.pre_lex;let post=opts.options.post_lex;// since JSON cannot encode functions, we'll have to do it manually now: +if(typeof pre==='function'){lexer.options.pre_lex=pre;}if(typeof post==='function'){lexer.options.post_lex=post;}}if(opts.options.showSource){if(typeof opts.options.showSource==='function'){opts.options.showSource(lexer,source,opts,RegExpLexer);}else{console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n',source,'\n----------------------------------------\n');}}return lexer;}catch(ex){// if (src_exception) { // src_exception.message += '\n (' + description + ': ' + ex.message + ')'; // } -if(ex_callback){ex_callback(ex);}else if(dump){console.log('source code:\n',source);}return false;}}/** @constructor */var lexer=test_me(null,null,null,function(ex){// When we get an exception here, it means some part of the user-specified lexer is botched. +if(ex_callback){ex_callback(ex);}else if(dump){console.log('source code:\n',source);}return false;}}/** @constructor */let lexer=test_me(null,null,null,function(ex){// When we get an exception here, it means some part of the user-specified lexer is botched. // // Now we go and try to narrow down the problem area/category: -assert__default['default'](opts.options);assert__default['default'](opts.options.xregexp!==undefined);var orig_xregexp_opt=!!opts.options.xregexp;if(!test_me(function(){assert__default['default'](opts.options.xregexp!==undefined);opts.options.xregexp=false;opts.showSource=false;},'When you have specified %option xregexp, you must also properly IMPORT the XRegExp library in the generated lexer.',ex,null)){if(!test_me(function(){// restore xregexp option setting: the trouble wasn't caused by the xregexp flag i.c.w. incorrect XRegExp library importing! -opts.options.xregexp=orig_xregexp_opt;opts.conditions=[];opts.showSource=false;},function(){assert__default['default'](Array.isArray(opts.rules));return opts.rules.length>0?'One or more of your lexer state names are possibly botched?':'Your custom lexer is somehow botched.';},ex,null)){var rulesSpecSize;if(!test_me(function(){// store the parsed rule set size so we can use that info in case +assert__default['default'](opts.options);assert__default['default'](opts.options.xregexp!==undefined);let orig_xregexp_opt=!!opts.options.xregexp;if(!test_me(function(){assert__default['default'](opts.options.xregexp!==undefined);opts.options.xregexp=false;opts.showSource=false;},'When you have specified %option xregexp, you must also properly IMPORT the XRegExp library in the generated lexer.',ex,null)){if(!test_me(function(){// restore xregexp option setting: the trouble wasn't caused by the xregexp flag i.c.w. incorrect XRegExp library importing! +opts.options.xregexp=orig_xregexp_opt;opts.conditions=[];opts.showSource=false;},function(){assert__default['default'](Array.isArray(opts.rules));return opts.rules.length>0?'One or more of your lexer state names are possibly botched?':'Your custom lexer is somehow botched.';},ex,null)){let rulesSpecSize;if(!test_me(function(){// store the parsed rule set size so we can use that info in case // this attempt also fails: assert__default['default'](Array.isArray(opts.rules));rulesSpecSize=opts.rules.length;// opts.conditions = []; opts.rules=[];opts.showSource=false;opts.__in_rules_failure_analysis_mode__=true;},'One or more of your lexer rules are possibly botched?',ex,null)){// kill each rule action block, one at a time and test again after each 'edit': -var rv=false;for(var i=0,len=rulesSpecSize;i= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -3752,8 +3789,6 @@ return`{ * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -3763,14 +3798,14 @@ return`{ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -3781,8 +3816,6 @@ return`{ * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -3790,40 +3823,40 @@ return`{ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -3835,7 +3868,7 @@ return`{ this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -3843,7 +3876,7 @@ return`{ last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -3904,9 +3937,7 @@ return`{ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -3925,8 +3956,6 @@ return`{ * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set \`done\` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -3935,7 +3964,7 @@ return`{ this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -3945,13 +3974,13 @@ return`{ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\\n') { lines = true; } else if (ch === '\\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\\n') { slice_len++; ch += ch2; @@ -3983,10 +4012,8 @@ return`{ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -4018,8 +4045,8 @@ return`{ // Get last entirely matched line into the \`pre_lines[]\` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -4037,9 +4064,9 @@ return`{ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -4049,14 +4076,12 @@ return`{ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -4067,8 +4092,6 @@ return`{ * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -4081,19 +4104,17 @@ return`{ * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the \`parseError()\` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // \`.lex()\` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -4106,8 +4127,6 @@ return`{ * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -4130,24 +4149,24 @@ return`{ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substr\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -4159,8 +4178,8 @@ return`{ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to \`maxSize\` (default: 20). @@ -4186,24 +4205,25 @@ return`{ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > \`lookAhead()\` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substring\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -4212,7 +4232,7 @@ return`{ } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -4231,10 +4251,8 @@ return`{ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^'; }, @@ -4256,15 +4274,13 @@ return`{ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -4395,58 +4411,54 @@ return`{ * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\\t/g, ' '); @@ -4455,13 +4467,13 @@ return`{ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -4483,15 +4495,13 @@ return`{ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -4503,8 +4513,8 @@ return`{ rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -4533,13 +4543,7 @@ return`{ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -4568,10 +4572,10 @@ return`{ }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -4599,7 +4603,7 @@ return`{ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -4610,7 +4614,7 @@ return`{ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -4632,8 +4636,6 @@ return`{ * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -4642,17 +4644,13 @@ return`{ this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -4662,67 +4660,75 @@ return`{ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that \`parseError()\` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) \`parseError()\` @@ -4749,9 +4755,7 @@ return`{ * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -4794,24 +4798,24 @@ return`{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -4831,9 +4835,7 @@ return`{ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -4843,24 +4845,24 @@ return`{ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -4868,7 +4870,7 @@ return`{ this._clear_state = 0; } - + return r; }, @@ -4881,9 +4883,7 @@ return`{ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -4891,7 +4891,7 @@ return`{ (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -4906,8 +4906,6 @@ return`{ * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -4919,8 +4917,6 @@ return`{ * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -4934,15 +4930,12 @@ return`{ * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -4954,14 +4947,11 @@ return`{ * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -4972,16 +4962,14 @@ return`{ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -4991,8 +4979,6 @@ return`{ * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; } }`;// --- END lexer kernel --- @@ -5015,7 +5001,7 @@ function stripUnusedLexerCode(src,opt){// uses yyleng: ..................... $ // uses display APIs pastInput(), upcomingInput(), showPosition(): // ............................. ${opt.lexerActionsUseDisplayAPIs} // uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC} -var new_src;try{var ast=helpers.parseCodeChunkToAST(src,opt);new_src=helpers.prettyPrintAST(ast,opt);}catch(ex){let line=ex.lineNumber||0;let a=src.split(/\r?\n/g);let len=a.length;let minl=Math.max(0,line-10);let b=a.slice(minl,line+10);let c=b.splice(line-minl,0,"","^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^","");let offendingChunk=' '+b.join('\n ');console.error(rmCommonWS$2` +let new_src;try{let ast=helpers.parseCodeChunkToAST(src,opt);new_src=helpers.prettyPrintAST(ast,opt);}catch(ex){let line=ex.lineNumber||0;let a=src.split(/\r?\n/g);let len=a.length;let minl=Math.max(0,line-10);let b=a.slice(minl,line+10);let c=b.splice(line-minl,0,'','^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^','');let offendingChunk=' '+b.join('\n ');console.error(rmCommonWS$2` stripUnusedLexerCode WARNING: JISON failed to reformat the generated lexer. @@ -5071,8 +5057,8 @@ new_src=new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g,rmCommonWS$2 // --------- END OF REPORT ----------- `);return new_src;}// generate lexer source from a grammar -/** @public */function generate(dict,tokens,build_options){var opt=processGrammar(dict,tokens,build_options);return generateFromOpts(opt);}// process the grammar and build final data structures and functions -/** @public */function processGrammar(dict,tokens,build_options){build_options=build_options||{};var opts={// include the knowledge passed through `build_options` about which lexer +/** @public */function generate(dict,tokens,build_options){let opt=processGrammar(dict,tokens,build_options);return generateFromOpts(opt);}// process the grammar and build final data structures and functions +/** @public */function processGrammar(dict,tokens,build_options){build_options=build_options||{};let opts={// include the knowledge passed through `build_options` about which lexer // features will actually be *used* by the environment (which in 99.9% // of cases is a jison *parser*): // @@ -5085,22 +5071,22 @@ opts.lex_rule_dictionary=dict;// Always provide the lexer with an options object opts.options=mkStdOptions(build_options,dict.options);opts.moduleType=opts.options.moduleType;opts.moduleName=opts.options.moduleName;opts.conditions=prepareStartConditions(dict.startConditions);opts.conditions.INITIAL={rules:[],inclusive:true};// only produce rule action code blocks when there are any rules at all; // a "custom lexer" has ZERO rules and must be defined entirely in // other code blocks: -var code=dict.rules?buildActions(dict,tokens,opts):{};opts.performAction=code.actions;opts.caseHelperInclude=code.caseHelperInclude;opts.rules=code.rules||[];opts.macros=code.macros;opts.regular_rule_count=code.regular_rule_count;opts.simple_rule_count=code.simple_rule_count;opts.conditionStack=['INITIAL'];opts.actionInclude=dict.actionInclude||'';opts.moduleInclude=(opts.moduleInclude||'')+(dict.moduleInclude||'').trim();return opts;}// Assemble the final source from the processed grammar -/** @public */function generateFromOpts(opt){var code='';switch(opt.moduleType){case'js':code=generateModule(opt);break;case'amd':code=generateAMDModule(opt);break;case'es':code=generateESModule(opt);break;case'commonjs':code=generateCommonJSModule(opt);break;default:throw new Error('unsupported moduleType: '+opt.moduleType);}return code;}function generateRegexesInitTableCode(opt){var a=opt.rules;var print_xregexp=opt.options&&opt.options.xregexp;var id_display_width=1+Math.log10(a.length|1)|0;var ws_prefix=new Array(id_display_width).join(' ');var b=a.map(function generateXRegExpInitCode(re,idx){var idx_str=(ws_prefix+idx).substr(-id_display_width);if(re instanceof XRegExp__default['default']){// When we don't need the special XRegExp sauce at run-time, we do with the original +let code=dict.rules?buildActions(dict,tokens,opts):{};opts.performAction=code.actions;opts.caseHelperInclude=code.caseHelperInclude;opts.rules=code.rules||[];opts.macros=code.macros;opts.regular_rule_count=code.regular_rule_count;opts.simple_rule_count=code.simple_rule_count;opts.conditionStack=['INITIAL'];opts.actionInclude=dict.actionInclude||'';opts.moduleInclude=(opts.moduleInclude||'')+(dict.moduleInclude||'').trim();return opts;}// Assemble the final source from the processed grammar +/** @public */function generateFromOpts(opt){let code='';switch(opt.moduleType){case'js':code=generateModule(opt);break;case'amd':code=generateAMDModule(opt);break;case'es':code=generateESModule(opt);break;case'commonjs':code=generateCommonJSModule(opt);break;default:throw new Error('unsupported moduleType: '+opt.moduleType);}return code;}function generateRegexesInitTableCode(opt){let a=opt.rules;let print_xregexp=opt.options&&opt.options.xregexp;let id_display_width=1+Math.log10(a.length|1)|0;let ws_prefix=new Array(id_display_width).join(' ');let b=a.map(function generateXRegExpInitCode(re,idx){let idx_str=(ws_prefix+idx).substr(-id_display_width);if(re instanceof XRegExp__default['default']){// When we don't need the special XRegExp sauce at run-time, we do with the original // JavaScript RegExp instance a.k.a. 'native regex': if(re.xregexp.isNative||!print_xregexp){return`/* ${idx_str}: */ ${re}`;}// And make sure to escape the regex to make it suitable for placement inside a *string* // as it is passed as a string argument to the XRegExp constructor here. -var re_src=re.xregexp.source.replace(/[\\"]/g,'\\$&');return`/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`;}else{return`/* ${idx_str}: */ ${re}`;}});return b.join(',\n');}function generateModuleBody(opt){// make the JSON output look more like JavaScript: -function cleanupJSON(str){str=str.replace(/ "rules": \[/g,' rules: [');str=str.replace(/ "inclusive": /g,' inclusive: ');return str;}function produceOptions(opts){var obj={};var do_not_pass={debug:!opts.debug,// do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! -enableDebugLogs:1,json:1,_:1,noMain:1,dumpSourceCodeOnFailure:1,throwErrorOnCompileFailure:1,reportStats:1,file:1,outfile:1,inputPath:1,inputFilename:1,defaultModuleName:1,moduleName:1,moduleType:1,lexerErrorsAreRecoverable:0,flex:0,backtrack_lexer:0,caseInsensitive:0,showSource:1,exportAST:1,exportAllTables:1,exportSourceCode:1,prettyCfg:1,parseActionsUseYYLENG:1,parseActionsUseYYLINENO:1,parseActionsUseYYTEXT:1,parseActionsUseYYLOC:1,parseActionsUseParseError:1,parseActionsUseYYERROR:1,parseActionsUseYYRECOVERING:1,parseActionsUseYYERROK:1,parseActionsUseYYCLEARIN:1,parseActionsUseValueTracking:1,parseActionsUseValueAssignment:1,parseActionsUseLocationTracking:1,parseActionsUseLocationAssignment:1,parseActionsUseYYSTACK:1,parseActionsUseYYSSTACK:1,parseActionsUseYYSTACKPOINTER:1,parseActionsUseYYRULELENGTH:1,parseActionsUseYYMERGELOCATIONINFO:1,parserHasErrorRecovery:1,parserHasErrorReporting:1,lexerActionsUseYYLENG:1,lexerActionsUseYYLINENO:1,lexerActionsUseYYTEXT:1,lexerActionsUseYYLOC:1,lexerActionsUseParseError:1,lexerActionsUseYYERROR:1,lexerActionsUseLocationTracking:1,lexerActionsUseMore:1,lexerActionsUseUnput:1,lexerActionsUseReject:1,lexerActionsUseLess:1,lexerActionsUseDisplayAPIs:1,lexerActionsUseDescribeYYLOC:1};for(var k in opts){if(!do_not_pass[k]&&opts[k]!=null&&opts[k]!==false){// make sure numeric values are encoded as numeric, the rest as boolean/string. -if(typeof opts[k]==='string'){var f=parseFloat(opts[k]);if(f==opts[k]){obj[k]=f;continue;}}obj[k]=opts[k];}}// And now some options which should receive some special processing: -var pre=obj.pre_lex;var post=obj.post_lex;// since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: -if(pre){obj.pre_lex=true;}if(post){obj.post_lex=true;}var js=JSON.stringify(obj,null,2);js=js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$1})": `,'g'),' $1: ');js=js.replace(/^( +)pre_lex: true(,)?$/gm,function(m,ls,tc){return ls+'pre_lex: '+String(pre)+(tc||'');});js=js.replace(/^( +)post_lex: true(,)?$/gm,function(m,ls,tc){return ls+'post_lex: '+String(post)+(tc||'');});return js;}var out;if(opt.rules.length>0||opt.__in_rules_failure_analysis_mode__){// we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: +let re_src=re.xregexp.source.replace(/[\\"]/g,'\\$&');return`/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`;}return`/* ${idx_str}: */ ${re}`;});return b.join(',\n');}function generateModuleBody(opt){// make the JSON output look more like JavaScript: +function cleanupJSON(str){str=str.replace(/ {2}"rules": \[/g,' rules: [');str=str.replace(/ {2}"inclusive": /g,' inclusive: ');return str;}function produceOptions(opts){let obj={};const do_not_pass={debug:!opts.debug,// do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! +enableDebugLogs:1,json:1,_:1,noMain:1,dumpSourceCodeOnFailure:1,throwErrorOnCompileFailure:1,reportStats:1,file:1,outfile:1,inputPath:1,inputFilename:1,defaultModuleName:1,moduleName:1,moduleType:1,lexerErrorsAreRecoverable:0,flex:0,backtrack_lexer:0,caseInsensitive:0,showSource:1,exportAST:1,exportAllTables:1,exportSourceCode:1,prettyCfg:1,parseActionsUseYYLENG:1,parseActionsUseYYLINENO:1,parseActionsUseYYTEXT:1,parseActionsUseYYLOC:1,parseActionsUseParseError:1,parseActionsUseYYERROR:1,parseActionsUseYYRECOVERING:1,parseActionsUseYYERROK:1,parseActionsUseYYCLEARIN:1,parseActionsUseValueTracking:1,parseActionsUseValueAssignment:1,parseActionsUseLocationTracking:1,parseActionsUseLocationAssignment:1,parseActionsUseYYSTACK:1,parseActionsUseYYSSTACK:1,parseActionsUseYYSTACKPOINTER:1,parseActionsUseYYRULELENGTH:1,parseActionsUseYYMERGELOCATIONINFO:1,parserHasErrorRecovery:1,parserHasErrorReporting:1,lexerActionsUseYYLENG:1,lexerActionsUseYYLINENO:1,lexerActionsUseYYTEXT:1,lexerActionsUseYYLOC:1,lexerActionsUseParseError:1,lexerActionsUseYYERROR:1,lexerActionsUseLocationTracking:1,lexerActionsUseMore:1,lexerActionsUseUnput:1,lexerActionsUseReject:1,lexerActionsUseLess:1,lexerActionsUseDisplayAPIs:1,lexerActionsUseDescribeYYLOC:1};for(let k in opts){if(!do_not_pass[k]&&opts[k]!=null&&opts[k]!==false){// make sure numeric values are encoded as numeric, the rest as boolean/string. +if(typeof opts[k]==='string'){let f=parseFloat(opts[k]);if(f==opts[k]){obj[k]=f;continue;}}obj[k]=opts[k];}}// And now some options which should receive some special processing: +let pre=obj.pre_lex;let post=obj.post_lex;// since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: +if(pre){obj.pre_lex=true;}if(post){obj.post_lex=true;}let js=JSON.stringify(obj,null,2);js=js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$1})": `,'g'),' $1: ');js=js.replace(/^( +)pre_lex: true(,)?$/gm,function(m,ls,tc){return ls+'pre_lex: '+String(pre)+(tc||'');});js=js.replace(/^( +)post_lex: true(,)?$/gm,function(m,ls,tc){return ls+'post_lex: '+String(post)+(tc||'');});return js;}let out;if(opt.rules.length>0||opt.__in_rules_failure_analysis_mode__){// we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. -var code=[rmCommonWS$2` - var lexer = { - `,'/*JISON-LEX-ANALYTICS-REPORT*/'/* slot #1: placeholder for analysis report further below */];// get the RegExpLexer.prototype in source code form: -var protosrc=getRegExpLexerPrototype();// and strip off the surrounding bits we don't want: +let code=[rmCommonWS$2` + const lexer = { + `,'/* JISON-LEX-ANALYTICS-REPORT */\n'/* slot #1: placeholder for analysis report further below */];// get the RegExpLexer.prototype in source code form: +let protosrc=getRegExpLexerPrototype();// and strip off the surrounding bits we don't want: protosrc=protosrc.replace(/^[\s\r\n]*\{/,'').replace(/\s*\}[\s\r\n]*$/,'').trim();code.push(protosrc+',\n');assert__default['default'](opt.options);// Assure all options are camelCased: assert__default['default'](typeof opt.options['case-insensitive']==='undefined');code.push(' options: '+produceOptions(opt.options));/* function isEmpty(code) { @@ -5113,7 +5099,7 @@ assert__default['default'](typeof opt.options['case-insensitive']==='undefined') } } - */var performActionCode=String(opt.performAction);var simpleCaseActionClustersCode=String(opt.caseHelperInclude);var rulesCode=generateRegexesInitTableCode(opt);var conditionsCode=cleanupJSON(JSON.stringify(opt.conditions,null,2));code.push(rmCommonWS$2`, + */let performActionCode=String(opt.performAction);let simpleCaseActionClustersCode=String(opt.caseHelperInclude);let rulesCode=generateRegexesInitTableCode(opt);let conditionsCode=cleanupJSON(JSON.stringify(opt.conditions,null,2));code.push(rmCommonWS$2`, JisonLexerError: JisonLexerError, performAction: ${performActionCode}, simpleCaseActionClusters: ${simpleCaseActionClustersCode}, @@ -5126,18 +5112,16 @@ assert__default['default'](typeof opt.options['case-insensitive']==='undefined') // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // -// Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter +// Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. -out='var lexer;\n';assert__default['default'](opt.regular_rule_count===0);assert__default['default'](opt.simple_rule_count===0);opt.is_custom_lexer=true;if(opt.actionInclude){out+=opt.actionInclude+(!opt.actionInclude.match(/;[\s\r\n]*$/)?';':'')+'\n';}}// The output of this function is guaranteed to read something like this: +out='\n';assert__default['default'](opt.regular_rule_count===0);assert__default['default'](opt.simple_rule_count===0);opt.is_custom_lexer=true;if(opt.actionInclude){out+=opt.actionInclude+(!opt.actionInclude.match(/;[\s\r\n]*$/)?';':'')+'\n';}}// The output of this function is guaranteed to read something like this: // // ``` -// var lexer; -// // bla bla bla bla ... lotsa bla bla; // ``` // // and that should work nicely as an `eval()`-able piece of source code. -return out;}function generateGenericHeaderComment(){var out=rmCommonWS$2` +return out;}function generateGenericHeaderComment(){let out=rmCommonWS$2` /* lexer generated by jison-lex ${version} */ /* @@ -5356,8 +5340,8 @@ return out;}function generateGenericHeaderComment(){var out=rmCommonWS$2` * } */ `;return out;}function prepareOptions(opt){opt=opt||{};// check for illegal identifier -if(!opt.moduleName||!opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)){if(opt.moduleName){var msg='WARNING: The specified moduleName "'+opt.moduleName+'" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.';if(typeof opt.warn_cb==='function'){opt.warn_cb(msg);}else{// do not treat as warning; barf hairball instead so that this oddity gets noticed right away! -throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return opt;}function generateModule(opt){opt=prepareOptions(opt);var modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';var src=rmCommonWS$2` +if(!opt.moduleName||!opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)){if(opt.moduleName){let msg='WARNING: The specified moduleName "'+opt.moduleName+'" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.';if(typeof opt.warn_cb==='function'){opt.warn_cb(msg);}else{// do not treat as warning; barf hairball instead so that this oddity gets noticed right away! +throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return opt;}function generateModule(opt){opt=prepareOptions(opt);let modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';let src=rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -5371,7 +5355,7 @@ throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return return lexer; })(); - `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateAMDModule(opt){opt=prepareOptions(opt);var modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';var src=rmCommonWS$2` + `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateAMDModule(opt){opt=prepareOptions(opt);let modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';let src=rmCommonWS$2` ${generateGenericHeaderComment()} define([], function () { @@ -5385,10 +5369,10 @@ throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return return lexer; }); - `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateESModule(opt){opt=prepareOptions(opt);var modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';var src=rmCommonWS$2` + `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateESModule(opt){opt=prepareOptions(opt);let modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';let src=rmCommonWS$2` ${generateGenericHeaderComment()} - var lexer = (function () { + const lexer = (function () { "use strict"; ${jisonLexerErrorDefinition} @@ -5408,7 +5392,7 @@ throw new Error(msg);}}opt.moduleName='lexer';}prepExportStructures(opt);return lexer, yylex as lex }; - `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateCommonJSModule(opt){opt=prepareOptions(opt);var modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';var src=rmCommonWS$2` + `;src=stripUnusedLexerCode(src,opt);opt.exportSourceCode.all=src;return src;}function generateCommonJSModule(opt){opt=prepareOptions(opt);let modIncSrc=opt.moduleInclude?opt.moduleInclude+';':'';let src=rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { diff --git a/packages/jison-lex/dist/regexp-lexer-umd.js b/packages/jison-lex/dist/regexp-lexer-umd.js index 0f1e57245..9eddea287 100644 --- a/packages/jison-lex/dist/regexp-lexer-umd.js +++ b/packages/jison-lex/dist/regexp-lexer-umd.js @@ -1,8 +1,8 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@gerhobbelt/xregexp'), require('@gerhobbelt/json5'), require('fs'), require('path'), require('recast'), require('@babel/core'), require('assert')) : - typeof define === 'function' && define.amd ? define(['@gerhobbelt/xregexp', '@gerhobbelt/json5', 'fs', 'path', 'recast', '@babel/core', 'assert'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['regexp-lexer'] = factory(global.XRegExp, global.JSON5, global.fs, global.path$1, global.recast, global.babel, global.assert$1)); -}(this, (function (XRegExp, JSON5, fs, path$1, recast, babel, assert$1) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@gerhobbelt/xregexp'), require('@gerhobbelt/json5'), require('fs'), require('path'), require('mkdirp'), require('recast'), require('@babel/core'), require('assert')) : + typeof define === 'function' && define.amd ? define(['@gerhobbelt/xregexp', '@gerhobbelt/json5', 'fs', 'path', 'mkdirp', 'recast', '@babel/core', 'assert'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['regexp-lexer'] = factory(global.XRegExp, global.JSON5, global.fs, global.path$1, global.mkdirp, global.recast, global.babel, global.assert$1)); +}(this, (function (XRegExp, JSON5, fs, path$1, mkdirp, recast, babel, assert$1) { 'use strict'; function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } @@ -10,10 +10,11 @@ var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); + var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); - // Return TRUE if `src` starts with `searchString`. + // Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -36,19 +37,19 @@ // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -67,19 +68,21 @@ // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -88,16 +91,19 @@ } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -108,27 +114,79 @@ return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } + // https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words + const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; + })([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' + ]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -146,6 +204,11 @@ .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -154,13 +217,13 @@ function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -171,23 +234,17 @@ break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -210,34 +267,33 @@ /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -260,28 +316,76 @@ // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } + function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; + } + + + function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); + } + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -292,27 +396,37 @@ dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -322,7 +436,7 @@ } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -330,7 +444,7 @@ ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -356,27 +470,43 @@ // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -389,9 +519,10 @@ - var code_exec = { + var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -413,22 +544,22 @@ // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; - // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries + // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; - // Determine which Unicode NonAsciiIdentifierStart characters + // Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. - // + // // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action - // code chunks. - // + // code chunks. + // // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -436,40 +567,40 @@ function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -477,30 +608,30 @@ // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -511,59 +642,59 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -605,38 +736,38 @@ return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -648,18 +779,18 @@ // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -670,56 +801,56 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -727,97 +858,97 @@ typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -825,7 +956,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -838,7 +969,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -851,7 +982,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -864,7 +995,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -883,37 +1014,37 @@ let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -945,7 +1076,7 @@ // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -962,37 +1093,37 @@ .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return babel.transformSync(src, options); // => { code, map, ast } @@ -1000,8 +1131,8 @@ function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1010,7 +1141,7 @@ // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1033,25 +1164,25 @@ // validate the given JISON+JavaScript snippet: does it compile? - // - // Return either the parsed AST (object) or an error message (string). + // + // Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1062,9 +1193,9 @@ // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. - // + // // Returns the trimmed sourcecode which was provided via `src`. - // + // // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1072,7 +1203,7 @@ // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: - // + // // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1081,14 +1212,14 @@ // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} - // + // // Of course the example would be 'ludicrous' action code but the - // key point here is that users will certainly be able to come up with + // key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! - // + // function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1142,7 +1273,7 @@ trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1156,7 +1287,7 @@ /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1168,24 +1299,24 @@ /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. - /// + /// /// Also supports ES6's Arrow Functions: - /// + /// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' - /// + /// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1202,8 +1333,8 @@ if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1214,14 +1345,14 @@ action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1232,17 +1363,17 @@ var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; - // - // - // + // + // + // function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1268,7 +1399,7 @@ // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1316,7 +1447,7 @@ // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1379,13 +1510,13 @@ getRegExpInfo: getRegExpInfo }; - var cycleref = []; - var cyclerefpath = []; + let cycleref = []; + let cyclerefpath = []; - var linkref = []; - var linkrefpath = []; + let linkref = []; + let linkrefpath = []; - var path = []; + let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1393,14 +1524,14 @@ return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1413,11 +1544,11 @@ function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1430,9 +1561,9 @@ dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1447,16 +1578,52 @@ } + // strip developer machine specific parts off any paths in a given stacktrace (string) + // to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } + // strip off the line/position info from any stacktrace as a assert.deepEqual() on these + // will otherwise FAIL due to us running this stuff through both regular `node` and + // the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing + // exceptions and stacktraces which point completely somewhere else and this would b0rk + // our test rigs for the jison subpackages. + function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; + } + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1471,7 +1638,7 @@ function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1497,10 +1664,10 @@ } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1598,7 +1765,7 @@ function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1615,7 +1782,7 @@ path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1643,7 +1810,7 @@ function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1659,7 +1826,7 @@ linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1671,14 +1838,14 @@ // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. - // + // // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1688,7 +1855,7 @@ cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1702,12 +1869,14 @@ dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1722,7 +1891,7 @@ printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; // See also: @@ -1730,7 +1899,6 @@ // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1747,9 +1915,9 @@ this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -1782,10 +1950,10 @@ // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -1798,11 +1966,11 @@ // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -1812,18 +1980,18 @@ // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -1854,7 +2022,7 @@ // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -1871,9 +2039,9 @@ // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -1886,7 +2054,7 @@ } - var parser = { + let parser = { // Code Generator Information Report // --------------------------------- // @@ -2136,7 +2304,6 @@ // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2144,7 +2311,6 @@ // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2156,8 +2322,8 @@ // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2170,14 +2336,13 @@ // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2193,10 +2358,10 @@ // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2204,10 +2369,10 @@ this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2362,9 +2527,9 @@ /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -2376,18 +2541,18 @@ case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2417,9 +2582,9 @@ case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -2432,10 +2597,10 @@ case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2462,9 +2627,9 @@ case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -2473,10 +2638,10 @@ case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2504,9 +2669,9 @@ case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -2515,10 +2680,10 @@ case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -2557,9 +2722,9 @@ case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2624,9 +2789,9 @@ case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2641,9 +2806,9 @@ case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -2678,10 +2843,10 @@ case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2698,9 +2863,9 @@ case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2717,10 +2882,10 @@ case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2737,9 +2902,9 @@ case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2756,10 +2921,10 @@ case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2776,9 +2941,9 @@ case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -2802,9 +2967,9 @@ case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -2815,9 +2980,9 @@ case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2837,9 +3002,9 @@ case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2863,9 +3028,9 @@ case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2878,10 +3043,10 @@ case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2898,9 +3063,9 @@ case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2912,9 +3077,9 @@ case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -2954,10 +3119,10 @@ case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2977,9 +3142,9 @@ case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3029,10 +3194,10 @@ case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -3056,10 +3221,10 @@ case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3079,10 +3244,10 @@ case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3106,10 +3271,10 @@ case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3130,10 +3295,10 @@ case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3145,10 +3310,10 @@ case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3158,10 +3323,10 @@ case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3171,10 +3336,10 @@ case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3184,10 +3349,10 @@ case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3197,10 +3362,10 @@ case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -3210,10 +3375,10 @@ case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3223,10 +3388,10 @@ case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3236,9 +3401,9 @@ case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -3247,9 +3412,9 @@ case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -3258,9 +3423,9 @@ case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3282,9 +3447,9 @@ case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3295,9 +3460,9 @@ case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3317,9 +3482,9 @@ case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3373,9 +3538,9 @@ case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3395,9 +3560,9 @@ case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -3406,9 +3571,9 @@ case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -3420,9 +3585,9 @@ case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -3436,10 +3601,10 @@ case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3459,10 +3624,10 @@ case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3482,10 +3647,10 @@ case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3505,9 +3670,9 @@ case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3518,9 +3683,9 @@ case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3539,9 +3704,9 @@ case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -3582,9 +3747,9 @@ case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3608,9 +3773,9 @@ case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3636,9 +3801,9 @@ case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3683,9 +3848,9 @@ case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -3711,9 +3876,9 @@ case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -3722,9 +3887,9 @@ case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -3733,10 +3898,10 @@ case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3750,10 +3915,10 @@ case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3767,10 +3932,10 @@ case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3784,10 +3949,10 @@ case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3806,9 +3971,9 @@ case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -3817,9 +3982,9 @@ case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -3857,10 +4022,10 @@ case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -3884,9 +4049,9 @@ case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -3965,9 +4130,9 @@ case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -3976,9 +4141,9 @@ case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -3987,9 +4152,9 @@ case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -3998,9 +4163,9 @@ case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -4009,9 +4174,9 @@ case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -4020,9 +4185,9 @@ case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -4031,9 +4196,9 @@ case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -4044,10 +4209,10 @@ case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4064,9 +4229,9 @@ case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -4075,9 +4240,9 @@ case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -4086,9 +4251,9 @@ case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -4097,9 +4262,9 @@ case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -4108,9 +4273,9 @@ case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -4129,18 +4294,18 @@ case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -4149,9 +4314,9 @@ case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -4160,9 +4325,9 @@ case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -4171,9 +4336,9 @@ case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -4182,9 +4347,9 @@ case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -4193,10 +4358,10 @@ case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4213,9 +4378,9 @@ case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -4232,9 +4397,9 @@ case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -4246,9 +4411,9 @@ case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -4258,9 +4423,9 @@ case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4295,9 +4460,9 @@ case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4316,9 +4481,9 @@ case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -4327,9 +4492,9 @@ case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -4338,9 +4503,9 @@ case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4358,10 +4523,10 @@ case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -4379,10 +4544,10 @@ case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -4403,9 +4568,9 @@ case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4438,9 +4603,9 @@ case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4466,9 +4631,9 @@ case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5__default['default'].parse(yyvstack[yysp]); @@ -4477,9 +4642,9 @@ case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue(yyvstack[yysp]); @@ -4488,9 +4653,9 @@ case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4499,9 +4664,9 @@ case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -4522,10 +4687,10 @@ case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4542,9 +4707,9 @@ case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -4563,9 +4728,9 @@ case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4589,9 +4754,9 @@ case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -4611,9 +4776,9 @@ case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4624,9 +4789,9 @@ case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -4682,10 +4847,10 @@ case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6288,7 +6453,6 @@ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -6305,38 +6469,34 @@ } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -6344,20 +6504,18 @@ pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -6379,7 +6537,6 @@ // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -6387,18 +6544,19 @@ if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -6406,24 +6564,19 @@ // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -6461,18 +6614,15 @@ - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); + let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -6493,7 +6643,7 @@ // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -6511,7 +6661,6 @@ // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -6524,7 +6673,6 @@ // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -6538,11 +6686,10 @@ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -6596,8 +6743,8 @@ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6605,8 +6752,8 @@ this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6638,19 +6785,18 @@ // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -6661,7 +6807,7 @@ if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -6674,7 +6820,7 @@ if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -6686,29 +6832,27 @@ // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -6716,7 +6860,7 @@ l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -6736,8 +6880,7 @@ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -6746,10 +6889,10 @@ token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -6757,7 +6900,7 @@ location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -6768,9 +6911,14 @@ // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -6786,8 +6934,7 @@ // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -6856,11 +7003,14 @@ // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -6871,8 +7021,7 @@ }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -6881,21 +7030,20 @@ function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6905,21 +7053,20 @@ } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6928,28 +7075,27 @@ return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -6962,8 +7108,7 @@ - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; + const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -6986,8 +7131,7 @@ - - if (symbol === EOF) { + if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -6999,8 +7143,7 @@ - - --stack_probe; // popStack(1): [symbol, action] + --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -7017,8 +7160,7 @@ - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -7032,8 +7174,7 @@ - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } @@ -7047,7 +7188,7 @@ // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -7100,16 +7241,13 @@ - - - - // handle parse error + // handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -7143,9 +7281,7 @@ - - - r = this.parseError(p.errStr, p, this.JisonParserError); + r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -7168,9 +7304,7 @@ - - - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -7197,17 +7331,16 @@ - - } + } // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -7254,8 +7387,8 @@ recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -7267,8 +7400,7 @@ - - } else { + } else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -7286,6 +7418,7 @@ yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -7294,7 +7427,7 @@ - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -7305,7 +7438,7 @@ sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -7365,10 +7498,10 @@ // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -7403,9 +7536,7 @@ - - - // encountered another parse error? If so, break out to main loop + // encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -7418,7 +7549,7 @@ - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -7439,9 +7570,7 @@ - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7463,12 +7592,12 @@ // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -7477,7 +7606,7 @@ ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7518,7 +7647,7 @@ } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -7565,7 +7694,7 @@ // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -7583,21 +7712,19 @@ - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7631,14 +7758,15 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7648,6 +7776,7 @@ + } continue; // accept: @@ -7699,7 +7828,7 @@ // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -7715,9 +7844,7 @@ - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7746,7 +7873,7 @@ sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7763,8 +7890,8 @@ symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -7775,8 +7902,8 @@ // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -7788,21 +7915,19 @@ - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7833,14 +7958,15 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7850,6 +7976,7 @@ + } continue; // accept: @@ -7902,8 +8029,7 @@ // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -8164,7 +8290,6 @@ * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -8181,10 +8306,10 @@ }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -8216,7 +8341,7 @@ JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -8258,7 +8383,9 @@ // // --------- END OF REPORT ----------- - EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -8344,7 +8471,7 @@ if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -8352,7 +8479,7 @@ msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -8365,7 +8492,7 @@ } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -8391,10 +8518,13 @@ * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -8417,7 +8547,6 @@ * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -8440,16 +8569,16 @@ * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -8471,7 +8600,6 @@ * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -8479,8 +8607,8 @@ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -8509,7 +8637,7 @@ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -8534,7 +8662,7 @@ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -8546,17 +8674,17 @@ } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -8650,7 +8778,7 @@ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -8671,7 +8799,6 @@ * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -8682,7 +8809,7 @@ this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -8693,15 +8820,15 @@ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -8735,8 +8862,8 @@ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -8769,9 +8896,9 @@ // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -8790,9 +8917,9 @@ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -8802,8 +8929,8 @@ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -8830,20 +8957,19 @@ * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -8883,17 +9009,19 @@ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8902,7 +9030,7 @@ // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -8917,8 +9045,8 @@ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -8944,24 +9072,26 @@ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8972,7 +9102,7 @@ // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -8994,8 +9124,8 @@ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -9017,8 +9147,7 @@ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -9162,21 +9291,21 @@ const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -9191,11 +9320,11 @@ len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -9214,13 +9343,13 @@ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -9244,13 +9373,13 @@ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -9265,8 +9394,8 @@ } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -9297,7 +9426,7 @@ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -9329,9 +9458,9 @@ }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -9360,7 +9489,7 @@ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -9378,7 +9507,7 @@ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -9403,7 +9532,6 @@ * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -9413,8 +9541,6 @@ this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -9423,7 +9549,7 @@ this.clear(); } - 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. @@ -9435,13 +9561,13 @@ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -9451,68 +9577,74 @@ } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -9537,7 +9669,7 @@ * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -9585,24 +9717,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9622,7 +9754,7 @@ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -9632,24 +9764,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9670,8 +9802,7 @@ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -9711,14 +9842,14 @@ * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -9734,9 +9865,9 @@ if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -9747,8 +9878,8 @@ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -9756,7 +9887,7 @@ state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -11446,7 +11577,7 @@ // The expanded regex sets which are equivalent to the given `\\{c}` escapes: // // `/\s/`: - const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; + const WHITESPACE_SETSTR = ' \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff'; // `/\d/`: const DIGIT_SETSTR = '0-9'; // `/\w/`: @@ -11458,7 +11589,7 @@ // Helper for `bitarray2set()`: convert character code to a representation string suitable for use in a regex function i2c(i) { - var c, x; + let c, x; switch (i) { case 10: @@ -11498,7 +11629,7 @@ || i > 0xFFF0 /* Unicode Specials, also in UTF16 */ || (i >= 0xD800 && i <= 0xDFFF) /* Unicode Supplementary Planes; we're TOAST in JavaScript as we're NOT UTF-16 but UCS-2! */ || String.fromCharCode(i).match(/[\u2028\u2029]/) /* Code compilation via `new Function()` does not like to see these, or rather: treats them as just another form of CRLF, which breaks your generated regex code! */ - ) { + ) { // Detail about a detail: // U+2028 and U+2029 are part of the `\s` regex escape code (`\s` and `[\s]` match either of these) and when placed in a JavaScript // source file verbatim (without escaping it as a `\uNNNN` item) then JavaScript will interpret it as such and consequently report @@ -11506,11 +11637,10 @@ // Hence we MUST escape these buggers everywhere we go... x = i.toString(16); if (x.length >= 1 && i <= 0xFFFF) { - c = '0000' + x; - return '\\u' + c.substr(c.length - 4); - } else { - return '\\u{' + x + '}'; + c = '0000' + x; + return '\\u' + c.substr(c.length - 4); } + return '\\u{' + x + '}'; } return String.fromCharCode(i); } @@ -11519,18 +11649,18 @@ // Helper collection for `bitarray2set()`: we have expanded all these cached `\\p{NAME}` regex sets when creating // this bitarray and now we should look at these expansions again to see if `bitarray2set()` can produce a // `\\p{NAME}` shorthand to represent [part of] the bitarray: - var Pcodes_bitarray_cache = {}; - var Pcodes_bitarray_cache_test_order = []; + let Pcodes_bitarray_cache = {}; + let Pcodes_bitarray_cache_test_order = []; - // Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by + // Helper collection for `bitarray2set()` for minifying special cases of result sets which can be represented by // a single regex 'escape', e.g. `\d` for digits 0-9. - var EscCode_bitarray_output_refs; + let EscCode_bitarray_output_refs; // now initialize the EscCodes_... table above: init_EscCode_lookup_table(); function init_EscCode_lookup_table() { - var s, bitarr, set2esc = {}, esc2bitarr = {}; + let s, bitarr, set2esc = {}, esc2bitarr = {}; // patch global lookup tables for the time being, while we calculate their *real* content in this function: EscCode_bitarray_output_refs = { @@ -11599,13 +11729,13 @@ }; updatePcodesBitarrayCacheTestOrder(); - } + } function updatePcodesBitarrayCacheTestOrder(opts) { - var t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var l = {}; - var user_has_xregexp = opts && opts.options && opts.options.xregexp; - var i, j, k, ba; + let t = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let l = {}; + let user_has_xregexp = opts && opts.options && opts.options.xregexp; + let i, j, k, ba; // mark every character with which regex pcodes they are part of: for (k in Pcodes_bitarray_cache) { @@ -11615,12 +11745,12 @@ continue; } - var cnt = 0; + let cnt = 0; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { cnt++; if (!t[i]) { - t[i] = [k]; + t[i] = [ k ]; } else { t[i].push(k); } @@ -11630,27 +11760,27 @@ } // now dig out the unique ones: only need one per pcode. - // + // // We ASSUME every \\p{NAME} 'pcode' has at least ONE character - // in it that is ONLY matched by that particular pcode. + // in it that is ONLY matched by that particular pcode. // If this assumption fails, nothing is lost, but our 'regex set // optimized representation' will be sub-optimal as than this pcode - // won't be tested during optimization. - // + // won't be tested during optimization. + // // Now that would be a pity, so the assumption better holds... // Turns out the assumption doesn't hold already for /\S/ + /\D/ // as the second one (\D) is a pure subset of \S. So we have to // look for markers which match multiple escapes/pcodes for those // ones where a unique item isn't available... - var lut = []; - var done = {}; - var keys = Object.keys(Pcodes_bitarray_cache); + let lut = []; + let done = {}; + let keys = Object.keys(Pcodes_bitarray_cache); for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { k = t[i][0]; if (t[i].length === 1 && !done[k]) { assert__default['default'](l[k] > 0); - lut.push([i, k]); + lut.push([ i, k ]); done[k] = true; } } @@ -11661,19 +11791,19 @@ if (!user_has_xregexp && k.indexOf('\\p{') >= 0) { continue; } - + if (!done[k]) { assert__default['default'](l[k] > 0); // find a minimum span character to mark this one: - var w = Infinity; + let w = Infinity; var rv; ba = Pcodes_bitarray_cache[k]; for (i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (ba[i]) { - var tl = t[i].length; + let tl = t[i].length; if (tl > 1 && tl < w) { assert__default['default'](l[k] > 0); - rv = [i, k]; + rv = [ i, k ]; w = tl; } } @@ -11687,16 +11817,16 @@ // order from large set to small set so that small sets don't gobble // characters also represented by overlapping larger set pcodes. - // + // // Again we assume something: that finding the large regex pcode sets // before the smaller, more specialized ones, will produce a more - // optimal minification of the regex set expression. - // + // optimal minification of the regex set expression. + // // This is a guestimate/heuristic only! lut.sort(function (a, b) { - var k1 = a[1]; - var k2 = b[1]; - var ld = l[k2] - l[k1]; + let k1 = a[1]; + let k2 = b[1]; + let ld = l[k2] - l[k1]; if (ld) { return ld; } @@ -11714,19 +11844,19 @@ // 'Join' a regex set `[...]` into a Unicode range spanning logic array, flagging every character in the given set. function set2bitarray(bitarr, s, opts) { - var orig = s; - var set_is_inverted = false; - var bitarr_orig; + let orig = s; + let set_is_inverted = false; + let bitarr_orig; function mark(d1, d2) { if (d2 == null) d2 = d1; - for (var i = d1; i <= d2; i++) { + for (let i = d1; i <= d2; i++) { bitarr[i] = true; } } function add2bitarray(dst, src) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (src[i]) { dst[i] = true; } @@ -11734,10 +11864,10 @@ } function eval_escaped_code(s) { - var c; + let c; // decode escaped code? If none, just take the character as-is if (s.indexOf('\\') === 0) { - var l = s.substr(0, 2); + let l = s.substr(0, 2); switch (l) { case '\\c': c = s.charCodeAt(2) - 'A'.charCodeAt(0) + 1; @@ -11755,7 +11885,7 @@ } c = parseInt(s, 16); if (c >= 0x10000) { - return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); + return new Error('We do NOT support Extended Plane Unicode Codepoints (i.e. CodePoints beyond U:FFFF) in regex set expressions, e.g. \\u{' + s + '}'); } return String.fromCharCode(c); @@ -11799,7 +11929,7 @@ } if (s && s.length) { - var c1, c2; + let c1, c2; // inverted set? if (s[0] === '^') { @@ -11830,13 +11960,13 @@ c2 = c2[0]; s = s.substr(c2.length); // do we have this one cached already? - var pex = c1 + c2; - var ba4p = Pcodes_bitarray_cache[pex]; + let pex = c1 + c2; + let ba4p = Pcodes_bitarray_cache[pex]; if (!ba4p) { // expand escape: - var xr = new XRegExp__default['default']('[' + pex + ']'); // TODO: case-insensitive grammar??? + let xr = new XRegExp__default['default']('[' + pex + ']'); // TODO: case-insensitive grammar??? // rewrite to a standard `[...]` regex set: XRegExp will do this for us via `XRegExp.toString()`: - var xs = '' + xr; + let xs = '' + xr; // remove the wrapping `/.../` to get at the (possibly *combined* series of) `[...]` sets inside: xs = xs.substr(1, xs.length - 2); @@ -11871,7 +12001,7 @@ break; } } - var v1 = eval_escaped_code(c1); + let v1 = eval_escaped_code(c1); // propagate deferred exceptions = error reports. if (v1 instanceof Error) { return v1; @@ -11889,7 +12019,7 @@ } else { c2 = c2[0]; } - var v2 = eval_escaped_code(c2); + let v2 = eval_escaped_code(c2); // propagate deferred exceptions = error reports. if (v2 instanceof Error) { return v1; @@ -11912,12 +12042,12 @@ } // When we have marked all slots, '^' NEGATES the set, hence we flip all slots. - // + // // Since a regex like `[^]` should match everything(?really?), we don't need to check if the MARK // phase actually marked anything at all: the `^` negation will correctly flip=mark the entire // range then. if (set_is_inverted) { - for (var i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { + for (let i = 0; i <= UNICODE_BASE_PLANE_MAX_CP; i++) { if (!bitarr[i]) { bitarr_orig[i] = true; } @@ -11936,10 +12066,10 @@ // below can be simple and fast: l[UNICODE_BASE_PLANE_MAX_CP + 1] = 1; // now reconstruct the regex set: - var rv = []; - var i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; - var bitarr_is_cloned = false; - var l_orig = l; + let rv = []; + let i, j, cnt, lut, tn, tspec, match, pcode, ba4pcode, l2; + let bitarr_is_cloned = false; + let l_orig = l; if (output_inverted_variant) { // generate the inverted set, hence all unmarked slots are part of the output range: @@ -11953,8 +12083,7 @@ // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. // BUT... since we output the INVERTED set, we output the match-all set instead: return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` // BUT... since we output the INVERTED set, we output the match-nothing set instead: @@ -11986,9 +12115,9 @@ } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12015,7 +12144,7 @@ } } } - + i = 0; while (i <= UNICODE_BASE_PLANE_MAX_CP) { // find first character not in original set: @@ -12046,8 +12175,7 @@ // When we find the entire Unicode range is in the output match set, we replace this with // a shorthand regex: `[\S\s]` return '\\S\\s'; - } - else if (cnt === 0) { + } else if (cnt === 0) { // When there's nothing in the output we output a special 'match-nothing' regex: `[^\S\s]`. return '^\\S\\s'; } @@ -12077,9 +12205,9 @@ } } - // We're only interested in matches which actually cover some + // We're only interested in matches which actually cover some // yet uncovered bits: `match !== 0 && match !== false`. - // + // // Apply the heuristic that the pcode/escape is only going to be used // when it covers *more* characters than its own identifier's length: if (match && match > pcode.length) { @@ -12131,11 +12259,11 @@ } assert__default['default'](rv.length); - var s = rv.join(''); + let s = rv.join(''); assert__default['default'](s); // Check if the set is better represented by one of the regex escapes: - var esc4s = EscCode_bitarray_output_refs.set2esc[s]; + let esc4s = EscCode_bitarray_output_refs.set2esc[s]; if (esc4s) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return '\\' + esc4s; @@ -12150,25 +12278,24 @@ // Pretty brutal conversion of 'regex' `s` back to raw regex set content: strip outer [...] when they're there; // ditto for inner combos of sets, i.e. `]|[` as in `[0-9]|[a-z]`. function reduceRegexToSetBitArray(s, name, opts) { - var orig = s; + let orig = s; // propagate deferred exceptions = error reports. if (s instanceof Error) { return s; } - var l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); - var internal_state = 0; - var derr; + let l = new Array(UNICODE_BASE_PLANE_MAX_CP + 1); + let internal_state = 0; + let derr; while (s.length) { - var c1 = s.match(CHR_RE); + let c1 = s.match(CHR_RE); if (!c1) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: "' + s + '" of regex "' + orig + '"'); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12176,15 +12303,14 @@ // this is starting a set within the regex: scan until end of set! var set_content = []; while (s.length) { - var inner = s.match(SET_PART_RE); + let inner = s.match(SET_PART_RE); if (!inner) { inner = s.match(CHR_RE); if (!inner) { // cope with illegal escape sequences too! return new Error('illegal escape sequence at start of regex part: ' + s + '" of regex "' + orig + '"'); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12198,9 +12324,8 @@ if (!c2) { // cope with illegal escape sequences too! return new Error('regex set expression is broken in regex: "' + orig + '" --> "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error('regex set expression is broken in regex: ' + orig); } @@ -12284,10 +12409,9 @@ // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; assert__default['default'](s); assert__default['default'](!(s instanceof Error)); - re = new XRegExp__default['default']('[' + s + ']'); + let re = new XRegExp__default['default']('[' + s + ']'); re.test(s[0]); // One thing is apparently *not* caught by the RegExp compile action above: `[a[b]c]` @@ -12312,25 +12436,24 @@ - // Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` + // Convert bitarray representing, for example, `'0-9'` to regex string `[0-9]` // -- or in this example it can be further optimized to only `\d`! function produceOptimizedRegex4Set(bitarr) { // First try to produce a minimum regex from the bitarray directly: - var s1 = bitarray2set(bitarr, false, true); + let s1 = bitarray2set(bitarr, false, true); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s1.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s1; - } else { - s1 = '[' + s1 + ']'; } + s1 = '[' + s1 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s2 = bitarray2set(bitarr, true, true); + let s2 = bitarray2set(bitarr, true, true); if (s2[0] === '^') { s2 = s2.substr(1); @@ -12345,23 +12468,22 @@ // Then, as some pcode/escapes still happen to deliver a LARGER regex string in the end, // we also check against the plain, unadulterated regex set expressions: - // + // // First try to produce a minimum regex from the bitarray directly: - var s3 = bitarray2set(bitarr, false, false); + let s3 = bitarray2set(bitarr, false, false); // and when the regex set turns out to match a single pcode/escape, then // use that one as-is: if (s3.match(SET_IS_SINGLE_PCODE_RE)) { // When we hit a special case like this, it is always the shortest notation, hence wins on the spot! return s3; - } else { - s3 = '[' + s3 + ']'; } + s3 = '[' + s3 + ']'; // Now try to produce a minimum regex from the *inverted* bitarray via negation: // Because we look at a negated bitset, there's no use looking for matches with // special cases here. - var s4 = bitarray2set(bitarr, true, false); + let s4 = bitarray2set(bitarr, true, false); if (s4[0] === '^') { s4 = s4.substr(1); @@ -12393,30 +12515,30 @@ var setmgmt = { - XREGEXP_UNICODE_ESCAPE_RE, - CHR_RE, - SET_PART_RE, - NOTHING_SPECIAL_RE, - SET_IS_SINGLE_PCODE_RE, - - UNICODE_BASE_PLANE_MAX_CP, - - WHITESPACE_SETSTR, - DIGIT_SETSTR, - WORDCHAR_SETSTR, - - set2bitarray, - bitarray2set, - produceOptimizedRegex4Set, - reduceRegexToSetBitArray, + XREGEXP_UNICODE_ESCAPE_RE, + CHR_RE, + SET_PART_RE, + NOTHING_SPECIAL_RE, + SET_IS_SINGLE_PCODE_RE, + + UNICODE_BASE_PLANE_MAX_CP, + + WHITESPACE_SETSTR, + DIGIT_SETSTR, + WORDCHAR_SETSTR, + + set2bitarray, + bitarray2set, + produceOptimizedRegex4Set, + reduceRegexToSetBitArray }; // Basic Lexer implemented using JavaScript regular expressions - var rmCommonWS$2 = helpers.rmCommonWS; - var mkIdentifier$2 = helpers.mkIdentifier; - var code_exec$1 = helpers.exec; + const rmCommonWS$2 = helpers.rmCommonWS; + const mkIdentifier$2 = helpers.mkIdentifier; + const code_exec = helpers.exec; - var version = '0.6.2-220'; // require('./package.json').version; + const version = '0.6.2-220'; // require('./package.json').version; @@ -12477,7 +12599,7 @@ exportAST: false, prettyCfg: true, pre_lex: undefined, - post_lex: undefined, + post_lex: undefined }; @@ -12495,23 +12617,23 @@ // Return a fresh set of options. /** @public */ function mkStdOptions(/*...args*/) { - var h = Object.prototype.hasOwnProperty; + let h = Object.prototype.hasOwnProperty; - var opts = {}; - var args = [].concat.apply([], arguments); + let opts = {}; + let args = [].concat.apply([], arguments); // clone defaults, so we do not modify those constants? - if (args[0] !== "NODEFAULT") { + if (args[0] !== 'NODEFAULT') { args.unshift(defaultJisonLexOptions); } else { args.shift(); } - for (var i = 0, len = args.length; i < len; i++) { - var o = args[i]; + for (let i = 0, len = args.length; i < len; i++) { + let o = args[i]; if (!o) continue; // clone input (while camel-casing the options), so we do not modify those either. - var o2 = {}; + let o2 = {}; for (var p in o) { if (typeof o[p] !== 'undefined' && h.call(o, p)) { @@ -12549,7 +12671,7 @@ function prepExportStructures(options) { // set up the 'option' `exportSourceCode` as a hash object for returning // all generated source code chunks to the caller - var exportSourceCode = options.exportSourceCode; + let exportSourceCode = options.exportSourceCode; if (!exportSourceCode || typeof exportSourceCode !== 'object') { exportSourceCode = { enabled: !!exportSourceCode @@ -12570,8 +12692,8 @@ // Otherwise return the *parsed* lexer spec as it has // been processed through LexParser. function autodetectAndConvertToJSONformat(lexerSpec, options) { - var chk_l = null; - var ex1, err; + let chk_l = null; + let ex1, err; if (typeof lexerSpec === 'string') { if (options.json) { @@ -12623,9 +12745,9 @@ /should be separated/, /an error in one or more of your lexer regex rules/, /an error in your lexer epilogue/, - /unsupported definition type/, + /unsupported definition type/ ]; - var cmnerr = commonErrors.filter(function check(re) { + let cmnerr = commonErrors.filter(function check(re) { return e.message.match(re); }); if (cmnerr.length > 0) { @@ -12654,14 +12776,14 @@ // expand macros and convert matchers to RegExp's function prepareRules(dict, actions, caseHelper, tokens, startConditions, opts) { - var m, i, k, rule, action, conditions; - var active_conditions; + let m, i, k, rule, action, conditions; + let active_conditions; assert__default['default'](Array.isArray(dict.rules)); - var rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! - var newRules = []; - var macros = {}; - var regular_rule_count = 0; - var simple_rule_count = 0; + let rules = dict.rules.slice(0); // shallow copy of the rules array as we MAY modify it in here! + let newRules = []; + let macros = {}; + let regular_rule_count = 0; + let simple_rule_count = 0; // Assure all options are camelCased: assert__default['default'](typeof opts.options['case-insensitive'] === 'undefined'); @@ -12671,7 +12793,7 @@ } if (opts.options.flex && rules.length > 0) { - rules.push(['.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */']); + rules.push([ '.', 'console.log("", yytext); /* `flex` lexing mode: the last resort rule! */' ]); } // Depending on the location within the regex we need different expansions of the macros: @@ -12695,7 +12817,7 @@ return str; } - var routingCode = ['switch(yyrulenumber) {']; + let routingCode = [ 'switch(yyrulenumber) {' ]; for (i = 0; i < rules.length; i++) { rule = rules[i].slice(0); // shallow copy: do not modify input rules @@ -12749,7 +12871,7 @@ action = action.replace(/return\s*\(?'((?:\\'|[^']+)+)'\)?/g, tokenNumberReplacement); action = action.replace(/return\s*\(?"((?:\\"|[^"]+)+)"\)?/g, tokenNumberReplacement); - var code = ['\n/*! Conditions::']; + let code = [ '\n/*! Conditions::' ]; code.push(postprocessComment(active_conditions)); code.push('*/', '\n/*! Rule:: '); code.push(postprocessComment(rule[0])); @@ -12770,7 +12892,7 @@ // 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'. - var match_nr = /^return[\s\r\n]+((?:'(?:\\'|[^']+)+')|(?:"(?:\\"|[^"]+)+")|\d+)[\s\r\n]*;?$/.exec(action.trim()); + 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 ')); @@ -12797,7 +12919,7 @@ macros: macros, regular_rule_count: regular_rule_count, - simple_rule_count: simple_rule_count, + simple_rule_count: simple_rule_count }; } @@ -12810,14 +12932,13 @@ // 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. function reduceRegex(s, name, opts, expandAllMacrosInSet_cb, expandAllMacrosElsewhere_cb) { - var orig = s; + let orig = s; function errinfo() { if (name) { return 'macro [[' + name + ']]'; - } else { - return 'regex [[' + orig + ']]'; } + return 'regex [[' + orig + ']]'; } // propagate deferred exceptions = error reports. @@ -12825,19 +12946,18 @@ return s; } - var c1, c2; - var rv = []; - var derr; - var se; + let c1, c2; + let rv = []; + let derr; + let se; while (s.length) { c1 = s.match(CHR_RE$1); if (!c1) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - c1 = c1[0]; } + c1 = c1[0]; s = s.substr(c1.length); switch (c1) { @@ -12847,15 +12967,14 @@ var l = new Array(UNICODE_BASE_PLANE_MAX_CP$1 + 1); while (s.length) { - var inner = s.match(SET_PART_RE$1); + let inner = s.match(SET_PART_RE$1); if (!inner) { inner = s.match(CHR_RE$1); if (!inner) { // cope with illegal escape sequences too! return new Error(errinfo() + ': illegal escape sequence at start of regex part: ' + s); - } else { - inner = inner[0]; } + inner = inner[0]; if (inner === ']') break; } else { inner = inner[0]; @@ -12869,9 +12988,8 @@ if (!c2) { // cope with illegal escape sequences too! return new Error(errinfo() + ': regex set expression is broken: "' + s + '"'); - } else { - c2 = c2[0]; } + c2 = c2[0]; if (c2 !== ']') { return new Error(errinfo() + ': regex set expression is broken: apparently unterminated'); } @@ -12932,7 +13050,7 @@ c2 = c2[0]; s = s.substr(c2.length); - var c3 = s[0]; + let c3 = s[0]; s = s.substr(c3.length); if (c3 === '}') { // possibly a macro name in there... Expand if possible: @@ -12985,7 +13103,7 @@ // it in a regex; that way we can easily validate whether macro X is fit to be used // inside a regex set: try { - var re; + let re; re = new XRegExp__default['default'](s); re.test(s[0]); } catch (ex) { @@ -13001,11 +13119,11 @@ // expand macros within macros and cache the result function prepareMacros(dict_macros, opts) { - var macros = {}; + let macros = {}; // expand a `{NAME}` macro which exists inside a `[...]` set: function expandMacroInSet(i) { - var k, a, m; + let k, a, m; if (!macros[i]) { m = dict_macros[i]; @@ -13039,7 +13157,7 @@ a = m.split('{' + k + '}'); if (a.length > 1) { - var x = expandMacroInSet(k); + let x = expandMacroInSet(k); assert__default['default'](x); if (x instanceof Error) { m = x; @@ -13051,9 +13169,9 @@ } } - var mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); + let mba = setmgmt.reduceRegexToSetBitArray(m, i, opts); - var s1; + let s1; // propagate deferred exceptions = error reports. if (mba instanceof Error) { @@ -13087,7 +13205,7 @@ } function expandMacroElsewhere(i) { - var m; + let m; if (macros[i].elsewhere == null) { m = dict_macros[i]; @@ -13122,13 +13240,13 @@ } function expandAllMacrosInSet(s) { - var i, x; + let i, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { for (i in macros) { if (macros.hasOwnProperty(i)) { - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroInSet(i); assert__default['default'](x); @@ -13150,7 +13268,7 @@ } function expandAllMacrosElsewhere(s) { - var i, x; + let i, x; // When we process the remaining macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13165,7 +13283,7 @@ for (i in macros) { if (macros.hasOwnProperty(i)) { // These are all submacro expansions, hence non-capturing grouping is applied: - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = expandMacroElsewhere(i); assert__default['default'](x); @@ -13187,7 +13305,7 @@ } - var i; + let i; if (opts.debug) console.log('\n############## RAW macros: ', dict_macros); @@ -13218,13 +13336,13 @@ // expand macros in a regex; expands them recursively function expandMacros(src, macros, opts) { - var expansion_count = 0; + let expansion_count = 0; // By the time we call this function `expandMacros` we MUST have expanded and cached all macros already! // Hence things should be easy in there: function expandAllMacrosInSet(s) { - var i, m, x; + let i, m, x; // process *all* the macros inside [...] set: if (s.indexOf('{') >= 0) { @@ -13232,7 +13350,7 @@ if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { x = m.in_set; @@ -13263,7 +13381,7 @@ } function expandAllMacrosElsewhere(s) { - var i, m, x; + let i, m, x; // When we process the main macro occurrences in the regex // every macro used in a lexer rule will become its own capture group. @@ -13279,7 +13397,7 @@ if (macros.hasOwnProperty(i)) { m = macros[i]; - var a = s.split('{' + i + '}'); + let a = s.split('{' + i + '}'); if (a.length > 1) { // These are all main macro expansions, hence CAPTURING grouping is applied: x = m.elsewhere; @@ -13315,7 +13433,7 @@ // used macro will expand into, i.e. which and how many submacros it has. // // This is a BREAKING CHANGE from vanilla jison 0.4.15! - var s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); + let s2 = reduceRegex(src, null, opts, expandAllMacrosInSet, expandAllMacrosElsewhere); // propagate deferred exceptions = error reports. if (s2 instanceof Error) { throw s2; @@ -13340,8 +13458,8 @@ } function prepareStartConditions(conditions) { - var sc; - var hash = {}; + let sc; + let hash = {}; for (sc in conditions) { if (conditions.hasOwnProperty(sc)) { @@ -13355,22 +13473,22 @@ } function buildActions(dict, tokens, opts) { - var actions = [dict.actionInclude || '', 'var YYSTATE = YY_START;']; - var tok; - var toks = {}; - var caseHelper = []; + let actions = [ dict.actionInclude || '', 'var YYSTATE = YY_START;' ]; + let tok; + let toks = {}; + let caseHelper = []; // tokens: map/array of token numbers to token names for (tok in tokens) { - var idx = parseInt(tok); + let idx = parseInt(tok); if (idx && idx > 0) { toks[tokens[tok]] = idx; } } - var gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); + let gen = prepareRules(dict, actions, caseHelper, tokens && toks, opts.conditions, opts); - var code = actions.join('\n'); + let code = actions.join('\n'); 'yytext yyleng yylineno yylloc yyerror'.split(' ').forEach(function (yy) { code = code.replace(new RegExp('\\b(' + yy + ')\\b', 'g'), 'yy_.$1'); }); @@ -13388,7 +13506,7 @@ macros: gen.macros, // propagate these for debugging/diagnostic purposes regular_rule_count: gen.regular_rule_count, - simple_rule_count: gen.simple_rule_count, + simple_rule_count: gen.simple_rule_count }; } @@ -13399,7 +13517,7 @@ function generateErrorClass() { // --- START lexer error class --- - var prelude = `/** + const prelude = `/** * 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 @@ -13410,8 +13528,6 @@ * @nocollapse */ function JisonLexerError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -13428,9 +13544,9 @@ function JisonLexerError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -13491,8 +13607,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /** @constructor */ function RegExpLexer(dict, input, tokens, build_options) { - var opts; - var dump = false; + let opts; + let dump = false; function test_me(tweak_cb, description, src_exception, ex_callback) { opts = processGrammar(dict, tokens, build_options); @@ -13502,7 +13618,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (tweak_cb) { tweak_cb(); } - var source = generateModuleBody(opts); + let source = generateModuleBody(opts); try { // The generated code will always have the `lexer` variable declared at local scope // as `eval()` will use the local scope. @@ -13510,16 +13626,16 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // The compiled code will look something like this: // // ``` - // var lexer; + // let lexer; // bla bla... // ``` // // or // // ``` - // var lexer = { bla... }; + // const lexer = { bla... }; // ``` - var testcode = [ + let testcode = [ '// provide a local version for test purposes:', jisonLexerErrorDefinition, '', @@ -13527,14 +13643,33 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; '', source, '', + rmCommonWS$2` + // JISON INJECTED VALIDATION CODE + // which attempts to ascertain you have defined a minimal viable lexer at least: + if (typeof lexer === "undefined") { + throw new SyntaxError("user-defined lexer does not define the required 'lexer' instance."); + } + if (!lexer) { + throw new SyntaxError("user-defined lexer does not define a non-NULL 'lexer' instance."); + } + if (typeof lexer.setInput !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.setInput()' API function."); + } + if (typeof lexer.lex !== 'function') { + throw new SyntaxError("user-defined lexer does not provide the mandatory 'lexer.lex()' API function."); + } + // END OF JISON INJECTED VALIDATION CODE + `, 'return lexer;' ].join('\n'); - var lexer = code_exec$1(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { + let lexer = code_exec(testcode, function generated_code_exec_wrapper_regexp_lexer(sourcecode) { //console.log("===============================LEXER TEST CODE\n", sourcecode, "\n=====================END====================\n"); chkBugger$2(sourcecode); - var lexer_f = new Function('', sourcecode); + let lexer_f = new Function('', sourcecode); return lexer_f(); - }, opts.options, "lexer"); + }, Object.assign({}, opts.options, { + throwErrorOnCompileFailure: true + }), 'lexer'); if (!lexer) { throw new Error('no lexer defined *at all*?!'); @@ -13551,7 +13686,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // When we do NOT crash, we found/killed the problem area just before this call! if (src_exception && description) { - var msg = description; + let msg = description; if (typeof description === 'function') { msg = description(); } @@ -13560,8 +13695,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // patch the pre and post handlers in there, now that we have some live code to work with: if (opts.options) { - var pre = opts.options.pre_lex; - var post = opts.options.post_lex; + let pre = opts.options.pre_lex; + let post = opts.options.post_lex; // since JSON cannot encode functions, we'll have to do it manually now: if (typeof pre === 'function') { lexer.options.pre_lex = pre; @@ -13575,7 +13710,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (typeof opts.options.showSource === 'function') { opts.options.showSource(lexer, source, opts, RegExpLexer); } else { - console.log("\nGenerated lexer sourcecode:\n----------------------------------------\n", source, "\n----------------------------------------\n"); + console.log('\nGenerated lexer sourcecode:\n----------------------------------------\n', source, '\n----------------------------------------\n'); } } return lexer; @@ -13594,13 +13729,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } /** @constructor */ - var lexer = test_me(null, null, null, function (ex) { + let lexer = test_me(null, null, null, function (ex) { // When we get an exception here, it means some part of the user-specified lexer is botched. // // Now we go and try to narrow down the problem area/category: assert__default['default'](opts.options); assert__default['default'](opts.options.xregexp !== undefined); - var orig_xregexp_opt = !!opts.options.xregexp; + let orig_xregexp_opt = !!opts.options.xregexp; if (!test_me(function () { assert__default['default'](opts.options.xregexp !== undefined); opts.options.xregexp = false; @@ -13619,7 +13754,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; 'Your custom lexer is somehow botched.' ); }, ex, null)) { - var rulesSpecSize; + let rulesSpecSize; if (!test_me(function () { // store the parsed rule set size so we can use that info in case // this attempt also fails: @@ -13632,7 +13767,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; opts.__in_rules_failure_analysis_mode__ = true; }, 'One or more of your lexer rules are possibly botched?', ex, null)) { // kill each rule action block, one at a time and test again after each 'edit': - var rv = false; + let rv = false; for (var i = 0, len = rulesSpecSize; i < len; i++) { var lastEditedRuleSpec; rv = test_me(function () { @@ -13644,10 +13779,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // opts.__in_rules_failure_analysis_mode__ = true; // nuke all rules' actions up to and including rule numero `i`: - for (var j = 0; j <= i; j++) { + for (let j = 0; j <= i; j++) { // rules, when parsed, have 2 or 3 elements: [conditions, handle, action]; // now we want to edit the *action* part: - var rule = opts.rules[j]; + let rule = opts.rules[j]; assert__default['default'](Array.isArray(rule)); assert__default['default'](rule.length === 2 || rule.length === 3); rule.pop(); @@ -13781,8 +13916,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -13792,14 +13925,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\\n\\s*$/.test(msg)) { msg += '\\n'; } msg += '\\n Erroneous area:\\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\\n' && pos_str[0] !== '\\n') { msg += '\\n' + pos_str; @@ -13810,14 +13943,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the \`upcomingInput\` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -13837,9 +13970,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -13859,8 +13991,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -13881,16 +14011,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name \`extra_error_attributes\`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -13911,8 +14039,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -13920,8 +14046,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -13939,8 +14065,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -13950,14 +14074,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -13968,8 +14092,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -13977,40 +14099,40 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in \`lexer_next()\` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -14022,7 +14144,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -14030,7 +14152,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -14091,9 +14213,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -14112,8 +14232,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set \`done\` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -14122,7 +14240,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -14132,13 +14250,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\\n') { lines = true; } else if (ch === '\\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\\n') { slice_len++; ch += ch2; @@ -14170,10 +14288,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -14205,8 +14321,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Get last entirely matched line into the \`pre_lines[]\` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -14224,9 +14340,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -14236,14 +14352,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -14254,8 +14368,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -14268,19 +14380,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the \`parseError()\` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // \`.lex()\` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -14293,8 +14403,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -14317,24 +14425,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substr\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14346,8 +14454,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to \`maxSize\` (default: 20). @@ -14373,24 +14481,25 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > \`lookAhead()\` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // \`substring\` anticipation: treat \\r\\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -14399,7 +14508,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\\n'); // When, after limiting to maxLines, we still have too much to return, @@ -14418,10 +14527,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\\s/g, ' ') + '\\n' + c + '^'; }, @@ -14443,15 +14550,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -14582,58 +14687,54 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\\t/g, ' '); @@ -14642,13 +14743,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -14670,15 +14771,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -14690,8 +14789,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -14720,13 +14819,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -14755,10 +14848,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -14786,7 +14879,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -14797,7 +14890,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -14819,8 +14912,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -14829,17 +14920,13 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -14849,67 +14936,75 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that \`parseError()\` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) \`parseError()\` @@ -14936,9 +15031,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -14981,24 +15074,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15018,9 +15111,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -15030,24 +15121,24 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value \`r\`). // 2) make sure any subsequent \`lex()\` API invocation CANNOT // edit the \`yytext\`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -15055,7 +15146,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; this._clear_state = 0; } - + return r; }, @@ -15068,9 +15159,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -15078,7 +15167,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -15093,8 +15182,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -15106,8 +15193,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -15121,15 +15206,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -15141,14 +15223,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -15159,16 +15238,14 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -15178,8 +15255,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; } }`; @@ -15211,18 +15286,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // ............................. ${opt.lexerActionsUseDisplayAPIs} // uses describeYYLLOC() API: ....... ${opt.lexerActionsUseDescribeYYLOC} - var new_src; + let new_src; try { - var ast = helpers.parseCodeChunkToAST(src, opt); + let ast = helpers.parseCodeChunkToAST(src, opt); new_src = helpers.prettyPrintAST(ast, opt); - } - catch (ex) { + } catch (ex) { let line = ex.lineNumber || 0; let a = src.split(/\r?\n/g); let len = a.length; let minl = Math.max(0, line - 10); let b = a.slice(minl, line + 10); - let c = b.splice(line - minl, 0, "", "^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", ""); + let c = b.splice(line - minl, 0, '', '^^^^^^^^^^^ source line above is reported as erroneous ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', ''); let offendingChunk = ' ' + b.join('\n '); console.error(rmCommonWS$2` stripUnusedLexerCode WARNING: @@ -15238,17 +15312,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; ${offendingChunk} `); - + new_src = src; } - - - - - - // inject analysis report now: new_src = new_src.replace(/\/\*\s*JISON-LEX-ANALYTICS-REPORT\s*\*\//g, rmCommonWS$2` // Code Generator Information Report @@ -15303,7 +15371,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // generate lexer source from a grammar /** @public */ function generate(dict, tokens, build_options) { - var opt = processGrammar(dict, tokens, build_options); + let opt = processGrammar(dict, tokens, build_options); return generateFromOpts(opt); } @@ -15312,7 +15380,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; /** @public */ function processGrammar(dict, tokens, build_options) { build_options = build_options || {}; - var opts = { + let opts = { // include the knowledge passed through `build_options` about which lexer // features will actually be *used* by the environment (which in 99.9% // of cases is a jison *parser*): @@ -15352,7 +15420,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; lexerActionsUseReject: '???', lexerActionsUseLess: '???', lexerActionsUseDisplayAPIs: '???', - lexerActionsUseDescribeYYLOC: '???', + lexerActionsUseDescribeYYLOC: '???' }; dict = autodetectAndConvertToJSONformat(dict, build_options) || {}; @@ -15377,7 +15445,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // only produce rule action code blocks when there are any rules at all; // a "custom lexer" has ZERO rules and must be defined entirely in // other code blocks: - var code = (dict.rules ? buildActions(dict, tokens, opts) : {}); + let code = (dict.rules ? buildActions(dict, tokens, opts) : {}); opts.performAction = code.actions; opts.caseHelperInclude = code.caseHelperInclude; opts.rules = code.rules || []; @@ -15386,7 +15454,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; opts.regular_rule_count = code.regular_rule_count; opts.simple_rule_count = code.simple_rule_count; - opts.conditionStack = ['INITIAL']; + opts.conditionStack = [ 'INITIAL' ]; opts.actionInclude = (dict.actionInclude || ''); opts.moduleInclude = (opts.moduleInclude || '') + (dict.moduleInclude || '').trim(); @@ -15397,7 +15465,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // Assemble the final source from the processed grammar /** @public */ function generateFromOpts(opt) { - var code = ''; + let code = ''; switch (opt.moduleType) { case 'js': @@ -15420,12 +15488,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function generateRegexesInitTableCode(opt) { - var a = opt.rules; - var print_xregexp = opt.options && opt.options.xregexp; - var id_display_width = (1 + Math.log10(a.length | 1) | 0); - var ws_prefix = new Array(id_display_width).join(' '); - var b = a.map(function generateXRegExpInitCode(re, idx) { - var idx_str = (ws_prefix + idx).substr(-id_display_width); + let a = opt.rules; + let print_xregexp = opt.options && opt.options.xregexp; + let id_display_width = (1 + Math.log10(a.length | 1) | 0); + let ws_prefix = new Array(id_display_width).join(' '); + let b = a.map(function generateXRegExpInitCode(re, idx) { + let idx_str = (ws_prefix + idx).substr(-id_display_width); if (re instanceof XRegExp__default['default']) { // When we don't need the special XRegExp sauce at run-time, we do with the original @@ -15435,11 +15503,11 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // And make sure to escape the regex to make it suitable for placement inside a *string* // as it is passed as a string argument to the XRegExp constructor here. - var re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); + let re_src = re.xregexp.source.replace(/[\\"]/g, '\\$&'); return `/* ${idx_str}: */ new XRegExp("${re_src}", "${re.xregexp.flags}")`; - } else { - return `/* ${idx_str}: */ ${re}`; } + return `/* ${idx_str}: */ ${re}`; + }); return b.join(',\n'); } @@ -15447,77 +15515,77 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateModuleBody(opt) { // make the JSON output look more like JavaScript: function cleanupJSON(str) { - str = str.replace(/ "rules": \[/g, ' rules: ['); - str = str.replace(/ "inclusive": /g, ' inclusive: '); + str = str.replace(/ {2}"rules": \[/g, ' rules: ['); + str = str.replace(/ {2}"inclusive": /g, ' inclusive: '); return str; } function produceOptions(opts) { - var obj = {}; - var do_not_pass = { - debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! - enableDebugLogs: 1, - json: 1, - _: 1, - noMain: 1, - dumpSourceCodeOnFailure: 1, - throwErrorOnCompileFailure: 1, - reportStats: 1, - file: 1, - outfile: 1, - inputPath: 1, - inputFilename: 1, - defaultModuleName: 1, - moduleName: 1, - moduleType: 1, - lexerErrorsAreRecoverable: 0, - flex: 0, - backtrack_lexer: 0, - caseInsensitive: 0, - showSource: 1, - exportAST: 1, - exportAllTables: 1, - exportSourceCode: 1, - prettyCfg: 1, - parseActionsUseYYLENG: 1, - parseActionsUseYYLINENO: 1, - parseActionsUseYYTEXT: 1, - parseActionsUseYYLOC: 1, - parseActionsUseParseError: 1, - parseActionsUseYYERROR: 1, - parseActionsUseYYRECOVERING: 1, - parseActionsUseYYERROK: 1, - parseActionsUseYYCLEARIN: 1, - parseActionsUseValueTracking: 1, - parseActionsUseValueAssignment: 1, - parseActionsUseLocationTracking: 1, - parseActionsUseLocationAssignment: 1, - parseActionsUseYYSTACK: 1, - parseActionsUseYYSSTACK: 1, - parseActionsUseYYSTACKPOINTER: 1, - parseActionsUseYYRULELENGTH: 1, - parseActionsUseYYMERGELOCATIONINFO: 1, - parserHasErrorRecovery: 1, - parserHasErrorReporting: 1, - lexerActionsUseYYLENG: 1, - lexerActionsUseYYLINENO: 1, - lexerActionsUseYYTEXT: 1, - lexerActionsUseYYLOC: 1, - lexerActionsUseParseError: 1, - lexerActionsUseYYERROR: 1, - lexerActionsUseLocationTracking: 1, - lexerActionsUseMore: 1, - lexerActionsUseUnput: 1, - lexerActionsUseReject: 1, - lexerActionsUseLess: 1, - lexerActionsUseDisplayAPIs: 1, - lexerActionsUseDescribeYYLOC: 1, + let obj = {}; + const do_not_pass = { + debug: !opts.debug, // do not include this item when it is FALSE as there's no debug tracing built into the generated grammar anyway! + enableDebugLogs: 1, + json: 1, + _: 1, + noMain: 1, + dumpSourceCodeOnFailure: 1, + throwErrorOnCompileFailure: 1, + reportStats: 1, + file: 1, + outfile: 1, + inputPath: 1, + inputFilename: 1, + defaultModuleName: 1, + moduleName: 1, + moduleType: 1, + lexerErrorsAreRecoverable: 0, + flex: 0, + backtrack_lexer: 0, + caseInsensitive: 0, + showSource: 1, + exportAST: 1, + exportAllTables: 1, + exportSourceCode: 1, + prettyCfg: 1, + parseActionsUseYYLENG: 1, + parseActionsUseYYLINENO: 1, + parseActionsUseYYTEXT: 1, + parseActionsUseYYLOC: 1, + parseActionsUseParseError: 1, + parseActionsUseYYERROR: 1, + parseActionsUseYYRECOVERING: 1, + parseActionsUseYYERROK: 1, + parseActionsUseYYCLEARIN: 1, + parseActionsUseValueTracking: 1, + parseActionsUseValueAssignment: 1, + parseActionsUseLocationTracking: 1, + parseActionsUseLocationAssignment: 1, + parseActionsUseYYSTACK: 1, + parseActionsUseYYSSTACK: 1, + parseActionsUseYYSTACKPOINTER: 1, + parseActionsUseYYRULELENGTH: 1, + parseActionsUseYYMERGELOCATIONINFO: 1, + parserHasErrorRecovery: 1, + parserHasErrorReporting: 1, + lexerActionsUseYYLENG: 1, + lexerActionsUseYYLINENO: 1, + lexerActionsUseYYTEXT: 1, + lexerActionsUseYYLOC: 1, + lexerActionsUseParseError: 1, + lexerActionsUseYYERROR: 1, + lexerActionsUseLocationTracking: 1, + lexerActionsUseMore: 1, + lexerActionsUseUnput: 1, + lexerActionsUseReject: 1, + lexerActionsUseLess: 1, + lexerActionsUseDisplayAPIs: 1, + lexerActionsUseDescribeYYLOC: 1 }; - for (var k in opts) { + for (let k in opts) { if (!do_not_pass[k] && opts[k] != null && opts[k] !== false) { // make sure numeric values are encoded as numeric, the rest as boolean/string. if (typeof opts[k] === 'string') { - var f = parseFloat(opts[k]); + let f = parseFloat(opts[k]); if (f == opts[k]) { obj[k] = f; continue; @@ -15528,8 +15596,8 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } // And now some options which should receive some special processing: - var pre = obj.pre_lex; - var post = obj.post_lex; + let pre = obj.pre_lex; + let post = obj.post_lex; // since JSON cannot encode functions, we'll have to do it manually at run-time, i.e. later on: if (pre) { obj.pre_lex = true; @@ -15538,7 +15606,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; obj.post_lex = true; } - var js = JSON.stringify(obj, null, 2); + let js = JSON.stringify(obj, null, 2); js = js.replace(new XRegExp__default['default'](` "(${ID_REGEX_BASE$1})": `, 'g'), ' $1: '); js = js.replace(/^( +)pre_lex: true(,)?$/gm, function (m, ls, tc) { @@ -15551,17 +15619,17 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } - var out; + let out; if (opt.rules.length > 0 || opt.__in_rules_failure_analysis_mode__) { // we don't mind that the `test_me()` code above will have this `lexer` variable re-defined: // JavaScript is fine with that. - var code = [rmCommonWS$2` - var lexer = { - `, '/*JISON-LEX-ANALYTICS-REPORT*/' /* slot #1: placeholder for analysis report further below */ + let code = [ rmCommonWS$2` + const lexer = { + `, '/* JISON-LEX-ANALYTICS-REPORT */\n' /* slot #1: placeholder for analysis report further below */ ]; // get the RegExpLexer.prototype in source code form: - var protosrc = getRegExpLexerPrototype(); + let protosrc = getRegExpLexerPrototype(); // and strip off the surrounding bits we don't want: protosrc = protosrc .replace(/^[\s\r\n]*\{/, '') @@ -15588,10 +15656,10 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } */ - var performActionCode = String(opt.performAction); - var simpleCaseActionClustersCode = String(opt.caseHelperInclude); - var rulesCode = generateRegexesInitTableCode(opt); - var conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); + let performActionCode = String(opt.performAction); + let simpleCaseActionClustersCode = String(opt.caseHelperInclude); + let rulesCode = generateRegexesInitTableCode(opt); + let conditionsCode = cleanupJSON(JSON.stringify(opt.conditions, null, 2)); code.push(rmCommonWS$2`, JisonLexerError: JisonLexerError, performAction: ${performActionCode}, @@ -15611,9 +15679,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // // We are re-purposing the `%{...%}` `actionInclude` code block here as it serves no purpose otherwise. // - // Meanwhile we make sure we have the `lexer` variable declared in *local scope* no matter + // Try to make sure we have the `lexer` variable declared in *local scope* no matter // what crazy stuff (or lack thereof) the userland code is pulling in the `actionInclude` chunk. - out = 'var lexer;\n'; + out = '\n'; assert__default['default'](opt.regular_rule_count === 0); assert__default['default'](opt.simple_rule_count === 0); @@ -15627,8 +15695,6 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // The output of this function is guaranteed to read something like this: // // ``` - // var lexer; - // // bla bla bla bla ... lotsa bla bla; // ``` // @@ -15637,7 +15703,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; } function generateGenericHeaderComment() { - var out = rmCommonWS$2` + let out = rmCommonWS$2` /* lexer generated by jison-lex ${version} */ /* @@ -15866,7 +15932,7 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; // check for illegal identifier if (!opt.moduleName || !opt.moduleName.match(/^[a-zA-Z_$][a-zA-Z0-9_$\.]*$/)) { if (opt.moduleName) { - var msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; + let msg = 'WARNING: The specified moduleName "' + opt.moduleName + '" is illegal (only characters [a-zA-Z0-9_$] and "." dot are accepted); using the default moduleName "lexer" instead.'; if (typeof opt.warn_cb === 'function') { opt.warn_cb(msg); } else { @@ -15884,9 +15950,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { @@ -15909,9 +15975,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateAMDModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} define([], function () { @@ -15934,12 +16000,12 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateESModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} - var lexer = (function () { + const lexer = (function () { "use strict"; ${jisonLexerErrorDefinition} @@ -15968,9 +16034,9 @@ JisonLexerError.prototype.name = 'JisonLexerError';`; function generateCommonJSModule(opt) { opt = prepareOptions(opt); - var modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); + let modIncSrc = (opt.moduleInclude ? opt.moduleInclude + ';' : ''); - var src = rmCommonWS$2` + let src = rmCommonWS$2` ${generateGenericHeaderComment()} var ${opt.moduleName} = (function () { diff --git a/packages/jison-lex/examples/output/basic2_lex.jison-lexer.js b/packages/jison-lex/examples/output/basic2_lex.jison-lexer.js index d4c55a0ca..73ba893aa 100644 --- a/packages/jison-lex/examples/output/basic2_lex.jison-lexer.js +++ b/packages/jison-lex/examples/output/basic2_lex.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1485,10 +1426,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1606,4 +1547,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/basic_lex.jison-lexer.js b/packages/jison-lex/examples/output/basic_lex.jison-lexer.js index 25dc075f0..2290fc133 100644 --- a/packages/jison-lex/examples/output/basic_lex.jison-lexer.js +++ b/packages/jison-lex/examples/output/basic_lex.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1490,10 +1431,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1630,4 +1571,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/c99.l-lexer.js b/packages/jison-lex/examples/output/c99.l-lexer.js index a3ed2f314..005e48aeb 100644 --- a/packages/jison-lex/examples/output/c99.l-lexer.js +++ b/packages/jison-lex/examples/output/c99.l-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -2030,10 +1971,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -4373,4 +4314,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/c99.l-ref.json5 b/packages/jison-lex/examples/output/c99.l-ref.json5 index bdbbd5d3e..3079b51d5 100644 --- a/packages/jison-lex/examples/output/c99.l-ref.json5 +++ b/packages/jison-lex/examples/output/c99.l-ref.json5 @@ -7,11 +7,11 @@ name: 'ReferenceError', message: 'sym_type is not defined', stack: `ReferenceError: sym_type is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1550:27) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/examples/output/ccalc-lex.l-lexer.js b/packages/jison-lex/examples/output/ccalc-lex.l-lexer.js index 98aeabf88..80adc7e27 100644 --- a/packages/jison-lex/examples/output/ccalc-lex.l-lexer.js +++ b/packages/jison-lex/examples/output/ccalc-lex.l-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1589,10 +1530,10 @@ break; }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2029,4 +1970,4 @@ break; is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 ac8fbe53d..4118f1eae 100644 --- a/packages/jison-lex/examples/output/ccalc-lex.l-ref.json5 +++ b/packages/jison-lex/examples/output/ccalc-lex.l-ref.json5 @@ -7,11 +7,11 @@ name: 'ReferenceError', message: 'BeginToken is not defined', stack: `ReferenceError: BeginToken is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1571:2) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/examples/output/classy.jisonlex-lexer.js b/packages/jison-lex/examples/output/classy.jisonlex-lexer.js index c525e8958..28090900c 100644 --- a/packages/jison-lex/examples/output/classy.jisonlex-lexer.js +++ b/packages/jison-lex/examples/output/classy.jisonlex-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1644,10 +1585,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2375,4 +2316,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/codegen-feature-tester-base.jison-lexer.js b/packages/jison-lex/examples/output/codegen-feature-tester-base.jison-lexer.js index 06a68c528..2f9309ce7 100644 --- a/packages/jison-lex/examples/output/codegen-feature-tester-base.jison-lexer.js +++ b/packages/jison-lex/examples/output/codegen-feature-tester-base.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1625,10 +1566,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -3096,4 +3037,4 @@ parser.main = function () { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/comments.jison-lexer.js b/packages/jison-lex/examples/output/comments.jison-lexer.js index f48d32e22..79be41ffc 100644 --- a/packages/jison-lex/examples/output/comments.jison-lexer.js +++ b/packages/jison-lex/examples/output/comments.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1628,10 +1569,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2161,4 +2102,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/comments.jison-ref.json5 b/packages/jison-lex/examples/output/comments.jison-ref.json5 index 396da2db4..2deeffd4f 100644 --- a/packages/jison-lex/examples/output/comments.jison-ref.json5 +++ b/packages/jison-lex/examples/output/comments.jison-ref.json5 @@ -7,11 +7,11 @@ name: 'ReferenceError', message: 'getTypes is not defined', stack: `ReferenceError: getTypes is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1570:9) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/examples/output/compiled_calc_parse.jison-lexer.js b/packages/jison-lex/examples/output/compiled_calc_parse.jison-lexer.js index 07d9ac063..be866b588 100644 --- a/packages/jison-lex/examples/output/compiled_calc_parse.jison-lexer.js +++ b/packages/jison-lex/examples/output/compiled_calc_parse.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1737,10 +1678,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2732,4 +2673,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 5a9deba13..ae3ff5c85 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 @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1721,10 +1662,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2971,4 +2912,4 @@ parser.main = function () { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/floop.l-lexer.js b/packages/jison-lex/examples/output/floop.l-lexer.js index 9e56ae794..865aa6817 100644 --- a/packages/jison-lex/examples/output/floop.l-lexer.js +++ b/packages/jison-lex/examples/output/floop.l-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1705,10 +1646,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2652,4 +2593,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/handlebars.jison.l-lexer.js b/packages/jison-lex/examples/output/handlebars.jison.l-lexer.js index 1fe9ec176..338339c34 100644 --- a/packages/jison-lex/examples/output/handlebars.jison.l-lexer.js +++ b/packages/jison-lex/examples/output/handlebars.jison.l-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1778,10 +1719,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2991,4 +2932,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/issue-19-jison_lex-fixed.jison-lexer.js b/packages/jison-lex/examples/output/issue-19-jison_lex-fixed.jison-lexer.js index e89f140c9..15d1894f2 100644 --- a/packages/jison-lex/examples/output/issue-19-jison_lex-fixed.jison-lexer.js +++ b/packages/jison-lex/examples/output/issue-19-jison_lex-fixed.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1504,10 +1445,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1781,4 +1722,4 @@ parser.main = function () { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 b53791515..c7808b632 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,10 +90,10 @@ Erroneous area: 1: ;;a;aBaa ^.......^ - at Object.lexer_parseError [as parseError] (/regexp-lexer-cjs-es5.js:3508:37), :213:15) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1251:27) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/examples/output/issue-19-jison_lex.jison-lexer.js b/packages/jison-lex/examples/output/issue-19-jison_lex.jison-lexer.js index 38d5d8e11..48a59bace 100644 --- a/packages/jison-lex/examples/output/issue-19-jison_lex.jison-lexer.js +++ b/packages/jison-lex/examples/output/issue-19-jison_lex.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1504,10 +1445,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1781,4 +1722,4 @@ parser.main = function () { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/issue-357-url-lexing.jison-lexer.js b/packages/jison-lex/examples/output/issue-357-url-lexing.jison-lexer.js index 8e9b290ce..68272c9a8 100644 --- a/packages/jison-lex/examples/output/issue-357-url-lexing.jison-lexer.js +++ b/packages/jison-lex/examples/output/issue-357-url-lexing.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1500,10 +1441,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1729,4 +1670,4 @@ parser.main = function () { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/lex.l-lexer.js b/packages/jison-lex/examples/output/lex.l-lexer.js index f2e862469..a0fd7745b 100644 --- a/packages/jison-lex/examples/output/lex.l-lexer.js +++ b/packages/jison-lex/examples/output/lex.l-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -2548,10 +2489,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -5910,4 +5851,4 @@ lexer.log = function l_log() { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/lex.l-ref.json5 b/packages/jison-lex/examples/output/lex.l-ref.json5 index 2441be3e6..723d4913a 100644 --- a/packages/jison-lex/examples/output/lex.l-ref.json5 +++ b/packages/jison-lex/examples/output/lex.l-ref.json5 @@ -37,11 +37,11 @@ name: 'ReferenceError', message: 'rmCommonWS is not defined', stack: `ReferenceError: rmCommonWS is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :2088:45) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/examples/output/lex_grammar.jisonlex-lexer.js b/packages/jison-lex/examples/output/lex_grammar.jisonlex-lexer.js index 9f2335fa9..9952aa618 100644 --- a/packages/jison-lex/examples/output/lex_grammar.jisonlex-lexer.js +++ b/packages/jison-lex/examples/output/lex_grammar.jisonlex-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1615,10 +1556,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2202,4 +2143,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/parser-to-lexer-communication-test-w-debug.jison-lexer.js b/packages/jison-lex/examples/output/parser-to-lexer-communication-test-w-debug.jison-lexer.js index c16528a4e..e37eeffb2 100644 --- a/packages/jison-lex/examples/output/parser-to-lexer-communication-test-w-debug.jison-lexer.js +++ b/packages/jison-lex/examples/output/parser-to-lexer-communication-test-w-debug.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1509,10 +1450,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2620,4 +2561,4 @@ parser.main = function compiledRunner(args) { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/pascal.l-lexer.js b/packages/jison-lex/examples/output/pascal.l-lexer.js index d4c4dbcec..47d040762 100644 --- a/packages/jison-lex/examples/output/pascal.l-lexer.js +++ b/packages/jison-lex/examples/output/pascal.l-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1985,10 +1926,10 @@ break; }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -3770,4 +3711,4 @@ function yywrap() { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/pascal.l-ref.json5 b/packages/jison-lex/examples/output/pascal.l-ref.json5 index dc82c6b08..ed2d1c650 100644 --- a/packages/jison-lex/examples/output/pascal.l-ref.json5 +++ b/packages/jison-lex/examples/output/pascal.l-ref.json5 @@ -7,11 +7,11 @@ name: 'ReferenceError', message: 'PROGRAM is not defined', stack: `ReferenceError: PROGRAM is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1685:2) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/examples/output/regex.jison-lexer.js b/packages/jison-lex/examples/output/regex.jison-lexer.js index 53dffa5dd..6dcca4510 100644 --- a/packages/jison-lex/examples/output/regex.jison-lexer.js +++ b/packages/jison-lex/examples/output/regex.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1513,10 +1454,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1746,4 +1687,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/semwhitespace_lex.jison-lexer.js b/packages/jison-lex/examples/output/semwhitespace_lex.jison-lexer.js index 7d576f4d5..8f2cdfaaf 100644 --- a/packages/jison-lex/examples/output/semwhitespace_lex.jison-lexer.js +++ b/packages/jison-lex/examples/output/semwhitespace_lex.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1608,10 +1549,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2096,4 +2037,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/tikiwikiparser.jison-lexer.js b/packages/jison-lex/examples/output/tikiwikiparser.jison-lexer.js index b1b164d67..f200dab1a 100644 --- a/packages/jison-lex/examples/output/tikiwikiparser.jison-lexer.js +++ b/packages/jison-lex/examples/output/tikiwikiparser.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -2402,10 +2343,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -4186,4 +4127,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/unicode.jison-lexer.js b/packages/jison-lex/examples/output/unicode.jison-lexer.js index a752820f2..c955658d8 100644 --- a/packages/jison-lex/examples/output/unicode.jison-lexer.js +++ b/packages/jison-lex/examples/output/unicode.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -2443,10 +2384,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -4819,4 +4760,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/unicode.jison-ref.json5 b/packages/jison-lex/examples/output/unicode.jison-ref.json5 index debab4e71..538ce9e95 100644 --- a/packages/jison-lex/examples/output/unicode.jison-ref.json5 +++ b/packages/jison-lex/examples/output/unicode.jison-ref.json5 @@ -7,11 +7,11 @@ name: 'ReferenceError', message: 'is_constant is not defined', stack: `ReferenceError: is_constant is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1558:2) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1213:34) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/examples/output/unicode2.jison-lexer.js b/packages/jison-lex/examples/output/unicode2.jison-lexer.js index a752820f2..c955658d8 100644 --- a/packages/jison-lex/examples/output/unicode2.jison-lexer.js +++ b/packages/jison-lex/examples/output/unicode2.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -2443,10 +2384,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -4819,4 +4760,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/unicode2.jison-ref.json5 b/packages/jison-lex/examples/output/unicode2.jison-ref.json5 index debab4e71..538ce9e95 100644 --- a/packages/jison-lex/examples/output/unicode2.jison-ref.json5 +++ b/packages/jison-lex/examples/output/unicode2.jison-ref.json5 @@ -7,11 +7,11 @@ name: 'ReferenceError', message: 'is_constant is not defined', stack: `ReferenceError: is_constant is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1558:2) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1213:34) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/examples/output/with-includes.jison-lexer.js b/packages/jison-lex/examples/output/with-includes.jison-lexer.js index 33220eb32..d7f40c6ac 100644 --- a/packages/jison-lex/examples/output/with-includes.jison-lexer.js +++ b/packages/jison-lex/examples/output/with-includes.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1531,10 +1472,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1997,4 +1938,4 @@ parser.main = function (args) { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/with-includes.test.lex-lexer.js b/packages/jison-lex/examples/output/with-includes.test.lex-lexer.js index f6ac33ad7..63bdb2709 100644 --- a/packages/jison-lex/examples/output/with-includes.test.lex-lexer.js +++ b/packages/jison-lex/examples/output/with-includes.test.lex-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1529,10 +1470,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1820,4 +1761,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/with_custom_lexer.jison-lexer.js b/packages/jison-lex/examples/output/with_custom_lexer.jison-lexer.js index 9d7ce261d..4f1a141c3 100644 --- a/packages/jison-lex/examples/output/with_custom_lexer.jison-lexer.js +++ b/packages/jison-lex/examples/output/with_custom_lexer.jison-lexer.js @@ -1,5 +1,5 @@ - var lexer; + // When you set up a custom lexer, this is the minimum example for one: // // your lexer class/object must provide these interface methods and constants at least: @@ -39,10 +39,10 @@ }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -367,4 +367,4 @@ parser.main = function (args) { is_custom_lexer: true, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/output/xregexp.jison-lexer.js b/packages/jison-lex/examples/output/xregexp.jison-lexer.js index 484b56082..832461e3c 100644 --- a/packages/jison-lex/examples/output/xregexp.jison-lexer.js +++ b/packages/jison-lex/examples/output/xregexp.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1494,10 +1435,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1659,4 +1600,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/basic2_lex.jison-lexer.js b/packages/jison-lex/examples/reference-output/basic2_lex.jison-lexer.js index d4c55a0ca..73ba893aa 100644 --- a/packages/jison-lex/examples/reference-output/basic2_lex.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/basic2_lex.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1485,10 +1426,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1606,4 +1547,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/basic_lex.jison-lexer.js b/packages/jison-lex/examples/reference-output/basic_lex.jison-lexer.js index 25dc075f0..2290fc133 100644 --- a/packages/jison-lex/examples/reference-output/basic_lex.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/basic_lex.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1490,10 +1431,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1630,4 +1571,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/c99.l-lexer.js b/packages/jison-lex/examples/reference-output/c99.l-lexer.js index a3ed2f314..005e48aeb 100644 --- a/packages/jison-lex/examples/reference-output/c99.l-lexer.js +++ b/packages/jison-lex/examples/reference-output/c99.l-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -2030,10 +1971,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -4373,4 +4314,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 bdbbd5d3e..3079b51d5 100644 --- a/packages/jison-lex/examples/reference-output/c99.l-ref.json5 +++ b/packages/jison-lex/examples/reference-output/c99.l-ref.json5 @@ -7,11 +7,11 @@ name: 'ReferenceError', message: 'sym_type is not defined', stack: `ReferenceError: sym_type is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1550:27) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/examples/reference-output/ccalc-lex.l-lexer.js b/packages/jison-lex/examples/reference-output/ccalc-lex.l-lexer.js index 98aeabf88..80adc7e27 100644 --- a/packages/jison-lex/examples/reference-output/ccalc-lex.l-lexer.js +++ b/packages/jison-lex/examples/reference-output/ccalc-lex.l-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1589,10 +1530,10 @@ break; }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2029,4 +1970,4 @@ break; is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 ac8fbe53d..4118f1eae 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,11 +7,11 @@ name: 'ReferenceError', message: 'BeginToken is not defined', stack: `ReferenceError: BeginToken is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1571:2) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/examples/reference-output/classy.jisonlex-lexer.js b/packages/jison-lex/examples/reference-output/classy.jisonlex-lexer.js index c525e8958..28090900c 100644 --- a/packages/jison-lex/examples/reference-output/classy.jisonlex-lexer.js +++ b/packages/jison-lex/examples/reference-output/classy.jisonlex-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1644,10 +1585,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2375,4 +2316,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/codegen-feature-tester-base.jison-lexer.js b/packages/jison-lex/examples/reference-output/codegen-feature-tester-base.jison-lexer.js index 06a68c528..2f9309ce7 100644 --- a/packages/jison-lex/examples/reference-output/codegen-feature-tester-base.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/codegen-feature-tester-base.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1625,10 +1566,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -3096,4 +3037,4 @@ parser.main = function () { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/comments.jison-lexer.js b/packages/jison-lex/examples/reference-output/comments.jison-lexer.js index f48d32e22..79be41ffc 100644 --- a/packages/jison-lex/examples/reference-output/comments.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/comments.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1628,10 +1569,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2161,4 +2102,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 396da2db4..2deeffd4f 100644 --- a/packages/jison-lex/examples/reference-output/comments.jison-ref.json5 +++ b/packages/jison-lex/examples/reference-output/comments.jison-ref.json5 @@ -7,11 +7,11 @@ name: 'ReferenceError', message: 'getTypes is not defined', stack: `ReferenceError: getTypes is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1570:9) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/examples/reference-output/compiled_calc_parse.jison-lexer.js b/packages/jison-lex/examples/reference-output/compiled_calc_parse.jison-lexer.js index 07d9ac063..be866b588 100644 --- a/packages/jison-lex/examples/reference-output/compiled_calc_parse.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/compiled_calc_parse.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1737,10 +1678,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2732,4 +2673,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 5a9deba13..ae3ff5c85 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 @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1721,10 +1662,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2971,4 +2912,4 @@ parser.main = function () { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/floop.l-lexer.js b/packages/jison-lex/examples/reference-output/floop.l-lexer.js index 9e56ae794..865aa6817 100644 --- a/packages/jison-lex/examples/reference-output/floop.l-lexer.js +++ b/packages/jison-lex/examples/reference-output/floop.l-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1705,10 +1646,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2652,4 +2593,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/handlebars.jison.l-lexer.js b/packages/jison-lex/examples/reference-output/handlebars.jison.l-lexer.js index 1fe9ec176..338339c34 100644 --- a/packages/jison-lex/examples/reference-output/handlebars.jison.l-lexer.js +++ b/packages/jison-lex/examples/reference-output/handlebars.jison.l-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1778,10 +1719,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2991,4 +2932,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/issue-19-jison_lex-fixed.jison-lexer.js b/packages/jison-lex/examples/reference-output/issue-19-jison_lex-fixed.jison-lexer.js index e89f140c9..15d1894f2 100644 --- a/packages/jison-lex/examples/reference-output/issue-19-jison_lex-fixed.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/issue-19-jison_lex-fixed.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1504,10 +1445,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1781,4 +1722,4 @@ parser.main = function () { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 b53791515..c7808b632 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,10 +90,10 @@ Erroneous area: 1: ;;a;aBaa ^.......^ - at Object.lexer_parseError [as parseError] (/regexp-lexer-cjs-es5.js:3508:37), :213:15) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1251:27) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/examples/reference-output/issue-19-jison_lex.jison-lexer.js b/packages/jison-lex/examples/reference-output/issue-19-jison_lex.jison-lexer.js index 38d5d8e11..48a59bace 100644 --- a/packages/jison-lex/examples/reference-output/issue-19-jison_lex.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/issue-19-jison_lex.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1504,10 +1445,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1781,4 +1722,4 @@ parser.main = function () { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/issue-357-url-lexing.jison-lexer.js b/packages/jison-lex/examples/reference-output/issue-357-url-lexing.jison-lexer.js index 8e9b290ce..68272c9a8 100644 --- a/packages/jison-lex/examples/reference-output/issue-357-url-lexing.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/issue-357-url-lexing.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1500,10 +1441,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1729,4 +1670,4 @@ parser.main = function () { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/lex.l-lexer.js b/packages/jison-lex/examples/reference-output/lex.l-lexer.js index f2e862469..a0fd7745b 100644 --- a/packages/jison-lex/examples/reference-output/lex.l-lexer.js +++ b/packages/jison-lex/examples/reference-output/lex.l-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -2548,10 +2489,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -5910,4 +5851,4 @@ lexer.log = function l_log() { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 2441be3e6..723d4913a 100644 --- a/packages/jison-lex/examples/reference-output/lex.l-ref.json5 +++ b/packages/jison-lex/examples/reference-output/lex.l-ref.json5 @@ -37,11 +37,11 @@ name: 'ReferenceError', message: 'rmCommonWS is not defined', stack: `ReferenceError: rmCommonWS is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :2088:45) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/examples/reference-output/lex_grammar.jisonlex-lexer.js b/packages/jison-lex/examples/reference-output/lex_grammar.jisonlex-lexer.js index 9f2335fa9..9952aa618 100644 --- a/packages/jison-lex/examples/reference-output/lex_grammar.jisonlex-lexer.js +++ b/packages/jison-lex/examples/reference-output/lex_grammar.jisonlex-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1615,10 +1556,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2202,4 +2143,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/parser-to-lexer-communication-test-w-debug.jison-lexer.js b/packages/jison-lex/examples/reference-output/parser-to-lexer-communication-test-w-debug.jison-lexer.js index c16528a4e..e37eeffb2 100644 --- a/packages/jison-lex/examples/reference-output/parser-to-lexer-communication-test-w-debug.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/parser-to-lexer-communication-test-w-debug.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1509,10 +1450,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2620,4 +2561,4 @@ parser.main = function compiledRunner(args) { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/pascal.l-lexer.js b/packages/jison-lex/examples/reference-output/pascal.l-lexer.js index d4c4dbcec..47d040762 100644 --- a/packages/jison-lex/examples/reference-output/pascal.l-lexer.js +++ b/packages/jison-lex/examples/reference-output/pascal.l-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1985,10 +1926,10 @@ break; }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -3770,4 +3711,4 @@ function yywrap() { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 dc82c6b08..ed2d1c650 100644 --- a/packages/jison-lex/examples/reference-output/pascal.l-ref.json5 +++ b/packages/jison-lex/examples/reference-output/pascal.l-ref.json5 @@ -7,11 +7,11 @@ name: 'ReferenceError', message: 'PROGRAM is not defined', stack: `ReferenceError: PROGRAM is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1685:2) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/examples/reference-output/regex.jison-lexer.js b/packages/jison-lex/examples/reference-output/regex.jison-lexer.js index 53dffa5dd..6dcca4510 100644 --- a/packages/jison-lex/examples/reference-output/regex.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/regex.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1513,10 +1454,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1746,4 +1687,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/semwhitespace_lex.jison-lexer.js b/packages/jison-lex/examples/reference-output/semwhitespace_lex.jison-lexer.js index 7d576f4d5..8f2cdfaaf 100644 --- a/packages/jison-lex/examples/reference-output/semwhitespace_lex.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/semwhitespace_lex.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1608,10 +1549,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -2096,4 +2037,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/tikiwikiparser.jison-lexer.js b/packages/jison-lex/examples/reference-output/tikiwikiparser.jison-lexer.js index b1b164d67..f200dab1a 100644 --- a/packages/jison-lex/examples/reference-output/tikiwikiparser.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/tikiwikiparser.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -2402,10 +2343,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -4186,4 +4127,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 a752820f2..c955658d8 100644 --- a/packages/jison-lex/examples/reference-output/unicode.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/unicode.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -2443,10 +2384,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -4819,4 +4760,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 debab4e71..538ce9e95 100644 --- a/packages/jison-lex/examples/reference-output/unicode.jison-ref.json5 +++ b/packages/jison-lex/examples/reference-output/unicode.jison-ref.json5 @@ -7,11 +7,11 @@ name: 'ReferenceError', message: 'is_constant is not defined', stack: `ReferenceError: is_constant is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1558:2) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1213:34) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 a752820f2..c955658d8 100644 --- a/packages/jison-lex/examples/reference-output/unicode2.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/unicode2.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -2443,10 +2384,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -4819,4 +4760,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 debab4e71..538ce9e95 100644 --- a/packages/jison-lex/examples/reference-output/unicode2.jison-ref.json5 +++ b/packages/jison-lex/examples/reference-output/unicode2.jison-ref.json5 @@ -7,11 +7,11 @@ name: 'ReferenceError', message: 'is_constant is not defined', stack: `ReferenceError: is_constant is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1558:2) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1213:34) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/examples/reference-output/with-includes.jison-lexer.js b/packages/jison-lex/examples/reference-output/with-includes.jison-lexer.js index 33220eb32..d7f40c6ac 100644 --- a/packages/jison-lex/examples/reference-output/with-includes.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/with-includes.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1531,10 +1472,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1997,4 +1938,4 @@ parser.main = function (args) { is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/with-includes.test.lex-lexer.js b/packages/jison-lex/examples/reference-output/with-includes.test.lex-lexer.js index f6ac33ad7..63bdb2709 100644 --- a/packages/jison-lex/examples/reference-output/with-includes.test.lex-lexer.js +++ b/packages/jison-lex/examples/reference-output/with-includes.test.lex-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1529,10 +1470,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1820,4 +1761,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/with_custom_lexer.jison-lexer.js b/packages/jison-lex/examples/reference-output/with_custom_lexer.jison-lexer.js index 9d7ce261d..4f1a141c3 100644 --- a/packages/jison-lex/examples/reference-output/with_custom_lexer.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/with_custom_lexer.jison-lexer.js @@ -1,5 +1,5 @@ - var lexer; + // When you set up a custom lexer, this is the minimum example for one: // // your lexer class/object must provide these interface methods and constants at least: @@ -39,10 +39,10 @@ }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -367,4 +367,4 @@ parser.main = function (args) { is_custom_lexer: true, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/examples/reference-output/xregexp.jison-lexer.js b/packages/jison-lex/examples/reference-output/xregexp.jison-lexer.js index 484b56082..832461e3c 100644 --- a/packages/jison-lex/examples/reference-output/xregexp.jison-lexer.js +++ b/packages/jison-lex/examples/reference-output/xregexp.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1494,10 +1435,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1659,4 +1600,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/tests/specs/output/001-custom-lexer-baseline.jison-lexer.js b/packages/jison-lex/tests/specs/output/001-custom-lexer-baseline.jison-lexer.js index 4cb2ea520..a12fff762 100644 --- a/packages/jison-lex/tests/specs/output/001-custom-lexer-baseline.jison-lexer.js +++ b/packages/jison-lex/tests/specs/output/001-custom-lexer-baseline.jison-lexer.js @@ -1,5 +1,5 @@ - var lexer; + // custom lexer... console.log('The moment the custom lexer gets defined...'); var lexer = { @@ -17,10 +17,10 @@ }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -135,4 +135,4 @@ var YYSTATE = YY_START; is_custom_lexer: true, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/tests/specs/output/002-custom-lexer-extra-code-chunks.jison-lexer.js b/packages/jison-lex/tests/specs/output/002-custom-lexer-extra-code-chunks.jison-lexer.js index 269ee4808..f9382615c 100644 --- a/packages/jison-lex/tests/specs/output/002-custom-lexer-extra-code-chunks.jison-lexer.js +++ b/packages/jison-lex/tests/specs/output/002-custom-lexer-extra-code-chunks.jison-lexer.js @@ -1,5 +1,5 @@ - var lexer; + // custom lexer... console.log('The moment the custom lexer gets defined...'); var lexer = { @@ -17,10 +17,10 @@ }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -144,4 +144,4 @@ var YYSTATE = YY_START; is_custom_lexer: true, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/tests/specs/output/003-issue-23-alt-good.js-lexer.js b/packages/jison-lex/tests/specs/output/003-issue-23-alt-good.js-lexer.js index 5cc2bfb0c..cc7c0c458 100644 --- a/packages/jison-lex/tests/specs/output/003-issue-23-alt-good.js-lexer.js +++ b/packages/jison-lex/tests/specs/output/003-issue-23-alt-good.js-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1508,10 +1449,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1695,4 +1636,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/tests/specs/output/003-issue-23-good.js-lexer.js b/packages/jison-lex/tests/specs/output/003-issue-23-good.js-lexer.js index 35da5a76d..460fe0e43 100644 --- a/packages/jison-lex/tests/specs/output/003-issue-23-good.js-lexer.js +++ b/packages/jison-lex/tests/specs/output/003-issue-23-good.js-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1506,10 +1447,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1685,4 +1626,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/tests/specs/output/003-issue-23-trouble.js-lexer.js b/packages/jison-lex/tests/specs/output/003-issue-23-trouble.js-lexer.js index 35da5a76d..460fe0e43 100644 --- a/packages/jison-lex/tests/specs/output/003-issue-23-trouble.js-lexer.js +++ b/packages/jison-lex/tests/specs/output/003-issue-23-trouble.js-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1506,10 +1447,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1685,4 +1626,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 eacb36155..7afed1941 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,11 +28,11 @@ 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-es5.js:3245:174) - at processGrammar (/regexp-lexer-cjs-es5.js:5081:1728) - at test_me (/regexp-lexer-cjs-es5.js:3492:175) - at new RegExpLexer (/regexp-lexer-cjs-es5.js:3514:130) - at Context.testEachLexerExample (/regexplexer.js:3515:17) + 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 Context.testEachLexerExample (/regexplexer.js:3637:25) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 2bde02f7b..71b08f6b2 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,11 +32,11 @@ 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-es5.js:3245:174) - at processGrammar (/regexp-lexer-cjs-es5.js:5081:1728) - at test_me (/regexp-lexer-cjs-es5.js:3492:175) - at new RegExpLexer (/regexp-lexer-cjs-es5.js:3514:130) - at Context.testEachLexerExample (/regexplexer.js:3515:17) + 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 Context.testEachLexerExample (/regexplexer.js:3637:25) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) @@ -1174,7 +1174,7 @@ Unexpected "ACTION_BODY"`, "a" %{ ret... -^ Unexpected "ACTION_BODY"`, - errorSymbolDescr: '"ACTION_BODY"', + errSymbolDescr: '"ACTION_BODY"', expectedStr: [], stackSampleLength: 3, }, @@ -3780,7 +3780,7 @@ Unexpected "ACTION_BODY"`, "a" %{ ret... -^ Unexpected "ACTION_BODY"`, - errorSymbolDescr: '"ACTION_BODY"', + errSymbolDescr: '"ACTION_BODY"', expectedStr: [], stackSampleLength: 3, }, diff --git a/packages/jison-lex/tests/specs/output/005-combined-rules.jison-lexer.js b/packages/jison-lex/tests/specs/output/005-combined-rules.jison-lexer.js index 942a86b16..8fe8baeb3 100644 --- a/packages/jison-lex/tests/specs/output/005-combined-rules.jison-lexer.js +++ b/packages/jison-lex/tests/specs/output/005-combined-rules.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1485,10 +1426,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1606,4 +1547,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/tests/specs/output/006-multiple-action-chunks.jison-lexer.js b/packages/jison-lex/tests/specs/output/006-multiple-action-chunks.jison-lexer.js index a9c31f74c..a852506b9 100644 --- a/packages/jison-lex/tests/specs/output/006-multiple-action-chunks.jison-lexer.js +++ b/packages/jison-lex/tests/specs/output/006-multiple-action-chunks.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1509,10 +1450,10 @@ break; }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1710,4 +1651,4 @@ function block0E() { }`, is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 8f5981cff..e98ef86c7 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,11 +7,11 @@ name: 'ReferenceError', message: 'block0A is not defined', stack: `ReferenceError: block0A is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1531:13) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/tests/specs/output/007-multiple-action-chunks-with-includes.jison-lexer.js b/packages/jison-lex/tests/specs/output/007-multiple-action-chunks-with-includes.jison-lexer.js index fbc1416c2..cba94ed4c 100644 --- a/packages/jison-lex/tests/specs/output/007-multiple-action-chunks-with-includes.jison-lexer.js +++ b/packages/jison-lex/tests/specs/output/007-multiple-action-chunks-with-includes.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1523,10 +1464,10 @@ break; }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1777,4 +1718,4 @@ function dummy3() {} is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 8f5981cff..e98ef86c7 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,11 +7,11 @@ name: 'ReferenceError', message: 'block0A is not defined', stack: `ReferenceError: block0A is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1531:13) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/tests/specs/output/008-template-string-in-action.jison-lexer.js b/packages/jison-lex/tests/specs/output/008-template-string-in-action.jison-lexer.js index 3a790b2b4..79fee99fa 100644 --- a/packages/jison-lex/tests/specs/output/008-template-string-in-action.jison-lexer.js +++ b/packages/jison-lex/tests/specs/output/008-template-string-in-action.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1489,10 +1430,10 @@ break; }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1628,4 +1569,4 @@ function log(msg) {}`, is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 c319fc806..e54fa4c0b 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,11 +7,11 @@ name: 'ReferenceError', message: 'log is not defined', stack: `ReferenceError: log is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1543:16) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/tests/specs/output/009-template-string-in-action.jison-lexer.js b/packages/jison-lex/tests/specs/output/009-template-string-in-action.jison-lexer.js index dca8dae63..bbd898f45 100644 --- a/packages/jison-lex/tests/specs/output/009-template-string-in-action.jison-lexer.js +++ b/packages/jison-lex/tests/specs/output/009-template-string-in-action.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1489,10 +1430,10 @@ break; }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1628,4 +1569,4 @@ function log(msg) {}`, is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 c319fc806..e54fa4c0b 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,11 +7,11 @@ name: 'ReferenceError', message: 'log is not defined', stack: `ReferenceError: log is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1543:16) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/tests/specs/output/010-action-code-marker-alternatives.jison-lexer.js b/packages/jison-lex/tests/specs/output/010-action-code-marker-alternatives.jison-lexer.js index 3a790b2b4..79fee99fa 100644 --- a/packages/jison-lex/tests/specs/output/010-action-code-marker-alternatives.jison-lexer.js +++ b/packages/jison-lex/tests/specs/output/010-action-code-marker-alternatives.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1489,10 +1430,10 @@ break; }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1628,4 +1569,4 @@ function log(msg) {}`, is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 c319fc806..e54fa4c0b 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,11 +7,11 @@ name: 'ReferenceError', message: 'log is not defined', stack: `ReferenceError: log is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1543:16) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/tests/specs/output/011-action-code-marker-alternatives.jison-lexer.js b/packages/jison-lex/tests/specs/output/011-action-code-marker-alternatives.jison-lexer.js index d0282a236..750365530 100644 --- a/packages/jison-lex/tests/specs/output/011-action-code-marker-alternatives.jison-lexer.js +++ b/packages/jison-lex/tests/specs/output/011-action-code-marker-alternatives.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1555,10 +1496,10 @@ break; }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1868,4 +1809,4 @@ function log(msg) {}`, is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 c319fc806..e54fa4c0b 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,11 +7,11 @@ name: 'ReferenceError', message: 'log is not defined', stack: `ReferenceError: log is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1543:16) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/tests/specs/reference-output/001-custom-lexer-baseline.jison-lexer.js b/packages/jison-lex/tests/specs/reference-output/001-custom-lexer-baseline.jison-lexer.js index 4cb2ea520..a12fff762 100644 --- a/packages/jison-lex/tests/specs/reference-output/001-custom-lexer-baseline.jison-lexer.js +++ b/packages/jison-lex/tests/specs/reference-output/001-custom-lexer-baseline.jison-lexer.js @@ -1,5 +1,5 @@ - var lexer; + // custom lexer... console.log('The moment the custom lexer gets defined...'); var lexer = { @@ -17,10 +17,10 @@ }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -135,4 +135,4 @@ var YYSTATE = YY_START; is_custom_lexer: true, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/tests/specs/reference-output/002-custom-lexer-extra-code-chunks.jison-lexer.js b/packages/jison-lex/tests/specs/reference-output/002-custom-lexer-extra-code-chunks.jison-lexer.js index 269ee4808..f9382615c 100644 --- a/packages/jison-lex/tests/specs/reference-output/002-custom-lexer-extra-code-chunks.jison-lexer.js +++ b/packages/jison-lex/tests/specs/reference-output/002-custom-lexer-extra-code-chunks.jison-lexer.js @@ -1,5 +1,5 @@ - var lexer; + // custom lexer... console.log('The moment the custom lexer gets defined...'); var lexer = { @@ -17,10 +17,10 @@ }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -144,4 +144,4 @@ var YYSTATE = YY_START; is_custom_lexer: true, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/tests/specs/reference-output/003-issue-23-alt-good.js-lexer.js b/packages/jison-lex/tests/specs/reference-output/003-issue-23-alt-good.js-lexer.js index 5cc2bfb0c..cc7c0c458 100644 --- a/packages/jison-lex/tests/specs/reference-output/003-issue-23-alt-good.js-lexer.js +++ b/packages/jison-lex/tests/specs/reference-output/003-issue-23-alt-good.js-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1508,10 +1449,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1695,4 +1636,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/tests/specs/reference-output/003-issue-23-good.js-lexer.js b/packages/jison-lex/tests/specs/reference-output/003-issue-23-good.js-lexer.js index 35da5a76d..460fe0e43 100644 --- a/packages/jison-lex/tests/specs/reference-output/003-issue-23-good.js-lexer.js +++ b/packages/jison-lex/tests/specs/reference-output/003-issue-23-good.js-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1506,10 +1447,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1685,4 +1626,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/tests/specs/reference-output/003-issue-23-trouble.js-lexer.js b/packages/jison-lex/tests/specs/reference-output/003-issue-23-trouble.js-lexer.js index 35da5a76d..460fe0e43 100644 --- a/packages/jison-lex/tests/specs/reference-output/003-issue-23-trouble.js-lexer.js +++ b/packages/jison-lex/tests/specs/reference-output/003-issue-23-trouble.js-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1506,10 +1447,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1685,4 +1626,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 eacb36155..7afed1941 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,11 +28,11 @@ 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-es5.js:3245:174) - at processGrammar (/regexp-lexer-cjs-es5.js:5081:1728) - at test_me (/regexp-lexer-cjs-es5.js:3492:175) - at new RegExpLexer (/regexp-lexer-cjs-es5.js:3514:130) - at Context.testEachLexerExample (/regexplexer.js:3515:17) + 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 Context.testEachLexerExample (/regexplexer.js:3637:25) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 2bde02f7b..71b08f6b2 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,11 +32,11 @@ 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-es5.js:3245:174) - at processGrammar (/regexp-lexer-cjs-es5.js:5081:1728) - at test_me (/regexp-lexer-cjs-es5.js:3492:175) - at new RegExpLexer (/regexp-lexer-cjs-es5.js:3514:130) - at Context.testEachLexerExample (/regexplexer.js:3515:17) + 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 Context.testEachLexerExample (/regexplexer.js:3637:25) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) @@ -1174,7 +1174,7 @@ Unexpected "ACTION_BODY"`, "a" %{ ret... -^ Unexpected "ACTION_BODY"`, - errorSymbolDescr: '"ACTION_BODY"', + errSymbolDescr: '"ACTION_BODY"', expectedStr: [], stackSampleLength: 3, }, @@ -3780,7 +3780,7 @@ Unexpected "ACTION_BODY"`, "a" %{ ret... -^ Unexpected "ACTION_BODY"`, - errorSymbolDescr: '"ACTION_BODY"', + errSymbolDescr: '"ACTION_BODY"', expectedStr: [], stackSampleLength: 3, }, diff --git a/packages/jison-lex/tests/specs/reference-output/005-combined-rules.jison-lexer.js b/packages/jison-lex/tests/specs/reference-output/005-combined-rules.jison-lexer.js index 942a86b16..8fe8baeb3 100644 --- a/packages/jison-lex/tests/specs/reference-output/005-combined-rules.jison-lexer.js +++ b/packages/jison-lex/tests/specs/reference-output/005-combined-rules.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1485,10 +1426,10 @@ default: }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1606,4 +1547,4 @@ default: is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file diff --git a/packages/jison-lex/tests/specs/reference-output/006-multiple-action-chunks.jison-lexer.js b/packages/jison-lex/tests/specs/reference-output/006-multiple-action-chunks.jison-lexer.js index a9c31f74c..a852506b9 100644 --- a/packages/jison-lex/tests/specs/reference-output/006-multiple-action-chunks.jison-lexer.js +++ b/packages/jison-lex/tests/specs/reference-output/006-multiple-action-chunks.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1509,10 +1450,10 @@ break; }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1710,4 +1651,4 @@ function block0E() { }`, is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 8f5981cff..e98ef86c7 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,11 +7,11 @@ name: 'ReferenceError', message: 'block0A is not defined', stack: `ReferenceError: block0A is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1531:13) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/tests/specs/reference-output/007-multiple-action-chunks-with-includes.jison-lexer.js b/packages/jison-lex/tests/specs/reference-output/007-multiple-action-chunks-with-includes.jison-lexer.js index fbc1416c2..cba94ed4c 100644 --- a/packages/jison-lex/tests/specs/reference-output/007-multiple-action-chunks-with-includes.jison-lexer.js +++ b/packages/jison-lex/tests/specs/reference-output/007-multiple-action-chunks-with-includes.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1523,10 +1464,10 @@ break; }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1777,4 +1718,4 @@ function dummy3() {} is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 8f5981cff..e98ef86c7 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,11 +7,11 @@ name: 'ReferenceError', message: 'block0A is not defined', stack: `ReferenceError: block0A is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1531:13) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/tests/specs/reference-output/008-template-string-in-action.jison-lexer.js b/packages/jison-lex/tests/specs/reference-output/008-template-string-in-action.jison-lexer.js index 3a790b2b4..79fee99fa 100644 --- a/packages/jison-lex/tests/specs/reference-output/008-template-string-in-action.jison-lexer.js +++ b/packages/jison-lex/tests/specs/reference-output/008-template-string-in-action.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1489,10 +1430,10 @@ break; }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1628,4 +1569,4 @@ function log(msg) {}`, is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 c319fc806..e54fa4c0b 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,11 +7,11 @@ name: 'ReferenceError', message: 'log is not defined', stack: `ReferenceError: log is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1543:16) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/tests/specs/reference-output/009-template-string-in-action.jison-lexer.js b/packages/jison-lex/tests/specs/reference-output/009-template-string-in-action.jison-lexer.js index dca8dae63..bbd898f45 100644 --- a/packages/jison-lex/tests/specs/reference-output/009-template-string-in-action.jison-lexer.js +++ b/packages/jison-lex/tests/specs/reference-output/009-template-string-in-action.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1489,10 +1430,10 @@ break; }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1628,4 +1569,4 @@ function log(msg) {}`, is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 c319fc806..e54fa4c0b 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,11 +7,11 @@ name: 'ReferenceError', message: 'log is not defined', stack: `ReferenceError: log is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1543:16) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/tests/specs/reference-output/010-action-code-marker-alternatives.jison-lexer.js b/packages/jison-lex/tests/specs/reference-output/010-action-code-marker-alternatives.jison-lexer.js index 3a790b2b4..79fee99fa 100644 --- a/packages/jison-lex/tests/specs/reference-output/010-action-code-marker-alternatives.jison-lexer.js +++ b/packages/jison-lex/tests/specs/reference-output/010-action-code-marker-alternatives.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1489,10 +1430,10 @@ break; }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1628,4 +1569,4 @@ function log(msg) {}`, is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 c319fc806..e54fa4c0b 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,11 +7,11 @@ name: 'ReferenceError', message: 'log is not defined', stack: `ReferenceError: log is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1543:16) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/jison-lex/tests/specs/reference-output/011-action-code-marker-alternatives.jison-lexer.js b/packages/jison-lex/tests/specs/reference-output/011-action-code-marker-alternatives.jison-lexer.js index d0282a236..750365530 100644 --- a/packages/jison-lex/tests/specs/reference-output/011-action-code-marker-alternatives.jison-lexer.js +++ b/packages/jison-lex/tests/specs/reference-output/011-action-code-marker-alternatives.jison-lexer.js @@ -1,7 +1,8 @@ - -var lexer = { -/*JISON-LEX-ANALYTICS-REPORT*/EOF: 1, + +const lexer = { +/* JISON-LEX-ANALYTICS-REPORT */ +EOF: 1, ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -43,8 +44,6 @@ var lexer = { * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - "use strict"; - msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -54,14 +53,14 @@ var lexer = { } if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; } msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { msg += '\n' + pos_str; @@ -72,14 +71,14 @@ var lexer = { } } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... token: null, line: this.yylineno, loc: this.yylloc, - yy: this.yy, + yy: this.yy, lexer: this, /** @@ -99,9 +98,8 @@ var lexer = { // info.yy = null; // info.lexer = null; // ... - "use strict"; - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -121,8 +119,6 @@ var lexer = { * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -143,16 +139,14 @@ var lexer = { * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - "use strict"; - - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; } @@ -173,8 +167,6 @@ var lexer = { * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - "use strict"; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -182,8 +174,8 @@ var lexer = { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -201,8 +193,6 @@ var lexer = { * @this {RegExpLexer} */ clear: function lexer_clear() { - "use strict"; - this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -212,14 +202,14 @@ var lexer = { this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, last_line: this.yylineno + 1, last_column: col, - range: [this.offset, this.offset] + range: [ this.offset, this.offset ] }; }, @@ -230,8 +220,6 @@ var lexer = { * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - "use strict"; - this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -239,40 +227,40 @@ var lexer = { // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; - for (var i = 0, len = rules.length; i < len; i++) { - var rule_re = rules[i]; + let rules = this.rules; + for (var i = 0, len = rules.length; i < len; i++) { + var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? - if (typeof rule_re === 'number') { - rules[i] = rules[rule_re]; + if (typeof rule_re === 'number') { + rules[i] = rules[rule_re]; + } } - } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; + let conditions = this.conditions; + for (let k in conditions) { + let spec = conditions[k]; - var rule_ids = spec.rules; + let rule_ids = spec.rules; - var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + var len = rule_ids.length; + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); - for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; - var rule_re = rules[idx]; - rule_regexes[i + 1] = rule_re; - rule_new_ids[i + 1] = idx; - } + for (var i = 0; i < len; i++) { + let idx = rule_ids[i]; + var rule_re = rules[idx]; + rule_regexes[i + 1] = rule_re; + rule_new_ids[i + 1] = idx; + } - spec.rules = rule_new_ids; - spec.__rule_regexes = rule_regexes; - spec.__rule_count = len; - } + spec.rules = rule_new_ids; + spec.__rule_regexes = rule_regexes; + spec.__rule_count = len; + } - this.__decompressed = true; + this.__decompressed = true; } if (input && typeof input !== 'string') { @@ -284,7 +272,7 @@ var lexer = { this.done = false; this.yylineno = 0; this.matched = ''; - this.conditionStack = ['INITIAL']; + this.conditionStack = [ 'INITIAL' ]; this.__currentRuleSet__ = null; this.yylloc = { first_line: 1, @@ -292,7 +280,7 @@ var lexer = { last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; this.offset = 0; this.base_position = 0; @@ -353,9 +341,7 @@ var lexer = { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - "use strict"; - - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { this._input = '' + rv; @@ -374,8 +360,6 @@ var lexer = { * @this {RegExpLexer} */ input: function lexer_input() { - "use strict"; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -384,7 +368,7 @@ var lexer = { this._clear_state = -1; this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -394,13 +378,13 @@ var lexer = { // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; ch += ch2; @@ -432,10 +416,8 @@ var lexer = { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - "use strict"; - - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -467,8 +449,8 @@ var lexer = { // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; pre_lines = pre.split(this.CRLF_Re); @@ -486,9 +468,9 @@ var lexer = { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -498,14 +480,12 @@ var lexer = { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - "use strict"; - return this._input || ''; }, @@ -516,8 +496,6 @@ var lexer = { * @this {RegExpLexer} */ more: function lexer_more() { - "use strict"; - this._more = true; return this; }, @@ -530,19 +508,17 @@ var lexer = { * @this {RegExpLexer} */ reject: function lexer_reject() { - "use strict"; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } return this; @@ -555,8 +531,6 @@ var lexer = { * @this {RegExpLexer} */ less: function lexer_less(n) { - "use strict"; - return this.unput(this.match.slice(n)); }, @@ -579,24 +553,24 @@ var lexer = { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - "use strict"; - - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + let past = this.matched.substring(0, this.matched.length - this.match.length); + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this! - else if (!maxLines) + } + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -608,8 +582,8 @@ var lexer = { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -635,24 +609,25 @@ var lexer = { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - "use strict"; - - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) + let next = this.match; + let source = this._input || ''; + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this! - else if (!maxLines) + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: @@ -661,7 +636,7 @@ var lexer = { } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -680,10 +655,8 @@ var lexer = { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - "use strict"; - - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -705,15 +678,13 @@ var lexer = { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - "use strict"; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0, - range: [0, 0] + range: [ 0, 0 ] }; if (actual) { loc.first_line = actual.first_line | 0; @@ -844,58 +815,54 @@ var lexer = { * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - "use strict"; - loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); - var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); - var lineno_display_width = (1 + Math.log10(l1 | 1) | 0); - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - "use strict"; - - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = (new Array(lineno_display_width + 1)).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT)); + let l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL)); + let lineno_display_width = (1 + Math.log10(l1 | 1) | 0); + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [ [], [], [] ]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = (new Array(lineno_display_width + 1)).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { - offset += loc.first_column; + offset += loc.first_column; - len = Math.max( - 2, - ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 - ); + len = Math.max( + 2, + ((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1 + ); } else if (lno === loc.last_line) { - len = Math.max(2, loc.last_column + 1); + len = Math.max(2, loc.last_column + 1); } else if (lno > loc.first_line && lno < loc.last_line) { - len = Math.max(2, line.length + 1); + len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); - rv += '\n' + errpfx + lead + mark; + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); + rv += '\n' + errpfx + lead + mark; - nli = 1; + nli = 1; } else if (lno < loc.first_line) { - nli = 0; + nli = 0; } else if (lno > loc.last_line) { - nli = 2; + nli = 2; } if (line.trim().length > 0) { - nonempty_line_indexes[nli].push(index); + nonempty_line_indexes[nli].push(index); } rv = rv.replace(/\t/g, ' '); @@ -904,13 +871,13 @@ var lexer = { // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; + let intermediate_line = (new Array(lineno_display_width + 1)).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + (new Array(lineno_display_width + 1)).join('-') + ' (---------------)'; } @@ -932,15 +899,13 @@ var lexer = { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - "use strict"; - - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; if (dc <= 1) { @@ -952,8 +917,8 @@ var lexer = { rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')'; } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; } else { @@ -982,13 +947,7 @@ var lexer = { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - "use strict"; - - var token, - lines, - backup, - match_str, - match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -1017,10 +976,10 @@ var lexer = { }; } - match_str = match[0]; - match_str_len = match_str.length; + let match_str = match[0]; + let match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -1048,7 +1007,7 @@ var lexer = { // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -1059,7 +1018,7 @@ var lexer = { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } this.__currentRuleSet__ = null; @@ -1081,8 +1040,6 @@ var lexer = { * @this {RegExpLexer} */ next: function lexer_next() { - "use strict"; - if (this.done) { this.clear(); return this.EOF; @@ -1091,17 +1048,13 @@ var lexer = { this.done = true; } - var token, - match, - tempMatch, - index; if (!this._more) { if (!this._clear_state) { this._clear_state = 1; } this.clear(); } - 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 @@ -1111,67 +1064,75 @@ var lexer = { // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; + + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; + + if (match) { + let token = this.test_match(match, rule_ids[index]); + if (token !== false) { + return token; + } + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; } + if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; - token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); + let token = (this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR); if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us // by moving forward at least one character at a time IFF the (user-specified?) `parseError()` @@ -1198,9 +1159,7 @@ var lexer = { * @this {RegExpLexer} */ lex: function lexer_lex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1243,24 +1202,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1280,9 +1239,7 @@ var lexer = { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - "use strict"; - - var r; + let r; //this._clear_state = 0; @@ -1292,24 +1249,24 @@ var lexer = { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -1317,7 +1274,7 @@ var lexer = { this._clear_state = 0; } - + return r; }, @@ -1330,9 +1287,7 @@ var lexer = { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - "use strict"; - - var rv = { + const rv = { fastLex: !( typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || @@ -1340,7 +1295,7 @@ var lexer = { (this.yy && typeof this.yy.post_lex === 'function') || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function' - ) && typeof this.fastLex === 'function', + ) && typeof this.fastLex === 'function' }; return rv; }, @@ -1355,8 +1310,6 @@ var lexer = { * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - "use strict"; - return this.pushState(condition); }, @@ -1368,8 +1321,6 @@ var lexer = { * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - "use strict"; - this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -1383,15 +1334,12 @@ var lexer = { * @this {RegExpLexer} */ popState: function lexer_popState() { - "use strict"; - - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + return this.conditionStack[0]; }, /** @@ -1403,14 +1351,11 @@ var lexer = { * @this {RegExpLexer} */ topState: function lexer_topState(n) { - "use strict"; - n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + return 'INITIAL'; }, /** @@ -1421,16 +1366,14 @@ var lexer = { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - "use strict"; - - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; } else { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -1440,8 +1383,6 @@ var lexer = { * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - "use strict"; - return this.conditionStack.length; }, options: { @@ -1555,10 +1496,10 @@ break; }; ; - //============================================================================= - // JISON-LEX OPTIONS: + //============================================================================= + // JISON-LEX OPTIONS: - { + { lexerActionsUseYYLENG: '???', lexerActionsUseYYLINENO: '???', lexerActionsUseYYTEXT: '???', @@ -1868,4 +1809,4 @@ function log(msg) {}`, is_custom_lexer: false, } - \ No newline at end of file + \ No newline at end of file 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 c319fc806..e54fa4c0b 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,11 +7,11 @@ name: 'ReferenceError', message: 'log is not defined', stack: `ReferenceError: log is not defined - at Object.lexer__performAction [as performAction] (/regexp-lexer-cjs-es5.js:3508:37), :1543:16) - at Object.lexer_test_match [as test_match] (/regexp-lexer-cjs-es5.js:3508:37), :1128:36) - at Object.lexer_next [as next] (/regexp-lexer-cjs-es5.js:3508:37), :1229:26) - at Object.lexer_lex [as lex] (/regexp-lexer-cjs-es5.js:3508:37), :1305:22) - at Context.testEachLexerExample (/regexplexer.js:3528:27) + 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 Context.testEachLexerExample (/regexplexer.js:3650:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) diff --git a/packages/lex-parser/dist/lex-parser-cjs-es5.js b/packages/lex-parser/dist/lex-parser-cjs-es5.js index 63b2b8f5f..780cf00f3 100644 --- a/packages/lex-parser/dist/lex-parser-cjs-es5.js +++ b/packages/lex-parser/dist/lex-parser-cjs-es5.js @@ -8,6 +8,8 @@ var fs = require('fs'); var path$1 = require('path'); +var mkdirp = require('mkdirp'); + var recast = require('recast'); var babel = require('@babel/core'); @@ -28,9 +30,11 @@ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); +var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); + var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); -var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); // Return TRUE if `src` starts with `searchString`. +var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); // Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { @@ -53,18 +57,18 @@ function rmCommonWS(strings, ...values) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -82,18 +86,20 @@ function rmCommonWS(strings, ...values) { // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); // Done removing common indentation. - // + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; // only correct indentation at start of line, i.e. only check for + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -102,17 +108,20 @@ function rmCommonWS(strings, ...values) { } // now merge everything to construct the template result: - var rv = []; + { + let rv = []; + let i = 0; - for (var i = 0, len = values.length; i < len; i++) { - rv.push(src[i].join('\n')); - rv.push(values[i]); - } // the last value is always followed by a last template string partial: + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + rv.push(src[i].join('\n')); + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` /** @public */ @@ -123,8 +132,8 @@ function camelCase(s) { return s.replace(/^\w/, function (match) { return match.toLowerCase(); }).replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; @@ -132,18 +141,30 @@ function camelCase(s) { return rv; }); -} // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers +} // https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words + + +const reservedWords = (list => { + let rv = new Set(); + + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + + return rv; +})(['await', 'break', 'case', 'catch', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'enum', 'export', 'extends', 'finally', 'for', 'function', 'if', 'implements', 'import', 'in', 'instanceof', 'interface', 'new', 'package', 'private', 'protected', 'public', 'return', 'super', 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'yield']); // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -155,6 +176,12 @@ function mkIdentifier(s) { .replace(/^[^\w_]/, '_') // do not accept numerics at the leading position, despite those matching regex `\w`: .replace(/^\d/, '_').replace(/[^\w\d_]/g, '_') // and only accept multiple (double, not triple) underscores at start or end of identifier name: .replace(/^__+/, '#').replace(/__+$/, '#').replace(/_+/g, '_').replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + + return rv; } // Check if the start of the given input matches a regex expression. // Return the length of the regex expression or -1 if none was found. @@ -164,13 +191,13 @@ function mkIdentifier(s) { function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; @@ -190,13 +217,11 @@ function scanRegExp(s) { if (ch === ']') { classMarker = false; } - } else { - if (ch === '/') { - terminated = true; - break; - } else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } @@ -220,12 +245,12 @@ function isLineTerminator(cp) { function isLegalIdentifierInput(s) { - s = '' + s; // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + s = '' + s; // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s.replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -233,14 +258,14 @@ function isLegalIdentifierInput(s) { return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = s.indexOf('\'') >= 0; - var dq = s.indexOf('"') >= 0; + let sq = s.indexOf('\'') >= 0; + let dq = s.indexOf('"') >= 0; if (sq && dq) { s = s.replace(/"/g, '\\"'); @@ -268,48 +293,104 @@ function chkBugger(src) { function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); +} + +function convertExceptionToObject(ex) { + if (!ex) return ex; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + + let rv = Object.assign({}, ex); // - Set up the default fields which should ALWAYS be present: + + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + + if (Array.isArray(ex.errors)) { + rv.errors = []; + + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + + return rv; +} + +function find_suitable_app_dump_path() { + return process.cwd().replace(/\\/g, '/').replace(/\/node_modules\/.*$/, m => '/___nm___/').replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map(d => d.charAt(0).toUpperCase()).join('_')); } // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [options.outfile ? path__default['default'].dirname(options.outfile) : null, options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname).replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + const dumpPaths = [options.outfile ? path__default['default'].dirname(options.outfile) : null, options.inputPath, find_suitable_app_dump_path()]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname).replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; + } // generate a stacktrace for the dump no matter what: + + + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } } err_id = err_id || 'XXX'; - var ts = new Date(); - var tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + '' + pad(ts.getUTCMinutes()) + '' + pad(ts.getUTCSeconds()) + '.' + pad(ts.getUTCMilliseconds(), 3) + 'Z'; + err_id = err_id.replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + '' + pad(ts.getUTCMinutes()) + '' + pad(ts.getUTCSeconds()) + '.' + pad(ts.getUTCMilliseconds(), 3) + 'Z'; dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); - let dump = { + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); + const dump = { errname, err_id, options, - ex + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); // make sure each line is a comment line: + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]' + }); // make sure each line is a comment line: d = d.split('\n').map(l => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -319,7 +400,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -350,25 +431,40 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; } - const debug = 0; - var p; + const debug = options.debug || 0; + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); + } + + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + if (debug > 1) console.log('exec-and-diagnose options:', options); + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } @@ -381,9 +477,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t return p; } -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject }; // assert__default['default'](recast__default['default']); //var types = recast.types; @@ -397,18 +494,18 @@ assert__default['default'](recast__default['default']); //var types = recast.typ // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! -const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: -const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; // Determine which Unicode NonAsciiIdentifierStart characters +const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; // Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -418,37 +515,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -456,30 +553,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -490,58 +587,58 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -586,27 +683,27 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: - const typeIdCharSets = ["ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", + const typeIdCharSets = ['ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ"]; //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ']; //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -617,18 +714,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { hash[i] = (hash[i] || 0) + 1; } // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -639,56 +736,56 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); @@ -696,7 +793,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { for (let i = 0, l = typeIdCharSets.length; i < l; i++) { typeIdChar[i] = pickChar(typeIdCharSets[i]); - } // produce a function set for encoding and decoding content, + } // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: @@ -704,57 +801,57 @@ function generateMapper4JisonGrammarIdentifiers(input) { return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction @@ -765,10 +862,10 @@ function generateMapper4JisonGrammarIdentifiers(input) { re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -851,10 +948,10 @@ function generateMapper4JisonGrammarIdentifiers(input) { re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -863,19 +960,19 @@ function generateMapper4JisonGrammarIdentifiers(input) { // p1 is only serving as lookbehind emulation switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -917,7 +1014,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { function parseCodeChunkToAST(src, options) { src = src.replace(/@/g, '\uFFDA').replace(/#/g, '\uFFDB'); - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } @@ -932,13 +1029,13 @@ function compileCodeToES5(src, options) { sourceRoot: '.', sourceType: 'module', babelrc: false, - ignore: ["node_modules/**/*.js"], + ignore: ['node_modules/**/*.js'], compact: false, retainLines: false, - presets: [["@babel/preset-env", { + presets: [['@babel/preset-env', { targets: { - browsers: ["last 2 versions"], - node: "8.0" + browsers: ['last 2 versions'], + node: '8.0' } }]] }, options); @@ -946,7 +1043,7 @@ function compileCodeToES5(src, options) { } function prettyPrintAST(ast, options) { - var options = options || {}; + options = options || {}; const defaultOptions = { tabWidth: 2, quote: 'single', @@ -956,7 +1053,7 @@ function prettyPrintAST(ast, options) { reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -969,16 +1066,16 @@ function prettyPrintAST(ast, options) { .replace(/\uFFDA/g, '@').replace(/\uFFDB/g, '#'); return new_src; } // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; } @@ -987,19 +1084,19 @@ function checkActionBlock(src, yylloc, options) { } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } // The rough-and-ready preprocessor for any action code block: // this one trims off any surplus whitespace and removes any // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1007,7 +1104,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1016,16 +1113,16 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { - var s = src.trim(); // remove outermost set of braces UNLESS there's + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated // code analyzer to simplify the code! @@ -1090,7 +1187,7 @@ function chkBugger$1(src) { function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1098,25 +1195,25 @@ function printFunctionSourceCode(f) { const funcRe = /^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/; const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/; /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; // Also cope with Arrow Functions (and inline those as well?). + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); @@ -1136,8 +1233,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1148,7 +1245,7 @@ function printFunctionSourceCodeContainer(f) { action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } @@ -1163,14 +1260,14 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { printFunctionSourceCode, printFunctionSourceCodeContainer -}; // -// -// +}; // +// +// function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } // // Helper library for safe code execution/compilation @@ -1193,7 +1290,7 @@ function detectIstanbulGlobal() { function checkRegExp(re_src, re_flags, XRegExp) { - var re; // were we fed a RegExp object or a string? + let re; // were we fed a RegExp object or a string? if (re_src && typeof re_src.source === 'string' && typeof re_src.flags === 'string' && typeof re_src.toString === 'function' && typeof re_src.test === 'function' && typeof re_src.exec === 'function') { // we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member @@ -1237,7 +1334,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; // were we fed a RegExp object or a string? + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src && typeof re_src.source === 'string' && typeof re_src.flags === 'string' && typeof re_src.toString === 'function' && typeof re_src.test === 'function' && typeof re_src.exec === 'function') { // we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member @@ -1285,11 +1382,11 @@ var reHelpers = { checkRegExp: checkRegExp, getRegExpInfo: getRegExpInfo }; -var cycleref = []; -var cyclerefpath = []; -var linkref = []; -var linkrefpath = []; -var path = []; +let cycleref = []; +let cyclerefpath = []; +let linkref = []; +let linkrefpath = []; +let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1297,7 +1394,7 @@ function shallow_copy(src) { return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; @@ -1305,7 +1402,7 @@ function shallow_copy(src) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1319,12 +1416,12 @@ function shallow_copy(src) { function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1338,9 +1435,9 @@ function shallow_copy_and_strip_depth(src, parentKey) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; @@ -1355,12 +1452,44 @@ function shallow_copy_and_strip_depth(src, parentKey) { } return src; -} +} // strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. + function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: - msg = msg.replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)').replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + msg = msg.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; +} // strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. + + +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + + let keys = Object.keys(obj); + + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + + return obj; } function trim_array_tail(arr) { @@ -1377,7 +1506,7 @@ function trim_array_tail(arr) { function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; @@ -1404,11 +1533,11 @@ function treat_value_stack(v) { } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1555,7 +1684,7 @@ function treat_error_report_info(e) { function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. @@ -1581,7 +1710,7 @@ function treat_object(e) { return e; } // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. @@ -1613,10 +1742,12 @@ var helpers = { dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, compileCodeToES5: parse2AST.compileCodeToES5, @@ -1646,10 +1777,10 @@ function JisonParserError(msg, hash) { value: msg }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -1682,11 +1813,11 @@ JisonParserError.prototype.constructor = JisonParserError; JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; + let rv = []; + let p = s.pop; + let r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + for (let i = 0, l = p.length; i < l; i++) { rv.push([p[i], r[i]]); } @@ -1695,12 +1826,12 @@ function bp(s) { function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; + let rv = {}; + let d = s.idx; + let g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } @@ -1709,20 +1840,20 @@ function bda(s) { function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: @@ -1750,7 +1881,7 @@ function bt(s) { function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -1768,10 +1899,10 @@ function c(i, l) { function u(a) { - var rv = []; + let rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; // Is this entry a helper function? + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -1784,7 +1915,7 @@ function u(a) { return rv; } -var parser = { +let parser = { // Code Generator Information Report // --------------------------------- // @@ -2048,9 +2179,9 @@ var parser = { // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; + const s = this.symbols_; - for (var key in s) { + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2069,7 +2200,7 @@ var parser = { return 'end of input'; } - var id = this.getSymbolName(symbol); + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); @@ -2086,20 +2217,20 @@ var parser = { // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { return [this.state_descriptions_[state]]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); @@ -2119,9 +2250,9 @@ var parser = { , yysp, yyvstack, yylstack) { /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; const OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME = 0x0004; @@ -2131,16 +2262,16 @@ var parser = { switch (yystate) { case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; - this._$ = yylstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -2169,8 +2300,8 @@ var parser = { case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { @@ -2187,9 +2318,9 @@ var parser = { case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` There's probably an error in one or more of your lexer regex rules. @@ -2214,8 +2345,8 @@ var parser = { case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { rules: yyvstack[yysp] @@ -2224,9 +2355,9 @@ var parser = { case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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 probably an error in one or more of your lexer regex rules. @@ -2252,8 +2383,8 @@ var parser = { case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { rules: [] @@ -2262,9 +2393,9 @@ var parser = { case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; if (!yy.options) yy.options = {}; @@ -2303,8 +2434,8 @@ var parser = { case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -2372,8 +2503,8 @@ var parser = { case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { macros: {}, @@ -2391,8 +2522,8 @@ var parser = { case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` // macros here: @@ -2425,9 +2556,9 @@ var parser = { case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` ill defined macro definition. @@ -2442,8 +2573,8 @@ var parser = { case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -2460,9 +2591,9 @@ var parser = { case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` ill defined '%s' inclusive lexer condition set specification. @@ -2477,8 +2608,8 @@ var parser = { case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -2495,9 +2626,9 @@ var parser = { case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` ill defined '%x' exclusive lexer condition set specification. @@ -2512,8 +2643,8 @@ var parser = { case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -2540,8 +2671,8 @@ var parser = { case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. @@ -2550,8 +2681,8 @@ var parser = { case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -2569,8 +2700,8 @@ var parser = { case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -2592,8 +2723,8 @@ var parser = { case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -2606,9 +2737,9 @@ var parser = { case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` ill defined %options line. @@ -2623,8 +2754,8 @@ var parser = { case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { type: 'unknown', @@ -2634,8 +2765,8 @@ var parser = { case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -2674,9 +2805,9 @@ var parser = { case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` %import name or source filename missing maybe? @@ -2694,8 +2825,8 @@ var parser = { case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 5, yysp); // END of default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -2746,9 +2877,9 @@ var parser = { case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + 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 : ''; @@ -2770,9 +2901,9 @@ var parser = { case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` Each '%code' initialization code section must be qualified by a name, @@ -2790,9 +2921,9 @@ var parser = { case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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, @@ -2814,9 +2945,9 @@ var parser = { case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` illegal input in the lexer spec definitions section. @@ -2835,9 +2966,9 @@ var parser = { case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = yyvstack[yysp]; @@ -2848,9 +2979,9 @@ var parser = { case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; yy.__options_category_description__ = yyvstack[yysp]; @@ -2858,9 +2989,9 @@ var parser = { case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; yy.__options_category_description__ = yyvstack[yysp]; @@ -2868,9 +2999,9 @@ var parser = { case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = 'the inclusive lexer start conditions set (%s)'; @@ -2878,9 +3009,9 @@ var parser = { case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = 'the exclusive lexer start conditions set (%x)'; @@ -2888,9 +3019,9 @@ var parser = { case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; yy.__options_category_description__ = 'the <...> delimited set of lexer start conditions'; @@ -2898,9 +3029,9 @@ var parser = { case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; yy.__options_category_description__ = 'the lexer rules definition section'; @@ -2908,9 +3039,9 @@ var parser = { case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; yy.__options_category_description__ = 'the lexer epilogue section'; @@ -2918,24 +3049,24 @@ var parser = { case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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].concat(yyvstack[yysp]); break; case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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].concat([yyvstack[yysp]]); break; case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -2959,8 +3090,8 @@ var parser = { case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. @@ -2969,8 +3100,8 @@ var parser = { case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -2988,8 +3119,8 @@ var parser = { case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3048,8 +3179,8 @@ var parser = { case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3068,16 +3199,16 @@ var parser = { case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (yyvstack[yysp - 1]) { yyvstack[yysp].unshift(yyvstack[yysp - 1]); @@ -3088,8 +3219,8 @@ var parser = { case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (yyvstack[yysp - 3]) { yyvstack[yysp - 1].forEach(function (d) { @@ -3102,9 +3233,9 @@ var parser = { case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + 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$1` Seems you made a mistake while specifying one of the lexer rules inside @@ -3122,9 +3253,9 @@ var parser = { case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` Seems you did not correctly bracket a lexer rules set inside @@ -3142,9 +3273,9 @@ var parser = { case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` Seems you did not correctly bracket a lexer rules set inside @@ -3162,8 +3293,8 @@ var parser = { case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push(yyvstack[yysp]); @@ -3174,8 +3305,8 @@ var parser = { case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -3194,8 +3325,8 @@ var parser = { case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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. @@ -3235,8 +3366,8 @@ var parser = { case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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` @@ -3258,8 +3389,8 @@ var parser = { case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO: REWRITE this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3283,8 +3414,8 @@ var parser = { case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO: REWRITE this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3327,8 +3458,8 @@ var parser = { case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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], yyvstack[yysp]]; yyparser.yyError(rmCommonWS$1` @@ -3356,25 +3487,25 @@ var parser = { case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + yyvstack[yysp]; break; case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '\n\n' + yyvstack[yysp] + '\n\n'; break; case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` You may place the '%include' instruction only at the start/front of a line. @@ -3386,9 +3517,9 @@ var parser = { case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` Missing curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: '{ ... }'. @@ -3400,9 +3531,9 @@ var parser = { case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` Too many curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: '{ ... }'. @@ -3414,9 +3545,9 @@ var parser = { case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` Unterminated string constant in lexer rule action block. @@ -3434,16 +3565,16 @@ var parser = { case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -3477,9 +3608,9 @@ var parser = { case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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) { @@ -3500,8 +3631,8 @@ var parser = { case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3581,56 +3712,56 @@ var parser = { case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; break; case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '|'; break; case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; break; case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '|'; break; case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + ')'; break; case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + ')'; break; @@ -3640,9 +3771,9 @@ var parser = { case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` Seems you did not correctly bracket a lex rule regex part in '(...)' braces. @@ -3657,40 +3788,40 @@ var parser = { case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '+'; break; case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '*'; break; case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '?'; break; case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + ')'; break; case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + ')'; break; @@ -3712,57 +3843,57 @@ var parser = { case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '.'; break; case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '^'; break; case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '$'; break; case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); break; case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + yyvstack[yysp]; break; case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` Seems you did not correctly bracket a lex rule regex set in '[...]' brackets. @@ -3777,8 +3908,8 @@ var parser = { case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) && yyvstack[yysp].toUpperCase() !== yyvstack[yysp]) { // treat this as part of an XRegExp `\p{...}` Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories @@ -3792,8 +3923,8 @@ var parser = { case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -3803,8 +3934,8 @@ var parser = { case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -3812,8 +3943,8 @@ var parser = { case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -3847,8 +3978,8 @@ var parser = { case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -3866,24 +3997,24 @@ var parser = { case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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], true]; break; case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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_VALUE) { @@ -3900,9 +4031,9 @@ var parser = { case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... yyparser.yyError(rmCommonWS$1` @@ -3918,9 +4049,9 @@ var parser = { case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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)'; @@ -3941,8 +4072,8 @@ var parser = { case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -3976,8 +4107,8 @@ var parser = { case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -4004,32 +4135,32 @@ var parser = { case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = parseValue(yyvstack[yysp]); break; case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = ''; break; case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4051,9 +4182,9 @@ var parser = { case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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. @@ -4068,8 +4199,8 @@ var parser = { case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$1` @@ -4086,8 +4217,8 @@ var parser = { case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4112,8 +4243,8 @@ var parser = { case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -4131,8 +4262,8 @@ var parser = { case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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. @@ -4141,8 +4272,8 @@ var parser = { case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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]; @@ -4200,9 +4331,9 @@ var parser = { case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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. @@ -4248,32 +4379,32 @@ var parser = { } }, parse: function parse(input) { - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) - var vstack = new Array(128); // semantic value stack + let vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack + let lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks - var yyloc; - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) + let yyloc; + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = this.options.errorRecoveryTokenDiscardCount | 0 || 3; - var NO_ACTION = [0, 189 + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = this.options.errorRecoveryTokenDiscardCount | 0 || 3; + const NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */ ]; - var lexer; + let lexer; if (this.__lexer__) { lexer = this.__lexer__; @@ -4281,7 +4412,7 @@ var parser = { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -4289,20 +4420,14 @@ var parser = { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = typeof assert !== 'function' ? function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : assert; this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -4330,18 +4455,19 @@ var parser = { return src.slice(); } - var dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; @@ -4353,21 +4479,19 @@ var parser = { function shallow_copy_noclobber(dst, src) { const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - var rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -4393,14 +4517,14 @@ var parser = { this.yyError = function yyError(str /*, ...args */ ) { - var error_rule_depth = this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1; - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, error_rule_depth >= 0); // append to the old one? + let error_rule_depth = this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1; + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, error_rule_depth >= 0); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; @@ -4418,7 +4542,7 @@ var parser = { } // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; @@ -4457,10 +4581,10 @@ var parser = { this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -4520,8 +4644,8 @@ var parser = { // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -4530,8 +4654,8 @@ var parser = { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -4562,16 +4686,16 @@ var parser = { this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; // rules: + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { @@ -4583,7 +4707,7 @@ var parser = { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { @@ -4597,7 +4721,7 @@ var parser = { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { @@ -4611,30 +4735,30 @@ var parser = { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; - } + return null; + } // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + + rv = this.copy_yylloc(l2); return rv; + } // shallow-copy L1, then adjust first col/row 1 column past the end. + + + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; } + + return rv; } if (!l1) { @@ -4643,7 +4767,7 @@ var parser = { } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... @@ -4663,7 +4787,7 @@ var parser = { this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -4672,10 +4796,10 @@ var parser = { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -4683,7 +4807,7 @@ var parser = { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential // ref cycle via userland code manipulations. @@ -4693,9 +4817,15 @@ var parser = { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - var rec = !!this.recoverable; - - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -4713,7 +4843,7 @@ var parser = { this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - var rv = shallow_copy(p); // remove the large parts which can only cause cyclic references + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. delete rv.sharedState_yy; @@ -4775,11 +4905,15 @@ var parser = { // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty - } + { + let i; + + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty + } - rv.base_pointer = i; - rv.info_stack_pointer = i; + rv.base_pointer = i; + rv.info_stack_pointer = i; + } rv.root_failure_pointer = rv.stack_pointer; // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_recovery_infos.push(rv); @@ -4788,7 +4922,7 @@ var parser = { }; function getNonTerminalFromCode(symbol) { - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; @@ -4798,21 +4932,21 @@ var parser = { } function stdLex() { - var token = lexer.lex(); // if token isn't its numeric value, convert + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -4822,21 +4956,21 @@ var parser = { } function fastLex() { - var token = lexer.fastLex(); // if token isn't its numeric value, convert + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -4845,27 +4979,27 @@ var parser = { return token || EOF; } - var lex = stdLex; - var state, action, r, t; - var yyval = { + let lex = stdLex; + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; // Return the rule stack depth where the nearest error rule can be found. + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - var stack_probe = sp - 1; - var depth = 0; // try to recover from error + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { // check for error recovery rule in this state - var t = table[state] && table[state][TERROR] || NO_ACTION; + const t = table[state] && table[state][TERROR] || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: @@ -4919,7 +5053,7 @@ var parser = { // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; @@ -4967,10 +5101,10 @@ var parser = { if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = this.describeSymbol(symbol) || symbol; - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = this.describeSymbol(symbol) || symbol; + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -5013,7 +5147,7 @@ var parser = { } } - var esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -5030,11 +5164,11 @@ var parser = { if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; // Report error + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { errStr = 'Parsing halted on line ' + (lexer.yylineno + 1) + ' while starting to recover from another error'; @@ -5085,8 +5219,8 @@ var parser = { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -5105,7 +5239,8 @@ var parser = { yyval.$ = recoveringErrorInfo; yyval._$ = undefined; yyrulelen = error_rule_depth; - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + let combineState = NO_ACTION[1]; + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -5115,7 +5250,7 @@ var parser = { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -5162,10 +5297,10 @@ var parser = { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack @@ -5197,7 +5332,7 @@ var parser = { // and take it from there! if (!action) { - ASSERT(recoveringErrorInfo, "line 1087"); // Prep state variables so that upon breaking out of + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` // statement in the outer "fast parse loop" we redo // the exact same state table lookup as the one above @@ -5232,12 +5367,12 @@ var parser = { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -5247,7 +5382,7 @@ var parser = { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; @@ -5279,7 +5414,7 @@ var parser = { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; // read action for current state and first input @@ -5309,7 +5444,7 @@ var parser = { // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; @@ -5325,18 +5460,18 @@ var parser = { r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', nonterminal: currentNonterminal, @@ -5369,15 +5504,17 @@ var parser = { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -5431,7 +5568,7 @@ var parser = { // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; @@ -5473,7 +5610,7 @@ var parser = { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; @@ -5489,9 +5626,9 @@ var parser = { ++sp; symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc = this.copy_yylloc(lexer.yylloc); @@ -5499,9 +5636,9 @@ var parser = { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... @@ -5509,18 +5646,18 @@ var parser = { r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', nonterminal: currentNonterminal, @@ -5549,15 +5686,17 @@ var parser = { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -5884,10 +6023,10 @@ var lexer = function () { value: msg }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -5918,7 +6057,7 @@ var lexer = function () { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- // @@ -6020,7 +6159,7 @@ var lexer = function () { if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -6028,7 +6167,7 @@ var lexer = function () { msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -6042,7 +6181,7 @@ var lexer = function () { /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... @@ -6066,9 +6205,13 @@ var lexer = function () { * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { - var rec = !!this.recoverable; + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -6114,15 +6257,15 @@ var lexer = function () { yyerror: function yyError(str /*, ...args */ ) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -6150,8 +6293,8 @@ var lexer = function () { // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -6178,7 +6321,7 @@ var lexer = function () { this.matches = false; this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, @@ -6201,7 +6344,7 @@ var lexer = function () { if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? @@ -6212,18 +6355,18 @@ var lexer = function () { } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -6313,7 +6456,7 @@ var lexer = function () { * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -6344,7 +6487,7 @@ var lexer = function () { this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -6354,14 +6497,14 @@ var lexer = function () { // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -6395,8 +6538,8 @@ var lexer = function () { * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -6427,8 +6570,8 @@ var lexer = function () { // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -6447,9 +6590,9 @@ var lexer = function () { /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -6459,8 +6602,8 @@ var lexer = function () { * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -6493,13 +6636,13 @@ var lexer = function () { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; } @@ -6535,17 +6678,27 @@ var lexer = function () { * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) maxSize = Infinity;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substr` anticipation: treat \r\n as a single character and take a little + let past = this.matched.substring(0, this.matched.length - this.match.length); + + if (maxSize < 0) { + maxSize = Infinity; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, // do add an ellipsis prefix... @@ -6558,8 +6711,8 @@ var lexer = function () { }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -6585,27 +6738,37 @@ var lexer = function () { * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) maxSize = next.length + source.length;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substring` anticipation: treat \r\n as a single character and take a little + let next = this.match; + let source = this._input || ''; + + if (maxSize < 0) { + maxSize = next.length + source.length; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + if (next.length < maxSize * 2 + 2) { next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8 } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -6626,8 +6789,8 @@ var lexer = function () { * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -6649,7 +6812,7 @@ var lexer = function () { * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -6794,20 +6957,20 @@ var lexer = function () { const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -6818,11 +6981,11 @@ var lexer = function () { len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -6840,13 +7003,13 @@ var lexer = function () { }); // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -6870,13 +7033,13 @@ var lexer = function () { * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -6891,8 +7054,8 @@ var lexer = function () { } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -6923,7 +7086,7 @@ var lexer = function () { * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -6951,9 +7114,9 @@ var lexer = function () { }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -6979,7 +7142,7 @@ var lexer = function () { // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */ ); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -6992,7 +7155,7 @@ var lexer = function () { return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -7025,8 +7188,6 @@ var lexer = function () { this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -7035,7 +7196,7 @@ var lexer = function () { this.clear(); } - 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. @@ -7046,75 +7207,81 @@ var lexer = function () { // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; // 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! + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + for (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + if (token !== false) { + return token; + } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -7139,7 +7306,7 @@ var lexer = function () { * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; //this._clear_state = 0; + let r; //this._clear_state = 0; if (!this._more) { if (!this._clear_state) { @@ -7185,24 +7352,24 @@ var lexer = function () { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -7221,7 +7388,7 @@ var lexer = function () { * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; //this._clear_state = 0; + let r; //this._clear_state = 0; while (!r) { r = this.next(); @@ -7229,24 +7396,24 @@ var lexer = function () { if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -7266,7 +7433,7 @@ var lexer = function () { * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; return rv; @@ -7305,14 +7472,14 @@ var lexer = function () { * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -7328,9 +7495,9 @@ var lexer = function () { if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -7341,8 +7508,8 @@ var lexer = function () { * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -7350,7 +7517,7 @@ var lexer = function () { state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** diff --git a/packages/lex-parser/dist/lex-parser-cjs.js b/packages/lex-parser/dist/lex-parser-cjs.js index 1084ae521..19f3d14df 100644 --- a/packages/lex-parser/dist/lex-parser-cjs.js +++ b/packages/lex-parser/dist/lex-parser-cjs.js @@ -4,6 +4,7 @@ var XRegExp = require('@gerhobbelt/xregexp'); var JSON5 = require('@gerhobbelt/json5'); var fs = require('fs'); var path$1 = require('path'); +var mkdirp = require('mkdirp'); var recast = require('recast'); var babel = require('@babel/core'); var assert$1 = require('assert'); @@ -14,10 +15,11 @@ var XRegExp__default = /*#__PURE__*/_interopDefaultLegacy(XRegExp); var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); +var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); -// Return TRUE if `src` starts with `searchString`. +// Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -40,19 +42,19 @@ function rmCommonWS(strings, ...values) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -71,19 +73,21 @@ function rmCommonWS(strings, ...values) { // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -92,16 +96,19 @@ function rmCommonWS(strings, ...values) { } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -112,27 +119,79 @@ function camelCase(s) { return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } +// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; +})([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' +]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -150,6 +209,11 @@ function mkIdentifier(s) { .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -158,13 +222,13 @@ function mkIdentifier(s) { function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -175,23 +239,17 @@ function scanRegExp(s) { break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -214,34 +272,33 @@ function isLineTerminator(cp) { /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -264,28 +321,76 @@ function chkBugger(src) { // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } +function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; +} + + +function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); +} + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -296,27 +401,37 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -326,7 +441,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -334,7 +449,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -360,27 +475,43 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -393,9 +524,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -417,22 +549,22 @@ assert__default['default'](recast__default['default']); // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; -// Determine which Unicode NonAsciiIdentifierStart characters +// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -440,40 +572,40 @@ const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -481,30 +613,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -515,59 +647,59 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -609,38 +741,38 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -652,18 +784,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -674,56 +806,56 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -731,97 +863,97 @@ function generateMapper4JisonGrammarIdentifiers(input) { typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -829,7 +961,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -842,7 +974,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -855,7 +987,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -868,7 +1000,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -887,37 +1019,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -949,7 +1081,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -966,37 +1098,37 @@ function parseCodeChunkToAST(src, options) { .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return babel.transformSync(src, options); // => { code, map, ast } @@ -1004,8 +1136,8 @@ function compileCodeToES5(src, options) { function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1014,7 +1146,7 @@ function prettyPrintAST(ast, options) { // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1037,25 +1169,25 @@ function prettyPrintAST(ast, options) { // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1066,9 +1198,9 @@ function checkActionBlock(src, yylloc, options) { // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1076,7 +1208,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1085,14 +1217,14 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1146,7 +1278,7 @@ var parse2AST = { trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1160,7 +1292,7 @@ function chkBugger$1(src) { /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1172,24 +1304,24 @@ const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?: /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1206,8 +1338,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1218,14 +1350,14 @@ function printFunctionSourceCodeContainer(f) { action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1236,17 +1368,17 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; -// -// -// +// +// +// function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1272,7 +1404,7 @@ function detectIstanbulGlobal() { // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1320,7 +1452,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1383,13 +1515,13 @@ var reHelpers = { getRegExpInfo: getRegExpInfo }; -var cycleref = []; -var cyclerefpath = []; +let cycleref = []; +let cyclerefpath = []; -var linkref = []; -var linkrefpath = []; +let linkref = []; +let linkrefpath = []; -var path = []; +let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1397,14 +1529,14 @@ function shallow_copy(src) { return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1417,11 +1549,11 @@ function shallow_copy(src) { function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1434,9 +1566,9 @@ function shallow_copy_and_strip_depth(src, parentKey) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1451,16 +1583,52 @@ function shallow_copy_and_strip_depth(src, parentKey) { } +// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } +// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; +} + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1475,7 +1643,7 @@ function trim_array_tail(arr) { function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1501,10 +1669,10 @@ function treat_value_stack(v) { } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1602,7 +1770,7 @@ function treat_hash(h) { function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1619,7 +1787,7 @@ function treat_error_report_info(e) { path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1647,7 +1815,7 @@ function treat_error_report_info(e) { function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1663,7 +1831,7 @@ function treat_object(e) { linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1675,14 +1843,14 @@ function treat_object(e) { // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1692,7 +1860,7 @@ function trimErrorForTestReporting(e) { cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1706,12 +1874,14 @@ var helpers = { dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1726,7 +1896,7 @@ var helpers = { printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; // See also: @@ -1734,7 +1904,6 @@ var helpers = { // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1751,9 +1920,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -1786,10 +1955,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -1802,11 +1971,11 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -1816,18 +1985,18 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -1858,7 +2027,7 @@ JisonParserError.prototype.name = 'JisonParserError'; // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -1875,9 +2044,9 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -1890,7 +2059,7 @@ JisonParserError.prototype.name = 'JisonParserError'; } -var parser = { +let parser = { // Code Generator Information Report // --------------------------------- // @@ -2140,7 +2309,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2148,7 +2316,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2160,8 +2327,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2174,14 +2341,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2197,10 +2363,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2208,10 +2374,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2366,9 +2532,9 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -2380,18 +2546,18 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2421,9 +2587,9 @@ case 1: case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -2436,10 +2602,10 @@ case 2: case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2466,9 +2632,9 @@ case 3: case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -2477,10 +2643,10 @@ case 4: case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2508,9 +2674,9 @@ case 5: case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -2519,10 +2685,10 @@ case 6: case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -2561,9 +2727,9 @@ case 7: case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2628,9 +2794,9 @@ case 8: case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2645,9 +2811,9 @@ case 9: case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -2682,10 +2848,10 @@ case 10: case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2702,9 +2868,9 @@ case 11: case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2721,10 +2887,10 @@ case 12: case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2741,9 +2907,9 @@ case 13: case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2760,10 +2926,10 @@ case 14: case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2780,9 +2946,9 @@ case 15: case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -2806,9 +2972,9 @@ case 17: case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -2819,9 +2985,9 @@ case 132: case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2841,9 +3007,9 @@ case 18: case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2867,9 +3033,9 @@ case 19: case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2882,10 +3048,10 @@ case 20: case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2902,9 +3068,9 @@ case 21: case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2916,9 +3082,9 @@ case 22: case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -2958,10 +3124,10 @@ case 23: case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2981,9 +3147,9 @@ case 24: case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3033,10 +3199,10 @@ case 25: case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -3060,10 +3226,10 @@ case 26: case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3083,10 +3249,10 @@ case 27: case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3110,10 +3276,10 @@ case 28: case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3134,10 +3300,10 @@ case 29: case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3149,10 +3315,10 @@ case 31: case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3162,10 +3328,10 @@ case 33: case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3175,10 +3341,10 @@ case 32: case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3188,10 +3354,10 @@ case 34: case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3201,10 +3367,10 @@ case 35: case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -3214,10 +3380,10 @@ case 36: case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3227,10 +3393,10 @@ case 37: case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3240,9 +3406,9 @@ case 38: case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -3251,9 +3417,9 @@ case 39: case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -3262,9 +3428,9 @@ case 40: case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3286,9 +3452,9 @@ case 41: case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3299,9 +3465,9 @@ case 42: case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3321,9 +3487,9 @@ case 43: case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3377,9 +3543,9 @@ case 49: case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3399,9 +3565,9 @@ case 51: case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -3410,9 +3576,9 @@ case 58: case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -3424,9 +3590,9 @@ case 52: case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -3440,10 +3606,10 @@ case 53: case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3463,10 +3629,10 @@ case 54: case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3486,10 +3652,10 @@ case 55: case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3509,9 +3675,9 @@ case 56: case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3522,9 +3688,9 @@ case 59: case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3543,9 +3709,9 @@ case 60: case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -3586,9 +3752,9 @@ case 61: case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3612,9 +3778,9 @@ case 62: case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3640,9 +3806,9 @@ case 63: case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3687,9 +3853,9 @@ case 64: case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -3715,9 +3881,9 @@ case 106: case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -3726,9 +3892,9 @@ case 127: case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -3737,10 +3903,10 @@ case 67: case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3754,10 +3920,10 @@ case 68: case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3771,10 +3937,10 @@ case 69: case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3788,10 +3954,10 @@ case 70: case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3810,9 +3976,9 @@ case 72: case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -3821,9 +3987,9 @@ case 77: case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -3861,10 +4027,10 @@ case 73: case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -3888,9 +4054,9 @@ case 74: case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -3969,9 +4135,9 @@ case 110: case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -3980,9 +4146,9 @@ case 129: case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -3991,9 +4157,9 @@ case 78: case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -4002,9 +4168,9 @@ case 79: case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -4013,9 +4179,9 @@ case 80: case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -4024,9 +4190,9 @@ case 81: case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -4035,9 +4201,9 @@ case 85: case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -4048,10 +4214,10 @@ case 87: case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4068,9 +4234,9 @@ case 88: case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -4079,9 +4245,9 @@ case 89: case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -4090,9 +4256,9 @@ case 90: case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -4101,9 +4267,9 @@ case 91: case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -4112,9 +4278,9 @@ case 92: case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -4133,18 +4299,18 @@ case 107: case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -4153,9 +4319,9 @@ case 97: case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -4164,9 +4330,9 @@ case 98: case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -4175,9 +4341,9 @@ case 99: case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -4186,9 +4352,9 @@ case 102: case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -4197,10 +4363,10 @@ case 104: case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4217,9 +4383,9 @@ case 105: case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -4236,9 +4402,9 @@ case 109: case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -4250,9 +4416,9 @@ case 111: case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -4262,9 +4428,9 @@ case 112: case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4299,9 +4465,9 @@ case 113: case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4320,9 +4486,9 @@ case 114: case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -4331,9 +4497,9 @@ case 115: case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -4342,9 +4508,9 @@ case 116: case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4362,10 +4528,10 @@ case 117: case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -4383,10 +4549,10 @@ case 118: case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -4407,9 +4573,9 @@ case 119: case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4442,9 +4608,9 @@ case 120: case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4470,9 +4636,9 @@ case 121: case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5__default['default'].parse(yyvstack[yysp]); @@ -4481,9 +4647,9 @@ case 122: case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue(yyvstack[yysp]); @@ -4492,9 +4658,9 @@ case 123: case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4503,9 +4669,9 @@ case 124: case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -4526,10 +4692,10 @@ case 125: case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4546,9 +4712,9 @@ case 126: case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -4567,9 +4733,9 @@ case 128: case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4593,9 +4759,9 @@ case 130: case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -4615,9 +4781,9 @@ case 131: case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4628,9 +4794,9 @@ case 133: case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -4686,10 +4852,10 @@ case 134: case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6292,7 +6458,6 @@ defaultActions: bda({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -6309,38 +6474,34 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -6348,20 +6509,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -6383,7 +6542,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -6391,18 +6549,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -6410,24 +6569,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -6465,18 +6619,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -6497,7 +6648,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -6515,7 +6666,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -6528,7 +6678,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -6542,11 +6691,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -6600,8 +6748,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6609,8 +6757,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6642,19 +6790,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -6665,7 +6812,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -6678,7 +6825,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -6690,29 +6837,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -6720,7 +6865,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -6740,8 +6885,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -6750,10 +6894,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -6761,7 +6905,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -6772,9 +6916,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -6790,8 +6939,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -6860,11 +7008,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -6875,8 +7026,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -6885,21 +7035,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6909,21 +7058,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6932,28 +7080,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -6966,8 +7113,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -6990,8 +7136,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -7003,8 +7148,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -7021,8 +7165,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -7036,8 +7179,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -7051,7 +7193,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -7104,16 +7246,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -7147,9 +7286,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -7172,9 +7309,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -7201,17 +7336,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -7258,8 +7392,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -7271,8 +7405,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -7290,6 +7423,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -7298,7 +7432,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -7309,7 +7443,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -7369,10 +7503,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -7407,9 +7541,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -7422,7 +7554,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -7443,9 +7575,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7467,12 +7597,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -7481,7 +7611,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7522,7 +7652,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -7569,7 +7699,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -7587,21 +7717,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7635,14 +7763,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7652,6 +7781,7 @@ parse: function parse(input) { + } continue; // accept: @@ -7703,7 +7833,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -7719,9 +7849,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7750,7 +7878,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7767,8 +7895,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -7779,8 +7907,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -7792,21 +7920,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7837,14 +7963,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7854,6 +7981,7 @@ parse: function parse(input) { + } continue; // accept: @@ -7906,8 +8034,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -8168,7 +8295,6 @@ var lexer = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -8185,10 +8311,10 @@ var lexer = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -8220,7 +8346,7 @@ var lexer = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -8262,7 +8388,9 @@ var lexer = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -8348,7 +8476,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -8356,7 +8484,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -8369,7 +8497,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -8395,10 +8523,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -8421,7 +8552,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -8444,16 +8574,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -8475,7 +8605,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -8483,8 +8612,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -8513,7 +8642,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -8538,7 +8667,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -8550,17 +8679,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -8654,7 +8783,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -8675,7 +8804,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -8686,7 +8814,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -8697,15 +8825,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -8739,8 +8867,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -8773,9 +8901,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -8794,9 +8922,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -8806,8 +8934,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -8834,20 +8962,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -8887,17 +9014,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8906,7 +9035,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -8921,8 +9050,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -8948,24 +9077,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8976,7 +9107,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -8998,8 +9129,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -9021,8 +9152,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -9166,21 +9296,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -9195,11 +9325,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -9218,13 +9348,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -9248,13 +9378,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -9269,8 +9399,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -9301,7 +9431,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -9333,9 +9463,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -9364,7 +9494,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -9382,7 +9512,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -9407,7 +9537,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -9417,8 +9546,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -9427,7 +9554,7 @@ EOF: 1, this.clear(); } - 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. @@ -9439,13 +9566,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -9455,68 +9582,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -9541,7 +9674,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -9589,24 +9722,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9626,7 +9759,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -9636,24 +9769,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9674,8 +9807,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -9715,14 +9847,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -9738,9 +9870,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -9751,8 +9883,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -9760,7 +9892,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** diff --git a/packages/lex-parser/dist/lex-parser-es6.js b/packages/lex-parser/dist/lex-parser-es6.js index b56baadd7..802479451 100644 --- a/packages/lex-parser/dist/lex-parser-es6.js +++ b/packages/lex-parser/dist/lex-parser-es6.js @@ -2,11 +2,12 @@ import XRegExp from '@gerhobbelt/xregexp'; import JSON5 from '@gerhobbelt/json5'; import fs from 'fs'; import path$1 from 'path'; +import mkdirp from 'mkdirp'; import recast from 'recast'; import { transformSync } from '@babel/core'; import assert$1 from 'assert'; -// Return TRUE if `src` starts with `searchString`. +// Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -29,19 +30,19 @@ function rmCommonWS(strings, ...values) { // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -60,19 +61,21 @@ function rmCommonWS(strings, ...values) { // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -81,16 +84,19 @@ function rmCommonWS(strings, ...values) { } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -101,27 +107,79 @@ function camelCase(s) { return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } +// https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words +const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; +})([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' +]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -139,6 +197,11 @@ function mkIdentifier(s) { .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -147,13 +210,13 @@ function mkIdentifier(s) { function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -164,23 +227,17 @@ function scanRegExp(s) { break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -203,34 +260,33 @@ function isLineTerminator(cp) { /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -253,28 +309,76 @@ function chkBugger(src) { // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } +function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; +} + + +function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); +} + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path$1.dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path$1.basename(options.inputFilename || options.moduleName || (options.outfile ? path$1.dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path$1.dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path$1.basename(options.inputFilename || options.moduleName || (options.outfile ? path$1.dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -285,27 +389,37 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path$1.normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path$1.normalize(path$1.join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5.stringify(dump, null, 2); + let d = JSON5.stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp(path$1.dirname(dumpfile)); fs.writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -315,7 +429,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -323,7 +437,7 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -349,27 +463,43 @@ function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -382,9 +512,10 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, t -var code_exec = { +var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -406,22 +537,22 @@ assert$1(recast); // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; -// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries +// regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; -// Determine which Unicode NonAsciiIdentifierStart characters +// Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. -// +// // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action -// code chunks. -// +// code chunks. +// // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -429,40 +560,40 @@ const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -470,30 +601,30 @@ function generateMapper4JisonGrammarIdentifiers(input) { // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -504,59 +635,59 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -598,38 +729,38 @@ function generateMapper4JisonGrammarIdentifiers(input) { return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -641,18 +772,18 @@ function generateMapper4JisonGrammarIdentifiers(input) { // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -663,56 +794,56 @@ function generateMapper4JisonGrammarIdentifiers(input) { // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -720,97 +851,97 @@ function generateMapper4JisonGrammarIdentifiers(input) { typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp(`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp(`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp(`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp(`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp(`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp(`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp(`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp(`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp(`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp(`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp(`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -818,7 +949,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -831,7 +962,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -844,7 +975,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -857,7 +988,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -876,37 +1007,37 @@ function generateMapper4JisonGrammarIdentifiers(input) { let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -938,7 +1069,7 @@ function generateMapper4JisonGrammarIdentifiers(input) { // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -955,37 +1086,37 @@ function parseCodeChunkToAST(src, options) { .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast.parse(src); + const ast = recast.parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return transformSync(src, options); // => { code, map, ast } @@ -993,8 +1124,8 @@ function compileCodeToES5(src, options) { function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1003,7 +1134,7 @@ function prettyPrintAST(ast, options) { // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1026,25 +1157,25 @@ function prettyPrintAST(ast, options) { // validate the given JISON+JavaScript snippet: does it compile? -// -// Return either the parsed AST (object) or an error message (string). +// +// Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1055,9 +1186,9 @@ function checkActionBlock(src, yylloc, options) { // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. -// +// // Returns the trimmed sourcecode which was provided via `src`. -// +// // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1065,7 +1196,7 @@ function checkActionBlock(src, yylloc, options) { // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: -// +// // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1074,14 +1205,14 @@ function checkActionBlock(src, yylloc, options) { // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} -// +// // Of course the example would be 'ludicrous' action code but the -// key point here is that users will certainly be able to come up with +// key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! -// +// function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1135,7 +1266,7 @@ var parse2AST = { trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1149,7 +1280,7 @@ function chkBugger$1(src) { /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1161,24 +1292,24 @@ const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?: /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. -/// +/// /// Also supports ES6's Arrow Functions: -/// +/// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' -/// +/// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1195,8 +1326,8 @@ function printFunctionSourceCodeContainer(f) { if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1207,14 +1338,14 @@ function printFunctionSourceCodeContainer(f) { action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1225,17 +1356,17 @@ function printFunctionSourceCodeContainer(f) { var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; -// -// -// +// +// +// function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1261,7 +1392,7 @@ function detectIstanbulGlobal() { // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1309,7 +1440,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1372,13 +1503,13 @@ var reHelpers = { getRegExpInfo: getRegExpInfo }; -var cycleref = []; -var cyclerefpath = []; +let cycleref = []; +let cyclerefpath = []; -var linkref = []; -var linkrefpath = []; +let linkref = []; +let linkrefpath = []; -var path = []; +let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1386,14 +1517,14 @@ function shallow_copy(src) { return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1406,11 +1537,11 @@ function shallow_copy(src) { function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1423,9 +1554,9 @@ function shallow_copy_and_strip_depth(src, parentKey) { dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1440,16 +1571,52 @@ function shallow_copy_and_strip_depth(src, parentKey) { } +// strip developer machine specific parts off any paths in a given stacktrace (string) +// to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } +// strip off the line/position info from any stacktrace as a assert.deepEqual() on these +// will otherwise FAIL due to us running this stuff through both regular `node` and +// the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing +// exceptions and stacktraces which point completely somewhere else and this would b0rk +// our test rigs for the jison subpackages. +function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; +} + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1464,7 +1631,7 @@ function trim_array_tail(arr) { function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1490,10 +1657,10 @@ function treat_value_stack(v) { } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1591,7 +1758,7 @@ function treat_hash(h) { function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1608,7 +1775,7 @@ function treat_error_report_info(e) { path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1636,7 +1803,7 @@ function treat_error_report_info(e) { function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1652,7 +1819,7 @@ function treat_object(e) { linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1664,14 +1831,14 @@ function treat_object(e) { // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. -// +// // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1681,7 +1848,7 @@ function trimErrorForTestReporting(e) { cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1695,12 +1862,14 @@ var helpers = { dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1715,7 +1884,7 @@ var helpers = { printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; // See also: @@ -1723,7 +1892,6 @@ var helpers = { // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1740,9 +1908,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -1775,10 +1943,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -1791,11 +1959,11 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -1805,18 +1973,18 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -1847,7 +2015,7 @@ JisonParserError.prototype.name = 'JisonParserError'; // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -1864,9 +2032,9 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -1879,7 +2047,7 @@ JisonParserError.prototype.name = 'JisonParserError'; } -var parser = { +let parser = { // Code Generator Information Report // --------------------------------- // @@ -2129,7 +2297,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2137,7 +2304,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2149,8 +2315,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2163,14 +2329,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2186,10 +2351,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2197,10 +2362,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2355,9 +2520,9 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -2369,18 +2534,18 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2410,9 +2575,9 @@ case 1: case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -2425,10 +2590,10 @@ case 2: case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2455,9 +2620,9 @@ case 3: case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -2466,10 +2631,10 @@ case 4: case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2497,9 +2662,9 @@ case 5: case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -2508,10 +2673,10 @@ case 6: case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -2550,9 +2715,9 @@ case 7: case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2617,9 +2782,9 @@ case 8: case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2634,9 +2799,9 @@ case 9: case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -2671,10 +2836,10 @@ case 10: case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2691,9 +2856,9 @@ case 11: case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2710,10 +2875,10 @@ case 12: case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2730,9 +2895,9 @@ case 13: case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2749,10 +2914,10 @@ case 14: case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2769,9 +2934,9 @@ case 15: case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -2795,9 +2960,9 @@ case 17: case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -2808,9 +2973,9 @@ case 132: case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2830,9 +2995,9 @@ case 18: case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2856,9 +3021,9 @@ case 19: case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2871,10 +3036,10 @@ case 20: case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2891,9 +3056,9 @@ case 21: case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2905,9 +3070,9 @@ case 22: case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -2947,10 +3112,10 @@ case 23: case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2970,9 +3135,9 @@ case 24: case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3022,10 +3187,10 @@ case 25: case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -3049,10 +3214,10 @@ case 26: case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3072,10 +3237,10 @@ case 27: case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3099,10 +3264,10 @@ case 28: case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3123,10 +3288,10 @@ case 29: case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3138,10 +3303,10 @@ case 31: case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3151,10 +3316,10 @@ case 33: case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3164,10 +3329,10 @@ case 32: case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3177,10 +3342,10 @@ case 34: case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3190,10 +3355,10 @@ case 35: case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -3203,10 +3368,10 @@ case 36: case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3216,10 +3381,10 @@ case 37: case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3229,9 +3394,9 @@ case 38: case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -3240,9 +3405,9 @@ case 39: case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -3251,9 +3416,9 @@ case 40: case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3275,9 +3440,9 @@ case 41: case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3288,9 +3453,9 @@ case 42: case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3310,9 +3475,9 @@ case 43: case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3366,9 +3531,9 @@ case 49: case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3388,9 +3553,9 @@ case 51: case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -3399,9 +3564,9 @@ case 58: case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -3413,9 +3578,9 @@ case 52: case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -3429,10 +3594,10 @@ case 53: case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3452,10 +3617,10 @@ case 54: case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3475,10 +3640,10 @@ case 55: case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3498,9 +3663,9 @@ case 56: case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3511,9 +3676,9 @@ case 59: case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3532,9 +3697,9 @@ case 60: case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -3575,9 +3740,9 @@ case 61: case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3601,9 +3766,9 @@ case 62: case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3629,9 +3794,9 @@ case 63: case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3676,9 +3841,9 @@ case 64: case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -3704,9 +3869,9 @@ case 106: case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -3715,9 +3880,9 @@ case 127: case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -3726,10 +3891,10 @@ case 67: case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3743,10 +3908,10 @@ case 68: case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3760,10 +3925,10 @@ case 69: case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3777,10 +3942,10 @@ case 70: case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3799,9 +3964,9 @@ case 72: case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -3810,9 +3975,9 @@ case 77: case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -3850,10 +4015,10 @@ case 73: case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -3877,9 +4042,9 @@ case 74: case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -3958,9 +4123,9 @@ case 110: case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -3969,9 +4134,9 @@ case 129: case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -3980,9 +4145,9 @@ case 78: case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -3991,9 +4156,9 @@ case 79: case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -4002,9 +4167,9 @@ case 80: case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -4013,9 +4178,9 @@ case 81: case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -4024,9 +4189,9 @@ case 85: case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -4037,10 +4202,10 @@ case 87: case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4057,9 +4222,9 @@ case 88: case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -4068,9 +4233,9 @@ case 89: case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -4079,9 +4244,9 @@ case 90: case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -4090,9 +4255,9 @@ case 91: case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -4101,9 +4266,9 @@ case 92: case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -4122,18 +4287,18 @@ case 107: case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -4142,9 +4307,9 @@ case 97: case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -4153,9 +4318,9 @@ case 98: case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -4164,9 +4329,9 @@ case 99: case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -4175,9 +4340,9 @@ case 102: case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -4186,10 +4351,10 @@ case 104: case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4206,9 +4371,9 @@ case 105: case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -4225,9 +4390,9 @@ case 109: case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -4239,9 +4404,9 @@ case 111: case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -4251,9 +4416,9 @@ case 112: case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4288,9 +4453,9 @@ case 113: case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4309,9 +4474,9 @@ case 114: case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -4320,9 +4485,9 @@ case 115: case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -4331,9 +4496,9 @@ case 116: case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4351,10 +4516,10 @@ case 117: case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -4372,10 +4537,10 @@ case 118: case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -4396,9 +4561,9 @@ case 119: case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4431,9 +4596,9 @@ case 120: case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4459,9 +4624,9 @@ case 121: case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5.parse(yyvstack[yysp]); @@ -4470,9 +4635,9 @@ case 122: case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue(yyvstack[yysp]); @@ -4481,9 +4646,9 @@ case 123: case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4492,9 +4657,9 @@ case 124: case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -4515,10 +4680,10 @@ case 125: case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4535,9 +4700,9 @@ case 126: case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -4556,9 +4721,9 @@ case 128: case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4582,9 +4747,9 @@ case 130: case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -4604,9 +4769,9 @@ case 131: case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4617,9 +4782,9 @@ case 133: case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -4675,10 +4840,10 @@ case 134: case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6281,7 +6446,6 @@ defaultActions: bda({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -6298,38 +6462,34 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -6337,20 +6497,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -6372,7 +6530,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -6380,18 +6537,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -6399,24 +6557,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -6454,18 +6607,15 @@ parse: function parse(input) { - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -6486,7 +6636,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -6504,7 +6654,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -6517,7 +6666,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -6531,11 +6679,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -6589,8 +6736,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6598,8 +6745,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6631,19 +6778,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -6654,7 +6800,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -6667,7 +6813,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -6679,29 +6825,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -6709,7 +6853,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -6729,8 +6873,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -6739,10 +6882,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -6750,7 +6893,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -6761,9 +6904,14 @@ parse: function parse(input) { // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -6779,8 +6927,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -6849,11 +6996,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -6864,8 +7014,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -6874,21 +7023,20 @@ parse: function parse(input) { function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6898,21 +7046,20 @@ parse: function parse(input) { } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6921,28 +7068,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -6955,8 +7101,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -6979,8 +7124,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -6992,8 +7136,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -7010,8 +7153,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -7025,8 +7167,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -7040,7 +7181,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -7093,16 +7234,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -7136,9 +7274,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -7161,9 +7297,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -7190,17 +7324,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -7247,8 +7380,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -7260,8 +7393,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -7279,6 +7411,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -7287,7 +7420,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -7298,7 +7431,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -7358,10 +7491,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -7396,9 +7529,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -7411,7 +7542,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -7432,9 +7563,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7456,12 +7585,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -7470,7 +7599,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7511,7 +7640,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -7558,7 +7687,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -7576,21 +7705,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7624,14 +7751,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7641,6 +7769,7 @@ parse: function parse(input) { + } continue; // accept: @@ -7692,7 +7821,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -7708,9 +7837,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7739,7 +7866,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7756,8 +7883,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -7768,8 +7895,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -7781,21 +7908,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7826,14 +7951,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7843,6 +7969,7 @@ parse: function parse(input) { + } continue; // accept: @@ -7895,8 +8022,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -8157,7 +8283,6 @@ var lexer = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -8174,10 +8299,10 @@ var lexer = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -8209,7 +8334,7 @@ var lexer = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -8251,7 +8376,9 @@ var lexer = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -8337,7 +8464,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -8345,7 +8472,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -8358,7 +8485,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -8384,10 +8511,13 @@ EOF: 1, * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -8410,7 +8540,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -8433,16 +8562,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -8464,7 +8593,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -8472,8 +8600,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -8502,7 +8630,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -8527,7 +8655,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -8539,17 +8667,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -8643,7 +8771,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -8664,7 +8792,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -8675,7 +8802,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -8686,15 +8813,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -8728,8 +8855,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -8762,9 +8889,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -8783,9 +8910,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -8795,8 +8922,8 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -8823,20 +8950,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -8876,17 +9002,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8895,7 +9023,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -8910,8 +9038,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -8937,24 +9065,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8965,7 +9095,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -8987,8 +9117,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -9010,8 +9140,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -9155,21 +9284,21 @@ EOF: 1, const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -9184,11 +9313,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -9207,13 +9336,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -9237,13 +9366,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -9258,8 +9387,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -9290,7 +9419,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -9322,9 +9451,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -9353,7 +9482,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -9371,7 +9500,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -9396,7 +9525,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -9406,8 +9534,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -9416,7 +9542,7 @@ EOF: 1, this.clear(); } - 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. @@ -9428,13 +9554,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -9444,68 +9570,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -9530,7 +9662,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -9578,24 +9710,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9615,7 +9747,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -9625,24 +9757,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9663,8 +9795,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -9704,14 +9835,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -9727,9 +9858,9 @@ EOF: 1, if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -9740,8 +9871,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -9749,7 +9880,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** diff --git a/packages/lex-parser/dist/lex-parser-umd-es5.js b/packages/lex-parser/dist/lex-parser-umd-es5.js index 94ea3b472..4b71483df 100644 --- a/packages/lex-parser/dist/lex-parser-umd-es5.js +++ b/packages/lex-parser/dist/lex-parser-umd-es5.js @@ -1,6 +1,6 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@gerhobbelt/xregexp'), require('@gerhobbelt/json5'), require('fs'), require('path'), require('recast'), require('@babel/core'), require('assert')) : typeof define === 'function' && define.amd ? define(['@gerhobbelt/xregexp', '@gerhobbelt/json5', 'fs', 'path', 'recast', '@babel/core', 'assert'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['lex-parser'] = factory(global.XRegExp, global.JSON5, global.fs, global.path$1, global.recast, global.babel, global.assert$1)); -})(this, function (XRegExp, JSON5, fs, path$1, recast, babel, assert$1) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@gerhobbelt/xregexp'), require('@gerhobbelt/json5'), require('fs'), require('path'), require('mkdirp'), require('recast'), require('@babel/core'), require('assert')) : typeof define === 'function' && define.amd ? define(['@gerhobbelt/xregexp', '@gerhobbelt/json5', 'fs', 'path', 'mkdirp', 'recast', '@babel/core', 'assert'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['lex-parser'] = factory(global.XRegExp, global.JSON5, global.fs, global.path$1, global.mkdirp, global.recast, global.babel, global.assert$1)); +})(this, function (XRegExp, JSON5, fs, path$1, mkdirp, recast, babel, assert$1) { 'use strict'; function _interopDefaultLegacy(e) { @@ -17,9 +17,11 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); + var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); + var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); - var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); // Return TRUE if `src` starts with `searchString`. + var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); // Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { @@ -42,18 +44,18 @@ // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -71,18 +73,20 @@ // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); // Done removing common indentation. - // + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; // only correct indentation at start of line, i.e. only check for + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -91,17 +95,20 @@ } // now merge everything to construct the template result: - var rv = []; + { + let rv = []; + let i = 0; - for (var i = 0, len = values.length; i < len; i++) { - rv.push(src[i].join('\n')); - rv.push(values[i]); - } // the last value is always followed by a last template string partial: + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + rv.push(src[i].join('\n')); + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` /** @public */ @@ -112,8 +119,8 @@ return s.replace(/^\w/, function (match) { return match.toLowerCase(); }).replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; @@ -121,18 +128,30 @@ return rv; }); - } // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers + } // https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words + + + const reservedWords = (list => { + let rv = new Set(); + + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + + return rv; + })(['await', 'break', 'case', 'catch', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'enum', 'export', 'extends', 'finally', 'for', 'function', 'if', 'implements', 'import', 'in', 'instanceof', 'interface', 'new', 'package', 'private', 'protected', 'public', 'return', 'super', 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'yield']); // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -144,6 +163,12 @@ .replace(/^[^\w_]/, '_') // do not accept numerics at the leading position, despite those matching regex `\w`: .replace(/^\d/, '_').replace(/[^\w\d_]/g, '_') // and only accept multiple (double, not triple) underscores at start or end of identifier name: .replace(/^__+/, '#').replace(/__+$/, '#').replace(/_+/g, '_').replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + + return rv; } // Check if the start of the given input matches a regex expression. // Return the length of the regex expression or -1 if none was found. @@ -153,13 +178,13 @@ function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; @@ -179,13 +204,11 @@ if (ch === ']') { classMarker = false; } - } else { - if (ch === '/') { - terminated = true; - break; - } else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } @@ -209,12 +232,12 @@ function isLegalIdentifierInput(s) { - s = '' + s; // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + s = '' + s; // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s.replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -222,14 +245,14 @@ return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = s.indexOf('\'') >= 0; - var dq = s.indexOf('"') >= 0; + let sq = s.indexOf('\'') >= 0; + let dq = s.indexOf('"') >= 0; if (sq && dq) { s = s.replace(/"/g, '\\"'); @@ -257,48 +280,104 @@ function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); + } + + function convertExceptionToObject(ex) { + if (!ex) return ex; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + + let rv = Object.assign({}, ex); // - Set up the default fields which should ALWAYS be present: + + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + + if (Array.isArray(ex.errors)) { + rv.errors = []; + + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + + return rv; + } + + function find_suitable_app_dump_path() { + return process.cwd().replace(/\\/g, '/').replace(/\/node_modules\/.*$/, m => '/___nm___/').replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map(d => d.charAt(0).toUpperCase()).join('_')); } // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [options.outfile ? path__default['default'].dirname(options.outfile) : null, options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname).replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + const dumpPaths = [options.outfile ? path__default['default'].dirname(options.outfile) : null, options.inputPath, find_suitable_app_dump_path()]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname).replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; + } // generate a stacktrace for the dump no matter what: + + + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } } err_id = err_id || 'XXX'; - var ts = new Date(); - var tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + '' + pad(ts.getUTCMinutes()) + '' + pad(ts.getUTCSeconds()) + '.' + pad(ts.getUTCMilliseconds(), 3) + 'Z'; + err_id = err_id.replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + '' + pad(ts.getUTCMinutes()) + '' + pad(ts.getUTCSeconds()) + '.' + pad(ts.getUTCMilliseconds(), 3) + 'Z'; dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); - let dump = { + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); + const dump = { errname, err_id, options, - ex + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); // make sure each line is a comment line: + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]' + }); // make sure each line is a comment line: d = d.split('\n').map(l => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -308,7 +387,7 @@ } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -339,25 +418,40 @@ function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; } - const debug = 0; - var p; + const debug = options.debug || 0; + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); + } + + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + if (debug > 1) console.log('exec-and-diagnose options:', options); + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } @@ -370,9 +464,10 @@ return p; } - var code_exec = { + var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject }; // assert__default['default'](recast__default['default']); //var types = recast.types; @@ -386,18 +481,18 @@ // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! - const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries + const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: - const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; // Determine which Unicode NonAsciiIdentifierStart characters + const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; // Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. - // + // // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action - // code chunks. - // + // code chunks. + // // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -407,37 +502,37 @@ // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -445,30 +540,30 @@ // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -479,58 +574,58 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -575,27 +670,27 @@ return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: - const typeIdCharSets = ["ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", + const typeIdCharSets = ['ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ"]; //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ']; //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -606,18 +701,18 @@ hash[i] = (hash[i] || 0) + 1; } // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -628,56 +723,56 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); @@ -685,7 +780,7 @@ for (let i = 0, l = typeIdCharSets.length; i < l; i++) { typeIdChar[i] = pickChar(typeIdCharSets[i]); - } // produce a function set for encoding and decoding content, + } // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: @@ -693,57 +788,57 @@ return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction @@ -754,10 +849,10 @@ re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -840,10 +935,10 @@ re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. @@ -852,19 +947,19 @@ // p1 is only serving as lookbehind emulation switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -906,7 +1001,7 @@ function parseCodeChunkToAST(src, options) { src = src.replace(/@/g, '\uFFDA').replace(/#/g, '\uFFDB'); - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } @@ -921,13 +1016,13 @@ sourceRoot: '.', sourceType: 'module', babelrc: false, - ignore: ["node_modules/**/*.js"], + ignore: ['node_modules/**/*.js'], compact: false, retainLines: false, - presets: [["@babel/preset-env", { + presets: [['@babel/preset-env', { targets: { - browsers: ["last 2 versions"], - node: "8.0" + browsers: ['last 2 versions'], + node: '8.0' } }]] }, options); @@ -935,7 +1030,7 @@ } function prettyPrintAST(ast, options) { - var options = options || {}; + options = options || {}; const defaultOptions = { tabWidth: 2, quote: 'single', @@ -945,7 +1040,7 @@ reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -958,16 +1053,16 @@ .replace(/\uFFDA/g, '@').replace(/\uFFDB/g, '#'); return new_src; } // validate the given JISON+JavaScript snippet: does it compile? - // - // Return either the parsed AST (object) or an error message (string). + // + // Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; } @@ -976,19 +1071,19 @@ } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } // The rough-and-ready preprocessor for any action code block: // this one trims off any surplus whitespace and removes any // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. - // + // // Returns the trimmed sourcecode which was provided via `src`. - // + // // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -996,7 +1091,7 @@ // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: - // + // // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1005,16 +1100,16 @@ // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} - // + // // Of course the example would be 'ludicrous' action code but the - // key point here is that users will certainly be able to come up with + // key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! - // + // function trimActionCode(src, startMarker) { - var s = src.trim(); // remove outermost set of braces UNLESS there's + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated // code analyzer to simplify the code! @@ -1079,7 +1174,7 @@ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1087,25 +1182,25 @@ const funcRe = /^function[\s\r\n]*[^\(]*\(([^\)]*)\)[\s\r\n]*\{([^]*?)\}$/; const arrowFuncRe = /^(?:(?:\(([^\)]*)\))|(?:([^\(\)]+)))[\s\r\n]*=>[\s\r\n]*(?:(?:\{([^]*?)\})|(?:(([^\s\r\n\{)])[^]*?)))$/; /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. - /// + /// /// Also supports ES6's Arrow Functions: - /// + /// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' - /// + /// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; // Also cope with Arrow Functions (and inline those as well?). + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); @@ -1125,8 +1220,8 @@ if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1137,7 +1232,7 @@ action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } @@ -1152,14 +1247,14 @@ var stringifier = { printFunctionSourceCode, printFunctionSourceCodeContainer - }; // - // - // + }; // + // + // function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } // // Helper library for safe code execution/compilation @@ -1182,7 +1277,7 @@ function checkRegExp(re_src, re_flags, XRegExp) { - var re; // were we fed a RegExp object or a string? + let re; // were we fed a RegExp object or a string? if (re_src && typeof re_src.source === 'string' && typeof re_src.flags === 'string' && typeof re_src.toString === 'function' && typeof re_src.test === 'function' && typeof re_src.exec === 'function') { // we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member @@ -1226,7 +1321,7 @@ function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; // were we fed a RegExp object or a string? + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src && typeof re_src.source === 'string' && typeof re_src.flags === 'string' && typeof re_src.toString === 'function' && typeof re_src.test === 'function' && typeof re_src.exec === 'function') { // we're looking at a RegExp (or XRegExp) object, so we can trust the `.source` member @@ -1274,11 +1369,11 @@ checkRegExp: checkRegExp, getRegExpInfo: getRegExpInfo }; - var cycleref = []; - var cyclerefpath = []; - var linkref = []; - var linkrefpath = []; - var path = []; + let cycleref = []; + let cyclerefpath = []; + let linkref = []; + let linkrefpath = []; + let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1286,7 +1381,7 @@ return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; @@ -1294,7 +1389,7 @@ dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1308,12 +1403,12 @@ function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1327,9 +1422,9 @@ dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; @@ -1344,12 +1439,44 @@ } return src; - } + } // strip developer machine specific parts off any paths in a given stacktrace (string) + // to ease cross-platform comparison of these stacktraces. + function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: - msg = msg.replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)').replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + msg = msg.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; + } // strip off the line/position info from any stacktrace as a assert.deepEqual() on these + // will otherwise FAIL due to us running this stuff through both regular `node` and + // the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing + // exceptions and stacktraces which point completely somewhere else and this would b0rk + // our test rigs for the jison subpackages. + + + function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj.replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)').replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + + let keys = Object.keys(obj); + + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + + return obj; } function trim_array_tail(arr) { @@ -1366,7 +1493,7 @@ function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; @@ -1393,11 +1520,11 @@ } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1544,7 +1671,7 @@ function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. @@ -1570,7 +1697,7 @@ return e; } // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. - // + // // Internal use in the unit test rigs. @@ -1602,10 +1729,12 @@ dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, compileCodeToES5: parse2AST.compileCodeToES5, @@ -1635,10 +1764,10 @@ value: msg }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -1671,11 +1800,11 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; + let rv = []; + let p = s.pop; + let r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + for (let i = 0, l = p.length; i < l; i++) { rv.push([p[i], r[i]]); } @@ -1684,12 +1813,12 @@ function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; + let rv = {}; + let d = s.idx; + let g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } @@ -1698,20 +1827,20 @@ function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: @@ -1739,7 +1868,7 @@ function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -1757,10 +1886,10 @@ function u(a) { - var rv = []; + let rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; // Is this entry a helper function? + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -1773,7 +1902,7 @@ return rv; } - var parser = { + let parser = { // Code Generator Information Report // --------------------------------- // @@ -2037,9 +2166,9 @@ // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; + const s = this.symbols_; - for (var key in s) { + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2058,7 +2187,7 @@ return 'end of input'; } - var id = this.getSymbolName(symbol); + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); @@ -2075,20 +2204,20 @@ // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { return [this.state_descriptions_[state]]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); @@ -2108,9 +2237,9 @@ , yysp, yyvstack, yylstack) { /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; const OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME = 0x0004; @@ -2120,16 +2249,16 @@ switch (yystate) { case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; - this._$ = yylstack[yysp - 1]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -2158,8 +2287,8 @@ case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { @@ -2176,9 +2305,9 @@ case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` There's probably an error in one or more of your lexer regex rules. @@ -2203,8 +2332,8 @@ case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { rules: yyvstack[yysp] @@ -2213,9 +2342,9 @@ case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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 probably an error in one or more of your lexer regex rules. @@ -2241,8 +2370,8 @@ case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { rules: [] @@ -2251,9 +2380,9 @@ case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; if (!yy.options) yy.options = {}; @@ -2292,8 +2421,8 @@ case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -2361,8 +2490,8 @@ case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { macros: {}, @@ -2380,8 +2509,8 @@ case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` // macros here: @@ -2414,9 +2543,9 @@ case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` ill defined macro definition. @@ -2431,8 +2560,8 @@ case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -2449,9 +2578,9 @@ case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` ill defined '%s' inclusive lexer condition set specification. @@ -2466,8 +2595,8 @@ case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -2484,9 +2613,9 @@ case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` ill defined '%x' exclusive lexer condition set specification. @@ -2501,8 +2630,8 @@ case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -2529,8 +2658,8 @@ case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. @@ -2539,8 +2668,8 @@ case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -2558,8 +2687,8 @@ case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -2581,8 +2710,8 @@ case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -2595,9 +2724,9 @@ case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` ill defined %options line. @@ -2612,8 +2741,8 @@ case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = { type: 'unknown', @@ -2623,8 +2752,8 @@ case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -2663,9 +2792,9 @@ case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` %import name or source filename missing maybe? @@ -2683,8 +2812,8 @@ case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 5, yysp); // END of default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-) + // 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]; @@ -2735,9 +2864,9 @@ case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + 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 : ''; @@ -2759,9 +2888,9 @@ case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` Each '%code' initialization code section must be qualified by a name, @@ -2779,9 +2908,9 @@ case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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, @@ -2803,9 +2932,9 @@ case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` illegal input in the lexer spec definitions section. @@ -2824,9 +2953,9 @@ case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = yyvstack[yysp]; @@ -2837,9 +2966,9 @@ case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; yy.__options_category_description__ = yyvstack[yysp]; @@ -2847,9 +2976,9 @@ case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; yy.__options_category_description__ = yyvstack[yysp]; @@ -2857,9 +2986,9 @@ case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = 'the inclusive lexer start conditions set (%s)'; @@ -2867,9 +2996,9 @@ case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; yy.__options_category_description__ = 'the exclusive lexer start conditions set (%x)'; @@ -2877,9 +3006,9 @@ case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; yy.__options_category_description__ = 'the <...> delimited set of lexer start conditions'; @@ -2887,9 +3016,9 @@ case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; yy.__options_category_description__ = 'the lexer rules definition section'; @@ -2897,9 +3026,9 @@ case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; yy.__options_category_description__ = 'the lexer epilogue section'; @@ -2907,24 +3036,24 @@ case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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].concat(yyvstack[yysp]); break; case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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].concat([yyvstack[yysp]]); break; case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -2948,8 +3077,8 @@ case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // The issue has already been reported by the lexer. No need to repeat // ourselves with another error report from here. @@ -2958,8 +3087,8 @@ case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -2977,8 +3106,8 @@ case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3037,8 +3166,8 @@ case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3057,16 +3186,16 @@ case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (yyvstack[yysp - 1]) { yyvstack[yysp].unshift(yyvstack[yysp - 1]); @@ -3077,8 +3206,8 @@ case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (yyvstack[yysp - 3]) { yyvstack[yysp - 1].forEach(function (d) { @@ -3091,9 +3220,9 @@ case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + 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$1` Seems you made a mistake while specifying one of the lexer rules inside @@ -3111,9 +3240,9 @@ case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` Seems you did not correctly bracket a lexer rules set inside @@ -3131,9 +3260,9 @@ case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` Seems you did not correctly bracket a lexer rules set inside @@ -3151,8 +3280,8 @@ case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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.$.push(yyvstack[yysp]); @@ -3163,8 +3292,8 @@ case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -3183,8 +3312,8 @@ case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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. @@ -3224,8 +3353,8 @@ case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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` @@ -3247,8 +3376,8 @@ case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO: REWRITE this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3272,8 +3401,8 @@ case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO: REWRITE this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3316,8 +3445,8 @@ case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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], yyvstack[yysp]]; yyparser.yyError(rmCommonWS$1` @@ -3345,25 +3474,25 @@ case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + yyvstack[yysp]; break; case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '\n\n' + yyvstack[yysp] + '\n\n'; break; case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` You may place the '%include' instruction only at the start/front of a line. @@ -3375,9 +3504,9 @@ case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` Missing curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: '{ ... }'. @@ -3389,9 +3518,9 @@ case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` Too many curly braces: seems you did not correctly bracket a lexer rule action block in curly braces: '{ ... }'. @@ -3403,9 +3532,9 @@ case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` Unterminated string constant in lexer rule action block. @@ -3423,16 +3552,16 @@ case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-) + // 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 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -3466,9 +3595,9 @@ case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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) { @@ -3489,8 +3618,8 @@ case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3570,56 +3699,56 @@ case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]; break; case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '|'; break; case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]; break; case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '|'; break; case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + ')'; break; case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + ')'; break; @@ -3629,9 +3758,9 @@ case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` Seems you did not correctly bracket a lex rule regex part in '(...)' braces. @@ -3646,40 +3775,40 @@ case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '+'; break; case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '*'; break; case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + '?'; break; case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + ')'; break; case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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] + ')'; break; @@ -3701,57 +3830,57 @@ case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '.'; break; case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '^'; break; case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = '$'; break; case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); break; case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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 - 1] + yyvstack[yysp]; break; case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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` Seems you did not correctly bracket a lex rule regex set in '[...]' brackets. @@ -3766,8 +3895,8 @@ case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) && yyvstack[yysp].toUpperCase() !== yyvstack[yysp]) { // treat this as part of an XRegExp `\p{...}` Unicode 'General Category' Property cf. http://unicode.org/reports/tr18/#Categories @@ -3781,8 +3910,8 @@ case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -3792,8 +3921,8 @@ case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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); @@ -3801,8 +3930,8 @@ case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -3836,8 +3965,8 @@ case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -3855,24 +3984,24 @@ case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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], true]; break; case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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_VALUE) { @@ -3889,9 +4018,9 @@ case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... yyparser.yyError(rmCommonWS$1` @@ -3907,9 +4036,9 @@ case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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)'; @@ -3930,8 +4059,8 @@ case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -3965,8 +4094,8 @@ case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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) { @@ -3993,32 +4122,32 @@ case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = parseValue(yyvstack[yysp]); break; case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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.$ = ''; break; case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4040,9 +4169,9 @@ case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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. @@ -4057,8 +4186,8 @@ case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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,-,-) // TODO ... yyparser.yyError(rmCommonWS$1` @@ -4075,8 +4204,8 @@ case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 2, yysp); // END of default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4101,8 +4230,8 @@ case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): - this._$ = yyparser.yyMergeLocationInfo(yysp - 1, yysp); // END of default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-) + // 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 : ''; @@ -4120,8 +4249,8 @@ case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): - this._$ = yylstack[yysp]; // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-) + // 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. @@ -4130,8 +4259,8 @@ case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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]; @@ -4189,9 +4318,9 @@ case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + 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. @@ -4237,32 +4366,32 @@ } }, parse: function parse(input) { - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) - var vstack = new Array(128); // semantic value stack + let vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack + let lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks - var yyloc; - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) + let yyloc; + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = this.options.errorRecoveryTokenDiscardCount | 0 || 3; - var NO_ACTION = [0, 189 + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = this.options.errorRecoveryTokenDiscardCount | 0 || 3; + const NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */ ]; - var lexer; + let lexer; if (this.__lexer__) { lexer = this.__lexer__; @@ -4270,7 +4399,7 @@ lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -4278,20 +4407,14 @@ pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = typeof assert !== 'function' ? function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : assert; this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -4319,18 +4442,19 @@ return src.slice(); } - var dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; @@ -4342,21 +4466,19 @@ function shallow_copy_noclobber(dst, src) { const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - var rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -4382,14 +4504,14 @@ this.yyError = function yyError(str /*, ...args */ ) { - var error_rule_depth = this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1; - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, error_rule_depth >= 0); // append to the old one? + let error_rule_depth = this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1; + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, error_rule_depth >= 0); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; // v.stackSampleLength = error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH; @@ -4407,7 +4529,7 @@ } // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; @@ -4446,10 +4568,10 @@ this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -4509,8 +4631,8 @@ // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -4519,8 +4641,8 @@ this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -4551,16 +4673,16 @@ this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; // rules: + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { @@ -4572,7 +4694,7 @@ if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { @@ -4586,7 +4708,7 @@ if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { @@ -4600,30 +4722,30 @@ // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; - } + return null; + } // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + + rv = this.copy_yylloc(l2); return rv; + } // shallow-copy L1, then adjust first col/row 1 column past the end. + + + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; } + + return rv; } if (!l1) { @@ -4632,7 +4754,7 @@ } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking // at unconventional yylloc info objects... @@ -4652,7 +4774,7 @@ this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -4661,10 +4783,10 @@ token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -4672,7 +4794,7 @@ location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential // ref cycle via userland code manipulations. @@ -4682,9 +4804,15 @@ // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - var rec = !!this.recoverable; - - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -4702,7 +4830,7 @@ this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - var rv = shallow_copy(p); // remove the large parts which can only cause cyclic references + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. delete rv.sharedState_yy; @@ -4764,11 +4892,15 @@ // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty - } + { + let i; + + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) {// empty + } - rv.base_pointer = i; - rv.info_stack_pointer = i; + rv.base_pointer = i; + rv.info_stack_pointer = i; + } rv.root_failure_pointer = rv.stack_pointer; // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection! this.__error_recovery_infos.push(rv); @@ -4777,7 +4909,7 @@ }; function getNonTerminalFromCode(symbol) { - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; @@ -4787,21 +4919,21 @@ } function stdLex() { - var token = lexer.lex(); // if token isn't its numeric value, convert + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -4811,21 +4943,21 @@ } function fastLex() { - var token = lexer.fastLex(); // if token isn't its numeric value, convert + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -4834,27 +4966,27 @@ return token || EOF; } - var lex = stdLex; - var state, action, r, t; - var yyval = { + let lex = stdLex; + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; // Return the rule stack depth where the nearest error rule can be found. + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - var stack_probe = sp - 1; - var depth = 0; // try to recover from error + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { // check for error recovery rule in this state - var t = table[state] && table[state][TERROR] || NO_ACTION; + const t = table[state] && table[state][TERROR] || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: @@ -4908,7 +5040,7 @@ // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; @@ -4956,10 +5088,10 @@ if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = this.describeSymbol(symbol) || symbol; - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = this.describeSymbol(symbol) || symbol; + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -5002,7 +5134,7 @@ } } - var esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -5019,11 +5151,11 @@ if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; // Report error + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { errStr = 'Parsing halted on line ' + (lexer.yylineno + 1) + ' while starting to recover from another error'; @@ -5074,8 +5206,8 @@ recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -5094,7 +5226,8 @@ yyval.$ = recoveringErrorInfo; yyval._$ = undefined; yyrulelen = error_rule_depth; - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + let combineState = NO_ACTION[1]; + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -5104,7 +5237,7 @@ sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -5151,10 +5284,10 @@ // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack @@ -5186,7 +5319,7 @@ // and take it from there! if (!action) { - ASSERT(recoveringErrorInfo, "line 1087"); // Prep state variables so that upon breaking out of + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` // statement in the outer "fast parse loop" we redo // the exact same state table lookup as the one above @@ -5221,12 +5354,12 @@ // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -5236,7 +5369,7 @@ ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; @@ -5268,7 +5401,7 @@ } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; // read action for current state and first input @@ -5298,7 +5431,7 @@ // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; @@ -5314,18 +5447,18 @@ r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', nonterminal: currentNonterminal, @@ -5358,15 +5491,17 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -5420,7 +5555,7 @@ // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; @@ -5462,7 +5597,7 @@ sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; @@ -5478,9 +5613,9 @@ ++sp; symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: yyloc = this.copy_yylloc(lexer.yylloc); @@ -5488,9 +5623,9 @@ // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... @@ -5498,18 +5633,18 @@ r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', nonterminal: currentNonterminal, @@ -5538,15 +5673,17 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; + } continue; // accept: @@ -5873,10 +6010,10 @@ value: msg }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -5907,7 +6044,7 @@ JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- // @@ -6009,7 +6146,7 @@ if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -6017,7 +6154,7 @@ msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -6031,7 +6168,7 @@ /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... @@ -6055,9 +6192,13 @@ * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { - var rec = !!this.recoverable; + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -6103,15 +6244,15 @@ yyerror: function yyError(str /*, ...args */ ) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -6139,8 +6280,8 @@ // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -6167,7 +6308,7 @@ this.matches = false; this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, first_column: col, @@ -6190,7 +6331,7 @@ if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; // compression: is the RE an xref to another RE slot in the rules[] table? @@ -6201,18 +6342,18 @@ } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -6302,7 +6443,7 @@ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -6333,7 +6474,7 @@ this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -6343,14 +6484,14 @@ // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; - var lines = false; + let slice_len = 1; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -6384,8 +6525,8 @@ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -6416,8 +6557,8 @@ // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre = this.match; + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -6436,9 +6577,9 @@ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -6448,8 +6589,8 @@ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -6482,13 +6623,13 @@ // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); + const p = this.constructLexErrorInfo(lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false); this._signaled_error_token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; } @@ -6524,17 +6665,27 @@ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) maxSize = Infinity;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substr` anticipation: treat \r\n as a single character and take a little + let past = this.matched.substring(0, this.matched.length - this.match.length); + + if (maxSize < 0) { + maxSize = Infinity; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + past = past.substr(-maxSize * 2 - 2); // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, // do add an ellipsis prefix... @@ -6547,8 +6698,8 @@ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -6574,27 +6725,37 @@ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; - if (maxSize < 0) maxSize = next.length + source.length;else if (!maxSize) maxSize = 20; - if (maxLines < 0) maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) maxLines = 1; // `substring` anticipation: treat \r\n as a single character and take a little + let next = this.match; + let source = this._input || ''; + + if (maxSize < 0) { + maxSize = next.length + source.length; + } else if (!maxSize) { + maxSize = 20; + } + + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { + maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize // after we've transformed and limited the newLines in here: + if (next.length < maxSize * 2 + 2) { next += source.substring(0, maxSize * 2 + 2 - next.length); // substring is faster on Chrome/V8 } // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); // When, after limiting to maxLines, we still have too much to return, @@ -6615,8 +6776,8 @@ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -6638,7 +6799,7 @@ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -6783,20 +6944,20 @@ const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -6807,11 +6968,11 @@ len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -6829,13 +6990,13 @@ }); // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -6859,13 +7020,13 @@ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -6880,8 +7041,8 @@ } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -6912,7 +7073,7 @@ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -6940,9 +7101,9 @@ }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -6968,7 +7129,7 @@ // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] + let token = this.performAction.call(this, this.yy, indexed_rule, this.conditionStack[this.conditionStack.length - 1] /* = YY_START */ ); // otherwise, when the action codes are all simple return token statements: //token = this.simpleCaseActionClusters[indexed_rule]; @@ -6981,7 +7142,7 @@ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -7014,8 +7175,6 @@ this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -7024,7 +7183,7 @@ this.clear(); } - 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. @@ -7035,75 +7194,81 @@ // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! + const p = this.constructLexErrorInfo('Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false); // produce one 'error' token until this situation has been resolved, most probably by parse termination! return this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; // 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! + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + for (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + if (token !== false) { + return token; + } // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + const p = this.constructLexErrorInfo(lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable); + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -7128,7 +7293,7 @@ * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; //this._clear_state = 0; + let r; //this._clear_state = 0; if (!this._more) { if (!this._clear_state) { @@ -7174,24 +7339,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -7210,7 +7375,7 @@ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; //this._clear_state = 0; + let r; //this._clear_state = 0; while (!r) { r = this.next(); @@ -7218,24 +7383,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); this.yylloc.range = Object.freeze(this.yylloc.range); @@ -7255,7 +7420,7 @@ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; return rv; @@ -7294,14 +7459,14 @@ * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -7317,9 +7482,9 @@ if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -7330,8 +7495,8 @@ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -7339,7 +7504,7 @@ state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** diff --git a/packages/lex-parser/dist/lex-parser-umd.js b/packages/lex-parser/dist/lex-parser-umd.js index a7a89a9ae..6f4fc2ac8 100644 --- a/packages/lex-parser/dist/lex-parser-umd.js +++ b/packages/lex-parser/dist/lex-parser-umd.js @@ -1,8 +1,8 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@gerhobbelt/xregexp'), require('@gerhobbelt/json5'), require('fs'), require('path'), require('recast'), require('@babel/core'), require('assert')) : - typeof define === 'function' && define.amd ? define(['@gerhobbelt/xregexp', '@gerhobbelt/json5', 'fs', 'path', 'recast', '@babel/core', 'assert'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['lex-parser'] = factory(global.XRegExp, global.JSON5, global.fs, global.path$1, global.recast, global.babel, global.assert$1)); -}(this, (function (XRegExp, JSON5, fs, path$1, recast, babel, assert$1) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@gerhobbelt/xregexp'), require('@gerhobbelt/json5'), require('fs'), require('path'), require('mkdirp'), require('recast'), require('@babel/core'), require('assert')) : + typeof define === 'function' && define.amd ? define(['@gerhobbelt/xregexp', '@gerhobbelt/json5', 'fs', 'path', 'mkdirp', 'recast', '@babel/core', 'assert'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global['lex-parser'] = factory(global.XRegExp, global.JSON5, global.fs, global.path$1, global.mkdirp, global.recast, global.babel, global.assert$1)); +}(this, (function (XRegExp, JSON5, fs, path$1, mkdirp, recast, babel, assert$1) { 'use strict'; function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } @@ -10,10 +10,11 @@ var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5); var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); + var mkdirp__default = /*#__PURE__*/_interopDefaultLegacy(mkdirp); var recast__default = /*#__PURE__*/_interopDefaultLegacy(recast); var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$1); - // Return TRUE if `src` starts with `searchString`. + // Return TRUE if `src` starts with `searchString`. function startsWith(src, searchString) { return src.substr(0, searchString.length) === searchString; } @@ -36,19 +37,19 @@ // As `strings[]` is an array of strings, each potentially consisting // of multiple lines, followed by one(1) value, we have to split each // individual string into lines to keep that bit of information intact. - // + // // We assume clean code style, hence no random mix of tabs and spaces, so every // line MUST have the same indent style as all others, so `length` of indent // should suffice, but the way we coded this is stricter checking as we look // for the *exact* indenting=leading whitespace in each line. - var indent_str = null; - var src = strings.map(function splitIntoLines(s) { - var a = s.split('\n'); - + let indent_str = null; + let src = strings.map(function splitIntoLines(s) { + let a = s.split('\n'); + indent_str = a.reduce(function analyzeLine(indent_str, line, index) { // only check indentation of parts which follow a NEWLINE: if (index !== 0) { - var m = /^(\s*)\S/.exec(line); + let m = /^(\s*)\S/.exec(line); // only non-empty ~ content-carrying lines matter re common indent calculus: if (m) { if (indent_str == null) { @@ -67,19 +68,21 @@ // Also note: due to the way we format the template strings in our sourcecode, // the last line in the entire template must be empty when it has ANY trailing // whitespace: - var a = src[src.length - 1]; - a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + { + let a = src[src.length - 1]; + a[a.length - 1] = a[a.length - 1].replace(/\s+$/, ''); + } // Done removing common indentation. - // + // // Process template string partials now, but only when there's // some actual UNindenting to do: if (indent_str) { - for (var i = 0, len = src.length; i < len; i++) { - var a = src[i]; + for (let i = 0, len = src.length; i < len; i++) { + let a = src[i]; // only correct indentation at start of line, i.e. only check for // the indent after every NEWLINE ==> start at j=1 rather than j=0 - for (var j = 1, linecnt = a.length; j < linecnt; j++) { + for (let j = 1, linecnt = a.length; j < linecnt; j++) { if (startsWith(a[j], indent_str)) { a[j] = a[j].substr(indent_str.length); } @@ -88,16 +91,19 @@ } // now merge everything to construct the template result: - var rv = []; - for (var i = 0, len = values.length; i < len; i++) { + { + let rv = []; + let i = 0; + for (let len = values.length; i < len; i++) { + rv.push(src[i].join('\n')); + rv.push(values[i]); + } + // the last value is always followed by a last template string partial: rv.push(src[i].join('\n')); - rv.push(values[i]); - } - // the last value is always followed by a last template string partial: - rv.push(src[i].join('\n')); - var sv = rv.join(''); - return sv; + let sv = rv.join(''); + return sv; + } } // Convert dashed option keys to Camel Case, e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` @@ -108,27 +114,79 @@ return match.toLowerCase(); }) .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + const c = match.charAt(1); + const rv = c.toUpperCase(); // do not mutate 'a-2' to 'a2': if (c === rv && c.match(/\d/)) { return match; } return rv; - }) + }); } + // https://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words + const reservedWords = ((list) => { + let rv = new Set(); + for (let w of list) { + //console.error('reserved word:', w); + rv.add(w); + } + return rv; + })([ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'new', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield' + ]); + // Convert dashed option keys and other inputs to Camel Cased legal JavaScript identifiers /** @public */ function mkIdentifier(s) { s = '' + s; - return s - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + let rv = s + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); @@ -146,6 +204,11 @@ .replace(/__+$/, '#') .replace(/_+/g, '_') .replace(/#/g, '__'); + + if (reservedWords.has(rv)) { + rv = '_' + rv; + } + return rv; } // Check if the start of the given input matches a regex expression. @@ -154,13 +217,13 @@ function scanRegExp(s) { s = '' + s; // code based on Esprima scanner: `Scanner.prototype.scanRegExpBody()` - var index = 0; - var length = s.length; - var ch = s[index]; + let index = 0; + let length = s.length; + let ch = s[index]; //assert.assert(ch === '/', 'Regular expression literal must start with a slash'); - var str = s[index++]; - var classMarker = false; - var terminated = false; + let str = s[index++]; + let classMarker = false; + let terminated = false; while (index < length) { ch = s[index++]; str += ch; @@ -171,23 +234,17 @@ break; // UnterminatedRegExp } str += ch; - } - else if (isLineTerminator(ch.charCodeAt(0))) { + } else if (isLineTerminator(ch.charCodeAt(0))) { break; // UnterminatedRegExp - } - else if (classMarker) { + } else if (classMarker) { if (ch === ']') { classMarker = false; } - } - else { - if (ch === '/') { - terminated = true; - break; - } - else if (ch === '[') { - classMarker = true; - } + } else if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; } } if (!terminated) { @@ -210,34 +267,33 @@ /** @public */ function isLegalIdentifierInput(s) { s = '' + s; - // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), + // Convert dashed ids to Camel Case (though NOT lowercasing the initial letter though!), // e.g. `camelCase('camels-have-one-hump')` => `'camelsHaveOneHump'` let ref = s .replace(/-\w/g, function (match) { - var c = match.charAt(1); - var rv = c.toUpperCase(); + let c = match.charAt(1); + let rv = c.toUpperCase(); // mutate 'a-2' to 'a_2': if (c === rv && c.match(/\d/)) { return '_' + match.substr(1); } return rv; }); - var alt = mkIdentifier(s); + let alt = mkIdentifier(s); return alt === ref; } // properly quote and escape the given input string function dquote(s) { - var sq = (s.indexOf('\'') >= 0); - var dq = (s.indexOf('"') >= 0); + let sq = (s.indexOf('\'') >= 0); + let dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; - } - else { + } else { s = '"' + s + '"'; } return s; @@ -260,28 +316,76 @@ // Helper function: pad number with leading zeroes function pad(n, p) { p = p || 2; - var rv = '0000' + n; + let rv = '0000' + n; return rv.slice(-p); } + function convertExceptionToObject(ex) { + if (!ex) return ex; + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error + // + // - Copy enumerable properties (which may exist when this is a custom exception class derived off Error) + let rv = Object.assign({}, ex); + // - Set up the default fields which should ALWAYS be present: + rv.message = ex.message; + rv.name = ex.name; + rv.stack = ex.stack; // this assignment stringifies the stack trace in ex.stack. + // - Set the optional fields: + if (ex.code !== undefined) rv.code = ex.code; + if (ex.type !== undefined) rv.type = ex.type; + if (ex.fileName !== undefined) rv.fileName = ex.fileName; + if (ex.lineNumber !== undefined) rv.lineNumber = ex.lineNumber; + if (ex.columnNumber !== undefined) rv.columnNumber = ex.columnNumber; + if (Array.isArray(ex.errors)) { + rv.errors = []; + for (let se of ex.errors) { + rv.errors.push(convertExceptionToObject(se)); + } + } + return rv; + } + + + function find_suitable_app_dump_path() { + return process.cwd() + .replace(/\\/g, '/') + .replace(/\/node_modules\/.*$/, (m) => '/___nm___/') + .replace(/(\/jison\/)(.*)$/, (m, p1, p2) => p1 + '___' + p2.split('/').map((d) => d.charAt(0).toUpperCase()).join('_')); + } + // attempt to dump in one of several locations: first winner is *it*! function dumpSourceToFile(sourcecode, errname, err_id, options, ex) { - var dumpfile; + let dumpfile; options = options || {}; try { - var dumpPaths = [(options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, process.cwd()]; - var dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) + const dumpPaths = [ (options.outfile ? path__default['default'].dirname(options.outfile) : null), options.inputPath, find_suitable_app_dump_path() ]; + let dumpName = path__default['default'].basename(options.inputFilename || options.moduleName || (options.outfile ? path__default['default'].dirname(options.outfile) : null) || options.defaultModuleName || errname) .replace(/\.[a-z]{1,5}$/i, '') // remove extension .y, .yacc, .jison, ...whatever - .replace(/[^a-z0-9_]/ig, '_'); // make sure it's legal in the destination filesystem: the least common denominator. + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 100); if (dumpName === '' || dumpName === '_') { dumpName = '__bugger__'; } + + // generate a stacktrace for the dump no matter what: + if (!ex) { + try { + throw new Error("Not an error: only fetching stacktrace in sourcecode dump helper so you can see which code invoked this."); + } catch (ex2) { + ex = ex2; + } + } + err_id = err_id || 'XXX'; + err_id = err_id + .replace(/[^a-z0-9_]/ig, '_') // make sure it's legal in the destination filesystem: the least common denominator. + .substr(0, 50); - var ts = new Date(); - var tm = ts.getUTCFullYear() + + const ts = new Date(); + const tm = ts.getUTCFullYear() + '_' + pad(ts.getUTCMonth() + 1) + '_' + pad(ts.getUTCDate()) + 'T' + pad(ts.getUTCHours()) + @@ -292,27 +396,37 @@ dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js'; - for (var i = 0, l = dumpPaths.length; i < l; i++) { + for (let i = 0, l = dumpPaths.length; i < l; i++) { if (!dumpPaths[i]) { continue; } try { - dumpfile = path__default['default'].normalize(dumpPaths[i] + '/' + dumpName); + dumpfile = path__default['default'].normalize(path__default['default'].join(dumpPaths[i], dumpName)); - let dump = { + const dump = { errname, err_id, options, - ex, + ex: convertExceptionToObject(ex) }; - let d = JSON5__default['default'].stringify(dump, null, 2); + let d = JSON5__default['default'].stringify(dump, { + replacer: function remove_lexer_objrefs(key, value) { + if (value instanceof Error) { + return convertExceptionToObject(value); + } + return value; + }, + space: 2, + circularRefHandler: (value, circusPos, stack, keyStack, key, err) => '[!circular ref!]', + }); // make sure each line is a comment line: d = d.split('\n').map((l) => '// ' + l); d = d.join('\n'); + mkdirp__default['default'](path__default['default'].dirname(dumpfile)); fs__default['default'].writeFileSync(dumpfile, sourcecode + '\n\n\n' + d, 'utf8'); - console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile); + console.error('****** offending generated ' + errname + ' source code dumped into file: ', dumpfile); break; // abort loop once a dump action was successful! } catch (ex3) { //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack); @@ -322,7 +436,7 @@ } } } catch (ex2) { - console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack); + console.error('generated ' + errname + ' source code fatal DUMPING error: ', ex2.message, ' -- while attempting to dump into file: ', dumpfile, '\n', ex2.stack); } // augment the exception info, when available: @@ -330,7 +444,7 @@ ex.offending_source_code = sourcecode; ex.offending_source_title = errname; ex.offending_source_dumpfile = dumpfile; - } + } } @@ -356,27 +470,43 @@ // function exec_and_diagnose_this_stuff(sourcecode, code_execution_rig, options, title) { options = options || {}; - var errname = "" + (title || "exec_test"); - var err_id = errname.replace(/[^a-z0-9_]/ig, "_"); + let errname = '' + (title || 'exec_test'); + let err_id = errname.replace(/[^a-z0-9_]/ig, '_'); if (err_id.length === 0) { - err_id = "exec_crash"; + err_id = 'exec_crash'; + } + const debug = options.debug || 0; + + if (debug) console.warn('generated ' + errname + ' code under EXEC TEST.'); + if (debug > 1) { + console.warn(` + ######################## source code ########################## + ${sourcecode} + ######################## source code ########################## + `); } - const debug = 0; - var p; + let p; try { // p = eval(sourcecode); if (typeof code_execution_rig !== 'function') { - throw new Error("safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function"); + throw new Error('safe-code-exec-and-diag: code_execution_rig MUST be a JavaScript function'); } chkBugger(sourcecode); p = code_execution_rig.call(this, sourcecode, options, errname, debug); } catch (ex) { - + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + + if (debug) console.log('generated ' + errname + ' source code fatal error: ', ex.message); + + if (debug > 1) console.log('exec-and-diagnose options:', options); + + if (debug > 1) console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); + if (options.dumpSourceCodeOnFailure || 1) { dumpSourceToFile(sourcecode, errname, err_id, options, ex); } - + if (options.throwErrorOnCompileFailure) { throw ex; } @@ -389,9 +519,10 @@ - var code_exec = { + var exec = { exec: exec_and_diagnose_this_stuff, - dump: dumpSourceToFile + dump: dumpSourceToFile, + convertExceptionToObject, }; // @@ -413,22 +544,22 @@ // // This is the base XRegExp ID regex used in many places; this should match the ID macro definition in the EBNF/BNF parser et al as well! const ID_REGEX_BASE = '[\\p{Alphabetic}_][\\p{Alphabetic}_\\p{Number}]*'; - // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries + // regex set expression which can be used as part of a conditional check to find word/ID/token boundaries // as this lists all characters which are not allowed in an Identifier anywhere: const IN_ID_CHARSET = '\\p{Alphabetic}_\\p{Number}'; - // Determine which Unicode NonAsciiIdentifierStart characters + // Determine which Unicode NonAsciiIdentifierStart characters // are unused in the given sourcecode and provide a mapping array // from given (JISON) start/end identifier character-sequences // to these. - // + // // The purpose of this routine is to deliver a reversible // transform from JISON to plain JavaScript for any action - // code chunks. - // + // code chunks. + // // This is the basic building block which helps us convert // jison variables such as `$id`, `$3`, `$-1` ('negative index' reference), // `@id`, `#id`, `#TOK#` to variable names which can be @@ -436,40 +567,40 @@ function generateMapper4JisonGrammarIdentifiers(input) { // IMPORTANT: we only want the single char Unicodes in here // so we can do this transformation at 'Char'-word rather than 'Code'-codepoint level. - + //const IdentifierStart = unicode4IdStart.filter((e) => e.codePointAt(0) < 0xFFFF); - // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode + // As we will be 'encoding' the Jison Special characters @ and # into the IDStart Unicode // range to make JavaScript parsers *not* barf a hairball on Jison action code chunks, we // must consider a few things while doing that: - // + // // We CAN use an escape system where we replace a single character with multiple characters, // as JavaScript DOES NOT discern between single characters and multi-character strings: anything - // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is + // between quotes is a string and there's no such thing as C/C++/C#'s `'c'` vs `"c"` which is // *character* 'c' vs *string* 'c'. - // + // // As we can safely escape characters, all we need to do is find a character (or set of characters) // which are in the ID_Start range and are expected to be used rarely while clearly identifyable // by humans for ease of debugging of the escaped intermediate values. - // + // // The escape scheme is simple and borrowed from ancient serial communication protocols and // the JavaScript string spec alike: - // + // // - assume the escape character is A // - then if the original input stream includes an A, we output AA // - if the original input includes a character #, which must be escaped, it is encoded/output as A - // + // // This is the same as the way the backslash escape in JavaScript strings works and has a minor issue: // sequences of AAA with an odd number of A's CAN occur in the output, which might be a little hard to read. // Those are, however, easily machine-decodable and that's what's most important here. - // - // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to + // + // To help with that AAA... issue AND because we need to escape multiple Jison markers, we choose to // a slightly tweaked approach: we are going to use a set of 2-char wide escape codes, where the - // first character is fixed and the second character is chosen such that the escape code - // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input + // first character is fixed and the second character is chosen such that the escape code + // DOES NOT occur in the original input -- unless someone would have intentionally fed nasty input // to the encoder as we will pick the 2 characters in the escape from 2 utterly different *human languages*: - // - // - the first character is ဩ which is highly visible and allows us to quickly search through a + // + // - the first character is ဩ which is highly visible and allows us to quickly search through a // source to see if and where there are *any* Jison escapes. // - the second character is taken from the Unicode CANADIAN SYLLABICS range (0x1400-0x1670) as far as // those are part of ID_Start (0x1401-0x166C or there-abouts) and, unless an attack is attempted at jison, @@ -477,30 +608,30 @@ // writes such a escape in the comments to document this system, e.g. 'ဩᐅ', then there's still plenty // alternatives for the second character left. // - the second character represents the escape type: $-n, $#, #n, @n, #ID#, etc. and each type will - // pick a different base shape from that CANADIAN SYLLABICS charset. - // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to + // pick a different base shape from that CANADIAN SYLLABICS charset. + // - note that the trailing '#' in Jison's '#TOKEN#' escape will be escaped as a different code to // signal '#' as a token terminator there. // - meanwhile, only the initial character in the escape needs to be escaped if encountered in the // original text: ဩ -> ဩဩ as the 2nd and 3rd character are only there to *augment* the escape. // Any CANADIAN SYLLABICS in the original input don't need escaping, as these only have special meaning // when prefixed with ဩ - // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered + // - if the ဩ character is used often in the text, the alternative ℹ இ ண ஐ Ϟ ല ઊ characters MAY be considered // for the initial escape code, hence we start with analyzing the entire source input to see which // escapes we'll come up with this time. // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -511,59 +642,59 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // - + // + // count the number of occurrences of ch in src: - // + // // function countOccurrences(ch, src) { // let cnt = 0; // let offset = 0; @@ -605,38 +736,38 @@ return set[lsidx]; } - const escCharSet = "ဩ ℹ இ ண ஐ Ϟ ല ઊ"; + const escCharSet = 'ဩ ℹ இ ண ஐ Ϟ ല ઊ'; // Currently we only need 7 rows of typeIdCharSets. The other rows are commented out but available for future use: const typeIdCharSets = [ - "ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ", + 'ᐁ ᐂ ᐃ ᐄ ᐅ ᐆ ᐇ ᐈ ᐉ ᐊ ᐋ ᐌ ᐍ ᐎ ᐏ ᐐ ᐑ ᐒ ᐓ ᐔ ᐕ ᐖ ᐗ ᐘ ᐙ ᐚ ᐛ ᐫ ᐬ ᐭ ᐮ', //"ᐯ ᐰ ᐱ ᐲ ᐳ ᐴ ᐵ ᐶ ᐷ ᐸ ᐹ ᐺ ᐻ ᐼ ᐽ ᐾ ᐿ ᑀ ᑁ ᑂ ᑃ ᑄ ᑅ ᑆ ᑇ ᑈ", - "ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ", - "ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ", + 'ᑌ ᑍ ᑎ ᑏ ᑐ ᑑ ᑒ ᑓ ᑔ ᑕ ᑖ ᑗ ᑘ ᑙ ᑚ ᑛ ᑜ ᑝ ᑞ ᑟ ᑠ ᑡ ᑢ ᑣ ᑤ ᑥ ᑧ ᑨ ᑩ ᑪ', + 'ᑫ ᑬ ᑭ ᑮ ᑯ ᑰ ᑱ ᑲ ᑳ ᑴ ᑵ ᑶ ᑷ ᑸ ᑹ ᑺ ᑻ ᑼ ᑽ ᑾ ᑿ ᒀ ᒁ ᒂ ᒅ ᒆ ᒇ ᒈ', //"ᒉ ᒊ ᒋ ᒌ ᒍ ᒎ ᒏ ᒐ ᒑ ᒒ ᒓ ᒔ ᒕ ᒖ ᒗ ᒘ ᒙ ᒚ ᒛ ᒜ ᒝ ᒞ ᒟ ᒠ", //"ᒣ ᒤ ᒥ ᒦ ᒧ ᒨ ᒩ ᒪ ᒫ ᒬ ᒭ ᒮ ᒯ ᒰ ᒱ ᒲ ᒳ ᒴ ᒵ ᒶ ᒷ ᒸ ᒹ ᒺ", //"ᓓ ᓔ ᓕ ᓖ ᓗ ᓘ ᓙ ᓚ ᓛ ᓜ ᓝ ᓞ ᓟ ᓠ ᓡ ᓢ ᓣ ᓤ ᓥ ᓦ ᓧ ᓨ ᓩ", //"ᓭ ᓮ ᓯ ᓰ ᓱ ᓲ ᓳ ᓴ ᓵ ᓶ ᓷ ᓸ ᓹ ᓺ ᓻ ᓼ ᓽ ᓾ ᓿ ᔀ ᔁ ᔂ ᔃ ᔄ", //"ᔐ ᔑ ᔒ ᔓ ᔔ ᔕ ᔖ ᔗ ᔘ ᔙ ᔚ ᔛ ᔜ ᔝ ᔞ ᔟ ᔠ ᔡ ᔢ ᔣ ᔤ", - "ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ", + 'ᔦ ᔧ ᔨ ᔩ ᔪ ᔫ ᔬ ᔭ ᔮ ᔯ ᔰ ᔱ ᔲ ᔳ ᔴ ᔵ ᔶ ᔷ ᔸ ᔹ ᔺ ᔻ ᔼ ᔽ', //"ᓀ ᓁ ᓂ ᓃ ᓄ ᓅ ᓆ ᓇ ᓈ ᓉ ᓊ ᓋ ᓌ ᓍ ᓎ ᓏ", //"ᕂ ᕃ ᕄ ᕅ ᕆ ᕇ ᕈ ᕉ ᕊ ᕋ ᕌ ᕍ ᕎ ᕏ", //"ᕞ ᕟ ᕠ ᕡ ᕢ ᕣ ᕤ ᕥ ᕦ ᕧ ᕨ ᕩ", //"ᖸ ᖹ ᖺ ᖻ ᖼ ᖽ ᖾ ᖿ ᗀ ᗁ ᗂ ᗃ", - "ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ", + 'ᗜ ᗝ ᗞ ᗟ ᗠ ᗡ ᗢ ᗣ ᗤ ᗥ ᗦ ᗧ ᗨ ᗩ ᗪ ᗫ ᗬ ᗭ', //"ᗯ ᗰ ᗱ ᗲ ᗳ ᗴ ᗵ ᗶ ᗷ ᗸ ᗹ ᗺ ᗻ ᗼ ᗽ ᗾ ᗿ ᘀ", - "ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ", + 'ᘔ ᘕ ᘖ ᘗ ᘘ ᘙ ᘚ ᘛ ᘜ ᘝ ᘞ ᘟ ᘠ ᘡ', //"ᘢ ᘣ ᘤ ᘥ ᘦ ᘧ ᘨ ᘩ ᘪ ᘫ ᘬ ᘭ ᘴ ᘵ ᘶ ᘷ ᘸ ᘹ", //"ᕓ ᕔ ᕕ ᕖ ᕗ ᕘ ᕙ ᕚ ᕛ ᕜ", - "ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ", + 'ᗄ ᗅ ᗆ ᗇ ᗈ ᗉ ᗊ ᗋ ᗌ ᗍ ᗎ ᗏ ᗐ ᗑ ᗒ ᗓ ᗔ ᗕ ᗖ ᗗ ᗘ ᗙ ᗚ ᗛ' ]; - //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) + //const I = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ'; // 1..12, but accepted as IdentifierStart in JavaScript :-) // Probable speed improvement: scan a single time through the (probably large) input source, // looking for all characters in parallel, instead of scanning N times through there: // construct a regex to dig out all potential occurrences and take it from there. - let reStr = escCharSet + typeIdCharSets.join(""); + let reStr = escCharSet + typeIdCharSets.join(''); reStr = reStr.replace(/\s+/g, ''); const re = new RegExp(`[${reStr}]`, 'g'); var hash = new Array(0xD800); @@ -648,18 +779,18 @@ // // The basic shapes are: - // + // // - 1401-141B: ᐁ 1 // - 142F-1448: ᐯ 2 // - 144C-1465: ᑌ 3 // - 146B-1482: ᑫ 4 - // - 1489-14A0: ᒉ 5 - // - 14A3-14BA: ᒣ 6 - // - 14C0-14CF: ᓀ + // - 1489-14A0: ᒉ 5 + // - 14A3-14BA: ᒣ 6 + // - 14C0-14CF: ᓀ // - 14D3-14E9: ᓓ 7 // - 14ED-1504: ᓭ 8 // - 1510-1524: ᔐ 9 - // - 1526-153D: ᔦ + // - 1526-153D: ᔦ // - 1542-154F: ᕂ // - 1553-155C: ᕓ // - 155E-1569: ᕞ @@ -670,56 +801,56 @@ // - 1622-162D: ᘢ // // ## JISON identifier formats ## - // + // // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1+2) start-# + end-# - // + // // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ - // + // // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# - // + // // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# - // + // // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required - // + // // - result location reference `@$` - // + // // -> (6) single-@ - // + // // - rule id number `#$` - // + // // -> (3) single-# - // + // // - result stack index `##$` - // + // // -> (4) double-# - // + // // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ - // + // // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ - // + // // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# - // + // const escChar = pickChar(escCharSet); let typeIdChar = []; @@ -727,97 +858,97 @@ typeIdChar[i] = pickChar(typeIdCharSets[i]); } - // produce a function set for encoding and decoding content, + // produce a function set for encoding and decoding content, // plus the basic strings to build regexes for matching the various jison // identifier types: return { // - direct symbol references, e.g. `#NUMBER#` when there's a `%token NUMBER` for your grammar. // These represent the token ID number. - // + // // -> (1) start-# tokenDirectIdentifierStart: escChar + typeIdChar[0], tokenDirectIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})#`, 'g'), // - alias/token value references, e.g. `$token`, `$2` - // + // // -> $ is an accepted starter, so no encoding required // - result value reference `$$` - // + // // -> $ is an accepted starter, so no encoding required tokenValueReferenceStart: '$', tokenValueReferenceRe: new XRegExp__default['default'](`$(${ID_REGEX_BASE})|$([0-9]+)`, 'g'), // - alias/token location reference, e.g. `@token`, `@2` - // + // // -> (6) single-@ // - result location reference `@$` - // + // // -> (6) single-@ tokenLocationStart: escChar + typeIdChar[1], tokenLocationRe: new XRegExp__default['default'](`@(${ID_REGEX_BASE})|@([0-9]+)`, 'g'), // - alias/token id numbers, e.g. `#token`, `#2` - // + // // -> (3) single-# // - rule id number `#$` - // + // // -> (3) single-# tokenIdentifierStart: escChar + typeIdChar[2], tokenIdentifierRe: new XRegExp__default['default'](`#(${ID_REGEX_BASE})|#([0-9]+)`, 'g'), - + // - alias/token stack indexes, e.g. `##token`, `##2` - // + // // -> (4) double-# // - result stack index `##$` - // + // // -> (4) double-# tokenStackIndexStart: escChar + typeIdChar[3], tokenStackIndexRe: new XRegExp__default['default'](`##(${ID_REGEX_BASE})|##([0-9]+)`, 'g'), // - 'negative index' value references, e.g. `$-2` - // + // // -> (8) single-negative-$ tokenNegativeValueReferenceStart: escChar + typeIdChar[4], - tokenValueReferenceRe: new XRegExp__default['default'](`$-([0-9]+)`, 'g'), - + tokenValueReferenceRe: new XRegExp__default['default']('$-([0-9]+)', 'g'), + // - 'negative index' location reference, e.g. `@-2` - // + // // -> (7) single-negative-@ tokenNegativeLocationStart: escChar + typeIdChar[5], - tokenNegativeLocationRe: new XRegExp__default['default'](`@-([0-9]+)`, 'g'), - + tokenNegativeLocationRe: new XRegExp__default['default']('@-([0-9]+)', 'g'), + // - 'negative index' stack indexes, e.g. `##-2` - // + // // -> (5) double-negative-# tokenNegativeStackIndexStart: escChar + typeIdChar[6], - tokenNegativeStackIndexRe: new XRegExp__default['default'](`#-([0-9]+)`, 'g'), + tokenNegativeStackIndexRe: new XRegExp__default['default']('#-([0-9]+)', 'g'), // combined regex for encoding direction tokenDetect4EncodeRe: new XRegExp__default['default'](`([^$@#${IN_ID_CHARSET}])([$@#]|##)(${ID_REGEX_BASE}|[$]|-?[0-9]+)(#?)(?![$@#${IN_ID_CHARSET}])`, 'g'), // combined regex for decoding direction - tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0,7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), + tokenDetect4DecodeRe: new XRegExp__default['default'](`([^$${IN_ID_CHARSET}])(${escChar}[${typeIdChar.slice(0, 7).join('')}])(${ID_REGEX_BASE}|[$]|[0-9]+)(?![$@#${IN_ID_CHARSET}])`, 'g'), encode: function encodeJisonTokens(src, locationOffsetSpec) { let re = this.tokenDetect4EncodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, p4, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case '$': // no encoding required UNLESS it's a negative index; p4 MUST be empty @@ -825,7 +956,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeValueReferenceStart + p3.substring(1); @@ -838,7 +969,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeStackIndexStart + p3.substring(1); @@ -851,7 +982,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3} cannot be followed by ${p4}`, src, offset + p1.length + p2.length + p3.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p3[0] === '-') { return p1 + this.tokenNegativeLocationStart + p3.substring(1); @@ -864,7 +995,7 @@ if (locationOffsetSpec) { locationOffsetSpec.reportLocation(`syntax error: ${p2 + p3 + p4} is an illegal negative reference type`, src, offset + p1.length + p2.length); } - return p1 + p2 +p3 + p4; + return p1 + p2 + p3 + p4; } if (p4 !== '') { return p1 + this.tokenDirectIdentifierStart + p3; @@ -883,37 +1014,37 @@ let re = this.tokenDetect4DecodeRe; // reset regex - re.lastIndex = 0; + re.lastIndex = 0; // patch `src` for the lookbehind emulation in the main regex used: src = ' ' + src; // Perform the encoding, one token at a time via callback function. - // + // // Note: all erroneous inputs are IGNORED as those MAY be part of a string // or comment, where they are perfectly legal. - // This is a tad sub-optimal as we won't be able to report errors early + // This is a tad sub-optimal as we won't be able to report errors early // but otherwise we would be rejecting some potentially *legal* action code // and we DO NOT want to be pedantically strict while we are unable to parse // the input very precisely yet. src = src.replace(re, (m, p1, p2, p3, offset) => { // p1 is only serving as lookbehind emulation - + switch (p2) { case this.tokenNegativeValueReferenceStart: - return p1 + "$-" + p3; + return p1 + '$-' + p3; case this.tokenNegativeStackIndexStart: - return p1 + "##-" + p3; + return p1 + '##-' + p3; case this.tokenStackIndexStart: - return p1 + "##" + p3; + return p1 + '##' + p3; case this.tokenNegativeLocationStart: - return p1 + "@-" + p3; + return p1 + '@-' + p3; case this.tokenLocationStart: - return p1 + "@" + p3; + return p1 + '@' + p3; case this.tokenDirectIdentifierStart: // p3 CANNOT be a negative value or token ID @@ -945,7 +1076,7 @@ // and remove the added prefix which was used for lookbehind emulation: return src.substring(1); - }, + } }; } @@ -962,37 +1093,37 @@ .replace(/@/g, '\uFFDA') .replace(/#/g, '\uFFDB') ; - var ast = recast__default['default'].parse(src); + const ast = recast__default['default'].parse(src); return ast; } function compileCodeToES5(src, options) { options = Object.assign({}, { - ast: true, - code: true, - sourceMaps: true, - comments: true, - filename: 'compileCodeToES5.js', - sourceFileName: 'compileCodeToES5.js', - sourceRoot: '.', - sourceType: 'module', - - babelrc: false, - - ignore: [ - "node_modules/**/*.js" - ], - compact: false, - retainLines: false, - presets: [ - ["@babel/preset-env", { - targets: { - browsers: ["last 2 versions"], - node: "8.0" - } - }] - ] + ast: true, + code: true, + sourceMaps: true, + comments: true, + filename: 'compileCodeToES5.js', + sourceFileName: 'compileCodeToES5.js', + sourceRoot: '.', + sourceType: 'module', + + babelrc: false, + + ignore: [ + 'node_modules/**/*.js' + ], + compact: false, + retainLines: false, + presets: [ + [ '@babel/preset-env', { + targets: { + browsers: [ 'last 2 versions' ], + node: '8.0' + } + } ] + ] }, options); return babel.transformSync(src, options); // => { code, map, ast } @@ -1000,8 +1131,8 @@ function prettyPrintAST(ast, options) { - var options = options || {}; - const defaultOptions = { + options = options || {}; + const defaultOptions = { tabWidth: 2, quote: 'single', arrowParensAlways: true, @@ -1010,7 +1141,7 @@ // when printing generically. reuseWhitespace: false }; - for (var key in defaultOptions) { + for (let key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key]; } @@ -1033,25 +1164,25 @@ // validate the given JISON+JavaScript snippet: does it compile? - // - // Return either the parsed AST (object) or an error message (string). + // + // Return either the parsed AST (object) or an error message (string). function checkActionBlock(src, yylloc, options) { // make sure reasonable line numbers, etc. are reported in any // potential parse errors by pushing the source code down: if (yylloc && yylloc.first_line > 0) { - var cnt = yylloc.first_line; - var lines = new Array(cnt); + let cnt = yylloc.first_line; + let lines = new Array(cnt); src = lines.join('\n') + src; - } + } if (!src.trim()) { return false; } try { - var rv = parseCodeChunkToAST(src, options); + let rv = parseCodeChunkToAST(src, options); return false; } catch (ex) { - return ex.message || "code snippet cannot be parsed"; + return ex.message || 'code snippet cannot be parsed'; } } @@ -1062,9 +1193,9 @@ // trailing semicolons and/or wrapping `{...}` braces, // when such is easily possible *without having to actually // **parse** the `src` code block in order to do this safely*. - // + // // Returns the trimmed sourcecode which was provided via `src`. - // + // // Note: the `startMarker` argument is special in that a lexer/parser // can feed us the delimiter which started the code block here: // when the starting delimiter actually is `{` we can safely @@ -1072,7 +1203,7 @@ // while otherwise we may *not* do so as complex/specially-crafted // code will fail when it was wrapped in other delimiters, e.g. // action code specs like this one: - // + // // %{ // { // trimActionCode sees this one as outer-starting: WRONG // a: 1 @@ -1081,14 +1212,14 @@ // b: 2 // } // trimActionCode sees this one as outer-ending: WRONG // %} - // + // // Of course the example would be 'ludicrous' action code but the - // key point here is that users will certainly be able to come up with + // key point here is that users will certainly be able to come up with // convoluted code that is smarter than our simple regex-based // `{...}` trimmer in here! - // + // function trimActionCode(src, startMarker) { - var s = src.trim(); + let s = src.trim(); // remove outermost set of braces UNLESS there's // a curly brace in there anywhere: in that case // we should leave it up to the sophisticated @@ -1142,7 +1273,7 @@ trimActionCode, ID_REGEX_BASE, - IN_ID_CHARSET, + IN_ID_CHARSET }; function chkBugger$1(src) { @@ -1156,7 +1287,7 @@ /// HELPER FUNCTION: print the function in source code form, properly indented. /** @public */ function printFunctionSourceCode(f) { - var src = String(f); + const src = String(f); chkBugger$1(src); return src; } @@ -1168,24 +1299,24 @@ /// HELPER FUNCTION: print the function **content** in source code form, properly indented, /// ergo: produce the code for inlining the function. - /// + /// /// Also supports ES6's Arrow Functions: - /// + /// /// ``` /// function a(x) { return x; } ==> 'return x;' /// function (x) { return x; } ==> 'return x;' /// (x) => { return x; } ==> 'return x;' /// (x) => x; ==> 'return x;' /// (x) => do(1), do(2), x; ==> 'return (do(1), do(2), x);' - /// + /// /** @public */ function printFunctionSourceCodeContainer(f) { - var action = printFunctionSourceCode(f).trim(); - var args; + let action = printFunctionSourceCode(f).trim(); + let args; // Also cope with Arrow Functions (and inline those as well?). // See also https://github.com/zaach/jison-lex/issues/23 - var m = funcRe.exec(action); + let m = funcRe.exec(action); if (m) { args = m[1].trim(); action = m[2].trim(); @@ -1202,8 +1333,8 @@ if (m[5]) { // non-bracketed version: implicit `return` statement! // - // Q: Must we make sure we have extra braces around the return value - // to prevent JavaScript from inserting implit EOS (End Of Statement) + // Q: Must we make sure we have extra braces around the return value + // to prevent JavaScript from inserting implit EOS (End Of Statement) // markers when parsing this, when there are newlines in the code? // A: No, we don't have to as arrow functions rvalues suffer from this // same problem, hence the arrow function's programmer must already @@ -1214,14 +1345,14 @@ action = m[3].trim(); } } else { - var e = new Error('Cannot extract code from function'); + const e = new Error('Cannot extract code from function'); e.subject = action; throw e; } } return { args: args, - code: action, + code: action }; } @@ -1232,17 +1363,17 @@ var stringifier = { - printFunctionSourceCode, - printFunctionSourceCodeContainer, + printFunctionSourceCode, + printFunctionSourceCodeContainer }; - // - // - // + // + // + // function detectIstanbulGlobal() { - const gcv = "__coverage__"; + const gcv = '__coverage__'; const globalvar = new Function('return this')(); - var coverage = globalvar[gcv]; + const coverage = globalvar[gcv]; return coverage || false; } @@ -1268,7 +1399,7 @@ // // Return FALSE when there's no failure, otherwise return an `Error` info object. function checkRegExp(re_src, re_flags, XRegExp) { - var re; + let re; // were we fed a RegExp object or a string? if (re_src @@ -1316,7 +1447,7 @@ // // Return FALSE when the input is not a legal regex. function getRegExpInfo(re_src, re_flags, XRegExp) { - var re1, re2, m1, m2; + let re1, re2, m1, m2; // were we fed a RegExp object or a string? if (re_src @@ -1379,13 +1510,13 @@ getRegExpInfo: getRegExpInfo }; - var cycleref = []; - var cyclerefpath = []; + let cycleref = []; + let cyclerefpath = []; - var linkref = []; - var linkrefpath = []; + let linkref = []; + let linkrefpath = []; - var path = []; + let path = []; function shallow_copy(src) { if (typeof src === 'object') { @@ -1393,14 +1524,14 @@ return src.slice(); } - var dst = {}; + let dst = {}; if (src instanceof Error) { dst.name = src.name; dst.message = src.message; dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { dst[k] = src[k]; } @@ -1413,11 +1544,11 @@ function shallow_copy_and_strip_depth(src, parentKey) { if (typeof src === 'object') { - var dst; + let dst; if (src instanceof Array) { dst = src.slice(); - for (var i = 0, len = dst.length; i < len; i++) { + for (let i = 0, len = dst.length; i < len; i++) { path.push('[' + i + ']'); dst[i] = shallow_copy_and_strip_depth(dst[i], parentKey + '[' + i + ']'); path.pop(); @@ -1430,9 +1561,9 @@ dst.stack = src.stack; } - for (var k in src) { + for (let k in src) { if (Object.prototype.hasOwnProperty.call(src, k)) { - var el = src[k]; + let el = src[k]; if (el && typeof el === 'object') { dst[k] = '[cyclic reference::attribute --> ' + parentKey + '.' + k + ']'; } else { @@ -1447,16 +1578,52 @@ } + // strip developer machine specific parts off any paths in a given stacktrace (string) + // to ease cross-platform comparison of these stacktraces. function stripErrorStackPaths(msg) { // strip away devbox-specific paths in error stack traces in the output: + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': msg = msg - .replace(/\bat ([^\r\n(\\\/]*?)\([^)]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)\)/gi, 'at $1(/$2)') - .replace(/\bat [^\r\n ]+?[\\\/]([a-z0-9_-]+\.js:[0-9]+:[0-9]+)/gi, 'at /$1'); + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2:$3)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1:$2'); return msg; } + // strip off the line/position info from any stacktrace as a assert.deepEqual() on these + // will otherwise FAIL due to us running this stuff through both regular `node` and + // the `nyc` profiler: the latter reformats the sourcecode-under-test, thus producing + // exceptions and stacktraces which point completely somewhere else and this would b0rk + // our test rigs for the jison subpackages. + function cleanStackTrace4Comparison(obj) { + if (typeof obj === 'string') { + // and any `nyc` profiler run added trailing cruft has to go too, e.g. ', :1489:27)': + let msg = obj + .replace(/\bat ([^\r\n(\\\/]+?)\([^)]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)\)(?:, :[0-9]+:[0-9]+\))?/gi, 'at $1(/$2)') + .replace(/\bat [^\r\n ]*?[\\\/]([a-z0-9_-]+\.js):([0-9]+:[0-9]+)/gi, 'at /$1'); + + return msg; + } + + if (obj) { + if (obj.stack) { + obj.stack = cleanStackTrace4Comparison(obj.stack); + } + let keys = Object.keys(obj); + for (let i in keys) { + let key = keys[i]; + let el = obj[key]; + cleanStackTrace4Comparison(el); + } + } + return obj; + } + + + + + function trim_array_tail(arr) { if (arr instanceof Array) { @@ -1471,7 +1638,7 @@ function treat_value_stack(v) { if (v instanceof Array) { - var idx = cycleref.indexOf(v); + let idx = cycleref.indexOf(v); if (idx >= 0) { v = '[cyclic reference to parent array --> ' + cyclerefpath[idx] + ']'; } else { @@ -1497,10 +1664,10 @@ } function treat_error_infos_array(arr) { - var inf = arr.slice(); + let inf = arr.slice(); trim_array_tail(inf); - for (var key = 0, len = inf.length; key < len; key++) { - var err = inf[key]; + for (let key = 0, len = inf.length; key < len; key++) { + let err = inf[key]; if (err) { path.push('[' + key + ']'); @@ -1598,7 +1765,7 @@ function treat_error_report_info(e) { // shallow copy object: e = shallow_copy(e); - + if (e && e.hash) { path.push('hash'); e.hash = treat_hash(e.hash); @@ -1615,7 +1782,7 @@ path.push('lexer'); e.lexer = treat_lexer(e.lexer); path.pop(); - } + } if (e.__error_infos) { path.push('__error_infos'); @@ -1643,7 +1810,7 @@ function treat_object(e) { if (e && typeof e === 'object') { - var idx = cycleref.indexOf(e); + let idx = cycleref.indexOf(e); if (idx >= 0) { // cyclic reference, most probably an error instance. // we still want it to be READABLE in a way, though: @@ -1659,7 +1826,7 @@ linkrefpath.push(path.join('.')); e = treat_error_report_info(e); - + cycleref.pop(); cyclerefpath.pop(); } @@ -1671,14 +1838,14 @@ // strip off large chunks from the Error exception object before // it will be fed to a test log or other output. - // + // // Internal use in the unit test rigs. function trimErrorForTestReporting(e) { cycleref.length = 0; cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; if (e) { e = treat_object(e); @@ -1688,7 +1855,7 @@ cyclerefpath.length = 0; linkref.length = 0; linkrefpath.length = 0; - path = ['*']; + path = [ '*' ]; return e; } @@ -1702,12 +1869,14 @@ dquote, trimErrorForTestReporting, stripErrorStackPaths, + cleanStackTrace4Comparison, checkRegExp: reHelpers.checkRegExp, getRegExpInfo: reHelpers.getRegExpInfo, - exec: code_exec.exec, - dump: code_exec.dump, + exec: exec.exec, + dump: exec.dump, + convertExceptionToObject: exec.convertExceptionToObject, generateMapper4JisonGrammarIdentifiers: parse2AST.generateMapper4JisonGrammarIdentifiers, parseCodeChunkToAST: parse2AST.parseCodeChunkToAST, @@ -1722,7 +1891,7 @@ printFunctionSourceCode: stringifier.printFunctionSourceCode, printFunctionSourceCodeContainer: stringifier.printFunctionSourceCodeContainer, - detectIstanbulGlobal, + detectIstanbulGlobal }; // See also: @@ -1730,7 +1899,6 @@ // 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. function JisonParserError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -1747,9 +1915,9 @@ this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -1782,10 +1950,10 @@ // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -1798,11 +1966,11 @@ // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -1812,18 +1980,18 @@ // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -1854,7 +2022,7 @@ // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -1871,9 +2039,9 @@ // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -1886,7 +2054,7 @@ } - var parser = { + let parser = { // Code Generator Information Report // --------------------------------- // @@ -2136,7 +2304,6 @@ // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - return '"' + id_str + '"'; }, @@ -2144,7 +2311,6 @@ // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -2156,8 +2322,8 @@ // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -2170,14 +2336,13 @@ // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -2193,10 +2358,10 @@ // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -2204,10 +2369,10 @@ this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -2362,9 +2527,9 @@ /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -2376,18 +2541,18 @@ case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2417,9 +2582,9 @@ case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -2432,10 +2597,10 @@ case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2462,9 +2627,9 @@ case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -2473,10 +2638,10 @@ case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2504,9 +2669,9 @@ case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -2515,10 +2680,10 @@ case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -2557,9 +2722,9 @@ case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -2624,9 +2789,9 @@ case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2641,9 +2806,9 @@ case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -2678,10 +2843,10 @@ case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2698,9 +2863,9 @@ case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2717,10 +2882,10 @@ case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2737,9 +2902,9 @@ case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2756,10 +2921,10 @@ case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2776,9 +2941,9 @@ case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -2802,9 +2967,9 @@ case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -2815,9 +2980,9 @@ case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2837,9 +3002,9 @@ case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2863,9 +3028,9 @@ case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -2878,10 +3043,10 @@ case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2898,9 +3063,9 @@ case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -2912,9 +3077,9 @@ case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -2954,10 +3119,10 @@ case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -2977,9 +3142,9 @@ case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3029,10 +3194,10 @@ case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -3056,10 +3221,10 @@ case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3079,10 +3244,10 @@ case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3106,10 +3271,10 @@ case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3130,10 +3295,10 @@ case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3145,10 +3310,10 @@ case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3158,10 +3323,10 @@ case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -3171,10 +3336,10 @@ case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3184,10 +3349,10 @@ case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -3197,10 +3362,10 @@ case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -3210,10 +3375,10 @@ case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3223,10 +3388,10 @@ case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -3236,9 +3401,9 @@ case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -3247,9 +3412,9 @@ case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -3258,9 +3423,9 @@ case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3282,9 +3447,9 @@ case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -3295,9 +3460,9 @@ case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3317,9 +3482,9 @@ case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3373,9 +3538,9 @@ case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3395,9 +3560,9 @@ case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -3406,9 +3571,9 @@ case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -3420,9 +3585,9 @@ case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -3436,10 +3601,10 @@ case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3459,10 +3624,10 @@ case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3482,10 +3647,10 @@ case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3505,9 +3670,9 @@ case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3518,9 +3683,9 @@ case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3539,9 +3704,9 @@ case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp - 1]); @@ -3582,9 +3747,9 @@ case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -3608,9 +3773,9 @@ case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3636,9 +3801,9 @@ case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -3683,9 +3848,9 @@ case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -3711,9 +3876,9 @@ case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -3722,9 +3887,9 @@ case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -3733,10 +3898,10 @@ case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3750,10 +3915,10 @@ case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3767,10 +3932,10 @@ case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3784,10 +3949,10 @@ case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -3806,9 +3971,9 @@ case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -3817,9 +3982,9 @@ case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -3857,10 +4022,10 @@ case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -3884,9 +4049,9 @@ case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -3965,9 +4130,9 @@ case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -3976,9 +4141,9 @@ case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -3987,9 +4152,9 @@ case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -3998,9 +4163,9 @@ case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -4009,9 +4174,9 @@ case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -4020,9 +4185,9 @@ case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -4031,9 +4196,9 @@ case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -4044,10 +4209,10 @@ case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4064,9 +4229,9 @@ case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -4075,9 +4240,9 @@ case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -4086,9 +4251,9 @@ case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -4097,9 +4262,9 @@ case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -4108,9 +4273,9 @@ case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -4129,18 +4294,18 @@ case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -4149,9 +4314,9 @@ case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -4160,9 +4325,9 @@ case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -4171,9 +4336,9 @@ case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -4182,9 +4347,9 @@ case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -4193,10 +4358,10 @@ case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4213,9 +4378,9 @@ case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp__default['default']._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -4232,9 +4397,9 @@ case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -4246,9 +4411,9 @@ case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -4258,9 +4423,9 @@ case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4295,9 +4460,9 @@ case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4316,9 +4481,9 @@ case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -4327,9 +4492,9 @@ case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -4338,9 +4503,9 @@ case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4358,10 +4523,10 @@ case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -4379,10 +4544,10 @@ case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -4403,9 +4568,9 @@ case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4438,9 +4603,9 @@ case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -4466,9 +4631,9 @@ case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5__default['default'].parse(yyvstack[yysp]); @@ -4477,9 +4642,9 @@ case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue(yyvstack[yysp]); @@ -4488,9 +4653,9 @@ case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -4499,9 +4664,9 @@ case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode$1(yyvstack[yysp]); @@ -4522,10 +4687,10 @@ case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -4542,9 +4707,9 @@ case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -4563,9 +4728,9 @@ case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -4589,9 +4754,9 @@ case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -4611,9 +4776,9 @@ case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -4624,9 +4789,9 @@ case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -4682,10 +4847,10 @@ case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS$1` @@ -6288,7 +6453,6 @@ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -6305,38 +6469,34 @@ } }, parse: function parse(input) { - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -6344,20 +6504,18 @@ pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -6379,7 +6537,6 @@ // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -6387,18 +6544,19 @@ if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -6406,24 +6564,19 @@ // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -6461,18 +6614,15 @@ - - - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); + let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -6493,7 +6643,7 @@ // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -6511,7 +6661,6 @@ // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -6524,7 +6673,6 @@ // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -6538,11 +6686,10 @@ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -6596,8 +6743,8 @@ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6605,8 +6752,8 @@ this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -6638,19 +6785,18 @@ // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -6661,7 +6807,7 @@ if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -6674,7 +6820,7 @@ if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -6686,29 +6832,27 @@ // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -6716,7 +6860,7 @@ l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -6736,8 +6880,7 @@ // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -6746,10 +6889,10 @@ token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -6757,7 +6900,7 @@ location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -6768,9 +6911,14 @@ // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. destroy: function destructParseErrorInfo() { - - var rec = !!this.recoverable; - for (var key in this) { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // info.value = null; + // info.value_stack = null; + // ... + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -6786,8 +6934,7 @@ // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -6856,11 +7003,14 @@ // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -6871,8 +7021,7 @@ }; function getNonTerminalFromCode(symbol) { - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -6881,21 +7030,20 @@ function stdLex() { - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6905,21 +7053,20 @@ } function fastLex() { - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -6928,28 +7075,27 @@ return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -6962,8 +7108,7 @@ - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; + const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -6986,8 +7131,7 @@ - - if (symbol === EOF) { + if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -6999,8 +7143,7 @@ - - --stack_probe; // popStack(1): [symbol, action] + --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -7017,8 +7160,7 @@ - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -7032,8 +7174,7 @@ - - return -1; // No suitable error recovery rule available. + return -1; // No suitable error recovery rule available. } @@ -7047,7 +7188,7 @@ // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -7100,16 +7241,13 @@ - - - - // handle parse error + // handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -7143,9 +7281,7 @@ - - - r = this.parseError(p.errStr, p, this.JisonParserError); + r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -7168,9 +7304,7 @@ - - - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -7197,17 +7331,16 @@ - - } + } // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -7254,8 +7387,8 @@ recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -7267,8 +7400,7 @@ - - } else { + } else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -7286,6 +7418,7 @@ yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -7294,7 +7427,7 @@ - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -7305,7 +7438,7 @@ sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -7365,10 +7498,10 @@ // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -7403,9 +7536,7 @@ - - - // encountered another parse error? If so, break out to main loop + // encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -7418,7 +7549,7 @@ - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -7439,9 +7570,7 @@ - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7463,12 +7592,12 @@ // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -7477,7 +7606,7 @@ ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7518,7 +7647,7 @@ } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -7565,7 +7694,7 @@ // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -7583,21 +7712,19 @@ - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7631,14 +7758,15 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7648,6 +7776,7 @@ + } continue; // accept: @@ -7699,7 +7828,7 @@ // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -7715,9 +7844,7 @@ - - - switch (action) { + switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -7746,7 +7873,7 @@ sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -7763,8 +7890,8 @@ symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -7775,8 +7902,8 @@ // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -7788,21 +7915,19 @@ - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); + r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -7833,14 +7958,15 @@ sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -7850,6 +7976,7 @@ + } continue; // accept: @@ -7902,8 +8029,7 @@ // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -8164,7 +8290,6 @@ * @nocollapse */ function JisonLexerError(msg, hash) { - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -8181,10 +8306,10 @@ }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -8216,7 +8341,7 @@ JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -8258,7 +8383,9 @@ // // --------- END OF REPORT ----------- - EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -8344,7 +8471,7 @@ if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -8352,7 +8479,7 @@ msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -8365,7 +8492,7 @@ } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -8391,10 +8518,13 @@ * @this {LexErrorInfo} */ destroy: function destructLexErrorInfo() { + // remove cyclic references added to error info: + // info.yy = null; + // info.lexer = null; + // ... + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -8417,7 +8547,6 @@ * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -8440,16 +8569,16 @@ * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -8471,7 +8600,6 @@ * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -8479,8 +8607,8 @@ // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -8509,7 +8637,7 @@ this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -8534,7 +8662,7 @@ // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -8546,17 +8674,17 @@ } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -8650,7 +8778,7 @@ * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -8671,7 +8799,6 @@ * @this {RegExpLexer} */ input: function lexer_input() { - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -8682,7 +8809,7 @@ this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -8693,15 +8820,15 @@ // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -8735,8 +8862,8 @@ * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -8769,9 +8896,9 @@ // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -8790,9 +8917,9 @@ /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -8802,8 +8929,8 @@ * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ @@ -8830,20 +8957,19 @@ * @this {RegExpLexer} */ reject: function lexer_reject() { - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -8883,17 +9009,19 @@ * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8902,7 +9030,7 @@ // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -8917,8 +9045,8 @@ }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -8944,24 +9072,26 @@ * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -8972,7 +9102,7 @@ // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -8994,8 +9124,8 @@ * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -9017,8 +9147,7 @@ * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -9162,21 +9291,21 @@ const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -9191,11 +9320,11 @@ len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -9214,13 +9343,13 @@ // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -9244,13 +9373,13 @@ * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -9265,8 +9394,8 @@ } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -9297,7 +9426,7 @@ * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -9329,9 +9458,9 @@ }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -9360,7 +9489,7 @@ // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -9378,7 +9507,7 @@ return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -9403,7 +9532,6 @@ * @this {RegExpLexer} */ next: function lexer_next() { - if (this.done) { this.clear(); return this.EOF; @@ -9413,8 +9541,6 @@ this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -9423,7 +9549,7 @@ this.clear(); } - 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. @@ -9435,13 +9561,13 @@ // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -9451,68 +9577,74 @@ } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); - - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -9537,7 +9669,7 @@ * @this {RegExpLexer} */ lex: function lexer_lex() { - var r; + let r; //this._clear_state = 0; @@ -9585,24 +9717,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9622,7 +9754,7 @@ * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - var r; + let r; //this._clear_state = 0; @@ -9632,24 +9764,24 @@ if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -9670,8 +9802,7 @@ * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -9711,14 +9842,14 @@ * @this {RegExpLexer} */ popState: function lexer_popState() { - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -9734,9 +9865,9 @@ if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -9747,8 +9878,8 @@ * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -9756,7 +9887,7 @@ state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** diff --git a/packages/lex-parser/lex-parser.js b/packages/lex-parser/lex-parser.js index 52fef6ca5..a10a8cdd3 100644 --- a/packages/lex-parser/lex-parser.js +++ b/packages/lex-parser/lex-parser.js @@ -1,5 +1,5 @@ -/* parser generated by jison 0.6.2-220 */ +/* parser generated by jison 0.7.0-220 */ /* * Returns a Parser object of the following structure: @@ -162,9 +162,9 @@ * Produces a new errorInfo 'hash object' which can be passed into `parseError()`. * See it's use in this parser kernel in many places; example usage: * - * var infoObj = parser.constructParseErrorInfo('fail!', null, + * let infoObj = parser.constructParseErrorInfo('fail!', null, * parser.collect_expected_token_set(state), true); - * var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); + * let retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError); * * originalParseError: function(str, hash, ExceptionClass), * The basic `parseError` handler provided by JISON. @@ -366,212 +366,7 @@ * flex: boolean * optional: `true` ==> flex-like lexing behaviour where the rules are tested * exhaustively to find the longest match. - * backtrack_lexer: boolean (⅏ 센 ⅊ ⁖ ⁘ ⁙ ⁚ ⁛ ⁜ ⁝ ⁞ † ‡ - a⯈b - ∀ ∁ ∂ ∃ ∄ ∅ ∆ ∇ ∈ ∉ ∊ ∋ ∌ ∍ ∎ ∏ -U+221x ∐ ∑ − ∓ ∔ ∕ ∖ ∗ ∘ ∙ √ ∛ ∜ ∝ ∞ ∟ -U+222x ∠ ∡ ∢ ∣ ∤ ∥ ∦ ∧ ∨ ∩ ∪ ∫ ∬ ∭ ∮ ∯ -U+223x ∰ ∱ ∲ ∳ ∴ ∵ ∶ ∷ ∸ ∹ ∺ ∻ ∼ ∽ ∾ ∿ -U+224x ≀ ≁ ≂ ≃ ≄ ≅ ≆ ≇ ≈ ≉ ≊ ≋ ≌ ≍ ≎ ≏ -U+225x ≐ ≑ ≒ ≓ ≔ ≕ ≖ ≗ ≘ ≙ ≚ ≛ ≜ ≝ ≞ ≟ -U+226x ≠ ≡ ≢ ≣ ≤ ≥ ≦ ≧ ≨ ≩ ≪ ≫ ≬ ≭ ≮ ≯ -U+227x ≰ ≱ ≲ ≳ ≴ ≵ ≶ ≷ ≸ ≹ ≺ ≻ ≼ ≽ ≾ ≿ -U+228x ⊀ ⊁ ⊂ ⊃ ⊄ ⊅ ⊆ ⊇ ⊈ ⊉ ⊊ ⊋ ⊌ ⊍ ⊎ ⊏ -U+229x ⊐ ⊑ ⊒ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊜ ⊝ ⊞ ⊟ -U+22Ax ⊠ ⊡ ⊢ ⊣ ⊤ ⊥ ⊦ ⊧ ⊨ ⊩ ⊪ ⊫ ⊬ ⊭ ⊮ ⊯ -U+22Bx ⊰ ⊱ ⊲ ⊳ ⊴ ⊵ ⊶ ⊷ ⊸ ⊹ ⊺ ⊻ ⊼ ⊽ ⊾ ⊿ -U+22Cx ⋀ ⋁ ⋂ ⋃ ⋄ ⋅ ⋆ ⋇ ⋈ ⋉ ⋊ ⋋ ⋌ ⋍ ⋎ ⋏ -U+22Dx ⋐ ⋑ ⋒ ⋓ ⋔ ⋕ ⋖ ⋗ ⋘ ⋙ ⋚ ⋛ ⋜ ⋝ ⋞ ⋟ -U+22Ex ⋠ ⋡ ⋢ ⋣ ⋤ ⋥ ⋦ ⋧ ⋨ ⋩ ⋪ ⋫ ⋬ ⋭ ⋮ ⋯ -U+22Fx ⋰ ⋱ ⋲ ⋳ ⋴ ⋵ ⋶ ⋷ ⋸ ⋹ ⋺ ⋻ ⋼ ⋽ ⋾ ⋿) -U+230x ⌀ ⌁ ⌂ ⌃ ⌄ ⌅ ⌆ ⌇ ⌈ ⌉ ⌊ ⌋ ⌌ ⌍ ⌎ ⌏ -U+231x ⌐ ⌑ ⌒ ⌓ ⌔ ⌕ ⌖ ⌗ ⌘ ⌙ ⌚ ⌛ ⌜ ⌝ ⌞ ⌟ -U+232x ⌠ ⌡ ⌢ ⌣ ⌤ ⌥ ⌦ ⌧ ⌨ 〈 〉 ⌫ ⌬ ⌭ ⌮ ⌯ -U+233x ⌰ ⌱ ⌲ ⌳ ⌴ ⌵ ⌶ ⌷ ⌸ ⌹ ⌺ ⌻ ⌼ ⌽ ⌾ ⌿ -U+234x ⍀ ⍁ ⍂ ⍃ ⍄ ⍅ ⍆ ⍇ ⍈ ⍉ ⍊ ⍋ ⍌ ⍍ ⍎ ⍏ -U+235x ⍐ ⍑ ⍒ ⍓ ⍔ ⍕ ⍖ ⍗ ⍘ ⍙ ⍚ ⍛ ⍜ ⍝ ⍞ ⍟ -U+236x ⍠ ⍡ ⍢ ⍣ ⍤ ⍥ ⍦ ⍧ ⍨ ⍩ ⍪ ⍫ ⍬ ⍭ ⍮ ⍯ -U+237x ⍰ ⍱ ⍲ ⍳ ⍴ ⍵ ⍶ ⍷ ⍸ ⍹ ⍺ ⍻ ⍼ ⍽ ⍾ ⍿ -U+238x ⎀ ⎁ ⎂ ⎃ ⎄ ⎅ ⎆ ⎇ ⎈ ⎉ ⎊ ⎋ ⎌ ⎍ ⎎ ⎏ -U+239x ⎐ ⎑ ⎒ ⎓ ⎔ ⎕ ⎖ ⎗ ⎘ ⎙ ⎚ ⎛ ⎜ ⎝ ⎞ ⎟ -U+23Ax ⎠ ⎡ ⎢ ⎣ ⎤ ⎥ ⎦ ⎧ ⎨ ⎩ ⎪ ⎫ ⎬ ⎭ ⎮ ⎯ -U+23Bx ⎰ ⎱ ⎲ ⎳ ⎴ ⎵ ⎶ ⎷ ⎸ ⎹ ⎺ ⎻ ⎼ ⎽ ⎾ ⎿ -U+23Cx ⏀ ⏁ ⏂ ⏃ ⏄ ⏅ ⏆ ⏇ ⏈ ⏉ ⏊ ⏋ ⏌ ⏍ ⏎ ⏏ -U+23Dx ⏐ ⏑ ⏒ ⏓ ⏔ ⏕ ⏖ ⏗ ⏘ ⏙ ⏚ ⏛ ⏜ ⏝ ⏞ ⏟ -U+23Ex ⏠ ⏡ ⏢ ⏣ ⏤ ⏥ ⏦ ⏧ ⏨ ⏩ ⏪ ⏫ ⏬ ⏭ ⏮ ⏯ -U+23Fx ⏰ ⏱ ⏲ ⏳ ⏴ ⏵ ⏶ ⏷ ⏸ ⏹ ⏺ ⏻ ⏼ ⏽ ⏾ ⏿ - -U+260x ☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☎ ☏ -U+261x ☐ ☑ ☒ ☓ ☔ ☕ ☖ ☗ ☘ ☙ ☚ ☛ ☜ ☝ ☞ ☟ -U+262x ☠ ☡ ☢ ☣ ☤ ☥ ☦ ☧ ☨ ☩ ☪ ☫ ☬ ☭ ☮ ☯ -U+263x ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷ ☸ ☹ ☺ ☻ ☼ ☽ ☾ ☿ -U+264x ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇ ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ -U+265x ♐ ♑ ♒ ♓ ♔ ♕ ♖ ♗ ♘ ♙ ♚ ♛ ♜ ♝ ♞ ♟ -U+266x ♠ ♡ ♢ ♣ ♤ ♥ ♦ ♧ ♨ ♩ ♪ ♫ ♬ ♭ ♮ ♯ -U+267x ♰ ♱ ♲ ♳ ♴ ♵ ♶ ♷ ♸ ♹ ♺ ♻ ♼ ♽ ♾ ♿ -U+268x ⚀ ⚁ ⚂ ⚃ ⚄ ⚅ ⚆ ⚇ ⚈ ⚉ ⚊ ⚋ ⚌ ⚍ ⚎ ⚏ -U+269x ⚐ ⚑ ⚒ ⚓ ⚔ ⚕ ⚖ ⚗ ⚘ ⚙ ⚚ ⚛ ⚜ ⚝ ⚞ ⚟ -U+26Ax ⚠ ⚡ ⚢ ⚣ ⚤ ⚥ ⚦ ⚧ ⚨ ⚩ ⚪ ⚫ ⚬ ⚭ ⚮ ⚯ -U+26Bx ⚰ ⚱ ⚲ ⚳ ⚴ ⚵ ⚶ ⚷ ⚸ ⚹ ⚺ ⚻ ⚼ ⚽ ⚾ ⚿ -U+26Cx ⛀ ⛁ ⛂ ⛃ ⛄ ⛅ ⛆ ⛇ ⛈ ⛉ ⛊ ⛋ ⛌ ⛍ ⛎ ⛏ -U+26Dx ⛐ ⛑ ⛒ ⛓ ⛔ ⛕ ⛖ ⛗ ⛘ ⛙ ⛚ ⛛ ⛜ ⛝ ⛞ ⛟ -U+26Ex ⛠ ⛡ ⛢ ⛣ ⛤ ⛥ ⛦ ⛧ ⛨ ⛩ ⛪ ⛫ ⛬ ⛭ ⛮ ⛯ -U+26Fx ⛰ ⛱ ⛲ ⛳ ⛴ ⛵ ⛶ ⛷ ⛸ ⛹ ⛺ ⛻ ⛼ ⛽ ⛾ ⛿ - - ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ☛ ☞ ✌ ✍ ✎ ✏ -✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -✠ ✡ ✢ ✣ ✤ ✥ ✦ ✧ ★ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ● ❍ ■ ❏ -☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ❐ ❑ ❒ ▲ ▼ ◆ ❖ -◗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ - -U+270x ✀ ✁ ✂ ✃ ✄ ✅ ✆ ✇ ✈ ✉ ✊ ✋ ✌ ✍ ✎ ✏ -U+271x ✐ ✑ ✒ ✓ ✔ ✕ ✖ ✗ ✘ ✙ ✚ ✛ ✜ ✝ ✞ ✟ -U+272x ✠ ✡ ✢ ✣ a✤b a✥b a✦b a✧b ✨ ✩ ✪ ✫ ✬ ✭ ✮ ✯ -U+273x ✰ ✱ ✲ ✳ ✴ ✵ ✶ ✷ ✸ ✹ ✺ ✻ ✼ ✽ ✾ ✿ -U+274x ❀ ❁ ❂ ❃ ❄ ❅ ❆ ❇ ❈ ❉ ❊ ❋ ❌ ❍ ❎ ❏ -U+275x ❐ ❑ ❒ ❓ ❔ ❕ ❖ ❗ ❘ ❙ ❚ ❛ ❜ ❝ ❞ ❟ -U+276x ❠ ❡ ❢ ❣ ❤ ❥ ❦ ❧ ❨ ❩ ❪ ❫ ❬ ❭ ❮ a❯b -U+277x ❰ ❱ ❲ ❳ ❴ ❵ ❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ ❾ ❿ -U+278x ➀ ➁ ➂ ➃ ➄ ➅ ➆ ➇ ➈ ➉ ➊ ➋ ➌ ➍ ➎ ➏ -U+279x ➐ ➑ ➒ ➓ ➔ ➕ ➖ ➗ ➘ ➙ ➚ ➛ ➜ ➝ ➞ ➟ -U+27Ax ➠ ➡ ➢ ➣ ➤ ➥ ➦ ➧ a➨b ➩ ➪ ➫ ➬ ➭ ➮ ➯ -U+27Bx ➰ a➱b ➲ ➳ ➴ ➵ ➶ ➷ ➸ ➹ ➺ ➻ ➼ ➽ ➾ ➿ - -U+2580 ▀ Upper half block -U+2581 ▁ Lower one eighth block -U+2582 ▂ Lower one quarter block -U+2583 ▃ Lower three eighths block -U+2584 ▄ Lower half block -U+2585 ▅ Lower five eighths block -U+2586 ▆ Lower three quarters block -U+2587 ▇ Lower seven eighths block -U+2588 █ Full block -U+2589 ▉ Left seven eighths block -U+258A ▊ Left three quarters block -U+258B ▋ Left five eighths block -U+258C ▌ Left half block -U+258D ▍ Left three eighths block -U+258E ▎ Left one quarter block -U+258F ▏ Left one eighth block -U+2590 ▐ Right half block -U+2591 ░ Light shade -U+2592 ▒ Medium shade -U+2593 ▓ Dark shade -U+2594 ▔ Upper one eighth block -U+2595 ▕ Right one eighth block -U+2596 ▖ Quadrant lower left -U+2597 ▗ Quadrant lower right -U+2598 ▘ Quadrant upper left -U+2599 ▙ Quadrant upper left and lower left and lower right -U+259A ▚ Quadrant upper left and lower right -U+259B ▛ Quadrant upper left and upper right and lower left -U+259C ▜ Quadrant upper left and upper right and lower right -U+259D ▝ Quadrant upper right -U+259E ▞ Quadrant upper right and lower left -U+259F ▟ Quadrant upper right and lower left and lower right -Geometric Shapes -Main articles: Geometric Shapes (Unicode block) and Geometric Shapes Extended (Unicode block) -[hide]Code Glyph Description -U+25A0 ■ Black square -U+25A1 □ White square -U+25A2 ▢ White square with rounded corners -U+25A3 ▣ White square containing small black square -U+25A4 ▤ Square with horizontal fill -U+25A5 ▥ Square with vertical fill -U+25A6 ▦ Square with orthogonal crosshatch fill -U+25A7 ▧ Square with upper left to lower right fill -U+25A8 ▨ Square with upper right to lower left fill -U+25A9 ▩ Square with diagonal crosshatch fill -U+25AA ▪ Black small square -U+25AB ▫ White small square -U+25AC ▬ Black rectangle -U+25AD ▭ White rectangle -U+25AE ▮ Black vertical rectangle -U+25AF ▯ White vertical rectangle -U+25B0 ▰ Black parallelogram -U+25B1 ▱ White parallelogram -U+25B2 ▲ Black up-pointing triangle -U+25B3 △ White up-pointing triangle -U+25B4 ▴ Black up-pointing small triangle -U+25B5 ▵ White up-pointing small triangle -U+25B6 ▶ Black right-pointing triangle -U+25B7 ▷ White right-pointing triangle -U+25B8 ▸ Black right-pointing small triangle -U+25B9 ▹ White right-pointing small triangle -U+25BA ► Black right-pointing pointer -U+25BB ▻ White right-pointing pointer -U+25BC ▼ Black down-pointing triangle -U+25BD ▽ White down-pointing triangle -U+25BE ▾ Black down-pointing small triangle -U+25BF ▿ White down-pointing small triangle -U+25C0 ◀ Black left-pointing triangle -U+25C1 ◁ White left-pointing triangle -U+25C2 ◂ Black left-pointing small triangle -U+25C3 ◃ White left-pointing small triangle -U+25C4 ◄ Black left-pointing pointer -U+25C5 ◅ White left-pointing pointer -U+25C6 ◆ Black diamond -U+25C7 ◇ White diamond -U+25C8 ◈ White diamond containing small black diamond -U+25C9 ◉ Fisheye -U+25CA ◊ Lozenge -U+25CB ○ White circle -U+25CC ◌ Dotted circle -U+25CD ◍ Circle with vertical fill -U+25CE ◎ Bullseye -U+25CF ● Black circle -U+25D0 ◐ Circle with left half black -U+25D1 ◑ Circle with right half black -U+25D2 ◒ Circle with lower half black -U+25D3 ◓ Circle with upper half black -U+25D4 ◔ Circle with upper right quadrant black -U+25D5 ◕ Circle with all but upper left quadrant black -U+25D6 ◖ Left half circle black -U+25D7 ◗ Right half black circle -U+25D8 ◘ Inverse bullet -U+25D9 ◙ Inverse white circle -U+25DA ◚ Upper half inverse white circle -U+25DB ◛ Lower half inverse white circle -U+25DC ◜ Upper left quadrant circular arc -U+25DD ◝ Upper right quadrant circular arc -U+25DE ◞ Lower right quadrant circular arc -U+25DF ◟ Lower left quadrant circular arc -U+25E0 ◠ Upper half circle -U+25E1 ◡ Lower half circle -U+25E2 ◢ Black lower right triangle -U+25E3 ◣ Black lower left triangle -U+25E4 ◤ Black upper left triangle -U+25E5 ◥ Black upper right triangle -U+25E6 ◦ White bullet -U+25E7 ◧ Square with left half black -U+25E8 ◨ Square with right half black -U+25E9 ◩ Square with upper left diagonal half black -U+25EA ◪ Square with lower right diagonal half black -U+25EB ◫ White square with vertical bisecting line -U+25EC ◬ White up-pointing triangle with dot -U+25ED ◭ Up-pointing triangle with left half black -U+25EE ◮ Up-pointing triangle with right half black -U+25EF ◯ Large circle -U+25F0 ◰ White square with upper left quadrant -U+25F1 ◱ White square with lower left quadrant -U+25F2 ◲ White square with lower right quadrant -U+25F3 ◳ White square with upper right quadrant -U+25F4 ◴ White circle with upper left quadrant -U+25F5 ◵ White circle with lower left quadrant -U+25F6 ◶ White circle with lower right quadrant -U+25F7 ◷ White circle with upper right quadrant -U+25F8 ◸ Upper left triangle -U+25F9 ◹ Upper right triangle -U+25FA ◺ Lower-left triangle -U+25FB ◻ White medium square -U+25FC ◼ Black medium square -U+25FD ◽ White medium small square -U+25FE ◾ Black medium small square -U+25FF ◿ Lower right triangle - - + * backtrack_lexer: boolean * optional: `true` ==> lexer regexes are tested in order and for invoked; * the lexer terminates the scan when a token is returned by the action code. * xregexp: boolean @@ -593,8 +388,6 @@ import XRegExp from '@gerhobbelt/xregexp'; // for helping out the `%optio // 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. function JisonParserError(msg, hash) { - "use strict"; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -611,9 +404,9 @@ function JisonParserError(msg, hash) { this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + let ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -646,10 +439,10 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the productions[] table function bp(s) { - var rv = []; - var p = s.pop; - var r = s.rule; - for (var i = 0, l = p.length; i < l; i++) { + let rv = []; + let p = s.pop; + let r = s.rule; + for (let i = 0, l = p.length; i < l; i++) { rv.push([ p[i], r[i] @@ -662,11 +455,11 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the defaultActions[] table function bda(s) { - var rv = {}; - var d = s.idx; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var j = d[i]; + let rv = {}; + let d = s.idx; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let j = d[i]; rv[j] = g[i]; } return rv; @@ -676,18 +469,18 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: reconstruct the 'goto' table function bt(s) { - var rv = []; - var d = s.len; - var y = s.symbol; - var t = s.type; - var a = s.state; - var m = s.mode; - var g = s.goto; - for (var i = 0, l = d.length; i < l; i++) { - var n = d[i]; - var q = {}; - for (var j = 0; j < n; j++) { - var z = y.shift(); + let rv = []; + let d = s.len; + let y = s.symbol; + let t = s.type; + let a = s.state; + let m = s.mode; + let g = s.goto; + for (let i = 0, l = d.length; i < l; i++) { + let n = d[i]; + let q = {}; + for (let j = 0; j < n; j++) { + let z = y.shift(); switch (t.shift()) { case 2: q[z] = [ @@ -718,7 +511,7 @@ JisonParserError.prototype.name = 'JisonParserError'; // `this` references an array function s(c, l, a) { a = a || 0; - for (var i = 0; i < l; i++) { + for (let i = 0; i < l; i++) { this.push(c); c += a; } @@ -735,9 +528,9 @@ JisonParserError.prototype.name = 'JisonParserError'; // helper: unpack an array using helpers and data, all passed in an array argument 'a'. function u(a) { - var rv = []; - for (var i = 0, l = a.length; i < l; i++) { - var e = a[i]; + let rv = []; + for (let i = 0, l = a.length; i < l; i++) { + let e = a[i]; // Is this entry a helper function? if (typeof e === 'function') { i++; @@ -750,7 +543,7 @@ JisonParserError.prototype.name = 'JisonParserError'; } -var parser = { +let parser = { // Code Generator Information Report // --------------------------------- // @@ -1000,8 +793,6 @@ TERROR: 2, // Helper function which can be overridden by user code later on: put suitable quotes around // literal IDs in a description string. quoteName: function parser_quoteName(id_str) { - "use strict"; - return '"' + id_str + '"'; }, @@ -1009,8 +800,6 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. getSymbolName: function parser_getSymbolName(symbol) { - "use strict"; - if (this.terminals_[symbol]) { return this.terminals_[symbol]; } @@ -1022,8 +811,8 @@ TERROR: 2, // parser.getSymbolName(#$) // // to obtain a human-readable name of the current grammar rule. - var s = this.symbols_; - for (var key in s) { + const s = this.symbols_; + for (let key in s) { if (s[key] === symbol) { return key; } @@ -1036,15 +825,13 @@ TERROR: 2, // // Return NULL when the symbol is unknown to the parser. describeSymbol: function parser_describeSymbol(symbol) { - "use strict"; - if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) { return this.terminal_descriptions_[symbol]; - } - else if (symbol === this.EOF) { + } else if (symbol === this.EOF) { return 'end of input'; } - var id = this.getSymbolName(symbol); + + let id = this.getSymbolName(symbol); if (id) { return this.quoteName(id); } @@ -1060,11 +847,10 @@ TERROR: 2, // // The returned list (array) will not contain any duplicate entries. collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) { - "use strict"; + const TERROR = this.TERROR; + let tokenset = []; + let check = {}; - var TERROR = this.TERROR; - var tokenset = []; - var check = {}; // Has this (error?) state been outfitted with a custom expectations description text for human consumption? // If so, use that one instead of the less palatable token set. if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) { @@ -1072,10 +858,10 @@ TERROR: 2, this.state_descriptions_[state] ]; } - for (var p in this.table[state]) { + for (let p in this.table[state]) { p = +p; if (p !== TERROR) { - var d = do_not_describe ? p : this.describeSymbol(p); + let d = do_not_describe ? p : this.describeSymbol(p); if (d && !check[d]) { tokenset.push(d); check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries. @@ -1230,9 +1016,9 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy /* this == yyval */ // the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code! - var yy = this.yy; - var yyparser = yy.parser; - var yylexer = yy.lexer; + let yy = this.yy; + let yyparser = yy.parser; + let yylexer = yy.lexer; const OPTION_DOES_NOT_ACCEPT_VALUE = 0x0001; const OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES = 0x0002; @@ -1244,18 +1030,18 @@ performAction: function parser__PerformAction(yyloc, yystate /* action[1] */, yy case 0: /*! Production:: $accept : lex $end */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/2,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 1]; this._$ = yylstack[yysp - 1]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // 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,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -1286,9 +1072,9 @@ case 1: case 2: /*! Production:: rules_and_epilogue : start_productions_marker rules epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp]) { @@ -1301,10 +1087,10 @@ case 2: case 3: /*! Production:: rules_and_epilogue : start_productions_marker error epilogue */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -1331,9 +1117,9 @@ case 3: case 4: /*! Production:: rules_and_epilogue : start_productions_marker rules */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: yyvstack[yysp] }; @@ -1342,10 +1128,10 @@ case 4: case 5: /*! Production:: rules_and_epilogue : start_productions_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -1373,9 +1159,9 @@ case 5: case 6: /*! Production:: rules_and_epilogue : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { rules: [] }; @@ -1384,10 +1170,10 @@ case 6: case 7: /*! Production:: init : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-): this.$ = undefined; this._$ = yyparser.yyMergeLocationInfo(null, null, null, null, true); - // END of default action (generated by JISON mode classic/merge :: 0,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,-,-,LT,LA,-,-) yy.actionInclude = []; @@ -1426,9 +1212,9 @@ case 7: case 8: /*! Production:: definitions : definitions definition */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1]; @@ -1493,9 +1279,9 @@ case 8: case 9: /*! Production:: definitions : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -1510,9 +1296,9 @@ case 9: case 10: /*! Production:: definition : MACRO_NAME regex MACRO_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // Note: make sure we don't try re-define/override any XRegExp `\p{...}` or `\P{...}` @@ -1547,10 +1333,10 @@ case 10: case 11: /*! Production:: definition : MACRO_NAME error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -1567,9 +1353,9 @@ case 11: case 12: /*! Production:: definition : start_inclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -1586,10 +1372,10 @@ case 12: case 13: /*! Production:: definition : start_inclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -1606,9 +1392,9 @@ case 13: case 14: /*! Production:: definition : start_exclusive_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -1625,10 +1411,10 @@ case 14: case 15: /*! Production:: definition : start_exclusive_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -1645,9 +1431,9 @@ case 15: case 16: /*! Production:: definition : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -1671,9 +1457,9 @@ case 17: case 132: /*! Production:: epilogue_chunk : UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -1684,9 +1470,9 @@ case 132: case 18: /*! Production:: definition : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -1706,9 +1492,9 @@ case 18: case 19: /*! Production:: definition : ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -1732,9 +1518,9 @@ case 19: case 20: /*! Production:: definition : option_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var lst = yyvstack[yysp - 1]; @@ -1747,10 +1533,10 @@ case 20: case 21: /*! Production:: definition : option_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -1767,9 +1553,9 @@ case 21: case 22: /*! Production:: definition : UNKNOWN_DECL */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = { @@ -1781,9 +1567,9 @@ case 22: case 23: /*! Production:: definition : import_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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' @@ -1823,10 +1609,10 @@ case 23: case 24: /*! Production:: definition : import_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -1846,9 +1632,9 @@ case 24: case 25: /*! Production:: definition : init_code_keyword option_list ACTION_START action ACTION_END OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 6,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -1898,10 +1684,10 @@ case 25: case 26: /*! Production:: definition : init_code_keyword option_list ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 2].trim(); @@ -1925,10 +1711,10 @@ case 26: case 27: /*! Production:: definition : init_code_keyword error ACTION_START error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 4]; this._$ = yyparser.yyMergeLocationInfo(yysp - 4, yysp); - // END of default action (generated by JISON mode classic/merge :: 5,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 5/5,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -1948,10 +1734,10 @@ case 27: case 28: /*! Production:: definition : init_code_keyword error OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -1975,10 +1761,10 @@ case 28: case 29: /*! Production:: definition : error */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -1999,10 +1785,10 @@ case 29: case 30: /*! Production:: option_keyword : OPTIONS */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -2014,10 +1800,10 @@ case 31: case 33: /*! Production:: include_keyword : INCLUDE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -2027,10 +1813,10 @@ case 33: case 32: /*! Production:: init_code_keyword : CODE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_DOES_NOT_ACCEPT_MULTIPLE_OPTIONS | OPTION_DOES_NOT_ACCEPT_COMMA_SEPARATED_OPTIONS; @@ -2040,10 +1826,10 @@ case 32: case 34: /*! Production:: start_inclusive_keyword : START_INC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -2053,10 +1839,10 @@ case 34: case 35: /*! Production:: start_exclusive_keyword : START_EXC */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES; @@ -2066,10 +1852,10 @@ case 35: case 36: /*! Production:: start_conditions_marker : "<" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = OPTION_DOES_NOT_ACCEPT_VALUE | OPTION_EXPECTS_ONLY_IDENTIFIER_NAMES | OPTION_ALSO_ACCEPTS_STAR_AS_IDENTIFIER_NAME; @@ -2079,10 +1865,10 @@ case 36: case 37: /*! Production:: start_productions_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -2092,10 +1878,10 @@ case 37: case 38: /*! Production:: start_epilogue_marker : "%%" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) yy.__options_flags__ = 0; @@ -2105,9 +1891,9 @@ case 38: case 39: /*! Production:: rules : rules scoped_rules_collective */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat(yyvstack[yysp]); @@ -2116,9 +1902,9 @@ case 39: case 40: /*! Production:: rules : rules rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1].concat([yyvstack[yysp]]); @@ -2127,9 +1913,9 @@ case 40: case 41: /*! Production:: rules : rules ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -2151,9 +1937,9 @@ case 41: case 42: /*! Production:: rules : rules UNTERMINATED_ACTION_BLOCK */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // The issue has already been reported by the lexer. No need to repeat @@ -2164,9 +1950,9 @@ case 42: case 43: /*! Production:: rules : rules ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2186,9 +1972,9 @@ case 43: case 44: /*! Production:: rules : rules ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -2242,9 +2028,9 @@ case 49: case 50: /*! Production:: rules : rules init_code_keyword */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -2264,9 +2050,9 @@ case 51: case 58: /*! Production:: rule_block : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = []; @@ -2275,9 +2061,9 @@ case 58: case 52: /*! Production:: scoped_rules_collective : start_conditions rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 1]) { @@ -2289,9 +2075,9 @@ case 52: case 53: /*! Production:: scoped_rules_collective : start_conditions "{" rule_block "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) if (yyvstack[yysp - 3]) { @@ -2305,10 +2091,10 @@ case 53: case 54: /*! Production:: scoped_rules_collective : start_conditions "{" error "}" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp - 3]; this._$ = yyparser.yyMergeLocationInfo(yysp - 3, yysp); - // END of default action (generated by JISON mode classic/merge :: 4,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -2328,10 +2114,10 @@ case 54: case 55: /*! Production:: scoped_rules_collective : start_conditions "{" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -2351,10 +2137,10 @@ case 55: case 56: /*! Production:: scoped_rules_collective : start_conditions error "}" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -2374,9 +2160,9 @@ case 56: case 57: /*! Production:: rule_block : rule_block rule */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -2387,9 +2173,9 @@ case 59: case 60: /*! Production:: rule : regex ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -2408,9 +2194,9 @@ case 60: case 61: /*! Production:: rule : regex ARROW_ACTION_START action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 4/4,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode(yyvstack[yysp - 1]); @@ -2451,9 +2237,9 @@ case 61: case 62: /*! Production:: rule : regex ARROW_ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 2], yyvstack[yysp]]; @@ -2477,9 +2263,9 @@ case 62: case 63: /*! Production:: rule : regex ACTION_START error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -2505,9 +2291,9 @@ case 63: case 64: /*! Production:: rule : regex ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) // TODO: REWRITE @@ -2552,9 +2338,9 @@ case 64: case 65: /*! Production:: rule : regex error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp - 1], yyvstack[yysp]]; @@ -2580,9 +2366,9 @@ case 106: case 127: /*! Production:: epilogue_chunks : epilogue_chunks epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + yyvstack[yysp]; @@ -2591,9 +2377,9 @@ case 127: case 67: /*! Production:: action : action include_macro_code */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '\n\n' + yyvstack[yysp] + '\n\n'; @@ -2602,10 +2388,10 @@ case 67: case 68: /*! Production:: action : action INCLUDE_PLACEMENT_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -2619,10 +2405,10 @@ case 68: case 69: /*! Production:: action : action BRACKET_MISSING */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -2636,10 +2422,10 @@ case 69: case 70: /*! Production:: action : action BRACKET_SURPLUS */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -2653,10 +2439,10 @@ case 70: case 71: /*! Production:: action : action UNTERMINATED_STRING_ERROR */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -2675,9 +2461,9 @@ case 72: case 77: /*! Production:: regex_list : %epsilon */ - // default action (generated by JISON mode classic/merge :: 0,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 0/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -2686,9 +2472,9 @@ case 77: case 73: /*! Production:: start_conditions : start_conditions_marker option_list OPTIONS_END ">" */ - // default action (generated by JISON mode classic/merge :: 4,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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? @@ -2726,10 +2512,10 @@ case 73: case 74: /*! Production:: start_conditions : start_conditions_marker option_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // 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? @@ -2753,9 +2539,9 @@ case 74: case 75: /*! Production:: regex : nonempty_regex_list */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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; @@ -2834,9 +2620,9 @@ case 110: case 129: /*! Production:: epilogue_chunks : epilogue_chunk */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp]; @@ -2845,9 +2631,9 @@ case 129: case 78: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + '|' + yyvstack[yysp]; @@ -2856,9 +2642,9 @@ case 78: case 79: /*! Production:: nonempty_regex_list : nonempty_regex_list "|" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '|'; @@ -2867,9 +2653,9 @@ case 79: case 80: /*! Production:: nonempty_regex_list : "|" regex_concat */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '|' + yyvstack[yysp]; @@ -2878,9 +2664,9 @@ case 80: case 81: /*! Production:: nonempty_regex_list : "|" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '|'; @@ -2889,9 +2675,9 @@ case 81: case 85: /*! Production:: regex_base : "(" regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = '(' + yyvstack[yysp - 1] + ')'; @@ -2900,9 +2686,9 @@ case 85: case 86: /*! Production:: regex_base : SPECIAL_GROUP regex_list ")" */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + ')'; @@ -2913,10 +2699,10 @@ case 87: case 88: /*! Production:: regex_base : SPECIAL_GROUP regex_list error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -2933,9 +2719,9 @@ case 88: case 89: /*! Production:: regex_base : regex_base "+" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '+'; @@ -2944,9 +2730,9 @@ case 89: case 90: /*! Production:: regex_base : regex_base "*" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '*'; @@ -2955,9 +2741,9 @@ case 90: case 91: /*! Production:: regex_base : regex_base "?" */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 1] + '?'; @@ -2966,9 +2752,9 @@ case 91: case 92: /*! Production:: regex_base : "/" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?=' + yyvstack[yysp] + ')'; @@ -2977,9 +2763,9 @@ case 92: case 93: /*! Production:: regex_base : "/!" regex_base */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) this.$ = '(?!' + yyvstack[yysp] + ')'; @@ -2998,18 +2784,18 @@ case 107: case 108: /*! Production:: regex_set_atom : REGEX_SET */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-): + // default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-): this.$ = yyvstack[yysp]; this._$ = yylstack[yysp]; - // END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,-,-,LT,LA,-,-) break; case 97: /*! Production:: regex_base : "." */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '.'; @@ -3018,9 +2804,9 @@ case 97: case 98: /*! Production:: regex_base : "^" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '^'; @@ -3029,9 +2815,9 @@ case 98: case 99: /*! Production:: regex_base : "$" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = '$'; @@ -3040,9 +2826,9 @@ case 99: case 102: /*! Production:: regex_base : ESCAPED_CHAR */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = encodeRegexLiteralStr(encodeUnicodeCodepoint(yyvstack[yysp])); @@ -3051,9 +2837,9 @@ case 102: case 104: /*! Production:: any_group_regex : REGEX_SET_START regex_set REGEX_SET_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,VU,-,LT,LA,-,-) this.$ = yyvstack[yysp - 2] + yyvstack[yysp - 1] + yyvstack[yysp]; @@ -3062,10 +2848,10 @@ case 104: case 105: /*! Production:: any_group_regex : REGEX_SET_START regex_set error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -3082,9 +2868,9 @@ case 105: case 109: /*! Production:: regex_set_atom : name_expansion */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) if (XRegExp._getUnicodeProperty(yyvstack[yysp].replace(/[{}]/g, '')) @@ -3101,9 +2887,9 @@ case 109: case 111: /*! Production:: literal_string : STRING_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var src = yyvstack[yysp]; @@ -3115,9 +2901,9 @@ case 111: case 112: /*! Production:: literal_string : CHARACTER_LIT */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) var s = yyvstack[yysp]; @@ -3127,9 +2913,9 @@ case 112: case 113: /*! Production:: option_list : option_list "," option */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -3164,9 +2950,9 @@ case 113: case 114: /*! Production:: option_list : option_list option */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -3185,9 +2971,9 @@ case 114: case 115: /*! Production:: option_list : option */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp]]; @@ -3196,9 +2982,9 @@ case 115: case 116: /*! Production:: option : option_name */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = [yyvstack[yysp], true]; @@ -3207,9 +2993,9 @@ case 116: case 117: /*! Production:: option : option_name "=" option_value */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -3227,10 +3013,10 @@ case 117: case 118: /*! Production:: option : option_name "=" error */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 3/3,VT,VA,-,-,LT,LA,-,-) // TODO ... @@ -3248,10 +3034,10 @@ case 118: case 119: /*! Production:: option : DUMMY3 error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) var with_value_msg = ' (with optional value assignment)'; @@ -3272,9 +3058,9 @@ case 119: case 120: /*! Production:: option_name : option_value */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -3307,9 +3093,9 @@ case 120: case 121: /*! Production:: option_name : "*" */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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: @@ -3335,9 +3121,9 @@ case 121: case 122: /*! Production:: option_value : OPTION_STRING */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = JSON5.parse(yyvstack[yysp]); @@ -3346,9 +3132,9 @@ case 122: case 123: /*! Production:: option_value : OPTION_VALUE */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = parseValue(yyvstack[yysp]); @@ -3357,9 +3143,9 @@ case 123: case 124: /*! Production:: epilogue : start_epilogue_marker */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 1/1,VT,VA,VU,-,LT,LA,-,-) this.$ = ''; @@ -3368,9 +3154,9 @@ case 124: case 125: /*! Production:: epilogue : start_epilogue_marker epilogue_chunks */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var srcCode = trimActionCode(yyvstack[yysp]); @@ -3391,10 +3177,10 @@ case 125: case 126: /*! Production:: epilogue : start_epilogue_marker error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -3411,9 +3197,9 @@ case 126: case 128: /*! Production:: epilogue_chunks : epilogue_chunks error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) // TODO ... @@ -3432,9 +3218,9 @@ case 128: case 130: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL action ACTION_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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]); @@ -3458,9 +3244,9 @@ case 130: case 131: /*! Production:: epilogue_chunk : ACTION_START_AT_SOL error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,VU,-,LT,LA,-,-) var start_marker = yyvstack[yysp - 1].trim(); @@ -3480,9 +3266,9 @@ case 131: case 133: /*! Production:: epilogue_chunk : TRAILING_CODE_CHUNK */ - // default action (generated by JISON mode classic/merge :: 1,VT,VA,VU,-,LT,LA,-,-): + // 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,VT,VA,VU,-,LT,LA,-,-) + // 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 @@ -3493,9 +3279,9 @@ case 133: case 134: /*! Production:: include_macro_code : include_keyword option_list OPTIONS_END */ - // default action (generated by JISON mode classic/merge :: 3,VT,VA,VU,-,LT,LA,LU,LUbA): + // 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,VT,VA,VU,-,LT,LA,LU,LUbA) + // 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' @@ -3551,10 +3337,10 @@ case 134: case 135: /*! Production:: include_macro_code : include_keyword error */ - // default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,LT,LA,-,-): + // 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,VT,VA,-,-,LT,LA,-,-) + // END of default action (generated by JISON mode classic/merge :: 2/2,VT,VA,-,-,LT,LA,-,-) yyparser.yyError(rmCommonWS` @@ -5165,8 +4951,6 @@ defaultActions: bda({ ]) }), parseError: function parseError(str, hash, ExceptionClass) { - "use strict"; - if (hash.recoverable) { if (typeof this.trace === 'function') { this.trace(str); @@ -5183,39 +4967,37 @@ parseError: function parseError(str, hash, ExceptionClass) { } }, parse: function parse(input) { - "use strict"; - - var self = this; - var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) - var sstack = new Array(128); // state stack: stores states (column storage) - - var vstack = new Array(128); // semantic value stack - var lstack = new Array(128); // location stack - var table = this.table; - var sp = 0; // 'stack pointer': index into the stacks - var yyloc; - - - - - var symbol = 0; - var preErrorSymbol = 0; - var lastEofErrorStateDepth = Infinity; - var recoveringErrorInfo = null; - var recovering = 0; // (only used when the grammar contains error recovery rules) - var TERROR = this.TERROR; - var EOF = this.EOF; - var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; - var NO_ACTION = [0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; - - var lexer; + let self = this; + let stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage) + let sstack = new Array(128); // state stack: stores states (column storage) + + let vstack = new Array(128); // semantic value stack + let lstack = new Array(128); // location stack + let table = this.table; + let sp = 0; // 'stack pointer': index into the stacks + let yyloc; + let yytext; + let yylineno; + let yyleng; + + let symbol = 0; + let preErrorSymbol = 0; + let lastEofErrorStateDepth = Infinity; + let recoveringErrorInfo = null; + let recovering = 0; // (only used when the grammar contains error recovery rules) + const TERROR = this.TERROR; + const EOF = this.EOF; + const ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3; + const NO_ACTION = [ 0, 189 /* === table.length :: ensures that anyone using this new state will fail dramatically! */]; + + let lexer; if (this.__lexer__) { lexer = this.__lexer__; } else { lexer = this.__lexer__ = Object.create(this.lexer); } - var sharedState_yy = { + let sharedState_yy = { parseError: undefined, quoteName: undefined, lexer: undefined, @@ -5223,21 +5005,18 @@ parse: function parse(input) { pre_parse: undefined, post_parse: undefined, pre_lex: undefined, - post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes! + post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly! }; - var ASSERT; - if (typeof assert !== 'function') { - ASSERT = function JisonAssert(cond, msg) { - "use strict"; - - if (!cond) { - throw new Error('assertion failed: ' + (msg || '***')); - } - }; - } else { - ASSERT = assert; - } + const ASSERT = ( + typeof assert !== 'function' ? + function JisonAssert(cond, msg) { + if (!cond) { + throw new Error('assertion failed: ' + (msg || '***')); + } + } : + assert + ); this.yyGetSharedState = function yyGetSharedState() { return sharedState_yy; @@ -5259,8 +5038,6 @@ parse: function parse(input) { // benchmark:: http://127.0.0.1:8080/example/jsperf/?333#testfile=test0021-shallow-clones.json5 // function shallow_copy(src) { - "use strict"; - if (src && typeof src === 'object') { // non-Object-type objects, e.g. RegExp, Date, etc., can usually be shallow cloned // using their constructor: @@ -5268,18 +5045,19 @@ parse: function parse(input) { if (Array.isArray(src)) { return src.slice(); } - var dst = new src.constructor(src); + let dst = new src.constructor(src); // and make sure all custom attributes are added to the clone: shallow_copy_noclobber(dst, src); return dst; } // native objects must be cloned a different way: - // - //return Object.assign({}, src); - var dst = {}; - shallow_copy_noclobber(dst, src); - return dst; + { + //return Object.assign({}, src); + let dst = {}; + shallow_copy_noclobber(dst, src); + return dst; + } } return src; } @@ -5287,26 +5065,19 @@ parse: function parse(input) { // - either the element does not yet exist in `src` // - or exists in `src` but is NULL or UNDEFINED there, while its value is non-NULL in `dst` function shallow_copy_noclobber(dst, src) { - "use strict"; - const chk = Object.prototype.hasOwnProperty; - for (var k in src) { + for (let k in src) { if (!(k in dst)) { if (chk.call(src, k)) { dst[k] = src[k]; } - } - else { - if (src[k] != null && dst[k] == null && chk.call(src, k)) { - dst[k] = src[k]; - } + } else if (src[k] != null && dst[k] == null && chk.call(src, k)) { + dst[k] = src[k]; } } } function copy_yylloc_native(loc) { - "use strict"; - - var rv = shallow_copy(loc); + let rv = shallow_copy(loc); // shallow copy the yylloc ranges info to prevent us from modifying the original arguments' entries: if (rv) { rv.range = rv.range.slice(); @@ -5336,9 +5107,6 @@ parse: function parse(input) { // them up. Hence we MUST set them up at the start of every `parse()` run! if (this.yyError) { this.yyError = function yyError(str /*, ...args */) { - "use strict"; - - @@ -5347,16 +5115,15 @@ parse: function parse(input) { - - var error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); - var expected = this.collect_expected_token_set(state); - var hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); +let error_rule_depth = (this.options.parserErrorsAreRecoverable ? locateNearestErrorRecoveryRule(state) : -1); + let expected = this.collect_expected_token_set(state); + let hash = this.constructParseErrorInfo(str, null, expected, (error_rule_depth >= 0)); // append to the old one? if (recoveringErrorInfo) { - var esp = recoveringErrorInfo.info_stack_pointer; + let esp = recoveringErrorInfo.info_stack_pointer; recoveringErrorInfo.symbol_stack[esp] = symbol; - var v = this.shallowCopyErrorInfo(hash); + let v = this.shallowCopyErrorInfo(hash); v.yyError = true; v.errorRuleDepth = error_rule_depth; v.recovering = recovering; @@ -5377,7 +5144,7 @@ parse: function parse(input) { // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { hash.extra_error_attributes = args; } @@ -5395,8 +5162,6 @@ parse: function parse(input) { // Does the shared state override the default `parseError` that already comes with this instance? if (typeof sharedState_yy.parseError === 'function') { this.parseError = function parseErrorAlt(str, hash, ExceptionClass) { - "use strict"; - if (!ExceptionClass) { ExceptionClass = this.JisonParserError; } @@ -5409,8 +5174,6 @@ parse: function parse(input) { // Does the shared state override the default `quoteName` that already comes with this instance? if (typeof sharedState_yy.quoteName === 'function') { this.quoteName = function quoteNameAlt(id_str) { - "use strict"; - return sharedState_yy.quoteName.call(this, id_str); }; } else { @@ -5424,12 +5187,10 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `sharedState`, etc. references will be *wrong*! this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) { - "use strict"; - - var rv; + let rv; if (invoke_post_methods) { - var hash; + let hash; if (sharedState_yy.post_parse || this.post_parse) { // create an error hash info instance: we re-use this API in a **non-error situation** @@ -5483,8 +5244,8 @@ parse: function parse(input) { // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -5492,8 +5253,8 @@ parse: function parse(input) { this.__error_infos.length = 0; - for (var i = this.__error_recovery_infos.length - 1; i >= 0; i--) { - var el = this.__error_recovery_infos[i]; + for (let i = this.__error_recovery_infos.length - 1; i >= 0; i--) { + let el = this.__error_recovery_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); } @@ -5525,20 +5286,18 @@ parse: function parse(input) { // // Note: epsilon rule's yylloc situation is detected by passing both `first_index` and `first_yylloc` as UNDEFINED/NULL. this.yyMergeLocationInfo = function parser_yyMergeLocationInfo(first_index, last_index, first_yylloc, last_yylloc, dont_look_back) { - "use strict"; - - var i1 = first_index | 0, - i2 = last_index | 0; - var l1 = first_yylloc, - l2 = last_yylloc; - var rv; + let i1 = first_index | 0; + let i2 = last_index | 0; + let l1 = first_yylloc; + let l2 = last_yylloc; + let rv; // rules: // - first/last yylloc entries override first/last indexes if (!l1) { if (first_index != null) { - for (var i = i1; i <= i2; i++) { + for (let i = i1; i <= i2; i++) { l1 = lstack[i]; if (l1) { break; @@ -5549,7 +5308,7 @@ parse: function parse(input) { if (!l2) { if (last_index != null) { - for (var i = i2; i >= i1; i--) { + for (let i = i2; i >= i1; i--) { l2 = lstack[i]; if (l2) { break; @@ -5562,7 +5321,7 @@ parse: function parse(input) { if (!l1 && first_index == null) { // epsilon rule span merger. With optional look-ahead in l2. if (!dont_look_back) { - for (var i = (i1 || sp) - 1; i >= 0; i--) { + for (let i = (i1 || sp) - 1; i >= 0; i--) { l1 = lstack[i]; if (l1) { break; @@ -5574,29 +5333,27 @@ parse: function parse(input) { // when we still don't have any valid yylloc info, we're looking at an epsilon rule // without look-ahead and no preceding terms and/or `dont_look_back` set: // in that case we ca do nothing but return NULL/UNDEFINED: - return undefined; - } else { - // shallow-copy L2: after all, we MAY be looking - // at unconventional yylloc info objects... - rv = this.copy_yylloc(l2); - return rv; - } - } else { - // shallow-copy L1, then adjust first col/row 1 column past the end. - rv = this.copy_yylloc(l1); - rv.first_line = rv.last_line; - rv.first_column = rv.last_column; - rv.range[0] = rv.range[1]; - - if (l2) { - // shallow-mixin L2, then adjust last col/row accordingly. - shallow_copy_noclobber(rv, l2); - rv.last_line = l2.last_line; - rv.last_column = l2.last_column; - rv.range[1] = l2.range[1]; + return null; } + // shallow-copy L2: after all, we MAY be looking + // at unconventional yylloc info objects... + rv = this.copy_yylloc(l2); return rv; } + // shallow-copy L1, then adjust first col/row 1 column past the end. + rv = this.copy_yylloc(l1); + rv.first_line = rv.last_line; + rv.first_column = rv.last_column; + rv.range[0] = rv.range[1]; + + if (l2) { + // shallow-mixin L2, then adjust last col/row accordingly. + shallow_copy_noclobber(rv, l2); + rv.last_line = l2.last_line; + rv.last_column = l2.last_column; + rv.range[1] = l2.range[1]; + } + return rv; } if (!l1) { @@ -5604,7 +5361,7 @@ parse: function parse(input) { l2 = null; } if (!l1) { - return undefined; + return null; } // shallow-copy L1|L2, before we try to adjust the yylloc values: after all, we MAY be looking @@ -5624,9 +5381,7 @@ parse: function parse(input) { // NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation, // or else your `lexer`, `sharedState`, etc. references will be *wrong*! this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) { - "use strict"; - - var pei = { + const pei = { errStr: msg, exception: ex, text: lexer.match, @@ -5635,10 +5390,10 @@ parse: function parse(input) { token_id: symbol, line: lexer.yylineno, loc: this.copy_yylloc(lexer.yylloc), - expected: expected, - recoverable: recoverable, - state: state, - action: action, + expected, + recoverable, + state, + action, new_state: newState, symbol_stack: stack, state_stack: sstack, @@ -5646,7 +5401,7 @@ parse: function parse(input) { location_stack: lstack, stack_pointer: sp, yy: sharedState_yy, - lexer: lexer, + lexer, parser: this, // and make sure the error info doesn't stay due to potential @@ -5663,10 +5418,8 @@ parse: function parse(input) { // info.value = null; // info.value_stack = null; // ... - "use strict"; - - var rec = !!this.recoverable; - for (var key in this) { + const rec = !!this.recoverable; + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -5682,9 +5435,7 @@ parse: function parse(input) { // clone some parts of the (possibly enhanced!) errorInfo object // to give them some persistence. this.shallowCopyErrorInfo = function parser_shallowCopyErrorInfo(p) { - "use strict"; - - var rv = shallow_copy(p); + let rv = shallow_copy(p); // remove the large parts which can only cause cyclic references // and are otherwise available from the parser kernel anyway. @@ -5753,11 +5504,14 @@ parse: function parse(input) { // - root_failure_pointer: // copy of the `stack_pointer`... // - for (var i = rv.stack_pointer; rv.state_stack[i] != null; i++) { - // empty + { + let i; + for (i = rv.stack_pointer; rv.state_stack[i] != null; i++) { + // empty + } + rv.base_pointer = i; + rv.info_stack_pointer = i; } - rv.base_pointer = i; - rv.info_stack_pointer = i; rv.root_failure_pointer = rv.stack_pointer; @@ -5768,9 +5522,7 @@ parse: function parse(input) { }; function getNonTerminalFromCode(symbol) { - "use strict"; - - var tokenName = self.getSymbolName(symbol); + let tokenName = self.getSymbolName(symbol); if (!tokenName) { tokenName = symbol; } @@ -5779,22 +5531,20 @@ parse: function parse(input) { function stdLex() { - "use strict"; - - var token = lexer.lex(); + let token = lexer.lex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -5804,22 +5554,20 @@ parse: function parse(input) { } function fastLex() { - "use strict"; - - var token = lexer.fastLex(); + let token = lexer.fastLex(); // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } if (typeof Jison !== 'undefined' && Jison.lexDebugger) { - var tokenName = self.getSymbolName(token || EOF); + let tokenName = self.getSymbolName(token || EOF); if (!tokenName) { tokenName = token; } Jison.lexDebugger.push({ - tokenName: tokenName, + tokenName, tokenText: lexer.match, tokenValue: lexer.yytext }); @@ -5828,29 +5576,27 @@ parse: function parse(input) { return token || EOF; } - var lex = stdLex; + let lex = stdLex; - var state, action, r, t; - var yyval = { + let state, action, r, t; + let yyval = { $: true, _$: undefined, yy: sharedState_yy }; - var p; - var yyrulelen; - var this_production; - var newState; - var retval = false; + let p; + let yyrulelen; + let this_production; + let newState; + let retval = false; // Return the rule stack depth where the nearest error rule can be found. // Return -1 when no error recovery rule was found. function locateNearestErrorRecoveryRule(state) { - "use strict"; - - var stack_probe = sp - 1; - var depth = 0; + let stack_probe = sp - 1; + let depth = 0; // try to recover from error while (stack_probe >= 0) { @@ -5863,8 +5609,7 @@ parse: function parse(input) { - - var t = (table[state] && table[state][TERROR]) || NO_ACTION; +const t = (table[state] && table[state][TERROR]) || NO_ACTION; if (t[0]) { // We need to make sure we're not cycling forever: // once we hit EOF, even when we `yyerrok()` an error, we must @@ -5887,8 +5632,7 @@ parse: function parse(input) { - - if (symbol === EOF) { +if (symbol === EOF) { if (lastEofErrorStateDepth > sp - 1 - depth) { lastEofErrorStateDepth = sp - 1 - depth; } else { @@ -5900,8 +5644,7 @@ parse: function parse(input) { - - --stack_probe; // popStack(1): [symbol, action] +--stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; ++depth; continue; @@ -5918,8 +5661,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } --stack_probe; // popStack(1): [symbol, action] state = sstack[stack_probe]; @@ -5933,8 +5675,7 @@ parse: function parse(input) { - - return -1; // No suitable error recovery rule available. +return -1; // No suitable error recovery rule available. } @@ -5948,7 +5689,7 @@ parse: function parse(input) { // whether we'll go with the standard, slower, lex() API or the // `fast_lex()` one: if (typeof lexer.canIUse === 'function') { - var lexerInfo = lexer.canIUse(); + let lexerInfo = lexer.canIUse(); if (lexerInfo.fastLex && typeof fastLex === 'function') { lex = fastLex; } @@ -6001,16 +5742,13 @@ parse: function parse(input) { - - - - // handle parse error +// handle parse error if (!action) { // first see if there's any chance at hitting an error recovery rule: - var error_rule_depth = locateNearestErrorRecoveryRule(state); - var errStr = null; - var errSymbolDescr = (this.describeSymbol(symbol) || symbol); - var expected = this.collect_expected_token_set(state); + let error_rule_depth = locateNearestErrorRecoveryRule(state); + let errStr = null; + let errSymbolDescr = (this.describeSymbol(symbol) || symbol); + let expected = this.collect_expected_token_set(state); if (!recovering) { // Report error @@ -6044,9 +5782,7 @@ parse: function parse(input) { - - - r = this.parseError(p.errStr, p, this.JisonParserError); +r = this.parseError(p.errStr, p, this.JisonParserError); if (typeof r !== 'undefined') { retval = r; break; @@ -6069,9 +5805,7 @@ parse: function parse(input) { - - - var esp = recoveringErrorInfo.info_stack_pointer; +let esp = recoveringErrorInfo.info_stack_pointer; // just recovered from another error if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) { @@ -6098,17 +5832,16 @@ parse: function parse(input) { - - } +} // try to recover from error if (error_rule_depth < 0) { - ASSERT(recovering > 0, "line 897"); + ASSERT(recovering > 0, 'Line 1048'); recoveringErrorInfo.info_stack_pointer = esp; // barf a fatal hairball when we're out of look-ahead symbols and none hit a match // while we are still busy recovering from another error: - var po = this.__error_infos[this.__error_infos.length - 1]; + let po = this.__error_infos[this.__error_infos.length - 1]; // Report error if (typeof lexer.yylineno === 'number') { @@ -6155,8 +5888,8 @@ parse: function parse(input) { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, - errStr: errStr, - errorSymbolDescr: errSymbolDescr, + errStr, + errSymbolDescr, expectedStr: expected, stackSampleLength: error_rule_depth + EXTRA_STACK_SAMPLE_DEPTH }; @@ -6168,8 +5901,7 @@ parse: function parse(input) { - - } else { +} else { recoveringErrorInfo.value_stack[esp] = { yytext: this.copy_yytext(lexer.yytext), errorRuleDepth: error_rule_depth, @@ -6187,6 +5919,7 @@ parse: function parse(input) { yyrulelen = error_rule_depth; + let combineState = NO_ACTION[1]; @@ -6195,7 +5928,7 @@ parse: function parse(input) { - r = this.performAction.call(yyval, yyloc, NO_ACTION[1], sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, combineState, sp - 1, vstack, lstack); if (typeof r !== 'undefined') { retval = r; @@ -6206,7 +5939,7 @@ parse: function parse(input) { sp -= yyrulelen; // and move the top entries + discarded part of the parse stacks onto the error info stack: - for (var idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { + for (let idx = sp - EXTRA_STACK_SAMPLE_DEPTH, top = idx + yyrulelen; idx < top; idx++, esp++) { recoveringErrorInfo.symbol_stack[esp] = stack[idx]; recoveringErrorInfo.value_stack[esp] = vstack[idx]; recoveringErrorInfo.location_stack[esp] = lstack[idx]; @@ -6266,10 +5999,10 @@ parse: function parse(input) { // only a single parse loop, which handles everything. Our goal is // to eke out every drop of performance in the main parse loop... - ASSERT(recoveringErrorInfo, "line 1049"); - ASSERT(symbol === TERROR, "line 1050"); - ASSERT(!action, "line 1051"); - var errorSymbolFromParser = true; + ASSERT(recoveringErrorInfo, 'Line 1204'); + ASSERT(symbol === TERROR, 'Line 1205'); + ASSERT(!action, 'Line 1206'); + let errorSymbolFromParser = true; for (;;) { // retrieve state number from top of stack state = newState; // sstack[sp - 1]; @@ -6304,9 +6037,7 @@ parse: function parse(input) { - - - // encountered another parse error? If so, break out to main loop +// encountered another parse error? If so, break out to main loop // and take it from there! if (!action) { @@ -6319,7 +6050,7 @@ parse: function parse(input) { - ASSERT(recoveringErrorInfo, "line 1087"); + ASSERT(recoveringErrorInfo, 'Line 1248'); // Prep state variables so that upon breaking out of // this "slow parse loop" and hitting the `continue;` @@ -6340,9 +6071,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -6364,12 +6093,12 @@ parse: function parse(input) { // Push a special value onto the stack when we're // shifting the `error` symbol that is related to the // error we're recovering from. - ASSERT(recoveringErrorInfo, "line 1131"); + ASSERT(recoveringErrorInfo, 'Line 1305'); vstack[sp] = recoveringErrorInfo; lstack[sp] = this.yyMergeLocationInfo(null, null, recoveringErrorInfo.loc, lexer.yylloc, true); } else { - ASSERT(symbol !== 0, "line 1135"); - ASSERT(preErrorSymbol === 0, "line 1136"); + ASSERT(symbol !== 0, 'Line 1309'); + ASSERT(preErrorSymbol === 0, 'Line 1310'); vstack[sp] = lexer.yytext; lstack[sp] = this.copy_yylloc(lexer.yylloc); } @@ -6378,7 +6107,7 @@ parse: function parse(input) { ++sp; if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -6419,7 +6148,7 @@ parse: function parse(input) { } } else { // error just occurred, resume old lookahead f/ before error, *unless* that drops us straight back into error mode: - ASSERT(recovering > 0, "line 1163"); + ASSERT(recovering > 0, 'Line 1352'); symbol = preErrorSymbol; preErrorSymbol = 0; @@ -6466,7 +6195,7 @@ parse: function parse(input) { // while the error symbol hasn't been shifted onto // the stack yet. Hence we only exit this "slow parse loop" // when *both* conditions are met! - ASSERT(preErrorSymbol === 0, "line 1194"); + ASSERT(preErrorSymbol === 0, 'Line 1383'); if (recovering === 0) { break; } @@ -6484,21 +6213,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -6532,14 +6259,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -6549,6 +6277,7 @@ parse: function parse(input) { + } continue; // accept: @@ -6600,7 +6329,7 @@ parse: function parse(input) { // i.e. did the parser already produce a parse result in here?! // *or* did we hit an unsupported parse state, to be handled // in the `switch/default` code further below? - ASSERT(action !== 2, "line 1272"); + ASSERT(action !== 2, 'Line 1509'); if (!action || action === 1) { continue; } @@ -6616,9 +6345,7 @@ parse: function parse(input) { - - - switch (action) { +switch (action) { // catch misc. parse failures: default: // this shouldn't happen, unless resolve defaults are off @@ -6647,7 +6374,7 @@ parse: function parse(input) { sstack[sp] = newState; // push state if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var tokenName = this.getSymbolName(symbol || EOF); + let tokenName = this.getSymbolName(symbol || EOF); if (!tokenName) { tokenName = symbol; } @@ -6664,8 +6391,8 @@ parse: function parse(input) { symbol = 0; - ASSERT(preErrorSymbol === 0, "line 1352"); // normal execution / no error - ASSERT(recovering === 0, "line 1353"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1619'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1620'); // normal execution / no error // Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more: @@ -6676,8 +6403,8 @@ parse: function parse(input) { // reduce: case 2: - ASSERT(preErrorSymbol === 0, "line 1364"); // normal execution / no error - ASSERT(recovering === 0, "line 1365"); // normal execution / no error + ASSERT(preErrorSymbol === 0, 'Line 1631'); // normal execution / no error + ASSERT(recovering === 0, 'Line 1632'); // normal execution / no error this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards... yyrulelen = this_production[1]; @@ -6689,21 +6416,19 @@ parse: function parse(input) { - - - r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); +r = this.performAction.call(yyval, yyloc, newState, sp - 1, vstack, lstack); if (typeof Jison !== 'undefined' && Jison.parserDebugger) { - var prereduceValue = vstack.slice(sp - yyrulelen, sp); - var debuggableProductions = []; - for (var debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { - var debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); + let prereduceValue = vstack.slice(sp - yyrulelen, sp); + let debuggableProductions = []; + for (let debugIdx = yyrulelen - 1; debugIdx >= 0; debugIdx--) { + let debuggableProduction = getNonTerminalFromCode(stack[sp - debugIdx]); debuggableProductions.push(debuggableProduction); } // find the current nonterminal name (- nolan) - var currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; - var currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); + let currentNonterminalCode = this_production[0]; // WARNING: nolan's original code takes this one instead: this.productions_[newState][0]; + let currentNonterminal = getNonTerminalFromCode(currentNonterminalCode); Jison.parserDebugger.push({ action: 'reduce', @@ -6734,14 +6459,15 @@ parse: function parse(input) { sp -= yyrulelen; // don't overwrite the `symbol` variable: use a local var to speed things up: - var ntsymbol = this_production[0]; // push nonterminal (reduce) - stack[sp] = ntsymbol; - vstack[sp] = yyval.$; - lstack[sp] = yyval._$; - // goto new state = table[STATE][NONTERMINAL] - newState = table[sstack[sp - 1]][ntsymbol]; - sstack[sp] = newState; - ++sp; + { + let ntsymbol = this_production[0]; // push nonterminal (reduce) + stack[sp] = ntsymbol; + vstack[sp] = yyval.$; + lstack[sp] = yyval._$; + // goto new state = table[STATE][NONTERMINAL] + newState = table[sstack[sp - 1]][ntsymbol]; + sstack[sp] = newState; + ++sp; @@ -6751,6 +6477,7 @@ parse: function parse(input) { + } continue; // accept: @@ -6803,8 +6530,7 @@ parse: function parse(input) { // if it is a known parser or lexer error which has been thrown by parseError() already: if (ex instanceof this.JisonParserError) { throw ex; - } - else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { + } else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) { throw ex; } @@ -7066,8 +6792,6 @@ var lexer = function() { * @nocollapse */ function JisonLexerError(msg, hash) { - 'use strict'; - Object.defineProperty(this, 'name', { enumerable: false, writable: false, @@ -7084,10 +6808,10 @@ var lexer = function() { }); this.hash = hash; - var stacktrace; + let stacktrace; if (hash && hash.exception instanceof Error) { - var ex2 = hash.exception; + const ex2 = hash.exception; this.message = ex2.message || msg; stacktrace = ex2.stack; } @@ -7119,7 +6843,7 @@ var lexer = function() { JisonLexerError.prototype.constructor = JisonLexerError; JisonLexerError.prototype.name = 'JisonLexerError'; - var lexer = { + const lexer = { // Code Generator Information Report // --------------------------------- @@ -7161,7 +6885,9 @@ var lexer = function() { // // --------- END OF REPORT ----------- -EOF: 1, + + EOF: 1, + ERROR: 2, // JisonLexerError: JisonLexerError, /// <-- injected by the code generator @@ -7237,7 +6963,6 @@ EOF: 1, * @this {RegExpLexer} */ constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) { - 'use strict'; msg = '' + msg; // heuristic to determine if the error message already contains a (partial) source code dump @@ -7248,7 +6973,7 @@ EOF: 1, if (this.yylloc && show_input_position) { if (typeof this.prettyPrintRange === 'function') { - var pretty_src = this.prettyPrintRange(this.yylloc); + const pretty_src = this.prettyPrintRange(this.yylloc); if (!/\n\s*$/.test(msg)) { msg += '\n'; @@ -7256,7 +6981,7 @@ EOF: 1, msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc); } else if (typeof this.showPosition === 'function') { - var pos_str = this.showPosition(); + const pos_str = this.showPosition(); if (pos_str) { if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') { @@ -7269,7 +6994,7 @@ EOF: 1, } /** @constructor */ - var pei = { + const pei = { errStr: msg, recoverable: !!recoverable, @@ -7299,11 +7024,9 @@ EOF: 1, // info.yy = null; // info.lexer = null; // ... - 'use strict'; + const rec = !!this.recoverable; - var rec = !!this.recoverable; - - for (var key in this) { + for (let key in this) { if (this[key] && this.hasOwnProperty(key) && typeof this[key] === 'object') { this[key] = undefined; } @@ -7326,8 +7049,6 @@ EOF: 1, * @this {RegExpLexer} */ parseError: function lexer_parseError(str, hash, ExceptionClass) { - 'use strict'; - if (!ExceptionClass) { ExceptionClass = this.JisonLexerError; } @@ -7350,17 +7071,16 @@ EOF: 1, * @this {RegExpLexer} */ yyerror: function yyError(str /*, ...args */) { - 'use strict'; - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); + const p = this.constructLexErrorInfo(lineno_msg + ': ' + str, this.options.lexerErrorsAreRecoverable); // Add any extra args to the hash under the name `extra_error_attributes`: - var args = Array.prototype.slice.call(arguments, 1); + let args = Array.prototype.slice.call(arguments, 1); if (args.length) { p.extra_error_attributes = args; @@ -7382,8 +7102,6 @@ EOF: 1, * @this {RegExpLexer} */ cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) { - 'use strict'; - // prevent lingering circular references from causing memory leaks: this.setInput('', {}); @@ -7391,8 +7109,8 @@ EOF: 1, // Userland code must COPY any data/references // in the error hash instance(s) it is more permanently interested in. if (!do_not_nuke_errorinfos) { - for (var i = this.__error_infos.length - 1; i >= 0; i--) { - var el = this.__error_infos[i]; + for (let i = this.__error_infos.length - 1; i >= 0; i--) { + let el = this.__error_infos[i]; if (el && typeof el.destroy === 'function') { el.destroy(); @@ -7412,7 +7130,6 @@ EOF: 1, * @this {RegExpLexer} */ clear: function lexer_clear() { - 'use strict'; this.yytext = ''; this.yyleng = 0; this.match = ''; @@ -7422,7 +7139,7 @@ EOF: 1, this._more = false; this._backtrack = false; - var col = this.yylloc.last_column; + const col = this.yylloc.last_column; this.yylloc = { first_line: this.yylineno + 1, @@ -7440,7 +7157,6 @@ EOF: 1, * @this {RegExpLexer} */ setInput: function lexer_setInput(input, yy) { - 'use strict'; this.yy = yy || this.yy || {}; // also check if we've fully initialized the lexer instance, @@ -7448,7 +7164,7 @@ EOF: 1, // lexer to a usable lexer: if (!this.__decompressed) { // step 1: decompress the regex list: - var rules = this.rules; + let rules = this.rules; for (var i = 0, len = rules.length; i < len; i++) { var rule_re = rules[i]; @@ -7460,17 +7176,17 @@ EOF: 1, } // step 2: unfold the conditions[] set to make these ready for use: - var conditions = this.conditions; + let conditions = this.conditions; - for (var k in conditions) { - var spec = conditions[k]; - var rule_ids = spec.rules; + for (let k in conditions) { + let spec = conditions[k]; + let rule_ids = spec.rules; var len = rule_ids.length; - var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! - var rule_new_ids = new Array(len + 1); + let rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple! + let rule_new_ids = new Array(len + 1); for (var i = 0; i < len; i++) { - var idx = rule_ids[i]; + let idx = rule_ids[i]; var rule_re = rules[idx]; rule_regexes[i + 1] = rule_re; rule_new_ids[i + 1] = idx; @@ -7564,8 +7280,7 @@ EOF: 1, * @this {RegExpLexer} */ editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) { - 'use strict'; - var rv = callback.call(this, this._input, cpsArg); + const rv = callback.call(this, this._input, cpsArg); if (typeof rv !== 'string') { if (rv) { @@ -7586,8 +7301,6 @@ EOF: 1, * @this {RegExpLexer} */ input: function lexer_input() { - 'use strict'; - if (!this._input) { //this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*) return null; @@ -7598,7 +7311,7 @@ EOF: 1, this.clear(); } - var ch = this._input[0]; + let ch = this._input[0]; this.yytext += ch; this.yyleng++; this.offset++; @@ -7609,15 +7322,15 @@ EOF: 1, // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only. - var slice_len = 1; + let slice_len = 1; - var lines = false; + let lines = false; if (ch === '\n') { lines = true; } else if (ch === '\r') { lines = true; - var ch2 = this._input[1]; + const ch2 = this._input[1]; if (ch2 === '\n') { slice_len++; @@ -7651,9 +7364,8 @@ EOF: 1, * @this {RegExpLexer} */ unput: function lexer_unput(ch) { - 'use strict'; - var len = ch.length; - var lines = ch.split(this.CRLF_Re); + let len = ch.length; + let lines = ch.split(this.CRLF_Re); if (!this._clear_state && !this._more) { this._clear_state = -1; @@ -7686,9 +7398,9 @@ EOF: 1, // Get last entirely matched line into the `pre_lines[]` array's // last index slot; we don't mind when other previously // matched lines end up in the array too. - var pre = this.match; + let pre = this.match; - var pre_lines = pre.split(this.CRLF_Re); + let pre_lines = pre.split(this.CRLF_Re); if (pre_lines.length === 1) { pre = this.matched; @@ -7707,9 +7419,9 @@ EOF: 1, /** * return the upcoming input *which has not been lexed yet*. - * This can, for example, be used for custom look-ahead inspection code + * This can, for example, be used for custom look-ahead inspection code * in your lexer. - * + * * The entire pending input string is returned. * * > ### NOTE ### @@ -7719,13 +7431,12 @@ EOF: 1, * > features for limited input extraction and which includes the * > part of the input which has been lexed by the last token a.k.a. * > the *currently lexed* input. - * > - * + * > + * * @public * @this {RegExpLexer} */ lookAhead: function lexer_lookAhead() { - 'use strict'; return this._input || ''; }, @@ -7736,7 +7447,6 @@ EOF: 1, * @this {RegExpLexer} */ more: function lexer_more() { - 'use strict'; this._more = true; return this; }, @@ -7749,21 +7459,19 @@ EOF: 1, * @this {RegExpLexer} */ reject: function lexer_reject() { - 'use strict'; - if (this.options.backtrack_lexer) { this._backtrack = true; } else { // when the `parseError()` call returns, we MUST ensure that the error is registered. // We accomplish this by signaling an 'error' token to be produced for the current // `.lex()` run. - var lineno_msg = 'Lexical error'; + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).', false ); @@ -7781,7 +7489,6 @@ EOF: 1, * @this {RegExpLexer} */ less: function lexer_less(n) { - 'use strict'; return this.unput(this.match.slice(n)); }, @@ -7804,18 +7511,19 @@ EOF: 1, * @this {RegExpLexer} */ pastInput: function lexer_pastInput(maxSize, maxLines) { - 'use strict'; - var past = this.matched.substring(0, this.matched.length - this.match.length); + let past = this.matched.substring(0, this.matched.length - this.match.length); - if (maxSize < 0) + if (maxSize < 0) { maxSize = Infinity; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = Infinity; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = Infinity; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substr` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -7824,7 +7532,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = past.split(this.CRLF_Re); + let a = past.split(this.CRLF_Re); a = a.slice(-maxLines); past = a.join('\n'); @@ -7839,8 +7547,8 @@ EOF: 1, }, /** - * return (part of the) upcoming input *including* the input - * matched by the last token (see also the NOTE below). + * return (part of the) upcoming input *including* the input + * matched by the last token (see also the NOTE below). * This can be used to augment error messages, for example. * * Limit the returned string length to `maxSize` (default: 20). @@ -7866,25 +7574,26 @@ EOF: 1, * > to the input *which has not been lexed yet* for look-ahead * > inspection or likewise purposes, please consider using the * > `lookAhead()` API instead. - * > - * + * > + * * @public * @this {RegExpLexer} */ upcomingInput: function lexer_upcomingInput(maxSize, maxLines) { - 'use strict'; - var next = this.match; - var source = this._input || ''; + let next = this.match; + let source = this._input || ''; - if (maxSize < 0) + if (maxSize < 0) { maxSize = next.length + source.length; - else if (!maxSize) + } else if (!maxSize) { maxSize = 20; + } - if (maxLines < 0) - maxLines = maxSize; // can't ever have more input lines than this!; - else if (!maxLines) + if (maxLines < 0) { + maxLines = maxSize; // can't ever have more input lines than this! + } else if (!maxLines) { maxLines = 1; + } // `substring` anticipation: treat \r\n as a single character and take a little // more than necessary so that we can still properly check against maxSize @@ -7895,7 +7604,7 @@ EOF: 1, // now that we have a significantly reduced string to process, transform the newlines // and chop them, then limit them: - var a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. + let a = next.split(this.CRLF_Re, maxLines + 1); // stop splitting once we have reached just beyond the reuired number of lines. a = a.slice(0, maxLines); next = a.join('\n'); @@ -7917,9 +7626,8 @@ EOF: 1, * @this {RegExpLexer} */ showPosition: function lexer_showPosition(maxPrefix, maxPostfix) { - 'use strict'; - var pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); - var c = new Array(pre.length + 1).join('-'); + const pre = this.pastInput(maxPrefix).replace(/\s/g, ' '); + let c = new Array(pre.length + 1).join('-'); return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^'; }, @@ -7941,9 +7649,7 @@ EOF: 1, * @this {RegExpLexer} */ deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) { - 'use strict'; - - var loc = { + let loc = { first_line: 1, first_column: 0, last_line: 1, @@ -8083,27 +7789,25 @@ EOF: 1, * @this {RegExpLexer} */ prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) { - 'use strict'; loc = this.deriveLocationInfo(loc, context_loc, context_loc2); const CONTEXT = 3; const CONTEXT_TAIL = 1; const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2; - var input = this.matched + (this._input || ''); - var lines = input.split('\n'); - var l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); - var l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); - var lineno_display_width = 1 + Math.log10(l1 | 1) | 0; - var ws_prefix = new Array(lineno_display_width).join(' '); - var nonempty_line_indexes = [[], [], []]; - - var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { - 'use strict'; - var lno = index + l0; - var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); - var rv = lno_pfx + ': ' + line; - var errpfx = new Array(lineno_display_width + 1).join('^'); - var offset = 2 + 1; - var len = 0; + let input = this.matched + (this._input || ''); + let lines = input.split('\n'); + let l0 = Math.max(1, context_loc ? context_loc.first_line : loc.first_line - CONTEXT); + let l1 = Math.max(1, context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL); + let lineno_display_width = 1 + Math.log10(l1 | 1) | 0; + let ws_prefix = new Array(lineno_display_width).join(' '); + let nonempty_line_indexes = [[], [], []]; + + let rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) { + let lno = index + l0; + let lno_pfx = (ws_prefix + lno).substr(-lineno_display_width); + let rv = lno_pfx + ': ' + line; + let errpfx = new Array(lineno_display_width + 1).join('^'); + let offset = 2 + 1; + let len = 0; if (lno === loc.first_line) { offset += loc.first_column; @@ -8118,11 +7822,11 @@ EOF: 1, len = Math.max(2, line.length + 1); } - var nli; + let nli; if (len) { - var lead = new Array(offset).join('.'); - var mark = new Array(len).join('^'); + let lead = new Array(offset).join('.'); + let mark = new Array(len).join('^'); rv += '\n' + errpfx + lead + mark; nli = 1; } else if (lno < loc.first_line) { @@ -8141,13 +7845,13 @@ EOF: 1, // now make sure we don't print an overly large amount of lead/error/tail area: limit it // to the top and bottom line count: - for (var i = 0; i <= 2; i++) { - var line_arr = nonempty_line_indexes[i]; + for (let i = 0; i <= 2; i++) { + let line_arr = nonempty_line_indexes[i]; if (line_arr.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) { - var clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; - var clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; - var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; + let clip_start = line_arr[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1; + let clip_end = line_arr[line_arr.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1; + let intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)'; if (i === 1) { intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)'; @@ -8171,14 +7875,13 @@ EOF: 1, * @this {RegExpLexer} */ describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) { - 'use strict'; - var l1 = yylloc.first_line; - var l2 = yylloc.last_line; - var c1 = yylloc.first_column; - var c2 = yylloc.last_column; - var dl = l2 - l1; - var dc = c2 - c1; - var rv; + let l1 = yylloc.first_line; + let l2 = yylloc.last_line; + let c1 = yylloc.first_column; + let c2 = yylloc.last_column; + let dl = l2 - l1; + let dc = c2 - c1; + let rv; if (dl === 0) { rv = 'line ' + l1 + ', '; @@ -8193,8 +7896,8 @@ EOF: 1, } if (yylloc.range && display_range_too) { - var r1 = yylloc.range[0]; - var r2 = yylloc.range[1] - 1; + let r1 = yylloc.range[0]; + let r2 = yylloc.range[1] - 1; if (r2 <= r1) { rv += ' {String Offset: ' + r1 + '}'; @@ -8225,8 +7928,7 @@ EOF: 1, * @this {RegExpLexer} */ test_match: function lexer_test_match(match, indexed_rule) { - 'use strict'; - var token, lines, backup, match_str, match_str_len; + let backup; if (this.options.backtrack_lexer) { // save context @@ -8258,9 +7960,9 @@ EOF: 1, }; } - match_str = match[0]; - match_str_len = match_str.length; - lines = match_str.split(this.CRLF_Re); + let match_str = match[0]; + let match_str_len = match_str.length; + let lines = match_str.split(this.CRLF_Re); if (lines.length > 1) { this.yylineno += lines.length - 1; @@ -8289,7 +7991,7 @@ EOF: 1, // calling this method: // // function lexer__performAction(yy, yyrulenumber, YY_START) {...} - token = this.performAction.call( + let token = this.performAction.call( this, this.yy, indexed_rule, @@ -8307,7 +8009,7 @@ EOF: 1, return token; } else if (this._backtrack) { // recover context - for (var k in backup) { + for (let k in backup) { this[k] = backup[k]; } @@ -8332,8 +8034,6 @@ EOF: 1, * @this {RegExpLexer} */ next: function lexer_next() { - 'use strict'; - if (this.done) { this.clear(); return this.EOF; @@ -8343,8 +8043,6 @@ EOF: 1, this.done = true; } - var token, match, tempMatch, index; - if (!this._more) { if (!this._clear_state) { this._clear_state = 1; @@ -8353,7 +8051,7 @@ EOF: 1, this.clear(); } - 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. @@ -8365,13 +8063,13 @@ EOF: 1, // Check whether a *sane* condition has been pushed before: this makes the lexer robust against // user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19 if (!spec || !spec.rules) { - var lineno_msg = ''; + let lineno_msg = ''; if (this.yylloc) { lineno_msg = ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( 'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!', false ); @@ -8381,68 +8079,74 @@ EOF: 1, } } - var rule_ids = spec.rules; - var regexes = spec.__rule_regexes; - var len = spec.__rule_count; - - // 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 (var i = 1; i <= len; i++) { - tempMatch = this._input.match(regexes[i]); + { + let rule_ids = spec.rules; + let regexes = spec.__rule_regexes; + let len = spec.__rule_count; + let match; + let index; - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rule_ids[i]); - - if (token !== false) { - return token; - } else if (this._backtrack) { - match = undefined; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // 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 (let i = 1; i <= len; i++) { + let tempMatch = this._input.match(regexes[i]); + + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + + if (this.options.backtrack_lexer) { + let token = this.test_match(tempMatch, rule_ids[i]); + + if (token !== false) { + return token; + } else if (this._backtrack) { + match = undefined; + continue; // rule action called reject() implying a rule MISmatch. + } else { + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } + } else if (!this.options.flex) { + break; } - } else if (!this.options.flex) { - break; } } - } - if (match) { - token = this.test_match(match, rule_ids[index]); + if (match) { + let token = this.test_match(match, rule_ids[index]); - if (token !== false) { - return token; - } + if (token !== false) { + return token; + } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; + // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) + return false; + } } if (!this._input) { this.done = true; this.clear(); return this.EOF; - } else { - var lineno_msg = 'Lexical error'; + } + + { + let lineno_msg = 'Lexical error'; if (this.yylloc) { lineno_msg += ' on line ' + (this.yylineno + 1); } - var p = this.constructLexErrorInfo( + const p = this.constructLexErrorInfo( lineno_msg + ': Unrecognized text.', this.options.lexerErrorsAreRecoverable ); - var pendingInput = this._input; - var activeCondition = this.topState(); - var conditionStackDepth = this.conditionStack.length; - token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; + let pendingInput = this._input; + let activeCondition = this.topState(); + let conditionStackDepth = this.conditionStack.length; + let token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR; if (token === this.ERROR) { // we can try to recover from a lexer error that `parseError()` did not 'recover' for us @@ -8467,8 +8171,7 @@ EOF: 1, * @this {RegExpLexer} */ lex: function lexer_lex() { - 'use strict'; - var r; + let r; //this._clear_state = 0; @@ -8516,24 +8219,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -8553,8 +8256,7 @@ EOF: 1, * @this {RegExpLexer} */ fastLex: function lexer_fastLex() { - 'use strict'; - var r; + let r; //this._clear_state = 0; @@ -8564,24 +8266,24 @@ EOF: 1, if (!this._more) { // - // 1) make sure any outside interference is detected ASAP: + // 1) make sure any outside interference is detected ASAP: // these attributes are to be treated as 'const' values // once the lexer has produced them with the token (return value `r`). // 2) make sure any subsequent `lex()` API invocation CANNOT // edit the `yytext`, etc. token attributes for the *current* // token, i.e. provide a degree of 'closure safety' so that // code like this: - // + // // t1 = lexer.lex(); // v = lexer.yytext; // l = lexer.yylloc; // t2 = lexer.lex(); // assert(lexer.yytext !== v); // assert(lexer.yylloc !== l); - // + // // succeeds. Older (pre-v0.6.5) jison versions did not *guarantee* // these conditions. - // + // this.yytext = Object.freeze(this.yytext); this.matches = Object.freeze(this.matches); @@ -8602,9 +8304,7 @@ EOF: 1, * @this {RegExpLexer} */ canIUse: function lexer_canIUse() { - 'use strict'; - - var rv = { + const rv = { fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function' }; @@ -8620,7 +8320,6 @@ EOF: 1, * @this {RegExpLexer} */ begin: function lexer_begin(condition) { - 'use strict'; return this.pushState(condition); }, @@ -8632,7 +8331,6 @@ EOF: 1, * @this {RegExpLexer} */ pushState: function lexer_pushState(condition) { - 'use strict'; this.conditionStack.push(condition); this.__currentRuleSet__ = null; return this; @@ -8646,15 +8344,14 @@ EOF: 1, * @this {RegExpLexer} */ popState: function lexer_popState() { - 'use strict'; - var n = this.conditionStack.length - 1; + const n = this.conditionStack.length - 1; if (n > 0) { this.__currentRuleSet__ = null; return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; } + + return this.conditionStack[0]; }, /** @@ -8666,14 +8363,13 @@ EOF: 1, * @this {RegExpLexer} */ topState: function lexer_topState(n) { - 'use strict'; n = this.conditionStack.length - 1 - Math.abs(n || 0); if (n >= 0) { return this.conditionStack[n]; - } else { - return 'INITIAL'; } + + return 'INITIAL'; }, /** @@ -8684,9 +8380,8 @@ EOF: 1, * @this {RegExpLexer} */ _currentRules: function lexer__currentRules() { - 'use strict'; - var n = this.conditionStack.length - 1; - var state; + const n = this.conditionStack.length - 1; + let state; if (n >= 0) { state = this.conditionStack[n]; @@ -8694,7 +8389,7 @@ EOF: 1, state = 'INITIAL'; } - return this.conditions[state] || this.conditions['INITIAL']; + return this.conditions[state] || this.conditions.INITIAL; }, /** @@ -8704,7 +8399,6 @@ EOF: 1, * @this {RegExpLexer} */ stateStackSize: function lexer_stateStackSize() { - 'use strict'; return this.conditionStack.length; }, 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 85bf72a09..4e5217282 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,13 +117,13 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^ 3: return true; 4: }} - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6105:13) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7628:19) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_lex [as lex] (/lex-parser-cjs-es5.js:7168:18) - at Context.testEachParserExample (/all-tests.js:221:27) + 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 Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 597ac9095..96c9e3b8d 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,17 +30,17 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^ 3: return true; 4: }} - at Object.parseError (/lex-parser-cjs-es5.js:4247:13) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6099:44) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7628:19) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs-es5.js:7227:18) - at fastLex (/lex-parser-cjs-es5.js:4825:25) - at Object.parse (/lex-parser-cjs-es5.js:4960:22) - at Object.yyparse [as parse] (/lex-parser-cjs-es5.js:8992:23) - at Context.testEachParserExample (/all-tests.js:323:19) + 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 Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 d25416b21..8f3c4656b 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,13 +117,13 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^ 3: return true; 4: %}} - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6105:13) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7628:19) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_lex [as lex] (/lex-parser-cjs-es5.js:7168:18) - at Context.testEachParserExample (/all-tests.js:221:27) + 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 Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 21bb10b67..9fd8424e4 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,17 +30,17 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^ 3: return true; 4: %}} - at Object.parseError (/lex-parser-cjs-es5.js:4247:13) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6099:44) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7628:19) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs-es5.js:7227:18) - at fastLex (/lex-parser-cjs-es5.js:4825:25) - at Object.parse (/lex-parser-cjs-es5.js:4960:22) - at Object.yyparse [as parse] (/lex-parser-cjs-es5.js:8992:23) - at Context.testEachParserExample (/all-tests.js:323:19) + 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 Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 659d19e2a..45539d6dc 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,13 +172,13 @@ to help jison grok more or less complex action code chunks. ^.....^ 5: 6: - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6105:13) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7520:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_lex [as lex] (/lex-parser-cjs-es5.js:7168:18) - at Context.testEachParserExample (/all-tests.js:221:27) + 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 Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 abf10473f..1019181b5 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,17 +38,17 @@ to help jison grok more or less complex action code chunks. ^.....^ 5: 6: - at Object.parseError (/lex-parser-cjs-es5.js:4247:13) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6099:44) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7520:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs-es5.js:7227:18) - at fastLex (/lex-parser-cjs-es5.js:4825:25) - at Object.parse (/lex-parser-cjs-es5.js:4960:22) - at Object.yyparse [as parse] (/lex-parser-cjs-es5.js:8992:23) - at Context.testEachParserExample (/all-tests.js:323:19) + 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 Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 59a7e85eb..794454b78 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,13 +172,13 @@ to help jison grok more or less complex action code chunks. ^...^ 6: 7: - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6105:13) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7520:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_lex [as lex] (/lex-parser-cjs-es5.js:7168:18) - at Context.testEachParserExample (/all-tests.js:221:27) + 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 Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 81b05aa68..3eea96021 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,17 +39,17 @@ to help jison grok more or less complex action code chunks. ^...^ 6: 7: - at Object.parseError (/lex-parser-cjs-es5.js:4247:13) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6099:44) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7520:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs-es5.js:7227:18) - at fastLex (/lex-parser-cjs-es5.js:4825:25) - at Object.parse (/lex-parser-cjs-es5.js:4960:22) - at Object.yyparse [as parse] (/lex-parser-cjs-es5.js:8992:23) - at Context.testEachParserExample (/all-tests.js:323:19) + 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 Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 0bf549928..88a901ec3 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,12 +65,12 @@ 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-es5.js:4247:13) - at Object.yyError (/lex-parser-cjs-es5.js:4427:21) - at Object.parser__PerformAction (/lex-parser-cjs-es5.js:2194:18) - at Object.parse (/lex-parser-cjs-es5.js:5325:42) - at Object.yyparse [as parse] (/lex-parser-cjs-es5.js:8992:23) - at Context.testEachParserExample (/all-tests.js:323:19) + 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 Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 8a449c5d7..acf8169ba 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,13 +114,13 @@ rules (i.e. jison lex regexes) in "rules" state. ^..........^ 3: return "%{..%}"; 4: }}}}}% - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6105:13) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:8128:15) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_lex [as lex] (/lex-parser-cjs-es5.js:7168:18) - at Context.testEachParserExample (/all-tests.js:221:27) + 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 Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 e89244517..886a603e5 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,17 +42,17 @@ rules (i.e. jison lex regexes) in "rules" state. ^..........^ 3: return "%{..%}"; 4: }}}}}% - at Object.parseError (/lex-parser-cjs-es5.js:4247:13) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6099:44) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:8128:15) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs-es5.js:7227:18) - at fastLex (/lex-parser-cjs-es5.js:4825:25) - at Object.parse (/lex-parser-cjs-es5.js:4960:22) - at Object.yyparse [as parse] (/lex-parser-cjs-es5.js:8992:23) - at Context.testEachParserExample (/all-tests.js:323:19) + 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 Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 3130a307c..eee46a5bf 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,13 +117,13 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^^^^^ 3: return "%{..%}"; 4: }}}}}% - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6105:13) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7628:19) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_lex [as lex] (/lex-parser-cjs-es5.js:7168:18) - at Context.testEachParserExample (/all-tests.js:221:27) + 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 Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 c7aa31916..459e2f28e 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,17 +31,17 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^^^^^ 3: return "%{..%}"; 4: }}}}}% - at Object.parseError (/lex-parser-cjs-es5.js:4247:13) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6099:44) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7628:19) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs-es5.js:7227:18) - at fastLex (/lex-parser-cjs-es5.js:4825:25) - at Object.parse (/lex-parser-cjs-es5.js:4960:22) - at Object.yyparse [as parse] (/lex-parser-cjs-es5.js:8992:23) - at Context.testEachParserExample (/all-tests.js:323:19) + 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 Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 fae8ade16..3684c8b73 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,12 +46,12 @@ Parse error on line 2: --^ Unexpected "ACTION_BODY" - at Object.parseError (/lex-parser-cjs-es5.js:4247:13) - at Object.yyError (/lex-parser-cjs-es5.js:4427:21) - at Object.parser__PerformAction (/lex-parser-cjs-es5.js:3016:20) - at Object.parse (/lex-parser-cjs-es5.js:5325:42) - at Object.yyparse [as parse] (/lex-parser-cjs-es5.js:8992:23) - at Context.testEachParserExample (/all-tests.js:323:19) + 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 Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 85bf72a09..4e5217282 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,13 +117,13 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^ 3: return true; 4: }} - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6105:13) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7628:19) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_lex [as lex] (/lex-parser-cjs-es5.js:7168:18) - at Context.testEachParserExample (/all-tests.js:221:27) + 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 Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 597ac9095..96c9e3b8d 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,17 +30,17 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^ 3: return true; 4: }} - at Object.parseError (/lex-parser-cjs-es5.js:4247:13) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6099:44) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7628:19) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs-es5.js:7227:18) - at fastLex (/lex-parser-cjs-es5.js:4825:25) - at Object.parse (/lex-parser-cjs-es5.js:4960:22) - at Object.yyparse [as parse] (/lex-parser-cjs-es5.js:8992:23) - at Context.testEachParserExample (/all-tests.js:323:19) + 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 Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 d25416b21..8f3c4656b 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,13 +117,13 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^ 3: return true; 4: %}} - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6105:13) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7628:19) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_lex [as lex] (/lex-parser-cjs-es5.js:7168:18) - at Context.testEachParserExample (/all-tests.js:221:27) + 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 Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 21bb10b67..9fd8424e4 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,17 +30,17 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^ 3: return true; 4: %}} - at Object.parseError (/lex-parser-cjs-es5.js:4247:13) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6099:44) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7628:19) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs-es5.js:7227:18) - at fastLex (/lex-parser-cjs-es5.js:4825:25) - at Object.parse (/lex-parser-cjs-es5.js:4960:22) - at Object.yyparse [as parse] (/lex-parser-cjs-es5.js:8992:23) - at Context.testEachParserExample (/all-tests.js:323:19) + 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 Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 659d19e2a..45539d6dc 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,13 +172,13 @@ to help jison grok more or less complex action code chunks. ^.....^ 5: 6: - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6105:13) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7520:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_lex [as lex] (/lex-parser-cjs-es5.js:7168:18) - at Context.testEachParserExample (/all-tests.js:221:27) + 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 Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 abf10473f..1019181b5 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,17 +38,17 @@ to help jison grok more or less complex action code chunks. ^.....^ 5: 6: - at Object.parseError (/lex-parser-cjs-es5.js:4247:13) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6099:44) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7520:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs-es5.js:7227:18) - at fastLex (/lex-parser-cjs-es5.js:4825:25) - at Object.parse (/lex-parser-cjs-es5.js:4960:22) - at Object.yyparse [as parse] (/lex-parser-cjs-es5.js:8992:23) - at Context.testEachParserExample (/all-tests.js:323:19) + 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 Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 59a7e85eb..794454b78 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,13 +172,13 @@ to help jison grok more or less complex action code chunks. ^...^ 6: 7: - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6105:13) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7520:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_lex [as lex] (/lex-parser-cjs-es5.js:7168:18) - at Context.testEachParserExample (/all-tests.js:221:27) + 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 Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 81b05aa68..3eea96021 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,17 +39,17 @@ to help jison grok more or less complex action code chunks. ^...^ 6: 7: - at Object.parseError (/lex-parser-cjs-es5.js:4247:13) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6099:44) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7520:17) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs-es5.js:7227:18) - at fastLex (/lex-parser-cjs-es5.js:4825:25) - at Object.parse (/lex-parser-cjs-es5.js:4960:22) - at Object.yyparse [as parse] (/lex-parser-cjs-es5.js:8992:23) - at Context.testEachParserExample (/all-tests.js:323:19) + 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 Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 0bf549928..88a901ec3 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,12 +65,12 @@ 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-es5.js:4247:13) - at Object.yyError (/lex-parser-cjs-es5.js:4427:21) - at Object.parser__PerformAction (/lex-parser-cjs-es5.js:2194:18) - at Object.parse (/lex-parser-cjs-es5.js:5325:42) - at Object.yyparse [as parse] (/lex-parser-cjs-es5.js:8992:23) - at Context.testEachParserExample (/all-tests.js:323:19) + 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 Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 8a449c5d7..acf8169ba 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,13 +114,13 @@ rules (i.e. jison lex regexes) in "rules" state. ^..........^ 3: return "%{..%}"; 4: }}}}}% - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6105:13) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:8128:15) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_lex [as lex] (/lex-parser-cjs-es5.js:7168:18) - at Context.testEachParserExample (/all-tests.js:221:27) + 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 Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 e89244517..886a603e5 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,17 +42,17 @@ rules (i.e. jison lex regexes) in "rules" state. ^..........^ 3: return "%{..%}"; 4: }}}}}% - at Object.parseError (/lex-parser-cjs-es5.js:4247:13) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6099:44) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:8128:15) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs-es5.js:7227:18) - at fastLex (/lex-parser-cjs-es5.js:4825:25) - at Object.parse (/lex-parser-cjs-es5.js:4960:22) - at Object.yyparse [as parse] (/lex-parser-cjs-es5.js:8992:23) - at Context.testEachParserExample (/all-tests.js:323:19) + 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 Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 3130a307c..eee46a5bf 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,13 +117,13 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^^^^^ 3: return "%{..%}"; 4: }}}}}% - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6105:13) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7628:19) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_lex [as lex] (/lex-parser-cjs-es5.js:7168:18) - at Context.testEachParserExample (/all-tests.js:221:27) + 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 Context.testEachParserExample (/all-tests.js:232:37) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 c7aa31916..459e2f28e 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,17 +31,17 @@ Regrettably, it does not exist in the remainder of the input. ^..............^^^^^^ 3: return "%{..%}"; 4: }}}}}% - at Object.parseError (/lex-parser-cjs-es5.js:4247:13) - at Object.lexer_parseError [as parseError] (/lex-parser-cjs-es5.js:6099:44) - at Object.yyError [as yyerror] (/lex-parser-cjs-es5.js:6131:19) - at Object.lexer__performAction [as performAction] (/lex-parser-cjs-es5.js:7628:19) - at Object.lexer_test_match [as test_match] (/lex-parser-cjs-es5.js:6982:34) - at Object.lexer_next [as next] (/lex-parser-cjs-es5.js:7092:22) - at Object.lexer_fastLex [as fastLex] (/lex-parser-cjs-es5.js:7227:18) - at fastLex (/lex-parser-cjs-es5.js:4825:25) - at Object.parse (/lex-parser-cjs-es5.js:4960:22) - at Object.yyparse [as parse] (/lex-parser-cjs-es5.js:8992:23) - at Context.testEachParserExample (/all-tests.js:323:19) + 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 Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10) 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 fae8ade16..3684c8b73 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,12 +46,12 @@ Parse error on line 2: --^ Unexpected "ACTION_BODY" - at Object.parseError (/lex-parser-cjs-es5.js:4247:13) - at Object.yyError (/lex-parser-cjs-es5.js:4427:21) - at Object.parser__PerformAction (/lex-parser-cjs-es5.js:3016:20) - at Object.parse (/lex-parser-cjs-es5.js:5325:42) - at Object.yyparse [as parse] (/lex-parser-cjs-es5.js:8992:23) - at Context.testEachParserExample (/all-tests.js:323:19) + 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 Context.testEachParserExample (/all-tests.js:336:27) at callFn (/runnable.js:364:21) at Test.Runnable.run (/runnable.js:352:5) at Runner.runTest (/runner.js:677:10)